Class BorderPainter
- java.lang.Object
-
- org.apache.fop.render.intermediate.BorderPainter
-
- Direct Known Subclasses:
AFPPainter.AFPBorderPainterAdapter
public class BorderPainter extends java.lang.ObjectThis is an abstract base class for handling border painting.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classBorderPainter.AbstractBorderSegmentprivate static interfaceBorderPainter.BorderSegmentprivate static classBorderPainter.Cornerprivate static classBorderPainter.CornerAnglesThe four corners SB - Start-Before BE - Before-End EA - End-After AS - After-Start 0 --> x | v y SB BE *----* | | | | *----* AS EAprivate static classBorderPainter.CornerScaleCorrectionCalculatorprivate classBorderPainter.PathPainterThis is a helper class for constructing curves composed of move, line and arc operations.
-
Field Summary
Fields Modifier and Type Field Description protected static intBOTTOMConvention index of bottom borderprotected static intBOTTOM_LEFTConvention index of bottom-left border cornersprotected static intBOTTOM_RIGHTConvention index of bottom-right border cornersprotected static floatDASHED_BORDER_LENGTH_FACTORThe length of the dash as a factor of the border width i.e.static floatDASHED_BORDER_SPACE_RATIOThe ratio between a solid dash and the white-space in a dashed-borderprivate GraphicsPaintergraphicsPainterprotected static intLEFTConvention index of left borderprotected static intRIGHTConvention index of right borderprotected static intTOPConvention index of before topprotected static intTOP_LEFTConvention index of top-left border cornersprotected static intTOP_RIGHTConvention index of top-right-end border corners
-
Constructor Summary
Constructors Constructor Description BorderPainter(GraphicsPainter graphicsPainter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidarcTo(double startAngle, double endAngle, int cx, int cy, int width, int height)private static BorderPainter.BorderSegmentborderSegmentForAfter(BorderProps after)private static BorderPainter.BorderSegmentborderSegmentForBefore(BorderProps before)private static BorderPainter.BorderSegmentborderSegmentForEnd(BorderProps end)private static BorderPainter.BorderSegmentborderSegmentForStart(BorderProps start)protected static doublecalculateCornerCorrectionFactor(int width, int height, BorderProps before, BorderProps after, BorderProps start, BorderProps end)Calculate the correction factor to handle over-sized elliptic corner radii.protected static doublecalculateCornerScaleCorrection(int width, int height, BorderPainter.BorderSegment before, BorderPainter.BorderSegment after, BorderPainter.BorderSegment start, BorderPainter.BorderSegment end)Calculate the scaling factor to handle over-sized elliptic corner radii.private voidclip()voidclipBackground(java.awt.Rectangle rect, BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd)Clip the background to the inner borderprivate voidclosePath()private static intcorrectRadius(double cornerCorrectionFactor, int radius)static floatdashWidthCalculator(float borderLength, float borderWidth)This method calculates the length of the "dash" in a dashed border.private voiddrawBorderLine(int x1, int y1, int x2, int y2, boolean horz, boolean startOrBefore, int style, java.awt.Color color)voiddrawBorders(java.awt.Rectangle borderRect, BorderProps bpsTop, BorderProps bpsBottom, BorderProps bpsLeft, BorderProps bpsRight, java.awt.Color innerBackgroundColor)Draws borders.private voiddrawBorderSegment(BorderPainter.BorderSegment start, BorderPainter.BorderSegment before, BorderPainter.BorderSegment end, int orientation, int width, int x, int y, double cornerCorrectionFactor)protected voiddrawRectangularBorders(java.awt.Rectangle borderRect, BorderProps bpsTop, BorderProps bpsBottom, BorderProps bpsLeft, BorderProps bpsRight)TODO merge with drawRoundedBorders()?protected voiddrawRoundedBorders(java.awt.Rectangle borderRect, BorderProps beforeBorderProps, BorderProps afterBorderProps, BorderProps startBorderProps, BorderProps endBorderProps)TODO merge with drawRectangularBorders?private double[]getCornerBorderJoinMetrics(double ellipseCenterX, double ellipseCenterY, double borderWidthRatio)private double[]getCornerBorderJoinMetrics(double ellipseCenterX, double ellipseCenterY, double xWidth, double yWidth)private booleanisCollapseOuter(BorderProps bp)private voidlineTo(int x, int y)private voidmoveTo(int x, int y)private voidrestoreGraphicsState()private voidrotateCoordinates(double angle)private BorderPropssanitizeBorderProps(BorderProps bps)private voidsaveGraphicsState()private voidtranslateCoordinates(int xTranslate, int yTranslate)
-
-
-
Field Detail
-
TOP
protected static final int TOP
Convention index of before top- See Also:
- Constant Field Values
-
RIGHT
protected static final int RIGHT
Convention index of right border- See Also:
- Constant Field Values
-
BOTTOM
protected static final int BOTTOM
Convention index of bottom border- See Also:
- Constant Field Values
-
LEFT
protected static final int LEFT
Convention index of left border- See Also:
- Constant Field Values
-
TOP_LEFT
protected static final int TOP_LEFT
Convention index of top-left border corners- See Also:
- Constant Field Values
-
TOP_RIGHT
protected static final int TOP_RIGHT
Convention index of top-right-end border corners- See Also:
- Constant Field Values
-
BOTTOM_RIGHT
protected static final int BOTTOM_RIGHT
Convention index of bottom-right border corners- See Also:
- Constant Field Values
-
BOTTOM_LEFT
protected static final int BOTTOM_LEFT
Convention index of bottom-left border corners- See Also:
- Constant Field Values
-
DASHED_BORDER_SPACE_RATIO
public static final float DASHED_BORDER_SPACE_RATIO
The ratio between a solid dash and the white-space in a dashed-border- See Also:
- Constant Field Values
-
DASHED_BORDER_LENGTH_FACTOR
protected static final float DASHED_BORDER_LENGTH_FACTOR
The length of the dash as a factor of the border width i.e. 2 -> dashWidth = 2*borderWidth- See Also:
- Constant Field Values
-
graphicsPainter
private final GraphicsPainter graphicsPainter
-
-
Constructor Detail
-
BorderPainter
public BorderPainter(GraphicsPainter graphicsPainter)
-
-
Method Detail
-
drawBorders
public void drawBorders(java.awt.Rectangle borderRect, BorderProps bpsTop, BorderProps bpsBottom, BorderProps bpsLeft, BorderProps bpsRight, java.awt.Color innerBackgroundColor) throws IFExceptionDraws borders.- Parameters:
borderRect- the border rectanglebpsTop- the border specification on the top sidebpsBottom- the border specification on the bottom sidebpsLeft- the border specification on the left sidebpsRight- the border specification on the end sideinnerBackgroundColor- the inner background color- Throws:
IFException- if an error occurs while drawing the borders
-
sanitizeBorderProps
private BorderProps sanitizeBorderProps(BorderProps bps)
-
drawRectangularBorders
protected void drawRectangularBorders(java.awt.Rectangle borderRect, BorderProps bpsTop, BorderProps bpsBottom, BorderProps bpsLeft, BorderProps bpsRight) throws java.io.IOExceptionTODO merge with drawRoundedBorders()?- Parameters:
borderRect- the border rectanglebpsTop- the border specification on the top sidebpsBottom- the border specification on the bottom sidebpsLeft- the border specification on the left sidebpsRight- the border specification on the end side- Throws:
java.io.IOException
-
isCollapseOuter
private boolean isCollapseOuter(BorderProps bp)
-
dashWidthCalculator
public static float dashWidthCalculator(float borderLength, float borderWidth)This method calculates the length of the "dash" in a dashed border. The dash satisfies the condition that corners start on a dash and end with a dash (rather than ending with a white space).- Parameters:
borderLength- The length of the border.borderWidth- The width/thickness of the border.- Returns:
- returns the length of the dash such that it fits the criteria above.
-
drawRoundedBorders
protected void drawRoundedBorders(java.awt.Rectangle borderRect, BorderProps beforeBorderProps, BorderProps afterBorderProps, BorderProps startBorderProps, BorderProps endBorderProps) throws java.io.IOExceptionTODO merge with drawRectangularBorders?- Parameters:
borderRect- the border rectangle- Throws:
java.io.IOException- on io exception
-
drawBorderSegment
private void drawBorderSegment(BorderPainter.BorderSegment start, BorderPainter.BorderSegment before, BorderPainter.BorderSegment end, int orientation, int width, int x, int y, double cornerCorrectionFactor) throws java.io.IOException
- Throws:
java.io.IOException
-
correctRadius
private static int correctRadius(double cornerCorrectionFactor, int radius)
-
borderSegmentForBefore
private static BorderPainter.BorderSegment borderSegmentForBefore(BorderProps before)
-
borderSegmentForAfter
private static BorderPainter.BorderSegment borderSegmentForAfter(BorderProps after)
-
borderSegmentForStart
private static BorderPainter.BorderSegment borderSegmentForStart(BorderProps start)
-
borderSegmentForEnd
private static BorderPainter.BorderSegment borderSegmentForEnd(BorderProps end)
-
getCornerBorderJoinMetrics
private double[] getCornerBorderJoinMetrics(double ellipseCenterX, double ellipseCenterY, double xWidth, double yWidth)
-
getCornerBorderJoinMetrics
private double[] getCornerBorderJoinMetrics(double ellipseCenterX, double ellipseCenterY, double borderWidthRatio)
-
clipBackground
public void clipBackground(java.awt.Rectangle rect, BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd) throws java.io.IOExceptionClip the background to the inner border- Parameters:
rect- clipping rectanglebpsBefore- before borderbpsAfter- after borderbpsStart- start borderbpsEnd- end border- Throws:
java.io.IOException- if an I/O error occurs
-
calculateCornerCorrectionFactor
protected static double calculateCornerCorrectionFactor(int width, int height, BorderProps before, BorderProps after, BorderProps start, BorderProps end)Calculate the correction factor to handle over-sized elliptic corner radii.- Parameters:
width- the border widthheight- the border heightbefore- the before border propertiesafter- the after border propertiesstart- the start border propertiesend- the end border properties
-
calculateCornerScaleCorrection
protected static double calculateCornerScaleCorrection(int width, int height, BorderPainter.BorderSegment before, BorderPainter.BorderSegment after, BorderPainter.BorderSegment start, BorderPainter.BorderSegment end)Calculate the scaling factor to handle over-sized elliptic corner radii.- Parameters:
width- the border widthheight- the border heightbefore- the before border segmentafter- the after border segmentstart- the start border segmentend- the end border segment
-
drawBorderLine
private void drawBorderLine(int x1, int y1, int x2, int y2, boolean horz, boolean startOrBefore, int style, java.awt.Color color) throws java.io.IOException- Throws:
java.io.IOException
-
moveTo
private void moveTo(int x, int y) throws java.io.IOException- Throws:
java.io.IOException
-
lineTo
private void lineTo(int x, int y) throws java.io.IOException- Throws:
java.io.IOException
-
arcTo
private void arcTo(double startAngle, double endAngle, int cx, int cy, int width, int height) throws java.io.IOException- Throws:
java.io.IOException
-
rotateCoordinates
private void rotateCoordinates(double angle) throws java.io.IOException- Throws:
java.io.IOException
-
translateCoordinates
private void translateCoordinates(int xTranslate, int yTranslate) throws java.io.IOException- Throws:
java.io.IOException
-
closePath
private void closePath() throws java.io.IOException- Throws:
java.io.IOException
-
clip
private void clip() throws java.io.IOException- Throws:
java.io.IOException
-
saveGraphicsState
private void saveGraphicsState() throws java.io.IOException- Throws:
java.io.IOException
-
restoreGraphicsState
private void restoreGraphicsState() throws java.io.IOException- Throws:
java.io.IOException
-
-