Lines 25-31
Link Here
|
25 |
/** |
25 |
/** |
26 |
* Utility class for FlowFigures. |
26 |
* Utility class for FlowFigures. |
27 |
* @author hudsonr |
27 |
* @author hudsonr |
28 |
* @since 2.1 |
28 |
* @since 3.4 |
29 |
*/ |
29 |
*/ |
30 |
public class FlowUtilities |
30 |
public class FlowUtilities |
31 |
{ |
31 |
{ |
Lines 155-172
Link Here
|
155 |
return getTextUtilities().getStringExtents(string.substring(0, guess), font).width; |
155 |
return getTextUtilities().getStringExtents(string.substring(0, guess), font).width; |
156 |
} |
156 |
} |
157 |
|
157 |
|
158 |
protected void setupFragment(TextFragmentBox frag, Font f, String s) { |
158 |
/** |
159 |
if (frag.getWidth() == -1 || frag.isTruncated()) { |
159 |
* Sets up the fragment width based using the font and string passed in. |
|
|
160 |
* |
161 |
* @param fragment |
162 |
* the text fragment whose width will be set |
163 |
* @param font |
164 |
* the font to be used in the calculation |
165 |
* @param string |
166 |
* the string to be used in the calculation |
167 |
*/ |
168 |
final protected void setupFragment(TextFragmentBox fragment, Font font, String string) { |
169 |
if (fragment.getWidth() == -1 || fragment.isTruncated()) { |
160 |
int width; |
170 |
int width; |
161 |
if (s.length() == 0 || frag.length == 0) |
171 |
if (string.length() == 0 || fragment.length == 0) |
162 |
width = 0; |
172 |
width = 0; |
163 |
else if (frag.requiresBidi()) { |
173 |
else if (fragment.requiresBidi()) { |
164 |
width = getTextLayoutBounds(s, f, 0, frag.length - 1).width; |
174 |
width = getTextLayoutBounds(string, font, 0, fragment.length - 1).width; |
165 |
} else |
175 |
} else |
166 |
width = getTextUtilities().getStringExtents(s.substring(0, frag.length), f).width; |
176 |
width = getTextUtilities().getStringExtents(string.substring(0, fragment.length), font).width; |
167 |
if (frag.isTruncated()) |
177 |
if (fragment.isTruncated()) |
168 |
width += getEllipsisWidth(f); |
178 |
width += getEllipsisWidth(font); |
169 |
frag.setWidth(width); |
179 |
fragment.setWidth(width); |
170 |
} |
180 |
} |
171 |
} |
181 |
} |
172 |
|
182 |
|
Lines 183-189
Link Here
|
183 |
* @return the number of characters that will fit in the given space; can be 0 (eg., when |
193 |
* @return the number of characters that will fit in the given space; can be 0 (eg., when |
184 |
* the first character of the given string is a newline) |
194 |
* the first character of the given string is a newline) |
185 |
*/ |
195 |
*/ |
186 |
protected int wrapFragmentInContext(TextFragmentBox frag, String string, |
196 |
final protected int wrapFragmentInContext(TextFragmentBox frag, String string, |
187 |
FlowContext context, LookAhead lookahead, Font font, int wrapping) { |
197 |
FlowContext context, LookAhead lookahead, Font font, int wrapping) { |
188 |
frag.setTruncated(false); |
198 |
frag.setTruncated(false); |
189 |
int strLen = string.length(); |
199 |
int strLen = string.length(); |