List of usage examples for org.jfree.chart.plot Zoomable zoomDomainAxes
public void zoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source);
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 w ww. j a va2 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:de.xirp.ui.widgets.custom.XChartComposite.java
/** * Zooms in on a selected region.//w w w .j a v a 2 s . c om * * @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.//from ww w. ja v a 2s .co 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 v a 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:com.isti.traceview.common.TraceViewChartPanel.java
/** * Zooms in on a selected region.//from ww w. j a va2s .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
/** * 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). *//*from ww w . j a v a 2 s .co m*/ 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)), this.zoomAroundAnchor); } }
From source file:org.rdv.viz.chart.ChartPanel.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()}. * * @param x the x coordinate (in screen coordinates). * @param y the y-coordinate (in screen coordinates). *//*from w w w.j a v a2s . c om*/ 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)), this.zoomAroundAnchor); } }
From source file:org.rdv.viz.chart.ChartPanel.java
/** * Zooms in on a selected region.// w w w . j ava 2s .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) { // 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()); } } } }