afreechart/src/main/java/org/afree/chart/plot/dial/StandardDialScale.java
/**
     * Draws the scale on the dial plot.
     *
     * @param canvas  the graphics target (<code>null</code> not permitted).
     * @param plot  the dial plot (<code>null</code> not permitted).
     * @param frame  the reference frame that is used to construct the
     *     geometry of the plot (<code>null</code> not permitted).
     * @param view  the visible part of the plot (<code>null</code> not
     *     permitted).
     */
Draws the scale on the dial plot.
@param canvas  the graphics target (null not permitted).
@param plot  the dial plot (null not permitted).
@param frame  the reference frame that is used to construct the
geometry of the plot (null not permitted).
@param view  the visible part of the plot (null not
permitted).
Draws the scale on the dial plot . @param canvas the graphics target ( null not permitted ) . @param plot the dial plot ( null not permitted ) . @param frame the reference frame that is used to construct the geometry of the plot ( null not permitted ) . @param view the visible part of the plot ( null not permitted ) .
public void draw(Canvas canvas, DialPlot plot, RectShape frame,
            Shape view) {
        RectShape arcRect = DialPlot.RectShapeByRadius(frame,
                this.tickRadius, this.tickRadius);
        RectShape arcRectMajor = DialPlot.RectShapeByRadius(frame,
                this.tickRadius - this.majorTickLength,
                this.tickRadius - this.majorTickLength);
        RectShape arcRectMinor = arcRect;
        if (this.minorTickCount > 0 && this.minorTickLength > 0.0) {
            arcRectMinor = DialPlot.RectShapeByRadius(frame,
                    this.tickRadius - this.minorTickLength,
                    this.tickRadius - this.minorTickLength);
        }
        RectShape arcRectForLabels = DialPlot.RectShapeByRadius(frame,
                this.tickRadius - this.tickLabelOffset,
                this.tickRadius - this.tickLabelOffset);
        boolean firstLabel = true;
        ArcShape arc = new ArcShape();
        LineShape workingLine = new LineShape();
        for (double v = this.lowerBound; v <= this.upperBound;
                v += this.majorTickIncrement) {
            arc.setArc(arcRect, this.startAngle, -(this.startAngle - valueToAngle(v)), true);
            PointF pt0 = arc.getEndPoint();
            arc.setArc(arcRectMajor, this.startAngle, -(this.startAngle - valueToAngle(v)), true);
            PointF pt1 = arc.getEndPoint();
            majorTickPaint.setStrokeWidth(majorTickStroke);
            workingLine.setLine(pt0, pt1);
            workingLine.draw(canvas, majorTickPaint);
            arc.setArc(arcRectForLabels, this.startAngle, -(this.startAngle - valueToAngle(v)), true);
            PointF pt2 = arc.getEndPoint();
            if (this.tickLabelsVisible) {
                if (!firstLabel || this.firstTickLabelVisible) {
                    tickLabelPaint.setTypeface(tickLabelFont.getTypeFace());
                    tickLabelPaint.setTextSize(tickLabelFont.getSize());
                    tickLabelPaint.setTextAlign(Align.CENTER);
                    canvas.drawText(this.tickLabelFormatter.format(v), pt2.x, pt2.y, tickLabelPaint);
                }
            }
            firstLabel = false;
            if (this.minorTickCount > 0 && this.minorTickLength > 0.0) {
                double minorTickIncrement = this.majorTickIncrement
                        / (this.minorTickCount + 1);
                for (int i = 0; i < this.minorTickCount; i++) {
                    double vv = v + ((i + 1) * minorTickIncrement);
                    if (vv >= this.upperBound) {
                        break;
                    }
                    double angle = valueToAngle(vv);
                    arc.setArc(arcRect, this.startAngle, -(this.startAngle - angle), true);
                    pt0 = arc.getEndPoint();
                    arc.setArc(arcRectMinor, this.startAngle, -(this.startAngle - angle), true);
                    PointF pt3 = arc.getEndPoint();
                    minorTickPaint.setStrokeWidth(minorTickStroke);
                    workingLine.setLine(pt0, pt3);
                    workingLine.draw(canvas, minorTickPaint);
                }
            }
        }
    }
