afreechart/src/main/java/org/afree/chart/axis/CategoryAxis.java
/**
     * Estimates the space required for the axis, given a specific drawing area.
     * 
     * @param canvas
     *            the graphics device (used to obtain font information).
     * @param plot
     *            the plot that the axis belongs to.
     * @param plotArea
     *            the area within which the axis should be drawn.
     * @param edge
     *            the axis location (top or bottom).
     * @param space
     *            the space already reserved.
     * 
     * @return The space required to draw the axis.
     */
Estimates the space required for the axis, given a specific drawing area.

@param canvas
the graphics device (used to obtain font information).
@param plot
the plot that the axis belongs to.
@param plotArea
the area within which the axis should be drawn.
@param edge
the axis location (top or bottom).
@param space
the space already reserved.

@return The space required to draw the axis.
Estimates the space required for the axis given a specific drawing area . @param canvas the graphics device ( used to obtain font information ) . @param plot the plot that the axis belongs to . @param plotArea the area within which the axis should be drawn . @param edge the axis location ( top or bottom ) . @param space the space already reserved . @return The space required to draw the axis .
public AxisSpace reserveSpace(Canvas canvas, Plot plot, RectShape plotArea,
            RectangleEdge edge, AxisSpace space) {
        if (space == null) {
            space = new AxisSpace();
        }
        if (!isVisible()) {
            return space;
        }
        double tickLabelHeight = 0.0;
        double tickLabelWidth = 0.0;
        if (isTickLabelsVisible()) {
            AxisState state = new AxisState();
            refreshTicks(canvas, state, plotArea, edge);
            if (edge == RectangleEdge.TOP) {
                tickLabelHeight = state.getMax();
            } else if (edge == RectangleEdge.BOTTOM) {
                tickLabelHeight = state.getMax();
            } else if (edge == RectangleEdge.LEFT) {
                tickLabelWidth = state.getMax();
            } else if (edge == RectangleEdge.RIGHT) {
                tickLabelWidth = state.getMax();
            }
        }
        RectShape labelEnclosure = getLabelEnclosure(canvas, edge);
        double labelHeight = 0.0;
        double labelWidth = 0.0;
        if (RectangleEdge.isTopOrBottom(edge)) {
            labelHeight = labelEnclosure.getHeight();
            space.add(labelHeight + tickLabelHeight
                    + this.categoryLabelPositionOffset, edge);
        } else if (RectangleEdge.isLeftOrRight(edge)) {
            labelWidth = labelEnclosure.getWidth();
            space.add(labelWidth + tickLabelWidth
                    + this.categoryLabelPositionOffset, edge);
        }
        return space;
    }
public AxisSpace reserveSpace ( Canvas canvas , Plot plot , RectShape plotArea , RectangleEdge edge , AxisSpace space ) { if ( space == null ) { space = new AxisSpace ( ) ; } if ( ! isVisible ( ) ) { return space ; } double tickLabelHeight = 0.0 ; double tickLabelWidth = 0.0 ; if ( isTickLabelsVisible ( ) ) { AxisState state = new AxisState ( ) ; refreshTicks ( canvas , state , plotArea , edge ) ; if ( edge == RectangleEdge . TOP ) { tickLabelHeight = state . getMax ( ) ; } else if ( edge == RectangleEdge . BOTTOM ) { tickLabelHeight = state . getMax ( ) ; } else if ( edge == RectangleEdge . LEFT ) { tickLabelWidth = state . getMax ( ) ; } else if ( edge == RectangleEdge . RIGHT ) { tickLabelWidth = state . getMax ( ) ; } } RectShape labelEnclosure = getLabelEnclosure ( canvas , edge ) ; double labelHeight = 0.0 ; double labelWidth = 0.0 ; if ( RectangleEdge . isTopOrBottom ( edge ) ) { labelHeight = labelEnclosure . getHeight ( ) ; space . add ( labelHeight + tickLabelHeight + this . categoryLabelPositionOffset , edge ) ; } else if ( RectangleEdge . isLeftOrRight ( edge ) ) { labelWidth = labelEnclosure . getWidth ( ) ; space . add ( labelWidth + tickLabelWidth + this . categoryLabelPositionOffset , edge ) ; } return space ; }
Estimates the space required for the axis, given a specific drawing area.
Estimates the space required for the axis given a specific drawing area .
// create a new space object if one wasn't supplied... // if the axis is not visible, no additional space is required... // calculate the max size of the tick labels (if visible)... // canvas.setFont(getTickLabelFont()); // we call refresh ticks just to get the maximum width or height // get the axis label size and update the space object...