List of usage examples for org.jfree.chart.plot Plot isNotify
public boolean isNotify()
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.//ww w . j a va 2 s . c o m * @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:com.rapidminer.gui.new_plotter.engine.jfreechart.link_and_brush.LinkAndBrushChartPanel.java
@Override public void restoreAutoBounds() { Plot plot = getChart().getPlot(); if (plot == null) { return;/* w w w. j a va 2 s. c o m*/ } // 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); }
From source file:de.hs.mannheim.modUro.controller.diagram.fx.interaction.ZoomHandlerFX.java
@Override public void handleMouseReleased(ChartCanvas canvas, MouseEvent e) { Plot p = canvas.getChart().getPlot(); if (!(p instanceof Zoomable)) { return;/*ww w. j a va 2 s. c om*/ } boolean hZoom, vZoom; Zoomable z = (Zoomable) p; if (z.getOrientation().isHorizontal()) { hZoom = z.isRangeZoomable(); vZoom = z.isDomainZoomable(); } else { hZoom = z.isDomainZoomable(); vZoom = z.isRangeZoomable(); } boolean zoomTrigger1 = hZoom && Math.abs(e.getX() - this.startPoint.getX()) >= 10; boolean zoomTrigger2 = vZoom && Math.abs(e.getY() - this.startPoint.getY()) >= 10; if (zoomTrigger1 || zoomTrigger2) { Point2D endPoint = new Point2D.Double(e.getX(), e.getY()); PlotRenderingInfo pri = canvas.getRenderingInfo().getPlotInfo(); if ((hZoom && (e.getX() < this.startPoint.getX())) || (vZoom && (e.getY() < this.startPoint.getY()))) { boolean saved = p.isNotify(); p.setNotify(false); z.zoomDomainAxes(0, pri, endPoint); z.zoomRangeAxes(0, pri, endPoint); p.setNotify(saved); } else { double x = this.startPoint.getX(); double y = this.startPoint.getY(); double w = e.getX() - x; double h = e.getY() - y; Rectangle2D dataArea = canvas.findDataArea(this.startPoint); double maxX = dataArea.getMaxX(); double maxY = dataArea.getMaxY(); // for mouseReleased event, (horizontalZoom || verticalZoom) // will be true, so we can just test for either being false; // otherwise both are true if (!vZoom) { y = dataArea.getMinY(); w = Math.min(w, maxX - this.startPoint.getX()); h = dataArea.getHeight(); } else if (!hZoom) { x = dataArea.getMinX(); w = dataArea.getWidth(); h = Math.min(h, maxY - this.startPoint.getY()); } else { w = Math.min(w, maxX - this.startPoint.getX()); h = Math.min(h, maxY - this.startPoint.getY()); } Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h); boolean saved = p.isNotify(); p.setNotify(false); double pw0 = percentW(x, dataArea); double pw1 = percentW(x + w, dataArea); double ph0 = percentH(y, dataArea); double ph1 = percentH(y + h, dataArea); PlotRenderingInfo info = this.viewer.getRenderingInfo().getPlotInfo(); if (z.getOrientation().isVertical()) { z.zoomDomainAxes(pw0, pw1, info, endPoint); z.zoomRangeAxes(1 - ph1, 1 - ph0, info, endPoint); } else { z.zoomRangeAxes(pw0, pw1, info, endPoint); z.zoomDomainAxes(1 - ph1, 1 - ph0, info, endPoint); } p.setNotify(saved); } } viewer.hideZoomRectangle(); this.startPoint = null; canvas.clearLiveHandler(); }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.link_and_brush.LinkAndBrushChartPanel.java
@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(); }//from www .j ava2 s . co m 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); } } }
From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java
/** * Zooms in on an anchor point (specified in screen coordinate space). * //from w w w. j a va 2 s .co m * @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); }
From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java
/** * Zooms out on an anchor point (specified in screen coordinate space). * /* www .j a v a 2 s. c o m*/ * @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); }
From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java
/** * Restores the auto-range calculation on both axes. *///from w w w.ja v a2s.c o m @Override 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); selectCompleteDomainBounds(); selectCompleteRangeBounds(); plot.setNotify(savedNotify); }
From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java
/** * Restores the auto-range calculation on the domain axis. *//*from w ww .j av a 2 s . com*/ public void selectCompleteDomainBounds() { 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); if (plot instanceof XYPlot) { XYPlot xyPlot = (XYPlot) plot; Selection selectionObject = new Selection(); for (int i = 0; i < xyPlot.getDomainAxisCount(); i++) { ValueAxis domain = xyPlot.getDomainAxis(i); Range axisRange = new Range(domain.getLowerBound(), domain.getUpperBound()); for (String axisName : axisNameResolver.resolveXAxis(i)) { selectionObject.addDelimiter(axisName, axisRange); } } informSelectionListener(selectionObject, null); } } }
From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java
/** * Restores the auto-range calculation on the range axis. *//*w w w . j a v a2s . co m*/ 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); } } }