org.jfree.chart.plot.PlotRenderingInfo Java Examples
The following examples show how to use
org.jfree.chart.plot.PlotRenderingInfo.
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: CategoryAxis.java From opensim-gui with Apache License 2.0 | 6 votes |
/** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (<code>null</code> not permitted). * @param cursor the cursor location. * @param plotArea the area within which the axis should be drawn * (<code>null</code> not permitted). * @param dataArea the area within which the plot is being drawn * (<code>null</code> not permitted). * @param edge the location of the axis (<code>null</code> not permitted). * @param plotState collects information about the plot * (<code>null</code> permitted). * * @return The axis state (never <code>null</code>). */ public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { // if the axis is not visible, don't draw it... if (!isVisible()) { return new AxisState(cursor); } if (isAxisLineVisible()) { drawAxisLine(g2, cursor, dataArea, edge); } // draw the category labels and axis label AxisState state = new AxisState(cursor); state = drawCategoryLabels(g2, plotArea, dataArea, edge, state, plotState); state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); return state; }
Example #2
Source File: Cardumen_0075_s.java From coming with MIT License | 6 votes |
/** * Draws all the annotations for the specified layer. * * @param g2 the graphics device. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param layer the layer. * @param info the plot rendering info. * * @since 1.2.0 */ public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis, Layer layer, PlotRenderingInfo info) { Iterator iterator = null; if (layer.equals(Layer.FOREGROUND)) { iterator = this.foregroundAnnotations.iterator(); } else if (layer.equals(Layer.BACKGROUND)) { iterator = this.backgroundAnnotations.iterator(); } else { // should not get here throw new RuntimeException("Unknown layer."); } while (iterator.hasNext()) { CategoryAnnotation annotation = (CategoryAnnotation) iterator.next(); annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis, 0, info); } }
Example #3
Source File: SamplingXYLineRenderer.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Initialises the renderer. * <P> * This method will be called before the first item is rendered, giving the * renderer an opportunity to initialise any state information it wants to * maintain. The renderer can do nothing if it chooses. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param data the data. * @param info an optional info collection object to return data back to * the caller. * * @return The renderer state. */ @Override public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info) { double dpi = 72; // Integer dpiVal = (Integer) g2.getRenderingHint(HintKey.DPI); // if (dpiVal != null) { // dpi = dpiVal.intValue(); // } State state = new State(info); state.seriesPath = new GeneralPath(); state.intervalPath = new GeneralPath(); state.dX = 72.0 / dpi; return state; }
Example #4
Source File: ScrollHandlerFX.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * 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 #5
Source File: Cardumen_0075_t.java From coming with MIT License | 6 votes |
/** * Draws all the annotations for the specified layer. * * @param g2 the graphics device. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param layer the layer. * @param info the plot rendering info. * * @since 1.2.0 */ public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis, Layer layer, PlotRenderingInfo info) { Iterator iterator = null; if (layer.equals(Layer.FOREGROUND)) { iterator = this.foregroundAnnotations.iterator(); } else if (layer.equals(Layer.BACKGROUND)) { iterator = this.backgroundAnnotations.iterator(); } else { // should not get here throw new RuntimeException("Unknown layer."); } while (iterator.hasNext()) { CategoryAnnotation annotation = (CategoryAnnotation) iterator.next(); annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis, 0, info); } }
Example #6
Source File: JGenProg2017_000_t.java From coming with MIT License | 6 votes |
/** * Draws all the annotations for the specified layer. * * @param g2 the graphics device. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param layer the layer. * @param info the plot rendering info. * * @since 1.2.0 */ public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis, Layer layer, PlotRenderingInfo info) { Iterator iterator = null; if (layer.equals(Layer.FOREGROUND)) { iterator = this.foregroundAnnotations.iterator(); } else if (layer.equals(Layer.BACKGROUND)) { iterator = this.backgroundAnnotations.iterator(); } else { // should not get here throw new RuntimeException("Unknown layer."); } while (iterator.hasNext()) { CategoryAnnotation annotation = (CategoryAnnotation) iterator.next(); annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis, 0, info); } }
Example #7
Source File: Cardumen_0075_s.java From coming with MIT License | 6 votes |
/** * Creates a new state instance---this method is called from the * {@link #initialise(Graphics2D, Rectangle2D, CategoryPlot, int, * PlotRenderingInfo)} method. Subclasses can override this method if * they need to use a subclass of {@link CategoryItemRendererState}. * * @param info collects plot rendering info (<code>null</code> permitted). * * @return The new state instance (never <code>null</code>). * * @since 1.0.5 */ protected CategoryItemRendererState createState(PlotRenderingInfo info) { CategoryItemRendererState state = new CategoryItemRendererState(info); int[] visibleSeriesTemp = new int[this.rowCount]; int visibleSeriesCount = 0; for (int row = 0; row < this.rowCount; row++) { if (isSeriesVisible(row)) { visibleSeriesTemp[visibleSeriesCount] = row; visibleSeriesCount++; } } int[] visibleSeries = new int[visibleSeriesCount]; System.arraycopy(visibleSeriesTemp, 0, visibleSeries, 0, visibleSeriesCount); state.setVisibleSeriesArray(visibleSeries); return state; }
Example #8
Source File: PeriodAxis.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (<code>null</code> not permitted). * @param cursor the cursor location (determines where to draw the axis). * @param plotArea the area within which the axes and plot should be drawn. * @param dataArea the area within which the data should be drawn. * @param edge the axis location (<code>null</code> not permitted). * @param plotState collects information about the plot * (<code>null</code> permitted). * * @return The axis state (never <code>null</code>). */ public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { AxisState axisState = new AxisState(cursor); if (isAxisLineVisible()) { drawAxisLine(g2, cursor, dataArea, edge); } drawTickMarks(g2, axisState, dataArea, edge); for (int band = 0; band < this.labelInfo.length; band++) { axisState = drawTickLabels(band, g2, axisState, dataArea, edge); } // draw the axis label (note that 'state' is passed in *and* // returned)... axisState = drawLabel(getLabel(), g2, plotArea, dataArea, edge, axisState, plotState); return axisState; }
Example #9
Source File: jMutRepair_000_s.java From coming with MIT License | 6 votes |
/** * Creates a new state instance---this method is called from the * {@link #initialise(Graphics2D, Rectangle2D, CategoryPlot, int, * PlotRenderingInfo)} method. Subclasses can override this method if * they need to use a subclass of {@link CategoryItemRendererState}. * * @param info collects plot rendering info (<code>null</code> permitted). * * @return The new state instance (never <code>null</code>). * * @since 1.0.5 */ protected CategoryItemRendererState createState(PlotRenderingInfo info) { CategoryItemRendererState state = new CategoryItemRendererState(info); int[] visibleSeriesTemp = new int[this.rowCount]; int visibleSeriesCount = 0; for (int row = 0; row < this.rowCount; row++) { if (isSeriesVisible(row)) { visibleSeriesTemp[visibleSeriesCount] = row; visibleSeriesCount++; } } int[] visibleSeries = new int[visibleSeriesCount]; System.arraycopy(visibleSeriesTemp, 0, visibleSeries, 0, visibleSeriesCount); state.setVisibleSeriesArray(visibleSeries); return state; }
Example #10
Source File: PeriodAxis.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (<code>null</code> not permitted). * @param cursor the cursor location (determines where to draw the axis). * @param plotArea the area within which the axes and plot should be drawn. * @param dataArea the area within which the data should be drawn. * @param edge the axis location (<code>null</code> not permitted). * @param plotState collects information about the plot * (<code>null</code> permitted). * * @return The axis state (never <code>null</code>). */ @Override public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { AxisState axisState = new AxisState(cursor); if (isAxisLineVisible()) { drawAxisLine(g2, cursor, dataArea, edge); } if (isTickMarksVisible()) { drawTickMarks(g2, axisState, dataArea, edge); } if (isTickLabelsVisible()) { for (int band = 0; band < this.labelInfo.length; band++) { axisState = drawTickLabels(band, g2, axisState, dataArea, edge); } } if (getAttributedLabel() != null) { axisState = drawAttributedLabel(getAttributedLabel(), g2, plotArea, dataArea, edge, axisState); } else { axisState = drawLabel(getLabel(), g2, plotArea, dataArea, edge, axisState); } return axisState; }
Example #11
Source File: ChartPanel.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * 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) { 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); } } } }
Example #12
Source File: NumberAxis.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (<code>null</code> not permitted). * @param cursor the cursor location. * @param plotArea the area within which the axes and data should be drawn * (<code>null</code> not permitted). * @param dataArea the area within which the data should be drawn * (<code>null</code> not permitted). * @param edge the location of the axis (<code>null</code> not permitted). * @param plotState collects information about the plot * (<code>null</code> permitted). * * @return The axis state (never <code>null</code>). */ @Override public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { AxisState state; // if the axis is not visible, don't draw it... if (!isVisible()) { state = new AxisState(cursor); // even though the axis is not visible, we need ticks for the // gridlines... List ticks = refreshTicks(g2, state, dataArea, edge); state.setTicks(ticks); return state; } // draw the tick marks and labels... state = drawTickMarksAndLabels(g2, cursor, plotArea, dataArea, edge); if (getAttributedLabel() != null) { state = drawAttributedLabel(getAttributedLabel(), g2, plotArea, dataArea, edge, state); } else { state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); } createAndAddEntity(cursor, state, dataArea, edge, plotState); return state; }
Example #13
Source File: jKali_000_t.java From coming with MIT License | 5 votes |
/** * Draws all the annotations for the specified layer. * * @param g2 the graphics device. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param layer the layer. * @param info the plot rendering info. * * @since 1.2.0 */ public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis, Layer layer, PlotRenderingInfo info) { Iterator iterator = null; if (layer.equals(Layer.FOREGROUND)) { iterator = this.foregroundAnnotations.iterator(); } else if (layer.equals(Layer.BACKGROUND)) { iterator = this.backgroundAnnotations.iterator(); } else { // should not get here throw new RuntimeException("Unknown layer."); } while (iterator.hasNext()) { CategoryAnnotation annotation = (CategoryAnnotation) iterator.next(); annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis, 0, info); } }
Example #14
Source File: ScrollHandlerFX.java From jfreechart-fx with GNU Lesser General Public License v2.1 | 5 votes |
/** * Handle the case where a plot implements the {@link Zoomable} interface. * * @param canvas the chart canvas. * @param zoomable the zoomable plot. * @param e the mouse wheel event. */ private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, ScrollEvent e) { if (canvas.getChart() == null) { return; } // 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 (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 #15
Source File: Cardumen_00139_t.java From coming with MIT License | 5 votes |
/** * Creates a new state instance---this method is called from the * {@link #initialise(Graphics2D, Rectangle2D, CategoryPlot, int, * PlotRenderingInfo)} method. Subclasses can override this method if * they need to use a subclass of {@link CategoryItemRendererState}. * * @param info collects plot rendering info (<code>null</code> permitted). * * @return The new state instance (never <code>null</code>). * * @since 1.0.5 */ protected CategoryItemRendererState createState(PlotRenderingInfo info) { CategoryItemRendererState state = new CategoryItemRendererState(info); int[] visibleSeriesTemp = new int[this.rowCount]; int visibleSeriesCount = 0; for (int row = 0; row < this.rowCount; row++) { if (isSeriesVisible(row)) { visibleSeriesTemp[visibleSeriesCount] = row; visibleSeriesCount++; } } int[] visibleSeries = new int[visibleSeriesCount]; System.arraycopy(visibleSeriesTemp, 0, visibleSeries, 0, visibleSeriesCount); state.setVisibleSeriesArray(visibleSeries); return state; }
Example #16
Source File: SubCategoryAxis.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (<code>null</code> not permitted). * @param cursor the cursor location. * @param plotArea the area within which the axis should be drawn * (<code>null</code> not permitted). * @param dataArea the area within which the plot is being drawn * (<code>null</code> not permitted). * @param edge the location of the axis (<code>null</code> not permitted). * @param plotState collects information about the plot * (<code>null</code> permitted). * * @return The axis state (never <code>null</code>). */ @Override public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { // if the axis is not visible, don't draw it... if (!isVisible()) { return new AxisState(cursor); } if (isAxisLineVisible()) { drawAxisLine(g2, cursor, dataArea, edge); } // draw the category labels and axis label AxisState state = new AxisState(cursor); state = drawSubCategoryLabels(g2, plotArea, dataArea, edge, state, plotState); state = drawCategoryLabels(g2, plotArea, dataArea, edge, state, plotState); if (getAttributedLabel() != null) { state = drawAttributedLabel(getAttributedLabel(), g2, plotArea, dataArea, edge, state); } else { state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); } return state; }
Example #17
Source File: VenndiPlot.java From chipster with MIT License | 5 votes |
private void createEntity(Shape shape, PlotRenderingInfo info) { if (info != null) { EntityCollection entities = info.getOwner().getEntityCollection(); if (entities != null) { entities.add( new ChartEntity(shape)); } } }
Example #18
Source File: CyclicNumberAxis.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Draws the axis. * * @param g2 the graphics device (<code>null</code> not permitted). * @param cursor the cursor position. * @param plotArea the plot area (<code>null</code> not permitted). * @param dataArea the data area (<code>null</code> not permitted). * @param edge the edge (<code>null</code> not permitted). * @param plotState collects information about the plot * (<code>null</code> permitted). * * @return The axis state (never <code>null</code>). */ @Override public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { AxisState ret = super.draw(g2, cursor, plotArea, dataArea, edge, plotState); if (isAdvanceLineVisible()) { double xx = valueToJava2D(getRange().getUpperBound(), dataArea, edge); Line2D mark = null; g2.setStroke(getAdvanceLineStroke()); g2.setPaint(getAdvanceLinePaint()); if (edge == RectangleEdge.LEFT) { mark = new Line2D.Double(cursor, xx, cursor + dataArea.getWidth(), xx); } else if (edge == RectangleEdge.RIGHT) { mark = new Line2D.Double(cursor - dataArea.getWidth(), xx, cursor, xx); } else if (edge == RectangleEdge.TOP) { mark = new Line2D.Double(xx, cursor + dataArea.getHeight(), xx, cursor); } else if (edge == RectangleEdge.BOTTOM) { mark = new Line2D.Double(xx, cursor, xx, cursor - dataArea.getHeight()); } g2.draw(mark); } return ret; }
Example #19
Source File: AbstractXYItemRenderer.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * Draws all the annotations for the specified layer. * * @param g2 the graphics device. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param layer the layer. * @param info the plot rendering info. */ public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, Layer layer, PlotRenderingInfo info) { Iterator iterator = null; if (layer.equals(Layer.FOREGROUND)) { iterator = this.foregroundAnnotations.iterator(); } else if (layer.equals(Layer.BACKGROUND)) { iterator = this.backgroundAnnotations.iterator(); } else { // should not get here throw new RuntimeException("Unknown layer."); } while (iterator.hasNext()) { XYAnnotation annotation = (XYAnnotation) iterator.next(); annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis, 0, info); } }
Example #20
Source File: BarRenderer3D.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Initialises the renderer and returns a state object that will be passed * to subsequent calls to the drawItem method. This method gets called * once at the start of the process of drawing a chart. * * @param g2 the graphics device. * @param dataArea the area in which the data is to be plotted. * @param plot the plot. * @param rendererIndex the renderer index. * @param info collects chart rendering information for return to caller. * * @return The renderer state. */ public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info) { Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); CategoryItemRendererState state = super.initialise(g2, adjusted, plot, rendererIndex, info); return state; }
Example #21
Source File: NeutralLossDataPointRenderer.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { if (series > 0) { g2.setComposite(alphaComp); } else if (series == 0) { g2.setComposite(alphaCompOriginal); } super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState, pass); }
Example #22
Source File: PseudoSpectraRenderer.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
@Override public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { if (isTransparent) g2.setComposite(alphaComp); super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState, pass); }
Example #23
Source File: AbstractXYAnnotation.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * A utility method for adding an {@link XYAnnotationEntity} to * a {@link PlotRenderingInfo} instance. * * @param info the plot rendering info (<code>null</code> permitted). * @param hotspot the hotspot area. * @param rendererIndex the renderer index. * @param toolTipText the tool tip text. * @param urlText the URL text. */ protected void addEntity(PlotRenderingInfo info, Shape hotspot, int rendererIndex, String toolTipText, String urlText) { if (info == null) { return; } EntityCollection entities = info.getOwner().getEntityCollection(); if (entities == null) { return; } XYAnnotationEntity entity = new XYAnnotationEntity(hotspot, rendererIndex, toolTipText, urlText); entities.add(entity); }
Example #24
Source File: CustomXYStepRenderer.java From openbd-core with GNU General Public License v3.0 | 5 votes |
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState, pass); // draw the item label if there is one... if (isItemLabelVisible(series, item)) { // get the data point... double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); if (Double.isNaN(y1)) { return; } RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); double xx = transX1; double yy = transY1; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { xx = transY1; yy = transX1; } drawItemLabel(g2, orientation, dataset, series, item, xx, yy, (y1 < 0.0)); } }
Example #25
Source File: PanHandlerFX.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Handles a mouse dragged event by calculating the distance panned and * updating the axes accordingly. * * @param canvas the JavaFX canvas (<code>null</code> not permitted). * @param e the mouse event (<code>null</code> not permitted). */ public void handleMouseDragged(ChartCanvas canvas, MouseEvent e) { if (this.panLast == null) { //handle panning if we have a start point else unregister canvas.clearLiveHandler(); return; } JFreeChart chart = canvas.getChart(); double dx = e.getX() - this.panLast.getX(); double dy = e.getY() - this.panLast.getY(); if (dx == 0.0 && dy == 0.0) { return; } double wPercent = -dx / this.panW; double hPercent = dy / this.panH; boolean old = chart.getPlot().isNotify(); chart.getPlot().setNotify(false); Pannable p = (Pannable) chart.getPlot(); PlotRenderingInfo info = canvas.getRenderingInfo().getPlotInfo(); if (p.getOrientation().isVertical()) { p.panDomainAxes(wPercent, info, this.panLast); p.panRangeAxes(hPercent, info, this.panLast); } else { p.panDomainAxes(hPercent, info, this.panLast); p.panRangeAxes(wPercent, info, this.panLast); } this.panLast = new Point2D.Double(e.getX(), e.getY()); chart.getPlot().setNotify(old); }
Example #26
Source File: ChartLogicsFX.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * 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 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); } }
Example #27
Source File: MouseWheelHandler.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * 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 #28
Source File: AbstractXYAnnotation.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * A utility method for adding an {@link XYAnnotationEntity} to * a {@link PlotRenderingInfo} instance. * * @param info the plot rendering info (<code>null</code> permitted). * @param hotspot the hotspot area. * @param rendererIndex the renderer index. * @param toolTipText the tool tip text. * @param urlText the URL text. */ protected void addEntity(PlotRenderingInfo info, Shape hotspot, int rendererIndex, String toolTipText, String urlText) { if (info == null) { return; } EntityCollection entities = info.getOwner().getEntityCollection(); if (entities == null) { return; } XYAnnotationEntity entity = new XYAnnotationEntity(hotspot, rendererIndex, toolTipText, urlText); entities.add(entity); }
Example #29
Source File: CategoryAxis.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (<code>null</code> not permitted). * @param cursor the cursor location. * @param plotArea the area within which the axis should be drawn * (<code>null</code> not permitted). * @param dataArea the area within which the plot is being drawn * (<code>null</code> not permitted). * @param edge the location of the axis (<code>null</code> not permitted). * @param plotState collects information about the plot * (<code>null</code> permitted). * * @return The axis state (never <code>null</code>). */ @Override public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { // if the axis is not visible, don't draw it... if (!isVisible()) { return new AxisState(cursor); } if (isAxisLineVisible()) { drawAxisLine(g2, cursor, dataArea, edge); } AxisState state = new AxisState(cursor); if (isTickMarksVisible()) { drawTickMarks(g2, cursor, dataArea, edge, state); } createAndAddEntity(cursor, state, dataArea, edge, plotState); // draw the category labels and axis label state = drawCategoryLabels(g2, plotArea, dataArea, edge, state, plotState); if (getAttributedLabel() != null) { state = drawAttributedLabel(getAttributedLabel(), g2, plotArea, dataArea, edge, state); } else { state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); } return state; }
Example #30
Source File: CyclicNumberAxis.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Draws the axis. * * @param g2 the graphics device (<code>null</code> not permitted). * @param cursor the cursor position. * @param plotArea the plot area (<code>null</code> not permitted). * @param dataArea the data area (<code>null</code> not permitted). * @param edge the edge (<code>null</code> not permitted). * @param plotState collects information about the plot * (<code>null</code> permitted). * * @return The axis state (never <code>null</code>). */ @Override public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { AxisState ret = super.draw(g2, cursor, plotArea, dataArea, edge, plotState); if (isAdvanceLineVisible()) { double xx = valueToJava2D(getRange().getUpperBound(), dataArea, edge); Line2D mark = null; g2.setStroke(getAdvanceLineStroke()); g2.setPaint(getAdvanceLinePaint()); if (edge == RectangleEdge.LEFT) { mark = new Line2D.Double(cursor, xx, cursor + dataArea.getWidth(), xx); } else if (edge == RectangleEdge.RIGHT) { mark = new Line2D.Double(cursor - dataArea.getWidth(), xx, cursor, xx); } else if (edge == RectangleEdge.TOP) { mark = new Line2D.Double(xx, cursor + dataArea.getHeight(), xx, cursor); } else if (edge == RectangleEdge.BOTTOM) { mark = new Line2D.Double(xx, cursor, xx, cursor - dataArea.getHeight()); } g2.draw(mark); } return ret; }