private void zoom(float scale) { final double domainSpan = maxXY.x - minXY.x; final double domainMidPoint = maxXY.x - domainSpan / 2.0f; final double offset = domainSpan * scale / 2.0f; minXY.x = domainMidPoint - offset; maxXY.x = domainMidPoint + offset; checkBoundaries(); }
private void scroll(float pan) { final double domainSpan = maxXY.x - minXY.x; final double step = domainSpan / graph.getWidth(); final double offset = pan * step; minXY.x += offset; maxXY.x += offset; if (minXY.x < absMinX) { minXY.x = absMinX; maxXY.x -= offset; // (absMinX-minXY.x); } else if (minXY.x > maxNoError) minXY.x = maxNoError; if (maxXY.x > absMaxX) { maxXY.x = absMaxX; // (maxXY.x-absMaxX); minXY.x -= offset; // (maxXY.x-absMaxX); } else if (maxXY.x < minNoError) maxXY.x = minNoError; if (maxXY.x - minXY.x < minDif) maxXY.x = maxXY.x + (double) (minDif - (maxXY.x - minXY.x)); graph.setDomainBoundaries(minXY.x, maxXY.x, BoundaryMode.FIXED); }
private void checkBoundaries() { // Make sure the proposed domain boundaries will not cause plotting issues if (minXY.x < absMinX || ((Double) minXY.x).equals(Double.NaN)) minXY.x = absMinX; else if (minXY.x > maxNoError) minXY.x = maxNoError; if (maxXY.x > absMaxX || ((Double) maxXY.x).equals(Double.NaN)) maxXY.x = absMaxX; else if (maxXY.x < minNoError) maxXY.x = minNoError; if (maxXY.x - minXY.x < minDif) maxXY.x = maxXY.x + (double) (minDif - (maxXY.x - minXY.x)); else if (maxXY.x - minXY.x > maxDif) maxXY.x = maxXY.x + (double) (maxDif - (maxXY.x - minXY.x)); graph.setDomainBoundaries(minXY.x, maxXY.x, BoundaryMode.FIXED); }