aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeter Hancock <phancock@apache.org>2012-10-22 14:06:43 +0000
committerPeter Hancock <phancock@apache.org>2012-10-22 14:06:43 +0000
commit3f8838ef97cc1fc9799be4d1be2ac3a86dae596d (patch)
treef767783575a2d4efe99b1b82679ee5346cc2e423 /src
parent2d0a6a2c81b6c683f73e1886afb75e2ab45c6430 (diff)
downloadxmlgraphics-fop-3f8838ef97cc1fc9799be4d1be2ac3a86dae596d.tar.gz
xmlgraphics-fop-3f8838ef97cc1fc9799be4d1be2ac3a86dae596d.zip
Support for relative border-*-*-radius fox properties
Plus cleanup git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_RoundedCorners@1400883 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/fo/Constants.java26
-rw-r--r--src/java/org/apache/fop/fo/FOPropertyMapping.java79
-rw-r--r--src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java7
-rw-r--r--src/java/org/apache/fop/fo/properties/BoxCornerPropShorthandParser.java2
-rw-r--r--src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java23
-rw-r--r--src/java/org/apache/fop/layoutmgr/TraitSetter.java16
-rw-r--r--src/java/org/apache/fop/render/intermediate/BorderPainter.java15
7 files changed, 105 insertions, 63 deletions
diff --git a/src/java/org/apache/fop/fo/Constants.java b/src/java/org/apache/fop/fo/Constants.java
index 1a2425af5..7a83a12f8 100644
--- a/src/java/org/apache/fop/fo/Constants.java
+++ b/src/java/org/apache/fop/fo/Constants.java
@@ -781,37 +781,43 @@ public interface Constants {
/** Property constant FOP proprietary*/
int PR_X_BORDER_BEFORE_RADIUS_START = 276;
-
/** Property constant FOP proprietary*/
int PR_X_BORDER_BEFORE_RADIUS_END = 277;
-
/** Property constant FOP proprietary*/
int PR_X_BORDER_AFTER_RADIUS_START = 278;
/** Property constant FOP proprietary*/
int PR_X_BORDER_AFTER_RADIUS_END = 279;
-
/** Property constant FOP proprietary*/
- int PR_X_BORDER_START_RADIUS_START = 280;
+ int PR_X_BORDER_START_RADIUS_BEFORE = 280;
/** Property constant FOP proprietary*/
- int PR_X_BORDER_START_RADIUS_END = 281;
+ int PR_X_BORDER_START_RADIUS_AFTER = 281;
/** Property constant FOP proprietary*/
- int PR_X_BORDER_END_RADIUS_START = 282;
+ int PR_X_BORDER_END_RADIUS_BEFORE = 282;
/** Property constant FOP proprietary*/
- int PR_X_BORDER_END_RADIUS_END = 283;
+ int PR_X_BORDER_END_RADIUS_AFTER = 283;
/** Property constant FOP proprietary*/
int PR_X_BORDER_RADIUS = 284;
+ /** Property constant FOP proprietary*/
+ int PR_X_BORDER_BEFORE_START_RADIUS = 285;
+ /** Property constant FOP proprietary*/
+ int PR_X_BORDER_BEFORE_END_RADIUS = 286;
+ /** Property constant FOP proprietary*/
+ int PR_X_BORDER_AFTER_START_RADIUS = 287;
+ /** Property constant FOP proprietary*/
+ int PR_X_BORDER_AFTER_END_RADIUS = 288;
+
/**
* Property constant - FOP proprietary extension (see NumberConverter) used
* to perform additional control over number conversion when generating page
* numbers.
*/
- int PR_X_NUMBER_CONVERSION_FEATURES = 285;
+ int PR_X_NUMBER_CONVERSION_FEATURES = 289;
/** Scope for table header */
- int PR_X_HEADER_COLUMN = 286;
+ int PR_X_HEADER_COLUMN = 290;
/** Number of property constants defined */
- int PROPERTY_COUNT = 286;
+ int PROPERTY_COUNT = 290;
// compound property constants
diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java
index 08afbcd52..3ae81c62a 100644
--- a/src/java/org/apache/fop/fo/FOPropertyMapping.java
+++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java
@@ -206,12 +206,11 @@ public final class FOPropertyMapping implements Constants {
genericBorderStyle.setDefault("none");
// GenericCondCornerRadius
- genericCondCornerRadius = new CondLengthProperty.Maker(0);
+ genericCondCornerRadius = new CondLengthProperty.Maker(0);
genericCondCornerRadius.useGeneric(genericCondLength);
genericCondCornerRadius.setInherited(false);
genericCondCornerRadius.getSubpropMaker(CP_LENGTH).setDefault("0pt");
genericCondCornerRadius.setPercentBase(LengthBase.CONTAINING_BLOCK_HEIGHT);
- genericCondCornerRadius.addShorthand(generics[PR_X_BORDER_RADIUS]);
// GenericBreak
genericBreak = new EnumProperty.Maker(0);
@@ -2617,53 +2616,59 @@ public final class FOPropertyMapping implements Constants {
// fox:border-*-radius-*
-
- // border-before-radius-start
- m = new CondLengthProperty.Maker(PR_X_BORDER_BEFORE_RADIUS_START);
+ m = new CondLengthProperty.Maker(PR_X_BORDER_BEFORE_RADIUS_START);
m.useGeneric(genericCondCornerRadius);
+ m.addShorthand(generics[PR_X_BORDER_BEFORE_START_RADIUS]);
+ m.addShorthand(generics[PR_X_BORDER_RADIUS]);
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
-
addPropertyMaker("fox:border-before-radius-start", m);
- // border-before-radius-end
- m = new CondLengthProperty.Maker(PR_X_BORDER_BEFORE_RADIUS_END);
+ m = new CondLengthProperty.Maker(PR_X_BORDER_BEFORE_RADIUS_END);
m.useGeneric(genericCondCornerRadius);
+ m.addShorthand(generics[PR_X_BORDER_BEFORE_END_RADIUS]);
+ m.addShorthand(generics[PR_X_BORDER_RADIUS]);
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
addPropertyMaker("fox:border-before-radius-end", m);
- // border-after-radius-start
- m = new CondLengthProperty.Maker(PR_X_BORDER_AFTER_RADIUS_START);
+ m = new CondLengthProperty.Maker(PR_X_BORDER_AFTER_RADIUS_START);
m.useGeneric(genericCondCornerRadius);
+ m.addShorthand(generics[PR_X_BORDER_AFTER_START_RADIUS]);
+ m.addShorthand(generics[PR_X_BORDER_RADIUS]);
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
addPropertyMaker("fox:border-after-radius-start", m);
- // border-after-radius-end
- m = new CondLengthProperty.Maker(PR_X_BORDER_AFTER_RADIUS_END);
+ m = new CondLengthProperty.Maker(PR_X_BORDER_AFTER_RADIUS_END);
m.useGeneric(genericCondCornerRadius);
+ m.addShorthand(generics[PR_X_BORDER_AFTER_END_RADIUS]);
+ m.addShorthand(generics[PR_X_BORDER_RADIUS]);
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
addPropertyMaker("fox:border-after-radius-end", m);
- // border-start-radius-before
- m = new CondLengthProperty.Maker(PR_X_BORDER_START_RADIUS_START);
+ m = new CondLengthProperty.Maker(PR_X_BORDER_START_RADIUS_BEFORE);
m.useGeneric(genericCondCornerRadius);
+ m.addShorthand(generics[PR_X_BORDER_BEFORE_START_RADIUS]);
+ m.addShorthand(generics[PR_X_BORDER_RADIUS]);
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
addPropertyMaker("fox:border-start-radius-before", m);
- // border-start-radius-after
- m = new CondLengthProperty.Maker(PR_X_BORDER_START_RADIUS_END);
+ m = new CondLengthProperty.Maker(PR_X_BORDER_START_RADIUS_AFTER);
m.useGeneric(genericCondCornerRadius);
+ m.addShorthand(generics[PR_X_BORDER_AFTER_START_RADIUS]);
+ m.addShorthand(generics[PR_X_BORDER_RADIUS]);
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
addPropertyMaker("fox:border-start-radius-after", m);
- // border-end-radius-before
- m = new CondLengthProperty.Maker(PR_X_BORDER_END_RADIUS_START);
+ m = new CondLengthProperty.Maker(PR_X_BORDER_END_RADIUS_BEFORE);
m.useGeneric(genericCondCornerRadius);
+ m.addShorthand(generics[PR_X_BORDER_BEFORE_END_RADIUS]);
+ m.addShorthand(generics[PR_X_BORDER_RADIUS]);
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
addPropertyMaker("fox:border-end-radius-before", m);
- // border-end-radius-after
- m = new CondLengthProperty.Maker(PR_X_BORDER_END_RADIUS_END);
+ m = new CondLengthProperty.Maker(PR_X_BORDER_END_RADIUS_AFTER);
m.useGeneric(genericCondCornerRadius);
+ m.addShorthand(generics[PR_X_BORDER_AFTER_END_RADIUS]);
+ m.addShorthand(generics[PR_X_BORDER_RADIUS]);
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
addPropertyMaker("fox:border-end-radius-after", m);
@@ -2793,14 +2798,14 @@ public final class FOPropertyMapping implements Constants {
addPropertyMaker("border-right", m);
// border-style
- m = new ListProperty.Maker(PR_BORDER_STYLE);
+ m = new ListProperty.Maker(PR_BORDER_STYLE);
m.setInherited(false);
m.setDefault("");
m.setDatatypeParser(new BoxPropShorthandParser());
addPropertyMaker("border-style", m);
// border-spacing
- m = new ListProperty.Maker(PR_BORDER_SPACING);
+ m = new ListProperty.Maker(PR_BORDER_SPACING);
m.setInherited(true);
m.setDefault("0pt");
m.setDatatypeParser(new BorderSpacingShorthandParser());
@@ -2821,12 +2826,40 @@ public final class FOPropertyMapping implements Constants {
addPropertyMaker("border-width", m);
// fox:border-radius
- m = new ListProperty.Maker(PR_X_BORDER_RADIUS);
+ m = new ListProperty.Maker(PR_X_BORDER_RADIUS);
m.setInherited(false);
m.setDatatypeParser(new BoxCornerPropShorthandParser());
m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
addPropertyMaker("fox:border-radius", m);
+ // fox:border-before-start-radius
+ m = new ListProperty.Maker(PR_X_BORDER_BEFORE_START_RADIUS);
+ m.setInherited(false);
+ m.setDatatypeParser(new BoxCornerPropShorthandParser());
+ m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
+ addPropertyMaker("fox:border-before-start-radius", m);
+
+ // fox:border-before-end-radius
+ m = new ListProperty.Maker(PR_X_BORDER_BEFORE_END_RADIUS);
+ m.setInherited(false);
+ m.setDatatypeParser(new BoxCornerPropShorthandParser());
+ m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
+ addPropertyMaker("fox:border-before-end-radius", m);
+
+ // fox:border-after-start-radius
+ m = new ListProperty.Maker(PR_X_BORDER_AFTER_START_RADIUS);
+ m.setInherited(false);
+ m.setDatatypeParser(new BoxCornerPropShorthandParser());
+ m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
+ addPropertyMaker("fox:border-after-start-radius", m);
+
+ // fox:border-after-end-radius
+ m = new ListProperty.Maker(PR_X_BORDER_AFTER_END_RADIUS);
+ m.setInherited(false);
+ m.setDatatypeParser(new BoxCornerPropShorthandParser());
+ m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
+ addPropertyMaker("fox:border-after-end-radius", m);
+
// cue
m = new ToBeImplementedProperty.Maker(PR_CUE);
m.setInherited(false);
diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
index 076691cb4..09b47f02a 100644
--- a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
+++ b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
@@ -40,8 +40,7 @@ public class ExtensionElementMapping extends ElementMapping {
/** The standard XML prefix for elements and attributes in this namespace. */
public static final String STANDARD_PREFIX = "fox";
- private static final Set<String> PROPERTY_ATTRIBUTES
- = new java.util.HashSet<String>();
+ private static final Set<String> PROPERTY_ATTRIBUTES = new java.util.HashSet<String>();
static {
//These are FOP's standard extension properties (fox:*)
@@ -63,6 +62,10 @@ public class ExtensionElementMapping extends ElementMapping {
PROPERTY_ATTRIBUTES.add("border-end-radius-before");
PROPERTY_ATTRIBUTES.add("border-end-radius-after");
PROPERTY_ATTRIBUTES.add("border-radius");
+ PROPERTY_ATTRIBUTES.add("border-before-start-radius");
+ PROPERTY_ATTRIBUTES.add("border-before-end-radius");
+ PROPERTY_ATTRIBUTES.add("border-after-start-radius");
+ PROPERTY_ATTRIBUTES.add("border-after-end-radius");
}
/**
diff --git a/src/java/org/apache/fop/fo/properties/BoxCornerPropShorthandParser.java b/src/java/org/apache/fop/fo/properties/BoxCornerPropShorthandParser.java
index d3e37a7c9..06f198573 100644
--- a/src/java/org/apache/fop/fo/properties/BoxCornerPropShorthandParser.java
+++ b/src/java/org/apache/fop/fo/properties/BoxCornerPropShorthandParser.java
@@ -39,8 +39,8 @@ public class BoxCornerPropShorthandParser extends GenericShorthandParser {
* If 2 value are present the first is the corner radius in the IP direction,
* the second in the BP direction.
* {@inheritDoc}
- * int, Property, PropertyMaker, PropertyList)
*/
+ @Override
protected Property convertValueForProperty(int propId,
Property property,
PropertyMaker maker,
diff --git a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
index eaf678790..61c7b95cd 100644
--- a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
+++ b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
@@ -372,15 +372,15 @@ public class CommonBorderPaddingBackground {
Constants.PR_BORDER_START_STYLE,
Constants.PR_BORDER_START_WIDTH,
Constants.PR_PADDING_START,
- Constants.PR_X_BORDER_START_RADIUS_START,
- Constants.PR_X_BORDER_START_RADIUS_END);
+ Constants.PR_X_BORDER_START_RADIUS_BEFORE,
+ Constants.PR_X_BORDER_START_RADIUS_AFTER);
initBorderInfo(pList, END,
Constants.PR_BORDER_END_COLOR,
Constants.PR_BORDER_END_STYLE,
Constants.PR_BORDER_END_WIDTH,
Constants.PR_PADDING_END,
- Constants.PR_X_BORDER_END_RADIUS_START,
- Constants.PR_X_BORDER_END_RADIUS_END);
+ Constants.PR_X_BORDER_END_RADIUS_BEFORE,
+ Constants.PR_X_BORDER_END_RADIUS_AFTER);
}
@@ -452,15 +452,12 @@ public class CommonBorderPaddingBackground {
padding[side] = pList.get(paddingProp).getCondLength();
// If style = none, force width to 0, don't get Color (spec 7.7.20)
int style = pList.get(styleProp).getEnum();
- // if (style != Constants.EN_NONE) {
- FOUserAgent ua = pList.getFObj().getUserAgent();
- setBorderInfo(BorderInfo.getInstance(style,
- pList.get(widthProp).getCondLength(),
- pList.get(colorProp).getColor(ua),
- pList.get(radiusStartProp).getCondLength(),
- pList.get(radiusEndProp).getCondLength()), side);
- // }
-
+ FOUserAgent ua = pList.getFObj().getUserAgent();
+ setBorderInfo(BorderInfo.getInstance(style,
+ pList.get(widthProp).getCondLength(),
+ pList.get(colorProp).getColor(ua),
+ pList.get(radiusStartProp).getCondLength(),
+ pList.get(radiusEndProp).getCondLength()), side);
}
diff --git a/src/java/org/apache/fop/layoutmgr/TraitSetter.java b/src/java/org/apache/fop/layoutmgr/TraitSetter.java
index b96283a4e..c4aac1d8c 100644
--- a/src/java/org/apache/fop/layoutmgr/TraitSetter.java
+++ b/src/java/org/apache/fop/layoutmgr/TraitSetter.java
@@ -104,14 +104,16 @@ public final class TraitSetter {
*/
private static void addBorderTrait(Area area,
CommonBorderPaddingBackground bpProps,
- boolean bDiscard, int iSide, BorderProps.Mode mode,
+
+ boolean discard, int side, BorderProps.Mode mode,
Integer traitCode, PercentBaseContext context) {
- int iBP = bpProps.getBorderWidth(iSide, bDiscard);
- int radiusStart = bpProps.getBorderRadiusStart(iSide, bDiscard, context);
- int radiusEnd = bpProps.getBorderRadiusEnd(iSide, bDiscard, context);
- if (iBP > 0 || radiusStart > 0 || radiusEnd > 0) {
- area.addTrait(traitCode, new BorderProps(bpProps.getBorderStyle(iSide), iBP, radiusStart, radiusEnd,
- bpProps.getBorderColor(iSide), mode));
+ int width = bpProps.getBorderWidth(side, discard);
+ int radiusStart = bpProps.getBorderRadiusStart(side, discard, context);
+ int radiusEnd = bpProps.getBorderRadiusEnd(side, discard, context);
+ if (width > 0 || radiusStart > 0 || radiusEnd > 0) {
+ area.addTrait(traitCode, new BorderProps(bpProps.getBorderStyle(side), width, radiusStart,
+ radiusEnd, bpProps.getBorderColor(side), mode));
+
}
}
diff --git a/src/java/org/apache/fop/render/intermediate/BorderPainter.java b/src/java/org/apache/fop/render/intermediate/BorderPainter.java
index e286590ca..19e30b50f 100644
--- a/src/java/org/apache/fop/render/intermediate/BorderPainter.java
+++ b/src/java/org/apache/fop/render/intermediate/BorderPainter.java
@@ -30,9 +30,6 @@ import org.apache.fop.traits.BorderProps;
*/
public class BorderPainter {
- /** TODO remove before integration*/
- public static final String ROUNDED_CORNERS = "fop.round-corners";
-
// TODO Use a class to model border instead of an array
/** Convention index of before top */
protected static final int TOP = 0;
@@ -318,10 +315,10 @@ public class BorderPainter {
final int ex2 = ex1 - end.getWidth() + end.getClippedWidth();
final int outery = -before.getClippedWidth();
final int innery = outery + before.getWidth();
- final int ellipseSBRadiusX = (int) (cornerCorrectionFactor * start.getRadiusEnd());
- final int ellipseSBRadiusY = (int) (cornerCorrectionFactor * before.getRadiusStart());
- final int ellipseBERadiusX = (int) (cornerCorrectionFactor * end.getRadiusStart());
- final int ellipseBERadiusY = (int) (cornerCorrectionFactor * before.getRadiusEnd());
+ final int ellipseSBRadiusX = correctRadius(cornerCorrectionFactor, start.getRadiusEnd());
+ final int ellipseSBRadiusY = correctRadius(cornerCorrectionFactor, before.getRadiusStart());
+ final int ellipseBERadiusX = correctRadius(cornerCorrectionFactor, end.getRadiusStart());
+ final int ellipseBERadiusY = correctRadius(cornerCorrectionFactor, before.getRadiusEnd());
saveGraphicsState();
translateCoordinates(x, y);
if (orientation != 0) {
@@ -406,6 +403,10 @@ public class BorderPainter {
}
}
+ private static int correctRadius(double cornerCorrectionFactor, int radius) {
+ return (int) (Math.round(cornerCorrectionFactor * radius));
+ }
+
private static BorderSegment borderSegmentForBefore(BorderProps before) {
return AbstractBorderSegment.asBorderSegment(before);
}