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: RegionReference.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: import org.apache.fop.fo.pagination.Region;
026:
027: /**
028: * This is a region reference area for a page regions.
029: * This area is the direct child of a region-viewport-area. It is cloneable
030: * so the page master can make copies from the original page and regions.
031: */
032: public class RegionReference extends Area implements Cloneable {
033:
034: /** Reference to the region FO. */
035: //protected Region regionFO;
036: private int regionClass;
037: private String regionName;
038: private CTM ctm;
039:
040: // the list of block areas from the static flow
041: private ArrayList blocks = new ArrayList();
042:
043: /** the parent RegionViewport for this object */
044: protected RegionViewport regionViewport;
045:
046: /**
047: * Create a new region reference area.
048: *
049: * @param regionFO the region.
050: * @param parent the viewport for this region.
051: */
052: public RegionReference(Region regionFO, RegionViewport parent) {
053: this (regionFO.getNameId(), regionFO.getRegionName(), parent);
054: }
055:
056: /**
057: * Create a new region reference area.
058: *
059: * @param regionClass the region class (as returned by Region.getNameId())
060: * @param regionName the name of the region (as returned by Region.getRegionName())
061: * @param parent the viewport for this region.
062: */
063: public RegionReference(int regionClass, String regionName,
064: RegionViewport parent) {
065: this .regionClass = regionClass;
066: this .regionName = regionName;
067: addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
068: regionViewport = parent;
069: }
070:
071: /** @see org.apache.fop.area.Area#addChildArea(org.apache.fop.area.Area) */
072: public void addChildArea(Area child) {
073: blocks.add(child);
074: }
075:
076: /**
077: * Set the Coordinate Transformation Matrix which transforms content
078: * coordinates in this region reference area which are specified in
079: * terms of "start" and "before" into coordinates in a system which
080: * is positioned in "absolute" directions (with origin at lower left of
081: * the region reference area.
082: *
083: * @param ctm the current transform to position this region
084: */
085: public void setCTM(CTM ctm) {
086: this .ctm = ctm;
087: }
088:
089: /**
090: * @return Returns the parent RegionViewport.
091: */
092: public RegionViewport getRegionViewport() {
093: return regionViewport;
094: }
095:
096: /**
097: * Get the current transform of this region.
098: *
099: * @return ctm the current transform to position this region
100: */
101: public CTM getCTM() {
102: return this .ctm;
103: }
104:
105: /**
106: * Get the block in this region.
107: *
108: * @return the list of blocks in this region
109: */
110: public List getBlocks() {
111: return blocks;
112: }
113:
114: /**
115: * Get the region class of this region.
116: *
117: * @return the region class
118: */
119: public int getRegionClass() {
120: return this .regionClass;
121: }
122:
123: /** @return the region name */
124: public String getRegionName() {
125: return this .regionName;
126: }
127:
128: /**
129: * Add a block area to this region reference area.
130: *
131: * @param block the block area to add
132: */
133: public void addBlock(Block block) {
134: addChildArea(block);
135: }
136:
137: /**
138: * Clone this region.
139: * This is used when cloning the page by the page master.
140: *
141: * @return a copy of this region reference area
142: */
143: public Object clone() {
144: RegionReference rr = new RegionReference(regionClass,
145: regionName, regionViewport);
146: rr.ctm = ctm;
147: rr.setIPD(getIPD());
148: rr.blocks = (ArrayList) blocks.clone();
149: return rr;
150: }
151:
152: }
|