Java Code Examples for org.jfree.chart.plot.Plot#isNotify()

The following examples show how to use org.jfree.chart.plot.Plot#isNotify() . 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: 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 2
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 3
Source File: AbstractChartPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Zooms in on an anchor point (specified in screen coordinate space).
 * 
 * @param x
 *            the x value (in screen coordinates).
 * @param y
 *            the y value (in screen coordinates).
 */

public void shrinkSelectionOnCenter(double x, double y, MouseEvent selectionEvent) {
	Plot plot = this.chart.getPlot();
	if (plot == null) {
		return;
	}
	// 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);
	shrinkSelectionOnDomain(x, y, selectionEvent);
	shrinkSelectionOnRange(x, y, selectionEvent);
	plot.setNotify(savedNotify);
}
 
Example 4
Source File: ChartPanel.java    From buffer_bci 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 SIMVA-SoS with Apache License 2.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 6
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 7
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 8
Source File: ChartPanel.java    From astor with GNU General Public License v2.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 9
Source File: ScrollHandlerFX.java    From buffer_bci 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 10
Source File: AbstractChartPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Zooms out on an anchor point (specified in screen coordinate space).
 * 
 * @param x
 *            the x value (in screen coordinates).
 * @param y
 *            the y value (in screen coordinates).
 */

public void enlargeSelectionOnCenter(double x, double y, MouseEvent selectionEvent) {
	Plot plot = this.chart.getPlot();
	if (plot == null) {
		return;
	}
	// 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);
	enlargeSelectionOnDomain(x, y, selectionEvent);
	enlargeSelectionOnRange(x, y, selectionEvent);
	plot.setNotify(savedNotify);
}
 
Example 11
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 12
Source File: LinkAndBrushChartPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void restoreAutoBounds() {
	Plot plot = getChart().getPlot();
	if (plot == null) {
		return;
	}
	// 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);

	if (plot instanceof LinkAndBrushPlot) {

		LinkAndBrushPlot LABPlot = (LinkAndBrushPlot) plot;

		List<Pair<Integer, Range>> zoomedDomainAxisRanges = new LinkedList<Pair<Integer, Range>>();
		List<Pair<Integer, Range>> zoomedRangeAxisRanges = new LinkedList<Pair<Integer, Range>>();

		zoomedDomainAxisRanges.addAll(LABPlot.restoreAutoDomainAxisBounds(zoomOnLinkAndBrushSelection));
		zoomedRangeAxisRanges.addAll(LABPlot.restoreAutoRangeAxisBounds(zoomOnLinkAndBrushSelection));

		if (zoomOnLinkAndBrushSelection) {
			informLinkAndBrushSelectionListeners(new LinkAndBrushSelection(SelectionType.RESTORE_AUTO_BOUNDS,
					zoomedDomainAxisRanges, zoomedRangeAxisRanges));
		} else {
			informLinkAndBrushSelectionListeners(new LinkAndBrushSelection(SelectionType.RESTORE_SELECTION,
					zoomedDomainAxisRanges, zoomedRangeAxisRanges));
		}

	} else {
		restoreAutoDomainBounds();
		restoreAutoRangeBounds();
	}

	plot.setNotify(savedNotify);
}
 
Example 13
Source File: ChartPanel.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Zooms out on an anchor point (specified in screen coordinate space).
 *
 * @param x  the x value (in screen coordinates).
 * @param y  the y value (in screen coordinates).
 */
public void zoomOutBoth(double x, double y) {
    Plot plot = this.chart.getPlot();
    if (plot == null) {
        return;
    }
    // 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);
    zoomOutDomain(x, y);
    zoomOutRange(x, y);
    plot.setNotify(savedNotify);
}
 
Example 14
Source File: ChartPanel.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Zooms in on an anchor point (specified in screen coordinate space).
 *
 * @param x  the x value (in screen coordinates).
 * @param y  the y value (in screen coordinates).
 */
