1 17 18 19 20 package org.apache.fop.fo.properties; 21 22 import org.apache.fop.fo.Constants; 23 import org.apache.fop.fo.FObj; 24 import org.apache.fop.fo.PropertyList; 25 import org.apache.fop.fo.expr.PropertyException; 26 27 32 public class SpaceProperty extends LengthRangeProperty { 33 private Property precedence; 34 private Property conditionality; 35 36 39 public static class Maker extends CompoundPropertyMaker { 40 41 44 public Maker(int propId) { 45 super(propId); 46 } 47 48 52 public Property makeNewProperty() { 53 return new SpaceProperty(); 54 } 55 56 59 public Property convertProperty(Property p, 60 PropertyList propertyList, 61 FObj fo) throws PropertyException { 62 if (p instanceof SpaceProperty) { 63 return p; 64 } 65 return super.convertProperty(p, propertyList, fo); 66 } 67 } 68 69 70 71 74 public void setComponent(int cmpId, Property cmpnValue, 75 boolean bIsDefault) { 76 if (cmpId == CP_PRECEDENCE) { 77 setPrecedence(cmpnValue, bIsDefault); 78 } else if (cmpId == CP_CONDITIONALITY) { 79 setConditionality(cmpnValue, bIsDefault); 80 } else { 81 super.setComponent(cmpId, cmpnValue, bIsDefault); 82 } 83 } 84 85 88 public Property getComponent(int cmpId) { 89 if (cmpId == CP_PRECEDENCE) { 90 return getPrecedence(); 91 } else if (cmpId == CP_CONDITIONALITY) { 92 return getConditionality(); 93 } else { 94 return super.getComponent(cmpId); 95 } 96 } 97 98 103 protected void setPrecedence(Property precedence, boolean bIsDefault) { 104 this.precedence = precedence; 105 } 106 107 112 protected void setConditionality(Property conditionality, 113 boolean bIsDefault) { 114 this.conditionality = conditionality; 115 } 116 117 120 public Property getPrecedence() { 121 return this.precedence; 122 } 123 124 127 public Property getConditionality() { 128 return this.conditionality; 129 } 130 131 135 public boolean isDiscard() { 136 return this.conditionality.getEnum() == Constants.EN_DISCARD; 137 } 138 139 public String toString() { 140 return "Space[" + 141 "min:" + getMinimum(null).getObject() + 142 ", max:" + getMaximum(null).getObject() + 143 ", opt:" + getOptimum(null).getObject() + 144 ", precedence:" + precedence.getObject() + 145 ", conditionality:" + conditionality.getObject() + "]"; 146 } 147 148 151 public SpaceProperty getSpace() { 152 return this; 153 } 154 155 159 public LengthRangeProperty getLengthRange() { 160 return this; 161 } 162 163 166 public Object getObject() { 167 return this; 168 } 169 170 } 171 | Popular Tags |