Browse Source

added basic support for padding-{top,left,bottom,right} on blocks


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193256 13f79535-47bb-0310-9956-ffa450edef68
pull/42/head
jtauber 24 years ago
parent
commit
19b7fef59d

+ 6
- 1
STATUS View File

@@ -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()

+ 29
- 1
src/codegen/properties.xml View File

@@ -330,5 +330,33 @@
<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>


+ 1
- 1
src/org/apache/fop/apps/Version.java View 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]";
}
}

+ 4
- 0
src/org/apache/fop/fo/PropertyListBuilder.java View 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());

+ 14
- 0
src/org/apache/fop/fo/flow/Block.java View 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();

+ 28
- 0
src/org/apache/fop/layout/Area.java View 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;
}

+ 5
- 1
src/org/apache/fop/render/pdf/PDFRenderer.java View 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());
}

Loading…
Cancel
Save