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 in which the plot should be drawn.
     * @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 in which the plot should be drawn.
@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 in which the plot should be drawn . @param edge the axis location .
protected void selectVerticalAutoTickUnit(Canvas canvas,
                                              RectShape dataArea,
                                              RectangleEdge edge) {
        TickUnitSource tickUnits = getStandardTickUnits();
        double zero = valueToJava2D(0.0, dataArea, edge);
        double estimate1 = getRange().getLength() / 10.0;
        DateTickUnit candidate1
            = (DateTickUnit) tickUnits.getCeilingTickUnit(estimate1);
        double labelHeight1 = estimateMaximumTickLabelHeight(canvas, candidate1);
        double y1 = valueToJava2D(candidate1.getSize(), dataArea, edge);
        double candidate1UnitHeight = Math.abs(y1 - zero);
        double estimate2
            = (labelHeight1 / candidate1UnitHeight) * candidate1.getSize();
        DateTickUnit candidate2
            = (DateTickUnit) tickUnits.getCeilingTickUnit(estimate2);
        double labelHeight2 = estimateMaximumTickLabelHeight(canvas, candidate2);
        double y2 = valueToJava2D(candidate2.getSize(), dataArea, edge);
        double unit2Height = Math.abs(y2 - zero);
       DateTickUnit finalUnit;
       if (labelHeight2 < unit2Height) {
           finalUnit = candidate2;
       }
       else {
           finalUnit = (DateTickUnit) tickUnits.getLargerTickUnit(candidate2);
       }
       setTickUnit(finalUnit, false, false);
    }
protected void selectVerticalAutoTickUnit ( Canvas canvas , RectShape dataArea , RectangleEdge edge ) { TickUnitSource tickUnits = getStandardTickUnits ( ) ; double zero = valueToJava2D ( 0.0 , dataArea , edge ) ; double estimate1 = getRange ( ) . getLength ( ) / 10.0 ; DateTickUnit candidate1 = ( DateTickUnit ) tickUnits . getCeilingTickUnit ( estimate1 ) ; double labelHeight1 = estimateMaximumTickLabelHeight ( canvas , candidate1 ) ; double y1 = valueToJava2D ( candidate1 . getSize ( ) , dataArea , edge ) ; double candidate1UnitHeight = Math . abs ( y1 - zero ) ; double estimate2 = ( labelHeight1 / candidate1UnitHeight ) * candidate1 . getSize ( ) ; DateTickUnit candidate2 = ( DateTickUnit ) tickUnits . getCeilingTickUnit ( estimate2 ) ; double labelHeight2 = estimateMaximumTickLabelHeight ( canvas , candidate2 ) ; double y2 = valueToJava2D ( candidate2 . getSize ( ) , dataArea , edge ) ; double unit2Height = Math . abs ( y2 - zero ) ; DateTickUnit finalUnit ; if ( labelHeight2 < unit2Height ) { finalUnit = candidate2 ; } else { finalUnit = ( DateTickUnit ) tickUnits . getLargerTickUnit ( candidate2 ) ; } setTickUnit ( finalUnit , false , false ) ; }
Selects an appropriate tick size for the axis.
Selects an appropriate tick size for the axis .
// start with the current tick unit... // start with a unit that is at least 1/10th of the axis length // now extrapolate based on label height and unit height... // make final selection...