Search in sources :

Example 6 with AxisLocation

use of org.jfree.chart.axis.AxisLocation in project SIMVA-SoS by SESoS.

the class XYDataImageAnnotation method draw.

/**
 * Draws the annotation.  This method is called by the drawing code in the
 * {@link XYPlot} class, you don't normally need to call this method
 * directly.
 *
 * @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  if supplied, this info object 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();
    AxisLocation xAxisLocation = plot.getDomainAxisLocation();
    AxisLocation yAxisLocation = plot.getRangeAxisLocation();
    RectangleEdge xEdge = Plot.resolveDomainAxisLocation(xAxisLocation, orientation);
    RectangleEdge yEdge = Plot.resolveRangeAxisLocation(yAxisLocation, orientation);
    float j2DX0 = (float) domainAxis.valueToJava2D(this.x, dataArea, xEdge);
    float j2DY0 = (float) rangeAxis.valueToJava2D(this.y, dataArea, yEdge);
    float j2DX1 = (float) domainAxis.valueToJava2D(this.x + this.w, dataArea, xEdge);
    float j2DY1 = (float) rangeAxis.valueToJava2D(this.y + this.h, dataArea, yEdge);
    float xx0 = 0.0f;
    float yy0 = 0.0f;
    float xx1 = 0.0f;
    float yy1 = 0.0f;
    if (orientation == PlotOrientation.HORIZONTAL) {
        xx0 = j2DY0;
        xx1 = j2DY1;
        yy0 = j2DX0;
        yy1 = j2DX1;
    } else if (orientation == PlotOrientation.VERTICAL) {
        xx0 = j2DX0;
        xx1 = j2DX1;
        yy0 = j2DY0;
        yy1 = j2DY1;
    }
    // TODO: rotate the image when drawn with horizontal orientation?
    g2.drawImage(this.image, (int) xx0, (int) Math.min(yy0, yy1), (int) (xx1 - xx0), (int) Math.abs(yy1 - yy0), null);
    String toolTip = getToolTipText();
    String url = getURL();
    if (toolTip != null || url != null) {
        addEntity(info, new Rectangle2D.Float(xx0, yy0, (xx1 - xx0), (yy1 - yy0)), rendererIndex, toolTip, url);
    }
}
Also used : AxisLocation(org.jfree.chart.axis.AxisLocation) PlotOrientation(org.jfree.chart.plot.PlotOrientation) Rectangle2D(java.awt.geom.Rectangle2D) RectangleEdge(org.jfree.ui.RectangleEdge)

Aggregations

AxisLocation (org.jfree.chart.axis.AxisLocation)6 RectangleEdge (org.jfree.ui.RectangleEdge)4 Rectangle2D (java.awt.geom.Rectangle2D)3 PlotOrientation (org.jfree.chart.plot.PlotOrientation)3 Point2D (java.awt.geom.Point2D)2 TreeMap (java.util.TreeMap)2 ValueAxis (org.jfree.chart.axis.ValueAxis)2 CategoryAxis (org.jfree.chart.axis.CategoryAxis)1 BlockParams (org.jfree.chart.block.BlockParams)1 EntityBlockResult (org.jfree.chart.block.EntityBlockResult)1 RectangleConstraint (org.jfree.chart.block.RectangleConstraint)1 AbstractCategoryItemRenderer (org.jfree.chart.renderer.category.AbstractCategoryItemRenderer)1 CategoryItemRenderer (org.jfree.chart.renderer.category.CategoryItemRenderer)1 AbstractXYItemRenderer (org.jfree.chart.renderer.xy.AbstractXYItemRenderer)1 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)1 Range (org.jfree.data.Range)1 CategoryDataset (org.jfree.data.category.CategoryDataset)1 XYDataset (org.jfree.data.xy.XYDataset)1 Size2D (org.jfree.ui.Size2D)1