1 17 18 19 20 package org.apache.fop.fo.properties; 21 22 import org.apache.fop.datatypes.CompoundDatatype; 23 import org.apache.fop.datatypes.Length; 24 import org.apache.fop.datatypes.PercentBaseContext; 25 import org.apache.fop.fo.Constants; 26 import org.apache.fop.fo.FObj; 27 import org.apache.fop.fo.PropertyList; 28 import org.apache.fop.fo.expr.PropertyException; 29 30 33 public class CondLengthProperty extends Property implements CompoundDatatype { 34 private Property length; 35 private Property conditionality; 36 37 40 public static class Maker extends CompoundPropertyMaker { 41 42 45 public Maker(int propId) { 46 super(propId); 47 } 48 49 53 public Property makeNewProperty() { 54 return new CondLengthProperty(); 55 } 56 57 60 public Property convertProperty(Property p, PropertyList propertyList, FObj fo) 61 throws PropertyException { 62 if (p instanceof KeepProperty) { 63 return p; 64 } 65 return super.convertProperty(p, propertyList, fo); 66 } 67 } 68 69 72 public void setComponent(int cmpId, Property cmpnValue, 73 boolean bIsDefault) { 74 if (cmpId == CP_LENGTH) { 75 length = cmpnValue; 76 } else if (cmpId == CP_CONDITIONALITY) { 77 conditionality = cmpnValue; 78 } 79 } 80 81 84 public Property getComponent(int cmpId) { 85 if (cmpId == CP_LENGTH) { 86 return length; 87 } else if (cmpId == CP_CONDITIONALITY) { 88 return conditionality; 89 } else { 90 return null; 91 } 92 } 93 94 98 public Property getConditionality() { 99 return this.conditionality; 100 } 101 102 106 public Property getLengthComponent() { 107 return this.length; 108 } 109 110 114 public boolean isDiscard() { 115 return this.conditionality.getEnum() == Constants.EN_DISCARD; 116 } 117 118 122 public int getLengthValue() { 123 return this.length.getLength().getValue(); 124 } 125 126 131 public int getLengthValue(PercentBaseContext context) { 132 return this.length.getLength().getValue(context); 133 } 134 135 136 public String toString() { 137 return "CondLength[" + length.getObject().toString() 138 + ", " + (isDiscard() 139 ? conditionality.toString().toLowerCase() 140 : conditionality.toString()) + "]"; 141 } 142 143 146 public CondLengthProperty getCondLength() { 147 return this; 148 } 149 150 154 public Length getLength() { 155 return length.getLength(); 156 } 157 158 161 public Object getObject() { 162 return this; 163 } 164 165 } 166 | Popular Tags |