afreechart/src/main/java/org/afree/chart/axis/NumberAxis.java
/**
     * Calculates the positions of the tick labels for the axis, storing the
     * results in the tick label list (ready for drawing).
     * 
     * @param canvas
     *            the graphics device.
     * @param dataArea
     *            the area in which the data should be drawn.
     * @param edge
     *            the location of the axis.
     * 
     * @return A list of ticks.
     */
Calculates the positions of the tick labels for the axis, storing the
results in the tick label list (ready for drawing).

@param canvas
the graphics device.
@param dataArea
the area in which the data should be drawn.
@param edge
the location of the axis.

@return A list of ticks.
Calculates the positions of the tick labels for the axis storing the results in the tick label list ( ready for drawing ) . @param canvas the graphics device . @param dataArea the area in which the data should be drawn . @param edge the location of the axis . @return A list of ticks .
protected List refreshTicksHorizontal(Canvas canvas, RectShape dataArea,
            RectangleEdge edge) {
        List result = new java.util.ArrayList();
        if (isAutoTickUnitSelection()) {
            selectAutoTickUnit(canvas, dataArea, edge);
        }
        TickUnit tu = getTickUnit();
        double size = tu.getSize();
        int count = calculateVisibleTickCount();
        double lowestTickValue = calculateLowestVisibleTickValue();
        if (count <= ValueAxis.MAXIMUM_TICK_COUNT) {
            int minorTickSpaces = getMinorTickCount();
            if (minorTickSpaces <= 0) {
                minorTickSpaces = tu.getMinorTickCount();
            }
            for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) {
                double minorTickValue = lowestTickValue - size * minorTick
                        / minorTickSpaces;
                if (getRange().contains(minorTickValue)) {
                    result.add(new NumberTick(TickType.MINOR, minorTickValue,
                            "", TextAnchor.TOP_CENTER, TextAnchor.CENTER, 0.0));
                }
            }
            for (int i = 0; i < count; i++) {
                double currentTickValue = lowestTickValue + (i * size);
                String tickLabel;
                NumberFormat formatter = getNumberFormatOverride();
                if (formatter != null) {
                    tickLabel = formatter.format(currentTickValue);
                } else {
                    tickLabel = getTickUnit().valueToString(currentTickValue);
                }
                TextAnchor anchor = null;
                TextAnchor rotationAnchor = null;
                double angle = 0.0;
                if (isVerticalTickLabels()) {
                    anchor = TextAnchor.CENTER_RIGHT;
                    rotationAnchor = TextAnchor.CENTER_RIGHT;
                    if (edge == RectangleEdge.TOP) {
                        angle = 90;
                    } else {
                        angle = -90;
                    }
                } else {
                    if (edge == RectangleEdge.TOP) {
                        anchor = TextAnchor.BOTTOM_CENTER;
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
                    } else {
                        anchor = TextAnchor.TOP_CENTER;
                        rotationAnchor = TextAnchor.TOP_CENTER;
                    }
                }
                Tick tick = new NumberTick(new Double(currentTickValue),
                        tickLabel, anchor, rotationAnchor, angle);
                result.add(tick);
                double nextTickValue = lowestTickValue + ((i + 1) * size);
                for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) {
                    double minorTickValue = currentTickValue
                            + (nextTickValue - currentTickValue) * minorTick
                            / minorTickSpaces;
                    if (getRange().contains(minorTickValue)) {
                        result.add(new NumberTick(TickType.MINOR,
                                minorTickValue, "", TextAnchor.TOP_CENTER,
                                TextAnchor.CENTER, 0.0));
                    }
                }
            }
        }
        return result;
    }
protected List refreshTicksHorizontal ( Canvas canvas , RectShape dataArea , RectangleEdge edge ) { List result = new java . util . ArrayList ( ) ; if ( isAutoTickUnitSelection ( ) ) { selectAutoTickUnit ( canvas , dataArea , edge ) ; } TickUnit tu = getTickUnit ( ) ; double size = tu . getSize ( ) ; int count = calculateVisibleTickCount ( ) ; double lowestTickValue = calculateLowestVisibleTickValue ( ) ; if ( count <= ValueAxis . MAXIMUM_TICK_COUNT ) { int minorTickSpaces = getMinorTickCount ( ) ; if ( minorTickSpaces <= 0 ) { minorTickSpaces = tu . getMinorTickCount ( ) ; } for ( int minorTick = 1 ; minorTick < minorTickSpaces ; minorTick ++ ) { double minorTickValue = lowestTickValue - size * minorTick / minorTickSpaces ; if ( getRange ( ) . contains ( minorTickValue ) ) { result . add ( new NumberTick ( TickType . MINOR , minorTickValue , "" , TextAnchor . TOP_CENTER , TextAnchor . CENTER , 0.0 ) ) ; } } for ( int i = 0 ; i < count ; i ++ ) { double currentTickValue = lowestTickValue + ( i * size ) ; String tickLabel ; NumberFormat formatter = getNumberFormatOverride ( ) ; if ( formatter != null ) { tickLabel = formatter . format ( currentTickValue ) ; } else { tickLabel = getTickUnit ( ) . valueToString ( currentTickValue ) ; } TextAnchor anchor = null ; TextAnchor rotationAnchor = null ; double angle = 0.0 ; if ( isVerticalTickLabels ( ) ) { anchor = TextAnchor . CENTER_RIGHT ; rotationAnchor = TextAnchor . CENTER_RIGHT ; if ( edge == RectangleEdge . TOP ) { angle = 90 ; } else { angle = - 90 ; } } else { if ( edge == RectangleEdge . TOP ) { anchor = TextAnchor . BOTTOM_CENTER ; rotationAnchor = TextAnchor . BOTTOM_CENTER ; } else { anchor = TextAnchor . TOP_CENTER ; rotationAnchor = TextAnchor . TOP_CENTER ; } } Tick tick = new NumberTick ( new Double ( currentTickValue ) , tickLabel , anchor , rotationAnchor , angle ) ; result . add ( tick ) ; double nextTickValue = lowestTickValue + ( ( i + 1 ) * size ) ; for ( int minorTick = 1 ; minorTick < minorTickSpaces ; minorTick ++ ) { double minorTickValue = currentTickValue + ( nextTickValue - currentTickValue ) * minorTick / minorTickSpaces ; if ( getRange ( ) . contains ( minorTickValue ) ) { result . add ( new NumberTick ( TickType . MINOR , minorTickValue , "" , TextAnchor . TOP_CENTER , TextAnchor . CENTER , 0.0 ) ) ; } } } } return result ; }
Calculates the positions of the tick labels for the axis, storing the
 results in the tick label list (ready for drawing).
Calculates the positions of the tick labels for the axis storing the results in the tick label list ( ready for drawing ) .
//TODO There is a possibility that tickLabelFont will be used in the future. //Font tickLabelFont = getTickLabelFont(); // canvas.setFont(tickLabelFont);