public void zoomInBoth(double x, double y) {
    Plot plot = this.chart.getPlot();
    if (plot == null) {
        return;
    }
    // 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);
    zoomInDomain(x, y);
    zoomInRange(x, y);
    plot.setNotify(savedNotify);
}
 
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: ChartPanel.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Zooms out on an anchor point (specified in screen coordinate space).
 *
 * @param x  the x value (in screen coordinates).
 * @param y  the y value (in screen coordinates).
 */
public void zoomOutBoth(double x, double y) {
    Plot plot = this.chart.getPlot();
    if (plot == null) {
        return;
    }
    // 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);
    zoomOutDomain(x, y);
    zoomOutRange(x, y);
    plot.setNotify(savedNotify);
}
 
Example 17
Source File: ChartPanel.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Restores the auto-range calculation on both axes.
 */
public void restoreAutoBounds() {
    Plot plot = this.chart.getPlot();
    if (plot == null) {
        return;
    }
    // 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);
    restoreAutoDomainBounds();
    restoreAutoRangeBounds();
    plot.setNotify(savedNotify);
}
 
Example 18
Source File: ChartPanel.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Zooms in on a selected region.
 *
 * @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) {
            // here we tweak the notify flag on the plot so that only
            // one notification happens even though we update multiple
            // axes...
            boolean savedNotify = p.isNotify();
            p.setNotify(false);
            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);
            }
            p.setNotify(savedNotify);
        }

    }

}
 
Example 19
Source File: LinkAndBrushChartPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
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 = getChartRenderingInfo().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 = getChart().getPlot();
		if (p instanceof LinkAndBrushPlot) {

			PlotOrientation orientation = null;
			if (p instanceof XYPlot) {
				XYPlot xyPlot = (XYPlot) p;
				orientation = xyPlot.getOrientation();
			}
			if (p instanceof CategoryPlot) {
				CategoryPlot categoryPlot = (CategoryPlot) p;
				orientation = categoryPlot.getOrientation();
			}

			// here we tweak the notify flag on the plot so that only
			// one notification happens even though we update multiple
			// axes...

			boolean savedNotify = p.isNotify();
			p.setNotify(false);
			LinkAndBrushPlot LABPlot = (LinkAndBrushPlot) p;

			List<Pair<Integer, Range>> zoomedDomainAxisRanges = new LinkedList<Pair<Integer, Range>>();
			List<Pair<Integer, Range>> zoomedRangeAxisRanges = new LinkedList<Pair<Integer, Range>>();

			if (orientation == PlotOrientation.HORIZONTAL) {
				zoomedDomainAxisRanges.addAll(LABPlot.calculateDomainAxesZoom(vLower, vUpper,
						zoomOnLinkAndBrushSelection));
				zoomedRangeAxisRanges.addAll(LABPlot.calculateRangeAxesZoom(hLower, hUpper, plotInfo, selectOrigin,
						zoomOnLinkAndBrushSelection));
			} else {
				zoomedDomainAxisRanges.addAll(LABPlot.calculateDomainAxesZoom(hLower, hUpper,
						zoomOnLinkAndBrushSelection));
				zoomedRangeAxisRanges.addAll(LABPlot.calculateRangeAxesZoom(vLower, vUpper, plotInfo, selectOrigin,
						zoomOnLinkAndBrushSelection));
			}
			p.setNotify(savedNotify);

			if (zoomOnLinkAndBrushSelection) {
				informLinkAndBrushSelectionListeners(new LinkAndBrushSelection(SelectionType.ZOOM_IN,
						zoomedDomainAxisRanges, zoomedRangeAxisRanges));
			} else {
				informLinkAndBrushSelectionListeners(new LinkAndBrushSelection(SelectionType.SELECTION,
						zoomedDomainAxisRanges, zoomedRangeAxisRanges));
			}

		} else {
			super.zoom(selection);
		}
	}
}
 
Example 20
Source File: ChartPanel.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Zooms in on a selected region.
 *
 * @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) {
            // here we tweak the notify flag on the plot so that only
            // one notification happens even though we update multiple
            // axes...
            boolean savedNotify = p.isNotify();
            p.setNotify(false);
            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);
            }
            p.setNotify(savedNotify);
        }

    }

}