]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Support for relative border-*-*-radius fox properties
authorPeter Hancock <phancock@apache.org>
Mon, 22 Oct 2012 14:06:43 +0000 (14:06 +0000)
committerPeter Hancock <phancock@apache.org>
Mon, 22 Oct 2012 14:06:43 +0000 (14:06 +0000)
Plus cleanup

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_RoundedCorners@1400883 13f79535-47bb-0310-9956-ffa450edef68

examples/fo/advanced/rounded-corners.fo
src/java/org/apache/fop/fo/Constants.java
src/java/org/apache/fop/fo/FOPropertyMapping.java
src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
src/java/org/apache/fop/fo/properties/BoxCornerPropShorthandParser.java
src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
src/java/org/apache/fop/layoutmgr/TraitSetter.java
src/java/org/apache/fop/render/intermediate/BorderPainter.java
test/java/org/apache/fop/render/pdf/PDFPainterTestCase.java
test/java/org/apache/fop/render/ps/PSPainterTestCase.java

index d8df05922dc654e5e03d75c9844ecb64379ca789..7b275ae1731d36e211d5a8255be2f21050a4e3ae 100644 (file)
@@ -12,7 +12,7 @@
                                Examples using Rounded Corners
       </fo:block>
       <fo:block margin="20pt 0 40pt 0">
-        <fo:block>The "border-radius" property in the http://xmlgraphics.apache.org/fop/extensions namespace is a shorthand property for setting appropriate values for "border-*-radius-*" (see below), and is used to specify round corners on block areas.  The property takes one or two values:
+        <fo:block>The "border-radius" property in the http://xmlgraphics.apache.org/fop/extensions namespace is a shorthand property for setting appropriate values for "border-*-radius" (see below), and is used to specify round corners on block areas.  The property takes one or two values:
         </fo:block>
         <fo:block-container margin="10 20pt 20pt 20pt">
           <fo:block border-style="solid" border-width="10" border-color="#00f" fox:border-radius="20pt" padding="20pt" text-align="center" margin-bottom="10pt"> Circular corners are specified when 'border-radius' is set to a single value.  This value is the radius of the outer quadrant of the corner.</fo:block>
         </fo:block-container>
       </fo:block>
       <fo:block margin="20pt 0 40pt 0">
-        <fo:block>To specify the corner radii of two adjacent border segments, A and B, the properties border-A-radius-B and border-B-radius-A are set.  The value border-A-radius-B is the radius of the A-B corner in the direction perpendicular to segment A.
-        </fo:block>
+        <fo:block>The radii for a specific corner can be specified for each <fo:inline font-style="italic">CORNER</fo:inline> (in 'before-start', 'before-end', 'after-start', 'after-end') with the property "border-<fo:inline font-style="italic">CORNER</fo:inline>-radius".  These properties
+         have the same interpretation as the "border-radius" property.        </fo:block>
         <fo:table border-collapse="separate" margin-top="10pt">
           <fo:table-column column-width="200pt"/>
           <fo:table-column column-width="200pt"/>
           <fo:table-body>
             <fo:table-row>
               <fo:table-cell>
-                <fo:block margin-left="50pt" border-style="solid" border-width="50pt 0 0 50pt" border-color="#00f" fox:border-before-radius-start="100pt" fox:border-start-radius-before="100pt" height="100pt">
+                <fo:block margin-left="50pt" border-style="solid" border-width="50pt 0 0 50pt" border-color="#00f" fox:border-before-start-radius="100pt" height="100pt">
                   <fo:block padding="50pt"/>
                 </fo:block>
               </fo:table-cell>
               <fo:table-cell>
-                <fo:block margin-left="50pt" border-style="solid" border-width="50pt 0 0 50pt" border-color="#00f" fox:border-before-radius-start="100pt" fox:border-start-radius-before="200pt" height="100pt">
+                <fo:block margin-left="50pt" border-style="solid" border-width="50pt 0 0 50pt" border-color="#00f" fox:border-before-start-radius="200pt 100pt" height="100pt">
                   <fo:block padding="50pt"/>
                 </fo:block>
               </fo:table-cell>
         <fo:table-body>
           <fo:table-row>
             <fo:table-cell height="100pt">
