1 17 18 19 20 package org.apache.fop.fo.properties; 21 22 import org.apache.fop.datatypes.CompoundDatatype; 23 import org.apache.fop.fo.FObj; 24 import org.apache.fop.fo.PropertyList; 25 import org.apache.fop.fo.expr.PropertyException; 26 27 30 public class KeepProperty extends Property implements CompoundDatatype { 31 private Property withinLine; 32 private Property withinColumn; 33 private Property withinPage; 34 35 38 public static class Maker extends CompoundPropertyMaker { 39 40 43 public Maker(int propId) { 44 super(propId); 45 } 46 47 51 public Property makeNewProperty() { 52 return new KeepProperty(); 53 } 54 55 58 public Property convertProperty(Property p, PropertyList propertyList, FObj fo) 59 throws PropertyException 60 { 61 if (p instanceof KeepProperty) { 62 return p; 63 } 64 return super.convertProperty(p, propertyList, fo); 65 } 66 } 67 68 71 public void setComponent(int cmpId, Property cmpnValue, 72 boolean bIsDefault) { 73 if (cmpId == CP_WITHIN_LINE) { 74 setWithinLine(cmpnValue, bIsDefault); 75 } else if (cmpId == CP_WITHIN_COLUMN) { 76 setWithinColumn(cmpnValue, bIsDefault); 77 } else if (cmpId == CP_WITHIN_PAGE) { 78 setWithinPage(cmpnValue, bIsDefault); 79 } 80 } 81 82 85 public Property getComponent(int cmpId) { 86 if (cmpId == CP_WITHIN_LINE) { 87 return getWithinLine(); 88 } else if (cmpId == CP_WITHIN_COLUMN) { 89 return getWithinColumn(); 90 } else if (cmpId == CP_WITHIN_PAGE) { 91 return getWithinPage(); 92 } else { 93 return null; 94 } 95 } 96 97 101 public void setWithinLine(Property withinLine, boolean bIsDefault) { 102 this.withinLine = withinLine; 103 } 104 105 109 protected void setWithinColumn(Property withinColumn, 110 boolean bIsDefault) { 111 this.withinColumn = withinColumn; 112 } 113 114 118 public void setWithinPage(Property withinPage, boolean bIsDefault) { 119 this.withinPage = withinPage; 120 } 121 122 125 public Property getWithinLine() { 126 return this.withinLine; 127 } 128 129 132 public Property getWithinColumn() { 133 return this.withinColumn; 134 } 135 136 139 public Property getWithinPage() { 140 return this.withinPage; 141 } 142 143 147 public String toString() { 148 return "Keep[" + 149 "withinLine:" + getWithinLine().getObject() + 150 ", withinColumn:" + getWithinColumn().getObject() + 151 ", withinPage:" + getWithinPage().getObject() + "]"; 152 } 153 154 157 public KeepProperty getKeep() { 158 return this; 159 } 160 161 164 public Object getObject() { 165 return this; 166 } 167 168 } 169 | Popular Tags |