KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > layoutmgr > LayoutManager


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: LayoutManager.java 426576 2006-07-28 15:44:37Z jeremias $ */
19  
20 package org.apache.fop.layoutmgr;
21
22 import java.util.LinkedList JavaDoc;
23 import java.util.List JavaDoc;
24
25 import org.apache.fop.area.Area;
26 import org.apache.fop.datatypes.PercentBaseContext;
27 import org.apache.fop.fo.FObj;
28
29 /**
30  * The interface for all LayoutManagers.
31  */

32 public interface LayoutManager extends PercentBaseContext {
33
34     /**
35      * Set the parent layout manager.
36      * The parent layout manager is required for adding areas.
37      *
38      * @param lm the parent layout manager
39      */

40     void setParent(LayoutManager lm);
41
42     /**
43      * Get the parent layout manager.
44      * @return the parent layout manager.
45      */

46     LayoutManager getParent();
47
48     /**
49      * initialize the layout manager. Allows each layout manager
50      * to calculate often used values.
51      */

52     void initialize();
53     
54     /**
55      * Get the active PageSequenceLayoutManager instance for this
56      * layout process.
57      * @return the PageSequenceLayoutManager
58      */

59     PageSequenceLayoutManager getPSLM();
60
61     /**
62      * Reset to the position.
63      *
64      * @param position the Position to reset to
65      */

66     void resetPosition(Position position);
67
68     /**
69      * Return a value indicating whether this LayoutManager has laid out
70      * all its content (or generated BreakPossibilities for all content.)
71      *
72      * @return true if this layout manager is finished
73      */

74     boolean isFinished();
75
76     /**
77      * Set a flag indicating whether the LayoutManager has laid out all
78      * its content. This is generally called by the LM itself, but can
79      * be called by a parentLM when backtracking.
80      *
81      * @param isFinished the value to set the finished flag to
82      */

83     void setFinished(boolean isFinished);
84
85     /**
86      * Get the parent area for an area.
87      * This should get the parent depending on the class of the
88      * area passed in.
89      *
90      * @param childArea the child area to get the parent for
91      * @return the parent Area
92      */

93     Area getParentArea(Area childArea);
94
95     /**
96      * Add the area as a child of the current area.
97      * This is called by child layout managers to add their
98      * areas as children of the current area.
99      *
100      * @param childArea the child area to add
101      */

102     void addChildArea(Area childArea);
103
104     /**
105      * Tell the layout manager to add all the child areas implied
106      * by Position objects which will be returned by the
107      * Iterator.
108      *
109      * @param posIter the position iterator
110      * @param context the context
111      */

112     void addAreas(PositionIterator posIter, LayoutContext context);
113
114     /**
115      * Create more child LMs of the parent, up to child LM index pos
116      * @param pos index up to which child LMs are requested
117      * @return true if requested index does exist
118      */

119     boolean createNextChildLMs(int pos);
120
121     /**
122      * @return the list of child LMs
123      */

124     List JavaDoc getChildLMs();
125
126     /**
127      * Add the LM in the argument to the list of child LMs;
128      * set this LM as the parent;
129      * initialize the LM.
130      * @param lm the LM to be added
131      */

132     void addChildLM(LayoutManager lm);
133
134     /**
135      * Add the LMs in the argument to the list of child LMs;
136      * @param newLMs the list of LMs to be added
137      */

138     void addChildLMs(List JavaDoc newLMs);
139
140     /**
141      * Get a sequence of KnuthElements representing the content
142      * of the node assigned to the LM
143      *
144      * @param context the LayoutContext used to store layout information
145      * @param alignment the desired text alignement
146      * @return the list of KnuthElements
147      */

148     LinkedList JavaDoc getNextKnuthElements(LayoutContext context, int alignment);
149
150     /**
151      * Get a sequence of KnuthElements representing the content
152      * of the node assigned to the LM, after changes have been applied
153      *
154      * In the context of line breaking, this method is called after hyphenation has
155      * been performed, in order to receive the sequence of elements representing the
156      * text together with all possibile hyphenation points.
157      * For example, if the text "representation" originates a single box element
158      * when getNextKnuthElements() is called, it will be now split in syllables
159      * (rep-re-sen-ta-tion) each one originating a box and divided by additional
160      * elements allowing a line break.
161      *
162      * In the context of page breaking, this method is called only if the pages need
163      * to be "vertically justified" modifying (also) the quantity of lines created by
164      * the paragraphs, and after a first page breaking has been performed.
165      * According to the result of the first page breaking, each paragraph now knows
166      * how many lines it must create (among the existing layout possibilities) and
167      * has to create a sequence of elements representing this layout; in particular,
168      * each box, representing a line, will contain a LineBreakPositions that will be
169      * used in the addAreas() phase.
170      *
171      * LMs having children look at the old list of elements in order to know which
172      * ones they must get the new elements from, as break conditions of preserved
173      * linefeeds can divide children into smaller groups (page sequences or
174      * paragraphs).
175      * LMs having no children can simply return the old elements if they have nothing
176      * to change.
177      *
178      * Inline LMs need to know the text alignment because it affects the elements
179      * representing feasible breaks between syllables.
180      *
181      * @param oldList the elements to replace
182      * @param alignment the desired text alignment
183      * @return the updated list of KnuthElements
184      */

185     LinkedList JavaDoc getChangedKnuthElements(List JavaDoc oldList, int alignment);
186     
187     /**
188      * Returns the IPD of the content area
189      * @return the IPD of the content area
190      */

191     int getContentAreaIPD();
192    
193     /**
194      * Returns the BPD of the content area
195      * @return the BPD of the content area
196      */

197     int getContentAreaBPD();
198    
199     /**
200      * Returns an indication if the layout manager generates a reference area.
201      * @return True if the layout manager generates a reference area
202      */

203     boolean getGeneratesReferenceArea();
204
205     /**
206      * Returns an indication if the layout manager generates a block area.
207      * @return True if the layout manager generates a block area
208      */

209     boolean getGeneratesBlockArea();
210
211     /**
212      * Returns an indication if the layout manager generates a line area.
213      * @return True if the layout manager generates a line area
214      */

215     boolean getGeneratesLineArea();
216     
217     /**
218      * Returns the fo this layout manager is associated with.
219      * @return The fo for this layout manager or null.
220      */

221     FObj getFObj();
222     
223     /**
224      * Adds a Position to the Position participating in the first|last determination by assigning
225      * it a unique position index.
226      * @param pos the Position
227      * @return the same Position but with a position index
228      */

229     Position notifyPos(Position pos);
230 }
231
Popular Tags