summaryrefslogtreecommitdiff
path: root/java/awt
diff options
context:
space:
mode:
authorThomas Fitzsimmons <fitzsim@redhat.com>2004-02-03 17:17:28 +0000
committerThomas Fitzsimmons <fitzsim@redhat.com>2004-02-03 17:17:28 +0000
commitae8c30ebd4d7b20832df50745efebf628509add4 (patch)
tree7b81ddcbd3ab5726021f6d141f96d2e9c50522c1 /java/awt
parent0aeb3f22c7bfd3dcd65452cb61ecf26499e6bce4 (diff)
downloadclasspath-ae8c30ebd4d7b20832df50745efebf628509add4.tar.gz
2004-02-03 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkListPeer.java, java/awt/BorderLayout.java, java/awt/CardLayout.java, java/awt/CheckboxGroup.java, java/awt/Choice.java, java/awt/Component.java, java/awt/Container.java, java/awt/FontMetrics.java, java/awt/GridBagLayout.java, java/awt/LayoutManager2.java, java/awt/List.java, java/awt/Menu.java, java/awt/MenuBar.java, java/awt/MenuItem.java, java/awt/Polygon.java, java/awt/Rectangle.java, java/awt/ScrollPane.java, java/awt/Scrollbar.java, java/awt/TextArea.java, java/awt/TextField.java, java/awt/image/renderable/RenderContext.java, javax/swing/JApplet.java: Fix handling of alias methods, where a method has been deprecated in favour of a new one with the same funtion but a different name. Put the method implementation in the deprecated method and have the new method call the deprecated one. Make all other code call the new method.
Diffstat (limited to 'java/awt')
-rw-r--r--java/awt/BorderLayout.java44
-rw-r--r--java/awt/CardLayout.java4
-rw-r--r--java/awt/CheckboxGroup.java28
-rw-r--r--java/awt/Choice.java2
-rw-r--r--java/awt/Component.java118
-rw-r--r--java/awt/Container.java78
-rw-r--r--java/awt/FontMetrics.java4
-rw-r--r--java/awt/GridBagLayout.java555
-rw-r--r--java/awt/LayoutManager2.java6
-rw-r--r--java/awt/List.java119
-rw-r--r--java/awt/Menu.java4
-rw-r--r--java/awt/MenuBar.java6
-rw-r--r--java/awt/MenuItem.java29
-rw-r--r--java/awt/Polygon.java32
-rw-r--r--java/awt/Rectangle.java49
-rw-r--r--java/awt/ScrollPane.java40
-rw-r--r--java/awt/Scrollbar.java96
-rw-r--r--java/awt/TextArea.java96
-rw-r--r--java/awt/TextField.java47
-rw-r--r--java/awt/image/renderable/RenderContext.java12
20 files changed, 682 insertions, 687 deletions
diff --git a/java/awt/BorderLayout.java b/java/awt/BorderLayout.java
index 930773f01..5033bcf7a 100644
--- a/java/awt/BorderLayout.java
+++ b/java/awt/BorderLayout.java
@@ -349,7 +349,28 @@ addLayoutComponent(Component component, Object constraints)
if (constraints != null && ! (constraints instanceof String))
throw new IllegalArgumentException("Constraint must be a string");
- String str = (String)constraints;
+ addLayoutComponent((String) constraints, component);
+}
+
+/*************************************************************************/
+
+/**
+ * Adds a component to the layout in the specified constraint position,
+ * which must be one of the string constants defined in this class.
+ *
+ * @param constraints The constraint string.
+ * @param component The component to add.
+ *
+ * @exception IllegalArgumentException If the constraint object is not
+ * one of the specified constants in this class.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>addLayoutComponent(Component, Object)</code>.
+ */
+public void
+addLayoutComponent(String constraints, Component component)
+{
+ String str = constraints;
if (str == null || str.equals(CENTER))
center = component;
@@ -376,27 +397,6 @@ addLayoutComponent(Component component, Object constraints)
/*************************************************************************/
/**
- * Adds a component to the layout in the specified constraint position,
- * which must be one of the string constants defined in this class.
- *
- * @param constraints The constraint string.
- * @param component The component to add.
- *
- * @exception IllegalArgumentException If the constraint object is not
- * one of the specified constants in this class.
- *
- * @deprecated This method is deprecated in favor of
- * <code>addLayoutComponent(Component, Object)</code>.
- */
-public void
-addLayoutComponent(String constraints, Component component)
-{
- addLayoutComponent(component, constraints);
-}
-
-/*************************************************************************/
-
-/**
* Removes the specified component from the layout.
*
* @param component The component to remove from the layout.
diff --git a/java/awt/CardLayout.java b/java/awt/CardLayout.java
index 1900a6094..c3c9f5381 100644
--- a/java/awt/CardLayout.java
+++ b/java/awt/CardLayout.java
@@ -90,7 +90,7 @@ public class CardLayout implements LayoutManager2, Serializable
if (! (constraints instanceof String))
throw new IllegalArgumentException ("Object " + constraints
+ " is not a string");
- tab.put (constraints, comp);
+ addLayoutComponent ((String) constraints, comp);
}
/** Add a new component to the layout. The name can be used later
@@ -102,7 +102,7 @@ public class CardLayout implements LayoutManager2, Serializable
*/
public void addLayoutComponent (String name, Component comp)
{
- addLayoutComponent (comp, name);
+ tab.put (name, comp);
}
/** Cause the first component in the container to be displayed.
diff --git a/java/awt/CheckboxGroup.java b/java/awt/CheckboxGroup.java
index 64d01951d..52af1903a 100644
--- a/java/awt/CheckboxGroup.java
+++ b/java/awt/CheckboxGroup.java
@@ -95,8 +95,8 @@ CheckboxGroup()
public Checkbox
getSelectedCheckbox()
{
- return(selectedCheckbox);
-}
+ return getCurrent ();
+}
/*************************************************************************/
@@ -126,17 +126,7 @@ getCurrent()
public void
setSelectedCheckbox(Checkbox selectedCheckbox)
{
- if (this.selectedCheckbox != null)
- {
- if (this.selectedCheckbox.getCheckboxGroup() != this)
- return;
-
- this.selectedCheckbox.setState(false);
- }
-
- this.selectedCheckbox = selectedCheckbox;
- if (selectedCheckbox != null)
- selectedCheckbox.setState(true);
+ setCurrent (selectedCheckbox);
}
/*************************************************************************/
@@ -153,7 +143,17 @@ setSelectedCheckbox(Checkbox selectedCheckbox)
public void
setCurrent(Checkbox selectedCheckbox)
{
- setSelectedCheckbox(selectedCheckbox);
+ if (this.selectedCheckbox != null)
+ {
+ if (this.selectedCheckbox.getCheckboxGroup() != this)
+ return;
+
+ this.selectedCheckbox.setState(false);
+ }
+
+ this.selectedCheckbox = selectedCheckbox;
+ if (selectedCheckbox != null)
+ selectedCheckbox.setState(true);
}
/*************************************************************************/
diff --git a/java/awt/Choice.java b/java/awt/Choice.java
index d1f601f77..b2b597ed0 100644
--- a/java/awt/Choice.java
+++ b/java/awt/Choice.java
@@ -111,7 +111,7 @@ private ItemListener item_listeners;
public int
getItemCount()
{
- return(pItems.size());
+ return countItems ();
}
/*************************************************************************/
diff --git a/java/awt/Component.java b/java/awt/Component.java
index 87c73b51e..f2fcef59b 100644
--- a/java/awt/Component.java
+++ b/java/awt/Component.java
@@ -779,9 +779,7 @@ public abstract class Component
*/
public void setEnabled(boolean b)
{
- this.enabled = b;
- if (peer != null)
- peer.setEnabled(b);
+ enable (b);
}
/**
@@ -791,7 +789,9 @@ public abstract class Component
*/
public void enable()
{
- setEnabled(true);
+ this.enabled = true;
+ if (peer != null)
+ peer.setEnabled (true);
}
/**
@@ -802,7 +802,10 @@ public abstract class Component
*/
public void enable(boolean b)
{
- setEnabled(b);
+ if (b)
+ enable ();
+ else
+ disable ();
}
/**
@@ -812,7 +815,9 @@ public abstract class Component
*/
public void disable()
{
- setEnabled(false);
+ this.enabled = false;
+ if (peer != null)
+ peer.setEnabled (false);
}
/**
@@ -856,10 +861,7 @@ public abstract class Component
// Inspection by subclassing shows that Sun's implementation calls
// show(boolean) which then calls show() or hide(). It is the show()
// method that is overriden in subclasses like Window.
- if (b)
- show();
- else
- hide();
+ show (b);
}
/**
@@ -887,7 +889,10 @@ public abstract class Component
*/
public void show(boolean b)
{
- setVisible(b);
+ if (b)
+ show ();
+ else
+ hide ();
}
/**
@@ -1083,7 +1088,7 @@ public abstract class Component
*/
public Point getLocation()
{
- return new Point(x, y);
+ return location ();
}
/**
@@ -1110,7 +1115,7 @@ public abstract class Component
*/
public Point location()
{
- return getLocation();
+ return new Point (x, y);
}
/**
@@ -1125,13 +1130,7 @@ public abstract class Component
*/
public void setLocation(int x, int y)
{
- if (this.x == x && this.y == y)
- return;
- invalidate();
- this.x = x;
- this.y = y;
- if (peer != null)
- peer.setBounds(x, y, width, height);
+ move (x, y);
}
/**
@@ -1145,7 +1144,13 @@ public abstract class Component
*/
public void move(int x, int y)
{
- setLocation(x, y);
+ if (this.x == x && this.y == y)
+ return;
+ invalidate ();
+ this.x = x;
+ this.y = y;
+ if (peer != null)
+ peer.setBounds (x, y, width, height);
}
/**
@@ -1173,7 +1178,7 @@ public abstract class Component
*/
public Dimension getSize()
{
- return new Dimension(width, height);
+ return size ();
}
/**
@@ -1184,7 +1189,7 @@ public abstract class Component
*/
public Dimension size()
{
- return getSize();
+ return new Dimension (width, height);
}
/**
@@ -1197,13 +1202,7 @@ public abstract class Component
*/
public void setSize(int width, int height)
{
- if (this.width == width && this.height == height)
- return;
- invalidate();
- this.width = width;
- this.height = height;
- if (peer != null)
- peer.setBounds(x, y, width, height);
+ resize (width, height);
}
/**
@@ -1215,7 +1214,13 @@ public abstract class Component
*/
public void resize(int width, int height)
{
- setSize(width, height);
+ if (this.width == width && this.height == height)
+ return;
+ invalidate ();
+ this.width = width;
+ this.height = height;
+ if (peer != null)
+ peer.setBounds (x, y, width, height);
}
/**
@@ -1229,7 +1234,7 @@ public abstract class Component
*/
public void setSize(Dimension d)
{
- setSize(d.width, d.height);
+ resize (d);
}
/**
@@ -1241,7 +1246,7 @@ public abstract class Component
*/
public void resize(Dimension d)
{
- setSize(d.width, d.height);
+ resize (d.width, d.height);
}
/**
@@ -1256,7 +1261,7 @@ public abstract class Component
*/
public Rectangle getBounds()
{
- return new Rectangle(x, y, width, height);
+ return bounds ();
}
/**
@@ -1269,7 +1274,7 @@ public abstract class Component
*/
public Rectangle bounds()
{
- return getBounds();
+ return new Rectangle (x, y, width, height);
}
/**
@@ -1289,15 +1294,7 @@ public abstract class Component
*/
public void setBounds(int x, int y, int w, int h)
{
- if (this.x == x && this.y == y && width == w && height == h)
- return;
- invalidate();
- this.x = x;
- this.y = y;
- width = w;
- height = h;
- if (peer != null)
- peer.setBounds(x, y, w, h);
+ reshape (x, y, w, h);
}
/**
@@ -1306,13 +1303,22 @@ public abstract class Component
*
* @param x the X coordinate of the upper left corner of the rectangle
* @param y the Y coordinate of the upper left corner of the rectangle
- * @param w the width of the rectangle
- * @param h the height of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
* @deprecated use {@link #setBounds(int, int, int, int)} instead
*/
public void reshape(int x, int y, int width, int height)
{
- setBounds(x, y, width, height);
+ if (this.x == x && this.y == y
+ && this.width == width && this.height == height)
+ return;
+ invalidate ();
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ if (peer != null)
+ peer.setBounds (x, y, width, height);
}
/**
@@ -1329,7 +1335,7 @@ public abstract class Component
*/
public void setBounds(Rectangle r)
{
- setBounds(r.x, r.y, r.width, r.height);
+ setBounds (r.x, r.y, r.width, r.height);
}
/**
@@ -1560,7 +1566,7 @@ public abstract class Component
*/
public void doLayout()
{
- // nothing to do unless we're a container
+ layout ();
}
/**
@@ -1571,7 +1577,7 @@ public abstract class Component
*/
public void layout()
{
- doLayout();
+ // Nothing to do unless we're a container.
}
/**
@@ -2076,7 +2082,7 @@ public abstract class Component
*/
public boolean contains(int x, int y)
{
- return x >= 0 && y >= 0 && x < width && y < height;
+ return inside (x, y);
}
/**
@@ -2090,7 +2096,7 @@ public abstract class Component
*/
public boolean inside(int x, int y)
{
- return contains(x, y);
+ return x >= 0 && y >= 0 && x < width && y < height;
}
/**
@@ -2105,7 +2111,7 @@ public abstract class Component
*/
public boolean contains(Point p)
{
- return contains(p.x, p.y);
+ return contains (p.x, p.y);
}
/**
@@ -2120,7 +2126,7 @@ public abstract class Component
*/
public Component getComponentAt(int x, int y)
{
- return contains(x, y) ? this : null;
+ return locate (x, y);
}
/**
@@ -2135,7 +2141,7 @@ public abstract class Component
*/
public Component locate(int x, int y)
{
- return getComponentAt(x, y);
+ return contains (x, y) ? this : null;
}
/**
@@ -2151,7 +2157,7 @@ public abstract class Component
*/
public Component getComponentAt(Point p)
{
- return getComponentAt(p.x, p.y);
+ return getComponentAt (p.x, p.y);
}
/**
diff --git a/java/awt/Container.java b/java/awt/Container.java
index 57cd8338c..ed869e18e 100644
--- a/java/awt/Container.java
+++ b/java/awt/Container.java
@@ -106,7 +106,7 @@ public class Container extends Component
*/
public int getComponentCount()
{
- return ncomponents;
+ return countComponents ();
}
/**
@@ -118,7 +118,7 @@ public class Container extends Component
*/
public int countComponents()
{
- return getComponentCount();
+ return ncomponents;
}
/**
@@ -186,10 +186,7 @@ public class Container extends Component
*/
public Insets getInsets()
{
- if (peer == null)
- return new Insets(0, 0, 0, 0);
-
- return ((ContainerPeer) peer).getInsets();
+ return insets ();
}
/**
@@ -201,7 +198,10 @@ public class Container extends Component
*/
public Insets insets()
{
- return getInsets();
+ if (peer == null)
+ return new Insets (0, 0, 0, 0);
+
+ return ((ContainerPeer) peer).getInsets ();
}
/**
@@ -463,8 +463,7 @@ public class Container extends Component
*/
public void doLayout()
{
- if (layoutMgr != null)
- layoutMgr.layoutContainer(this);
+ layout ();
}
/**
@@ -474,7 +473,8 @@ public class Container extends Component
*/
public void layout()
{
- doLayout();
+ if (layoutMgr != null)
+ layoutMgr.layoutContainer (this);
}
/**
@@ -555,7 +555,7 @@ public class Container extends Component
*/
public Dimension getPreferredSize()
{
- return preferredSize();
+ return preferredSize ();
}
/**
@@ -567,10 +567,10 @@ public class Container extends Component
*/
public Dimension preferredSize()
{
- if (layoutMgr != null)
- return layoutMgr.preferredLayoutSize(this);
- else
- return super.preferredSize();
+ if (layoutMgr != null)
+ return layoutMgr.preferredLayoutSize (this);
+ else
+ return super.preferredSize ();
}
/**
@@ -580,7 +580,7 @@ public class Container extends Component
*/
public Dimension getMinimumSize()
{
- return minimumSize();
+ return minimumSize ();
}
/**
@@ -592,10 +592,10 @@ public class Container extends Component
*/
public Dimension minimumSize()
{
- if (layoutMgr != null)
- return layoutMgr.minimumLayoutSize(this);
- else
- return super.minimumSize();
+ if (layoutMgr != null)
+ return layoutMgr.minimumLayoutSize (this);
+ else
+ return super.minimumSize ();
}
/**
@@ -833,23 +833,7 @@ public class Container extends Component
*/
public Component getComponentAt(int x, int y)
{
- synchronized (getTreeLock ())
- {
- if (! contains(x, y))
- return null;
- for (int i = 0; i < ncomponents; ++i)
- {
- // Ignore invisible children...
- if (!component[i].isVisible())
- continue;
-
- int x2 = x - component[i].x;
- int y2 = y - component[i].y;
- if (component[i].contains(x2, y2))
- return component[i];
- }
- return this;
- }
+ return locate (x, y);
}
/**
@@ -869,7 +853,23 @@ public class Container extends Component
*/
public Component locate(int x, int y)
{
- return getComponentAt(x, y);
+ synchronized (getTreeLock ())
+ {
+ if (!contains (x, y))
+ return null;
+ for (int i = 0; i < ncomponents; ++i)
+ {
+ // Ignore invisible children...
+ if (!component[i].isVisible ())
+ continue;
+
+ int x2 = x - component[i].x;
+ int y2 = y - component[i].y;
+ if (component[i].contains (x2, y2))
+ return component[i];
+ }
+ return this;
+ }
}
/**
@@ -886,7 +886,7 @@ public class Container extends Component
*/
public Component getComponentAt(Point p)
{
- return getComponentAt(p.x, p.y);
+ return getComponentAt (p.x, p.y);
}
public Component findComponentAt(int x, int y)
diff --git a/java/awt/FontMetrics.java b/java/awt/FontMetrics.java
index ce340dadb..a7f76e03a 100644
--- a/java/awt/FontMetrics.java
+++ b/java/awt/FontMetrics.java
@@ -195,7 +195,7 @@ getMaxAscent()
public int
getMaxDescent()
{
- return(getDescent());
+ return getMaxDecent ();
}
/*************************************************************************/
@@ -212,7 +212,7 @@ getMaxDescent()
public int
getMaxDecent()
{
- return(getMaxDescent());
+ return getDescent ();
}
/*************************************************************************/
diff --git a/java/awt/GridBagLayout.java b/java/awt/GridBagLayout.java
index 7572c1d1d..2cf8daa6b 100644
--- a/java/awt/GridBagLayout.java
+++ b/java/awt/GridBagLayout.java
@@ -149,7 +149,7 @@ public class GridBagLayout
public void layoutContainer (Container parent)
{
- arrangeGrid (parent);
+ arrangeGrid (parent);
}
public float getLayoutAlignmentX (Container target)
@@ -302,7 +302,8 @@ public class GridBagLayout
*/
protected void AdjustForGravity (GridBagConstraints gbc, Rectangle rect)
{
- adjustForGravity (gbc, rect);
+ // FIXME
+ throw new Error ("Not implemented");
}
/**
@@ -310,7 +311,115 @@ public class GridBagLayout
*/
protected void ArrangeGrid (Container parent)
{
- arrangeGrid (parent);
+ Component[] components = parent.getComponents();
+
+ if (components.length == 0)
+ return;
+
+ GridBagLayoutInfo info = getLayoutInfo (parent, PREFERREDSIZE);
+ if (info.cols == 0 && info.rows == 0)
+ return;
+ layoutInfo = info;
+
+ // DEBUG
+ //dumpLayoutInfo (layoutInfo);
+
+ for(int i = 0; i < components.length; i++)
+ {
+ Component component = components [i];
+
+ // If component is not visible we dont have to care about it.
+ if (!component.isVisible())
+ continue;
+
+ GridBagConstraints constraints = lookupConstraints (component);
+
+ int cellx = sumIntArray(layoutInfo.colWidths, constraints.gridx);
+ int celly = sumIntArray(layoutInfo.rowHeights, constraints.gridy);
+ int cellw = sumIntArray(layoutInfo.colWidths,
+ constraints.gridx + constraints.gridwidth) - cellx;
+ int cellh = sumIntArray(layoutInfo.rowHeights,
+ constraints.gridy + constraints.gridheight) - celly;
+
+ Insets insets = constraints.insets;
+ if (insets != null)
+ {
+ cellx += insets.left;
+ celly += insets.top;
+ cellw -= insets.left + insets.right;
+ cellh -= insets.top + insets.bottom;
+ }
+
+ Dimension dim = component.getPreferredSize();
+
+ // Note: Documentation says that padding is added on both sides, but
+ // visual inspection shows that the Sun implementation only adds it
+ // once, so we do the same.
+ dim.width += constraints.ipadx;
+ dim.height += constraints.ipady;
+
+ switch(constraints.fill)
+ {
+ case GridBagConstraints.HORIZONTAL:
+ dim.width = cellw;
+ break;
+ case GridBagConstraints.VERTICAL:
+ dim.height = cellh;
+ break;
+ case GridBagConstraints.BOTH:
+ dim.width = cellw;
+ dim.height = cellh;
+ break;
+ }
+
+ int x;
+ int y;
+
+ switch(constraints.anchor)
+ {
+ case GridBagConstraints.NORTH:
+ x = cellx + (cellw - dim.width) / 2;
+ y = celly;
+ break;
+ case GridBagConstraints.SOUTH:
+ x = cellx + (cellw - dim.width) / 2;
+ y = celly + cellh - dim.height;
+ break;
+ case GridBagConstraints.WEST:
+ x = cellx;
+ y = celly + (cellh - dim.height) / 2;
+ break;
+ case GridBagConstraints.EAST:
+ x = cellx + cellw - dim.width;
+ y = celly + (cellh - dim.height) / 2;
+ break;
+ case GridBagConstraints.NORTHEAST:
+ x = cellx + cellw - dim.width;
+ y = celly;
+ break;
+ case GridBagConstraints.NORTHWEST:
+ x = cellx;
+ y = celly;
+ break;
+ case GridBagConstraints.SOUTHEAST:
+ x = cellx + cellw - dim.width;
+ y = celly + cellh - dim.height;
+ break;
+ case GridBagConstraints.SOUTHWEST:
+ x = cellx;
+ y = celly + cellh - dim.height;
+ break;
+ default:
+ x = cellx + (cellw - dim.width) / 2;
+ y = celly + (cellh - dim.height) / 2;
+ break;
+ }
+
+ component.setBounds(layoutInfo.pos_x + x, layoutInfo.pos_y + y, dim.width, dim.height);
+ }
+
+ // DEBUG
+ //dumpLayoutInfo (layoutInfo);
}
/**
@@ -318,7 +427,160 @@ public class GridBagLayout
*/
protected GridBagLayoutInfo GetLayoutInfo (Container parent, int sizeflag)
{
- return getLayoutInfo (parent, sizeflag);
+ if (sizeflag != MINSIZE && sizeflag != PREFERREDSIZE)
+ throw new IllegalArgumentException();
+
+ Dimension parentDim = parent.getSize ();
+ Insets parentInsets = parent.getInsets ();
+ parentDim.width -= parentInsets.left + parentInsets.right;
+ parentDim.height -= parentInsets.top + parentInsets.bottom;
+
+ int x = 0;
+ int y = 0;
+ int max_x = 0;
+ int max_y = 0;
+
+ // first we figure out how many rows/columns
+ Component[] components = parent.getComponents();
+ for (int i = 0; i < components.length; i++)
+ {
+ Component component = components [i];
+
+ // If component is not visible we dont have to care about it.
+ if (!component.isVisible())
+ continue;
+
+ GridBagConstraints constraints = lookupConstraints (component);
+
+ if(constraints.gridx == GridBagConstraints.RELATIVE)
+ constraints.gridx = x;
+
+ if(constraints.gridy == GridBagConstraints.RELATIVE)
+ constraints.gridy = y;
+
+ max_x = Math.max(max_x,
+ constraints.gridx + Math.max(1, constraints.gridwidth));
+ max_y = Math.max(max_y,
+ constraints.gridy + Math.max(1, constraints.gridheight));
+
+ if(constraints.gridwidth == GridBagConstraints.REMAINDER)
+ {
+ x = 0;
+ y++;
+ }
+ else
+ {
+ x = constraints.gridx + Math.max(1, constraints.gridwidth);
+ y = constraints.gridy;
+ }
+ }
+
+ GridBagLayoutInfo info = new GridBagLayoutInfo(max_x, max_y);
+
+ for (x = 0; x <= max_x; x++)
+ {
+ if(columnWidths != null && columnWidths.length > x)
+ {
+ info.colWidths[x] = columnWidths[x];
+ }
+ if(columnWeights != null && columnWeights.length > x)
+ {
+ info.colWeights[x] = columnWeights[x];
+ }
+ for (int i = 0; i < components.length; i++)
+ {
+ Component component = components [i];
+
+ // If component is not visible we dont have to care about it.
+ if (!component.isVisible())
+ continue;
+
+ GridBagConstraints constraints = lookupConstraints (component);
+
+ // first we fix up any REMAINDER cells
+ if(constraints.gridwidth == GridBagConstraints.REMAINDER)
+ {
+ constraints.gridwidth = max_x - constraints.gridx;
+ }
+ if(constraints.gridheight == GridBagConstraints.REMAINDER)
+ {
+ constraints.gridheight = max_y - constraints.gridy;
+ }
+
+ if(constraints.gridx + constraints.gridwidth - 1 == x)
+ {
+ int width = (sizeflag == PREFERREDSIZE) ?
+ component.getPreferredSize().width :
+ component.getMinimumSize().width;
+ if(constraints.insets != null)
+ {
+ width += constraints.insets.left + constraints.insets.right;
+ }
+ width += constraints.ipadx;
+ for(int w = 1; w < constraints.gridwidth; w++)
+ {
+ width -= info.colWidths[x - w];
+ }
+ info.colWidths[x] = Math.max(info.colWidths[x], width);
+ info.colWeights[x] =
+ Math.max(info.colWeights[x], constraints.weightx);
+ }
+ }
+ }
+
+ for (y = 0; y <= max_y; y++)
+ {
+ if(rowHeights != null && rowHeights.length > y)
+ {
+ info.rowHeights[y] = rowHeights[y];
+ }
+ if(rowWeights != null && rowWeights.length > y)
+ {
+ info.rowWeights[y] = rowWeights[y];
+ }
+ for (int i = 0; i < components.length; i++)
+ {
+ Component component = components [i];
+
+ // If component is not visible we dont have to care about it.
+ if (!component.isVisible())
+ continue;
+
+ GridBagConstraints constraints = lookupConstraints (component);
+
+ if(constraints.gridy + constraints.gridheight - 1 == y)
+ {
+ int height = (sizeflag == PREFERREDSIZE) ?
+ component.getPreferredSize().height :
+ component.getMinimumSize().height;
+ if(constraints.insets != null)
+ {
+ height += constraints.insets.top + constraints.insets.bottom;
+ }
+ height += constraints.ipady;
+ for(int h = 1; h < constraints.gridheight; h++)
+ {
+ height -= info.rowHeights[y - h];
+ }
+ info.rowHeights[y] = Math.max(info.rowHeights[y], height);
+ info.rowWeights[y] =
+ Math.max(info.rowWeights[y], constraints.weighty);
+ }
+ }
+ }
+
+ calcCellSizes (info.colWidths, info.colWeights, parentDim.width);
+ calcCellSizes (info.rowHeights, info.rowWeights, parentDim.height);
+
+ int totalWidth = sumIntArray(info.colWidths);
+ int totalHeight = sumIntArray(info.rowHeights);
+ info.pos_x = parentInsets.left + (parentDim.width - totalWidth) / 2;
+ info.pos_y = parentInsets.top + (parentDim.height - totalHeight) / 2;
+
+ // DEBUG
+ //dumpLayoutInfo (info);
+
+ return info;
}
/**
@@ -326,7 +588,13 @@ public class GridBagLayout
*/
protected Dimension GetMinSize (Container parent, GridBagLayoutInfo info)
{
- return getMinSize (parent, info);
+ if (parent == null || info == null)
+ return new Dimension (0, 0);
+
+ Insets insets = parent.getInsets();
+ int width = sumIntArray (info.colWidths) + insets.left + insets.right;
+ int height = sumIntArray (info.rowHeights) + insets.top + insets.bottom;
+ return new Dimension (width, height);
}
/**
@@ -334,13 +602,7 @@ public class GridBagLayout
*/
protected Dimension getMinSize (Container parent, GridBagLayoutInfo info)
{
- if (parent == null || info == null)
- return new Dimension (0, 0);
-
- Insets insets = parent.getInsets();
- int width = sumIntArray (info.colWidths) + insets.left + insets.right;
- int height = sumIntArray (info.rowHeights) + insets.top + insets.bottom;
- return new Dimension (width, height);
+ return GetMinSize (parent, info);
}
private void calcCellSizes (int[] sizes, double[] weights, int range)
@@ -404,116 +666,7 @@ public class GridBagLayout
*/
protected void arrangeGrid (Container parent)
{
- Component[] components = parent.getComponents();
-
- if (components.length == 0)
- return;
-
- GridBagLayoutInfo info = getLayoutInfo (parent, PREFERREDSIZE);
- if (info.cols == 0 && info.rows == 0)
- return;
- layoutInfo = info;
-
- // DEBUG
- //dumpLayoutInfo (layoutInfo);
-
- for(int i = 0; i < components.length; i++)
- {
- Component component = components [i];
-
- // If component is not visible we dont have to care about it.
- if (!component.isVisible())
- continue;
-
- GridBagConstraints constraints = lookupConstraints (component);
-
- int cellx = sumIntArray(layoutInfo.colWidths, constraints.gridx);
- int celly = sumIntArray(layoutInfo.rowHeights, constraints.gridy);
- int cellw = sumIntArray(layoutInfo.colWidths,
- constraints.gridx + constraints.gridwidth) - cellx;
- int cellh = sumIntArray(layoutInfo.rowHeights,
- constraints.gridy + constraints.gridheight) - celly;
-
- Insets insets = constraints.insets;
- if (insets != null)
- {
- cellx += insets.left;
- celly += insets.top;
- cellw -= insets.left + insets.right;
- cellh -= insets.top + insets.bottom;
- }
-
- Dimension dim = component.preferredSize();
-
- // Note: Documentation says that padding is added on both sides, but
- // visual inspection shows that the Sun implementation only adds it
- // once, so we do the same.
- dim.width += constraints.ipadx;
- dim.height += constraints.ipady;
-
- switch(constraints.fill)
- {
- case GridBagConstraints.HORIZONTAL:
- dim.width = cellw;
- break;
- case GridBagConstraints.VERTICAL:
- dim.height = cellh;
- break;
- case GridBagConstraints.BOTH:
- dim.width = cellw;
- dim.height = cellh;
- break;
- }
-
- int x;
- int y;
-
- switch(constraints.anchor)
- {
- case GridBagConstraints.NORTH:
- x = cellx + (cellw - dim.width) / 2;
- y = celly;
- break;
- case GridBagConstraints.SOUTH:
- x = cellx + (cellw - dim.width) / 2;
- y = celly + cellh - dim.height;
- break;
- case GridBagConstraints.WEST:
- x = cellx;
- y = celly + (cellh - dim.height) / 2;
- break;
- case GridBagConstraints.EAST:
- x = cellx + cellw - dim.width;
- y = celly + (cellh - dim.height) / 2;
- break;
- case GridBagConstraints.NORTHEAST:
- x = cellx + cellw - dim.width;
- y = celly;
- break;
- case GridBagConstraints.NORTHWEST:
- x = cellx;
- y = celly;
- break;
- case GridBagConstraints.SOUTHEAST:
- x = cellx + cellw - dim.width;
- y = celly + cellh - dim.height;
- break;
- case GridBagConstraints.SOUTHWEST:
- x = cellx;
- y = celly + cellh - dim.height;
- break;
- default:
- x = cellx + (cellw - dim.width) / 2;
- y = celly + (cellh - dim.height) / 2;
- break;
- }
-
- component.setBounds(layoutInfo.pos_x + x, layoutInfo.pos_y + y, dim.width, dim.height);
- }
-
- // DEBUG
- //dumpLayoutInfo (layoutInfo);
-
+ ArrangeGrid (parent);
}
/**
@@ -521,160 +674,7 @@ public class GridBagLayout
*/
protected GridBagLayoutInfo getLayoutInfo (Container parent, int sizeflag)
{
- if (sizeflag != MINSIZE && sizeflag != PREFERREDSIZE)
- throw new IllegalArgumentException();
-
- Dimension parentDim = parent.size();
- Insets parentInsets = parent.insets();
- parentDim.width -= parentInsets.left + parentInsets.right;
- parentDim.height -= parentInsets.top + parentInsets.bottom;
-
- int x = 0;
- int y = 0;
- int max_x = 0;
- int max_y = 0;
-
- // first we figure out how many rows/columns
- Component[] components = parent.getComponents();
- for (int i = 0; i < components.length; i++)
- {
- Component component = components [i];
-
- // If component is not visible we dont have to care about it.
- if (!component.isVisible())
- continue;
-
- GridBagConstraints constraints = lookupConstraints (component);
-
- if(constraints.gridx == GridBagConstraints.RELATIVE)
- constraints.gridx = x;
-
- if(constraints.gridy == GridBagConstraints.RELATIVE)
- constraints.gridy = y;
-
- max_x = Math.max(max_x,
- constraints.gridx + Math.max(1, constraints.gridwidth));
- max_y = Math.max(max_y,
- constraints.gridy + Math.max(1, constraints.gridheight));
-
- if(constraints.gridwidth == GridBagConstraints.REMAINDER)
- {
- x = 0;
- y++;
- }
- else
- {
- x = constraints.gridx + Math.max(1, constraints.gridwidth);
- y = constraints.gridy;
- }
- }
-
- GridBagLayoutInfo info = new GridBagLayoutInfo(max_x, max_y);
-
- for (x = 0; x <= max_x; x++)
- {
- if(columnWidths != null && columnWidths.length > x)
- {
- info.colWidths[x] = columnWidths[x];
- }
- if(columnWeights != null && columnWeights.length > x)
- {
- info.colWeights[x] = columnWeights[x];
- }
- for (int i = 0; i < components.length; i++)
- {
- Component component = components [i];
-
- // If component is not visible we dont have to care about it.
- if (!component.isVisible())
- continue;
-
- GridBagConstraints constraints = lookupConstraints (component);
-
- // first we fix up any REMAINDER cells
- if(constraints.gridwidth == GridBagConstraints.REMAINDER)
- {
- constraints.gridwidth = max_x - constraints.gridx;
- }
- if(constraints.gridheight == GridBagConstraints.REMAINDER)
- {
- constraints.gridheight = max_y - constraints.gridy;
- }
-
- if(constraints.gridx + constraints.gridwidth - 1 == x)
- {
- int width = (sizeflag == PREFERREDSIZE) ?
- component.preferredSize().width :
- component.minimumSize().width;
- if(constraints.insets != null)
- {
- width += constraints.insets.left + constraints.insets.right;
- }
- width += constraints.ipadx;
- for(int w = 1; w < constraints.gridwidth; w++)
- {
- width -= info.colWidths[x - w];
- }
- info.colWidths[x] = Math.max(info.colWidths[x], width);
- info.colWeights[x] =
- Math.max(info.colWeights[x], constraints.weightx);
- }
- }
- }
-
- for (y = 0; y <= max_y; y++)
- {
- if(rowHeights != null && rowHeights.length > y)
- {
- info.rowHeights[y] = rowHeights[y];
- }
- if(rowWeights != null && rowWeights.length > y)
- {
- info.rowWeights[y] = rowWeights[y];
- }
- for (int i = 0; i < components.length; i++)
- {
- Component component = components [i];
-
- // If component is not visible we dont have to care about it.
- if (!component.isVisible())
- continue;
-
- GridBagConstraints constraints = lookupConstraints (component);
-
- if(constraints.gridy + constraints.gridheight - 1 == y)
- {
- int height = (sizeflag == PREFERREDSIZE) ?
- component.preferredSize().height :
- component.minimumSize().height;
- if(constraints.insets != null)
- {
- height += constraints.insets.top + constraints.insets.bottom;
- }
- height += constraints.ipady;
- for(int h = 1; h < constraints.gridheight; h++)
- {
- height -= info.rowHeights[y - h];
- }
- info.rowHeights[y] = Math.max(info.rowHeights[y], height);
- info.rowWeights[y] =
- Math.max(info.rowWeights[y], constraints.weighty);
- }
- }
- }
-
- calcCellSizes (info.colWidths, info.colWeights, parentDim.width);
- calcCellSizes (info.rowHeights, info.rowWeights, parentDim.height);
-
- int totalWidth = sumIntArray(info.colWidths);
- int totalHeight = sumIntArray(info.rowHeights);
- info.pos_x = parentInsets.left + (parentDim.width - totalWidth) / 2;
- info.pos_y = parentInsets.top + (parentDim.height - totalHeight) / 2;
-
- // DEBUG
- //dumpLayoutInfo (info);
-
- return info;
+ return GetLayoutInfo (parent, sizeflag);
}
/**
@@ -682,7 +682,6 @@ public class GridBagLayout
*/
protected void adjustForGravity (GridBagConstraints gbc, Rectangle rect)
{
- // FIXME
- throw new Error ("Not implemented");
+ AdjustForGravity (gbc, rect);
}
}
diff --git a/java/awt/LayoutManager2.java b/java/awt/LayoutManager2.java
index 418e4d886..802e25e66 100644
--- a/java/awt/LayoutManager2.java
+++ b/java/awt/LayoutManager2.java
@@ -52,12 +52,12 @@ public interface LayoutManager2 extends LayoutManager
{
/**
* Adds the specified component to the layout, with the specified
- * constraint object.
+ * constraints object.
*
* @param component the component to add
- * @param constraint the constraint to satisfy
+ * @param constraints the constraints to satisfy
*/
- void addLayoutComponent(Component component, Object contraint);
+ void addLayoutComponent(Component component, Object contraints);
/**
* Determines the maximum size of the specified target container.
diff --git a/java/awt/List.java b/java/awt/List.java
index 79b2faa62..47177edc7 100644
--- a/java/awt/List.java
+++ b/java/awt/List.java
@@ -175,7 +175,7 @@ List(int rows, boolean multipleMode)
public int
getItemCount()
{
- return(items.size());
+ return countItems ();
}
/*************************************************************************/
@@ -191,7 +191,7 @@ getItemCount()
public int
countItems()
{
- return(getItemCount());
+ return items.size ();
}
/*************************************************************************/
@@ -249,7 +249,7 @@ getRows()
public boolean
isMultipleMode()
{
- return(multipleMode);
+ return allowsMultipleSelections ();
}
/*************************************************************************/
@@ -266,7 +266,7 @@ isMultipleMode()
public boolean
allowsMultipleSelections()
{
- return(multipleMode);
+ return multipleMode;
}
/*************************************************************************/
@@ -281,12 +281,7 @@ allowsMultipleSelections()
public void
setMultipleMode(boolean multipleMode)
{
- this.multipleMode = multipleMode;
- if (peer != null)
- {
- ListPeer l = (ListPeer) peer;
- l.setMultipleMode (multipleMode);
- }
+ setMultipleSelections (multipleMode);
}
/*************************************************************************/
@@ -303,7 +298,11 @@ setMultipleMode(boolean multipleMode)
public void
setMultipleSelections(boolean multipleMode)
{
- setMultipleMode(multipleMode);
+ this.multipleMode = multipleMode;
+
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ peer.setMultipleMode (multipleMode);
}
/*************************************************************************/
@@ -316,7 +315,7 @@ setMultipleSelections(boolean multipleMode)
public Dimension
getMinimumSize()
{
- return(getMinimumSize(rows));
+ return getMinimumSize (getRows ());
}
/*************************************************************************/
@@ -332,7 +331,7 @@ getMinimumSize()
public Dimension
minimumSize()
{
- return(getMinimumSize(rows));
+ return minimumSize (getRows ());
}
/*************************************************************************/
@@ -348,11 +347,7 @@ minimumSize()
public Dimension
getMinimumSize(int rows)
{
- ListPeer lp = (ListPeer)getPeer();
- if (lp != null)
- return(lp.minimumSize(rows));
- else
- return(new Dimension(0,0));
+ return minimumSize (rows);
}
/*************************************************************************/
@@ -371,7 +366,11 @@ getMinimumSize(int rows)
public Dimension
minimumSize(int rows)
{
- return(getMinimumSize(rows));
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ return peer.minimumSize (rows);
+ else
+ return new Dimension (0, 0);
}
/*************************************************************************/
@@ -384,7 +383,7 @@ minimumSize(int rows)
public Dimension
getPreferredSize()
{
- return(getPreferredSize(rows));
+ return getPreferredSize (getRows ());
}
/*************************************************************************/
@@ -400,7 +399,7 @@ getPreferredSize()
public Dimension
preferredSize()
{
- return(getPreferredSize(rows));
+ return preferredSize (getRows ());
}
/*************************************************************************/
@@ -416,11 +415,7 @@ preferredSize()
public Dimension
getPreferredSize(int rows)
{
- ListPeer lp = (ListPeer)getPeer();
- if (lp != null)
- return(lp.preferredSize(rows));
- else
- return(new Dimension(0,0));
+ return preferredSize (rows);
}
/*************************************************************************/
@@ -439,7 +434,11 @@ getPreferredSize(int rows)
public Dimension
preferredSize(int rows)
{
- return(getPreferredSize(rows));
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ return peer.preferredSize (rows);
+ else
+ return new Dimension (0, 0);
}
/*************************************************************************/
@@ -452,7 +451,7 @@ preferredSize(int rows)
public void
add(String item)
{
- add(item, -1);
+ add (item, -1);
}
/*************************************************************************/
@@ -467,7 +466,7 @@ add(String item)
public void
addItem(String item)
{
- addItem(item, -1);
+ addItem (item, -1);
}
/*************************************************************************/
@@ -484,16 +483,7 @@ addItem(String item)
public void
add(String item, int index)
{
- if ((index == -1) || (index >= items.size()))
- items.addElement(item);
- else
- items.insertElementAt(item, index);
-
- if (peer != null)
- {
- ListPeer l = (ListPeer) peer;
- l.add (item, index);
- }
+ addItem (item, index);
}
/*************************************************************************/
@@ -512,7 +502,14 @@ add(String item, int index)
public void
addItem(String item, int index)
{
- add(item, index);
+ if ((index == -1) || (index >= items.size ()))
+ items.addElement (item);
+ else
+ items.insertElementAt (item, index);
+
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ peer.add (item, index);
}
/*************************************************************************/
@@ -529,7 +526,11 @@ addItem(String item, int index)
public void
delItem(int index) throws IllegalArgumentException
{
- remove(index);
+ items.removeElementAt (index);
+
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ peer.delItems (index, index);
}
/*************************************************************************/
@@ -544,12 +545,7 @@ delItem(int index) throws IllegalArgumentException
public void
remove(int index) throws IllegalArgumentException
{
- items.removeElementAt (index);
- if (peer != null)
- {
- ListPeer l = (ListPeer) peer;
- l.delItems (index, index);
- }
+ delItem (index);
}
/*************************************************************************/
@@ -613,12 +609,7 @@ remove(String item) throws IllegalArgumentException
public synchronized void
removeAll()
{
- items.clear();
- if (peer != null)
- {
- ListPeer l = (ListPeer) peer;
- l.removeAll ();
- }
+ clear ();
}
/*************************************************************************/
@@ -631,7 +622,11 @@ removeAll()
public void
clear()
{
- removeAll();
+ items.clear();
+
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ peer.removeAll ();
}
/*************************************************************************/
@@ -782,13 +777,7 @@ getSelectedObjects()
public boolean
isIndexSelected(int index)
{
- int[] indexes = getSelectedIndexes();
-
- for (int i = 0; i < indexes.length; i++)
- if (indexes[i] == index)
- return(true);
-
- return(false);
+ return isSelected (index);
}
/*************************************************************************/
@@ -807,7 +796,13 @@ isIndexSelected(int index)
public boolean
isSelected(int index)
{
- return(isIndexSelected(index));
+ int[] indexes = getSelectedIndexes ();
+
+ for (int i = 0; i < indexes.length; i++)
+ if (indexes[i] == index)
+ return true;
+
+ return false;
}
/*************************************************************************/
diff --git a/java/awt/Menu.java b/java/awt/Menu.java
index 7fb293118..74478fbca 100644
--- a/java/awt/Menu.java
+++ b/java/awt/Menu.java
@@ -171,7 +171,7 @@ isTearOff()
public int
getItemCount()
{
- return(items.size());
+ return countItems ();
}
/**
@@ -183,7 +183,7 @@ getItemCount()
*/
public int countItems ()
{
- return getItemCount ();
+ return items.size ();
}
/*************************************************************************/
diff --git a/java/awt/MenuBar.java b/java/awt/MenuBar.java
index 9c278dfde..fb2672900 100644
--- a/java/awt/MenuBar.java
+++ b/java/awt/MenuBar.java
@@ -219,8 +219,7 @@ remove(MenuComponent menu)
public int
getMenuCount()
{
- // FIXME: How does the help menu fit in here?
- return(menus.size());
+ return countMenus ();
}
/*************************************************************************/
@@ -235,7 +234,8 @@ getMenuCount()
public int
countMenus()
{
- return(getMenuCount());
+ // FIXME: How does the help menu fit in here?
+ return menus.size ();
}
/*************************************************************************/
diff --git a/java/awt/MenuItem.java b/java/awt/MenuItem.java
index bea3b4fd4..cfdfafcc8 100644
--- a/java/awt/MenuItem.java
+++ b/java/awt/MenuItem.java
@@ -202,15 +202,7 @@ isEnabled()
public synchronized void
setEnabled(boolean enabled)
{
- if (enabled == this.enabled)
- return;
-
- this.enabled = enabled;
- if (peer != null)
- {
- MenuItemPeer mp = (MenuItemPeer) peer;
- mp.setEnabled (enabled);
- }
+ enable (enabled);
}
/*************************************************************************/
@@ -226,7 +218,10 @@ setEnabled(boolean enabled)
public void
enable(boolean enabled)
{
- setEnabled(enabled);
+ if (enabled)
+ enable ();
+ else
+ disable ();
}
/*************************************************************************/
@@ -239,7 +234,12 @@ enable(boolean enabled)
public void
enable()
{
- setEnabled(true);
+ if (enabled)
+ return;
+
+ this.enabled = true;
+ if (peer != null)
+ ((MenuItemPeer) peer).setEnabled (true);
}
/*************************************************************************/
@@ -252,7 +252,12 @@ enable()
public void
disable()
{
- setEnabled(false);
+ if (!enabled)
+ return;
+
+ this.enabled = false;
+ if (peer != null)
+ ((MenuItemPeer) peer).setEnabled (false);
}
/*************************************************************************/
diff --git a/java/awt/Polygon.java b/java/awt/Polygon.java
index 113dad992..e91144c88 100644
--- a/java/awt/Polygon.java
+++ b/java/awt/Polygon.java
@@ -258,10 +258,24 @@ public class Polygon implements Shape, Serializable
*/
public Rectangle getBounds()
{
+ return getBoundingBox ();
+ }
+
+ /**
+ * Returns the bounding box of this polygon. This is the smallest
+ * rectangle with sides parallel to the X axis that will contain this
+ * polygon.
+ *
+ * @return the bounding box for this polygon
+ * @see #getBounds2D()
+ * @deprecated use {@link #getBounds()} instead
+ */
+ public Rectangle getBoundingBox()
+ {
if (bounds == null)
{
if (npoints == 0)
- return bounds = new Rectangle();
+ return bounds = new Rectangle ();
int i = npoints - 1;
int minx = xpoints[i];
int maxx = minx;
@@ -280,26 +294,12 @@ public class Polygon implements Shape, Serializable
else if (y > maxy)
maxy = y;
}
- bounds = new Rectangle(minx, maxy, maxx - minx, maxy - miny);
+ bounds = new Rectangle (minx, maxy, maxx - minx, maxy - miny);
}
return bounds;
}
/**
- * Returns the bounding box of this polygon. This is the smallest
- * rectangle with sides parallel to the X axis that will contain this
- * polygon.
- *
- * @return the bounding box for this polygon
- * @see #getBounds2D()
- * @deprecated use {@link #getBounds()} instead
- */
- public Rectangle getBoundingBox()
- {
- return getBounds();
- }
-
- /**
* Tests whether or not the specified point is inside this polygon.
*
* @param p the point to test
diff --git a/java/awt/Rectangle.java b/java/awt/Rectangle.java
index 48a2fbec0..c3340bb8e 100644
--- a/java/awt/Rectangle.java
+++ b/java/awt/Rectangle.java
@@ -281,10 +281,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public void setBounds(Rectangle r)
{
- x = r.x;
- y = r.y;
- width = r.width;
- height = r.height;
+ setBounds (r.x, r.y, r.width, r.height);
}
/**
@@ -298,10 +295,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public void setBounds(int x, int y, int width, int height)
{
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
+ reshape (x, y, width, height);
}
/**
@@ -333,7 +327,10 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public void reshape(int x, int y, int width, int height)
{
- setBounds(x, y, width, height);
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
}
/**
@@ -360,8 +357,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public void setLocation(Point p)
{
- this.x = p.x;
- this.y = p.y;
+ setLocation (p.x, p.y);
}
/**
@@ -374,8 +370,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public void setLocation(int x, int y)
{
- this.x = x;
- this.y = y;
+ move (x, y);
}
/**
@@ -388,7 +383,8 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public void move(int x, int y)
{
- setLocation(x, y);
+ this.x = x;
+ this.y = y;
}
/**
@@ -426,8 +422,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public void setSize(Dimension d)
{
- width = d.width;
- height = d.height;
+ setSize (d.width, d.height);
}
/**
@@ -439,8 +434,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public void setSize(int width, int height)
{
- this.width = width;
- this.height = height;
+ resize (width, height);
}
/**
@@ -452,7 +446,8 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public void resize(int width, int height)
{
- setSize(width, height);
+ this.width = width;
+ this.height = height;
}
/**
@@ -469,9 +464,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public boolean contains(Point p)
{
- return width > 0 && height > 0
- && p.x >= x && p.x < x + width
- && p.y >= y && p.y < y + height;
+ return contains (p.x, p.y);
}
/**
@@ -487,9 +480,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public boolean contains(int x, int y)
{
- return width > 0 && height > 0
- && x >= this.x && x < this.x + width
- && y >= this.y && y < this.y + height;
+ return inside (x, y);
}
/**
@@ -504,9 +495,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public boolean contains(Rectangle r)
{
- return width > 0 && height > 0 && r.width > 0 && r.height > 0
- && r.x >= x && r.x + r.width <= x + width
- && r.y >= y && r.y + r.height <= y + height;
+ return contains (r.x, r.y, r.width, r.height);
}
/**
@@ -537,7 +526,9 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public boolean inside(int x, int y)
{
- return contains(x, y);
+ return width > 0 && height > 0
+ && x >= this.x && x < this.x + width
+ && y >= this.y && y < this.y + height;
}
/**
diff --git a/java/awt/ScrollPane.java b/java/awt/ScrollPane.java
index 937568a62..b772bee38 100644
--- a/java/awt/ScrollPane.java
+++ b/java/awt/ScrollPane.java
@@ -446,10 +446,25 @@ removeNotify()
public void
doLayout()
{
- Component[] list = getComponents();
+ layout ();
+}
+
+/*************************************************************************/
+
+/**
+ * Lays out this component. This consists of resizing the sole child
+ * component to its perferred size.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>doLayout()</code>.
+ */
+public void
+layout()
+{
+ Component[] list = getComponents ();
if ((list != null) && (list.length > 0))
{
- Dimension dim = list[0].getPreferredSize();
+ Dimension dim = list[0].getPreferredSize ();
Dimension vp = getViewportSize ();
if (dim.width < vp.width)
@@ -462,36 +477,21 @@ doLayout()
if (peer != null)
peer.childResized (dim.width, dim.height);
- list[0].resize (dim);
+ list[0].setSize (dim);
- Point p = getScrollPosition();
+ Point p = getScrollPosition ();
if (p.x > dim.width)
p.x = dim.width;
if (p.y > dim.height)
p.y = dim.height;
- setScrollPosition(p);
+ setScrollPosition (p);
}
}
/*************************************************************************/
/**
- * Lays out this component. This consists of resizing the sole child
- * component to its perferred size.
- *
- * @deprecated This method is deprecated in favor of
- * <code>doLayout()</code>.
- */
-public void
-layout()
-{
- doLayout();
-}
-
-/*************************************************************************/
-
-/**
* This method overrides its superclass method to ensure no layout
* manager is set for this container. <code>ScrollPane</code>'s do
* not have layout managers.
diff --git a/java/awt/Scrollbar.java b/java/awt/Scrollbar.java
index 85ac117e6..6b88ca6c8 100644
--- a/java/awt/Scrollbar.java
+++ b/java/awt/Scrollbar.java
@@ -333,7 +333,7 @@ setMinimum(int minimum)
public int
getVisibleAmount()
{
- return(visibleAmount);
+ return getVisible ();
}
/*************************************************************************/
@@ -350,7 +350,7 @@ getVisibleAmount()
public int
getVisible()
{
- return(getVisibleAmount());
+ return visibleAmount;
}
/*************************************************************************/
@@ -438,7 +438,7 @@ setValues(int value, int visibleAmount, int minimum, int maximum)
public int
getUnitIncrement()
{
- return(lineIncrement);
+ return getLineIncrement ();
}
/*************************************************************************/
@@ -455,7 +455,7 @@ getUnitIncrement()
public int
getLineIncrement()
{
- return(lineIncrement);
+ return lineIncrement;
}
/*************************************************************************/
@@ -469,26 +469,7 @@ getLineIncrement()
public synchronized void
setUnitIncrement(int unitIncrement)
{
- if (unitIncrement < 0)
- throw new IllegalArgumentException("Unit increment less than zero.");
-
- int range = maximum - minimum;
- if (unitIncrement > range)
- {
- if (range == 0)
- unitIncrement = 1;
- else
- unitIncrement = range;
- }
-
- if (unitIncrement == lineIncrement)
- return;
-
- lineIncrement = unitIncrement;
-
- ScrollbarPeer sp = (ScrollbarPeer)getPeer();
- if (sp != null)
- sp.setLineIncrement(lineIncrement);
+ setLineIncrement (unitIncrement);
}
/*************************************************************************/
@@ -505,7 +486,26 @@ setUnitIncrement(int unitIncrement)
public void
setLineIncrement(int lineIncrement)
{
- setUnitIncrement(lineIncrement);
+ if (lineIncrement < 0)
+ throw new IllegalArgumentException ("Unit increment less than zero.");
+
+ int range = maximum - minimum;
+ if (lineIncrement > range)
+ {
+ if (range == 0)
+ lineIncrement = 1;
+ else
+ lineIncrement = range;
+ }
+
+ if (lineIncrement == this.lineIncrement)
+ return;
+
+ this.lineIncrement = lineIncrement;
+
+ ScrollbarPeer sp = (ScrollbarPeer) getPeer ();
+ if (sp != null)
+ sp.setLineIncrement (this.lineIncrement);
}
/*************************************************************************/
@@ -519,7 +519,7 @@ setLineIncrement(int lineIncrement)
public int
getBlockIncrement()
{
- return(pageIncrement);
+ return getPageIncrement ();
}
/*************************************************************************/
@@ -536,7 +536,7 @@ getBlockIncrement()
public int
getPageIncrement()
{
- return(pageIncrement);
+ return pageIncrement;
}
/*************************************************************************/
@@ -550,26 +550,7 @@ getPageIncrement()
public synchronized void
setBlockIncrement(int blockIncrement)
{
- if (blockIncrement < 0)
- throw new IllegalArgumentException("Block increment less than zero.");
-
- int range = maximum - minimum;
- if (blockIncrement > range)
- {
- if (range == 0)
- blockIncrement = 1;
- else
- blockIncrement = range;
- }
-
- if (blockIncrement == pageIncrement)
- return;
-
- pageIncrement = blockIncrement;
-
- ScrollbarPeer sp = (ScrollbarPeer)getPeer();
- if (sp != null)
- sp.setPageIncrement(pageIncrement);
+ setPageIncrement (pageIncrement);
}
/*************************************************************************/
@@ -586,7 +567,26 @@ setBlockIncrement(int blockIncrement)
public void
setPageIncrement(int pageIncrement)
{
- setBlockIncrement(pageIncrement);
+ if (pageIncrement < 0)
+ throw new IllegalArgumentException ("Block increment less than zero.");
+
+ int range = maximum - minimum;
+ if (pageIncrement > range)
+ {
+ if (range == 0)
+ pageIncrement = 1;
+ else
+ pageIncrement = range;
+ }
+
+ if (pageIncrement == this.pageIncrement)
+ return;
+
+ this.pageIncrement = pageIncrement;
+
+ ScrollbarPeer sp = (ScrollbarPeer) getPeer ();
+ if (sp != null)
+ sp.setPageIncrement (this.pageIncrement);
}
/*************************************************************************/
diff --git a/java/awt/TextArea.java b/java/awt/TextArea.java
index 356efeb92..6f60ee69c 100644
--- a/java/awt/TextArea.java
+++ b/java/awt/TextArea.java
@@ -288,13 +288,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/
public Dimension getMinimumSize (int rows, int columns)
{
- TextAreaPeer peer = (TextAreaPeer) getPeer ();
-
- // Sun returns Dimension (0,0) in this case.
- if (peer == null)
- return new Dimension (0, 0);
-
- return peer.getMinimumSize (rows, columns);
+ return minimumSize (rows, columns);
}
/**
@@ -311,7 +305,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/
public Dimension minimumSize ()
{
- return getMinimumSize (getRows (), getColumns ());
+ return minimumSize (getRows (), getColumns ());
}
/**
@@ -333,7 +327,13 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/
public Dimension minimumSize (int rows, int columns)
{
- return getMinimumSize (rows, columns);
+ TextAreaPeer peer = (TextAreaPeer) getPeer ();
+
+ // Sun returns Dimension (0,0) in this case.
+ if (peer == null)
+ return new Dimension (0, 0);
+
+ return peer.getMinimumSize (rows, columns);
}
/**
@@ -366,13 +366,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/
public Dimension getPreferredSize (int rows, int columns)
{
- TextAreaPeer peer = (TextAreaPeer) getPeer ();
-
- // Sun returns Dimension (0,0) in this case.
- if (peer == null)
- return new Dimension (0, 0);
-
- return peer.getPreferredSize (rows, columns);
+ return preferredSize (rows, columns);
}
/**
@@ -389,7 +383,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/
public Dimension preferredSize ()
{
- return getPreferredSize (getRows (), getColumns ());
+ return preferredSize (getRows (), getColumns ());
}
/**
@@ -411,7 +405,13 @@ public class TextArea extends TextComponent implements java.io.Serializable
*/
public Dimension preferredSize (int rows, int columns)
{
- return getPreferredSize (rows, columns);
+ TextAreaPeer peer = (TextAreaPeer) getPeer ();
+
+ // Sun returns Dimension (0,0) in this case.
+ if (peer == null)
+ return new Dimension (0, 0);
+
+ return peer.getPreferredSize (rows, columns);
}
/**
@@ -440,59 +440,59 @@ public class TextArea extends TextComponent implements java.io.Serializable
/**
* Append the specified text to the end of the current text.
*
- * @param text The text to append.
+ * @param str The text to append.
*/
public void append (String str)
{
- TextAreaPeer peer = (TextAreaPeer) getPeer ();
- if (peer == null)
- return;
-
- peer.insert (str, peer.getText().length ());
+ appendText (str);
}
/**
* Append the specified text to the end of the current text.
*
- * @param text The text to append.
+ * @param str The text to append.
*
* @deprecated This method is deprecated in favor of
* <code>append ()</code>.
*/
- public void appendText (String text)
+ public void appendText (String str)
{
- append (text);
+ TextAreaPeer peer = (TextAreaPeer) getPeer ();
+ if (peer == null)
+ return;
+
+ peer.insert (str, peer.getText().length ());
}
/**
* Insert the specified text at the specified position. The first
* character in the text area is at position zero.
*
- * @param text The text to insert.
+ * @param str The text to insert.
* @param pos The position at which to insert text.
*/
- public void insert (String text, int pos)
+ public void insert (String str, int pos)
{
- TextAreaPeer peer = (TextAreaPeer) getPeer ();
- if (peer == null)
- return;
-
- peer.insert (text, pos);
+ insertText (str, pos);
}
/**
* Insert the specified text at the specified position. The first
* character in the text area is at position zero.
*
- * @param text The text to insert.
+ * @param str The text to insert.
* @param pos The position at which to insert text.
*
- * @deprecated This method is depcreated in favor of
+ * @deprecated This method is deprecated in favor of
* <code>insert ()</code>.
*/
- public void insertText (String text, int pos)
+ public void insertText (String str, int pos)
{
- insert (text, pos);
+ TextAreaPeer peer = (TextAreaPeer) getPeer ();
+ if (peer == null)
+ return;
+
+ peer.insert (str, pos);
}
/**
@@ -503,17 +503,13 @@ public class TextArea extends TextComponent implements java.io.Serializable
* length of the replacement text may differ from the length of the
* text that is replaced.
*
- * @param text The new text for the range.
+ * @param str The new text for the range.
* @param start The start position of the replacement range.
* @param end The end position of the replacement range.
*/
- public void replaceRange (String text, int start, int end)
+ public void replaceRange (String str, int start, int end)
{
- TextAreaPeer peer = (TextAreaPeer) getPeer ();
- if (peer == null)
- return;
-
- peer.replaceRange (text, start, end);
+ replaceText (str, start, end);
}
/**
@@ -524,16 +520,20 @@ public class TextArea extends TextComponent implements java.io.Serializable
* length of the replacement text may differ from the length of the
* text that is replaced.
*
- * @param text The new text for the range.
+ * @param str The new text for the range.
* @param start The start position of the replacement range.
* @param end The end position of the replacement range.
*
* @deprecated This method is deprecated in favor of
* <code>replaceRange ()</code>.
*/
- public void replaceText (String text, int start, int end)
+ public void replaceText (String str, int start, int end)
{
- replaceRange (text, start, end);
+ TextAreaPeer peer = (TextAreaPeer) getPeer ();
+ if (peer == null)
+ return;
+
+ peer.replaceRange (str, start, end);
}
/**
diff --git a/java/awt/TextField.java b/java/awt/TextField.java
index 7575e24d4..1a783e27a 100644
--- a/java/awt/TextField.java
+++ b/java/awt/TextField.java
@@ -212,11 +212,7 @@ getEchoChar()
public void
setEchoChar(char echoChar)
{
- this.echoChar = echoChar;
-
- TextFieldPeer tfp = (TextFieldPeer)getPeer();
- if (tfp != null)
- tfp.setEchoChar(echoChar);
+ setEchoCharacter (echoChar);
}
/*************************************************************************/
@@ -233,7 +229,11 @@ setEchoChar(char echoChar)
public void
setEchoCharacter(char echoChar)
{
- setEchoChar(echoChar);
+ this.echoChar = echoChar;
+
+ TextFieldPeer peer = (TextFieldPeer) getPeer ();
+ if (peer != null)
+ peer.setEchoChar (echoChar);
}
/*************************************************************************/
@@ -264,7 +264,7 @@ echoCharIsSet()
public Dimension
getMinimumSize()
{
- return(getMinimumSize(getColumns()));
+ return getMinimumSize (getColumns ());
}
/*************************************************************************/
@@ -278,11 +278,7 @@ getMinimumSize()
public Dimension
getMinimumSize(int columns)
{
- TextFieldPeer tfp = (TextFieldPeer)getPeer();
- if (tfp == null)
- return(null); // FIXME: What do we do if there is no peer?
-
- return(tfp.getMinimumSize(columns));
+ return minimumSize (columns);
}
/*************************************************************************/
@@ -292,13 +288,13 @@ getMinimumSize(int columns)
*
* @return The minimum size for this text field.
*
- * @deprecated This method is depcreated in favor of
+ * @deprecated This method is deprecated in favor of
* <code>getMinimumSize()</code>.
*/
public Dimension
minimumSize()
{
- return(getMinimumSize(getColumns()));
+ return minimumSize (getColumns ());
}
/*************************************************************************/
@@ -315,7 +311,11 @@ minimumSize()
public Dimension
minimumSize(int columns)
{
- return(getMinimumSize(columns));
+ TextFieldPeer peer = (TextFieldPeer) getPeer ();
+ if (peer == null)
+ return null; // FIXME: What do we do if there is no peer?
+
+ return peer.getMinimumSize (columns);
}
/*************************************************************************/
@@ -328,7 +328,7 @@ minimumSize(int columns)
public Dimension
getPreferredSize()
{
- return(getPreferredSize(getColumns()));
+ return getPreferredSize (getColumns ());
}
/*************************************************************************/
@@ -342,12 +342,7 @@ getPreferredSize()
public Dimension
getPreferredSize(int columns)
{
- TextFieldPeer tfp = (TextFieldPeer)getPeer();
- if (tfp == null)
- {
- return new Dimension(0, 0);
- }
- return(tfp.getPreferredSize(columns));
+ return preferredSize (columns);
}
/*************************************************************************/
@@ -363,7 +358,7 @@ getPreferredSize(int columns)
public Dimension
preferredSize()
{
- return(getPreferredSize(getColumns()));
+ return preferredSize (getColumns ());
}
/*************************************************************************/
@@ -380,7 +375,11 @@ preferredSize()
public Dimension
preferredSize(int columns)
{
- return(getPreferredSize(columns));
+ TextFieldPeer peer = (TextFieldPeer) getPeer ();
+ if (peer == null)
+ return new Dimension (0, 0);
+
+ return peer.getPreferredSize (columns);
}
/*************************************************************************/
diff --git a/java/awt/image/renderable/RenderContext.java b/java/awt/image/renderable/RenderContext.java
index eca35ed66..81d84a45e 100644
--- a/java/awt/image/renderable/RenderContext.java
+++ b/java/awt/image/renderable/RenderContext.java
@@ -87,24 +87,24 @@ public class RenderContext implements Cloneable
public void preConcatenateTransform(AffineTransform pre)
{
- xform.preConcatenate(pre);
+ preConcetenateTransform (pre);
}
- /** @deprecated Sun can't spell concatenate */
+ /** @deprecated */
public void preConcetenateTransform(AffineTransform pre)
{
- preConcetenateTransform(pre);
+ xform.preConcatenate (pre);
}
public void concatenateTransform(AffineTransform post)
{
- xform.concatenate(post);
+ concetenateTransform (post);
}
- /** @deprecated Sun can't spell concatenate */
+ /** @deprecated */
public void concetenateTransform(AffineTransform post)
{
- concatenateTransform(post);
+ xform.concatenate (post);
}
public AffineTransform getTransform()