List of usage examples for org.jfree.chart.axis ValueAxis valueToJava2D
public abstract double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge);
From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java
public static Point2D translateChartPoint(Point2D point, Rectangle2D imageArea, JFreeChart chart) { XYPlot plot = chart.getXYPlot();/*from w w w .j av a2 s . c om*/ double x, y; ValueAxis domainAxis = plot.getDomainAxis(); ValueAxis rangeAxis = plot.getRangeAxis(); x = domainAxis.valueToJava2D(point.getX(), imageArea, RectangleEdge.BOTTOM); y = rangeAxis.valueToJava2D(point.getY(), imageArea, RectangleEdge.LEFT); return new Point2D.Double(x, y); }
From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java
public static Point2D translateChartPoint(Point2D point, Rectangle2D imageArea, JFreeChart chart, int rangeAxisIndex) { XYPlot plot = chart.getXYPlot();// ww w .j av a 2 s . c o m double x, y; ValueAxis domainAxis = plot.getDomainAxis(); ValueAxis rangeAxis; if (rangeAxisIndex < 0 || rangeAxisIndex >= plot.getRangeAxisCount()) { rangeAxis = plot.getRangeAxis(); } else { rangeAxis = plot.getRangeAxis(rangeAxisIndex); } x = domainAxis.valueToJava2D(point.getX(), imageArea, RectangleEdge.BOTTOM); y = rangeAxis.valueToJava2D(point.getY(), imageArea, RectangleEdge.LEFT); return new Point2D.Double(x, y); }
From source file:org.geotools.renderer.chart.GeometryRenderer.java
void drawCoordinate(Coordinate c, Graphics2D g2, int series, int item, Rectangle2D dataArea, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis) { double tx = domainAxis.valueToJava2D(c.x, dataArea, plot.getDomainAxisEdge()); double ty = rangeAxis.valueToJava2D(c.y, dataArea, plot.getRangeAxisEdge()); Shape shape = getItemShape(series, item); shape = ShapeUtilities.createTranslatedShape(shape, tx, ty); if (fillCoordinates) { g2.fill(shape);//from www . j a v a 2 s. c o m } else { g2.draw(shape); } }
From source file:ucar.unidata.idv.control.chart.WayPoint.java
/** * Get the x position from the domain value * * @param dataArea data area/*from www. ja v a 2 s . com*/ * @param domainAxis domain axis * * @return The x value */ protected int getXFromValue(Rectangle2D dataArea, ValueAxis domainAxis) { return (int) domainAxis.valueToJava2D(domainValue, dataArea, RectangleEdge.BOTTOM); }
From source file:org.openaltimeter.desktopapp.annotations.XYDotAnnotation.java
@Override public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), orientation); float anchorX = (float) domainAxis.valueToJava2D(x, dataArea, domainEdge); float anchorY = (float) rangeAxis.valueToJava2D(y, dataArea, rangeEdge); if (orientation == PlotOrientation.HORIZONTAL) { float tempAnchor = anchorX; anchorX = anchorY;/*from w ww. j av a 2 s . co m*/ anchorY = tempAnchor; } // dot drawing g2.setPaint(color); g2.setStroke(new BasicStroke(1.0f)); Ellipse2D e = new Ellipse2D.Double(anchorX - size / 2, anchorY - size / 2, size, size); g2.fill(e); }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.MultiAxesCrosshairOverlay.java
@Override public void paintOverlay(Graphics2D g2, ChartPanel chartPanel) { Shape savedClip = g2.getClip(); Rectangle2D dataArea = chartPanel.getScreenDataArea(); g2.clip(dataArea);/*from www .j a v a2s. c om*/ JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis xAxis = plot.getDomainAxis(); RectangleEdge xAxisEdge = plot.getDomainAxisEdge(); Iterator iterator = this.getDomainCrosshairs().iterator(); while (iterator.hasNext()) { Crosshair ch = (Crosshair) iterator.next(); if (ch.isVisible()) { double x = ch.getValue(); double xx = xAxis.valueToJava2D(x, dataArea, xAxisEdge); if (plot.getOrientation() == PlotOrientation.VERTICAL) { drawVerticalCrosshair(g2, dataArea, xx, ch); } else { drawHorizontalCrosshair(g2, dataArea, xx, ch); } } } int rangeAxisIdx = 0; for (ArrayList<Crosshair> crosshairsForRange : rangeCrosshairs) { ValueAxis yAxis = plot.getRangeAxis(rangeAxisIdx); RectangleEdge yAxisEdge = plot.getRangeAxisEdge(rangeAxisIdx); iterator = crosshairsForRange.iterator(); while (iterator.hasNext()) { Crosshair ch = (Crosshair) iterator.next(); if (ch.isVisible()) { double y = ch.getValue(); double yy = yAxis.valueToJava2D(y, dataArea, yAxisEdge); if (plot.getOrientation() == PlotOrientation.VERTICAL) { drawHorizontalCrosshair(g2, dataArea, yy, ch); } else { drawVerticalCrosshair(g2, dataArea, yy, ch); } } } g2.setClip(savedClip); ++rangeAxisIdx; } }
From source file:org.openaltimeter.desktopapp.annotations.XYHeightAnnotation.java
@Override public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), orientation); float anchorX = (float) domainAxis.valueToJava2D(this.getX(), dataArea, domainEdge); float anchorY = (float) rangeAxis.valueToJava2D(this.getY(), dataArea, rangeEdge); if (orientation == PlotOrientation.HORIZONTAL) { float tempAnchor = anchorX; anchorX = anchorY;//from w w w. java 2s .c o m anchorY = tempAnchor; } g2.setFont(getFont()); Shape hotspot = TextUtilities.calculateRotatedStringBounds(getText(), g2, anchorX, anchorY, getTextAnchor(), getRotationAngle(), getRotationAnchor()); if (this.getBackgroundPaint() != null) { g2.setPaint(this.getBackgroundPaint()); g2.fill(hotspot); } g2.setPaint(getPaint()); TextUtilities.drawRotatedString(getText(), g2, anchorX + (3.6f * DOT_SIZE), anchorY + (0.2f * DOT_SIZE), getTextAnchor(), getRotationAngle(), getRotationAnchor()); if (this.isOutlineVisible()) { g2.setStroke(this.getOutlineStroke()); g2.setPaint(this.getOutlinePaint()); g2.draw(hotspot); } // cross drawing // g2.setPaint(getPaint()); // g2.setStroke(new BasicStroke(1.0f)); // g2.drawLine((int) anchorX - CROSS_SIZE / 2, (int) anchorY, (int) anchorX + CROSS_SIZE / 2, (int) anchorY); // g2.drawLine((int) anchorX, (int) anchorY - CROSS_SIZE / 2, (int) anchorX, (int) anchorY + CROSS_SIZE / 2); // dot drawing g2.setPaint(getPaint()); g2.setStroke(new BasicStroke(1.0f)); Ellipse2D e = new Ellipse2D.Double(anchorX - DOT_SIZE / 2, anchorY - DOT_SIZE / 2, DOT_SIZE, DOT_SIZE); g2.fill(e); String toolTip = getToolTipText(); String url = getURL(); if (toolTip != null || url != null) { addEntity(info, hotspot, rendererIndex, toolTip, url); } }
From source file:org.openfaces.component.chart.impl.renderers.LineFillRenderer.java
private double calculateItemYPoint(CategoryPlot plot, ValueAxis rangeAxis, Rectangle2D dataArea, double value) { return rangeAxis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); }
From source file:org.trade.ui.chart.renderer.HeikinAshiRenderer.java
/** * Method initialise./*from www . ja v a 2 s .c o m*/ * * @param g2 * Graphics2D * @param dataArea * Rectangle2D * @param plot * XYPlot * @param dataset * XYDataset * @param info * PlotRenderingInfo * @return XYItemRendererState * @see org.jfree.chart.renderer.xy.XYItemRenderer#initialise(Graphics2D, * Rectangle2D, XYPlot, XYDataset, PlotRenderingInfo) */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info) { ValueAxis axis = plot.getDomainAxis(); double x1 = axis.getLowerBound(); double x2 = x1 + getMaxCandleWidthInMilliseconds(); RectangleEdge edge = plot.getDomainAxisEdge(); double xx1 = axis.valueToJava2D(x1, dataArea, edge); double xx2 = axis.valueToJava2D(x2, dataArea, edge); maxCandleWidth = Math.abs(xx2 - xx1); return new XYItemRendererState(info); }
From source file:gda.plots.SimpleXYAnnotation.java
/** * Implements the XYAnnotation interface. This is actually a copy of the superclass method EXCEPT: it adds the shape * to the entity list based on the value of clickable and not whether or not there is a ToolTip; and it save the * hotpsot so that it can recognize when it is the clicked entity. * /* w ww. jav a2s . c om*/ * @param g2 * the graphics device. * @param plot * the plot. * @param dataArea * the data area. * @param domainAxis * the domain axis. * @param rangeAxis * the range axis. * @param rendererIndex * the renderer index. * @param info * an optional info object that will be populated with entity information. */ @Override public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), orientation); float anchorX = (float) domainAxis.valueToJava2D(getX(), dataArea, domainEdge); float anchorY = (float) rangeAxis.valueToJava2D(getY(), dataArea, rangeEdge); if (orientation == PlotOrientation.HORIZONTAL) { float tempAnchor = anchorX; anchorX = anchorY; anchorY = tempAnchor; } g2.setFont(getFont()); g2.setPaint(getPaint()); TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY, getTextAnchor(), getRotationAngle(), getRotationAnchor()); hotspot = TextUtilities.calculateRotatedStringBounds(getText(), g2, anchorX, anchorY, getTextAnchor(), getRotationAngle(), getRotationAnchor()); String toolTip = getToolTipText(); String url = getURL(); if (clickable || toolTip != null || url != null) { addEntity(info, hotspot, rendererIndex, toolTip, url); } }