-              <fo:block margin-left="50pt" border-style="solid" border-width="70pt 0 0 70pt" border-color="#00f" fox:border-before-radius-start="100pt" fox:border-start-radius-before="100pt" height="100pt">
+              <fo:block margin-left="50pt" border-style="solid" border-width="70pt 0 0 70pt" border-color="#00f" fox:border-before-start-radius="100pt" height="100pt">
                 <fo:block padding="50pt" text-align="center">
                   <fo:inline font-style="italic">I</fo:inline>
                 </fo:block>
               </fo:block>
             </fo:table-cell>
             <fo:table-cell height="100pt">
-              <fo:block margin-left="50pt" border-style="solid" border-width="70pt 0 0 70pt" border-color="#00f" fox:border-before-radius-start="50pt" fox:border-start-radius-before="50pt" height="100pt">
+              <fo:block margin-left="50pt" border-style="solid" border-width="70pt 0 0 70pt" border-color="#00f" fox:border-before-start-radius="50pt" height="100pt">
                 <fo:block padding="50pt" text-align="center">
                   <fo:inline font-style="italic">II</fo:inline>
                 </fo:block>
         <fo:table-body>
           <fo:table-row>
             <fo:table-cell number-columns-spanned="3">
-              <fo:block margin-bottom="20pt">The border segments join at a line that coincides with the one that interesects the inner and outer corners of the equivalent rectangular corner.  This is clearly demonstrated below where rounded borders are overlayed on top of rectangular borders.</fo:block>
+              <fo:block margin-bottom="20pt">The border segments join at a line that coincides with the one that intersects the inner and outer corners of the equivalent rectangular corner.  This is clearly demonstrated below where rounded borders are overlayed on top of rectangular borders.</fo:block>
             </fo:table-cell>
           </fo:table-row>
           <fo:table-row>
             <fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="50pt" height="100pt">
-              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-radius-start="50pt" fox:border-start-radius-before="50pt" border-before-width="50pt" border-start-width="50pt" height="100pt">
+              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-start-radius="50pt" border-before-width="50pt" border-start-width="50pt" height="100pt">
                 <fo:block margin-bottom="100pt"/>
               </fo:block>
             </fo:table-cell>
             <fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="50pt" height="100pt">
-              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-radius-start="100pt" fox:border-start-radius-before="100pt" border-before-width="50pt" border-start-width="50pt" height="100pt">
+              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-start-radius="100pt" border-before-width="50pt" border-start-width="50pt" height="100pt">
                 <fo:block margin-bottom="100pt"/>
               </fo:block>
             </fo:table-cell>
             <fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="50pt" height="100pt">
-              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-radius-start="100pt" fox:border-start-radius-before="150pt" border-before-width="50pt" border-start-width="50pt" height="100pt">
+              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-start-radius="150pt 100pt" border-before-width="50pt" border-start-width="50pt" height="100pt">
                 <fo:block margin-bottom="100pt"/>
               </fo:block>
             </fo:table-cell>
           </fo:table-row>
           <fo:table-row>
             <fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="100pt" height="100pt">
-              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-radius-start="50pt" fox:border-start-radius-before="50pt" border-before-width="50pt" border-start-width="100pt" height="100pt">
+              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-start-radius="50pt"  border-before-width="50pt" border-start-width="100pt" height="100pt">
                 <fo:block margin-bottom="100pt"/>
               </fo:block>
             </fo:table-cell>
             <fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="100pt" height="100pt">
-              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-radius-start="100pt" fox:border-start-radius-before="100pt" border-before-width="50pt" border-start-width="100pt" height="100pt">
+              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-start-radius="100pt" border-before-width="50pt" border-start-width="100pt" height="100pt">
                 <fo:block margin-bottom="100pt"/>
               </fo:block>
             </fo:table-cell>
             <fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="100pt" height="100pt">
