afreechart/src/main/java/org/afree/chart/annotations/XYPointerAnnotation.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  the plot rendering info.
     */
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  the plot rendering info.
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 the plot rendering info .
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);
        double j2DX = domainAxis.valueToJava2D(getX(), dataArea, domainEdge);
        double j2DY = rangeAxis.valueToJava2D(getY(), dataArea, rangeEdge);
        if (orientation == PlotOrientation.HORIZONTAL) {
            double temp = j2DX;
            j2DX = j2DY;
            j2DY = temp;
        }
        double startX = j2DX + Math.cos(this.angle) * this.baseRadius;
        double startY = j2DY + Math.sin(this.angle) * this.baseRadius;
        double endX = j2DX + Math.cos(this.angle) * this.tipRadius;
        double endY = j2DY + Math.sin(this.angle) * this.tipRadius;
        double arrowBaseX = endX + Math.cos(this.angle) * this.arrowLength;
        double arrowBaseY = endY + Math.sin(this.angle) * this.arrowLength;
        double arrowLeftX = arrowBaseX
                + Math.cos(this.angle + Math.PI / 2.0) * this.arrowWidth;
        double arrowLeftY = arrowBaseY
                + Math.sin(this.angle + Math.PI / 2.0) * this.arrowWidth;
        double arrowRightX = arrowBaseX
                - Math.cos(this.angle + Math.PI / 2.0) * this.arrowWidth;
        double arrowRightY = arrowBaseY
                - Math.sin(this.angle + Math.PI / 2.0) * this.arrowWidth;
        PathShape arrow = new PathShape();
        arrow.moveTo((float) endX, (float) endY);
        arrow.lineTo((float) arrowLeftX, (float) arrowLeftY);
        arrow.lineTo((float) arrowRightX, (float) arrowRightY);
        arrow.closePath();
        Paint paint = PaintUtility.createPaint(
                Paint.ANTI_ALIAS_FLAG,
                this.arrowPaintType, 
                this.arrowStroke, 
                this.arrowEffect);
        LineShape line = new LineShape(startX, startY, endX, endY);
        canvas.drawLine(line.getX1(), line.getY1(), 
                line.getX2(), line.getY2(), paint);
        canvas.drawPath(arrow.getPath(), paint);
        double labelX = j2DX + Math.cos(this.angle) * (this.baseRadius
                + this.labelOffset);
        double labelY = j2DY + Math.sin(this.angle) * (this.baseRadius
                + this.labelOffset);
        if (getBackgroundPaintType() != null) {
            PaintUtility.updatePaint(paint, getBackgroundPaintType());
            canvas.drawPaint(paint);
        }
        PaintUtility.updatePaint(paint, getPaintType());
        TextUtilities.drawRotatedString(
                getText(), canvas, (float) labelX, (float) labelY, getTextAnchor(),
                getRotationAngle(), getRotationAnchor(),paint);
        if (isOutlineVisible()) {
            PaintUtility.updatePaint(paint, getOutlinePaintType());
            paint.setStrokeWidth(getOutlineStroke());
            canvas.drawLine((float)startX, (float)startY, (float)endX, (float)endY, paint);
        }
        String toolTip = getToolTipText();
        String url = getURL();
        Shape hotspot = TextUtilities.getTextBounds(getText(),paint);
        if (toolTip != null || url != null) {
            addEntity(info, hotspot, 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 ) ; double j2DX = domainAxis . valueToJava2D ( getX ( ) , dataArea , domainEdge ) ; double j2DY = rangeAxis . valueToJava2D ( getY ( ) , dataArea , rangeEdge ) ; if ( orientation == PlotOrientation . HORIZONTAL ) { double temp = j2DX ; j2DX = j2DY ; j2DY = temp ; } double startX = j2DX + Math . cos ( this . angle ) * this . baseRadius ; double startY = j2DY + Math . sin ( this . angle ) * this . baseRadius ; double endX = j2DX + Math . cos ( this . angle ) * this . tipRadius ; double endY = j2DY + Math . sin ( this . angle ) * this . tipRadius ; double arrowBaseX = endX + Math . cos ( this . angle ) * this . arrowLength ; double arrowBaseY = endY + Math . sin ( this . angle ) * this . arrowLength ; double arrowLeftX = arrowBaseX + Math . cos ( this . angle + Math . PI / 2.0 ) * this . arrowWidth ; double arrowLeftY = arrowBaseY + Math . sin ( this . angle + Math . PI / 2.0 ) * this . arrowWidth ; double arrowRightX = arrowBaseX - Math . cos ( this . angle + Math . PI / 2.0 ) * this . arrowWidth ; double arrowRightY = arrowBaseY - Math . sin ( this . angle + Math . PI / 2.0 ) * this . arrowWidth ; PathShape arrow = new PathShape ( ) ; arrow . moveTo ( ( float ) endX , ( float ) endY ) ; arrow . lineTo ( ( float ) arrowLeftX , ( float ) arrowLeftY ) ; arrow . lineTo ( ( float ) arrowRightX , ( float ) arrowRightY ) ; arrow . closePath ( ) ; Paint paint = PaintUtility . createPaint ( Paint . ANTI_ALIAS_FLAG , this . arrowPaintType , this . arrowStroke , this . arrowEffect ) ; LineShape line = new LineShape ( startX , startY , endX , endY ) ; canvas . drawLine ( line . getX1 ( ) , line . getY1 ( ) , line . getX2 ( ) , line . getY2 ( ) , paint ) ; canvas . drawPath ( arrow . getPath ( ) , paint ) ; double labelX = j2DX + Math . cos ( this . angle ) * ( this . baseRadius + this . labelOffset ) ; double labelY = j2DY + Math . sin ( this . angle ) * ( this . baseRadius + this . labelOffset ) ; if ( getBackgroundPaintType ( ) != null ) { PaintUtility . updatePaint ( paint , getBackgroundPaintType ( ) ) ; canvas . drawPaint ( paint ) ; } PaintUtility . updatePaint ( paint , getPaintType ( ) ) ; TextUtilities . drawRotatedString ( getText ( ) , canvas , ( float ) labelX , ( float ) labelY , getTextAnchor ( ) , getRotationAngle ( ) , getRotationAnchor ( ) , paint ) ; if ( isOutlineVisible ( ) ) { PaintUtility . updatePaint ( paint , getOutlinePaintType ( ) ) ; paint . setStrokeWidth ( getOutlineStroke ( ) ) ; canvas . drawLine ( ( float ) startX , ( float ) startY , ( float ) endX , ( float ) endY , paint ) ; } String toolTip = getToolTipText ( ) ; String url = getURL ( ) ; Shape hotspot = TextUtilities . getTextBounds ( getText ( ) , paint ) ; if ( toolTip != null || url != null ) { addEntity ( info , hotspot , rendererIndex , toolTip , url ) ; } }
Draws the annotation.
Draws the annotation .
//        canvas.setStroke(this.arrowStroke); //        canvas.setPaint(this.arrowPaint); //        canvas.draw(line); //        canvas.fill(arrow); // draw the label //        canvas.setFont(getFont()); //        Shape hotspot = TextUtilities.calculateRotatedStringBounds( //                getText(), canvas, (float) labelX, (float) labelY, getTextAnchor(), //                getRotationAngle(), getRotationAnchor()); //        hotspot = TextUtilities.drawRotatedString( //                getText(), canvas, (float) labelX, (float) labelY, getTextAnchor(), //                getRotationAngle(), getRotationAnchor(),paint);         //            canvas.setPaint(getBackgroundPaint()); //            canvas.fill(hotspot); //        canvas.setPaint(getPaint()); //        TextUtilities.drawRotatedString(getText(), canvas, (float) labelX, //                (float) labelY, getTextAnchor(), getRotationAngle(), //                getRotationAnchor()); //            canvas.setStroke(getOutlineStroke()); //            canvas.setPaint(getOutlinePaint()); //            canvas.draw(hotspot);