summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2006-09-02 11:29:12 +0000
committerRoman Kennke <roman@kennke.org>2006-09-02 11:29:12 +0000
commit07994ff1ea635fd8de324f090fdc9c12db2f944e (patch)
tree64154d0288e80ff5b2fb0d2eaace9c660ea70b6a
parent7b504bccf265f3d636ee016a30404e9ed0825b76 (diff)
downloadclasspath-07994ff1ea635fd8de324f090fdc9c12db2f944e.tar.gz
2006-09-02 Roman Kennke <kennke@aicas.com>
PR 28928 * javax/swing/plaf/basic/BasicTextUI.java (RootView.getPreferredSpan): Default to 10 when there is no real view. (RootView.getMinimumSpan): Forward to view and default to 10 when there is no real view. (RootView.getMaximumSpan): Return Integer.MAX_VALUE. (getMaximumSize): Check for overflow. * javax/swing/text/FieldView.java (getResizeWeight): Removed unneeded assignment.
-rw-r--r--ChangeLog13
-rw-r--r--javax/swing/plaf/basic/BasicTextUI.java62
-rw-r--r--javax/swing/text/FieldView.java4
3 files changed, 54 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index 62c430707..1e76416ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-09-02 Roman Kennke <kennke@aicas.com>
+
+ PR 28928
+ * javax/swing/plaf/basic/BasicTextUI.java
+ (RootView.getPreferredSpan): Default to 10 when there is no
+ real view.
+ (RootView.getMinimumSpan): Forward to view and default to 10
+ when there is no real view.
+ (RootView.getMaximumSpan): Return Integer.MAX_VALUE.
+ (getMaximumSize): Check for overflow.
+ * javax/swing/text/FieldView.java
+ (getResizeWeight): Removed unneeded assignment.
+
2006-09-01 Francis Kung <fkung@redhat.com>
* java/awt/image/ColorConvertOp.java
(copyImage): Updated javadoc and comments.
diff --git a/javax/swing/plaf/basic/BasicTextUI.java b/javax/swing/plaf/basic/BasicTextUI.java
index d082ad055..dc30347f5 100644
--- a/javax/swing/plaf/basic/BasicTextUI.java
+++ b/javax/swing/plaf/basic/BasicTextUI.java
@@ -362,22 +362,6 @@ public abstract class BasicTextUI extends TextUI
return textComponent;
}
- /**
- * Returns the preferred span along the specified <code>axis</code>.
- * This is delegated to the real root view.
- *
- * @param axis the axis for which the preferred span is queried
- *
- * @return the preferred span along the axis
- */
- public float getPreferredSpan(int axis)
- {
- if (view != null)
- return view.getPreferredSpan(axis);
-
- return Integer.MAX_VALUE;
- }
-
public void setSize(float w, float h)
{
if (view != null)
@@ -554,6 +538,40 @@ public abstract class BasicTextUI extends TextUI
{
return null;
}
+
+ /**
+ * Overridden to forward to the view.
+ */
+ public float getPreferredSpan(int axis)
+ {
+ // The RI returns 10 in the degenerate case.
+ float span = 10;
+ if (view != null)
+ span = view.getPreferredSpan(axis);
+ return span;
+ }
+
+ /**
+ * Overridden to forward to the real view.
+ */
+ public float getMinimumSpan(int axis)
+ {
+ // The RI returns 10 in the degenerate case.
+ float span = 10;
+ if (view != null)
+ span = view.getMinimumSpan(axis);
+ return span;
+ }
+
+ /**
+ * Overridden to return Integer.MAX_VALUE.
+ */
+ public float getMaximumSpan(int axis)
+ {
+ // The RI returns Integer.MAX_VALUE here, regardless of the real view's
+ // maximum size.
+ return Integer.MAX_VALUE;
+ }
}
/**
@@ -1004,6 +1022,7 @@ public abstract class BasicTextUI extends TextUI
public Dimension getMaximumSize(JComponent c)
{
Dimension d = new Dimension();
+ Insets i = c.getInsets();
Document doc = textComponent.getDocument();
// We need to lock here, since we require the view hierarchy to _not_
// change in between.
@@ -1011,17 +1030,17 @@ public abstract class BasicTextUI extends TextUI
((AbstractDocument) doc).readLock();
try
{
- d.width = (int) rootView.getMaximumSpan(View.X_AXIS);
- d.height = (int) rootView.getMaximumSpan(View.Y_AXIS);
+ // Check for overflow here.
+ d.width = (int) Math.min((long) rootView.getMaximumSpan(View.X_AXIS)
+ + i.left + i.right, Integer.MAX_VALUE);
+ d.height = (int) Math.min((long) rootView.getMaximumSpan(View.Y_AXIS)
+ + i.top + i.bottom, Integer.MAX_VALUE);
}
finally
{
if (doc instanceof AbstractDocument)
((AbstractDocument) doc).readUnlock();
}
- Insets i = c.getInsets();
- d.width += i.left + i.right;
- d.height += i.top + i.bottom;
return d;
}
@@ -1123,7 +1142,6 @@ public abstract class BasicTextUI extends TextUI
g.setColor(oldColor);
}
-
rootView.paint(g, getVisibleEditorRect());
if (caret != null && textComponent.hasFocus())
diff --git a/javax/swing/text/FieldView.java b/javax/swing/text/FieldView.java
index f41f90130..0a078e53d 100644
--- a/javax/swing/text/FieldView.java
+++ b/javax/swing/text/FieldView.java
@@ -45,8 +45,6 @@ import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Shape;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import javax.swing.BoundedRangeModel;
import javax.swing.JTextField;
@@ -225,7 +223,7 @@ public class FieldView extends PlainView
public int getResizeWeight(int axis)
{
- return axis = axis == X_AXIS ? 1 : 0;
+ return axis == X_AXIS ? 1 : 0;
}
public Shape modelToView(int pos, Shape a, Position.Bias bias)