Re: JTextPane: Workaround for invisible text with hanging indents?
- From: usenet@xxxxxxx (Christian Kaufhold)
- Date: Sun, 28 Aug 2005 13:00:22 +0200
Hello!
Christian Kaufhold <usenet@xxxxxxx> wrote:
> private float poolPreferredXSpan()
[...]
> private float poolMinimumXSpan()
[...]
I forgot to actually take the indent into account here. But at least
"poolMinimumXSpan" is not anywhere near working anyway (It always is just
the indent of the first line) -- there is no feature in View to find the
actual minimum width if all possible break points are chosen. Also see
javax.swing.text.html for a hack.
Anyway, some better readable, more correct implementations.
public float poolPreferredXSpan()
{
float result = 0;
float lineSpan = firstLineIndent;
for (int n = layoutPool.getViewCount(), i = 0; i < n; i++)
{
View v = layoutPool.getView(i);
lineSpan += v.getPreferredSpan(X_AXIS);
if (v.getBreakWeight(X_AXIS, 0, Integer.MAX_VALUE) >= ForcedBreakWeight)
{
result = Math.max(result, lineSpan);
lineSpan = otherLinesIndent;
}
}
result = Math.max(result, lineSpan);
return result;
}
public float poolMinimumXSpan()
{
float result = 0;
boolean lineHasView = false;
float lineSpan = firstLineIndent;
for (int n = layoutPool.getViewCount(), i = 0; i < n; i++)
{
View v = layoutPool.getView(i);
if (v.getBreakWeight(X_AXIS, 0, Integer.MAX_VALUE) <= BadBreakWeight)
{
lineHasView = true;
lineSpan += v.getPreferredSpan(X_AXIS);
}
else
{
if (lineHasView)
{
result = Math.max(lineSpan, result);
lineHasView = false;
lineSpan = otherLinesIndent;
}
else
// here would have to add the minimum width of the
// fragments of the view
;
}
}
result = Math.max(result, lineSpan);
return result;
}
Christian
.
- References:
- JTextPane: Workaround for invisible text with hanging indents?
- From: Adam Warner
- Re: JTextPane: Workaround for invisible text with hanging indents?
- From: Christian Kaufhold
- JTextPane: Workaround for invisible text with hanging indents?
- Prev by Date: Re: Layout question
- Next by Date: Re: setFont()
- Previous by thread: Re: JTextPane: Workaround for invisible text with hanging indents?
- Next by thread: GUI Prototype erstellen
- Index(es):