You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/10/08 01:10:24 UTC
svn commit: r454042 [3/6] - in
/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common:
java/awt/ org/apache/harmony/awt/
Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Container.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Container.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Container.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Container.java Sat Oct 7 16:10:23 2006
@@ -14,10 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Dmitry A. Durnev, Michael Danilov
- * @version $Revision$
- */
+
package java.awt;
import java.awt.event.ContainerEvent;
@@ -41,12 +38,15 @@
private final Vector<Component> children = new Vector<Component>();
- private final AWTListenerList containerListeners = new AWTListenerList(this);
+ private final AWTListenerList<ContainerListener> containerListeners = new AWTListenerList<ContainerListener>(
+ this);
private FocusTraversalPolicy focusTraversalPolicy;
private LayoutManager layout;
+
private Dimension minimumLayoutSize;
+
private Dimension preferredLayoutSize;
Object layoutData;
@@ -69,8 +69,8 @@
if (listenersCount <= 0) {
return;
}
- firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
- null, e.getChild().getAccessibleContext());
+ firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, null, e
+ .getChild().getAccessibleContext());
}
@@ -78,8 +78,8 @@
if (listenersCount <= 0) {
return;
}
- firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
- e.getChild().getAccessibleContext(), null);
+ firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, e.getChild()
+ .getAccessibleContext(), null);
}
@@ -104,8 +104,7 @@
public Accessible getAccessibleAt(Point p) {
toolkit.lockAWT();
try {
- if (!(Container.this instanceof Accessible)
- || (getAccessibleContext() == null)) {
+ if (!(Container.this instanceof Accessible) || (getAccessibleContext() == null)) {
return super.getAccessibleAt(p);
}
int count = getAccessibleChildrenCount();
@@ -137,7 +136,7 @@
for (int i = 0; i < children.size(); i++) {
if (children.get(i) instanceof Accessible) {
if (count == index) {
- return (Accessible)children.get(i);
+ return (Accessible) children.get(i);
}
++count;
}
@@ -186,7 +185,10 @@
}
}
- /* places component at the index pos. of the stacking order (e. g. when it gains focus) */
+ /*
+ * places component at the index pos. of the stacking order (e. g. when it
+ * gains focus)
+ */
public final void setComponentZOrder(Component comp, int index) {
toolkit.lockAWT();
try {
@@ -200,6 +202,7 @@
toolkit.unlockAWT();
}
}
+
public Component add(Component comp) {
toolkit.lockAWT();
try {
@@ -273,7 +276,7 @@
try {
remove(children.indexOf(comp));
} catch (ArrayIndexOutOfBoundsException e) {
- //just silently ignore exception if comp is not found
+ // just silently ignore exception if comp is not found
}
} finally {
toolkit.unlockAWT();
@@ -285,7 +288,7 @@
toolkit.lockAWT();
try {
super.list(out, indent);
- for (int i=0; i < children.size(); i++) {
+ for (int i = 0; i < children.size(); i++) {
children.get(i).list(out, 2 * indent);
}
} finally {
@@ -298,7 +301,7 @@
toolkit.lockAWT();
try {
super.list(out, indent);
- for (int i=0; i < children.size(); i++) {
+ for (int i = 0; i < children.size(); i++) {
children.get(i).list(out, 2 * indent);
}
} finally {
@@ -319,7 +322,7 @@
public void removeAll() {
toolkit.lockAWT();
try {
- for (int i = children.size() - 1; i >=0; i--) {
+ for (int i = children.size() - 1; i >= 0; i--) {
remove(i);
}
} finally {
@@ -331,7 +334,7 @@
public void update(Graphics g) {
toolkit.lockAWT();
try {
- super.update(g); //calls paint() by default
+ super.update(g); // calls paint() by default
} finally {
toolkit.unlockAWT();
}
@@ -376,7 +379,7 @@
private void addToLayout(Component comp, Object constraints) {
if (layout != null) {
if (LayoutManager2.class.isInstance(layout)) {
- ((LayoutManager2)layout).addLayoutComponent(comp, constraints);
+ ((LayoutManager2) layout).addLayoutComponent(comp, constraints);
} else {
layout.addLayoutComponent(
(constraints == null) ? null : constraints.toString(), comp);
@@ -385,8 +388,7 @@
}
protected void addImpl(Component comp, Object constraints, int index)
- throws IllegalArgumentException
- {
+ throws IllegalArgumentException {
toolkit.lockAWT();
try {
if ((index < -1) || (index > children.size())) {
@@ -429,7 +431,7 @@
toolkit.lockAWT();
try {
super.addNotify();
- for (int i=0; i < children.size(); i++) {
+ for (int i = 0; i < children.size(); i++) {
children.get(i).addNotify();
}
} finally {
@@ -492,7 +494,7 @@
toolkit.unlockAWT();
}
}
-
+
/**
* @deprecated
*/
@@ -533,33 +535,32 @@
public Component findComponentAt(int x, int y) {
toolkit.lockAWT();
try {
- if (!contains(x,y) || !isShowing()) {
+ if (!contains(x, y) || !isShowing()) {
return null;
}
- if (!getClient().contains(x, y))
- {
+ if (!getClient().contains(x, y)) {
return this;
}
Component c = null, fc = null;// = getComponentAt(x,y);
- //if c is not visible, get next component
- //under it, etc. So cannot actually use getComponentAt():
- //have to traverse children manually
+ // if c is not visible, get next component
+ // under it, etc. So cannot actually use getComponentAt():
+ // have to traverse children manually
- for (int i = 0; i < children.size(); i++) {
+ for (int i = 0; i < children.size(); i++) {
c = children.get(i);
if (!c.isVisible()) {
continue;
}
- if ( c.contains(x-c.getX(), y-c.getY()) ) {
+ if (c.contains(x - c.getX(), y - c.getY())) {
fc = c;
break;
}
}
if (fc instanceof Container) {
- fc = ((Container) fc).findComponentAt(x - fc.getX(),y - fc.getY());
+ fc = ((Container) fc).findComponentAt(x - fc.getX(), y - fc.getY());
}
if (fc == null) {
@@ -576,7 +577,7 @@
toolkit.lockAWT();
try {
if ((layout != null) && (LayoutManager2.class.isInstance(layout))) {
- return ((LayoutManager2)layout).getLayoutAlignmentX(this);
+ return ((LayoutManager2) layout).getLayoutAlignmentX(this);
}
return super.getAlignmentX();
@@ -590,7 +591,7 @@
toolkit.lockAWT();
try {
if ((layout != null) && (LayoutManager2.class.isInstance(layout))) {
- return ((LayoutManager2)layout).getLayoutAlignmentY(this);
+ return ((LayoutManager2) layout).getLayoutAlignmentY(this);
}
return super.getAlignmentY();
@@ -661,11 +662,11 @@
try {
if (isFocusTraversalPolicyProvider() || focusCycleRoot) {
if (isFocusTraversalPolicySet()) {
- return focusTraversalPolicy;
+ return focusTraversalPolicy;
}
- Container root = getFocusCycleRootAncestor();
- return ((root != null) ? root.getFocusTraversalPolicy() :
- KeyboardFocusManager.getCurrentKeyboardFocusManager().getDefaultFocusTraversalPolicy());
+ Container root = getFocusCycleRootAncestor();
+ return ((root != null) ? root.getFocusTraversalPolicy() : KeyboardFocusManager
+ .getCurrentKeyboardFocusManager().getDefaultFocusTraversalPolicy());
}
return null;
} finally {
@@ -702,16 +703,15 @@
Rectangle getClient() {
Insets insets = getInsets();
- return new Rectangle(insets.left, insets.top,
- w - insets.right - insets.left,
- h - insets.top - insets.bottom);
+ return new Rectangle(insets.left, insets.top, w - insets.right - insets.left, h
+ - insets.top - insets.bottom);
}
@Override
public Dimension getMinimumSize() {
toolkit.lockAWT();
try {
- return minimumSize();
+ return minimumSize();
} finally {
toolkit.unlockAWT();
}
@@ -797,13 +797,12 @@
minimumLayoutSize = null;
preferredLayoutSize = null;
- for (int i=0; i < children.size(); i++) {
+ for (int i = 0; i < children.size(); i++) {
Component c = children.get(i);
c.resetDefaultSize();
}
}
-
/**
* @deprecated
*/
@@ -870,11 +869,9 @@
}
}
- /**
- * @deprecated
- */
@Deprecated
@Override
+ @SuppressWarnings("deprecation")
public void layout() {
toolkit.lockAWT();
try {
@@ -886,11 +883,9 @@
}
}
- /**
- * @deprecated
- */
@Deprecated
@Override
+ @SuppressWarnings("deprecation")
public Component locate(int x, int y) {
toolkit.lockAWT();
try {
@@ -901,21 +896,21 @@
}
Component locateImpl(int x, int y) {
-// return topmost child containing point - search from index 0
- for (int i = 0; i < children.size(); i++) {
+ // return topmost child containing point - search from index 0
+ for (int i = 0; i < children.size(); i++) {
Component c = children.get(i);
- if ( c.contains(x-c.getX(), y-c.getY()) ) {
+ if (c.contains(x - c.getX(), y - c.getY())) {
return c;
}
}
- if (contains(x,y)) {
+ if (contains(x, y)) {
return this;
}
return null;
}
@Override
- void setRedrawManager () {
+ void setRedrawManager() {
super.setRedrawManager();
for (int i = 0; i < children.size(); i++) {
children.get(i).setRedrawManager();
@@ -944,18 +939,18 @@
@Override
protected String paramString() {
- /* The format is based on 1.5 release behavior
- * which can be revealed by the following code:
+ /*
+ * The format is based on 1.5 release behavior which can be revealed by
+ * the following code:
*
- * Container container = new Container();
- * container.setLayout(new FlowLayout());
- * System.out.println(container);
+ * Container container = new Container(); container.setLayout(new
+ * FlowLayout()); System.out.println(container);
*/
toolkit.lockAWT();
try {
- return super.paramString() + (!isValid() ? ",invalid" : "") +
- (layout != null ? ",layout=" + layout.getClass().getName() : "");
+ return super.paramString() + (!isValid() ? ",invalid" : "")
+ + (layout != null ? ",layout=" + layout.getClass().getName() : "");
} finally {
toolkit.unlockAWT();
}
@@ -1009,8 +1004,8 @@
toolkit.lockAWT();
try {
isRemoved = true;
-// moveFocusOnHide();
- for (int i=0; i < children.size(); i++) {
+ // moveFocusOnHide();
+ for (int i = 0; i < children.size(); i++) {
children.get(i).removeNotify();
}
super.removeNotify();
@@ -1029,8 +1024,7 @@
} finally {
toolkit.unlockAWT();
}
- firePropertyChange("focusCycleRoot", wasFocusCycleRoot,
- focusCycleRoot);
+ firePropertyChange("focusCycleRoot", wasFocusCycleRoot, focusCycleRoot);
}
@Override
@@ -1112,7 +1106,7 @@
public void transferFocusBackward() {
toolkit.lockAWT();
try {
- super.transferFocusBackward(); //TODO: why override?
+ super.transferFocusBackward(); // TODO: why override?
} finally {
toolkit.unlockAWT();
}
@@ -1144,7 +1138,7 @@
try {
super.invalidate();
if ((layout != null) && LayoutManager2.class.isInstance(layout)) {
- ((LayoutManager2)layout).invalidateLayout(this);
+ ((LayoutManager2) layout).invalidateLayout(this);
}
} finally {
toolkit.unlockAWT();
@@ -1185,15 +1179,16 @@
@Override
void mapToDisplay(boolean b) {
super.mapToDisplay(b);
- //map to display from bottom to top, to get right initial Z-order
- for (int i = children.size() - 1; i >= 0 ; i--) {
+ // map to display from bottom to top, to get right initial Z-order
+ for (int i = children.size() - 1; i >= 0; i--) {
children.get(i).mapToDisplay(b);
}
}
@Override
void moveFocusOnHide() {
- Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
+ Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager()
+ .getFocusOwner();
if (focusOwner != null && isAncestorOf(focusOwner)) {
focusOwner.moveFocus();
}
@@ -1209,11 +1204,9 @@
@Override
void finishChildrenHierarchyChange(Component changed, Container changedParent,
- int ancestorFlags)
- {
+ int ancestorFlags) {
for (int i = 0; i < children.size(); i++) {
- children.get(i).finishHierarchyChange(changed, changedParent,
- ancestorFlags);
+ children.get(i).finishHierarchyChange(changed, changedParent, ancestorFlags);
}
}
@@ -1232,86 +1225,87 @@
}
public ContainerListener[] getContainerListeners() {
-// toolkit.lockAWT();
-// try {
- return (ContainerListener[]) containerListeners.getUserListeners(new ContainerListener[0]);
-// } finally {
-// toolkit.unlockAWT();
-// }
+ // toolkit.lockAWT();
+ // try {
+ return containerListeners.getUserListeners(new ContainerListener[0]);
+ // } finally {
+ // toolkit.unlockAWT();
+ // }
}
public void addContainerListener(ContainerListener l) {
-// toolkit.lockAWT();
-// try {
- containerListeners.addUserListener(l);
-// } finally {
-// toolkit.unlockAWT();
-// }
+ // toolkit.lockAWT();
+ // try {
+ containerListeners.addUserListener(l);
+ // } finally {
+ // toolkit.unlockAWT();
+ // }
}
public void removeContainerListener(ContainerListener l) {
-// toolkit.lockAWT();
-// try {
- containerListeners.removeUserListener(l);
-// } finally {
-// toolkit.unlockAWT();
-// }
+ // toolkit.lockAWT();
+ // try {
+ containerListeners.removeUserListener(l);
+ // } finally {
+ // toolkit.unlockAWT();
+ // }
}
+ @SuppressWarnings("unchecked")
@Override
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
-// toolkit.lockAWT();
-// try {
- if (ContainerListener.class.isAssignableFrom(listenerType)) {
- return (T[]) getContainerListeners();
- }
- return super.getListeners(listenerType);
-// } finally {
-// toolkit.unlockAWT();
-// }
+ // toolkit.lockAWT();
+ // try {
+ if (ContainerListener.class.isAssignableFrom(listenerType)) {
+ return (T[]) getContainerListeners();
+ }
+ return super.getListeners(listenerType);
+ // } finally {
+ // toolkit.unlockAWT();
+ // }
}
@Override
protected void processEvent(AWTEvent e) {
-// toolkit.lockAWT();
-// try {
- if (toolkit.eventTypeLookup.getEventMask(e) == AWTEvent.CONTAINER_EVENT_MASK) {
- processContainerEvent((ContainerEvent) e);
- } else {
- super.processEvent(e);
- }
-// } finally {
-// toolkit.unlockAWT();
-// }
+ // toolkit.lockAWT();
+ // try {
+ if (toolkit.eventTypeLookup.getEventMask(e) == AWTEvent.CONTAINER_EVENT_MASK) {
+ processContainerEvent((ContainerEvent) e);
+ } else {
+ super.processEvent(e);
+ }
+ // } finally {
+ // toolkit.unlockAWT();
+ // }
}
protected void processContainerEvent(ContainerEvent e) {
-// toolkit.lockAWT();
-// try {
- for (Iterator<?> i = containerListeners.getUserIterator(); i.hasNext();) {
- ContainerListener listener = (ContainerListener) i.next();
+ // toolkit.lockAWT();
+ // try {
+ for (Iterator<?> i = containerListeners.getUserIterator(); i.hasNext();) {
+ ContainerListener listener = (ContainerListener) i.next();
- switch (e.getID()) {
+ switch (e.getID()) {
case ContainerEvent.COMPONENT_ADDED:
listener.componentAdded(e);
break;
case ContainerEvent.COMPONENT_REMOVED:
listener.componentRemoved(e);
break;
- }
}
-// } finally {
-// toolkit.unlockAWT();
-// }
+ }
+ // } finally {
+ // toolkit.unlockAWT();
+ // }
}
/**
- * Determine if comp contains point pos. Comp must be showing and
- * top-most component in Z-order.
- *
+ * Determine if comp contains point pos. Comp must be showing and top-most
+ * component in Z-order.
+ *
* @param x
* @param y
- *
+ *
* @return
*/
boolean isComponentAt(Component comp, Point pos) {
@@ -1323,19 +1317,18 @@
if (!contains(p) || !isShowing()) {
return false;
}
- while(container != null) {
- if (!container.getClient().contains(p))
- {
+ while (container != null) {
+ if (!container.getClient().contains(p)) {
return false;
}
Vector<Component> children = container.children;
- for (int i = 0; i < children.size(); i++) {
+ for (int i = 0; i < children.size(); i++) {
c = children.get(i);
if (!c.isVisible()) {
continue;
}
- if ( c.contains(p.x-c.getX(), p.y-c.getY()) ) {
+ if (c.contains(p.x - c.getX(), p.y - c.getY())) {
fc = c;
break;
}
@@ -1363,14 +1356,13 @@
}
}
- public Point getMousePosition(boolean allowChildren)
- throws HeadlessException {
+ public Point getMousePosition(boolean allowChildren) throws HeadlessException {
toolkit.lockAWT();
try {
Point pos = getMousePosition();
if ((pos != null) && !allowChildren) {
- //check that there's no [visible] child
- //containing point pos:
+ // check that there's no [visible] child
+ // containing point pos:
Component child = findComponentAt(pos);
if (child != this) {
pos = null;
@@ -1400,9 +1392,9 @@
}
/**
- * Find which focus cycle root to take when
- * doing keyboard focus traversal and focus owner
- * is a container & focus cycle root itself.
+ * Find which focus cycle root to take when doing keyboard focus traversal
+ * and focus owner is a container & focus cycle root itself.
+ *
* @return
*/
Container getFocusTraversalRoot() {
@@ -1414,5 +1406,4 @@
}
return (container == root) ? root : null;
}
-
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/DefaultMouseDragGestureRecognizer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/DefaultMouseDragGestureRecognizer.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/DefaultMouseDragGestureRecognizer.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/DefaultMouseDragGestureRecognizer.java Sat Oct 7 16:10:23 2006
@@ -14,29 +14,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Pavel Dolgov
- * @version $Revision$
- */
+
package java.awt;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragSource;
import java.awt.dnd.MouseDragGestureRecognizer;
+import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
-class DefaultMouseDragGestureRecognizer extends
- MouseDragGestureRecognizer {
-
+class DefaultMouseDragGestureRecognizer extends MouseDragGestureRecognizer {
private boolean active;
- protected DefaultMouseDragGestureRecognizer(
- DragSource ds, Component c, int act, DragGestureListener dgl) {
+ protected DefaultMouseDragGestureRecognizer(DragSource ds, Component c, int act,
+ DragGestureListener dgl) {
super(ds, c, act, dgl);
-
- events = new ArrayList();
+ events = new ArrayList<InputEvent>();
}
@Override
@@ -51,7 +46,7 @@
}
events.add(e);
int distance = 2; // TODO: use desktop property
- MouseEvent e0 = (MouseEvent)events.get(0);
+ MouseEvent e0 = (MouseEvent) events.get(0);
if (e0.getPoint().distance(e.getPoint()) >= distance) {
if (sourceActions != DnDConstants.ACTION_NONE) {
active = true;
@@ -59,7 +54,7 @@
}
}
}
-
+
@Override
public void mouseReleased(MouseEvent e) {
active = false;
Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Dialog.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Dialog.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Dialog.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Dialog.java Sat Oct 7 16:10:23 2006
@@ -14,23 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Pavel Dolgov
- * @version $Revision$
- */
+
package java.awt;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
-
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
-
public class Dialog extends Window {
private static final long serialVersionUID = 5920926903803293709L;
@@ -43,6 +38,7 @@
restoreActive = active;
super.runModalLoop();
}
+
@Override
public void endModalLoop() {
if (restoreActive != null) {
@@ -79,7 +75,6 @@
toolkit.unlockAWT();
}
}
-
}
public Dialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc) {
@@ -175,7 +170,8 @@
protected String paramString() {
toolkit.lockAWT();
try {
- return super.paramString() + ",title=" + getTitle() + (isResizable() ? ",resizable" : "") + (isModal() ? ",modal" : "");
+ return super.paramString() + ",title=" + getTitle()
+ + (isResizable() ? ",resizable" : "") + (isModal() ? ",modal" : "");
} finally {
toolkit.unlockAWT();
}
@@ -185,7 +181,7 @@
public void dispose() {
toolkit.lockAWT();
try {
- if(modalContext != null && modalContext.isModalLoopRunning()) {
+ if (modalContext != null && modalContext.isModalLoopRunning()) {
modalContext.endModalLoop();
}
super.dispose();
@@ -214,9 +210,7 @@
}
}
- /**
- * @deprecated
- */
+ @SuppressWarnings("deprecation")
@Deprecated
@Override
public void hide() {
@@ -227,7 +221,8 @@
toolkit.unlockAWT();
}
}
-
+
+ @SuppressWarnings("deprecation")
void hideImpl() {
if (modalContext != null && modalContext.isModalLoopRunning()) {
modalContext.endModalLoop();
@@ -236,16 +231,15 @@
super.hide();
}
}
-
- /**
- * @deprecated
- */
+
+ @SuppressWarnings("deprecation")
@Deprecated
@Override
public void show() {
showImpl();
}
+ @SuppressWarnings("deprecation")
void showImpl() {
if (isModal()) {
if (EventQueue.isDispatchThread()) {
@@ -266,8 +260,7 @@
toolkit.unlockAWT();
}
}
- }
- else {
+ } else {
super.show();
}
}
@@ -314,14 +307,13 @@
public void setModal(boolean modal) {
toolkit.lockAWT();
try {
- if(modal == isModal()) {
+ if (modal == isModal()) {
return;
}
-
- if(isVisible()) {
- throw new IllegalComponentStateException("Cannot change the modality while the dialog is visible");
+ if (isVisible()) {
+ throw new IllegalComponentStateException(
+ "Cannot change the modality while the dialog is visible");
}
-
modalContext = modal ? new DialogModalContext() : null;
} finally {
toolkit.unlockAWT();
@@ -338,7 +330,6 @@
}
}
-
@Override
public void setTitle(String title) {
super.setTitle(title);
@@ -354,13 +345,13 @@
}
}
+ @SuppressWarnings("deprecation")
private void showModal() {
Collection<Window> otherWindows;
Window active;
toolkit.lockAWT();
try {
- active = KeyboardFocusManager.
- getCurrentKeyboardFocusManager().getActiveWindow();
+ active = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
otherWindows = disableOtherWindows();
super.show();
} finally {
@@ -373,15 +364,14 @@
private Collection<Window> disableOtherWindows() {
Iterator<?> i = toolkit.windows.iterator();
LinkedList<Window> result = new LinkedList<Window>();
- while(i.hasNext()) {
+ while (i.hasNext()) {
Object obj = i.next();
- if(obj instanceof Window) {
- Window w = (Window)obj;
- if(w.isEnabled() && w != this) {
+ if (obj instanceof Window) {
+ Window w = (Window) obj;
+ if (w.isEnabled() && w != this) {
w.setEnabled(false);
result.add(w);
}
-
}
}
return result;
@@ -414,7 +404,7 @@
void runModalLoop() {
modalContext.runModalLoop();
}
-
+
void endModalLoop() {
modalContext.endModalLoop();
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaint.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaint.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaint.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaint.java Sat Oct 7 16:10:23 2006
@@ -14,48 +14,43 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Denis M. Kishenko
- * @version $Revision$
- */
+
package java.awt;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.ColorModel;
-import java.awt.image.DataBufferInt;
-import java.awt.image.Raster;
-import java.awt.image.WritableRaster;
public class GradientPaint implements Paint {
-
/**
- * The start point color
+ * The start point color
*/
Color color1;
-
+
/**
* The end color point
*/
Color color2;
-
+
/**
* The location of the start point
*/
Point2D point1;
-
+
/**
* The location of the end point
*/
Point2D point2;
-
+
/**
- * The indicator of cycle filling. If TRUE filling repeated outside points stripe, if FALSE solid color filling outside.
+ * The indicator of cycle filling. If TRUE filling repeated outside points
+ * stripe, if FALSE solid color filling outside.
*/
boolean cyclic;
- public GradientPaint(Point2D point1, Color color1, Point2D point2, Color color2, boolean cyclic) {
+ public GradientPaint(Point2D point1, Color color1, Point2D point2, Color color2,
+ boolean cyclic) {
this.point1 = point1;
this.point2 = point2;
this.color1 = color1;
@@ -63,7 +58,8 @@
this.cyclic = cyclic;
}
- public GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2, boolean cyclic) {
+ public GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2,
+ boolean cyclic) {
this(new Point2D.Float(x1, y1), color1, new Point2D.Float(x2, y2), color2, cyclic);
}
@@ -75,7 +71,8 @@
this(point1, color1, point2, color2, false);
}
- public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform t, RenderingHints hints) {
+ public PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
+ Rectangle2D userBounds, AffineTransform t, RenderingHints hints) {
return new GradientPaintContext(cm, t, point1, color1, point2, color2, cyclic);
}
@@ -104,5 +101,4 @@
public boolean isCyclic() {
return cyclic;
}
-
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Graphics2D.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Graphics2D.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Graphics2D.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Graphics2D.java Sat Oct 7 16:10:23 2006
@@ -14,10 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Alexey A. Petrenko
- * @version $Revision$
- */
+
package java.awt;
import java.awt.font.GlyphVector;
@@ -32,14 +29,11 @@
import java.util.Map;
public abstract class Graphics2D extends Graphics {
- // Constructors
-
protected Graphics2D() {
+ super();
}
- // Abstract methods
-
- public abstract void addRenderingHints(Map<?,?> hints);
+ public abstract void addRenderingHints(Map<?, ?> hints);
public abstract void clip(Shape s);
@@ -101,7 +95,7 @@
public abstract void setRenderingHint(RenderingHints.Key key, Object value);
- public abstract void setRenderingHints(Map<?,?> hints);
+ public abstract void setRenderingHints(Map<?, ?> hints);
public abstract void setStroke(Stroke s);
@@ -116,6 +110,7 @@
@Override
public abstract void translate(int x, int y);
+ @Override
public void fill3DRect(int x, int y, int width, int height, boolean raised) {
// According to the spec, color should be used instead of paint,
// so Graphics.fill3DRect resets paint and
@@ -125,6 +120,7 @@
setPaint(savedPaint);
}
+ @Override
public void draw3DRect(int x, int y, int width, int height, boolean raised) {
// According to the spec, color should be used instead of paint,
// so Graphics.draw3DRect resets paint and
Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayout.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayout.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayout.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayout.java Sat Oct 7 16:10:23 2006
@@ -14,32 +14,40 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Michael Danilov
- * @version $Revision$
- */
+
package java.awt;
import java.io.Serializable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
public class GridBagLayout implements LayoutManager2, Serializable {
private static final long serialVersionUID = 8838754796412211005L;
protected static final int MAXGRIDSIZE = 512;
+
protected static final int MINSIZE = 1;
+
protected static final int PREFERREDSIZE = 2;
private final Toolkit toolkit = Toolkit.getDefaultToolkit();
// Direct modification is forbidden
protected volatile Hashtable<Component, GridBagConstraints> comptable;
+
protected volatile GridBagConstraints defaultConstraints;
+
protected volatile GridBagLayoutInfo layoutInfo;
public volatile double columnWeights[];
+
public volatile double rowWeights[];
+
public volatile int columnWidths[];
+
public volatile int rowHeights[];
private ParentInfo lastParentInfo;
@@ -49,7 +57,6 @@
try {
comptable = new Hashtable<Component, GridBagConstraints>();
defaultConstraints = new GridBagConstraints();
-
columnWeights = rowWeights = null;
columnWidths = rowHeights = null;
layoutInfo = null;
@@ -82,9 +89,7 @@
toolkit.lockAWT();
try {
assert comp != null : "AddLayoutComponent: attempt to add null component";
-
GridBagConstraints cons;
-
if (constraints != null) {
if (!GridBagConstraints.class.isInstance(constraints)) {
throw new IllegalArgumentException(
@@ -101,14 +106,10 @@
try {
//cons.verify();
} catch (IllegalArgumentException e) {
- throw new IllegalArgumentException("AddLayoutComponent: "
- + e.getMessage());
+ throw new IllegalArgumentException("AddLayoutComponent: " + e.getMessage());
}
-
GridBagConstraints consClone = (GridBagConstraints) cons.clone();
comptable.put(comp, consClone);
-
-
Container parent = comp.getParent();
updateParentInfo(parent, consClone);
} finally {
@@ -116,7 +117,6 @@
}
}
-
public void removeLayoutComponent(Component comp) {
toolkit.lockAWT();
try {
@@ -135,12 +135,10 @@
toolkit.lockAWT();
try {
GridBagConstraints cons = comptable.get(comp);
-
if (cons == null) {
cons = defaultConstraints;
- comptable.put(comp, (GridBagConstraints)cons.clone());
+ comptable.put(comp, (GridBagConstraints) cons.clone());
}
-
return (GridBagConstraints) cons.clone();
} finally {
toolkit.unlockAWT();
@@ -152,25 +150,20 @@
try {
assert comp != null : "SetConstraints: attempt to get constraints of null component";
assert constraints != null : "SetConstraints: attempt to set null constraints";
-
GridBagConstraints consClone = (GridBagConstraints) constraints.clone();
-
try {
-// consClone.verify();
+ // consClone.verify();
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("SetConstraints: " + e.getMessage());
}
-
ParentInfo info = getParentInfo(comp.getParent());
if (info != null) {
GridBagConstraints cons = comptable.get(comp);
info.allConstraints.remove(info.consTable.get(cons)); //?
info.consTable.remove(cons);
}
-
// add component if it's not there yet
comptable.put(comp, consClone);
-
if (info != null) {
MixedConstraints mixCons = new MixedConstraints(consClone);
info.consTable.put(consClone, mixCons);
@@ -218,13 +211,11 @@
if (getComponentsNumber(parent) == 0) {
return parent.addInsets(new Dimension(0, 0));
}
-
try {
validate(parent, info);
} catch (RuntimeException e) {
throw new IllegalArgumentException("MinimumLayoutSize: " + e.getMessage());
}
-
return parent.addInsets(info.grid.minimumSize());
//return addInsets(grid.minimumSize(), parent);
} finally {
@@ -239,13 +230,11 @@
if (getComponentsNumber(parent) == 0) {
return parent.addInsets(new Dimension(0, 0));
}
-
try {
validate(parent, info);
} catch (RuntimeException e) {
throw new IllegalArgumentException("PreferredLayoutSize: " + e.getMessage());
}
-
return parent.addInsets(info.grid.preferredSize());
//return addInsets(grid.preferredSize(), parent);
} finally {
@@ -284,9 +273,10 @@
toolkit.lockAWT();
try {
if (lastParentInfo == null) {
- return new int[][] {new int[0], new int[0]};
+ return new int[][] { new int[0], new int[0] };
}
- return new int[][] {lastParentInfo.grid.getWidths(), lastParentInfo.grid.getHeights()};
+ return new int[][] { lastParentInfo.grid.getWidths(),
+ lastParentInfo.grid.getHeights() };
} finally {
toolkit.unlockAWT();
}
@@ -296,7 +286,7 @@
toolkit.lockAWT();
try {
if (lastParentInfo == null) {
- return new double[][]{new double[0], new double[0]};
+ return new double[][] { new double[0], new double[0] };
}
return lastParentInfo.grid.getWeights();
} finally {
@@ -322,7 +312,8 @@
if (lastParentInfo == null) {
return new Point();
}
- return lastParentInfo.grid.location(x, y, lastParentInfo.orientation.isLeftToRight());
+ return lastParentInfo.grid.location(x, y, lastParentInfo.orientation
+ .isLeftToRight());
} finally {
toolkit.unlockAWT();
}
@@ -331,15 +322,12 @@
protected Dimension GetMinSize(Container parent, GridBagLayoutInfo info) {
toolkit.lockAWT();
try {
-
int w = 0;
int h = 0;
-
for (int i = 0; i < MAXGRIDSIZE; i++) {
w += info.widths[i];
h += info.heights[i];
}
-
return new Dimension(w, h);
} finally {
toolkit.unlockAWT();
@@ -350,15 +338,13 @@
toolkit.lockAWT();
try {
ParentInfo parentInfo = getParentInfo(parent);
-
if (sizeflag == PREFERREDSIZE) {
return new GridBagLayoutInfo(parentInfo.grid.lookupPrefWidths(),
parentInfo.grid.lookupPrefHeights());
- }
+ }
// MINSIZE
return new GridBagLayoutInfo(parentInfo.grid.lookupMinWidths(), parentInfo.grid
.lookupMinHeights());
-
} finally {
toolkit.unlockAWT();
}
@@ -367,12 +353,10 @@
protected void ArrangeGrid(Container parent) {
toolkit.lockAWT();
try {
-
ParentInfo info = lastParentInfo = getParentInfo(parent);
if (getComponentsNumber(parent) == 0) {
return;
}
-
try {
arrangeGridImpl(parent, info);
} catch (RuntimeException e) {
@@ -388,12 +372,10 @@
try {
assert comp != null : "LookupConstraints: attempt to get constraints of null component";
GridBagConstraints cons = comptable.get(comp);
-
if (cons == null) {
// if comp is not in the layout, return a copy of default constraints
cons = (GridBagConstraints) defaultConstraints.clone();
}
-
return cons;
} finally {
toolkit.unlockAWT();
@@ -442,17 +424,15 @@
assert constraints != null : "AdjustForGravity: attempt to use null constraints";
assert r != null : "AdjustForGravity: attempt to use null rectangle";
try {
-// ((GridBagConstraints) constraints).verify();
+ // ((GridBagConstraints) constraints).verify();
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("AdjustForGravity: " + e.getMessage());
}
-
//Don't get parent as param, so have to use older info if exists
if (layoutInfo == null) {
r.setBounds(0, 0, 0, 0);
return;
}
-
GridBagConstraints consClone = (GridBagConstraints) constraints.clone();
consClone.fill = GridBagConstraints.BOTH;
ComponentSide horSide = new ComponentSide();
@@ -460,7 +440,6 @@
Dimension dummySize = new Dimension(0, 0);
initHorCompSide(horSide, consClone, dummySize, dummySize, lastParentInfo);
initVertCompSide(vertSide, consClone, dummySize, dummySize, lastParentInfo);
-
calculateComponentBounds(horSide, vertSide, r, lastParentInfo.grid);
} finally {
toolkit.unlockAWT();
@@ -474,13 +453,11 @@
if ((parent.layoutData == null) || !(parent.layoutData instanceof ParentInfo)) {
parent.layoutData = new ParentInfo();
}
-
return (ParentInfo) parent.layoutData;
}
private void arrangeGridImpl(Container parent, ParentInfo info) {
validate(parent, info);
-
// Do not check clientRect for emptiness. Grid mus be updated anyway
Rectangle clientRect = parent.getClient();
info.grid.fit2Client(clientRect);
@@ -489,92 +466,77 @@
private void setComponentsBounds(ParentInfo info) {
for (int i = 0; i < info.components.length; i++) {
Rectangle r = new Rectangle();
-
calculateComponentBounds(info.horCompSides[i], info.vertCompSides[i], r, info.grid);
-
info.components[i].setBounds(r);
}
}
- private void calculateComponentBounds(ComponentSide horSide,
- ComponentSide vertSide, Rectangle r, Grid grid)
- {
+ private void calculateComponentBounds(ComponentSide horSide, ComponentSide vertSide,
+ Rectangle r, Grid grid) {
Rectangle dispArea = grid.componentDisplayArea(horSide, vertSide);
r.width = fillDisplaySide(dispArea.width, horSide);
r.height = fillDisplaySide(dispArea.height, vertSide);
r.x = anchorComponentSide(dispArea.x, dispArea.width, horSide, r.width);
- r.y = anchorComponentSide(dispArea.y, dispArea.height, vertSide,
- r.height);
+ r.y = anchorComponentSide(dispArea.y, dispArea.height, vertSide, r.height);
}
private int fillDisplaySide(int dispLength, ComponentSide compSide) {
int l = Math.max(dispLength - compSide.start_inset - compSide.end_inset, 0);
-
if (l < compSide.minLength) {
l = Math.min(compSide.minLength, dispLength);
} else if (!compSide.stretch) {
l = Math.min(l, compSide.prefLength);
}
-
return l;
}
- private int anchorComponentSide(int dispStart, int dispLength,
- ComponentSide compSide, int compLength)
- {
-// if (compLength == 0) {
-// return 0;
-// }
-
+ private int anchorComponentSide(int dispStart, int dispLength, ComponentSide compSide,
+ int compLength) {
+ // if (compLength == 0) {
+ // return 0;
+ // }
int insDispLength = dispLength - compSide.start_inset - compSide.end_inset;
-
if (compLength <= insDispLength) {
int s = dispStart + compSide.start_inset;
-
switch (compSide.position) {
- case ComponentSide.POS_START:
- break;
- case ComponentSide.POS_CENTER:
- s += (insDispLength - compLength) / 2;
- break;
- case ComponentSide.POS_END:
- s += insDispLength - compLength;
- break;
+ case ComponentSide.POS_START:
+ break;
+ case ComponentSide.POS_CENTER:
+ s += (insDispLength - compLength) / 2;
+ break;
+ case ComponentSide.POS_END:
+ s += insDispLength - compLength;
+ break;
}
-
return s;
}
float insetFactor = (float) (dispLength - compLength)
/ (float) (compSide.start_inset + compSide.end_inset);
-
return (dispStart + (int) (compSide.start_inset * insetFactor));
}
private void initHorCompSide(ComponentSide side, GridBagConstraints cons,
- Dimension minSize, Dimension prefSize, ParentInfo info)
- {
+ Dimension minSize, Dimension prefSize, ParentInfo info) {
MixedConstraints mixCons = info.consTable.get(cons);
-
side.gridStart = mixCons.mapped.x;
side.gridLength = mixCons.mapped.width;
-
side.weight = cons.weightx;
side.start_inset = cons.insets.left;
side.end_inset = cons.insets.right;
int anchor = translateRelativeAnchor(cons.anchor, info.orientation.isLeftToRight());
switch (anchor) {
- case GridBagConstraints.NORTHWEST:
- case GridBagConstraints.WEST:
- case GridBagConstraints.SOUTHWEST:
- side.position = ComponentSide.POS_START;
- break;
- case GridBagConstraints.NORTH:
- case GridBagConstraints.CENTER:
- case GridBagConstraints.SOUTH:
- side.position = ComponentSide.POS_CENTER;
- break;
- default:
- side.position = ComponentSide.POS_END;
+ case GridBagConstraints.NORTHWEST:
+ case GridBagConstraints.WEST:
+ case GridBagConstraints.SOUTHWEST:
+ side.position = ComponentSide.POS_START;
+ break;
+ case GridBagConstraints.NORTH:
+ case GridBagConstraints.CENTER:
+ case GridBagConstraints.SOUTH:
+ side.position = ComponentSide.POS_CENTER;
+ break;
+ default:
+ side.position = ComponentSide.POS_END;
}
if ((cons.fill == GridBagConstraints.BOTH)
|| (cons.fill == GridBagConstraints.HORIZONTAL)) {
@@ -587,34 +549,30 @@
}
private void initVertCompSide(ComponentSide side, GridBagConstraints cons,
- Dimension minSize, Dimension prefSize, ParentInfo info)
- {
+ Dimension minSize, Dimension prefSize, ParentInfo info) {
MixedConstraints mixCons = info.consTable.get(cons);
-
side.gridStart = mixCons.mapped.y;
side.gridLength = mixCons.mapped.height;
-
side.weight = cons.weighty;
side.start_inset = cons.insets.top;
side.end_inset = cons.insets.bottom;
int anchor = translateRelativeAnchor(cons.anchor, info.orientation.isLeftToRight());
switch (anchor) {
- case GridBagConstraints.NORTHWEST:
- case GridBagConstraints.NORTH:
- case GridBagConstraints.NORTHEAST:
- side.position = ComponentSide.POS_START;
- break;
- case GridBagConstraints.WEST:
- case GridBagConstraints.CENTER:
- case GridBagConstraints.EAST:
- side.position = ComponentSide.POS_CENTER;
- break;
- default:
- side.position = ComponentSide.POS_END;
+ case GridBagConstraints.NORTHWEST:
+ case GridBagConstraints.NORTH:
+ case GridBagConstraints.NORTHEAST:
+ side.position = ComponentSide.POS_START;
+ break;
+ case GridBagConstraints.WEST:
+ case GridBagConstraints.CENTER:
+ case GridBagConstraints.EAST:
+ side.position = ComponentSide.POS_CENTER;
+ break;
+ default:
+ side.position = ComponentSide.POS_END;
}
if ((cons.fill == GridBagConstraints.BOTH)
- || (cons.fill == GridBagConstraints.VERTICAL))
- {
+ || (cons.fill == GridBagConstraints.VERTICAL)) {
side.stretch = true;
} else {
side.stretch = false;
@@ -625,34 +583,32 @@
private int translateRelativeAnchor(int relAnchor, boolean l2r) {
int absAnchor = relAnchor;
-
switch (relAnchor) {
- case GridBagConstraints.PAGE_START:
- absAnchor = GridBagConstraints.NORTH;
- break;
- case GridBagConstraints.PAGE_END:
- absAnchor = GridBagConstraints.SOUTH;
- break;
- case GridBagConstraints.LINE_START:
- absAnchor = l2r ? GridBagConstraints.WEST : GridBagConstraints.EAST;
- break;
- case GridBagConstraints.LINE_END:
- absAnchor = l2r ? GridBagConstraints.EAST : GridBagConstraints.WEST;
- break;
- case GridBagConstraints.FIRST_LINE_START:
- absAnchor = l2r ? GridBagConstraints.NORTHWEST : GridBagConstraints.NORTHEAST;
- break;
- case GridBagConstraints.FIRST_LINE_END:
- absAnchor = l2r ? GridBagConstraints.NORTHEAST : GridBagConstraints.NORTHWEST;
- break;
- case GridBagConstraints.LAST_LINE_START:
- absAnchor = l2r ? GridBagConstraints.SOUTHWEST : GridBagConstraints.SOUTHEAST;
- break;
- case GridBagConstraints.LAST_LINE_END:
- absAnchor = l2r ? GridBagConstraints.SOUTHEAST : GridBagConstraints.SOUTHWEST;
- break;
+ case GridBagConstraints.PAGE_START:
+ absAnchor = GridBagConstraints.NORTH;
+ break;
+ case GridBagConstraints.PAGE_END:
+ absAnchor = GridBagConstraints.SOUTH;
+ break;
+ case GridBagConstraints.LINE_START:
+ absAnchor = l2r ? GridBagConstraints.WEST : GridBagConstraints.EAST;
+ break;
+ case GridBagConstraints.LINE_END:
+ absAnchor = l2r ? GridBagConstraints.EAST : GridBagConstraints.WEST;
+ break;
+ case GridBagConstraints.FIRST_LINE_START:
+ absAnchor = l2r ? GridBagConstraints.NORTHWEST : GridBagConstraints.NORTHEAST;
+ break;
+ case GridBagConstraints.FIRST_LINE_END:
+ absAnchor = l2r ? GridBagConstraints.NORTHEAST : GridBagConstraints.NORTHWEST;
+ break;
+ case GridBagConstraints.LAST_LINE_START:
+ absAnchor = l2r ? GridBagConstraints.SOUTHWEST : GridBagConstraints.SOUTHEAST;
+ break;
+ case GridBagConstraints.LAST_LINE_END:
+ absAnchor = l2r ? GridBagConstraints.SOUTHEAST : GridBagConstraints.SOUTHWEST;
+ break;
}
-
return absAnchor;
}
@@ -661,7 +617,6 @@
return;
}
info.valid = true;
-
resetCache(parent, info);
info.orientation = parent.getComponentOrientation();
Dimension maxSize = initCompsArray(parent, info.components);
@@ -669,8 +624,8 @@
initCompSides(info);
info.grid.validate(info);
if (layoutInfo == null) {
- layoutInfo = new GridBagLayoutInfo(info.grid.lookupWidths(),
- info.grid.lookupHeights());
+ layoutInfo = new GridBagLayoutInfo(info.grid.lookupWidths(), info.grid
+ .lookupHeights());
} else {
layoutInfo.update(info.grid.lookupWidths(), info.grid.lookupHeights());
}
@@ -679,13 +634,12 @@
private void initCompSides(ParentInfo info) {
for (int i = 0; i < info.components.length; i++) {
Component comp = info.components[i];
-
info.horCompSides[i] = new ComponentSide();
- initHorCompSide(info.horCompSides[i], comptable.get(comp),
- comp.getMinimumSize(), comp.getPreferredSize(), info);
+ initHorCompSide(info.horCompSides[i], comptable.get(comp), comp.getMinimumSize(),
+ comp.getPreferredSize(), info);
info.vertCompSides[i] = new ComponentSide();
- initVertCompSide(info.vertCompSides[i], comptable.get(comp),
- comp.getMinimumSize(), comp.getPreferredSize(), info);
+ initVertCompSide(info.vertCompSides[i], comptable.get(comp), comp.getMinimumSize(),
+ comp.getPreferredSize(), info);
}
}
@@ -693,44 +647,34 @@
int maxW = 0;
int maxH = 0;
int i = 0;
-
for (Enumeration<Component> keys = comptable.keys(); keys.hasMoreElements();) {
Component comp = keys.nextElement();
-
GridBagConstraints cons = comptable.get(comp);
-
if ((comp.getParent() == parent) && comp.isVisible()) {
components[i++] = comp;
}
-
if ((cons.gridx != GridBagConstraints.RELATIVE)
- && (cons.gridy != GridBagConstraints.RELATIVE) )
- {
+ && (cons.gridy != GridBagConstraints.RELATIVE)) {
maxW = Math.max(maxW, cons.gridx + cons.gridwidth);
maxH = Math.max(maxH, cons.gridy + cons.gridheight);
}
}
-
return new Dimension(maxW, maxH);
}
private int getComponentsNumber(Container parent) {
int componentsNumber = 0;
-
for (Enumeration<Component> keys = comptable.keys(); keys.hasMoreElements();) {
Component comp = keys.nextElement();
-
if ((comp.getParent() == parent) && comp.isVisible()) {
componentsNumber++;
}
}
-
return componentsNumber;
}
private void resetCache(Container parent, ParentInfo info) {
int componentsNumber = getComponentsNumber(parent);
-
info.components = new Component[componentsNumber];
info.horCompSides = new ComponentSide[componentsNumber];
info.vertCompSides = new ComponentSide[componentsNumber];
@@ -742,15 +686,11 @@
return;
}
ParentInfo info = getParentInfo(parent);
-
-
-
if (!info.consTable.containsKey(gbc)) {
MixedConstraints mixCons = new MixedConstraints(gbc);
info.consTable.put(gbc, mixCons);
info.allConstraints.add(mixCons);
}
-
}
private void updateParentInfo(Container parent) {
@@ -759,19 +699,25 @@
GridBagConstraints gbc = comptable.get(element);
updateParentInfo(parent, gbc);
}
-
}
private class RelativeTranslator {
+ private int curY; //Left-to-right (or vice versa)
+
+ private final int curX[]; // up-to-down
+
+ private int maxW; //Common for relative
+
+ private int maxH; // and absolute components
- private int curY; //Left-to-right (or vice versa)
- private int curX[]; // up-to-down
- private int maxW; //Common for relative
- private int maxH; // and absolute components
private boolean relWComp;
+
private boolean relHComp;
+
private int relEndY;
+
private int relEndX;
+
public RelativeTranslator(int maxW, int maxH) {
this.maxW = maxW;
this.maxH = maxH;
@@ -791,43 +737,30 @@
private void spreadComponents(ArrayList<MixedConstraints> allConstraints) {
for (int i = 0; i < allConstraints.size(); i++) {
- MixedConstraints mixCons =
- allConstraints.get(i);
-
- assert !((relWComp && (mixCons.initial.width != GridBagConstraints.REMAINDER))
- || (relHComp && (mixCons.initial.height != GridBagConstraints.REMAINDER)))
- : "REMINDER component expected after RELATIVE one";
-
-
+ MixedConstraints mixCons = allConstraints.get(i);
+ assert !((relWComp && (mixCons.initial.width != GridBagConstraints.REMAINDER)) || (relHComp && (mixCons.initial.height != GridBagConstraints.REMAINDER))) : "REMINDER component expected after RELATIVE one";
if (curY == MAXGRIDSIZE) {
- throw new RuntimeException(
- "component is out of grid's range");
+ throw new RuntimeException("component is out of grid's range");
}
-
translateHor(mixCons, translateVert(mixCons, i, allConstraints));
-
}
-
assert !(relWComp || relHComp) : "REMINDER component expected after RELATIVE one";
}
private void applyOrientation(ParentInfo info) {
if (!info.orientation.isLeftToRight()) {
for (int i = 0; i < info.allConstraints.size(); i++) {
- MixedConstraints mixCons =
- info.allConstraints.get(i);
-
+ MixedConstraints mixCons = info.allConstraints.get(i);
if (mixCons.relative) {
- mixCons.mapped.x = maxW - mixCons.mapped.x
- - mixCons.mapped.width;
+ mixCons.mapped.x = maxW - mixCons.mapped.x - mixCons.mapped.width;
}
}
}
}
- private int translateVert(MixedConstraints mixCons, int i, ArrayList<MixedConstraints> allConstraints) {
+ private int translateVert(MixedConstraints mixCons, int i,
+ ArrayList<MixedConstraints> allConstraints) {
int endY;
-
if (mixCons.initial.y != GridBagConstraints.RELATIVE) {
curY = mixCons.initial.y;
}
@@ -854,14 +787,13 @@
throw new RuntimeException("component is out of grid's range");
}
maxH = Math.max(maxH, mixCons.mapped.y + mixCons.mapped.height);
-
return endY;
}
private void translateHor(MixedConstraints mixCons, int endY) {
int trueCurY = curY;
if (mixCons.initial.x != GridBagConstraints.RELATIVE) {
- for(;; trueCurY++) {
+ for (;; trueCurY++) {
if (trueCurY == MAXGRIDSIZE) {
throw new RuntimeException("component is out of grid's range");
}
@@ -889,8 +821,7 @@
curX[curY]++;
} else {
if (!relHComp) {
- int endX = Math.max(curX[trueCurY] + mixCons.mapped.width,
- relEndX);
+ int endX = Math.max(curX[trueCurY] + mixCons.mapped.width, relEndX);
for (int j = trueCurY; j < endY; j++) {
curX[j] = endX;
}
@@ -901,17 +832,15 @@
throw new RuntimeException("component is out of grid's range");
}
maxW = Math.max(maxW, mixCons.mapped.x + mixCons.mapped.width);
-
-// if (curYBackup >= 0) { //FIX
-// curY = curYBackup;
-// curYBackup = -1;
-// }
+ // if (curYBackup >= 0) { //FIX
+ // curY = curYBackup;
+ // curYBackup = -1;
+ // }
}
private void recalculateRemainders(ArrayList<MixedConstraints> allConstraints) {
for (int i = 0; i < allConstraints.size(); i++) {
MixedConstraints mixCons = allConstraints.get(i);
-
if (mixCons.initial.width == GridBagConstraints.REMAINDER) {
mixCons.mapped.width = maxW - mixCons.mapped.x;
} else if (mixCons.initial.width == GridBagConstraints.RELATIVE) {
@@ -923,43 +852,48 @@
}
}
}
-
if (mixCons.initial.height == GridBagConstraints.REMAINDER) {
mixCons.mapped.height = maxH - mixCons.mapped.y;
} else if (mixCons.initial.height == GridBagConstraints.RELATIVE) {
int reserve = maxH - mixCons.mapped.y - 2;
mixCons.mapped.height += reserve;
if ((i + 1) < allConstraints.size()) {
- allConstraints.get(i + 1).mapped.y +=
- reserve;
+ allConstraints.get(i + 1).mapped.y += reserve;
}
}
}
}
-
}
private class ComponentSide {
-
public static final int POS_START = 1;
+
public static final int POS_CENTER = 2;
+
public static final int POS_END = 3;
public int gridStart;
+
public int gridLength;
+
public int start_inset;
+
public int end_inset;
+
public int position;
+
public int minLength;
+
public int prefLength;
+
public double weight;
- public boolean stretch;
+ public boolean stretch;
}
private class Grid {
-
private final GridSide cols = new GridSide();
+
private final GridSide rows = new GridSide();
public void validate(ParentInfo info) {
@@ -975,14 +909,9 @@
return new Dimension(cols.getPrefLength(), rows.getPrefLength());
}
- public Rectangle componentDisplayArea(ComponentSide horSide,
- ComponentSide vertSide)
- {
- Segment hor = cols.componentDisplaySide(horSide.gridStart,
- horSide.gridLength);
- Segment vert = rows.componentDisplaySide(vertSide.gridStart,
- vertSide.gridLength);
-
+ public Rectangle componentDisplayArea(ComponentSide horSide, ComponentSide vertSide) {
+ Segment hor = cols.componentDisplaySide(horSide.gridStart, horSide.gridLength);
+ Segment vert = rows.componentDisplaySide(vertSide.gridStart, vertSide.gridLength);
return new Rectangle(hor.start, vert.start, hor.length, vert.length);
}
@@ -991,7 +920,6 @@
cols.fit2Client(horSeg);
clientRect.x = horSeg.start;
clientRect.width = horSeg.length;
-
Segment vertSeg = new Segment(clientRect.y, clientRect.height);
rows.fit2Client(vertSeg);
clientRect.y = vertSeg.start;
@@ -1041,35 +969,40 @@
public Point location(int x, int y, boolean l2r) {
int col = cols.location(x);
int row = Math.max(Math.min(rows.location(y), MAXGRIDSIZE - 1), 0);
-
if (col == MAXGRIDSIZE) {
col = l2r ? MAXGRIDSIZE - 1 : 0;
} else if (col == -1) {
col = l2r ? 0 : MAXGRIDSIZE - 1;
}
-
return new Point(col, row);
}
private class GridSide {
-
private final int coordinates[] = new int[MAXGRIDSIZE];
+
private final int lengths[] = new int[MAXGRIDSIZE];
/*Cashed data. Validation controlled by parent class*/
private final int minLengths[] = new int[MAXGRIDSIZE];
+
private int minLength = 0;
+
private final int prefLengths[] = new int[MAXGRIDSIZE];
+
private int prefLength = 0;
+
private final double weights[] = new double[MAXGRIDSIZE];
+
private double weight = 0.;
+
private int weightlessPrefLength = 0;
+
private int weightlessMinLength = 0;
+
private int weightyPartsNum = 0;
- public void validate(ComponentSide compSides[],
- int lengthsOverride[], double weightsOverride[])
- {
+ public void validate(ComponentSide compSides[], int lengthsOverride[],
+ double weightsOverride[]) {
resetCache();
spreadComponents(compSides);
applyOverrides(lengthsOverride, weightsOverride);
@@ -1086,17 +1019,14 @@
public Segment componentDisplaySide(int startPart, int partsNum) {
int l = 0;
-
for (int part = startPart; part < (startPart + partsNum); part++) {
l += lengths[part];
}
-
return new Segment(coordinates[startPart], l);
}
public void fit2Client(Segment clientSide) {
int start = clientSide.start;
-
if (clientSide.length > weightlessPrefLength) {
if (weight > 0.) {
if (clientSide.length >= prefLength) {
@@ -1111,20 +1041,17 @@
} else if (weightlessMinLength > clientSide.length) {
divideInsufficientLength(clientSide);
} else {
-// divideSufficientLength(clientSide);
+ // divideSufficientLength(clientSide);
divideInsufWeightyLength(clientSide);
}
-
calculateCoordinates(start);
}
public int[] getLengths() {
int res[] = new int[MAXGRIDSIZE];
-
for (int i = 0; i < MAXGRIDSIZE; i++) {
res[i] = lengths[i];
}
-
return res;
}
@@ -1142,11 +1069,9 @@
public double[] getWeights() {
double res[] = new double[MAXGRIDSIZE];
-
for (int i = 0; i < MAXGRIDSIZE; i++) {
res[i] = weights[i];
}
-
return res;
}
@@ -1160,12 +1085,10 @@
} else if (p >= (coordinates[MAXGRIDSIZE - 1] + lengths[MAXGRIDSIZE - 1])) {
return MAXGRIDSIZE;
}
-
int i = 0;
while (!((coordinates[i] <= p) && ((coordinates[i] + lengths[i]) > p))) {
i++;
}
-
return i;
}
@@ -1182,28 +1105,22 @@
}
}
- private void applyOverrides(int lengthsOverride[],
- double weightsOverride[])
- {
+ private void applyOverrides(int lengthsOverride[], double weightsOverride[]) {
if (weightsOverride != null) {
if (weightsOverride.length > MAXGRIDSIZE) {
- throw new RuntimeException(
- "Weights' overrides array is too long");
+ throw new RuntimeException("Weights' overrides array is too long");
}
for (int i = 0; i < weightsOverride.length; i++) {
weights[i] = Math.max(weights[i], weightsOverride[i]);
}
}
-
if (lengthsOverride != null) {
if (lengthsOverride.length > MAXGRIDSIZE) {
- throw new RuntimeException(
- "Lengths' overrides array is too long");
+ throw new RuntimeException("Lengths' overrides array is too long");
}
for (int i = 0; i < lengthsOverride.length; i++) {
minLengths[i] = lengthsOverride[i];
- prefLengths[i] = Math.max(prefLengths[i],
- lengthsOverride[i]);
+ prefLengths[i] = Math.max(prefLengths[i], lengthsOverride[i]);
}
}
}
@@ -1211,20 +1128,14 @@
private void spreadComponents(ComponentSide compSides[]) {
for (ComponentSide element : compSides) {
if (element.gridLength == 1) {
- int insets = element.start_inset
- + element.end_inset;
-
- spreadUnicellularComponent(element.gridStart,
- element.minLength + insets, element.prefLength + insets,
- element.weight);
+ int insets = element.start_inset + element.end_inset;
+ spreadUnicellularComponent(element.gridStart, element.minLength
+ + insets, element.prefLength + insets, element.weight);
}
}
-
for (ComponentSide element : compSides) {
if (element.gridLength > 1) {
- int insets = element.start_inset
- + element.end_inset;
-
+ int insets = element.start_inset + element.end_inset;
spreadMulticellularComponent(element.gridStart, element.gridLength,
element.minLength + insets, element.prefLength + insets,
element.weight);
@@ -1233,22 +1144,19 @@
}
private void spreadUnicellularComponent(int part, int minCompLength,
- int prefCompLength, double compWeight)
- {
+ int prefCompLength, double compWeight) {
minLengths[part] = Math.max(minLengths[part], minCompLength);
prefLengths[part] = Math.max(prefLengths[part], prefCompLength);
weights[part] = Math.max(weights[part], compWeight);
}
private void spreadMulticellularComponent(int startPart, int partsNum,
- int minCompLength, int prefCompLength, double compWeight)
- {
- double sumWeight = spreadComponentWeight(weights, startPart,
- partsNum, compWeight);
-
+ int minCompLength, int prefCompLength, double compWeight) {
+ double sumWeight = spreadComponentWeight(weights, startPart, partsNum,
+ compWeight);
spreadComponentLength(minLengths, startPart, partsNum, minCompLength, sumWeight);
- spreadComponentLength(prefLengths, startPart, partsNum, prefCompLength, sumWeight);
-
+ spreadComponentLength(prefLengths, startPart, partsNum, prefCompLength,
+ sumWeight);
}
private void resetCache() {
@@ -1263,16 +1171,13 @@
weightyPartsNum = 0;
}
- private void spreadComponentLength(int arr[], int startPart,
- int partsNum, int compLength, double sumWeight)
- {
+ private void spreadComponentLength(int arr[], int startPart, int partsNum,
+ int compLength, double sumWeight) {
int rest = compLength;
int lastPart = startPart + partsNum - 1;
-
for (int part = startPart; part < lastPart; part++) {
rest -= arr[part];
}
-
if (sumWeight != 0.0) {
rest -= arr[lastPart];
// divide extra length using weights
@@ -1280,21 +1185,19 @@
double accumWeight = 0.0;
for (int part = startPart; part <= lastPart; part++) {
accumWeight += weights[part];
- int curExtraL = (int) (rest * (accumWeight / sumWeight))
- - sharedExtraL;
+ int curExtraL = (int) (rest * (accumWeight / sumWeight)) - sharedExtraL;
arr[part] = Math.max(arr[part], arr[part] + curExtraL);
sharedExtraL += curExtraL;
}
- } else {
+ } else {
// just put all extra
// length into the last part
arr[lastPart] = Math.max(arr[lastPart], rest);
}
}
- private double spreadComponentWeight(double arr[], int startPart,
- int partsNum, double compWeight)
- {
+ private double spreadComponentWeight(double arr[], int startPart, int partsNum,
+ double compWeight) {
int lastPart = startPart + partsNum - 1;
double sumWeight = .0;
for (int part = startPart; part <= lastPart; part++) {
@@ -1314,12 +1217,10 @@
int extraL = clientSide.length - prefLength;
int sharedExtraL = 0;
double accumWeight = 0.;
-
for (int i = 0; i < MAXGRIDSIZE; i++) {
if (weights[i] > 0.) {
accumWeight += weights[i];
- int curExtraL = (int) (extraL * (accumWeight / weight))
- - sharedExtraL;
+ int curExtraL = (int) (extraL * (accumWeight / weight)) - sharedExtraL;
lengths[i] = prefLengths[i] + curExtraL;
sharedExtraL += curExtraL;
} else {
@@ -1332,12 +1233,10 @@
int extraL = clientSide.length - minLength;
int sharedExtraL = 0;
double accumWeight = 0.;
-
for (int i = 0; i < MAXGRIDSIZE; i++) {
if (weights[i] > 0.) {
accumWeight += weights[i];
- int curExtraL = (int) (extraL * (accumWeight / weight))
- - sharedExtraL;
+ int curExtraL = (int) (extraL * (accumWeight / weight)) - sharedExtraL;
lengths[i] = minLengths[i] + curExtraL;
sharedExtraL += curExtraL;
} else {
@@ -1350,22 +1249,19 @@
for (int i = 0; i < MAXGRIDSIZE; i++) {
lengths[i] = prefLengths[i];
}
-
return (clientSide.start + (clientSide.length - prefLength) / 2);
}
private void divideInsufficientLength(Segment clientSide) {
int sharedL = (weightlessMinLength - clientSide.length) / 2;
-
if (sharedL < 0) {
sharedL = 0;
}
for (int i = 0; i < MAXGRIDSIZE; i++) {
if (weights[i] > 0.) {
lengths[i] = 0;
- } else {
+ } else {
int minL = minLengths[i];
-
if (sharedL >= minL) {
sharedL -= minL;
lengths[i] = 0;
@@ -1379,57 +1275,54 @@
private void calculateCoordinates(int start) {
coordinates[0] = start;
-
for (int i = 1; i < MAXGRIDSIZE; i++) {
coordinates[i] = coordinates[i - 1] + lengths[i - 1];
}
}
-
}
-
}
private class Segment {
-
public int start;
+
public int length;
Segment(int start, int length) {
this.start = start;
this.length = length;
}
-
}
private class MixedConstraints {
+ public Rectangle initial; //Relative/Absolute
+
+ public Rectangle mapped; //Absolute
- public Rectangle initial; //Relative/Absolute
- public Rectangle mapped; //Absolute
public boolean relative;
MixedConstraints(GridBagConstraints cons) {
- initial = new Rectangle(cons.gridx, cons.gridy,
- cons.gridwidth, cons.gridheight);
+ initial = new Rectangle(cons.gridx, cons.gridy, cons.gridwidth, cons.gridheight);
mapped = new Rectangle();
relative = (cons.gridx == GridBagConstraints.RELATIVE)
|| (cons.gridy == GridBagConstraints.RELATIVE);
}
-
}
private class ParentInfo {
+ final HashMap<GridBagConstraints, MixedConstraints> consTable; // Components' constraints to relative constraints
- final HashMap<GridBagConstraints, MixedConstraints> consTable; // Components' constraints to relative constraints
- final ArrayList<MixedConstraints> allConstraints; // Only mapped rectangle is a part of cache
+ final ArrayList<MixedConstraints> allConstraints; // Only mapped rectangle is a part of cache
final Grid grid;
boolean valid;
ComponentSide horCompSides[];
+
ComponentSide vertCompSides[];
- Component components[]; // Hashtable is too slow
+ Component components[]; // Hashtable is too slow
+
ComponentOrientation orientation;
ParentInfo() {
@@ -1441,7 +1334,5 @@
horCompSides = vertCompSides = null;
components = null;
}
-
}
-
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Image.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Image.java?view=diff&rev=454042&r1=454041&r2=454042
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Image.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Image.java Sat Oct 7 16:10:23 2006
@@ -43,7 +43,7 @@
protected float accelerationPriority = 0.5f;
- private static ImageCapabilities capabilities = new ImageCapabilities(false);
+ private static final ImageCapabilities capabilities = new ImageCapabilities(false);
public abstract Object getProperty(String name, ImageObserver observer);