PanAndZoomManager { public void zoomAction(ZoomDirection zoomAction) { XYAxis xAxis = plot.getPlotView().getXAxis(); XYAxis yAxis = plot.getPlotView().getYAxis(); if (plot.getAxisOrientationSetting() == AxisOrientationSetting.X_AXIS_AS_TIME) { double nonTimeScaleZoomAmount = yAxis.getEnd() - yAxis.getStart(); double timeScaleZoomAmount = xAxis.getEnd() - xAxis.getStart(); timeScaleZoomAmount = (timeScaleZoomAmount/100) * PlotConstants.ZOOMING_TIME_AXIS_PERCENTAGE; nonTimeScaleZoomAmount= (nonTimeScaleZoomAmount/100) * PlotConstants.ZOOMING_TIME_AXIS_PERCENTAGE; if (zoomAction == ZoomDirection.ZOOM_IN_HIGH_Y_AXIS) { yAxis.setEnd(yAxis.getEnd() - nonTimeScaleZoomAmount); markNonTimeZoomed(); } else if (zoomAction == ZoomDirection.ZOOM_OUT_HIGH_Y_AXIS) { yAxis.setEnd(yAxis.getEnd() + nonTimeScaleZoomAmount); markNonTimeZoomed(); } else if (zoomAction == ZoomDirection.ZOOM_IN_CENTER_Y_AXIS) { yAxis.setStart(yAxis.getStart() + nonTimeScaleZoomAmount); yAxis.setEnd(yAxis.getEnd() - nonTimeScaleZoomAmount); markNonTimeZoomed(); } else if (zoomAction == ZoomDirection.ZOOM_OUT_CENTER_Y_AXIS) { yAxis.setStart(yAxis.getStart() - nonTimeScaleZoomAmount); yAxis.setEnd(yAxis.getEnd() + nonTimeScaleZoomAmount); markNonTimeZoomed(); } else if (zoomAction == ZoomDirection.ZOOM_IN_LOW_Y_AXIS) { yAxis.setStart(yAxis.getStart() + nonTimeScaleZoomAmount); markNonTimeZoomed(); } else if (zoomAction == ZoomDirection.ZOOM_OUT_LOW_Y_AXIS) { yAxis.setStart(yAxis.getStart() - nonTimeScaleZoomAmount); markNonTimeZoomed(); } else if (zoomAction == ZoomDirection.ZOOM_IN_LEFT_X_AXIS) { xAxis.setStart(xAxis.getStart() + timeScaleZoomAmount); markTimeZoomed(); plot.notifyObserversTimeChange(); } else if (zoomAction == ZoomDirection.ZOOM_OUT_LEFT_X_AXIS) { xAxis.setStart(xAxis.getStart() - timeScaleZoomAmount); markTimeZoomed(); plot.notifyObserversTimeChange(); } else if (zoomAction == ZoomDirection.ZOOM_IN_CENTER_X_AXIS) { xAxis.setStart(xAxis.getStart() + timeScaleZoomAmount); xAxis.setEnd(xAxis.getEnd() - timeScaleZoomAmount); markTimeZoomed(); plot.notifyObserversTimeChange(); } else if (zoomAction == ZoomDirection.ZOOM_OUT_CENTER_X_AXIS) { xAxis.setStart(xAxis.getStart() - timeScaleZoomAmount); xAxis.setEnd(xAxis.getEnd() + timeScaleZoomAmount); markTimeZoomed(); plot.notifyObserversTimeChange(); } else if (zoomAction == ZoomDirection.ZOOM_IN_RIGHT_X_AXIS) { xAxis.setEnd(xAxis.getEnd() - timeScaleZoomAmount); markTimeZoomed(); plot.notifyObserversTimeChange(); } else if (zoomAction == ZoomDirection.ZOOM_OUT_RIGHT_X_AXIS) { xAxis.setEnd(xAxis.getEnd() + timeScaleZoomAmount); markTimeZoomed(); plot.notifyObserversTimeChange(); } } else { double nonTimeScaleZoomAmount = xAxis.getEnd() - xAxis.getStart(); double timeScaleZoomAmount = yAxis.getEnd() - yAxis.getStart(); timeScaleZoomAmount = (timeScaleZoomAmount/100) * PlotConstants.ZOOMING_TIME_AXIS_PERCENTAGE; nonTimeScaleZoomAmount = (nonTimeScaleZoomAmount/100) * PlotConstants.ZOOMING_TIME_AXIS_PERCENTAGE; if (zoomAction == ZoomDirection.ZOOM_IN_HIGH_Y_AXIS) { yAxis.setEnd(yAxis.getEnd() - timeScaleZoomAmount); markTimeZoomed(); plot.notifyObserversTimeChange(); } else if (zoomAction == ZoomDirection.ZOOM_OUT_HIGH_Y_AXIS) { yAxis.setEnd(yAxis.getEnd() + timeScaleZoomAmount); markTimeZoomed(); plot.notifyObserversTimeChange(); } else if (zoomAction == ZoomDirection.ZOOM_IN_CENTER_Y_AXIS) { yAxis.setStart(yAxis.getStart() + timeScaleZoomAmount); yAxis.setEnd(yAxis.getEnd() - timeScaleZoomAmount); markTimeZoomed(); plot.notifyObserversTimeChange(); } else if (zoomAction == ZoomDirection.ZOOM_OUT_CENTER_Y_AXIS) { yAxis.setStart(yAxis.getStart() - timeScaleZoomAmount); yAxis.setEnd(yAxis.getEnd() + timeScaleZoomAmount); markTimeZoomed(); plot.notifyObserversTimeChange(); } else if (zoomAction == ZoomDirection.ZOOM_IN_LOW_Y_AXIS) { yAxis.setStart(yAxis.getStart() + timeScaleZoomAmount); markTimeZoomed(); plot.notifyObserversTimeChange(); } else if (zoomAction == ZoomDirection.ZOOM_OUT_LOW_Y_AXIS) { yAxis.setStart(yAxis.getStart() - timeScaleZoomAmount); markTimeZoomed(); plot.notifyObserversTimeChange(); } else if (zoomAction == ZoomDirection.ZOOM_IN_LEFT_X_AXIS) { xAxis.setStart(xAxis.getStart() + nonTimeScaleZoomAmount); markNonTimeZoomed(); } else if (zoomAction == ZoomDirection.ZOOM_OUT_LEFT_X_AXIS) { xAxis.setStart(xAxis.getStart() - nonTimeScaleZoomAmount); markNonTimeZoomed(); } else if (zoomAction == ZoomDirection.ZOOM_IN_CENTER_X_AXIS) { xAxis.setStart(xAxis.getStart() + nonTimeScaleZoomAmount); xAxis.setEnd(xAxis.getEnd() - nonTimeScaleZoomAmount); markNonTimeZoomed(); } else if (zoomAction == ZoomDirection.ZOOM_OUT_CENTER_X_AXIS) { xAxis.setStart(xAxis.getStart() - nonTimeScaleZoomAmount); xAxis.setEnd(xAxis.getEnd() + nonTimeScaleZoomAmount); markNonTimeZoomed(); } else if (zoomAction == ZoomDirection.ZOOM_IN_RIGHT_X_AXIS) { xAxis.setEnd(xAxis.getEnd() - nonTimeScaleZoomAmount); markNonTimeZoomed(); } else if (zoomAction == ZoomDirection.ZOOM_OUT_RIGHT_X_AXIS) { xAxis.setEnd(xAxis.getEnd() + nonTimeScaleZoomAmount); markNonTimeZoomed(); } } plot.getPlotAbstraction().updateResetButtons(); plot.refreshDisplay(); plot.getLimitManager().setModeUntranslated(false); plot.getPlotDataManager().resizeAndReloadPlotBuffer(); } PanAndZoomManager(PlotterPlot quinnCurtisPlot); void enteredPanMode(); void exitedPanMode(); void enteredZoomMode(); void exitedZoomMode(); boolean isInZoomMode(); boolean isInPanMode(); void panAction(PanDirection panningAction); void zoomAction(ZoomDirection zoomAction);  }
@Test public void TestZoomingActionsTimeX() { XYAxis xAxis = plotTimeOnX.getPlotView().getXAxis(); XYAxis yAxis = plotTimeOnX.getPlotView().getYAxis(); double xStart = xAxis.getStart(); double xStop = xAxis.getEnd(); double yStart = yAxis.getStart(); double yStop = yAxis.getEnd(); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_IN_HIGH_Y_AXIS); double newXStart = xAxis.getStart(); double newXStop = xAxis.getEnd(); double newYStart = yAxis.getStart(); double newYStop = yAxis.getEnd(); Assert.assertEquals(newYStart, yStart); Assert.assertTrue(newYStop < yStop); Assert.assertEquals(newXStart, xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_OUT_HIGH_Y_AXIS); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_OUT_HIGH_Y_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertEquals(newYStart, yStart); Assert.assertTrue(newYStop > yStop); Assert.assertEquals(newXStart, xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_IN_CENTER_Y_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart > yStart); Assert.assertTrue(newYStop < yStop); Assert.assertEquals(newXStart, xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_OUT_CENTER_Y_AXIS); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_OUT_CENTER_Y_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); Assert.assertEquals(newXStart, xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_IN_LOW_Y_AXIS); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_IN_LOW_Y_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart > yStart); Assert.assertTrue(newYStop > yStop); Assert.assertEquals(newXStart, xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_OUT_LOW_Y_AXIS); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_OUT_LOW_Y_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); Assert.assertEquals(newXStart, xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_IN_LEFT_X_AXIS); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_IN_LEFT_X_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); Assert.assertTrue(newXStart > xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_OUT_LEFT_X_AXIS); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_OUT_LEFT_X_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); Assert.assertTrue(newXStart > xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_IN_CENTER_X_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newXStart > xStart); Assert.assertTrue(newXStop < xStop); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_OUT_CENTER_X_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); Assert.assertTrue(newXStart > xStart); Assert.assertTrue(newXStop < xStop); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_IN_RIGHT_X_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); Assert.assertTrue(newXStart > xStart); Assert.assertTrue(newXStop < xStop); panAndZoomManagerTimeOnX.zoomAction(ZoomDirection.ZOOM_OUT_RIGHT_X_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); Assert.assertTrue(newXStart > xStart); Assert.assertTrue(newXStop < xStop); }
@Test public void TestZoomingActionsTimeY() { XYAxis xAxis = plotTimeOnY.getPlotView().getXAxis(); XYAxis yAxis = plotTimeOnY.getPlotView().getYAxis(); double xStart = xAxis.getStart(); double xStop = xAxis.getEnd(); double yStart = yAxis.getStart(); double yStop = yAxis.getEnd(); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_IN_HIGH_Y_AXIS); double newXStart = xAxis.getStart(); double newXStop = xAxis.getEnd(); double newYStart = yAxis.getStart(); double newYStop = yAxis.getEnd(); Assert.assertEquals(newYStart, yStart); Assert.assertTrue(newYStop < yStop); Assert.assertEquals(newXStart, xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_OUT_HIGH_Y_AXIS); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_OUT_HIGH_Y_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertEquals(newYStart, yStart); Assert.assertTrue(newYStop > yStop); Assert.assertEquals(newXStart, xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_IN_CENTER_Y_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart > yStart); Assert.assertTrue(newYStop < yStop); Assert.assertEquals(newXStart, xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_OUT_CENTER_Y_AXIS); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_OUT_CENTER_Y_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); Assert.assertEquals(newXStart, xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_IN_LOW_Y_AXIS); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_IN_LOW_Y_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart > yStart); Assert.assertTrue(newYStop > yStop); Assert.assertEquals(newXStart, xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_OUT_LOW_Y_AXIS); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_OUT_LOW_Y_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); Assert.assertEquals(newXStart, xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_IN_LEFT_X_AXIS); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_IN_LEFT_X_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); Assert.assertTrue(newXStart > xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_OUT_LEFT_X_AXIS); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_OUT_LEFT_X_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); Assert.assertTrue(newXStart > xStart); Assert.assertEquals(newXStop, xStop); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_IN_CENTER_X_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newXStart > xStart); Assert.assertTrue(newXStop < xStop); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_OUT_CENTER_X_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); Assert.assertTrue(newXStart > xStart); Assert.assertTrue(newXStop < xStop); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_IN_RIGHT_X_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); Assert.assertTrue(newXStart > xStart); Assert.assertTrue(newXStop < xStop); panAndZoomManagerTimeOnY.zoomAction(ZoomDirection.ZOOM_OUT_RIGHT_X_AXIS); newXStart = xAxis.getStart(); newXStop = xAxis.getEnd(); newYStart = yAxis.getStart(); newYStop = yAxis.getEnd(); Assert.assertTrue(newYStart < yStart); Assert.assertTrue(newYStop > yStop); Assert.assertTrue(newXStart > xStart); Assert.assertTrue(newXStop < xStop); }