afreechart/src/main/java/org/afree/chart/axis/DateAxis.java
/**
     * Selects an appropriate tick size for the axis.  The strategy is to
     * display as many ticks as possible (selected from a collection of
     * 'standard' tick units) without the labels overlapping.
     *
     * @param canvas  the graphics device.
     * @param dataArea  the area defined by the axes.
     * @param edge  the axis location.
     */
Selects an appropriate tick size for the axis.  The strategy is to
display as many ticks as possible (selected from a collection of
'standard' tick units) without the labels overlapping.

@param canvas  the graphics device.
@param dataArea  the area defined by the axes.
@param edge  the axis location.
Selects an appropriate tick size for the axis . The strategy is to display as many ticks as possible ( selected from a collection of ' standard ' tick units ) without the labels overlapping . @param canvas the graphics device . @param dataArea the area defined by the axes . @param edge the axis location .
protected void selectHorizontalAutoTickUnit(Canvas canvas,
            RectShape dataArea, RectangleEdge edge) {
        long shift = 0;
        if (this.timeline instanceof SegmentedTimeline) {
            shift = ((SegmentedTimeline) this.timeline).getStartTime();
        }
        double zero = valueToJava2D(shift + 0.0, dataArea, edge);
        double tickLabelWidth = estimateMaximumTickLabelWidth(canvas,
                getTickUnit());
        TickUnitSource tickUnits = getStandardTickUnits();
        TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit());
        double x1 = valueToJava2D(shift + unit1.getSize(), dataArea, edge);
        double unit1Width = Math.abs(x1 - zero);
        double guess = (tickLabelWidth / unit1Width) * unit1.getSize();
        DateTickUnit unit2 = (DateTickUnit) tickUnits.getCeilingTickUnit(guess);
        double x2 = valueToJava2D(shift + unit2.getSize(), dataArea, edge);
        double unit2Width = Math.abs(x2 - zero);
        tickLabelWidth = estimateMaximumTickLabelWidth(canvas, unit2);
        if (tickLabelWidth > unit2Width) {
            unit2 = (DateTickUnit) tickUnits.getLargerTickUnit(unit2);
        }
        setTickUnit(unit2, false, false);
    }
protected void selectHorizontalAutoTickUnit ( Canvas canvas , RectShape dataArea , RectangleEdge edge ) { long shift = 0 ; if ( this . timeline instanceof SegmentedTimeline ) { shift = ( ( SegmentedTimeline ) this . timeline ) . getStartTime ( ) ; } double zero = valueToJava2D ( shift + 0.0 , dataArea , edge ) ; double tickLabelWidth = estimateMaximumTickLabelWidth ( canvas , getTickUnit ( ) ) ; TickUnitSource tickUnits = getStandardTickUnits ( ) ; TickUnit unit1 = tickUnits . getCeilingTickUnit ( getTickUnit ( ) ) ; double x1 = valueToJava2D ( shift + unit1 . getSize ( ) , dataArea , edge ) ; double unit1Width = Math . abs ( x1 - zero ) ; double guess = ( tickLabelWidth / unit1Width ) * unit1 . getSize ( ) ; DateTickUnit unit2 = ( DateTickUnit ) tickUnits . getCeilingTickUnit ( guess ) ; double x2 = valueToJava2D ( shift + unit2 . getSize ( ) , dataArea , edge ) ; double unit2Width = Math . abs ( x2 - zero ) ; tickLabelWidth = estimateMaximumTickLabelWidth ( canvas , unit2 ) ; if ( tickLabelWidth > unit2Width ) { unit2 = ( DateTickUnit ) tickUnits . getLargerTickUnit ( unit2 ) ; } setTickUnit ( unit2 , false , false ) ; }
Selects an appropriate tick size for the axis.
Selects an appropriate tick size for the axis .
// start with the current tick unit... // then extrapolate...