Class BorderPainter
java.lang.Object
org.apache.fop.render.intermediate.BorderPainter
- Direct Known Subclasses:
AFPPainter.AFPBorderPainterAdapter
This is an abstract base class for handling border painting.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static interface
private static final class
private static enum
The four corners SB - Start-Before BE - Before-End EA - End-After AS - After-Start 0 --> x | v y SB BE *----* | | | | *----* AS EAprivate static final class
private final class
This is a helper class for constructing curves composed of move, line and arc operations. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
Convention index of bottom borderprotected static final int
Convention index of bottom-left border cornersprotected static final int
Convention index of bottom-right border cornersprotected static final float
The length of the dash as a factor of the border width i.e.static final float
The ratio between a solid dash and the white-space in a dashed-borderprivate final GraphicsPainter
protected static final int
Convention index of left borderprotected static final int
Convention index of right borderprotected static final int
Convention index of before topprotected static final int
Convention index of top-left border cornersprotected static final int
Convention index of top-right-end border corners -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
arcTo
(double startAngle, double endAngle, int cx, int cy, int width, int height) private static BorderPainter.BorderSegment
borderSegmentForAfter
(BorderProps after) private static BorderPainter.BorderSegment
borderSegmentForBefore
(BorderProps before) private static BorderPainter.BorderSegment
private static BorderPainter.BorderSegment
borderSegmentForStart
(BorderProps start) 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.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.private void
clip()
void
clipBackground
(Rectangle rect, BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd) Clip the background to the inner borderprivate void
private static int
correctRadius
(double cornerCorrectionFactor, int radius) static float
dashWidthCalculator
(float borderLength, float borderWidth) This method calculates the length of the "dash" in a dashed border.private void
drawBorderLine
(int x1, int y1, int x2, int y2, boolean horz, boolean startOrBefore, int style, Color color) void
drawBorders
(Rectangle borderRect, BorderProps bpsTop, BorderProps bpsBottom, BorderProps bpsLeft, BorderProps bpsRight, Color innerBackgroundColor) Draws borders.private void
drawBorderSegment
(BorderPainter.BorderSegment start, BorderPainter.BorderSegment before, BorderPainter.BorderSegment end, int orientation, int width, int x, int y, double cornerCorrectionFactor) protected void
drawRectangularBorders
(Rectangle borderRect, BorderProps bpsTop, BorderProps bpsBottom, BorderProps bpsLeft, BorderProps bpsRight) TODO merge with drawRoundedBorders()?protected void
drawRoundedBorders
(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 boolean
private void
lineTo
(int x, int y) private void
moveTo
(int x, int y) private void
private void
rotateCoordinates
(double angle) private BorderProps
private void
private void
translateCoordinates
(int xTranslate, int yTranslate)
-
Field Details
-
TOP
protected static final int TOPConvention index of before top- See Also:
-
RIGHT
protected static final int RIGHTConvention index of right border- See Also:
-
BOTTOM
protected static final int BOTTOMConvention index of bottom border- See Also:
-
LEFT
protected static final int LEFTConvention index of left border- See Also:
-
TOP_LEFT
protected static final int TOP_LEFTConvention index of top-left border corners- See Also:
-
TOP_RIGHT
protected static final int TOP_RIGHTConvention index of top-right-end border corners- See Also:
-
BOTTOM_RIGHT
protected static final int BOTTOM_RIGHTConvention index of bottom-right border corners- See Also:
-
BOTTOM_LEFT
protected static final int BOTTOM_LEFTConvention index of bottom-left border corners- See Also:
-
DASHED_BORDER_SPACE_RATIO
public static final float DASHED_BORDER_SPACE_RATIOThe ratio between a solid dash and the white-space in a dashed-border- See Also:
-
DASHED_BORDER_LENGTH_FACTOR
protected static final float DASHED_BORDER_LENGTH_FACTORThe length of the dash as a factor of the border width i.e. 2 -> dashWidth = 2*borderWidth- See Also:
-
graphicsPainter
-
-
Constructor Details
-
BorderPainter
-
-
Method Details
-
drawBorders
public void drawBorders(Rectangle borderRect, BorderProps bpsTop, BorderProps bpsBottom, BorderProps bpsLeft, BorderProps bpsRight, Color innerBackgroundColor) throws IFException Draws 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
-
drawRectangularBorders
protected void drawRectangularBorders(Rectangle borderRect, BorderProps bpsTop, BorderProps bpsBottom, BorderProps bpsLeft, BorderProps bpsRight) throws IOException TODO 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:
IOException
-
isCollapseOuter
-
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(Rectangle borderRect, BorderProps beforeBorderProps, BorderProps afterBorderProps, BorderProps startBorderProps, BorderProps endBorderProps) throws IOException TODO merge with drawRectangularBorders?- Parameters:
borderRect
- the border rectangle- Throws:
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 IOException - Throws:
IOException
-
correctRadius
private static int correctRadius(double cornerCorrectionFactor, int radius) -
borderSegmentForBefore
-
borderSegmentForAfter
-
borderSegmentForStart
-
borderSegmentForEnd
-
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(Rectangle rect, BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd) throws IOException Clip the background to the inner border- Parameters:
rect
- clipping rectanglebpsBefore
- before borderbpsAfter
- after borderbpsStart
- start borderbpsEnd
- end border- Throws:
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, Color color) throws IOException - Throws:
IOException
-
moveTo
- Throws:
IOException
-
lineTo
- Throws:
IOException
-
arcTo
private void arcTo(double startAngle, double endAngle, int cx, int cy, int width, int height) throws IOException - Throws:
IOException
-
rotateCoordinates
- Throws:
IOException
-
translateCoordinates
- Throws:
IOException
-
closePath
- Throws:
IOException
-
clip
- Throws:
IOException
-
saveGraphicsState
- Throws:
IOException
-
restoreGraphicsState
- Throws:
IOException
-