org.jfree.chart.plot.Zoomable Java Examples

The following examples show how to use org.jfree.chart.plot.Zoomable. 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: TaScrollHandlerFX.java    From TAcharting with GNU Lesser General Public License v2.1 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(TaChartCanvas canvas, Zoomable zoomable,
                            ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's org.sjwimmer.tacharting.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 (canvas.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (canvas.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    }
}
 
Example #2
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 domain axis.
 */
public void restoreAutoDomainBounds() {
    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.zoomDomainAxes(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
/**
 * Restores the auto-range calculation on the domain axis.
 */
public void restoreAutoDomainBounds() {
    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.zoomDomainAxes(0.0, this.info.getPlotInfo(), zp);
        plot.setNotify(savedNotify);
    }
}
 
Example #4
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 #5
Source File: ChartPanel.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Increases the length of the domain axis, centered about the given
 * coordinate on the screen.  The length of the domain 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 zoomOutDomain(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.zoomDomainAxes(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
/**
 * 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 #7
Source File: ChartPanel.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Decreases the length of the domain axis, centered about the given
 * coordinate on the screen.  The length of the domain 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 zoomInDomain(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.zoomDomainAxes(this.zoomInFactor, this.info.getPlotInfo(),
                translateScreenToJava2D(new Point((int) x, (int) y)),
                this.zoomAroundAnchor);
        plot.setNotify(savedNotify);
    }
}
 
Example #8
Source File: ScrollHandlerFX.java    From jfreechart-fx with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void handleScroll(ChartCanvas canvas, ScrollEvent e) {
    JFreeChart chart = canvas.getChart();
    if (chart == null) {
        return;
    }
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(canvas, zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation((int) e.getDeltaY());
    }
}
 
Example #9
Source File: ChartPanel.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Decreases the length of the domain axis, centered about the given
 * coordinate on the screen.  The length of the domain 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 zoomInDomain(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.zoomDomainAxes(this.zoomInFactor, this.info.getPlotInfo(),
                translateScreenToJava2D(new Point((int) x, (int) y)),
                this.zoomAroundAnchor);
        plot.setNotify(savedNotify);
    }
}
 
Example #10
Source File: ChartPanel.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Increases the length of the domain axis, centered about the given
 * coordinate on the screen.  The length of the domain 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 zoomOutDomain(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.zoomDomainAxes(this.zoomOutFactor, this.info.getPlotInfo(),
                translateScreenToJava2D(new Point((int) x, (int) y)),
                this.zoomAroundAnchor);
        plot.setNotify(savedNotify);
    }
}
 
Example #11
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 #12
Source File: ScrollHandlerFX.java    From openstock 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 #13
Source File: ChartPanel.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Increases the length of the domain axis, centered about the given
 * coordinate on the screen.  The length of the domain 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 zoomOutDomain(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.zoomDomainAxes(this.zoomOutFactor, this.info.getPlotInfo(),
                translateScreenToJava2D(new Point((int) x, (int) y)),
                this.zoomAroundAnchor);
        plot.setNotify(savedNotify);
    }
}
 
Example #14
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 #15
Source File: ChartPanel.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Decreases the length of the domain axis, centered about the given
 * coordinate on the screen.  The length of the domain 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 zoomInDomain(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.zoomDomainAxes(this.zoomInFactor, this.info.getPlotInfo(),
                translateScreenToJava2D(new Point((int) x, (int) y)),
                this.zoomAroundAnchor);
        plot.setNotify(savedNotify);
    }
}
 
Example #16
Source File: MouseWheelHandler.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Handles a mouse wheel event from the underlying chart panel.
 *
 * @param e  the event.
 */
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    JFreeChart chart = this.chartPanel.getChart();
    if (chart == null) {
        return;
    }
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation(e.getWheelRotation());
    }
}
 
Example #17
Source File: MouseWheelHandler.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Handles a mouse wheel event from the underlying chart panel.
 *
 * @param e  the event.
 */
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
    JFreeChart chart = this.chartPanel.getChart();
    if (chart == null) {
        return;
    }
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation(e.getWheelRotation());
    }
}
 
