diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-11-29 22:43:35 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-11-29 22:43:35 +0000 |
commit | 3be294e0e9f07e379e1499b9868db9855eb8726f (patch) | |
tree | a1f67d3f1469ecc142b11c30b1e3c2e1a624794d /javax/swing/text/CompositeView.java | |
parent | f40b961c6c82ebc9ae9863635e5fe19c0b07c116 (diff) | |
download | classpath-3be294e0e9f07e379e1499b9868db9855eb8726f.tar.gz |
2006-11-29 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD-->generics for 2006/11/12-2006/11/29.
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; } |