afreechart/src/main/java/org/afree/chart/axis/DateAxis.java
/**
     * Recalculates the ticks for the date axis.
     *
     * @param canvas  the graphics device.
     * @param dataArea  the area in which the plot should be drawn.
     * @param edge  the location of the axis.
     *
     * @return A list of ticks.
     */
Recalculates the ticks for the date axis.
@param canvas  the graphics device.
@param dataArea  the area in which the plot should be drawn.
@param edge  the location of the axis.

@return A list of ticks.
Recalculates the ticks for the date axis . @param canvas the graphics device . @param dataArea the area in which the plot should be drawn . @param edge the location of the axis . @return A list of ticks .
protected List refreshTicksVertical(Canvas canvas,
            RectShape dataArea, RectangleEdge edge) {
        List result = new java.util.ArrayList();
        if (isAutoTickUnitSelection()) {
            selectAutoTickUnit(canvas, dataArea, edge);
        }
        DateTickUnit unit = getTickUnit();
        Date tickDate = calculateLowestVisibleTickValue(unit);
        Date upperDate = getMaximumDate();
        while (tickDate.before(upperDate)) {
            tickDate = correctTickDateForPosition(tickDate, unit,
                    this.tickMarkPosition);
            long lowestTickTime = tickDate.getTime();
            long distance = unit.addToDate(tickDate, this.timeZone).getTime()
                    - lowestTickTime;
            int minorTickSpaces = getMinorTickCount();
            if (minorTickSpaces <= 0) {
                minorTickSpaces = unit.getMinorTickCount();
            }
            for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) {
                long minorTickTime = lowestTickTime - distance
                        * minorTick / minorTickSpaces;
                if (minorTickTime > 0 && getRange().contains(minorTickTime)
                        && (!isHiddenValue(minorTickTime))) {
                    result.add(new DateTick(TickType.MINOR,
                            new Date(minorTickTime), "", TextAnchor.TOP_CENTER,
                            TextAnchor.CENTER, 0.0));
                }
            }
            if (!isHiddenValue(tickDate.getTime())) {
                String tickLabel;
                DateFormat formatter = getDateFormatOverride();
                if (formatter != null) {
                    tickLabel = formatter.format(tickDate);
                }
                else {
                    tickLabel = this.tickUnit.dateToString(tickDate);
                }
                TextAnchor anchor = null;
                TextAnchor rotationAnchor = null;
                double angle = 0.0;
                if (isVerticalTickLabels()) {
                    anchor = TextAnchor.BOTTOM_CENTER;
                    rotationAnchor = TextAnchor.BOTTOM_CENTER;
                    if (edge == RectangleEdge.LEFT) {
                        angle = -Math.PI / 2.0;
                    }
                    else {
                        angle = Math.PI / 2.0;
                    }
                }
                else {
                    if (edge == RectangleEdge.LEFT) {
                        anchor = TextAnchor.CENTER_RIGHT;
                        rotationAnchor = TextAnchor.CENTER_RIGHT;
                    }
                    else {
                        anchor = TextAnchor.CENTER_LEFT;
                        rotationAnchor = TextAnchor.CENTER_LEFT;
                    }
                }
                Tick tick = new DateTick(tickDate, tickLabel, anchor,
                        rotationAnchor, angle);
                result.add(tick);
                long currentTickTime = tickDate.getTime();
                tickDate = unit.addToDate(tickDate, this.timeZone);
                long nextTickTime = tickDate.getTime();
                for (int minorTick = 1; minorTick < minorTickSpaces;
                        minorTick++){
                    long minorTickTime = currentTickTime
                            + (nextTickTime - currentTickTime)
                            * minorTick / minorTickSpaces;
                    if (getRange().contains(minorTickTime)
                            && (!isHiddenValue(minorTickTime))) {
                        result.add(new DateTick(TickType.MINOR,
                                new Date(minorTickTime), "",
                                TextAnchor.TOP_CENTER, TextAnchor.CENTER,
                                0.0));
                    }
                }
            }
            else {
                tickDate = unit.rollDate(tickDate, this.timeZone);
            }
        }
        return result;
    }
