diff options
Diffstat (limited to 'javax/swing/text/CompositeView.java')
-rw-r--r-- | javax/swing/text/CompositeView.java | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/javax/swing/text/CompositeView.java b/javax/swing/text/CompositeView.java index d4467f314..570fc955c 100644 --- a/javax/swing/text/CompositeView.java +++ b/javax/swing/text/CompositeView.java @@ -68,7 +68,7 @@ public abstract class CompositeView * initialized in {@link #getInsideAllocation} and reused and modified in * {@link #childAllocation(int, Rectangle)}. */ - Rectangle insideAllocation; + private final Rectangle insideAllocation = new Rectangle(); /** * The insets of this <code>CompositeView</code>. This is initialized @@ -282,12 +282,12 @@ public abstract class CompositeView } } } - else - { - throw new BadLocationException("Position " + pos - + " is not represented by view.", pos); - } } + + if (ret == null) + throw new BadLocationException("Position " + pos + + " is not represented by view.", pos); + return ret; } @@ -527,24 +527,17 @@ public abstract class CompositeView if (a == null) return null; - Rectangle alloc = a.getBounds(); + // Try to avoid allocation of Rectangle here. + Rectangle alloc = a instanceof Rectangle ? (Rectangle) a : a.getBounds(); + // Initialize the inside allocation rectangle. This is done inside // a synchronized block in order to avoid multiple threads creating // this instance simultanously. - Rectangle inside; - synchronized(this) - { - inside = insideAllocation; - if (inside == null) - { - inside = new Rectangle(); - insideAllocation = inside; - } - } - inside.x = alloc.x + left; - inside.y = alloc.y + top; - inside.width = alloc.width - left - right; - inside.height = alloc.height - top - bottom; + Rectangle inside = insideAllocation; + inside.x = alloc.x + getLeftInset(); + inside.y = alloc.y + getTopInset(); + inside.width = alloc.width - getLeftInset() - getRightInset(); + inside.height = alloc.height - getTopInset() - getBottomInset(); return inside; } |