001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /* $Id: BlockParent.java 426576 2006-07-28 15:44:37Z jeremias $ */
019:
020: package org.apache.fop.area;
021:
022: import java.util.ArrayList;
023: import java.util.List;
024:
025: /**
026: * A BlockParent holds block-level areas.
027: */
028: public class BlockParent extends Area {
029:
030: // this position is used for absolute position
031: // or as an indent
032: // this has the size in the block progression dimension
033:
034: /**
035: * The x offset position of this block parent.
036: * Used for relative (serves as left-offset trait) and absolute positioning
037: * (serves as left-position trait).
038: */
039: protected int xOffset = 0;
040:
041: /**
042: * The y offset position of this block parent.
043: * Used for relative (serves as top-offset trait) and absolute positioning
044: * (serves as top-position trait).
045: */
046: protected int yOffset = 0;
047:
048: /**
049: * The children of this block parent area.
050: */
051: protected List children = null;
052:
053: // orientation if reference area
054: private int orientation = ORIENT_0;
055:
056: /** @see org.apache.fop.area.Area#addChildArea(org.apache.fop.area.Area) */
057: public void addChildArea(Area childArea) {
058: if (children == null) {
059: children = new ArrayList();
060: }
061: children.add(childArea);
062: }
063:
064: /**
065: * Add the block area to this block parent.
066: *
067: * @param block the child block area to add
068: */
069: public void addBlock(Block block) {
070: addChildArea(block);
071: }
072:
073: /**
074: * Get the list of child areas for this block area.
075: *
076: * @return the list of child areas
077: */
078: public List getChildAreas() {
079: return children;
080: }
081:
082: /**
083: * Check whether there are child areas.
084: *
085: * @return the result.
086: */
087: public boolean isEmpty() {
088: return children == null || children.size() == 0;
089: }
090:
091: /**
092: * Set the X offset of this block parent area.
093: *
094: * @param off the x offset of the block parent area
095: */
096: public void setXOffset(int off) {
097: xOffset = off;
098: }
099:
100: /**
101: * Set the Y offset of this block parent area.
102: *
103: * @param off the y offset of the block parent area
104: */
105: public void setYOffset(int off) {
106: yOffset = off;
107: }
108:
109: /**
110: * Get the X offset of this block parent area.
111: *
112: * @return the x offset of the block parent area
113: */
114: public int getXOffset() {
115: return xOffset;
116: }
117:
118: /**
119: * Get the Y offset of this block parent area.
120: *
121: * @return the y offset of the block parent area
122: */
123: public int getYOffset() {
124: return yOffset;
125: }
126: }
|