afreechart/src/main/java/org/afree/chart/annotations/XYTitleAnnotation.java
/**
     * 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 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.  This method is called by the drawing code in the
XYPlot class, you don't normally need to call this method
directly.

@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 . This method is called by the drawing code in the XYPlot class you don ' t normally need to call this method directly . @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();
        AxisLocation domainAxisLocation = plot.getDomainAxisLocation();
        AxisLocation rangeAxisLocation = plot.getRangeAxisLocation();
        RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
                domainAxisLocation, orientation);
        RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
                rangeAxisLocation, orientation);
        Range xRange = domainAxis.getRange();
        Range yRange = rangeAxis.getRange();
        double anchorX = 0.0;
        double anchorY = 0.0;
        if (this.coordinateType == XYCoordinateType.RELATIVE) {
            anchorX = xRange.getLowerBound() + (this.x * xRange.getLength());
            anchorY = yRange.getLowerBound() + (this.y * yRange.getLength());
        }
        else {
            anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
            anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
        }
        float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea,
                domainEdge);
        float j2DY = (float) rangeAxis.valueToJava2D(anchorY, dataArea,
                rangeEdge);
        float xx = 0.0f;
        float yy = 0.0f;
        if (orientation == PlotOrientation.HORIZONTAL) {
            xx = j2DY;
            yy = j2DX;
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            xx = j2DX;
            yy = j2DY;
        }
        double maxW = dataArea.getWidth();
        double maxH = dataArea.getHeight();
        if (this.coordinateType == XYCoordinateType.RELATIVE) {
            if (this.maxWidth > 0.0) {
                maxW = maxW * this.maxWidth;
            }
            if (this.maxHeight > 0.0) {
                maxH = maxH * this.maxHeight;
            }
        }
        if (this.coordinateType == XYCoordinateType.DATA) {
            maxW = this.maxWidth;
            maxH = this.maxHeight;
        }
        RectangleConstraint rc = new RectangleConstraint(
                new Range(0, maxW), new Range(0, maxH));
        Size2D size = this.title.arrange(canvas, rc);
        RectShape titleRect = new RectShape(0, 0, size.width,
                size.height);
        PointF anchorPoint = RectangleAnchor.coordinates(titleRect,
                this.anchor);
        xx = xx - (float) anchorPoint.x;
        yy = yy - (float) anchorPoint.y;
        titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight());
        BlockParams p = new BlockParams();
        if (info != null) {
            if (info.getOwner().getEntityCollection() != null) {
                p.setGenerateEntities(true);
            }
        }
        Object result = this.title.draw(canvas, titleRect, p);
        if (info != null) {
            if (result instanceof EntityBlockResult) {
                EntityBlockResult ebr = (EntityBlockResult) result;
                info.getOwner().getEntityCollection().addAll(
                        ebr.getEntityCollection());
            }
            String toolTip = getToolTipText();
            String url = getURL();
            if (toolTip != null || url != null) {
                addEntity(info, new RectShape(xx, yy,
                        (float) size.width, (float) size.height),
                        rendererIndex, toolTip, url);
            }
        }
    }
public void draw ( Canvas canvas , XYPlot plot , RectShape dataArea , ValueAxis domainAxis , ValueAxis rangeAxis , int rendererIndex , PlotRenderingInfo info ) { PlotOrientation orientation = plot . getOrientation ( ) ; AxisLocation domainAxisLocation = plot . getDomainAxisLocation ( ) ; AxisLocation rangeAxisLocation = plot . getRangeAxisLocation ( ) ; RectangleEdge domainEdge = Plot . resolveDomainAxisLocation ( domainAxisLocation , orientation ) ; RectangleEdge rangeEdge = Plot . resolveRangeAxisLocation ( rangeAxisLocation , orientation ) ; Range xRange = domainAxis . getRange ( ) ; Range yRange = rangeAxis . getRange ( ) ; double anchorX = 0.0 ; double anchorY = 0.0 ; if ( this . coordinateType == XYCoordinateType . RELATIVE ) { anchorX = xRange . getLowerBound ( ) + ( this . x * xRange . getLength ( ) ) ; anchorY = yRange . getLowerBound ( ) + ( this . y * yRange . getLength ( ) ) ; } else { anchorX = domainAxis . valueToJava2D ( this . x , dataArea , domainEdge ) ; anchorY = rangeAxis . valueToJava2D ( this . y , dataArea , rangeEdge ) ; } float j2DX = ( float ) domainAxis . valueToJava2D ( anchorX , dataArea , domainEdge ) ; float j2DY = ( float ) rangeAxis . valueToJava2D ( anchorY , dataArea , rangeEdge ) ; float xx = 0.0f ; float yy = 0.0f ; if ( orientation == PlotOrientation . HORIZONTAL ) { xx = j2DY ; yy = j2DX ; } else if ( orientation == PlotOrientation . VERTICAL ) { xx = j2DX ; yy = j2DY ; } double maxW = dataArea . getWidth ( ) ; double maxH = dataArea . getHeight ( ) ; if ( this . coordinateType == XYCoordinateType . RELATIVE ) { if ( this . maxWidth > 0.0 ) { maxW = maxW * this . maxWidth ; } if ( this . maxHeight > 0.0 ) { maxH = maxH * this . maxHeight ; } } if ( this . coordinateType == XYCoordinateType . DATA ) { maxW = this . maxWidth ; maxH = this . maxHeight ; } RectangleConstraint rc = new RectangleConstraint ( new Range ( 0 , maxW ) , new Range ( 0 , maxH ) ) ; Size2D size = this . title . arrange ( canvas , rc ) ; RectShape titleRect = new RectShape ( 0 , 0 , size . width , size . height ) ; PointF anchorPoint = RectangleAnchor . coordinates ( titleRect , this . anchor ) ; xx = xx - ( float ) anchorPoint . x ; yy = yy - ( float ) anchorPoint . y ; titleRect . setRect ( xx , yy , titleRect . getWidth ( ) , titleRect . getHeight ( ) ) ; BlockParams p = new BlockParams ( ) ; if ( info != null ) { if ( info . getOwner ( ) . getEntityCollection ( ) != null ) { p . setGenerateEntities ( true ) ; } } Object result = this . title . draw ( canvas , titleRect , p ) ; if ( info != null ) { if ( result instanceof EntityBlockResult ) { EntityBlockResult ebr = ( EntityBlockResult ) result ; info . getOwner ( ) . getEntityCollection ( ) . addAll ( ebr . getEntityCollection ( ) ) ; } String toolTip = getToolTipText ( ) ; String url = getURL ( ) ; if ( toolTip != null || url != null ) { addEntity ( info , new RectShape ( xx , yy , ( float ) size . width , ( float ) size . height ) , rendererIndex , toolTip , url ) ; } } }
Draws the annotation.
Draws the annotation .