MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / trim

Method trim

src/org/opensourcephysics/display/Stripchart.java:117–147  ·  view source on GitHub ↗

Trims data points whose x values are outside the xrange from the dataset.

()

Source from the content-addressed store, hash-verified

115 * Trims data points whose x values are outside the xrange from the dataset.
116 */
117 private void trim() {
118 if((index>0)&&(xpoints[0]<lastx-xrange)) {
119 int counter = 0;
120 while((counter<index)&&(xpoints[counter]<lastx-xrange)) {
121 counter++;
122 }
123 System.arraycopy(xpoints, counter, xpoints, 0, index-counter);
124 System.arraycopy(ypoints, counter, ypoints, 0, index-counter);
125 index = index-counter;
126 }
127 if(rightToLeft) {
128 xmin = lastx-xrange;
129 } else {
130 xmin = lastx;
131 }
132 if(rightToLeft) {
133 xmax = lastx;
134 } else {
135 xmax = lastx-xrange;
136 }
137 ymin = ymax = ypoints[0];
138 for(int i = 1; i<index; i++) {
139 ymin = Math.min(ymin, ypoints[i]);
140 ymax = Math.max(ymax, ypoints[i]);
141 }
142 if(ymax-ymin<yrange) {
143 ymin = (ymax+ymin-yrange)/2.0;
144 ymax = (ymax+ymin+yrange)/2.0;
145 }
146 recalculatePath();
147 }
148
149 /**
150 * Returns the XML.ObjectLoader for this class.

Callers 15

appendMethod · 0.95
mailMethod · 0.45
getMenuMethod · 0.45
removeMenuMethod · 0.45
removeMenuItemMethod · 0.45
readMethod · 0.45
parseDataMethod · 0.45
parseStringsMethod · 0.45
getUniqueYColumnNameMethod · 0.45
readMethod · 0.45
appendMethod · 0.45
drawMethod · 0.45

Calls 3

minMethod · 0.80
maxMethod · 0.80
recalculatePathMethod · 0.45

Tested by

no test coverage detected