afreechart/src/main/java/org/afree/ui/RectangleInsets.java
/**
     * Creates an adjusted RectShape using the supplied RectShape, the insets
     * specified by this instance, and the horizontal and vertical adjustment
     * types.
     * 
     * @param base
     *            the base RectShape (<code>null</code> not permitted).
     * @param horizontal
     *            the horizontal adjustment type (<code>null</code> not
     *            permitted).
     * @param vertical
     *            the vertical adjustment type (<code>null</code> not
     *            permitted).
     * 
     * @return The inset RectShape.
     */
Creates an adjusted RectShape using the supplied RectShape, the insets
specified by this instance, and the horizontal and vertical adjustment
types.

@param base
the base RectShape (null not permitted).
@param horizontal
the horizontal adjustment type (null not
permitted).
@param vertical
the vertical adjustment type (null not
permitted).

@return The inset RectShape.
Creates an adjusted RectShape using the supplied RectShape the insets specified by this instance and the horizontal and vertical adjustment types . @param base the base RectShape ( null not permitted ) . @param horizontal the horizontal adjustment type ( null not permitted ) . @param vertical the vertical adjustment type ( null not permitted ) . @return The inset RectShape .
public RectShape createAdjustedRectShape(final RectShape base,
            final LengthAdjustmentType horizontal,
            final LengthAdjustmentType vertical) {
        if (base == null) {
            throw new IllegalArgumentException("Null 'base' argument.");
        }
        double x = base.getX();
        double y = base.getY();
        double w = base.getWidth();
        double h = base.getHeight();
        if (horizontal == LengthAdjustmentType.EXPAND) {
            final double leftOutset = calculateLeftOutset(w);
            x = x - leftOutset;
            w = w + leftOutset + calculateRightOutset(w);
        } else if (horizontal == LengthAdjustmentType.CONTRACT) {
            final double leftMargin = calculateLeftInset(w);
            x = x + leftMargin;
            w = w - leftMargin - calculateRightInset(w);
        }
        if (vertical == LengthAdjustmentType.EXPAND) {
            final double topMargin = calculateTopOutset(h);
            y = y - topMargin;
            h = h + topMargin + calculateBottomOutset(h);
        } else if (vertical == LengthAdjustmentType.CONTRACT) {
            final double topMargin = calculateTopInset(h);
            y = y + topMargin;
            h = h - topMargin - calculateBottomInset(h);
        }
        return new RectShape(x, y, w, h);
    }
public RectShape createAdjustedRectShape ( final RectShape base , final LengthAdjustmentType horizontal , final LengthAdjustmentType vertical ) { if ( base == null ) { throw new IllegalArgumentException ( "Null 'base' argument." ) ; } double x = base . getX ( ) ; double y = base . getY ( ) ; double w = base . getWidth ( ) ; double h = base . getHeight ( ) ; if ( horizontal == LengthAdjustmentType . EXPAND ) { final double leftOutset = calculateLeftOutset ( w ) ; x = x - leftOutset ; w = w + leftOutset + calculateRightOutset ( w ) ; } else if ( horizontal == LengthAdjustmentType . CONTRACT ) { final double leftMargin = calculateLeftInset ( w ) ; x = x + leftMargin ; w = w - leftMargin - calculateRightInset ( w ) ; } if ( vertical == LengthAdjustmentType . EXPAND ) { final double topMargin = calculateTopOutset ( h ) ; y = y - topMargin ; h = h + topMargin + calculateBottomOutset ( h ) ; } else if ( vertical == LengthAdjustmentType . CONTRACT ) { final double topMargin = calculateTopInset ( h ) ; y = y + topMargin ; h = h - topMargin - calculateBottomInset ( h ) ; } return new RectShape ( x , y , w , h ) ; }
Creates an adjusted RectShape using the supplied RectShape, the insets
 specified by this instance, and the horizontal and vertical adjustment
 types.
Creates an adjusted RectShape using the supplied RectShape the insets specified by this instance and the horizontal and vertical adjustment types .