38 |
|
|
39 |
package javax.swing.text; |
package javax.swing.text; |
40 |
|
|
41 |
|
import java.awt.Shape; |
42 |
|
|
43 |
|
import javax.swing.event.DocumentEvent; |
44 |
|
|
45 |
/** |
/** |
46 |
* A {@link FlowView} that flows it's children horizontally and boxes the rows |
* A {@link FlowView} that flows it's children horizontally and boxes the rows |
47 |
* vertically. |
* vertically. |
71 |
} |
} |
72 |
|
|
73 |
/** |
/** |
74 |
|
* The indentation of the first line of the paragraph. |
75 |
|
*/ |
76 |
|
protected int firstLineIndent; |
77 |
|
|
78 |
|
/** |
79 |
|
* The justification of the paragraph. |
80 |
|
*/ |
81 |
|
private int justification; |
82 |
|
|
83 |
|
/** |
84 |
|
* The line spacing of this paragraph. |
85 |
|
*/ |
86 |
|
private float lineSpacing; |
87 |
|
|
88 |
|
/** |
89 |
|
* The TabSet of this paragraph. |
90 |
|
*/ |
91 |
|
private TabSet tabSet; |
92 |
|
|
93 |
|
/** |
94 |
* Creates a new <code>ParagraphView</code> for the given |
* Creates a new <code>ParagraphView</code> for the given |
95 |
* <code>Element</code>. |
* <code>Element</code>. |
96 |
* |
* |
140 |
else |
else |
141 |
return 0.0F; |
return 0.0F; |
142 |
} |
} |
143 |
|
|
144 |
|
/** |
145 |
|
* Receives notification when some attributes of the displayed element |
146 |
|
* changes. This triggers a refresh of the cached attributes of this |
147 |
|
* paragraph. |
148 |
|
* |
149 |
|
* @param ev the document event |
150 |
|
* @param a the allocation of this view |
151 |
|
* @param fv the view factory to use for creating new child views |
152 |
|
*/ |
153 |
|
public void changedUpdate(DocumentEvent ev, Shape a, ViewFactory fv) |
154 |
|
{ |
155 |
|
setPropertiesFromAttributes(); |
156 |
|
} |
157 |
|
|
158 |
|
/** |
159 |
|
* Fetches the cached properties from the element's attributes. |
160 |
|
*/ |
161 |
|
protected void setPropertiesFromAttributes() |
162 |
|
{ |
163 |
|
Element el = getElement(); |
164 |
|
AttributeSet atts = el.getAttributes(); |
165 |
|
setFirstLineIndent(StyleConstants.getFirstLineIndent(atts)); |
166 |
|
setLineSpacing(StyleConstants.getLineSpacing(atts)); |
167 |
|
setJustification(StyleConstants.getAlignment(atts)); |
168 |
|
tabSet = StyleConstants.getTabSet(atts); |
169 |
|
} |
170 |
|
|
171 |
|
/** |
172 |
|
* Sets the indentation of the first line of the paragraph. |
173 |
|
* |
174 |
|
* @param i the indentation to set |
175 |
|
*/ |
176 |
|
protected void setFirstLineIndent(float i) |
177 |
|
{ |
178 |
|
firstLineIndent = (int) i; |
179 |
|
} |
180 |
|
|
181 |
|
/** |
182 |
|
* Sets the justification of the paragraph. |
183 |
|
* |
184 |
|
* @param j the justification to set |
185 |
|
*/ |
186 |
|
protected void setJustification(int j) |
187 |
|
{ |
188 |
|
justification = j; |
189 |
|
} |
190 |
|
|
191 |
|
/** |
192 |
|
* Sets the line spacing for this paragraph. |
193 |
|
* |
194 |
|
* @param s the line spacing to set |
195 |
|
*/ |
196 |
|
protected void setLineSpacing(float s) |
197 |
|
{ |
198 |
|
lineSpacing = s; |
199 |
|
} |
200 |
|
|
201 |
|
/** |
202 |
|
* Returns the i-th view from the logical views, before breaking into rows. |
203 |
|
* |
204 |
|
* @param i the index of the logical view to return |
205 |
|
* |
206 |
|
* @return the i-th view from the logical views, before breaking into rows |
207 |
|
*/ |
208 |
|
protected View getLayoutView(int i) |
209 |
|
{ |
210 |
|
return layoutPool.getView(i); |
211 |
|
} |
212 |
|
|
213 |
|
/** |
214 |
|
* Returns the number of logical child views. |
215 |
|
* |
216 |
|
* @return the number of logical child views |
217 |
|
*/ |
218 |
|
protected int getLayoutViewCount() |
219 |
|
{ |
220 |
|
return layoutPool.getViewCount(); |
221 |
|
} |
222 |
|
|
223 |
|
/** |
224 |
|
* Returns the TabSet used by this ParagraphView. |
225 |
|
* |
226 |
|
* @return the TabSet used by this ParagraphView |
227 |
|
*/ |
228 |
|
protected TabSet getTabSet() |
229 |
|
{ |
230 |
|
return tabSet; |
231 |
|
} |
232 |
} |
} |