afreechart/src/main/java/org/afree/chart/annotations/XYDrawableAnnotation.java
/**
     * Draws the annotation.
     *
     * @param canvas  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.
     */
Draws the annotation.
@param canvas  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.
Draws the annotation . @param canvas 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 .
public void draw(Canvas canvas, XYPlot plot, RectShape 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 j2DX = (float) domainAxis.valueToJava2D(this.x, dataArea,
                domainEdge);
        float j2DY = (float) rangeAxis.valueToJava2D(this.y, dataArea,
                rangeEdge);
        RectShape displayArea = new RectShape(
                j2DX - this.displayWidth / 2.0,
                j2DY - this.displayHeight / 2.0, this.displayWidth,
                this.displayHeight);
        canvas.save();
        RectShape drawArea = new RectShape(0.0, 0.0,
                this.displayWidth * this.drawScaleFactor,
                this.displayHeight * this.drawScaleFactor);
        canvas.scale((float)(1/this.drawScaleFactor), (float)(1/this.drawScaleFactor));
        canvas.translate((float)((j2DX - this.displayWidth / 2.0) * this.drawScaleFactor),
                (float)((j2DY - this.displayHeight / 2.0) * this.drawScaleFactor));
        this.drawable.draw(canvas, drawArea);
        canvas.restore();
        String toolTip = getToolTipText();
        String url = getURL();
        if (toolTip != null || url != null) {
            addEntity(info, displayArea, rendererIndex, toolTip, url);
        }
    }
public void draw ( Canvas canvas , XYPlot plot , RectShape 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 j2DX = ( float ) domainAxis . valueToJava2D ( this . x , dataArea , domainEdge ) ; float j2DY = ( float ) rangeAxis . valueToJava2D ( this . y , dataArea , rangeEdge ) ; RectShape displayArea = new RectShape ( j2DX - this . displayWidth / 2.0 , j2DY - this . displayHeight / 2.0 , this . displayWidth , this . displayHeight ) ; canvas . save ( ) ; RectShape drawArea = new RectShape ( 0.0 , 0.0 , this . displayWidth * this . drawScaleFactor , this . displayHeight * this . drawScaleFactor ) ; canvas . scale ( ( float ) ( 1 / this . drawScaleFactor ) , ( float ) ( 1 / this . drawScaleFactor ) ) ; canvas . translate ( ( float ) ( ( j2DX - this . displayWidth / 2.0 ) * this . drawScaleFactor ) , ( float ) ( ( j2DY - this . displayHeight / 2.0 ) * this . drawScaleFactor ) ) ; this . drawable . draw ( canvas , drawArea ) ; canvas . restore ( ) ; String toolTip = getToolTipText ( ) ; String url = getURL ( ) ; if ( toolTip != null || url != null ) { addEntity ( info , displayArea , rendererIndex , toolTip , url ) ; } }
Draws the annotation.
Draws the annotation .
// here we change the AffineTransform so we can draw the annotation // to a larger area and scale it down into the display area // afterwards, the original transform is restored