diff options
author | Roman Kennke <roman@kennke.org> | 2006-08-05 12:13:19 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2006-08-05 12:13:19 +0000 |
commit | 08c81f99966f64985eea9fdf00737df867e43757 (patch) | |
tree | 2589b871a833073d7b93bb4355a974d83d7adea0 /javax/swing/text/CompositeView.java | |
parent | bba269fc5f7f2e4bb00cfffb4e3fae5732625db4 (diff) | |
download | classpath-08c81f99966f64985eea9fdf00737df867e43757.tar.gz |
2006-08-05 Roman Kennke <kennke@aicas.com>
* javax/swing/plaf/basic/BasicTextUI.java
(damageRange(JTextComponent,int,int)): Call damageRange() with
correct biases, rather than null.
(damageRange(JTextComponent,int,int,Bias,Bias)): Rewritten
to use simpler modelToView() approach without much special
casing. This seems not worth the effort and actually
caused problems. Added locking of the document.
* javax/swing/text/BoxView.java
(requirementsValid): New field.
(calculateMajorAxisRequirements): Rewritten without using
SizeRequirements. The SizeRequirements algorithms are slightly
different and too inefficient.
(calculateMinorAxisRequirements): Rewritten without using
SizeRequirements. The SizeRequirements algorithms are slightly
different and too inefficient.
(getAlignment): Simply return the alignment of the cached
requirements.
(getMaximumSpan): Add insets.
(getMinimumSpan): Add insets.
(getPreferredSpan): Add insets.
(layoutMajorAxis): Rewritten without using
SizeRequirements. The SizeRequirements algorithms are slightly
different and too inefficient.
(layoutMinorAxis): Rewritten without using
SizeRequirements. The SizeRequirements algorithms are slightly
different and too inefficient.
(modelToView): Call setSize() rather than layout().
(paint): Check clip for more efficient painting.
(preferenceChanged): Invalidate requirements here.
(replace): Invalidate requirements here.
(updateRequirements): Update requirements only when requirements
are marked invalid.
* javax/swing/text/CompositeView.java
(modelToView): Added some more checks and handling of corner cases.
* javax/swing/text/FlowView.java
(calculateMinorAxisRequirements): Set aligment to 0.5 and maximum
span to Integer.MAX_VALUE. Limit preferredSize to minimumSize.
* javax/swing/text/IconView.java
(getAlignment): Implemented to return 1.0 for vertical alignment.
* javax/swing/text/ParagraphView.java
(Row.getMaximumSpan): Implemented to let Rows span the whole
ParagraphView.
(getAlignment): Fixed horizontal alignment and vertical alignment
for empty paragraphs to be 0.5.
Diffstat (limited to 'javax/swing/text/CompositeView.java')
-rw-r--r-- | javax/swing/text/CompositeView.java | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/javax/swing/text/CompositeView.java b/javax/swing/text/CompositeView.java index 17f13dbed..5a904b1ea 100644 --- a/javax/swing/text/CompositeView.java +++ b/javax/swing/text/CompositeView.java @@ -217,25 +217,43 @@ public abstract class CompositeView public Shape modelToView(int pos, Shape a, Position.Bias bias) throws BadLocationException { - int childIndex = getViewIndex(pos, bias); - if (childIndex == -1) - throw new BadLocationException("Position " + pos + " is not represented by view.", pos); - - Shape ret = null; - - View child = getView(childIndex); - Shape childAlloc = getChildAllocation(childIndex, a); - - if (childAlloc == null) - ret = createDefaultLocation(a, bias); - - Shape result = child.modelToView(pos, childAlloc, bias); - - if (result != null) - ret = result; - else - ret = createDefaultLocation(a, bias); + boolean backward = bias == Position.Bias.Backward; + int testpos = backward ? Math.max(0, pos - 1) : pos; + Shape ret = null; + if (!backward || testpos >= getStartOffset()) + { + int childIndex = getViewIndexAtPosition(testpos); + if (childIndex != -1 && childIndex < getViewCount()) + { + View child = getView(childIndex); + if (child != null && testpos >= child.getStartOffset() + && testpos < child.getEndOffset()) + { + Shape childAlloc = getChildAllocation(childIndex, a); + if (childAlloc != null) + { + ret = child.modelToView(pos, childAlloc, bias); + // Handle corner case. + if (ret == null && child.getEndOffset() == pos) + { + childIndex++; + if (childIndex < getViewCount()) + { + child = getView(childIndex); + childAlloc = getChildAllocation(childIndex, a); + ret = child.modelToView(pos, childAlloc, bias); + } + } + } + } + } + else + { + throw new BadLocationException("Position " + pos + + " is not represented by view.", pos); + } + } return ret; } |