aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2007-11-13 17:13:19 +0000
committerVincent Hennebert <vhennebert@apache.org>2007-11-13 17:13:19 +0000
commitfdad001c2baf70ce221cf210cc20ce9f7d43749a (patch)
tree9ee82eea50ed2f81f81576b048aff0d667558121 /src/java/org/apache
parenta1abc9cf8323b1e69f3e665b76219973b1281073 (diff)
downloadxmlgraphics-fop-fdad001c2baf70ce221cf210cc20ce9f7d43749a.tar.gz
xmlgraphics-fop-fdad001c2baf70ce221cf210cc20ce9f7d43749a.zip
Use a singleton for a default BorderInfo of style none, instead of every time a new instance
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@594584 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java2
-rwxr-xr-xsrc/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java23
2 files changed, 22 insertions, 3 deletions
diff --git a/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java b/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
index bbed8a925..bcf67b2c5 100644
--- a/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
+++ b/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
@@ -42,7 +42,7 @@ public class EmptyGridUnit extends GridUnit {
/** {@inheritDoc} */
protected void setBorder(int side) {
resolvedBorders[side] = new BorderSpecification(
- new CommonBorderPaddingBackground.BorderInfo(Constants.EN_NONE, null, null),
+ CommonBorderPaddingBackground.getDefaultBorderInfo(),
Constants.FO_TABLE_CELL);
}
diff --git a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
index 114dadb94..6ea08f19c 100755
--- a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
+++ b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
@@ -83,7 +83,7 @@ public class CommonBorderPaddingBackground {
private Color mColor; // Border color
private CondLengthProperty mWidth;
- public BorderInfo(int style, CondLengthProperty width, Color color) {
+ BorderInfo(int style, CondLengthProperty width, Color color) {
mStyle = style;
mWidth = width;
mColor = color;
@@ -124,6 +124,25 @@ public class CommonBorderPaddingBackground {
}
}
+ /**
+ * A border info with style none. Used as a singleton, in the collapsing-border model,
+ * for elements which don't specify any border on some of their sides.
+ */
+ private static BorderInfo defaultBorderInfo;
+
+ /**
+ * Returns a default BorderInfo of style none.
+ *
+ * @return a BorderInfo instance with style set to {@link Constants#EN_NONE}
+ */
+ public static synchronized BorderInfo getDefaultBorderInfo() {
+ if (defaultBorderInfo == null) {
+ /* It is enough to set color and width to null, as they should never be consulted */
+ defaultBorderInfo = new BorderInfo(Constants.EN_NONE, null, null);
+ }
+ return defaultBorderInfo;
+ }
+
private BorderInfo[] borderInfo = new BorderInfo[4];
private CondLengthProperty[] padding = new CondLengthProperty[4];
@@ -228,7 +247,7 @@ public class CommonBorderPaddingBackground {
*/
public BorderInfo getBorderInfo(int side) {
if (this.borderInfo[side] == null) {
- return new BorderInfo(Constants.EN_NONE, null, null); // TODO
+ return getDefaultBorderInfo();
} else {
return this.borderInfo[side];
}