]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
W.I.P. on corresponding properties
authorPeter Bernard West <pbwest@apache.org>
Wed, 21 Apr 2004 15:21:18 +0000 (15:21 +0000)
committerPeter Bernard West <pbwest@apache.org>
Wed, 21 Apr 2004 15:21:18 +0000 (15:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197526 13f79535-47bb-0310-9956-ffa450edef68

16 files changed:
src/java/org/apache/fop/fo/properties/AbsoluteCorrespondingProperty.java
src/java/org/apache/fop/fo/properties/AbstractCorrespondingProperty.java [new file with mode: 0644]
src/java/org/apache/fop/fo/properties/BorderAfterStyle.java
src/java/org/apache/fop/fo/properties/BorderBeforeStyle.java
src/java/org/apache/fop/fo/properties/BorderBottomStyle.java
src/java/org/apache/fop/fo/properties/BorderCommonStyle.java
src/java/org/apache/fop/fo/properties/BorderCommonStyleAbsolute.java
src/java/org/apache/fop/fo/properties/BorderCommonStyleRelative.java
src/java/org/apache/fop/fo/properties/BorderEndStyle.java
src/java/org/apache/fop/fo/properties/BorderLeftStyle.java
src/java/org/apache/fop/fo/properties/BorderRightStyle.java
src/java/org/apache/fop/fo/properties/BorderStartStyle.java
src/java/org/apache/fop/fo/properties/BorderTopStyle.java
src/java/org/apache/fop/fo/properties/CorrespondingProperty.java [new file with mode: 0644]
src/java/org/apache/fop/fo/properties/Property.java
src/java/org/apache/fop/fo/properties/RelativeCorrespondingProperty.java

index e719032c19c951e397770901b709195abfd27e14..4eb2981653be6472d8bfa86b2e7555185e9fb5b7 100644 (file)
@@ -30,9 +30,8 @@ import org.apache.fop.fo.expr.PropertyException;
  * @author pbw
  * @version $Revision$ $Name$
  */
-public interface AbsoluteCorrespondingProperty {
-    public int getWritingMode (FONode foNode)
-    throws PropertyException;
+public interface AbsoluteCorrespondingProperty
+extends CorrespondingProperty {
     public int getCorrespondingRelativeProperty(FONode foNode)
     throws PropertyException;
     public boolean overridesCorresponding(FONode foNode);
diff --git a/src/java/org/apache/fop/fo/properties/AbstractCorrespondingProperty.java b/src/java/org/apache/fop/fo/properties/AbstractCorrespondingProperty.java
new file mode 100644 (file)
index 0000000..fe7de87
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 21/04/2004
+ * $Id$
+ */
+package org.apache.fop.fo.properties;
+
+import org.apache.fop.datatypes.EnumType;
+import org.apache.fop.datatypes.PropertyValue;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.PropNames;
+import org.apache.fop.fo.expr.PropertyException;
+
+/**
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public abstract class AbstractCorrespondingProperty extends Property
+        implements
+            CorrespondingProperty {
+    /* (non-Javadoc)
+     * @see org.apache.fop.fo.properties.CorrespondingProperty#getWritingMode(org.apache.fop.fo.FONode)
+     */
+    public int getWritingMode(FONode foNode)
+    throws PropertyException {
+        PropertyValue wm = foNode.getPropertyValue(PropNames.WRITING_MODE);
+        return EnumType.getEnumValue(wm);
+    }
+    /* (non-Javadoc)
+     * @see org.apache.fop.fo.properties.CorrespondingProperty#getCorrespondingProperty(org.apache.fop.fo.FONode)
+     */
+    public abstract int getCorrespondingProperty(FONode foNode)
+    throws PropertyException;
+}
index 829e8474ba036b2458ecaebb927c8d6397aa2f32..328c832b7fe0e55befbb4c7afbf1fde1c067b7fe 100644 (file)
@@ -53,8 +53,8 @@ extends BorderCommonStyleRelative {
 
     public int getCorrespondingAbsoluteProperty(FONode foNode)
     throws PropertyException {
-        return WritingMode.getCorrespondingAbsoluteEdge(
-                getWritingMode(foNode), WritingMode.AFTER);
+        return getCorrespondingAbsoluteStyleProperty(
+                foNode, WritingMode.AFTER);
     }
 
     public boolean correspondingOverrides(FONode foNode) {
index 7addf2d9dd5166d7e5faba98fa0636cc5f6cdff2..aad8ac11e2a40ab0c1abb9bcf29647d9c1941c89 100644 (file)
@@ -53,8 +53,8 @@ extends BorderCommonStyleRelative {
 
     public int getCorrespondingAbsoluteProperty(FONode foNode)
     throws PropertyException {
-        return WritingMode.getCorrespondingAbsoluteEdge(
-                getWritingMode(foNode), WritingMode.BEFORE);
+        return getCorrespondingAbsoluteStyleProperty(
+                foNode, WritingMode.BEFORE);
     }
 
     public boolean correspondingOverrides(FONode foNode) {
index cabcbb6590555a28770d84d2ea944f0f9b0a6804..f4aa8897cb7a8d415f8193fc05a6d82984310ded 100644 (file)
@@ -53,8 +53,8 @@ extends BorderCommonStyleAbsolute {
 
     public int getCorrespondingRelativeProperty(FONode foNode)
     throws PropertyException {
-        return WritingMode.getCorrespondingRelativeEdge(
-                getWritingMode(foNode), WritingMode.BOTTOM);
+        return getCorrespondingRelativeStyleProperty(
+                foNode, WritingMode.BOTTOM);
     }
 
     public boolean correspondingOverrides(FONode foNode) {
index 3df1b619cedb58880ceb498492a62bbed67958e1..186bd8e89148db4e53936d9da70794297e5b189d 100644 (file)
@@ -23,13 +23,14 @@ package org.apache.fop.fo.properties;
 import java.util.HashMap;
 
 import org.apache.fop.datatypes.Ints;
+import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.expr.PropertyException;
 
 /**
  * Pseudo-property class for common border style values occurring in a
  * number of classes.
  */
-public class BorderCommonStyle extends Property  {
+public class BorderCommonStyle extends AbstractCorrespondingProperty  {
     public static final int HIDDEN = 1;
     public static final int DOTTED = 2;
     public static final int DASHED = 3;
@@ -78,5 +79,10 @@ public class BorderCommonStyle extends Property  {
         return rwEnums[index];
     }
 
+    public int getCorrespondingProperty(FONode foNode)
+    throws PropertyException {
+        throw new PropertyException("Called from superclass");
+    }
+
 }
 
index c92ba35cfebbd79792da1f159adfd9a5ca40dc1c..50683b76ad7e85d29bb0bc2aa8ef3d1aa6d1e73a 100644 (file)
@@ -43,6 +43,11 @@ implements AbsoluteCorrespondingProperty {
         PropertyValue wm = foNode.getPropertyValue(PropNames.WRITING_MODE);
         return EnumType.getEnumValue(wm);
     }
+
+    public int getCorrespondingProperty(FONode foNode)
+    throws PropertyException {
+        return getCorrespondingRelativeProperty(foNode);
+    }
     /* (non-Javadoc)
      * @see org.apache.fop.fo.properties.AbsoluteCorrespondingProperty#getCorrespondingRelativeProperty()
      */
@@ -50,10 +55,44 @@ implements AbsoluteCorrespondingProperty {
     throws PropertyException {
         throw new PropertyException("Called from superclass");
     }
+
+    /** Array of relative border style properties,
+     * indexed by relative edge constants */
+    private static int[] relBorderStyleProps = {
+            PropNames.NO_PROPERTY
+            ,PropNames.BORDER_BEFORE_STYLE
+            ,PropNames.BORDER_AFTER_STYLE
+            ,PropNames.BORDER_START_STYLE
+            ,PropNames.BORDER_END_STYLE
+    };
+
+    /**
+     * Gets the relative border style property corresponding to the given
+     * absolute edge
+     * @param foNode the node on which the property is being defined
+     * @param absoluteEdge
+     * @return the relative border style property index
+     * @throws PropertyException
+     */
+    protected int getCorrespondingRelativeStyleProperty(
+            FONode foNode, int absoluteEdge)
+    throws PropertyException {
+        int relEdge = WritingMode.getCorrespondingRelativeEdge(
+                getWritingMode(foNode), absoluteEdge);
+        return relBorderStyleProps[relEdge];
+    }
+
     /* (non-Javadoc)
      * @see org.apache.fop.fo.properties.AbsoluteCorrespondingProperty#overridesCorresponding()
      */
     public boolean overridesCorresponding(FONode foNode) {
         return false;
     }
+
+    /* (non-Javadoc)
+     * @see org.apache.fop.fo.properties.Property#isCorrespondingAbsolute()
+     */
+    public static boolean isCorrespondingAbsolute() {
+        return true;
+    }
 }
index 2d8f5bc400f3d2174a34120d60b6f69dfc2048a6..202f1820a9e837fe8bddf03d7c7ca34fb64ca996 100644 (file)
@@ -43,6 +43,11 @@ implements RelativeCorrespondingProperty {
         PropertyValue wm = foNode.getPropertyValue(PropNames.WRITING_MODE);
         return EnumType.getEnumValue(wm);
     }
+
+    public int getCorrespondingProperty(FONode foNode)
+    throws PropertyException {
+        return getCorrespondingAbsoluteProperty(foNode);
+    }
     /* (non-Javadoc)
      * @see org.apache.fop.fo.properties.RelativeCorrespondingProperty#getCorrespondingAbsoluteProperty(org.apache.fop.fo.FONode)
      */
@@ -50,10 +55,45 @@ implements RelativeCorrespondingProperty {
     throws PropertyException {
         throw new PropertyException("Called from superclass");
     }
+
+    /** Array of absolute border style properties,
+     * indexed by absolute edge constants */
+    private static int[] absBorderStyleProps = {
+            PropNames.NO_PROPERTY
+            ,PropNames.BORDER_TOP_STYLE
+            ,PropNames.BORDER_BOTTOM_STYLE
+            ,PropNames.BORDER_LEFT_STYLE
+            ,PropNames.BORDER_RIGHT_STYLE
+    };
+
+    /**
+     * Gets the absolute border style property corresponding to the given
+     * relative edge
+     * @param foNode the node on which the property is being defined
+     * @param relativeEdge
+     * @return the absolute border style property index
+     * @throws PropertyException
+     */
+    protected int getCorrespondingAbsoluteStyleProperty(
+            FONode foNode, int relativeEdge)
+    throws PropertyException {
+        int absEdge = WritingMode.getCorrespondingAbsoluteEdge(
+                getWritingMode(foNode), relativeEdge);
+        return absBorderStyleProps[absEdge];
+    }
+
     /* (non-Javadoc)
      * @see org.apache.fop.fo.properties.RelativeCorrespondingProperty#correspondingOverrides(org.apache.fop.fo.FONode)
      */
     public boolean correspondingOverrides(FONode foNode) {
         return false;
     }
+
+    /* (non-Javadoc)
+     * @see org.apache.fop.fo.properties.Property#isCorrespondingRelative()
+     */
+    public static boolean isCorrespondingRelative() {
+        return true;
+    }
+
 }
index 9df3115505066611196428105f9527eecb6ce093..8b226728b1e3cce4a1e2a26acf102a336d110201 100644 (file)
@@ -53,8 +53,8 @@ extends BorderCommonStyleRelative {
 
     public int getCorrespondingAbsoluteProperty(FONode foNode)
     throws PropertyException {
-        return WritingMode.getCorrespondingAbsoluteEdge(
-                getWritingMode(foNode), WritingMode.END);
+        return getCorrespondingAbsoluteStyleProperty(
+                foNode, WritingMode.END);
     }
 
     public boolean correspondingOverrides(FONode foNode) {
index 79df9f81ca89e26f87ff8f5614dd3fc777901cff..6b290ae1ce56a03aa21754005189e4db95f6085c 100644 (file)
@@ -53,8 +53,8 @@ extends BorderCommonStyleAbsolute {
 
     public int getCorrespondingRelativeProperty(FONode foNode)
     throws PropertyException {
-        return WritingMode.getCorrespondingRelativeEdge(
-                getWritingMode(foNode), WritingMode.LEFT);
+        return getCorrespondingRelativeStyleProperty(
+                foNode, WritingMode.LEFT);
     }
 
     public boolean correspondingOverrides(FONode foNode) {
index f1353831de42cae8f56fe9ecbbddb720d81eba4f..f18cb3bc55a7d40b8172314099d60b8e7e8d7ffa 100644 (file)
@@ -53,8 +53,8 @@ extends BorderCommonStyleAbsolute {
 
     public int getCorrespondingRelativeProperty(FONode foNode)
     throws PropertyException {
-        return WritingMode.getCorrespondingRelativeEdge(
-                getWritingMode(foNode), WritingMode.RIGHT);
+        return getCorrespondingRelativeStyleProperty(
+                foNode, WritingMode.RIGHT);
     }
 
     public boolean correspondingOverrides(FONode foNode) {
index aa3fd1971c8a5283ed6e817f432459da3a930e16..5f07a465fb7fa374da4df86b88fe5f09c9b44e85 100644 (file)
@@ -53,8 +53,8 @@ extends BorderCommonStyleRelative {
 
     public int getCorrespondingAbsoluteProperty(FONode foNode)
     throws PropertyException {
-        return WritingMode.getCorrespondingAbsoluteEdge(
-                getWritingMode(foNode), WritingMode.START);
+        return getCorrespondingAbsoluteStyleProperty(
+                foNode, WritingMode.START);
     }
 
     public boolean correspondingOverrides(FONode foNode) {
index ea68c1b066d271f97fb7737afd5cb5da2ebe17b2..60f33913ddc9ef74814385ff09c9c4b14f6300b3 100644 (file)
@@ -52,8 +52,8 @@ extends BorderCommonStyleAbsolute {
 
     public int getCorrespondingRelativeProperty(FONode foNode)
     throws PropertyException {
-        return WritingMode.getCorrespondingRelativeEdge(
-                getWritingMode(foNode), WritingMode.TOP);
+        return getCorrespondingRelativeStyleProperty(
+                foNode, WritingMode.TOP);
     }
 
     public boolean correspondingOverrides(FONode foNode) {
diff --git a/src/java/org/apache/fop/fo/properties/CorrespondingProperty.java b/src/java/org/apache/fop/fo/properties/CorrespondingProperty.java
new file mode 100644 (file)
index 0000000..e526098
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on 21/04/2004
+ * $Id$
+ */
+package org.apache.fop.fo.properties;
+
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.expr.PropertyException;
+
+/**
+ * Interface implemented by those <code>Property</code> classes which have
+ * corresponding properties.
+ * 
+ * @author pbw
+ * @version $Revision$ $Name$
+ */
+public interface CorrespondingProperty {
+    public int getWritingMode (FONode foNode)
+    throws PropertyException;
+    public int getCorrespondingProperty(FONode foNode)
+    throws PropertyException;
+}
index 8d370a516dcaf08c2b87658df6e4cb4446174479..12760a3a0d267e0d3ff57b1f1fe81d04bbfa1a17 100644 (file)
@@ -246,6 +246,24 @@ public class Property {
 
     public static Map enumHash = null;
 
+    /**
+     * Is this a corresponding absolute property?
+     * Such properties must override this method.
+     * @return answer
+     */
+    public static boolean isCorrespondingAbsolute() {
+        return false;
+    }
+
+    /**
+     * Is this a corresponding relative property?
+     * Such properties must override this method.
+     * @return answer
+     */
+    public static boolean isCorrespondingRelative() {
+        return false;
+    }
+
     public Property() {}
 
     /**
index a8353acfeecbb336b9577691207e3cfd9e133a36..b71ce994f36a43abb27fa55959db2088d0a9b03e 100644 (file)
@@ -30,9 +30,8 @@ import org.apache.fop.fo.expr.PropertyException;
  * @author pbw
  * @version $Revision$ $Name$
  */
-public interface RelativeCorrespondingProperty {
-    public int getWritingMode(FONode foNode)
-    throws PropertyException;
+public interface RelativeCorrespondingProperty
+extends CorrespondingProperty {
     public int getCorrespondingAbsoluteProperty(FONode foNode)
     throws PropertyException;
     public boolean correspondingOverrides(FONode foNode);