in fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java [418:617]
public void paint(Graphics2D g2d, Rectangle2D area) {
//background
Area background = new Area(area);
Area cornerRegion = new Area();
Area[] cornerBorder = new Area[]{new Area(), new Area(), new Area(), new Area()};
Area[] clip = new Area[4];
if (roundCorner[TOP_LEFT]) {
AffineTransform transform = new AffineTransform();
int beforeRadius = (int)(cornerCorrectionFactor * bpsBefore.getRadiusStart());
int startRadius = (int)(cornerCorrectionFactor * bpsStart.getRadiusStart());
int beforeWidth = bpsBefore.width;
int startWidth = bpsStart.width;
int corner = TOP_LEFT;
background.subtract(makeCornerClip(beforeRadius, startRadius,
transform));
clip[TOP_LEFT] = new Area(new Rectangle(0, 0, startRadius, beforeRadius));
clip[TOP_LEFT].transform(transform);
cornerRegion.add(clip[TOP_LEFT]);
cornerBorder[TOP].add(makeCornerBorderBPD(beforeRadius,
startRadius, beforeWidth, startWidth, transform));
cornerBorder[LEFT].add(makeCornerBorderIPD(beforeRadius,
startRadius, beforeWidth, startWidth, transform));
}
if (roundCorner[TOP_RIGHT]) {
AffineTransform transform
= new AffineTransform(-1, 0, 0, 1, borderRect.width, 0);
int beforeRadius = (int)(cornerCorrectionFactor * bpsBefore.getRadiusEnd());
int startRadius = (int)(cornerCorrectionFactor * bpsEnd.getRadiusStart());
int beforeWidth = bpsBefore.width;
int startWidth = bpsEnd.width;
int corner = TOP_RIGHT;
background.subtract(makeCornerClip(beforeRadius, startRadius,
transform));
clip[TOP_RIGHT] = new Area(new Rectangle(0, 0, startRadius, beforeRadius));
clip[TOP_RIGHT].transform(transform);
cornerRegion.add(clip[TOP_RIGHT]);
cornerBorder[TOP].add(makeCornerBorderBPD(beforeRadius,
startRadius, beforeWidth, startWidth, transform));
cornerBorder[RIGHT].add(makeCornerBorderIPD(beforeRadius,
startRadius, beforeWidth, startWidth, transform));
}
if (roundCorner[BOTTOM_RIGHT]) {
AffineTransform transform = new AffineTransform(-1, 0, 0, -1,
borderRect.width, borderRect.height);
int beforeRadius = (int)(cornerCorrectionFactor * bpsAfter.getRadiusEnd());
int startRadius = (int)(cornerCorrectionFactor * bpsEnd.getRadiusEnd());
int beforeWidth = bpsAfter.width;
int startWidth = bpsEnd.width;
int corner = BOTTOM_RIGHT;
background.subtract(makeCornerClip(beforeRadius, startRadius,
transform));
clip[BOTTOM_RIGHT] = new Area(new Rectangle(0, 0, startRadius, beforeRadius));
clip[BOTTOM_RIGHT].transform(transform);
cornerRegion.add(clip[BOTTOM_RIGHT]);
cornerBorder[BOTTOM].add(makeCornerBorderBPD(beforeRadius,
startRadius, beforeWidth, startWidth, transform));
cornerBorder[RIGHT].add(makeCornerBorderIPD(beforeRadius,
startRadius, beforeWidth, startWidth, transform));
}
if (roundCorner[BOTTOM_LEFT]) {
AffineTransform transform
= new AffineTransform(1, 0, 0, -1, 0, borderRect.height);
int beforeRadius = (int)(cornerCorrectionFactor * bpsAfter.getRadiusStart());
int startRadius = (int)(cornerCorrectionFactor * bpsStart.getRadiusEnd());
int beforeWidth = bpsAfter.width;
int startWidth = bpsStart.width;
int corner = BOTTOM_LEFT;
background.subtract(makeCornerClip(beforeRadius, startRadius,
transform));
clip[BOTTOM_LEFT] = new Area(new Rectangle(0, 0, startRadius, beforeRadius));
clip[BOTTOM_LEFT].transform(transform);
cornerRegion.add(clip[BOTTOM_LEFT]);
cornerBorder[BOTTOM].add(makeCornerBorderBPD(beforeRadius,
startRadius, beforeWidth, startWidth, transform));
cornerBorder[LEFT].add(makeCornerBorderIPD(beforeRadius,
startRadius, beforeWidth, startWidth, transform));
}
g2d.setColor(innerBackgroundColor);
g2d.fill(background);
//paint the borders
//TODO refactor to repeating code into method
if (bpsBefore != null && bpsBefore.width > 0) {
GeneralPath borderPath = new GeneralPath();
borderPath.moveTo(0, 0);
borderPath.lineTo(borderRect.width, 0);
borderPath.lineTo(
borderRect.width - (bpsEnd == null ? 0 : bpsEnd.width),
bpsBefore.width);
borderPath.lineTo(bpsStart == null ? 0 : bpsStart.width, bpsBefore.width);
Area border = new Area(borderPath);
if (clip[TOP_LEFT] != null) {
border.subtract(clip[TOP_LEFT]);
}
if (clip[TOP_RIGHT] != null) {
border.subtract(clip[TOP_RIGHT]);
}
g2d.setColor(bpsBefore.color);
g2d.fill(border);
g2d.fill(cornerBorder[TOP]);
}
if (bpsEnd != null && bpsEnd.width > 0) {
GeneralPath borderPath = new GeneralPath();
borderPath.moveTo(borderRect.width, 0);
borderPath.lineTo(borderRect.width, borderRect.height);
borderPath.lineTo(
borderRect.width - bpsEnd.width,
borderRect.height - (bpsAfter == null ? 0 : bpsAfter.width));
borderPath.lineTo(
borderRect.width - bpsEnd.width,
bpsBefore == null ? 0 : bpsBefore.width);
Area border = new Area(borderPath);
if (clip[BOTTOM_RIGHT] != null) {
border.subtract(clip[BOTTOM_RIGHT]);
}
if (clip[TOP_RIGHT] != null) {
border.subtract(clip[TOP_RIGHT]);
}
g2d.setColor(bpsEnd.color);
g2d.fill(border);
g2d.fill(cornerBorder[RIGHT]);
}
if (bpsAfter != null && bpsAfter.width > 0) {
GeneralPath borderPath = new GeneralPath();
borderPath.moveTo(0, borderRect.height);
borderPath.lineTo(borderRect.width, borderRect.height);
borderPath.lineTo(
borderRect.width - (bpsEnd == null ? 0 : bpsEnd.width),
borderRect.height - bpsAfter.width);
borderPath.lineTo(bpsStart == null ? 0 : bpsStart.width,
borderRect.height - bpsAfter.width);
Area border = new Area(borderPath);
if (clip[BOTTOM_LEFT] != null) {
border.subtract(clip[BOTTOM_LEFT]);
}
if (clip[BOTTOM_RIGHT] != null) {
border.subtract(clip[BOTTOM_RIGHT]);
}
g2d.setColor(bpsAfter.color);
g2d.fill(border);
g2d.fill(cornerBorder[BOTTOM]);
}
if (bpsStart != null && bpsStart.width > 0) {
GeneralPath borderPath = new GeneralPath();
borderPath.moveTo(bpsStart.width,
bpsBefore == null ? 0 : bpsBefore.width);
borderPath.lineTo(bpsStart.width,
borderRect.height - (bpsAfter == null ? 0 : bpsAfter.width));
borderPath.lineTo(0, borderRect.height);
borderPath.lineTo(0, 0);
Area border = new Area(borderPath);
if (clip[BOTTOM_LEFT] != null) {
border.subtract(clip[BOTTOM_LEFT]);
}
if (clip[TOP_LEFT] != null) {
border.subtract(clip[TOP_LEFT]);
}
g2d.setColor(bpsStart.color);
g2d.fill(border);
g2d.fill(cornerBorder[LEFT]);
}
}