git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197526 13f79535-47bb-0310-9956-ffa450edef68tags/Defoe_export
@@ -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); |
@@ -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; | |||
} |
@@ -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) { |
@@ -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) { |
@@ -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) { |
@@ -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"); | |||
} | |||
} | |||
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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) { |
@@ -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) { |
@@ -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) { |
@@ -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) { |
@@ -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) { |
@@ -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; | |||
} |
@@ -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() {} | |||
/** |
@@ -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); |