1 51 package org.apache.fop.fo; 52 53 import org.apache.fop.apps.FOPException; 55 import org.apache.fop.layout.Area; 56 import org.apache.fop.layout.AreaClass; 57 import org.apache.fop.layout.LinkSet; 58 59 import org.apache.avalon.framework.logger.Logger; 61 62 import java.util.ArrayList ; 64 65 75 public abstract class FONode { 76 77 protected FObj parent; 78 79 protected String areaClass = AreaClass.UNASSIGNED; 80 81 protected ArrayList children = new ArrayList (); 83 86 public static final int START = -1000; 87 88 91 public static final int BREAK_AFTER = -1001; 92 93 98 protected int marker = START; 99 100 protected boolean isInTableCell = false; 101 102 protected int forcedStartOffset = 0; 103 protected int forcedWidth = 0; 104 105 protected LinkSet linkSet; 106 107 public int areasGenerated = 0; 109 110 protected Logger log; 111 112 protected FONode(FObj parent) { 113 this.parent = parent; 114 115 if (parent != null) { 116 this.areaClass = parent.areaClass; 117 log = parent.log; 118 } 119 } 120 121 public void setLogger(Logger logger) { 122 log = logger; 123 } 124 125 public void setIsInTableCell() { 126 this.isInTableCell = true; 127 for (int i = 0; i < this.children.size(); i++) { 129 FONode child = (FONode)this.children.get(i); 130 child.setIsInTableCell(); 131 } 132 } 133 134 public void forceStartOffset(int offset) { 135 this.forcedStartOffset = offset; 136 for (int i = 0; i < this.children.size(); i++) { 138 FONode child = (FONode)this.children.get(i); 139 child.forceStartOffset(offset); 140 } 141 } 142 143 public void forceWidth(int width) { 144 this.forcedWidth = width; 145 for (int i = 0; i < this.children.size(); i++) { 147 FONode child = (FONode)this.children.get(i); 148 child.forceWidth(width); 149 } 150 } 151 152 public void resetMarker() { 153 this.marker = START; 154 this.areasGenerated=0; 155 int numChildren = this.children.size(); 156 for (int i = 0; i < numChildren; i++) { 157 ((FONode)children.get(i)).resetMarker(); 158 } 159 } 160 161 public void removeAreas() { 162 } 164 165 166 protected void addChild(FONode child) { 167 children.add(child); 168 } 169 170 public FObj getParent() { 171 return this.parent; 172 } 173 174 public void setLinkSet(LinkSet linkSet) { 175 this.linkSet = linkSet; 176 for (int i = 0; i < this.children.size(); i++) { 177 FONode child = (FONode)this.children.get(i); 178 child.setLinkSet(linkSet); 179 } 180 } 181 182 public LinkSet getLinkSet() { 183 return this.linkSet; 184 } 185 186 public abstract int layout(Area area) throws FOPException; 187 188 195 public Property getProperty(String name) { 196 return (null); 197 } 198 199 206 public ArrayList getMarkerSnapshot(ArrayList snapshot) { 207 snapshot.add(new Integer (this.marker)); 208 209 if (this.marker < 0) 211 return snapshot; 212 else if (children.isEmpty()) 213 return snapshot; 214 else 215 return ((FONode)children.get(this.marker)).getMarkerSnapshot(snapshot); 216 } 217 218 224 public void rollback(ArrayList snapshot) { 225 this.marker = ((Integer )snapshot.get(0)).intValue(); 226 snapshot.remove(0); 227 228 if (this.marker == START) { 229 resetMarker(); 231 return; 232 } else if ((this.marker == -1) || children.isEmpty()) 233 return; 234 235 int numChildren = this.children.size(); 236 237 if (this.marker <= START) { 238 return; 239 } 240 241 for (int i = this.marker + 1; i < numChildren; i++) { 242 FONode fo = (FONode)children.get(i); 243 fo.resetMarker(); 244 } 245 ((FONode)children.get(this.marker)).rollback(snapshot); 246 } 247 248 249 public boolean mayPrecedeMarker() { 250 return false; 251 } 252 253 } 254 | Popular Tags |