KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > area > RegionReference


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id: RegionReference.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.area;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.List JavaDoc;
24
25 import org.apache.fop.fo.pagination.Region;
26
27 /**
28  * This is a region reference area for a page regions.
29  * This area is the direct child of a region-viewport-area. It is cloneable
30  * so the page master can make copies from the original page and regions.
31  */

32 public class RegionReference extends Area implements Cloneable JavaDoc {
33     
34     /** Reference to the region FO. */
35     //protected Region regionFO;
36
private int regionClass;
37     private String JavaDoc regionName;
38     private CTM ctm;
39     
40
41     // the list of block areas from the static flow
42
private ArrayList JavaDoc blocks = new ArrayList JavaDoc();
43     
44     /** the parent RegionViewport for this object */
45     protected RegionViewport regionViewport;
46
47     /**
48      * Create a new region reference area.
49      *
50      * @param regionFO the region.
51      * @param parent the viewport for this region.
52      */

53     public RegionReference(Region regionFO, RegionViewport parent) {
54         this(regionFO.getNameId(), regionFO.getRegionName(), parent);
55     }
56
57     /**
58      * Create a new region reference area.
59      *
60      * @param regionClass the region class (as returned by Region.getNameId())
61      * @param regionName the name of the region (as returned by Region.getRegionName())
62      * @param parent the viewport for this region.
63      */

64     public RegionReference(int regionClass, String JavaDoc regionName, RegionViewport parent) {
65         this.regionClass = regionClass;
66         this.regionName = regionName;
67         addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
68         regionViewport = parent;
69     }
70
71     /** @see org.apache.fop.area.Area#addChildArea(org.apache.fop.area.Area) */
72     public void addChildArea(Area child) {
73         blocks.add(child);
74     }
75
76     /**
77      * Set the Coordinate Transformation Matrix which transforms content
78      * coordinates in this region reference area which are specified in
79      * terms of "start" and "before" into coordinates in a system which
80      * is positioned in "absolute" directions (with origin at lower left of
81      * the region reference area.
82      *
83      * @param ctm the current transform to position this region
84      */

85     public void setCTM(CTM ctm) {
86         this.ctm = ctm;
87     }
88     
89     /**
90      * @return Returns the parent RegionViewport.
91      */

92     public RegionViewport getRegionViewport() {
93         return regionViewport;
94     }
95
96     /**
97      * Get the current transform of this region.
98      *
99      * @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 JavaDoc 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 JavaDoc 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 JavaDoc clone() {
144         RegionReference rr = new RegionReference(regionClass, regionName, regionViewport);
145         rr.ctm = ctm;
146         rr.setIPD(getIPD());
147         rr.blocks = (ArrayList JavaDoc)blocks.clone();
148         return rr;
149     }
150
151 }
152
Popular Tags