aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/ui/GridLayout.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/itmill/toolkit/ui/GridLayout.java')
-rw-r--r--src/com/itmill/toolkit/ui/GridLayout.java496
1 files changed, 272 insertions, 224 deletions
diff --git a/src/com/itmill/toolkit/ui/GridLayout.java b/src/com/itmill/toolkit/ui/GridLayout.java
index 3e2b7521ec..f0b957a11a 100644
--- a/src/com/itmill/toolkit/ui/GridLayout.java
+++ b/src/com/itmill/toolkit/ui/GridLayout.java
@@ -1,30 +1,30 @@
/* *************************************************************************
- IT Mill Toolkit
+ IT Mill Toolkit
- Development of Browser User Interfaces Made Easy
+ Development of Browser User Interfaces Made Easy
- Copyright (C) 2000-2006 IT Mill Ltd
-
- *************************************************************************
+ Copyright (C) 2000-2006 IT Mill Ltd
+
+ *************************************************************************
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might
- require purchasing a commercial license from IT Mill Ltd. For guidelines
- on usage, see licensing-guidelines.html
+ This product is distributed under commercial license that can be found
+ from the product package on license.pdf. Use of this product might
+ require purchasing a commercial license from IT Mill Ltd. For guidelines
+ on usage, see licensing-guidelines.html
- *************************************************************************
-
- For more information, contact:
-
- IT Mill Ltd phone: +358 2 4802 7180
- Ruukinkatu 2-4 fax: +358 2 4802 7181
- 20540, Turku email: info@itmill.com
- Finland company www: www.itmill.com
-
- Primary source for information and releases: www.itmill.com
+ *************************************************************************
+
+ For more information, contact:
+
+ IT Mill Ltd phone: +358 2 4802 7180
+ Ruukinkatu 2-4 fax: +358 2 4802 7181
+ 20540, Turku email: info@itmill.com
+ Finland company www: www.itmill.com
+
+ Primary source for information and releases: www.itmill.com
- ********************************************************************** */
+ ********************************************************************** */
package com.itmill.toolkit.ui;
@@ -36,127 +36,134 @@ import java.util.LinkedList;
import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
-/**
+/**
* <p>
- * A container that consists of components with certain coordinates on a
- * grid. It also maintains cursor for adding component in left to right,
- * top to bottom order.
+ * A container that consists of components with certain coordinates on a grid.
+ * It also maintains cursor for adding component in left to right, top to bottom
+ * order.
* </p>
*
* <p>
* Each component in a <code>GridLayout</code> uses a certain
- * {@link GridLayout.Area area} (x1,y1,x2,y2) from the grid. One should not
- * add components that would overlap with the existing components because in
- * such case an {@link OverlapsException} is thrown. Adding component with
- * cursor automatically extends the grid by increasing the grid height.
+ * {@link GridLayout.Area area} (x1,y1,x2,y2) from the grid. One should not add
+ * components that would overlap with the existing components because in such
+ * case an {@link OverlapsException} is thrown. Adding component with cursor
+ * automatically extends the grid by increasing the grid height.
* </p>
- *
+ *
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class GridLayout extends AbstractComponentContainer implements Layout {
- /**
- * Initial grid x size.
+ /**
+ * Initial grid x size.
*/
private int width = 0;
- /**
- * Initial grid y size.
+ /**
+ * Initial grid y size.
*/
private int height = 0;
- /**
- * Cursor X position: this is where the next component with
- * unspecified x,y is inserted
+ /**
+ * Cursor X position: this is where the next component with unspecified x,y
+ * is inserted
*/
private int cursorX = 0;
- /**
- * Cursor Y position: this is where the next component with
- * unspecified x,y is inserted
+ /**
+ * Cursor Y position: this is where the next component with unspecified x,y
+ * is inserted
*/
private int cursorY = 0;
- /**
- * Contains all items that are placed on the grid.
- * These are components with grid area definition.
+ /**
+ * Contains all items that are placed on the grid. These are components with
+ * grid area definition.
*/
private LinkedList areas = new LinkedList();
- /**
- * Mapping from components to threir respective areas.
+ /**
+ * Mapping from components to threir respective areas.
*/
private LinkedList components = new LinkedList();
- /**
- * Constructor for grid of given size.
- * Note that grid's final size depends on the items that are added into the grid.
- * Grid grows if you add components outside the grid's area.
- * @param width the Width of the grid.
- * @param height the Height of the grid.
+ /**
+ * Constructor for grid of given size. Note that grid's final size depends
+ * on the items that are added into the grid. Grid grows if you add
+ * components outside the grid's area.
+ *
+ * @param width
+ * the Width of the grid.
+ * @param height
+ * the Height of the grid.
*/
public GridLayout(int width, int height) {
setWidth(width);
setHeight(height);
}
- /**
- * Constructs an empty grid layout that is extended as needed.
+ /**
+ * Constructs an empty grid layout that is extended as needed.
*/
public GridLayout() {
this(1, 1);
}
- /**
+ /**
* <p>
- * Adds a component with a specified area to the grid. The area the
- * new component should take is defined by specifying the upper left
- * corner (x1, y1) and the lower right corner (x2, y2) of the area.
+ * Adds a component with a specified area to the grid. The area the new
+ * component should take is defined by specifying the upper left corner (x1,
+ * y1) and the lower right corner (x2, y2) of the area.
* </p>
*
* <p>
- * If the new component overlaps with any of the existing components
- * already present in the grid the operation will fail and an
+ * If the new component overlaps with any of the existing components already
+ * present in the grid the operation will fail and an
* {@link OverlapsException} is thrown.
* </p>
*
- * @param c the component to be added.
- * @param x1 the X-coordinate of the upper left corner of the area
- * <code>c</code> is supposed to occupy.
- * @param y1 the Y-coordinate of the upper left corner of the area
- * <code>c</code> is supposed to occupy.
- * @param x2 the X-coordinate of the lower right corner of the area
- * <code>c</code> is supposed to occupy.
- * @param y2 the Y-coordinate of the lower right corner of the area
- * <code>c</code> is supposed to occupy.
- * @throws OverlapsException if the new component overlaps with any
- * of the components already in the grid.
- * @throws OutOfBoundsException if the coordinates are outside of the
- * grid area.
+ * @param c
+ * the component to be added.
+ * @param x1
+ * the X-coordinate of the upper left corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @param y1
+ * the Y-coordinate of the upper left corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @param x2
+ * the X-coordinate of the lower right corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @param y2
+ * the Y-coordinate of the lower right corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @throws OverlapsException
+ * if the new component overlaps with any of the components
+ * already in the grid.
+ * @throws OutOfBoundsException
+ * if the coordinates are outside of the grid area.
*/
- public void addComponent(
- Component component,
- int x1,
- int y1,
- int x2,
- int y2)
- throws OverlapsException, OutOfBoundsException {
+ public void addComponent(Component component, int x1, int y1, int x2, int y2)
+ throws OverlapsException, OutOfBoundsException {
if (component == null)
throw new NullPointerException("Component must not be null");
// Checks that the component does not already exist in the container
if (components.contains(component))
- throw new IllegalArgumentException("Component is already in the container");
+ throw new IllegalArgumentException(
+ "Component is already in the container");
// Creates the area
Area area = new Area(component, x1, y1, x2, y2);
// Checks the validity of the coordinates
if (x2 < x1 || y2 < y2)
- throw new IllegalArgumentException("Illegal coordinates for the component");
+ throw new IllegalArgumentException(
+ "Illegal coordinates for the component");
if (x1 < 0 || y1 < 0 || x2 >= width || y2 >= height)
throw new OutOfBoundsException(area);
@@ -172,7 +179,7 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
while (!done && i.hasNext()) {
Area existingArea = (Area) i.next();
if ((existingArea.y1 >= y1 && existingArea.x1 > x1)
- || existingArea.y1 > y1) {
+ || existingArea.y1 > y1) {
areas.add(index, area);
components.add(index, component);
done = true;
@@ -188,13 +195,14 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
requestRepaint();
}
- /**
- * Tests if the given area overlaps with any of the items already on
- * the grid.
+ /**
+ * Tests if the given area overlaps with any of the items already on the
+ * grid.
*
- * @param area the Area to be checked for overlapping.
- * @throws OverlapsException if <code>area</code> overlaps with
- * any existing area.
+ * @param area
+ * the Area to be checked for overlapping.
+ * @throws OverlapsException
+ * if <code>area</code> overlaps with any existing area.
*/
private void checkExistingOverlaps(Area area) throws OverlapsException {
for (Iterator i = areas.iterator(); i.hasNext();) {
@@ -206,19 +214,23 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
}
}
- /**
- * Adds the component into this container to coordinates x1,y1 (NortWest corner of the area.)
- * End coordinates (SouthEast corner of the area) are the same as x1,y1. Component width
- * and height is 1.
- * @param c the component to be added.
- * @param x the X-coordinate.
- * @param y the Y-coordinate.
+ /**
+ * Adds the component into this container to coordinates x1,y1 (NortWest
+ * corner of the area.) End coordinates (SouthEast corner of the area) are
+ * the same as x1,y1. Component width and height is 1.
+ *
+ * @param c
+ * the component to be added.
+ * @param x
+ * the X-coordinate.
+ * @param y
+ * the Y-coordinate.
*/
public void addComponent(Component c, int x, int y) {
this.addComponent(c, x, y, x, y);
}
- /**
+ /**
* Force the next component to be added to the beginning of the next line.
* By calling this function user can ensure that no more components are
* added to the right of the previous component.
@@ -230,9 +242,9 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
cursorY++;
}
- /**
- * Moves the cursor forwards by one. If the cursor goes out of the right grid border,
- * move it to next line.
+ /**
+ * Moves the cursor forwards by one. If the cursor goes out of the right
+ * grid border, move it to next line.
*
* @see #newLine()
*/
@@ -244,12 +256,14 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
}
}
- /**
- * Adds the component into this container to the cursor position.
- * If the cursor position is already occupied, the cursor is
- * moved forwards to find free position. If the cursor goes out
- * from the bottom of the grid, the grid is automaticly extended.
- * @param c the component to be added.
+ /**
+ * Adds the component into this container to the cursor position. If the
+ * cursor position is already occupied, the cursor is moved forwards to find
+ * free position. If the cursor goes out from the bottom of the grid, the
+ * grid is automaticly extended.
+ *
+ * @param c
+ * the component to be added.
*/
public void addComponent(Component component) {
@@ -272,11 +286,11 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
addComponent(component, cursorX, cursorY);
}
- /**
- * Removes the given component from this
- * container.
+ /**
+ * Removes the given component from this container.
*
- * @param c the component to be removed.
+ * @param c
+ * the component to be removed.
*/
public void removeComponent(Component component) {
@@ -300,12 +314,14 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
requestRepaint();
}
- /**
+ /**
* Removes the component specified with it's top-left corner coordinates
* from this grid.
*
- * @param x the Component's top-left corner's X-coordinate.
- * @param y the Component's top-left corner's Y-coordinate.
+ * @param x
+ * the Component's top-left corner's X-coordinate.
+ * @param y
+ * the Component's top-left corner's Y-coordinate.
*/
public void removeComponent(int x, int y) {
@@ -319,9 +335,9 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
}
}
- /**
- * Gets an Iterator to the component container contents. Using the
- * Iterator it's possible to step through the contents of the container.
+ /**
+ * Gets an Iterator to the component container contents. Using the Iterator
+ * it's possible to step through the contents of the container.
*
* @return the Iterator of the components inside the container.
*/
@@ -329,11 +345,13 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
return Collections.unmodifiableCollection(components).iterator();
}
- /**
+ /**
* Paints the contents of this component.
*
- * @param target the Paint Event.
- * @throws PaintException if the paint operation failed.
+ * @param target
+ * the Paint Event.
+ * @throws PaintException
+ * if the paint operation failed.
*/
public void paintContent(PaintTarget target) throws PaintException {
@@ -381,7 +399,7 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
target.addAttribute("x", curx);
target.addAttribute("y", cury);
-
+
if (cols > 1) {
target.addAttribute("w", cols);
}
@@ -403,9 +421,8 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
if (rows > 1) {
int spannedx = curx;
for (int j = 1; j <= cols; j++) {
- cellUsed.put(
- new Integer(spannedx),
- new Integer(cury + rows - 1));
+ cellUsed.put(new Integer(spannedx), new Integer(
+ cury + rows - 1));
spannedx++;
}
}
@@ -422,9 +439,8 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
// Current column contains already an item,
// check if rowspan affects at current x,y position
- int rowspanDepth =
- ((Integer) cellUsed.get(new Integer(curx)))
- .intValue();
+ int rowspanDepth = ((Integer) cellUsed.get(new Integer(
+ curx))).intValue();
if (rowspanDepth >= cury) {
@@ -446,7 +462,8 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
// empty cell is needed
emptyCells++;
- // Removes the cellUsed key as it has become obsolete
+ // Removes the cellUsed key as it has become
+ // obsolete
cellUsed.remove(new Integer(curx));
}
} else {
@@ -479,7 +496,7 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
// Last row handled
}
- /**
+ /**
* Gets the components UIDL tag.
*
* @return the Component UIDL tag as string.
@@ -489,39 +506,40 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
return "gridlayout";
}
- /**
+ /**
* This class defines an area on a grid. An Area is defined by the
* coordinates of its upper left corner (x1,y1) and lower right corner
* (x2,y2).
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class Area {
- /**
- * X-coordinate of the upper left corner of the area.
+ /**
+ * X-coordinate of the upper left corner of the area.
*/
private int x1;
- /**
- * Y-coordinate of the upper left corner of the area.
+ /**
+ * Y-coordinate of the upper left corner of the area.
*/
private int y1;
- /**
- * X-coordinate of the lower right corner of the area.
+ /**
+ * X-coordinate of the lower right corner of the area.
*/
private int x2;
- /**
- * Y-coordinate of the lower right corner of the area.
+ /**
+ * Y-coordinate of the lower right corner of the area.
*/
private int y2;
- /**
- * Component painted on the area.
+ /**
+ * Component painted on the area.
*/
private Component component;
@@ -529,17 +547,24 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
* <p>
* Construct a new area on a grid.
* </p>
- * @param component the component connected to the area.
- * @param x1 the X-coordinate of the upper left corner of the area
- * <code>c</code> is supposed to occupy.
- * @param y1 the Y-coordinate of the upper left corner of the area
- * <code>c</code> is supposed to occupy.
- * @param x2 the X-coordinate of the lower right corner of the area
- * <code>c</code> is supposed to occupy.
- * @param y2 the Y-coordinate of the lower right corner of the area
- * <code>c</code> is supposed to occupy.
- * @throws OverlapsException if the new component overlaps with any
- * of the components already in the grid
+ *
+ * @param component
+ * the component connected to the area.
+ * @param x1
+ * the X-coordinate of the upper left corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @param y1
+ * the Y-coordinate of the upper left corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @param x2
+ * the X-coordinate of the lower right corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @param y2
+ * the Y-coordinate of the lower right corner of the area
+ * <code>c</code> is supposed to occupy.
+ * @throws OverlapsException
+ * if the new component overlaps with any of the components
+ * already in the grid
*/
public Area(Component component, int x1, int y1, int x2, int y2) {
this.x1 = x1;
@@ -549,44 +574,48 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
this.component = component;
}
- /**
+ /**
* Tests if the given Area overlaps with an another Area.
*
- * @param other the Another Area that's to be tested for overlap with
- * this area.
+ * @param other
+ * the Another Area that's to be tested for overlap with this
+ * area.
* @return <code>true</code> if <code>other</code> overlaps with
- * this area, <code>false</code> if it doesn't.
+ * this area, <code>false</code> if it doesn't.
*/
public boolean overlaps(Area other) {
- return x1 <= other.getX2()
- && y1 <= other.getY2()
- && x2 >= other.getX1()
- && y2 >= other.getY1();
+ return x1 <= other.getX2() && y1 <= other.getY2()
+ && x2 >= other.getX1() && y2 >= other.getY1();
}
- /**
+ /**
* Gets the component connected to the area.
+ *
* @return the Component.
*/
public Component getComponent() {
return component;
}
- /**
+ /**
* Sets the component connected to the area.
*
- * <p>This function only sets the value in the datastructure and does not
- * send any events or set parents.</p>
+ * <p>
+ * This function only sets the value in the datastructure and does not
+ * send any events or set parents.
+ * </p>
*
- * @param newComponent the new connected overriding the existing one.
+ * @param newComponent
+ * the new connected overriding the existing one.
*/
protected void setComponent(Component newComponent) {
- component= newComponent;
+ component = newComponent;
}
- /**
+ /**
* Gets the top-left corner x-coordinate.
+ *
* @return the top-left corner of x-coordinate.
*/
public int getX1() {
@@ -595,6 +624,7 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
/**
* Gets the bottom-right corner x-coordinate.
+ *
* @return the x-coordinate.
*/
public int getX2() {
@@ -603,6 +633,7 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
/**
* Gets the top-left corner y-coordinate.
+ *
* @return the y-coordinate.
*/
public int getY1() {
@@ -611,6 +642,7 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
/**
* Returns the bottom-right corner y-coordinate.
+ *
* @return the y-coordinate.
*/
public int getY2() {
@@ -619,33 +651,36 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
}
- /**
- * An <code>Exception</code> object which is thrown when two Items
- * occupy the same space on a grid.
+ /**
+ * An <code>Exception</code> object which is thrown when two Items occupy
+ * the same space on a grid.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class OverlapsException extends java.lang.RuntimeException {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3978144339870101561L;
-
- private Area existingArea;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3978144339870101561L;
+
+ private Area existingArea;
- /**
+ /**
* Constructs an <code>OverlapsException</code>.
- * @param existingArea
+ *
+ * @param existingArea
*/
public OverlapsException(Area existingArea) {
this.existingArea = existingArea;
}
- /**
+ /**
* Gets the area .
+ *
* @return the existing area.
*/
public Area getArea() {
@@ -653,35 +688,37 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
}
}
- /**
- * An <code>Exception</code> object which is thrown when an area exceeds the
- * bounds of the grid.
+ /**
+ * An <code>Exception</code> object which is thrown when an area exceeds
+ * the bounds of the grid.
*
* @author IT Mill Ltd.
- * @version @VERSION@
+ * @version
+ * @VERSION@
* @since 3.0
*/
public class OutOfBoundsException extends java.lang.RuntimeException {
/**
- * Serial generated by eclipse.
- */
- private static final long serialVersionUID = 3618985589664592694L;
-
- private Area areaOutOfBounds;
+ * Serial generated by eclipse.
+ */
+ private static final long serialVersionUID = 3618985589664592694L;
+
+ private Area areaOutOfBounds;
- /**
+ /**
* Constructs an <code>OoutOfBoundsException</code> with the specified
* detail message.
*
- * @param areaOutOfBounds
+ * @param areaOutOfBounds
*/
public OutOfBoundsException(Area areaOutOfBounds) {
this.areaOutOfBounds = areaOutOfBounds;
}
- /**
- * Gets the area that is out of bounds.
+ /**
+ * Gets the area that is out of bounds.
+ *
* @return the area out of Bound.
*/
public Area getArea() {
@@ -689,16 +726,19 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
}
}
- /**
- * Sets the width of the grid. The width can not be reduced if there are
- * any areas that would be outside of the shrunk grid.
- * @param width the New width of the grid.
+ /**
+ * Sets the width of the grid. The width can not be reduced if there are any
+ * areas that would be outside of the shrunk grid.
+ *
+ * @param width
+ * the New width of the grid.
*/
public void setWidth(int width) {
// The the param
if (width < 1)
- throw new IllegalArgumentException("The grid width and height must be at least 1");
+ throw new IllegalArgumentException(
+ "The grid width and height must be at least 1");
// In case of no change
if (this.width == width)
@@ -717,24 +757,28 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
requestRepaint();
}
- /**
+ /**
* Get the width of the grids.
+ *
* @return the width of the grid.
*/
public final int getWidth() {
return this.width;
}
- /**
+ /**
* Sets the height of the grid. The width can not be reduced if there are
* any areas that would be outside of the shrunk grid.
- * @param height the height of the grid.
+ *
+ * @param height
+ * the height of the grid.
*/
public void setHeight(int height) {
// The the param
if (height < 1)
- throw new IllegalArgumentException("The grid width and height must be at least 1");
+ throw new IllegalArgumentException(
+ "The grid width and height must be at least 1");
// In case of no change
if (this.height == height)
@@ -753,67 +797,71 @@ public class GridLayout extends AbstractComponentContainer implements Layout {
requestRepaint();
}
- /**
+ /**
* Gets the height of the grid.
+ *
* @return int - how many cells high the grid is.
*/
public final int getHeight() {
return this.height;
}
- /**
- * Gets the current cursor x-position.
- * The cursor position points the position for the next component
- * that is added without specifying its coordinates. When the
- * cursor position is occupied, the next component will be added
- * to first free position after the cursor.
+ /**
+ * Gets the current cursor x-position. The cursor position points the
+ * position for the next component that is added without specifying its
+ * coordinates. When the cursor position is occupied, the next component
+ * will be added to first free position after the cursor.
+ *
* @return the Cursor x-coordinate.
*/
public int getCursorX() {
return cursorX;
}
- /**
- * Gets the current cursor y-position.
- * The cursor position points the position for the next component
- * that is added without specifying its coordinates. When the
- * cursor position is occupied, the next component will be added
- * to first free position after the cursor.
+ /**
+ * Gets the current cursor y-position. The cursor position points the
+ * position for the next component that is added without specifying its
+ * coordinates. When the cursor position is occupied, the next component
+ * will be added to first free position after the cursor.
+ *
* @return the Cursor y-coordinate.
*/
public int getCursorY() {
return cursorY;
}
-
+
/* Documented in superclass */
- public void replaceComponent(
- Component oldComponent,
- Component newComponent) {
+ public void replaceComponent(Component oldComponent, Component newComponent) {
- // Gets the locations
+ // Gets the locations
Area oldLocation = null;
- Area newLocation = null;
- for (Iterator i=areas.iterator(); i.hasNext();) {
+ Area newLocation = null;
+ for (Iterator i = areas.iterator(); i.hasNext();) {
Area location = (Area) i.next();
Component component = (Component) location.getComponent();
- if (component == oldComponent) oldLocation = location;
- if (component == newComponent) newLocation = location;
- }
+ if (component == oldComponent)
+ oldLocation = location;
+ if (component == newComponent)
+ newLocation = location;
+ }
if (oldLocation == null)
addComponent(newComponent);
else if (newLocation == null) {
removeComponent(oldComponent);
- addComponent(newComponent,oldLocation.getX1(),oldLocation.getY1(),oldLocation.getX2(),oldLocation.getY2());
+ addComponent(newComponent, oldLocation.getX1(),
+ oldLocation.getY1(), oldLocation.getX2(), oldLocation
+ .getY2());
} else {
oldLocation.setComponent(newComponent);
newLocation.setComponent(oldComponent);
requestRepaint();
}
}
-
+
/*
* Removes all components from this container.
+ *
* @see com.itmill.toolkit.ui.ComponentContainer#removeAllComponents()
*/
public void removeAllComponents() {