Example usage for org.jfree.chart.plot Zoomable zoomRangeAxes

List of usage examples for org.jfree.chart.plot Zoomable zoomRangeAxes

Introduction

In this page you can find the example usage for org.jfree.chart.plot Zoomable zoomRangeAxes.

Prototype

public void zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source);

Source Link

Document

Zooms in on the range axes.

Usage

From source file:de.hs.mannheim.modUro.controller.diagram.fx.interaction.ScrollHandlerFX.java

/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot./*from  ww w  . j a v a  2s . com*/
 * @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
    }
}

From source file:de.xirp.ui.widgets.custom.XChartComposite.java

/**
 * Zooms in on a selected region.//from   w w w.ja  v  a 2s.  com
 * 
 * @param selection
 *            the selected region.
 */
@SuppressWarnings("cast")
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((int) (selection.x + selection.width) / 2,
            (int) (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);
            }
        }

    }

}

From source file:com.munch.exchange.ExchangeChartComposite.java

/**
 * Zooms in on a selected region.// w  w  w .ja v  a2  s .  c o m
 *
 * @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);
            }
        }

    }

}

From source file:org.mwc.cmap.grideditor.chart.FixedChartComposite.java

/**
 * Zooms in on a selected region.//from   w w w. j a va  2 s  .  c  om
 * 
 * @param selection
 *          the selected region.
 */
public void zoom(final 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)
    final Point2D selectOrigin = translateScreenToJava2D(new Point(selection.x, selection.y));
    final PlotRenderingInfo plotInfo = this.info.getPlotInfo();
    final Rectangle scaledDataArea = getScreenDataArea((selection.x + selection.width / 2),
            (selection.y + selection.height / 2));
    if ((selection.height > 0) && (selection.width > 0)) {

        final double hLower = (selection.x - scaledDataArea.x) / (double) scaledDataArea.width;
        final double hUpper = (selection.x + selection.width - scaledDataArea.x)
                / (double) scaledDataArea.width;
        final double vLower = (scaledDataArea.y + scaledDataArea.height - selection.y - selection.height)
                / (double) scaledDataArea.height;
        final double vUpper = (scaledDataArea.y + scaledDataArea.height - selection.y)
                / (double) scaledDataArea.height;
        final Plot p = this.chart.getPlot();
        if (p instanceof Zoomable) {
            final 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);
            }
        }

    }

}

From source file:org.rdv.viz.chart.ChartPanel.java

/**
 * 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).
 *//*ww  w.  j  ava2 s.  c o m*/
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)), this.zoomAroundAnchor);
    }
}

From source file:org.rdv.viz.chart.ChartPanel.java

/**
 * 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).
 *//*from  w ww . jav a  2  s .  c o  m*/
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)), this.zoomAroundAnchor);
    }
}

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Zooms in on a selected region./*from   www.  jav a  2 s.c om*/
 * 
 * @param selection
 *            the selected region.
 */
public void zoom(Rectangle2D 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((int) Math.ceil(selection.getX()), (int) Math.ceil(selection.getY())));
    PlotRenderingInfo plotInfo = this.info.getPlotInfo();
    Rectangle2D scaledDataArea = getScreenDataArea((int) selection.getCenterX(), (int) selection.getCenterY());
    if ((selection.getHeight() > 0) && (selection.getWidth() > 0)) {

        double hLower = (selection.getMinX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        double hUpper = (selection.getMaxX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        double vLower = (scaledDataArea.getMaxY() - selection.getMaxY()) / scaledDataArea.getHeight();
        double vUpper = (scaledDataArea.getMaxY() - selection.getMinY()) / scaledDataArea.getHeight();

        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);
            }
        }
    }
}

From source file:org.rdv.viz.chart.ChartPanel.java

/**
 * Zooms in on a selected region./* w  w w.j  av  a  2s .c o m*/
 *
 * @param selection  the selected region.
 */
public void zoom(Rectangle2D 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((int) Math.ceil(selection.getX()), (int) Math.ceil(selection.getY())));
    PlotRenderingInfo plotInfo = this.info.getPlotInfo();
    Rectangle2D scaledDataArea = getScreenDataArea((int) selection.getCenterX(), (int) selection.getCenterY());
    if ((selection.getHeight() > 0) && (selection.getWidth() > 0)) {

        double hLower = (selection.getMinX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        double hUpper = (selection.getMaxX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth();
        double vLower = (scaledDataArea.getMaxY() - selection.getMaxY()) / scaledDataArea.getHeight();
        double vUpper = (scaledDataArea.getMaxY() - selection.getMinY()) / scaledDataArea.getHeight();

        Plot p = this.chart.getPlot();
        if (p instanceof Zoomable) {
            // save previous ranges for use later when zooming out
            if (p instanceof XYPlot && rangeHistory.empty()) {
                XYPlot xyPlot = (XYPlot) p;
                rangeHistory.push(xyPlot.getDomainAxis().getRange());
                rangeHistory.push(xyPlot.getRangeAxis().getRange());
            }

            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);
            }

            // save current ranges for use later when zooming out
            if (p instanceof XYPlot) {
                XYPlot xyPlot = (XYPlot) p;
                rangeHistory.push(xyPlot.getDomainAxis().getRange());
                rangeHistory.push(xyPlot.getRangeAxis().getRange());
            }
        }

    }

}