Example #18
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 #19
Source File: ChartPanel.java    From ccu-historian 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 #20
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 #21
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 #22
Source File: ChartComposite.java    From SIMVA-SoS with Apache License 2.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 #23
Source File: ChartComposite.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Restores the auto-range calculation on the domain axis.
 */
public void restoreAutoDomainBounds() {
    Plot p = this.chart.getPlot();
    if (p instanceof Zoomable) {
        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.zoomDomainAxes(0.0, this.info.getPlotInfo(),
                SWTUtils.toAwtPoint(zp));
    }
}
 
Example #24
Source File: ChartComposite.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the flag that controls whether or not zooming is enable for the
 * domain axis.  A check is made to ensure that the current plot supports
 * zooming for the domain values.
 *
 * @param flag  <code>true</code> enables zooming if possible.
 */
public void setDomainZoomable(boolean flag) {
    if (flag) {
        Plot plot = this.chart.getPlot();
        if (plot instanceof Zoomable) {
            Zoomable z = (Zoomable) plot;
            this.domainZoomable = flag && (z.isDomainZoomable());
        }
    }
    else {
        this.domainZoomable = false;
    }
}
 
Example #25
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 #26
Source File: ChartPanel.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Receives notification of changes to the chart, and redraws the chart.
 *
 * @param event  details of the chart change event.
 */
@Override
public void chartChanged(ChartChangeEvent event) {
    this.refreshBuffer = true;
    Plot plot = this.chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable z = (Zoomable) plot;
        this.orientation = z.getOrientation();
    }
    repaint();
}
 
Example #27
Source File: ChartPanel.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A flag that controls mouse-based zooming on the vertical axis.
 *
 * @param flag  <code>true</code> enables zooming.
 */
public void setRangeZoomable(boolean flag) {
    if (flag) {
        Plot plot = this.chart.getPlot();
        if (plot instanceof Zoomable) {
            Zoomable z = (Zoomable) plot;
            this.rangeZoomable = flag && (z.isRangeZoomable());
        }
    }
    else {
        this.rangeZoomable = false;
    }
}
 
Example #28
Source File: ChartPanel.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the flag that controls whether or not zooming is enabled for the
 * domain axis.  A check is made to ensure that the current plot supports
 * zooming for the domain values.
 *
 * @param flag  <code>true</code> enables zooming if possible.
 */
public void setDomainZoomable(boolean flag) {
    if (flag) {
        Plot plot = this.chart.getPlot();
        if (plot instanceof Zoomable) {
            Zoomable z = (Zoomable) plot;
            this.domainZoomable = flag && (z.isDomainZoomable());
        }
    }
    else {
        this.domainZoomable = false;
    }
}
 
Example #29
Source File: ChartPanel.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the chart that is displayed in the panel.
 *
 * @param chart  the chart (<code>null</code> permitted).
 */
public void setChart(JFreeChart chart) {

    // stop listening for changes to the existing chart
    if (this.chart != null) {
        this.chart.removeChangeListener(this);
        this.chart.removeProgressListener(this);
    }

    // add the new chart
    this.chart = chart;
    if (chart != null) {
        this.chart.addChangeListener(this);
        this.chart.addProgressListener(this);
        Plot plot = chart.getPlot();
        this.domainZoomable = false;
        this.rangeZoomable = false;
        if (plot instanceof Zoomable) {
            Zoomable z = (Zoomable) plot;
            this.domainZoomable = z.isDomainZoomable();
            this.rangeZoomable = z.isRangeZoomable();
            this.orientation = z.getOrientation();
        }
    }
    else {
        this.domainZoomable = false;
        this.rangeZoomable = false;
    }
    if (this.useBuffer) {
        this.refreshBuffer = true;
    }
    repaint();

}
 
Example #30
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));
    }
}