List of usage examples for org.jfree.chart.axis ValueAxis resizeRange
public void resizeRange(double percent, double anchorValue)
From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelChart.java
/** * Decreases the range on the horizontal axis, centered about a Java2D x coordinate. * <P>// w w w . ja v a 2 s . co m * The range on the x axis is multiplied by zoomFactor * * @param x the x coordinate in Java2D space. * @param zoomFactor the zoomFactor < 1 == zoom in; else out. */ private void zoomHorizontal(double x, double zoomFactor) { JFreeChart chart = this.chartPanel.getChart(); ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo(); if (chart.getPlot() instanceof XYPlot) { XYPlot hvp = (XYPlot) chart.getPlot(); ValueAxis axis = hvp.getDomainAxis(); if (axis != null) { double anchorValue = axis.java2DToValue((float) x, info.getPlotInfo().getDataArea(), hvp.getDomainAxisEdge()); if (zoomFactor < 1.0) { axis.resizeRange(zoomFactor, anchorValue); } else if (zoomFactor > 1.0) { Range range = hvp.getDataRange(axis); adjustRange(axis, range, zoomFactor, anchorValue); } } } }
From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelChart.java
/** * Decreases the range on the vertical axis, centered about a Java2D y coordinate. * <P>//from w w w .j a v a 2s . c o m * The range on the y axis is multiplied by zoomFactor * * @param y the y coordinate in Java2D space. * @param zoomFactor the zoomFactor < 1 == zoom in; else out. */ private void zoomVertical(double y, double zoomFactor) { JFreeChart chart = this.chartPanel.getChart(); ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo(); if (chart.getPlot() instanceof XYPlot) { XYPlot vvp = (XYPlot) chart.getPlot(); ValueAxis primYAxis = vvp.getRangeAxis(); if (primYAxis != null) { double anchorValue = primYAxis.java2DToValue((float) y, info.getPlotInfo().getDataArea(), vvp.getRangeAxisEdge()); if (zoomFactor < 1.0) { // zoom in primYAxis.resizeRange(zoomFactor, anchorValue); } else if (zoomFactor > 1.0) { // zoom out Range range = new Range(yMin, yMax); adjustRange(primYAxis, range, zoomFactor, anchorValue); } } } }
From source file:apidemo.PanScrollZoomDemo.java
/** * Decreases the range on the horizontal axis, centered about a Java2D x coordinate. * <P>/* ww w . ja v a 2 s.c o m*/ * The range on the x axis is multiplied by zoomFactor * * @param x the x coordinate in Java2D space. * @param zoomFactor the zoomFactor < 1 == zoom in; else out. */ private void zoomHorizontal(final double x, final double zoomFactor) { final JFreeChart chart = this.chartPanel.getChart(); final ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo(); if (chart.getPlot() instanceof XYPlot) { final XYPlot hvp = (XYPlot) chart.getPlot(); final ValueAxis axis = hvp.getDomainAxis(); if (axis != null) { final double anchorValue = axis.java2DToValue((float) x, info.getPlotInfo().getDataArea(), hvp.getDomainAxisEdge()); if (zoomFactor < 1.0) { axis.resizeRange(zoomFactor, anchorValue); } else if (zoomFactor > 1.0) { final Range range = hvp.getDataRange(axis); adjustRange(axis, range, zoomFactor, anchorValue); } } } }
From source file:apidemo.PanScrollZoomDemo.java
/** * Decreases the range on the vertical axis, centered about a Java2D y coordinate. * <P>/*from w w w . j a v a 2 s .c o m*/ * The range on the y axis is multiplied by zoomFactor * * @param y the y coordinate in Java2D space. * @param zoomFactor the zoomFactor < 1 == zoom in; else out. */ private void zoomVertical(final double y, final double zoomFactor) { final JFreeChart chart = this.chartPanel.getChart(); final ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo(); // 1. (left) Y-Axis if (chart.getPlot() instanceof XYPlot) { final XYPlot vvp = (XYPlot) chart.getPlot(); final ValueAxis primYAxis = vvp.getRangeAxis(); if (primYAxis != null) { final double anchorValue = primYAxis.java2DToValue((float) y, info.getPlotInfo().getDataArea(), vvp.getRangeAxisEdge()); if (zoomFactor < 1.0) { // zoom in primYAxis.resizeRange(zoomFactor, anchorValue); } else if (zoomFactor > 1.0) { // zoom out final Range range = new Range(this.primYMinMax[0], this.primYMinMax[1]); adjustRange(primYAxis, range, zoomFactor, anchorValue); } } // 2. (right) Y-Axis if (chart.getPlot() instanceof XYPlot) { final XYPlot xyp = (XYPlot) chart.getPlot(); final ValueAxis secYAxis = xyp.getRangeAxis(1); if (secYAxis != null) { final double anchorValue = secYAxis.java2DToValue((float) y, info.getPlotInfo().getDataArea(), xyp.getRangeAxisEdge(1)); if (zoomFactor < 1.0) { // zoom in secYAxis.resizeRange(zoomFactor, anchorValue); } else if (zoomFactor > 1.0) { // zoom out final Range range = new Range(this.secondYMinMax[0], this.secondYMinMax[1]); adjustRange(secYAxis, range, zoomFactor, anchorValue); } } } } }