List of usage examples for org.jfree.chart.plot Zoomable zoomDomainAxes
public void zoomDomainAxes(double factor, PlotRenderingInfo state, Point2D source);
From source file:net.sf.mzmine.chartbasics.ChartLogicsFX.java
/** * Auto range the range axis/* w ww . j a va 2s . c o m*/ * * @param myChart * @param zoom * @param autoRangeY if true the range (Y) axis auto bounds will be restored */ public static void autoDomainAxis(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.zoomDomainAxes(0, pri, endPoint); } }
From source file:net.sf.mzmine.chartbasics.ChartLogicsFX.java
/** * Auto range the range axis/*from w w w .j a v a 2 s . c o m*/ * * @param myChart * @param zoom * @param autoRangeY if true the range (Y) axis auto bounds will be restored */ public static void autoAxes(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(); boolean saved = plot.isNotify(); plot.setNotify(false); z.zoomDomainAxes(0, pri, endPoint); z.zoomRangeAxes(0, pri, endPoint); plot.setNotify(saved); } }
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;//from w w w . j a v a2s .co m } 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:de.xirp.ui.widgets.custom.XChartComposite.java
/** * Restores the auto-range calculation on the domain axis. *//* w ww. j a va 2 s . co m*/ public void restoreAutoDomainBounds() { Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { Zoomable z = (Zoomable) p; z.zoomDomainAxes(0.0, this.info.getPlotInfo(), SWTUtils.toAwtPoint(this.zoomPoint)); } }
From source file:org.mwc.cmap.grideditor.chart.FixedChartComposite.java
/** * 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()}. * //from www . j a v a 2 s.com * @param x * the x coordinate (in screen coordinates). * @param y * the y-coordinate (in screen coordinates). */ public void zoomOutDomain(final double x, final double y) { final Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { final Zoomable z = (Zoomable) p; z.zoomDomainAxes(this.zoomOutFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y))); } }
From source file:org.mwc.cmap.grideditor.chart.FixedChartComposite.java
/** * 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()}./*from w ww .j a v a 2 s. com*/ * * @param x * the x coordinate (in screen coordinates). * @param y * the y-coordinate (in screen coordinates). */ public void zoomInDomain(final double x, final double y) { final Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { final Zoomable plot = (Zoomable) p; plot.zoomDomainAxes(this.zoomInFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y))); } }
From source file:com.munch.exchange.ExchangeChartComposite.java
/** * Restores the auto-range calculation on the domain axis. *///from w ww . j a va 2 s.c o m 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)); } }
From source file:org.mwc.cmap.grideditor.chart.FixedChartComposite.java
/** * Restores the auto-range calculation on the domain axis. *//*from w w w .ja v a 2 s . c o m*/ public void restoreAutoDomainBounds() { final Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { final Zoomable z = (Zoomable) p; // we need to guard against this.zoomPoint being null final 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)); } }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * 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()}. * /*from ww w . j ava 2 s. c om*/ * @param x * the x coordinate (in screen coordinates). * @param y * the y-coordinate (in screen coordinates). */ public void zoomOutDomain(double x, double y) { Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { Zoomable z = (Zoomable) p; z.zoomDomainAxes(this.zoomOutFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y))); } }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * 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()}. * // ww w . j ava2s .co m * @param x * the x coordinate (in screen coordinates). * @param y * the y-coordinate (in screen coordinates). */ public void zoomInDomain(double x, double y) { Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { Zoomable plot = (Zoomable) p; plot.zoomDomainAxes(this.zoomInFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y))); } }