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);
}
}
Aggregations