Java Code Examples for org.jfree.chart.plot.Zoomable#zoomRangeAxes()

The following examples show how to use org.jfree.chart.plot.Zoomable#zoomRangeAxes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScrollHandlerFX.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, 
        ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (true) { //this.chartPanel.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (true) { //this.chartPanel.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    } 
}
 
Example 2
Source File: ChartPanel.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Restores the auto-range calculation on the range axis.
 */
public void restoreAutoRangeBounds() {
    Plot plot = this.chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable z = (Zoomable) plot;
        // here we tweak the notify flag on the plot so that only
        // one notification happens even though we update multiple
        // axes...
        boolean savedNotify = plot.isNotify();
        plot.setNotify(false);
        // we need to guard against this.zoomPoint being null
        Point2D zp = (this.zoomPoint != null
                ? this.zoomPoint : new Point());
        z.zoomRangeAxes(0.0, this.info.getPlotInfo(), zp);
        plot.setNotify(savedNotify);
    }
}
 
Example 3
Source File: ChartPanel.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Increases the length the range axis, centered about the given
 * coordinate on the screen.  The length of the range axis is increased
 * by the value of {@link #getZoomOutFactor()}.
 *
 * @param x  the x coordinate (in screen coordinates).
 * @param y  the y-coordinate (in screen coordinates).
 */
public void zoomOutRange(double x, double y) {
    Plot plot = this.chart.getPlot();
    if (plot instanceof Zoomable) {
        // here we tweak the notify flag on the plot so that only
        // one notification happens even though we update multiple
        // axes...
        boolean savedNotify = plot.isNotify();
        plot.setNotify(false);
        Zoomable z = (Zoomable) plot;
        z.zoomRangeAxes(this.zoomOutFactor, this.info.getPlotInfo(),
                translateScreenToJava2D(new Point((int) x, (int) y)),
                this.zoomAroundAnchor);
        plot.setNotify(savedNotify);
    }
}
 
Example 4
Source File: ChartPanel.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Decreases the length of the range axis, centered about the given
 * coordinate on the screen.  The length of the range axis is reduced by
 * the value of {@link #getZoomInFactor()}.
 *
 * @param x  the x-coordinate (in screen coordinates).
 * @param y  the y coordinate (in screen coordinates).
 */
public void zoomInRange(double x, double y) {
    Plot plot = this.chart.getPlot();
    if (plot instanceof Zoomable) {
        // here we tweak the notify flag on the plot so that only
        // one notification happens even though we update multiple
        // axes...
        boolean savedNotify = plot.isNotify();
        plot.setNotify(false);
        Zoomable z = (Zoomable) plot;
        z.zoomRangeAxes(this.zoomInFactor, this.info.getPlotInfo(),
                translateScreenToJava2D(new Point((int) x, (int) y)),
                this.zoomAroundAnchor);
        plot.setNotify(savedNotify);
    }
}
 
Example 5
Source File: ChartPanel.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Increases the length the range axis, centered about the given
 * coordinate on the screen.  The length of the range axis is increased
 * by the value of {@link #getZoomOutFactor()}.
 *
 * @param x  the x coordinate (in screen coordinates).
 * @param y  the y-coordinate (in screen coordinates).
 */
public void zoomOutRange(double x, double y) {
    Plot plot = this.chart.getPlot();
    if (plot instanceof Zoomable) {
        // here we tweak the notify flag on the plot so that only
        // one notification happens even though we update multiple
        // axes...
        boolean savedNotify = plot.isNotify();
        plot.setNotify(false);
        Zoomable z = (Zoomable) plot;
        z.zoomRangeAxes(this.zoomOutFactor, this.info.getPlotInfo(),
                translateScreenToJava2D(new Point((int) x, (int) y)),
                this.zoomAroundAnchor);
        plot.setNotify(savedNotify);
    }
}
 
Example 6
Source File: ChartPanel.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Restores the auto-range calculation on the range axis.
 */
public void restoreAutoRangeBounds() {
    Plot plot = this.chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable z = (Zoomable) plot;
        // here we tweak the notify flag on the plot so that only
        // one notification happens even though we update multiple
        // axes...
        boolean savedNotify = plot.isNotify();
        plot.setNotify(false);
        // we need to guard against this.zoomPoint being null
        Point2D zp = (this.zoomPoint != null
                ? this.zoomPoint : new Point());
        z.zoomRangeAxes(0.0, this.info.getPlotInfo(), zp);
        plot.setNotify(savedNotify);
    }
}
 
Example 7
Source File: ChartPanel.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Increases the length the range axis, centered about the given
 * coordinate on the screen.  The length of the range axis is increased
 * by the value of {@link #getZoomOutFactor()}.
 *
 * @param x  the x coordinate (in screen coordinates).
 * @param y  the y-coordinate (in screen coordinates).
 */
public void zoomOutRange(double x, double y) {
    Plot plot = this.chart.getPlot();
    if (plot instanceof Zoomable) {
        // here we tweak the notify flag on the plot so that only
        // one notification happens even though we update multiple
        // axes...
        boolean savedNotify = plot.isNotify();
        plot.setNotify(false);
        Zoomable z = (Zoomable) plot;
        z.zoomRangeAxes(this.zoomOutFactor, this.info.getPlotInfo(),
                translateScreenToJava2D(new Point((int) x, (int) y)),
                this.zoomAroundAnchor);
        plot.setNotify(savedNotify);
    }
}
 
Example 8
Source File: ScrollHandlerFX.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, 
        ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (true) { //this.chartPanel.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (true) { //this.chartPanel.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    } 
}
 
Example 9
Source File: ChartLogicsFX.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Auto range the range axis
 * 
 * @param myChart
 * @param zoom
 * @param autoRangeY if true the range (Y) axis auto bounds will be restored
 */
public static void autoRangeAxis(ChartViewer myChart) {
  XYPlot plot = (XYPlot) myChart.getChart().getPlot();
  if (plot instanceof Zoomable) {
    Zoomable z = plot;
    Point2D endPoint = new Point2D.Double(0, 0);
    PlotRenderingInfo pri = myChart.getRenderingInfo().getPlotInfo();
    z.zoomRangeAxes(0, pri, endPoint);
  }
}
 
Example 10
Source File: ChartLogicsFX.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Auto range the range axis
 * 
 * @param myChart
 * @param zoom
 * @param autoRangeY if true the range (Y) axis auto bounds will be restored
 */
public static void autoRangeAxis(ChartViewer myChart) {
  XYPlot plot = (XYPlot) myChart.getChart().getPlot();
  if (plot instanceof Zoomable) {
    Zoomable z = plot;
    Point2D endPoint = new Point2D.Double(0, 0);
    PlotRenderingInfo pri = myChart.getRenderingInfo().getPlotInfo();
    z.zoomRangeAxes(0, pri, endPoint);
  }
}
 
Example 11
Source File: ChartComposite.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Restores the auto-range calculation on the range axis.
 */
public void restoreAutoRangeBounds() {
    Plot p = this.chart.getPlot();
    if (p instanceof ValueAxisPlot) {
        Zoomable z = (Zoomable) p;
        // we need to guard against this.zoomPoint being null
        org.eclipse.swt.graphics.Point zp =
                (this.zoomPoint != null ? this.zoomPoint
                : new org.eclipse.swt.graphics.Point(0, 0));
        z.zoomRangeAxes(0.0, this.info.getPlotInfo(),
                SWTUtils.toAwtPoint(zp));
    }
}
 
Example 12
Source File: MouseWheelHandler.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(Zoomable zoomable, MouseWheelEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = this.chartPanel.translateScreenToJava2D(e.getPoint());
    if (!pinfo.getDataArea().contains(p)) {
        return;
    }

    Plot plot = (Plot) zoomable;
    // do not notify while zooming each axis
    boolean notifyState = plot.isNotify();
    plot.setNotify(false);
    int clicks = e.getWheelRotation();
    double zf = 1.0 + this.zoomFactor;
    if (clicks < 0) {
        zf = 1.0 / zf;
    }
    if (chartPanel.isDomainZoomable()) {
        zoomable.zoomDomainAxes(zf, pinfo, p, true);
    }
    if (chartPanel.isRangeZoomable()) {
        zoomable.zoomRangeAxes(zf, pinfo, p, true);
    }
    plot.setNotify(notifyState);  // this generates the change event too
}
 
Example 13
Source File: ChartComposite.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Zooms in on a selected region.
 *
 * @param selection  the selected region.
 */
public void zoom(Rectangle selection) {

    // get the origin of the zoom selection in the Java2D space used for
    // drawing the chart (that is, before any scaling to fit the panel)
    Point2D selectOrigin = translateScreenToJava2D(
            new Point(selection.x, selection.y));
    PlotRenderingInfo plotInfo = this.info.getPlotInfo();
    Rectangle scaledDataArea = getScreenDataArea(
            (selection.x + selection.width / 2),
            (selection.y + selection.height / 2));
    if ((selection.height > 0) && (selection.width > 0)) {

        double hLower = (selection.x - scaledDataArea.x)
            / (double) scaledDataArea.width;
        double hUpper = (selection.x + selection.width - scaledDataArea.x)
            / (double) scaledDataArea.width;
        double vLower = (scaledDataArea.y + scaledDataArea.height
                - selection.y - selection.height)
                / (double) scaledDataArea.height;
        double vUpper = (scaledDataArea.y + scaledDataArea.height
                - selection.y) / (double) scaledDataArea.height;
        Plot p = this.chart.getPlot();
        if (p instanceof Zoomable) {
            Zoomable z = (Zoomable) p;
            if (z.getOrientation() == PlotOrientation.HORIZONTAL) {
                z.zoomDomainAxes(vLower, vUpper, plotInfo, selectOrigin);
                z.zoomRangeAxes(hLower, hUpper, plotInfo, selectOrigin);
            }
            else {
                z.zoomDomainAxes(hLower, hUpper, plotInfo, selectOrigin);
                z.zoomRangeAxes(vLower, vUpper, plotInfo, selectOrigin);
            }
        }

    }

}
 
Example 14
Source File: ChartComposite.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Decreases the length of the range axis, centered about the given
 * coordinate on the screen.  The length of the range axis is reduced by
 * the value of {@link #getZoomInFactor()}.
 *
 * @param x  the x-coordinate (in screen coordinates).
 * @param y  the y coordinate (in screen coordinates).
 */
public void zoomInRange(double x, double y) {
    Plot p = this.chart.getPlot();
    if (p instanceof Zoomable) {
        Zoomable z = (Zoomable) p;
        z.zoomRangeAxes(this.zoomInFactor, this.info.getPlotInfo(),
                translateScreenToJava2D(new Point((int) x, (int) y)));
    }
}
 
Example 15
Source File: MouseWheelHandler.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(Zoomable zoomable, MouseWheelEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = this.chartPanel.translateScreenToJava2D(e.getPoint());
    if (!pinfo.getDataArea().contains(p)) {
        return;
    }

    Plot plot = (Plot) zoomable;
    // do not notify while zooming each axis
    boolean notifyState = plot.isNotify();
    plot.setNotify(false);
    int clicks = e.getWheelRotation();
    double zf = 1.0 + this.zoomFactor;
    if (clicks < 0) {
        zf = 1.0 / zf;
    }
    if (chartPanel.isDomainZoomable()) {
        zoomable.zoomDomainAxes(zf, pinfo, p, true);
    }
    if (chartPanel.isRangeZoomable()) {
        zoomable.zoomRangeAxes(zf, pinfo, p, true);
    }
    plot.setNotify(notifyState);  // this generates the change event too
}
 
Example 16
Source File: ChartComposite.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Decreases the length of the range axis, centered about the given
 * coordinate on the screen.  The length of the range axis is reduced by
 * the value of {@link #getZoomInFactor()}.
 *
 * @param x  the x-coordinate (in screen coordinates).
 * @param y  the y coordinate (in screen coordinates).
 */
public void zoomInRange(double x, double y) {
    Plot p = this.chart.getPlot();
    if (p instanceof Zoomable) {
        Zoomable z = (Zoomable) p;
        z.zoomRangeAxes(this.zoomInFactor, this.info.getPlotInfo(),
                translateScreenToJava2D(new Point((int) x, (int) y)));
    }
}
 
Example 17
Source File: MouseWheelHandler.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(Zoomable zoomable, MouseWheelEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = this.chartPanel.translateScreenToJava2D(e.getPoint());
    if (!pinfo.getDataArea().contains(p)) {
        return;
    }

    Plot plot = (Plot) zoomable;
    // do not notify while zooming each axis
    boolean notifyState = plot.isNotify();
    plot.setNotify(false);
    int clicks = e.getWheelRotation();
    double zf = 1.0 + this.zoomFactor;
    if (clicks < 0) {
        zf = 1.0 / zf;
    }
    if (chartPanel.isDomainZoomable()) {
        zoomable.zoomDomainAxes(zf, pinfo, p, true);
    }
    if (chartPanel.isRangeZoomable()) {
        zoomable.zoomRangeAxes(zf, pinfo, p, true);
    }
    plot.setNotify(notifyState);  // this generates the change event too
}
 
Example 18
Source File: AbstractChartPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Restores the auto-range calculation on the range axis.
 */

public void selectCompleteRangeBounds() {
	Plot plot = this.chart.getPlot();
	if (plot instanceof Zoomable) {
		Zoomable z = (Zoomable) plot;
		// here we tweak the notify flag on the plot so that only
		// one notification happens even though we update multiple
		// axes...
		boolean savedNotify = plot.isNotify();
		plot.setNotify(false);
		// we need to guard against this.zoomPoint being null
		Point2D zp = this.zoomPoint != null ? this.zoomPoint : new Point();
		z.zoomRangeAxes(0.0, this.info.getPlotInfo(), zp);
		plot.setNotify(savedNotify);

		if (plot instanceof XYPlot) {
			XYPlot xyPlot = (XYPlot) plot;
			Selection selectionObject = new Selection();
			for (int i = 0; i < xyPlot.getRangeAxisCount(); i++) {
				ValueAxis range = xyPlot.getRangeAxis(i);
				Range axisRange = new Range(range.getLowerBound(), range.getUpperBound());
				for (String axisName : axisNameResolver.resolveYAxis(i)) {
					selectionObject.addDelimiter(axisName, axisRange);
				}
			}
			informSelectionListener(selectionObject, null);
		}
	}
}
 
Example 19
Source File: ChartComposite.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Zooms in on a selected region.
 *
 * @param selection  the selected region.
 */
public void zoom(Rectangle selection) {

    // get the origin of the zoom selection in the Java2D space used for
    // drawing the chart (that is, before any scaling to fit the panel)
    Point2D selectOrigin = translateScreenToJava2D(
            new Point(selection.x, selection.y));
    PlotRenderingInfo plotInfo = this.info.getPlotInfo();
    Rectangle scaledDataArea = getScreenDataArea(
            (selection.x + selection.width / 2),
            (selection.y + selection.height / 2));
    if ((selection.height > 0) && (selection.width > 0)) {

        double hLower = (selection.x - scaledDataArea.x)
            / (double) scaledDataArea.width;
        double hUpper = (selection.x + selection.width - scaledDataArea.x)
            / (double) scaledDataArea.width;
        double vLower = (scaledDataArea.y + scaledDataArea.height
                - selection.y - selection.height)
                / (double) scaledDataArea.height;
        double vUpper = (scaledDataArea.y + scaledDataArea.height
                - selection.y) / (double) scaledDataArea.height;
        Plot p = this.chart.getPlot();
        if (p instanceof Zoomable) {
            Zoomable z = (Zoomable) p;
            if (z.getOrientation() == PlotOrientation.HORIZONTAL) {
                z.zoomDomainAxes(vLower, vUpper, plotInfo, selectOrigin);
                z.zoomRangeAxes(hLower, hUpper, plotInfo, selectOrigin);
            }
            else {
                z.zoomDomainAxes(hLower, hUpper, plotInfo, selectOrigin);
                z.zoomRangeAxes(vLower, vUpper, plotInfo, selectOrigin);
            }
        }

    }

}
 
Example 20
Source File: ChartComposite.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Increases the length the range axis, centered about the given
 * coordinate on the screen.  The length of the range axis is increased
 * by the value of {@link #getZoomOutFactor()}.
 *
 * @param x  the x coordinate (in screen coordinates).
 * @param y  the y-coordinate (in screen coordinates).
 */
public void zoomOutRange(double x, double y) {
    Plot p = this.chart.getPlot();
    if (p instanceof Zoomable) {
        Zoomable z = (Zoomable) p;
        z.zoomRangeAxes(this.zoomOutFactor, this.info.getPlotInfo(),
                translateScreenToJava2D(new Point((int) x, (int) y)));
    }
}