Trims data points whose x values are outside the xrange from the dataset.
()
| 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. |
no test coverage detected