]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
added basic support for padding-{top,left,bottom,right} on blocks
authorjtauber <jtauber@unknown>
Tue, 30 Nov 1999 02:15:22 +0000 (02:15 +0000)
committerjtauber <jtauber@unknown>
Tue, 30 Nov 1999 02:15:22 +0000 (02:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193256 13f79535-47bb-0310-9956-ffa450edef68

STATUS
src/codegen/properties.xml
src/org/apache/fop/apps/Version.java
src/org/apache/fop/fo/PropertyListBuilder.java
src/org/apache/fop/fo/flow/Block.java
src/org/apache/fop/layout/Area.java
src/org/apache/fop/render/pdf/PDFRenderer.java

diff --git a/STATUS b/STATUS
index 0e340f66eb051aa3279ee31b12a691e9f2abe7e4..633b0460946a64f5c11ef8d24fca56859e6a6818 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -5,6 +5,7 @@ STATUS
 Things to do:
 
 Get images working
+[PARTIAL] Get padding working
 [PARTIAL] Incorporate Arved Sandstrom's simple-link implementation
 [PARTIAL] Implement basic keeps
 [PARTIAL] Incorporate Eric Schaeffer's further table fixes
@@ -28,7 +29,11 @@ Todo's and problems with AWT Previewer:
 - should "preview" be an option when calling FOP instead of having
   it's own main method?
 
-Done:
+Done since 0.12.0 release:
+
+basic support for padding-{top,left,bottom,right} on blocks.
+
+Done for 0.12.0 release:
 
 Make sure Makefiles work
 Switch to using Status object as return from layout()
index 647adf33b0dd9024535c0af47c9b7f5fb4f3e438..df9e36c5135ed82f32d9323f90b5590dac07e449 100644 (file)
     <datatype>ColorType</datatype>
     <default>transparent</default>
   </property>
+  <property>
+    <name>padding-top</name>
+    <class-name>PaddingTop</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>padding-left</name>
+    <class-name>PaddingLeft</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>padding-bottom</name>
+    <class-name>PaddingBottom</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
+  <property>
+    <name>padding-right</name>
+    <class-name>PaddingRight</class-name>
+    <inherited>false</inherited>
+    <datatype>Length</datatype>
+    <default>0pt</default>
+  </property>
 </property-list>
-
index ead62e37216100708c257aaedb3dfba7e45eb035..92d444e41a8e24f06a99d46ae1afd7fbb49b6b12 100644 (file)
@@ -62,6 +62,6 @@ public class Version {
      * @return the version string
      */
     public static String getVersion() {
-       return "FOP 0.12.0";
+       return "FOP 0.12.1[dev]";
     }
 }
index 1bd425ce785bbbf9e1b610a2ec991c5bf25e4adc..bffb5d3e9c087bc952c414489cfb3ecabfcfc144 100644 (file)
@@ -105,6 +105,10 @@ public class PropertyListBuilder {
        propertyTable.put("column-width",ColumnWidth.maker());
        propertyTable.put("keep-with-next",KeepWithNext.maker());
        propertyTable.put("background-color",BackgroundColor.maker());
+       propertyTable.put("padding-top",PaddingTop.maker());
+       propertyTable.put("padding-bottom",PaddingBottom.maker());
+       propertyTable.put("padding-left",PaddingLeft.maker());
+       propertyTable.put("padding-right",PaddingRight.maker());
 
        propertyTable.put("height",SVGLength.maker());
        propertyTable.put("width",SVGLength.maker());
index 8742b8fcf0ca67a1ffaf39341020e308c4cb8a19..76599ca236784b2ef4b5e8a5a4280985149deaa5 100644 (file)
@@ -84,6 +84,10 @@ public class Block extends FObjMixed {
     int textIndent;
     int keepWithNext;
     ColorType backgroundColor;
+    int paddingTop;
+    int paddingBottom;
+    int paddingLeft;
+    int paddingRight;
 
     BlockArea blockArea;
 
@@ -137,6 +141,14 @@ public class Block extends FObjMixed {
                this.properties.get("keep-with-next").getEnum();
            this.backgroundColor =
                this.properties.get("background-color").getColorType();
+           this.paddingTop =
+               this.properties.get("padding-top").getLength().mvalue();
+           this.paddingLeft =
+               this.properties.get("padding-left").getLength().mvalue();
+           this.paddingBottom =
+               this.properties.get("padding-bottom").getLength().mvalue();
+           this.paddingRight =
+               this.properties.get("padding-right").getLength().mvalue();
 
            if (area instanceof BlockArea) {
                area.end();
@@ -187,6 +199,8 @@ public class Block extends FObjMixed {
                          textIndent, align, alignLast, lineHeight);
        blockArea.setPage(area.getPage());
        blockArea.setBackgroundColor(backgroundColor);
+       blockArea.setPadding(paddingTop, paddingLeft, paddingBottom,
+                            paddingRight);
        blockArea.start();
 
        int numChildren = this.children.size();
index dff0fb5e7bfac10f51bf02c8318cf750bb3fb862..e16d7df54731b9f95e340707bcf2b51e324bfb80 100644 (file)
@@ -82,6 +82,11 @@ abstract public class Area extends Box {
 
     protected ColorType backgroundColor;
 
+    protected int paddingTop;
+    protected int paddingLeft;
+    protected int paddingBottom;
+    protected int paddingRight;
+
     public Area (FontState fontState) {
        this.fontState = fontState;
     }
@@ -146,6 +151,22 @@ abstract public class Area extends Box {
        return this.backgroundColor;
     }
 
+    public int getPaddingTop() {
+       return this.paddingTop;
+    }
+
+    public int getPaddingLeft() {
+       return this.paddingLeft;
+    }
+
+    public int getPaddingBottom() {
+       return this.paddingBottom;
+    }
+
+    public int getPaddingRight() {
+       return this.paddingRight;
+    }
+
     public void increaseHeight(int amount) {
        this.currentHeight += amount;
     }
@@ -167,6 +188,13 @@ abstract public class Area extends Box {
        this.backgroundColor = bgColor;
     }
 
+    public void setPadding(int top, int left, int bottom, int right) {
+       this.paddingTop = top;
+       this.paddingLeft = left;
+       this.paddingBottom = bottom;
+       this.paddingRight = right;
+    }
+
     public int spaceLeft() {
        return maxHeight - currentHeight;
     }
index 276233f36395ec288d2e6b58f7a34ed2b145be81..03bf6d40e24ec8e9918261588463ec2661178019 100644 (file)
@@ -237,10 +237,14 @@ public class PDFRenderer implements Renderer {
        int w = area.getContentWidth();
        int h = area.getHeight();
        ColorType bg = area.getBackgroundColor();
+       int pt = area.getPaddingTop();
+       int pl = area.getPaddingLeft();
+       int pb = area.getPaddingBottom();
+       int pr = area.getPaddingRight();
        // I'm not sure I should have to check for bg being null
        // but I do
        if ((bg != null) && (bg.alpha() == 0)) {
-           this.addRect(rx, ry, w, -h,
+           this.addRect(rx - pl, ry + pt, w + pl + pr , - (h + pt + pb),
                         bg.red(), bg.green(), bg.blue(),
                         bg.red(), bg.green(), bg.blue());
        }