public void draw ( Canvas canvas , DialPlot plot , RectShape frame , Shape view ) { RectShape arcRect = DialPlot . RectShapeByRadius ( frame , this . tickRadius , this . tickRadius ) ; RectShape arcRectMajor = DialPlot . RectShapeByRadius ( frame , this . tickRadius - this . majorTickLength , this . tickRadius - this . majorTickLength ) ; RectShape arcRectMinor = arcRect ; if ( this . minorTickCount > 0 && this . minorTickLength > 0.0 ) { arcRectMinor = DialPlot . RectShapeByRadius ( frame , this . tickRadius - this . minorTickLength , this . tickRadius - this . minorTickLength ) ; } RectShape arcRectForLabels = DialPlot . RectShapeByRadius ( frame , this . tickRadius - this . tickLabelOffset , this . tickRadius - this . tickLabelOffset ) ; boolean firstLabel = true ; ArcShape arc = new ArcShape ( ) ; LineShape workingLine = new LineShape ( ) ; for ( double v = this . lowerBound ; v <= this . upperBound ; v += this . majorTickIncrement ) { arc . setArc ( arcRect , this . startAngle , - ( this . startAngle - valueToAngle ( v ) ) , true ) ; PointF pt0 = arc . getEndPoint ( ) ; arc . setArc ( arcRectMajor , this . startAngle , - ( this . startAngle - valueToAngle ( v ) ) , true ) ; PointF pt1 = arc . getEndPoint ( ) ; majorTickPaint . setStrokeWidth ( majorTickStroke ) ; workingLine . setLine ( pt0 , pt1 ) ; workingLine . draw ( canvas , majorTickPaint ) ; arc . setArc ( arcRectForLabels , this . startAngle , - ( this . startAngle - valueToAngle ( v ) ) , true ) ; PointF pt2 = arc . getEndPoint ( ) ; if ( this . tickLabelsVisible ) { if ( ! firstLabel || this . firstTickLabelVisible ) { tickLabelPaint . setTypeface ( tickLabelFont . getTypeFace ( ) ) ; tickLabelPaint . setTextSize ( tickLabelFont . getSize ( ) ) ; tickLabelPaint . setTextAlign ( Align . CENTER ) ; canvas . drawText ( this . tickLabelFormatter . format ( v ) , pt2 . x , pt2 . y , tickLabelPaint ) ; } } firstLabel = false ; if ( this . minorTickCount > 0 && this . minorTickLength > 0.0 ) { double minorTickIncrement = this . majorTickIncrement / ( this . minorTickCount + 1 ) ; for ( int i = 0 ; i < this . minorTickCount ; i ++ ) { double vv = v + ( ( i + 1 ) * minorTickIncrement ) ; if ( vv >= this . upperBound ) { break ; } double angle = valueToAngle ( vv ) ; arc . setArc ( arcRect , this . startAngle , - ( this . startAngle - angle ) , true ) ; pt0 = arc . getEndPoint ( ) ; arc . setArc ( arcRectMinor , this . startAngle , - ( this . startAngle - angle ) , true ) ; PointF pt3 = arc . getEndPoint ( ) ; minorTickPaint . setStrokeWidth ( minorTickStroke ) ; workingLine . setLine ( pt0 , pt3 ) ; workingLine . draw ( canvas , minorTickPaint ) ; } } } }
Draws the scale on the dial plot.
Draws the scale on the dial plot .
//                    TextUtilities.drawAlignedString( //                            this.tickLabelFormatter.format(v), canvas, //                            (float) pt2.x, (float) pt2.y, //                            TextAnchor.CENTER, tickLabelPaint); // now do the minor tick marks