protected List refreshTicksVertical ( Canvas canvas , RectShape dataArea , RectangleEdge edge ) { List result = new java . util . ArrayList ( ) ; if ( isAutoTickUnitSelection ( ) ) { selectAutoTickUnit ( canvas , dataArea , edge ) ; } DateTickUnit unit = getTickUnit ( ) ; Date tickDate = calculateLowestVisibleTickValue ( unit ) ; Date upperDate = getMaximumDate ( ) ; while ( tickDate . before ( upperDate ) ) { tickDate = correctTickDateForPosition ( tickDate , unit , this . tickMarkPosition ) ; long lowestTickTime = tickDate . getTime ( ) ; long distance = unit . addToDate ( tickDate , this . timeZone ) . getTime ( ) - lowestTickTime ; int minorTickSpaces = getMinorTickCount ( ) ; if ( minorTickSpaces <= 0 ) { minorTickSpaces = unit . getMinorTickCount ( ) ; } for ( int minorTick = 1 ; minorTick < minorTickSpaces ; minorTick ++ ) { long minorTickTime = lowestTickTime - distance * minorTick / minorTickSpaces ; if ( minorTickTime > 0 && getRange ( ) . contains ( minorTickTime ) && ( ! isHiddenValue ( minorTickTime ) ) ) { result . add ( new DateTick ( TickType . MINOR , new Date ( minorTickTime ) , "" , TextAnchor . TOP_CENTER , TextAnchor . CENTER , 0.0 ) ) ; } } if ( ! isHiddenValue ( tickDate . getTime ( ) ) ) { String tickLabel ; DateFormat formatter = getDateFormatOverride ( ) ; if ( formatter != null ) { tickLabel = formatter . format ( tickDate ) ; } else { tickLabel = this . tickUnit . dateToString ( tickDate ) ; } TextAnchor anchor = null ; TextAnchor rotationAnchor = null ; double angle = 0.0 ; if ( isVerticalTickLabels ( ) ) { anchor = TextAnchor . BOTTOM_CENTER ; rotationAnchor = TextAnchor . BOTTOM_CENTER ; if ( edge == RectangleEdge . LEFT ) { angle = - Math . PI / 2.0 ; } else { angle = Math . PI / 2.0 ; } } else { if ( edge == RectangleEdge . LEFT ) { anchor = TextAnchor . CENTER_RIGHT ; rotationAnchor = TextAnchor . CENTER_RIGHT ; } else { anchor = TextAnchor . CENTER_LEFT ; rotationAnchor = TextAnchor . CENTER_LEFT ; } } Tick tick = new DateTick ( tickDate , tickLabel , anchor , rotationAnchor , angle ) ; result . add ( tick ) ; long currentTickTime = tickDate . getTime ( ) ; tickDate = unit . addToDate ( tickDate , this . timeZone ) ; long nextTickTime = tickDate . getTime ( ) ; for ( int minorTick = 1 ; minorTick < minorTickSpaces ; minorTick ++ ) { long minorTickTime = currentTickTime + ( nextTickTime - currentTickTime ) * minorTick / minorTickSpaces ; if ( getRange ( ) . contains ( minorTickTime ) && ( ! isHiddenValue ( minorTickTime ) ) ) { result . add ( new DateTick ( TickType . MINOR , new Date ( minorTickTime ) , "" , TextAnchor . TOP_CENTER , TextAnchor . CENTER , 0.0 ) ) ; } } } else { tickDate = unit . rollDate ( tickDate , this . timeZone ) ; } } return result ; }
Recalculates the ticks for the date axis.
Recalculates the ticks for the date axis .
// could add a flag to make the following correction optional... // work out the value, label and position