* @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);
--- /dev/null
+/*
+ *
+ * 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;
+}
public int getCorrespondingAbsoluteProperty(FONode foNode)
throws PropertyException {
- return WritingMode.getCorrespondingAbsoluteEdge(
- getWritingMode(foNode), WritingMode.AFTER);
+ return getCorrespondingAbsoluteStyleProperty(
+ foNode, WritingMode.AFTER);
}
public boolean correspondingOverrides(FONode foNode) {
public int getCorrespondingAbsoluteProperty(FONode foNode)
throws PropertyException {
- return WritingMode.getCorrespondingAbsoluteEdge(
- getWritingMode(foNode), WritingMode.BEFORE);
+ return getCorrespondingAbsoluteStyleProperty(
+ foNode, WritingMode.BEFORE);
}
public boolean correspondingOverrides(FONode foNode) {
public int getCorrespondingRelativeProperty(FONode foNode)
throws PropertyException {
- return WritingMode.getCorrespondingRelativeEdge(
- getWritingMode(foNode), WritingMode.BOTTOM);
+ return getCorrespondingRelativeStyleProperty(
+ foNode, WritingMode.BOTTOM);
}
public boolean correspondingOverrides(FONode foNode) {
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;
return rwEnums[index];
}
+ public int getCorrespondingProperty(FONode foNode)
+ throws PropertyException {
+ throw new PropertyException("Called from superclass");
+ }
+
}
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()
*/
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;
+ }
}
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)
*/
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;
+ }
+
}
public int getCorrespondingAbsoluteProperty(FONode foNode)
throws PropertyException {
- return WritingMode.getCorrespondingAbsoluteEdge(
- getWritingMode(foNode), WritingMode.END);
+ return getCorrespondingAbsoluteStyleProperty(
+ foNode, WritingMode.END);
}
public boolean correspondingOverrides(FONode foNode) {
public int getCorrespondingRelativeProperty(FONode foNode)
throws PropertyException {
- return WritingMode.getCorrespondingRelativeEdge(
- getWritingMode(foNode), WritingMode.LEFT);
+ return getCorrespondingRelativeStyleProperty(
+ foNode, WritingMode.LEFT);
}
public boolean correspondingOverrides(FONode foNode) {
public int getCorrespondingRelativeProperty(FONode foNode)
throws PropertyException {
- return WritingMode.getCorrespondingRelativeEdge(
- getWritingMode(foNode), WritingMode.RIGHT);
+ return getCorrespondingRelativeStyleProperty(
+ foNode, WritingMode.RIGHT);
}
public boolean correspondingOverrides(FONode foNode) {
public int getCorrespondingAbsoluteProperty(FONode foNode)
throws PropertyException {
- return WritingMode.getCorrespondingAbsoluteEdge(
- getWritingMode(foNode), WritingMode.START);
+ return getCorrespondingAbsoluteStyleProperty(
+ foNode, WritingMode.START);
}
public boolean correspondingOverrides(FONode foNode) {
public int getCorrespondingRelativeProperty(FONode foNode)
throws PropertyException {
- return WritingMode.getCorrespondingRelativeEdge(
- getWritingMode(foNode), WritingMode.TOP);
+ return getCorrespondingRelativeStyleProperty(
+ foNode, WritingMode.TOP);
}
public boolean correspondingOverrides(FONode foNode) {
--- /dev/null
+/*
+ *
+ * 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;
+}
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() {}
/**
* @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);