-              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-radius-start="100pt" fox:border-start-radius-before="150pt" border-before-width="50pt" border-start-width="100pt" height="100pt">
+              <fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-start-radius="150pt 100pt" border-before-width="50pt" border-start-width="100pt" height="100pt">
                 <fo:block margin-bottom="100pt"/>
               </fo:block>
             </fo:table-cell>
index 1a2425af5c34b02c05723a52f0529e440b1e581c..7a83a12f885be3e3fbe4e3243a7f785b986dc3ea 100644 (file)
@@ -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
 
index 08afbcd52542c2a70789f24482d249dd2c9a85f2..3ae81c62af56b7d08f8c9d05ae0c2a8fa99824ad 100644 (file)
@@ -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);
index 076691cb45302539e2c359a202fd430e6b363535..09b47f02a8fe369bd54df261e717b1699bee0ad7 100644 (file)
@@ -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");
     }
 
     /**
index d3e37a7c97558f42ee70ff1572e639bb2e8ac8ac..06f198573e6fa64b2734dde26ec12bc2ad21870f 100644 (file)
@@ -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,
index eaf678790961fb30e9edfed9e3002208dcafaffb..61c7b95cd5b9aac3256c62f600d029bcb6f735c9 100644 (file)
@@ -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);
     }
 
 
index b96283a4e5ef5dc3361d68821a65c8b171598a78..c4aac1d8c751a0b7ab7973bfaa46de432557b64e 100644 (file)
@@ -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));
+                    
         }
     }
 
index e286590ca0d8598300794f5db8e2f6a7f12bef39..19e30b50f61a5decfb909efb7eb936fb9c1a30a3 100644 (file)
@@ -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);
     }
index 31f2f5c3b6ea93f5c4faa6aaf1849cc5fecf5c03..f431b3ee9c511f156c604f001ab770768f62e5c1 100644 (file)
@@ -24,64 +24,43 @@ import java.awt.Rectangle;
 
 import org.junit.Test;
 
-import static org.junit.Assert.fail;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fo.Constants;
+import org.apache.fop.render.intermediate.IFContext;
+import org.apache.fop.traits.BorderProps;
+
 import static org.mockito.Matchers.endsWith;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.fo.Constants;
-import org.apache.fop.render.intermediate.IFContext;
-import org.apache.fop.traits.BorderProps;
-
 public class PDFPainterTestCase {
 
     @Test
-    public void testDrawBorderRect() {
+    public void testDrawBorderRect() throws Exception {
         // the goal of this test is to check that the drawing of rounded corners in PDF calls
         // PDFGraphicsPaiter.cubicBezierTo(); the check is done by verifying that a " c " command is written
         // to the PDFContentGenerator
-        // mock
         PDFContentGenerator pdfContentGenerator = mock(PDFContentGenerator.class);
-        // the next line is commented out because the format() method is static and not possible to mock
-        // when(PDFContentGenerator.format(anyFloat())).thenReturn("20.0");
-        // mock
         FOUserAgent foUserAgent = mock(FOUserAgent.class);
         when(foUserAgent.isAccessibilityEnabled()).thenReturn(false);
-        // mock
         IFContext ifContext = mock(IFContext.class);
         when(ifContext.getUserAgent()).thenReturn(foUserAgent);
-        // mock
         PDFDocumentHandler pdfDocumentHandler = mock(PDFDocumentHandler.class);
         when(pdfDocumentHandler.getGenerator()).thenReturn(pdfContentGenerator);
         when(pdfDocumentHandler.getContext()).thenReturn(ifContext);
-        // mock
         PDFLogicalStructureHandler pdfLogicalStructureHandler = mock(PDFLogicalStructureHandler.class);
-        // real, not mock
         PDFPainter pdfPainter = new PDFPainter(pdfDocumentHandler, pdfLogicalStructureHandler);
         // build rectangle 200 x 50 (points, which are converted to milipoints)
         Rectangle rectangle = new Rectangle(0, 0, 200000, 50000);
         // build border properties: width 4pt, radius 30pt
-        int style = Constants.EN_SOLID;
-        BorderProps.Mode mode = BorderProps.Mode.SEPARATE;
-        Color color = Color.BLACK;
-        int borderWidth = 4000;
-        int radiusStart = 30000;
-        int radiusEnd = 30000;
-        BorderProps border1 = new BorderProps(style, borderWidth, radiusStart, radiusEnd, color, mode);
-        BorderProps border2 = new BorderProps(style, borderWidth, radiusStart, radiusEnd, color, mode);
-        BorderProps border3 = new BorderProps(style, borderWidth, radiusStart, radiusEnd, color, mode);
-        BorderProps border4 = new BorderProps(style, borderWidth, radiusStart, radiusEnd, color, mode);
-        try {
-            pdfPainter.drawBorderRect(rectangle, border1, border2, border3, border4, Color.WHITE);
-            // since we cannot mock the PDFContentGenerator.format() static method we have to restrict the
-            // verification to commands that end with " c ".
-            verify(pdfContentGenerator, times(16)).add(endsWith(" c "));
-        } catch (Exception e) {
-            fail("something broke...");
-        }
+        BorderProps border = new BorderProps(Constants.EN_SOLID, 4000, 30000, 30000, Color.BLACK,
+                BorderProps.Mode.SEPARATE);
+        pdfPainter.drawBorderRect(rectangle, border, border, border, border, Color.WHITE);
+        // since we cannot mock the PDFContentGenerator.format() static method we have to restrict the
+        // verification to commands that end with " c ".
+        verify(pdfContentGenerator, times(16)).add(endsWith(" c "));
     }
 
 }
index 7fac2b584daff5514820a95d1a3e5448071a6513..0a9f552ff39b884035b43b4b3da9f2a6c60773b5 100644 (file)
@@ -87,32 +87,20 @@ public class PSPainterTestCase {
         // the goal of this test is to check that the drawing of rounded corners in PS calls
         // PSGraphicsPaiter.cubicBezierTo(); the check is done by verifying that a curveto command is written
         // to the PSGenerator
-        // mock
         PSGenerator psGenerator = mock(PSGenerator.class);
         when(psGenerator.formatDouble(anyFloat())).thenReturn("20.0"); // simplify!
-        // mock
         PSRenderingUtil psRenderingUtil = mock(PSRenderingUtil.class);
-        // mock
         PSDocumentHandler psDocumentHandler = mock(PSDocumentHandler.class);
         when(psDocumentHandler.getGenerator()).thenReturn(psGenerator);
         when(psDocumentHandler.getPSUtil()).thenReturn(psRenderingUtil);
-        // real instance, no mock
         PSPainter psPainter = new PSPainter(psDocumentHandler);
         // build rectangle 200 x 50 (points, which are converted to milipoints)
         Rectangle rectangle = new Rectangle(0, 0, 200000, 50000);
         // build border properties: width 4pt, radius 30pt
-        int style = Constants.EN_SOLID;
-        BorderProps.Mode mode = BorderProps.Mode.SEPARATE;
-        Color color = Color.BLACK;
-        int borderWidth = 4000;
-        int radiusStart = 30000;
-        int radiusEnd = 30000;
-        BorderProps border1 = new BorderProps(style, borderWidth, radiusStart, radiusEnd, color, mode);
-        BorderProps border2 = new BorderProps(style, borderWidth, radiusStart, radiusEnd, color, mode);
-        BorderProps border3 = new BorderProps(style, borderWidth, radiusStart, radiusEnd, color, mode);
-        BorderProps border4 = new BorderProps(style, borderWidth, radiusStart, radiusEnd, color, mode);
+        BorderProps border = new BorderProps(Constants.EN_SOLID, 4000, 30000, 30000, Color.BLACK,
+                BorderProps.Mode.SEPARATE);
         try {
-            psPainter.drawBorderRect(rectangle, border1, border2, border3, border4, Color.WHITE);
+            psPainter.drawBorderRect(rectangle, border, border, border, border, Color.WHITE);
             verify(psGenerator, times(16)).writeln("20.0 20.0 20.0 20.0 20.0 20.0 curveto ");
         } catch (Exception e) {
             fail("something broke...");