diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 27cbd78f5332..9f5fc7e4b4ac 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,125 @@ +2002-01-15 Tom Tromey + + Start of AWT merge with Classpath: + * Makefile.in: Rebuilt. + * Makefile.am (awt_java_source_files): Reference files in + gnu/java/awt, not gnu/gcj/awt. + * java/awt/image/BufferedImage.java: Updated copyright. + * java/awt/image/ComponentColorModel.java: Updated copyright. + * java/awt/image/ComponentSampleModel.java: Updated copyright. + * java/awt/image/DataBuffer.java: Updated copyright. + * java/awt/image/DataBufferByte.java: Updated copyright. + * java/awt/image/DataBufferInt.java: Updated copyright. + * java/awt/image/DataBufferUShort.java: Updated copyright. + * java/awt/image/IndexColorModel.java: Updated copyright. + * java/awt/image/PackedColorModel.java: Updated copyright. + * java/awt/image/Raster.java: Updated copyright. + * java/awt/image/RasterOp.java: Updated copyright. + * java/awt/image/SampleModel.java: Updated copyright. + * java/awt/image/SinglePixelPackedSampleModel.java: Updated copyright. + * java/awt/image/WritableRaster.java: Updated copyright. + * java/awt/color/ColorSpace.java: Updated copyright. + * java/awt/color/ICC_ColorSpace.java: Updated copyright + * java/awt/color/ICC_Profile.java: Updated copyright. + * java/awt/event/HierarchyBoundsAdapter.java: Updated copyright. + * java/awt/event/HierarchyBoundsListener.java: Updated copyright. + * java/awt/event/HierarchyEvent.java: Updated copyright. + * java/awt/event/HierarchyListener.java: Updated copyright. + * java/awt/geom/AffineTransform.java: Updated copyright. + * java/awt/geom/Dimension2D.java: Updated copyright. + * java/awt/geom/Ellipse2D.java: Updated copyright. + * java/awt/geom/IllegalPathStateException.java: Updated copyright. + * java/awt/geom/Line2D.java: Updated copyright. + * java/awt/geom/NoninvertibleTransformException.java: Updated + copyright. + * java/awt/geom/PathIterator.java: Updated copyright. + * java/awt/geom/Point2D.java: Updated copyright. + * java/awt/geom/Rectangle2D.java: Updated copyright. + * java/awt/geom/RectangularShape.java: Updated copyright. + * java/awt/geom/RoundRectangle2D.java: Updated copyright. + * java/awt/Toolkit.java: Updated import for file moves. + * java/awt/Rectangle.java: Updated copyright; added javadoc from + Classpath. + (hashCode): New method from Classpath. + * java/awt/Graphics2D.java: Updated copyright. + * java/awt/Transparency.java: Updated copyright. + * java/awt/Paint.java: Updated copyright. + * java/awt/Graphics.java: New version from Classpath. + * java/awt/EventDispatchThread.java: Updated copyright. + * java/awt/CardLayout.java (layoutContainer): Don't skip invisible + children. + (gotoComponent): Wrap around on next/previous. + * gnu/gcj/awt/BitMaskExtent.java: Removed. + * gnu/gcj/awt/Buffers.java: Removed. + * gnu/gcj/awt/ComponentDataBlitOp.java: Removed. + * gnu/gcj/awt/GLightweightPeer.java: Removed. + * gnu/java/awt/BitMaskExtent.java: Added. + * gnu/java/awt/Buffers.java: Added. + * gnu/java/awt/ComponentDataBlitOp.java: Added. + * gnu/java/awt/GLightweightPeer.java: Added. + * java/awt/geom/Line2D.java (clone): Ignore + CloneNotSupportedException. + * gnu/gcj/awt/GLightweightPeer.java (getColorModel): New method. + * java/awt/Frame.java: Merged with Classpath. + * java/awt/RenderingHints.java: Copyright update. + * java/awt/Paint.java: Copyright update. + * java/awt/image/DirectColorModel.java: Merged with Classpath. + * java/awt/image/ColorModel.java: Merged with Classpath. + * java/awt/Window.java (show): New Implementation from Classpath. + (isShowing): Use super.isShowing(). + * java/awt/EventQueue.java: Merged with Classpath. + * java/awt/AWTEventMulticaster.java (save): Throw + RuntimeException. + (saveInternal): Likewise. + * java/awt/AWTEvent.java: Now implements Serializable. + * java/awt/Event.java: Copyright update. + * java/awt/peer/ComponentPeer.java: Merged with Classpath. + * java/awt/image/BufferedImage.java: Copyright update. + * java/awt/GraphicsConfiguration.java: Copyright update. + * java/awt/Component.java: (addNotify): Don't call + addNotifyContainerChildren(). + (addNotifyContainerChildren): Removed. + (setPeer): New method from Classpath. + (setTreeLock): Likewise. + (setVisible): Rewrote. + (show): Use it. + (hide): Likewise. + (validate): Set `valid'. + (checkImage(Image,ImageObserver)): Implementation from Classpath. + (createImage(ImageProducer)): Likewise. + (prepareImage): Likewise. + * java/awt/Container.java (addImpl): Handle case where constraint + is not a String. Post event via system event queue. + (remove): Post event via system event queue. + (validateTree): Only validate child if it is invalid. + (getAlignmentX): Call super method as default. + (getAlignmentY): Likewise. + (addContainerListener): Now synchronized. + (removeContainerListener): Likewise. + (addNotifyContainerChildren): Now private. + * java/awt/ComponentOrientation.java: Updated copyright. Added + @author. + * java/awt/FlowLayout.java (serialVersionUID): New field. + (setAlignment): Better exception message. + (layoutContainer): Don't compute component's preferred size unless + we're going to use it. + * java/awt/BorderLayout.java (AFTER_LAST_LINE, AFTER_LINE_ENDS, + BEFORE_FIRST_LINE, BEFORE_LINE_BEGINS): New constants. + (firstLine, lastLine, firstItem, lastItem): New fields. + (addLayoutComponent): Handle case where constraints is null. + Also, handle relative locations. + (removeLayoutComponent): Handle relative locations. + (MIN, MAX, PREF): New constants. + (calcCompSize): New method. + (calcSize): New method. + (minimumLayoutSize): Use it. + (preferredLayoutSize): Likewise. + (maximumLayoutSize): Likewise. + (toString): Include more information. + (setBounds): New method. + (layoutContainer): Use libgcj implementation; extended to handle + relative locations. + 2002-01-15 Tom Tromey * java/lang/Float.java (equals): Preserve old code. diff --git a/libjava/Makefile.am b/libjava/Makefile.am index 18dba408b81d..3ce308c6d67d 100644 --- a/libjava/Makefile.am +++ b/libjava/Makefile.am @@ -583,10 +583,10 @@ gnu/awt/j2d/DirectRasterGraphics.java \ gnu/awt/j2d/Graphics2DImpl.java \ gnu/awt/j2d/IntegerGraphicsState.java \ gnu/awt/j2d/MappedRaster.java \ -gnu/gcj/awt/BitMaskExtent.java \ -gnu/gcj/awt/Buffers.java \ -gnu/gcj/awt/ComponentDataBlitOp.java \ -gnu/gcj/awt/GLightweightPeer.java \ +gnu/java/awt/BitMaskExtent.java \ +gnu/java/awt/Buffers.java \ +gnu/java/awt/ComponentDataBlitOp.java \ +gnu/java/awt/GLightweightPeer.java \ gnu/java/beans/editors/ColorEditor.java \ gnu/java/beans/editors/FontEditor.java \ gnu/java/beans/editors/NativeBooleanEditor.java \ diff --git a/libjava/Makefile.in b/libjava/Makefile.in index 234bda5a815b..ac5848dab469 100644 --- a/libjava/Makefile.in +++ b/libjava/Makefile.in @@ -334,10 +334,10 @@ gnu/awt/j2d/DirectRasterGraphics.java \ gnu/awt/j2d/Graphics2DImpl.java \ gnu/awt/j2d/IntegerGraphicsState.java \ gnu/awt/j2d/MappedRaster.java \ -gnu/gcj/awt/BitMaskExtent.java \ -gnu/gcj/awt/Buffers.java \ -gnu/gcj/awt/ComponentDataBlitOp.java \ -gnu/gcj/awt/GLightweightPeer.java \ +gnu/java/awt/BitMaskExtent.java \ +gnu/java/awt/Buffers.java \ +gnu/java/awt/ComponentDataBlitOp.java \ +gnu/java/awt/GLightweightPeer.java \ gnu/java/beans/editors/ColorEditor.java \ gnu/java/beans/editors/FontEditor.java \ gnu/java/beans/editors/NativeBooleanEditor.java \ @@ -1732,11 +1732,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ .deps/gnu/awt/xlib/XGraphicsConfiguration.P \ .deps/gnu/awt/xlib/XPanelPeer.P .deps/gnu/awt/xlib/XToolkit.P \ .deps/gnu/classpath/Configuration.P .deps/gnu/gcj/Core.P \ -.deps/gnu/gcj/RawData.P .deps/gnu/gcj/awt/BitMaskExtent.P \ -.deps/gnu/gcj/awt/Buffers.P .deps/gnu/gcj/awt/ComponentDataBlitOp.P \ -.deps/gnu/gcj/awt/GLightweightPeer.P \ -.deps/gnu/gcj/convert/BytesToUnicode.P .deps/gnu/gcj/convert/Convert.P \ -.deps/gnu/gcj/convert/IOConverter.P \ +.deps/gnu/gcj/RawData.P .deps/gnu/gcj/convert/BytesToUnicode.P \ +.deps/gnu/gcj/convert/Convert.P .deps/gnu/gcj/convert/IOConverter.P \ .deps/gnu/gcj/convert/Input_8859_1.P \ .deps/gnu/gcj/convert/Input_ASCII.P \ .deps/gnu/gcj/convert/Input_EUCJIS.P \ @@ -1802,6 +1799,9 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ .deps/gnu/gcj/xlib/natXColor.P .deps/gnu/gcj/xlib/natXConfigureEvent.P \ .deps/gnu/gcj/xlib/natXException.P .deps/gnu/gcj/xlib/natXExposeEvent.P \ .deps/gnu/gcj/xlib/natXImage.P .deps/gnu/gcj/xlib/natXUnmapEvent.P \ +.deps/gnu/java/awt/BitMaskExtent.P .deps/gnu/java/awt/Buffers.P \ +.deps/gnu/java/awt/ComponentDataBlitOp.P \ +.deps/gnu/java/awt/GLightweightPeer.P \ .deps/gnu/java/beans/BeanInfoEmbryo.P \ .deps/gnu/java/beans/EmptyBeanInfo.P \ .deps/gnu/java/beans/ExplicitBeanInfo.P \ diff --git a/libjava/gnu/awt/xlib/XGraphicsConfiguration.java b/libjava/gnu/awt/xlib/XGraphicsConfiguration.java index af2663ba58bc..69cc6e2b5e27 100644 --- a/libjava/gnu/awt/xlib/XGraphicsConfiguration.java +++ b/libjava/gnu/awt/xlib/XGraphicsConfiguration.java @@ -26,7 +26,7 @@ import gnu.gcj.xlib.Colormap; import gnu.gcj.xlib.XColor; import gnu.gcj.xlib.Screen; import gnu.gcj.xlib.Display; -import gnu.gcj.awt.Buffers; +import gnu.java.awt.Buffers; import java.util.Hashtable; public class XGraphicsConfiguration extends GraphicsConfiguration diff --git a/libjava/gnu/gcj/awt/BitMaskExtent.java b/libjava/gnu/gcj/awt/BitMaskExtent.java deleted file mode 100644 index 884ab502dc9c..000000000000 --- a/libjava/gnu/gcj/awt/BitMaskExtent.java +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2000 Free Software Foundation - - This file is part of libgcj. - -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - -package gnu.gcj.awt; - -/** - * Simple transparent utility class that can be used to perform bit - * mask extent calculations. - */ -public final class BitMaskExtent -{ - /** The number of the least significant bit of the bit mask extent. */ - public byte leastSignificantBit; - - /** The number of bits in the bit mask extent. */ - public byte bitWidth; - - /** - * Set the bit mask. This will calculate and set the leastSignificantBit - * and bitWidth fields. - * - * @see #leastSignificantBit - * @see #bitWidth - */ - public void setMask(long mask) - { - leastSignificantBit = 0; - bitWidth = 0; - if (mask == 0) return; - long shiftMask = mask; - for (; (shiftMask&1) == 0; shiftMask >>>=1) leastSignificantBit++; - for (; (shiftMask&1) != 0; shiftMask >>>=1) bitWidth++; - - if (shiftMask != 0) - throw new IllegalArgumentException("mask must be continuous"); - } - - /** - * Calculate the bit mask based on the values of the - * leastSignificantBit and bitWidth fields. - */ - public long toMask() - { - return ((1<>>=1) leastSignificantBit++; + for (; (shiftMask&1) != 0; shiftMask >>>=1) bitWidth++; + + if (shiftMask != 0) + throw new IllegalArgumentException("mask must be continuous"); + } + + /** + * Calculate the bit mask based on the values of the + * leastSignificantBit and bitWidth fields. + */ + public long toMask() + { + return ((1< file defines LC_MESSAGES. */ +#undef HAVE_LC_MESSAGES + /* Required define if using POSIX threads */ #undef _REENTRANT diff --git a/libjava/java/awt/AWTEvent.java b/libjava/java/awt/AWTEvent.java index 0717f6dda4c8..cb37b642c1d7 100644 --- a/libjava/java/awt/AWTEvent.java +++ b/libjava/java/awt/AWTEvent.java @@ -1,10 +1,28 @@ -/* Copyright (C) 1999, 2000 Free Software Foundation +/* Copyright (C) 1999, 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ package java.awt; @@ -18,26 +36,83 @@ package java.awt; /** * AWTEvent is the root event class for all AWT events in the JDK 1.1 event * model. It supersedes the Event class from JDK 1.0. + * @author Warren Levy + * @author Aaron M. Renn (arenn@urbanophile.com) */ - public abstract class AWTEvent extends java.util.EventObject { + /** + * @serial Indicates whether or not this event has been consumed. + */ protected boolean consumed; + + /** + * @serial The identifier number of this event. + */ protected int id; - /* Event selection masks */ - public static final long COMPONENT_EVENT_MASK = 1 << 0, - CONTAINER_EVENT_MASK = 1 << 1, - FOCUS_EVENT_MASK = 1 << 2, - KEY_EVENT_MASK = 1 << 3, - MOUSE_EVENT_MASK = 1 << 4, - MOUSE_MOTION_EVENT_MASK = 1 << 5, - WINDOW_EVENT_MASK = 1 << 6, - ACTION_EVENT_MASK = 1 << 7, - ADJUSTMENT_EVENT_MASK = 1 << 8, - ITEM_EVENT_MASK = 1 << 9, - TEXT_EVENT_MASK = 1 << 10, - INPUT_METHOD_EVENT_MASK = 1 << 11; + /** + * Mask for selecting component events. + */ + public static final long COMPONENT_EVENT_MASK = 0x001; + + /** + * Mask for selecting container events. + */ + public static final long CONTAINER_EVENT_MASK = 0x002; + + /** + * Mask for selecting component focus events. + */ + public static final long FOCUS_EVENT_MASK = 0x004; + + /** + * Mask for selecting keyboard events. + */ + public static final long KEY_EVENT_MASK = 0x008; + + /** + * Mask for mouse button events. + */ + public static final long MOUSE_EVENT_MASK = 0x010; + + /** + * Mask for mouse motion events. + */ + public static final long MOUSE_MOTION_EVENT_MASK = 0x020; + + /** + * Mask for window events. + */ + public static final long WINDOW_EVENT_MASK = 0x040; + + /** + * Mask for action events. + */ + public static final long ACTION_EVENT_MASK = 0x080; + + /** + * Mask for adjustment events. + */ + public static final long ADJUSTMENT_EVENT_MASK = 0x100; + + /** + * Mask for item events. + */ + public static final long ITEM_EVENT_MASK = 0x200; + + /** + * Mask for text events. + */ + public static final long TEXT_EVENT_MASK = 0x400; + + /** + * This is the highest number for event ids that are reserved for use by + * the AWT system itself. + */ + public static final int RESERVED_ID_MAX = 1999; + + public static final long INPUT_METHOD_EVENT_MASK = 1 << 11; /* Additional event selection masks from JDK 1.3 javadocs */ public static final long PAINT_EVENT_MASK = 1 << 13, @@ -45,41 +120,82 @@ public abstract class AWTEvent extends java.util.EventObject HIERARCHY_EVENT_MASK = 1 << 15, HIERARCHY_BOUNDS_EVENT_MASK = 1 << 16; - public static final int RESERVED_ID_MAX = 0x7cf; - + /** + * Initializes a new instance of AWTEvent from the + * specified Java 1.0 event object. + * + * @param event The Java 1.0 event to initialize from. + * + * + * Removed this method because we no longer support Java 1.0 + * + */ public AWTEvent(Event event) { // FIXME?? super(event.target); this.id = event.id; } - + + /** + * Initializes a new instance of AWTEvent with the specified + * source and id. + * + * @param source The object that caused the event. + * @param id The event id. + */ public AWTEvent(Object source, int id) { super(source); this.id = id; } + /** + * Returns the id number of this event. + * + * @return The id number of this event. + */ public int getID() { return id; } + /** + * Returns a string representation of this event. + * + * @return A string representation of this event. + */ public String paramString () { return ""; } + /** + * Returns a string representation of this event. + * + * @return A string representation of this event. + */ public String toString () { return getClass().getName() + "[" + paramString() + "] on " + source; } - + + /** + * Consumes this event so that it will not be processed in the default + * manner. + */ protected void consume() { consumed = true; } - + + /** + * Tests whether not not this event has been consumed. A consumed event + * is not processed in the default manner. + * + * @return true if this event has been consumed, + * false otherwise. + */ protected boolean isConsumed() { return consumed; diff --git a/libjava/java/awt/AWTEventMulticaster.java b/libjava/java/awt/AWTEventMulticaster.java index 560ebbe3b660..f417ad940402 100644 --- a/libjava/java/awt/AWTEventMulticaster.java +++ b/libjava/java/awt/AWTEventMulticaster.java @@ -1,10 +1,28 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 1999, 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ package java.awt; @@ -21,20 +39,65 @@ import java.io.ObjectOutputStream; */ /** - * Convienience class for thread-safe multicasting of AWT events, - * without synchronization. - * - * @author Bryce McKinlay - */ - + * This class is used to implement a chain of event handlers. Dispatching + * using this class is thread safe. Here is a quick example of how to + * add and delete listeners using this class. For this example, we will + * assume are firing AdjustableEvent's. However, this + * same approach is useful for all events in the java.awt.event + * package, and more if this class is subclassed. + *

+ * + * AdjustmentListener al; + * + * public void + * addAdjustmentListener(AdjustmentListener listener) + * { + * al = AWTEventMulticaster.add(al, listener); + * } + * + * public void + * removeAdjustmentListener(AdjustmentListener listener) + * { + * al = AWTEventMulticaster.remove(al, listener); + * } + * + *

+ * When it come time to process an event, simply call al, + * assuming it is not null. + *

+ * The first time add is called it is passed + * null and listener as its arguments. This + * starts building the chain. This class returns listener + * which becomes the new al. The next time, add + * is called with al and listener and the + * new listener is then chained to the old. + * + * @author Bryce McKinlay + * @author Aaron M. Renn (arenn@urbanophile.com) + */ public class AWTEventMulticaster implements ComponentListener, ContainerListener, FocusListener, KeyListener, MouseListener, MouseMotionListener, WindowListener, ActionListener, ItemListener, AdjustmentListener, TextListener, InputMethodListener, HierarchyListener, HierarchyBoundsListener { - protected final EventListener a, b; + /** + * A variable in the event chain. + */ + protected final EventListener a; + /** + * A variable in the event chain + */ + protected final EventListener b; + + /** + * Initializes a new instance of AWTEventMulticaster with + * the specified event listener parameters. + * + * @param a The "a" listener object. + * @param b The "b" listener object. + */ protected AWTEventMulticaster(EventListener a, EventListener b) { @@ -42,6 +105,14 @@ public class AWTEventMulticaster implements ComponentListener, this.b = b; } + /** + * Chain EventListener b to a. + * + * @param a - Listener to chain to. + * @param b - Listener to chain. + * + * @return Latest entry in the chain. + */ protected static EventListener addInternal(EventListener a, EventListener b) { if (a == null) @@ -50,7 +121,15 @@ public class AWTEventMulticaster implements ComponentListener, return a; else return new AWTEventMulticaster(a, b); } - + + /** + * Removes the listener old from the listener lis. + * + * @param lis The listener to remove old from. + * @param old The listener to remove. + * + * @return The resulting listener after the remove operation. + */ protected static EventListener removeInternal(EventListener l, EventListener oldl) { @@ -64,7 +143,17 @@ public class AWTEventMulticaster implements ComponentListener, return l; } - /* Remove oldl from this multicaster. */ + /** + * Removes the specified object from this multicaster object. If the + * object to remove is not part of this multicaster, then the remove + * method on the parent multicaster (if it exists) is called and a + * new multicaster object is returned based on that object and this + * multicaster's non-parent object. + * + * @param old The object to remove from this multicaster. + * + * @return The resulting multicaster with the specified listener removed. + */ protected EventListener remove(EventListener oldl) { // If oldl is an immediate child, return the other child. @@ -73,7 +162,7 @@ public class AWTEventMulticaster implements ComponentListener, if (b == oldl) return a; - // If a and/or b are Multicaster's, search them recursivly. + // If a and/or b are Multicaster's, search them recursively. if (a instanceof AWTEventMulticaster) { AWTEventMulticaster mc = (AWTEventMulticaster) a; @@ -88,108 +177,236 @@ public class AWTEventMulticaster implements ComponentListener, if (newb != b) return new AWTEventMulticaster (a, newb); } - + // oldl was not found. return this; } + /** + * Chain ActionListener b to a. + * + * @param a - Listener to chain to. + * @param b - Listener to chain. + * + * @return Latest entry in the chain. + */ public static ActionListener add(ActionListener a, ActionListener b) { return (ActionListener) addInternal(a, b); } - + + /** + * Chain AdjustmentListener b to a. + * + * @param a - Listener to chain to. + * @param b - Listener to chain. + * + * @return Latest entry in the chain. + */ public static AdjustmentListener add(AdjustmentListener a, AdjustmentListener b) { return (AdjustmentListener) addInternal(a, b); } - + + /** + * Chain ComponentListener b to a. + * + * @param a - Listener to chain to. + * @param b - Listener to chain. + * + * @return Latest entry in the chain. + */ public static ComponentListener add(ComponentListener a, ComponentListener b) { return (ComponentListener) addInternal(a, b); } - + + /** + * Chain ContainerListener b to a. + * + * @param a - Listener to chain to. + * @param b - Listener to chain. + * + * @return Latest entry in the chain. + */ public static ContainerListener add(ContainerListener a, ContainerListener b) { return (ContainerListener) addInternal(a, b); } - + + /** + * Chain FocusListener b to a. + * + * @param a - Listener to chain to. + * @param b - Listener to chain. + * + * @return Latest entry in the chain. + */ public static FocusListener add(FocusListener a, FocusListener b) { return (FocusListener) addInternal(a, b); } - + public static HierarchyBoundsListener add(HierarchyBoundsListener a, HierarchyBoundsListener b) { return (HierarchyBoundsListener) addInternal(a, b); } - + public static HierarchyListener add(HierarchyListener a, HierarchyListener b) { return (HierarchyListener) addInternal(a, b); } - + public static InputMethodListener add(InputMethodListener a, InputMethodListener b) { return (InputMethodListener) addInternal(a, b); } - + + /** + * Chain ItemListener b to a. + * + * @param a - Listener to chain to. + * @param b - Listener to chain. + * + * @return Latest entry in the chain. + */ public static ItemListener add(ItemListener a, ItemListener b) { return (ItemListener) addInternal(a, b); } - + + /** + * Chain KeyListener b to a. + * + * @param a - Listener to chain to. + * @param b - Listener to chain. + * + * @return Latest entry in the chain. + */ public static KeyListener add(KeyListener a, KeyListener b) { return (KeyListener) addInternal(a, b); } + /** + * Chain MouseListener b to a. + * + * @param a - Listener to chain to. + * @param b - Listener to chain. + * + * @return Latest entry in the chain. + */ public static MouseListener add(MouseListener a, MouseListener b) { return (MouseListener) addInternal(a, b); } - + + /** + * Chain MouseMotionListener b to a. + * + * @param a - Listener to chain to. + * @param b - Listener to chain. + * + * @return Latest entry in the chain. + */ public static MouseMotionListener add(MouseMotionListener a, MouseMotionListener b) { return (MouseMotionListener) addInternal(a, b); } - + + /** + * Chain AdjustmentListener b to a. + * + * @param a - Listener to chain to. + * @param b - Listener to chain. + * + * @return Latest entry in the chain. + */ public static TextListener add(TextListener a, TextListener b) { return (TextListener) addInternal(a, b); } - + + /** + * Chain WindowListener b to a. + * + * @param a - Listener to chain to. + * @param b - Listener to chain. + * + * @return Latest entry in the chain. + */ public static WindowListener add(WindowListener a, WindowListener b) { return (WindowListener) addInternal(a, b); } - + + /** + * Removes the listener old from the listener lis. + * + * @param lis The listener to remove old from. + * @param old The listener to remove. + * + * @return The resulting listener after the remove operation. + */ public static ActionListener remove(ActionListener l, ActionListener oldl) { return (ActionListener) removeInternal(l, oldl); } - + + /** + * Removes the listener old from the listener lis. + * + * @param lis The listener to remove old from. + * @param old The listener to remove. + * + * @return The resulting listener after the remove operation. + */ public static AdjustmentListener remove(AdjustmentListener l, AdjustmentListener oldl) { return (AdjustmentListener) removeInternal(l, oldl); } + /** + * Removes the listener old from the listener lis. + * + * @param lis The listener to remove old from. + * @param old The listener to remove. + * + * @return The resulting listener after the remove operation. + */ public static ComponentListener remove(ComponentListener l, ComponentListener oldl) { return (ComponentListener) removeInternal(l, oldl); } + /** + * Removes the listener old from the listener lis. + * + * @param lis The listener to remove old from. + * @param old The listener to remove. + * + * @return The resulting listener after the remove operation. + */ public static ContainerListener remove(ContainerListener l, ContainerListener oldl) { return (ContainerListener) removeInternal(l, oldl); } + /** + * Removes the listener old from the listener lis. + * + * @param lis The listener to remove old from. + * @param old The listener to remove. + * + * @return The resulting listener after the remove operation. + */ public static FocusListener remove(FocusListener l, FocusListener oldl) { return (FocusListener) removeInternal(l, oldl); @@ -213,251 +430,500 @@ public class AWTEventMulticaster implements ComponentListener, return (InputMethodListener) removeInternal(l, oldl); } + /** + * Removes the listener old from the listener lis. + * + * @param lis The listener to remove old from. + * @param old The listener to remove. + * + * @return The resulting listener after the remove operation. + */ public static ItemListener remove(ItemListener l, ItemListener oldl) { return (ItemListener) removeInternal(l, oldl); } + /** + * Removes the listener old from the listener lis. + * + * @param lis The listener to remove old from. + * @param old The listener to remove. + * + * @return The resulting listener after the remove operation. + */ public static KeyListener remove(KeyListener l, KeyListener oldl) { return (KeyListener) removeInternal(l, oldl); } + /** + * Removes the listener old from the listener lis. + * + * @param lis The listener to remove old from. + * @param old The listener to remove. + * + * @return The resulting listener after the remove operation. + */ public static MouseListener remove(MouseListener l, MouseListener oldl) { return (MouseListener) removeInternal(l, oldl); } + /** + * Removes the listener old from the listener lis. + * + * @param lis The listener to remove old from. + * @param old The listener to remove. + * + * @return The resulting listener after the remove operation. + */ public static MouseMotionListener remove(MouseMotionListener l, MouseMotionListener oldl) { return (MouseMotionListener) removeInternal(l, oldl); } + /** + * Removes the listener old from the listener lis. + * + * @param lis The listener to remove old from. + * @param old The listener to remove. + * + * @return The resulting listener after the remove operation. + */ public static TextListener remove(TextListener l, TextListener oldl) { return (TextListener) removeInternal(l, oldl); } + /** + * Removes the listener old from the listener lis. + * + * @param lis The listener to remove old from. + * @param old The listener to remove. + * + * @return The resulting listener after the remove operation. + */ public static WindowListener remove(WindowListener l, WindowListener oldl) { return (WindowListener) removeInternal(l, oldl); } + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void actionPerformed(ActionEvent e) { ((ActionListener) a).actionPerformed(e); ((ActionListener) b).actionPerformed(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void adjustmentValueChanged(AdjustmentEvent e) { ((AdjustmentListener) a).adjustmentValueChanged(e); ((AdjustmentListener) b).adjustmentValueChanged(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void componentHidden(ComponentEvent e) { ((ComponentListener) a).componentHidden(e); ((ComponentListener) b).componentHidden(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void componentMoved(ComponentEvent e) { ((ComponentListener) a).componentMoved(e); ((ComponentListener) b).componentMoved(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void componentResized(ComponentEvent e) { ((ComponentListener) a).componentResized(e); ((ComponentListener) b).componentResized(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void componentShown(ComponentEvent e) { ((ComponentListener) a).componentShown(e); ((ComponentListener) b).componentShown(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void componentAdded(ContainerEvent e) { ((ContainerListener) a).componentAdded(e); ((ContainerListener) b).componentAdded(e); } + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void componentRemoved(ContainerEvent e) { ((ContainerListener) a).componentRemoved(e); ((ContainerListener) b).componentRemoved(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void focusGained(FocusEvent e) { ((FocusListener) a).focusGained(e); ((FocusListener) b).focusGained(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void focusLost(FocusEvent e) { ((FocusListener) a).focusLost(e); ((FocusListener) b).focusLost(e); } - + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void ancestorMoved(HierarchyEvent e) { ((HierarchyBoundsListener) a).ancestorMoved(e); ((HierarchyBoundsListener) b).ancestorMoved(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void ancestorResized(HierarchyEvent e) { ((HierarchyBoundsListener) a).ancestorResized(e); ((HierarchyBoundsListener) b).ancestorResized(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void hierarchyChanged(HierarchyEvent e) { ((HierarchyListener) a).hierarchyChanged(e); ((HierarchyListener) b).hierarchyChanged(e); } + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void caretPositionChanged(InputMethodEvent e) { ((InputMethodListener) a).caretPositionChanged(e); ((InputMethodListener) b).caretPositionChanged(e); } + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void inputMethodTextChanged(InputMethodEvent e) { ((InputMethodListener) a).inputMethodTextChanged(e); ((InputMethodListener) b).inputMethodTextChanged(e); } + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void itemStateChanged(ItemEvent e) { ((ItemListener) a).itemStateChanged(e); ((ItemListener) b).itemStateChanged(e); } + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void keyPressed(KeyEvent e) { ((KeyListener) a).keyPressed(e); ((KeyListener) b).keyPressed(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void keyReleased(KeyEvent e) { ((KeyListener) a).keyReleased(e); ((KeyListener) b).keyReleased(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void keyTyped(KeyEvent e) { ((KeyListener) a).keyTyped(e); ((KeyListener) b).keyTyped(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void mouseClicked(MouseEvent e) { ((MouseListener) a).mouseClicked(e); ((MouseListener) b).mouseClicked(e); } - - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void mouseEntered(MouseEvent e) { ((MouseListener) a).mouseEntered(e); ((MouseListener) b).mouseEntered(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void mouseExited(MouseEvent e) { ((MouseListener) a).mouseExited(e); ((MouseListener) b).mouseExited(e); } + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void mousePressed(MouseEvent e) { ((MouseListener) a).mousePressed(e); ((MouseListener) b).mousePressed(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void mouseReleased(MouseEvent e) { ((MouseListener) a).mouseReleased(e); ((MouseListener) b).mouseReleased(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void mouseDragged(MouseEvent e) { ((MouseMotionListener) a).mouseDragged(e); ((MouseMotionListener) b).mouseDragged(e); } + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void mouseMoved(MouseEvent e) { ((MouseMotionListener) a).mouseMoved(e); ((MouseMotionListener) b).mouseMoved(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void textValueChanged(TextEvent e) { ((TextListener) a).textValueChanged(e); ((TextListener) b).textValueChanged(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void windowActivated(WindowEvent e) { ((WindowListener) a).windowActivated(e); ((WindowListener) b).windowActivated(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void windowClosed(WindowEvent e) { ((WindowListener) a).windowClosed(e); ((WindowListener) b).windowClosed(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void windowClosing(WindowEvent e) { ((WindowListener) a).windowClosing(e); ((WindowListener) b).windowClosing(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void windowDeactivated(WindowEvent e) { ((WindowListener) a).windowDeactivated(e); ((WindowListener) b).windowDeactivated(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void windowDeiconified(WindowEvent e) { ((WindowListener) a).windowDeiconified(e); ((WindowListener) b).windowDeiconified(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void windowIconified(WindowEvent e) { ((WindowListener) a).windowIconified(e); ((WindowListener) b).windowIconified(e); } - + + /** + * Handles this event by dispatching it to the "a" and "b" listener + * instances. + * + * @param event The event to handle. + */ public void windowOpened(WindowEvent e) { ((WindowListener) a).windowOpened(e); ((WindowListener) b).windowOpened(e); } - + protected static void save(ObjectOutputStream s, String k, EventListener l) { - // FIXME + throw new RuntimeException("Not Implemented"); } protected void saveInternal(ObjectOutputStream s, String k) { - // FIXME + throw new RuntimeException("Not Implemented"); } - } diff --git a/libjava/java/awt/BorderLayout.java b/libjava/java/awt/BorderLayout.java index 0d779c1a7521..dd19b0ebb8e5 100644 --- a/libjava/java/awt/BorderLayout.java +++ b/libjava/java/awt/BorderLayout.java @@ -1,174 +1,481 @@ -/* Copyright (C) 1999, 2000 Free Software Foundation +/* BorderLayout.java -- A layout manager class + Copyright (C) 1999, 2002 Free Software Foundation, Inc. - This file is part of libjava. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ package java.awt; +/** + * This class implements a layout manager that positions components + * in certain sectors of the parent container. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Rolf W. Rasmussen + */ public class BorderLayout implements LayoutManager2, java.io.Serializable { - public static final String NORTH = "North", - SOUTH = "South", - EAST = "East", - WEST = "West", - CENTER = "Center"; - - // FIXME: use these too - public static final String BEFORE_FIRST_LINE = "First", - AFTER_LAST_LINE = "Last", - BEFORE_LINE_BEGINS = "Before", - AFTER_LINE_ENDS = "After"; +/* + * Static Variables + */ - // FIXME: check serialization of fields - int hgap; - int vgap; - Component north, south, east, west, center; +/** + * Constant indicating the top of the container + */ +public static final String NORTH = "North"; - public BorderLayout () - { - this (0, 0); - } +/** + * Constant indicating the bottom of the container + */ +public static final String SOUTH = "South"; - public BorderLayout (int hgap, int vgap) - { - this.hgap = hgap; - this.vgap = vgap; - } +/** + * Constant indicating the right side of the container + */ +public static final String EAST = "East"; - public int getHgap() - { - return hgap; - } +/** + * Constant indicating the left side of the container + */ +public static final String WEST = "West"; - public void setHgap(int hgap) - { - this.hgap = hgap; - } +/** + * Constant indicating the center of the container + */ +public static final String CENTER = "Center"; - public int getVgap() - { - return vgap; - } +/** + * Constant indicating the position just after the last line of the + * layout. + */ +public static final String AFTER_LAST_LINE = "Last"; - public void setVgap(int vgap) - { - this.vgap = vgap; - } - - public void addLayoutComponent(Component comp, Object constraints) - { - if ((constraints == null) || CENTER.equals(constraints)) - { - center = comp; - } - else if (NORTH.equals(constraints)) - { - north = comp; - } - else if (SOUTH.equals(constraints)) - { - south = comp; - } - else if (EAST.equals(constraints)) - { - east = comp; - } - else if (WEST.equals(constraints)) - { - west = comp; - } - } - - public void addLayoutComponent(String name, Component comp) - { - addLayoutComponent(comp, name); - } +/** + * Constant indicating the position just after the end of the line. + */ +public static final String AFTER_LINE_ENDS = "After"; - public void removeLayoutComponent(Component comp) - { - if (center == comp) - { - center = null; - } - else if (north == comp) - { - north = null; - } - else if (south == comp) - { - south = null; - } - else if (east == comp) - { - east = null; - } - else if (west == comp) - { - west = null; - } - } +/** + * Constant indicating the position just before the first line of the + * layout. + */ +public static final String BEFORE_FIRST_LINE = "First"; - public Dimension minimumLayoutSize(Container target) - { - return calcSize(getMinimumSize(center), - getMinimumSize(north), - getMinimumSize(south), - getMinimumSize(east), - getMinimumSize(west), - target); - } +/** + * Constant indicating the position at the beginning of the line. + */ +public static final String BEFORE_LINE_BEGINS = "Before"; - public Dimension preferredLayoutSize(Container target) - { - return calcSize(getPreferredSize(center), - getPreferredSize(north), - getPreferredSize(south), - getPreferredSize(east), - getPreferredSize(west), - target); - } - - /** - * Completely disregards the requested maximum sizes of the - * components, and states that the container has no upper size - * limit. - * - * @return a dimension of width and height Integer.MAX_VALUE. - */ - public Dimension maximumLayoutSize(Container target) - { - return (Dimension) DIM_MAX.clone(); - } +// Serialization constant +private static final long serialVersionUID = -8658291919501921765L; - public float getLayoutAlignmentX(Container parent) - { - return Component.CENTER_ALIGNMENT; - } +/*************************************************************************/ - public float getLayoutAlignmentY(Container parent) - { - return Component.CENTER_ALIGNMENT; - } - - public void invalidateLayout(Container target) - { - // TODO... implement caching? - } +/* + * Instance Variables + */ + +/** + * @serial + */ +private Component north; + +/** + * @serial + */ +private Component south; + +/** + * @serial + */ +private Component east; + +/** + * @serial + */ +private Component west; + +/** + * @serial + */ +private Component center; + +/** + * @serial + */ +private Component firstLine; + +/** + * @serial + */ +private Component lastLine; + +/** + * @serial + */ +private Component firstItem; + +/** + * @serial + */ +private Component lastItem; + +/** + * @serial The horizontal gap between components + */ +private int hgap; + +/** + * @serial The vertical gap between components + */ +private int vgap; + +/*************************************************************************/ + +/* + * Constructors + */ + +/** + * Initializes a new instance of BorderLayout with no + * horiztonal or vertical gaps between components. + */ +public +BorderLayout() +{ + this(0,0); +} + +/*************************************************************************/ + +/** + * Initializes a new instance of BorderLayout with the + * specified horiztonal and vertical gaps between components. + * + * @param hgap The horizontal gap between components. + * @param vgap The vertical gap between components. + */ +public +BorderLayout(int hgap, int vgap) +{ + this.hgap = hgap; + this.vgap = vgap; +} + +/*************************************************************************/ + +/* + * Instance Variables + */ + +/** + * Returns the horitzontal gap value. + * + * @return The horitzontal gap value. + */ +public int +getHgap() +{ + return(hgap); +} + +/*************************************************************************/ + +/** + * Sets the horizontal gap to the specified value. + * + * @param hgap The new horizontal gap. + */ +public void +setHgap(int hgap) +{ + this.hgap = hgap; +} + +/*************************************************************************/ + +/** + * Returns the vertical gap value. + * + * @return The vertical gap value. + */ +public int +getVgap() +{ + return(vgap); +} + +/*************************************************************************/ + +/** + * Sets the vertical gap to the specified value. + * + * @param vgap The new vertical gap value. + */ +public void +setVgap(int vgap) +{ + this.vgap = vgap; +} + +/*************************************************************************/ + +/** + * Adds a component to the layout in the specified constraint position, + * which must be one of the string constants defined in this class. + * + * @param component The component to add. + * @param constraints The constraint string. + * + * @exception IllegalArgumentException If the constraint object is not + * a string, or is not one of the specified constants in this class. + */ +public void +addLayoutComponent(Component component, Object constraints) +{ + if (constraints != null && ! (constraints instanceof String)) + throw new IllegalArgumentException("Constraint must be a string"); + + String str = (String)constraints; + + if (str == null || str.equals(CENTER)) + center = component; + if (str.equals(NORTH)) + north = component; + else if (str.equals(SOUTH)) + south = component; + else if (str.equals(EAST)) + east = component; + else if (str.equals(WEST)) + west = component; + else if (str.equals(BEFORE_FIRST_LINE)) + firstLine = component; + else if (str.equals(AFTER_LAST_LINE)) + lastLine = component; + else if (str.equals(BEFORE_LINE_BEGINS)) + firstItem = component; + else if (str.equals(AFTER_LINE_ENDS)) + lastItem = component; + else + throw new IllegalArgumentException("Constraint value not valid: " + str); +} + +/*************************************************************************/ + +/** + * 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 + * addLayoutComponent(Component, Object). + */ +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. + */ +public void +removeLayoutComponent(Component component) +{ + if (north == component) + north = null; + if (south == component) + south = null; + if (east == component) + east = null; + if (west == component) + west = null; + if (center == component) + center = null; + if (firstItem == component) + firstItem = null; + if (lastItem == component) + lastItem = null; + if (firstLine == component) + firstLine = null; + if (lastLine == component) + lastLine = null; +} + +/*************************************************************************/ + +/** + * Returns the minimum size of the specified container using this layout. + * + * @param target The container to calculate the minimum size for. + * + * @return The minimum size of the container + */ +public Dimension +minimumLayoutSize(Container target) +{ + return calcSize(target, MIN); +} + +/*************************************************************************/ + +/** + * Returns the preferred size of the specified container using this layout. + * + * @param target The container to calculate the preferred size for. + * + * @return The preferred size of the container + */ +public Dimension +preferredLayoutSize(Container target) +{ + return calcSize(target, PREF); +} + +/*************************************************************************/ + +/** + * Returns the maximum size of the specified container using this layout. + * + * @param target The container to calculate the maximum size for. + * + * @return The maximum size of the container + */ +public Dimension +maximumLayoutSize(Container target) +{ + return calcSize(target, MAX); +} + +/*************************************************************************/ + +/** + * Returns the X axis alignment, which is a float indicating + * where along the X axis this container wishs to position its layout. + * 0 indicates align to the left, 1 indicates align to the right, and 0.5 + * indicates align to the center. + * + * @param parent The parent container. + * + * @return The X alignment value. + */ +public float +getLayoutAlignmentX(Container parent) +{ + return(parent.getAlignmentX()); +} + +/*************************************************************************/ + +/** + * Returns the Y axis alignment, which is a float indicating + * where along the Y axis this container wishs to position its layout. + * 0 indicates align to the top, 1 indicates align to the bottom, and 0.5 + * indicates align to the center. + * + * @param parent The parent container. + * + * @return The Y alignment value. + */ +public float +getLayoutAlignmentY(Container parent) +{ + return(parent.getAlignmentY()); +} + +/*************************************************************************/ + +/** + * Instructs this object to discard any layout information it might + * have cached. + * + * @param parent The parent container. + */ +public void +invalidateLayout(Container parent) +{ +} + +/*************************************************************************/ + +/** + * Lays out the specified container according to the constraints + * in this object. + * + * @param target The container to lay out. + */ +public void +layoutContainer(Container target) +{ + Insets i = target.getInsets(); + + ComponentOrientation orient = target.getComponentOrientation (); + boolean left_to_right = orient.isLeftToRight (); + + Component my_north = north; + Component my_east = east; + Component my_south = south; + Component my_west = west; + + // Note that we currently don't handle vertical layouts. Neither + // does JDK 1.3. + if (firstLine != null) + my_north = firstLine; + if (lastLine != null) + my_south = lastLine; + if (firstItem != null) + { + if (left_to_right) + my_west = firstItem; + else + my_east = firstItem; + } + if (lastItem != null) + { + if (left_to_right) + my_east = lastItem; + else + my_west = lastItem; + } + + Dimension c = calcCompSize(center, PREF); + Dimension n = calcCompSize(my_north, PREF); + Dimension s = calcCompSize(my_south, PREF); + Dimension e = calcCompSize(my_east, PREF); + Dimension w = calcCompSize(my_west, PREF); + Dimension t = target.getSize(); - public void layoutContainer(Container target) - { - Insets i = target.getInsets(); - Dimension c = getPreferredSize(center); - Dimension n = getPreferredSize(north); - Dimension s = getPreferredSize(south); - Dimension e = getPreferredSize(east); - Dimension w = getPreferredSize(west); - Dimension t = target.getSize(); - /* <-> hgap <-> hgap +----------------------------+ } @@ -190,65 +497,119 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable i.left i.right */ - int x1 = i.left; - int x2 = x1 + w.width + hgap; - int x3 = t.width - i.right - e.width; - int ww = t.width - i.right - i.left; + int x1 = i.left; + int x2 = x1 + w.width + hgap; + int x3 = t.width - i.right - e.width; + int ww = t.width - i.right - i.left; - int y1 = i.top; - int y2 = y1 + n.height + vgap; - int y3 = t.height - i.bottom - s.height; - int hh = y3-y2-vgap; + int y1 = i.top; + int y2 = y1 + n.height + vgap; + int y3 = t.height - i.bottom - s.height; + int hh = y3-y2-vgap; - setBounds(center, x2, y2, x3-x2-hgap, hh); - setBounds(north, x1, y1, ww, n.height); - setBounds(south, x1, y3, ww, s.height); - setBounds(west, x1, y2, w.width, hh); - setBounds(east, x3, y2, e.width, hh); - } - - public String toString() - { - return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + "]"; - } - - - // Support: - - static final Dimension DIM_0 = new Dimension(0, 0); - static final Dimension DIM_MAX = new Dimension(Integer.MAX_VALUE, - Integer.MAX_VALUE); - - void setBounds(Component comp, int x, int y, int w, int h) - { - if (comp == null) - return; - comp.setBounds(x, y, w, h); - } - - Dimension getMinimumSize(Component comp) - { - if (comp == null) - return DIM_0; - return comp.getMinimumSize(); - } - - Dimension getPreferredSize(Component comp) - { - if (comp == null) - return DIM_0; - return comp.getPreferredSize(); - } - - Dimension calcSize(Dimension c, Dimension n, Dimension s, - Dimension e, Dimension w, Container target) - { - Insets i = target.getInsets(); - - return new Dimension(c.width + e.width + w.width + hgap*2 + - i.left + i.right, - c.height + n.height + s.height + vgap*2 + - i.top + i.bottom - ); - } + setBounds(center, x2, y2, x3-x2-hgap, hh); + setBounds(my_north, x1, y1, ww, n.height); + setBounds(my_south, x1, y3, ww, s.height); + setBounds(my_west, x1, y2, w.width, hh); + setBounds(my_east, x3, y2, e.width, hh); } + +/*************************************************************************/ + +/** + * Returns a string representation of this layout manager. + * + * @return A string representation of this object. + */ +public String +toString() +{ + return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + "]"; +} + +private void +setBounds(Component comp, int x, int y, int w, int h) +{ + if (comp == null) + return; + comp.setBounds(x, y, w, h); +} + +// Some constants for use with calcSize(). +private static final int MIN = 0; +private static final int MAX = 1; +private static final int PREF = 2; + +private Dimension +calcCompSize(Component comp, int what) +{ + if (comp == null) + return new Dimension(0, 0); + if (what == MIN) + return comp.getMinimumSize(); + else if (what == MAX) + return comp.getMaximumSize(); + return comp.getPreferredSize(); +} + +// This is a helper function used to compute the various sizes for +// this layout. +private Dimension +calcSize(Container target, int what) +{ + Insets ins = target.getInsets(); + + ComponentOrientation orient = target.getComponentOrientation (); + boolean left_to_right = orient.isLeftToRight (); + + Component my_north = north; + Component my_east = east; + Component my_south = south; + Component my_west = west; + + // Note that we currently don't handle vertical layouts. Neither + // does JDK 1.3. + if (firstLine != null) + my_north = firstLine; + if (lastLine != null) + my_south = lastLine; + if (firstItem != null) + { + if (left_to_right) + my_west = firstItem; + else + my_east = firstItem; + } + if (lastItem != null) + { + if (left_to_right) + my_east = lastItem; + else + my_west = lastItem; + } + + Dimension ndim = calcCompSize(my_north, what); + Dimension sdim = calcCompSize(my_south, what); + Dimension edim = calcCompSize(my_east, what); + Dimension wdim = calcCompSize(my_west, what); + Dimension cdim = calcCompSize(center, what); + + int width = edim.width + cdim.width + wdim.width + (hgap * 2); + if (ndim.width > width) + width = ndim.width; + if (sdim.width > width) + width = sdim.width; + + width += (ins.left + ins.right); + + int height = edim.height; + if (cdim.height > height) + height = cdim.height; + if (wdim.height > height) + height = wdim.height; + + height += (ndim.height + sdim.height + (vgap * 2) + ins.top + ins.bottom); + + return(new Dimension(width, height)); +} +} // class BorderLayout diff --git a/libjava/java/awt/CardLayout.java b/libjava/java/awt/CardLayout.java index 05e4a44b9f48..9445bf7820f7 100644 --- a/libjava/java/awt/CardLayout.java +++ b/libjava/java/awt/CardLayout.java @@ -1,6 +1,6 @@ // CardLayout.java - Card-based layout engine -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation This file is part of libgcj. @@ -137,14 +137,9 @@ public class CardLayout implements LayoutManager2, Serializable for (int i = 0; i < num; ++i) { - if (comps[i].isVisible ()) - { - // Only resize the one we care about. - comps[i].setBounds (hgap + ins.left, vgap + ins.top, - width - 2 * hgap - ins.left - ins.right, - height - 2 * vgap - ins.top - ins.bottom); - break; - } + comps[i].setBounds (hgap + ins.left, vgap + ins.top, + width - 2 * hgap - ins.left - ins.right, + height - 2 * vgap - ins.top - ins.bottom); } } @@ -272,13 +267,13 @@ public class CardLayout implements LayoutManager2, Serializable { choice = i + 1; if (choice == num) - choice = num - 1; + choice = 0; } else if (what == PREV) { choice = i - 1; if (choice < 0) - choice = 0; + choice = num - 1; } else { diff --git a/libjava/java/awt/Component.java b/libjava/java/awt/Component.java index 0feb69451aab..8f79f8a1d663 100644 --- a/libjava/java/awt/Component.java +++ b/libjava/java/awt/Component.java @@ -1,10 +1,27 @@ -/* Copyright (C) 1999, 2000, 2001 Free Software Foundation +/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt; import java.awt.event.*; @@ -34,13 +51,41 @@ import java.beans.PropertyChangeListener; public abstract class Component implements ImageObserver, MenuContainer, java.io.Serializable { + /** + * Constant returned by the getAlignmentY method to indicate + * that the component wishes to be aligned to the bottom relative to + * other components. + */ + public static final float BOTTOM_ALIGNMENT = (float)1.0; - /* Constants for use with getAlignmentX()/getAlignmentY(). */ - public static final float BOTTOM_ALIGNMENT = 1.0f, - CENTER_ALIGNMENT = 0.5f, - LEFT_ALIGNMENT = 0.0f, - RIGHT_ALIGNMENT = 1.0f, - TOP_ALIGNMENT = 0.0f; + /** + * Constant returned by the getAlignmentY and + * getAlignmentX methods to indicate + * that the component wishes to be aligned to the center relative to + * other components. + */ + public static final float CENTER_ALIGNMENT = (float)0.5; + + /** + * Constant returned by the getAlignmentY method to indicate + * that the component wishes to be aligned to the top relative to + * other components. + */ + public static final float TOP_ALIGNMENT = (float)0.0; + + /** + * Constant returned by the getAlignmentX method to indicate + * that the component wishes to be aligned to the right relative to + * other components. + */ + public static final float RIGHT_ALIGNMENT = (float)1.0; + + /** + * Constant returned by the getAlignmentX method to indicate + * that the component wishes to be aligned to the left relative to + * other components. + */ + public static final float LEFT_ALIGNMENT = (float)0.0; /* Make the treelock a String so that it can easily be identified in debug dumps. We clone the String in order to avoid a conflict in @@ -92,17 +137,30 @@ public abstract class Component implements ImageObserver, MenuContainer, transient ComponentOrientation orientation = ComponentOrientation.UNKNOWN; + /** + * Default constructor for subclasses. + */ protected Component() { } + /** + * Returns the name of this component. + * + * @return The name of this component. + */ public String getName() { if (name == null && !nameExplicitlySet) name = generateName(); return name; } - + + /** + * Sets the name of this component to the specified name. + * + * @param name The new name of this component. + */ public void setName(String name) { nameExplicitlySet = true; @@ -117,19 +175,35 @@ public abstract class Component implements ImageObserver, MenuContainer, // Component is abstract. return null; } - + + /** + * Returns the parent of this component. + * + * @return The parent of this component. + */ public Container getParent() { return parent; } - - /** @deprecated */ - // However, Classpath's Gtk peers rely on it. + + // Sets the peer for this component. + final void setPeer (ComponentPeer peer) + { + this.peer = peer; + } + + /** + * Returns the native windowing system peer for this component. + * + * @return The peer for this component. + * @deprecated + */ + // Classpath's Gtk peers rely on this. public java.awt.peer.ComponentPeer getPeer() { return peer; } - + // FIXME: java.awt.dnd classes not yet implemented /* public void setDropTarget(DropTarget dt) @@ -167,11 +241,28 @@ public abstract class Component implements ImageObserver, MenuContainer, return null; } + /** + * Returns the object used for synchronization locks on this component + * when performing tree and layout functions. + * + * @return The synchronization lock for this component. + */ public final Object getTreeLock() { return treeLock; } + // The sync lock object for this component. + final void setTreeLock(Object tree_lock) + { + this.treeLock = tree_lock; + } + + /** + * Returns the toolkit in use for this component. + * + * @return The toolkit for this component. + */ public Toolkit getToolkit() { if (peer != null) @@ -185,6 +276,13 @@ public abstract class Component implements ImageObserver, MenuContainer, return Toolkit.getDefaultToolkit (); } + /** + * Tests whether or not this component is valid. A invalid component needs + * to have its layout redone. + * + * @return true if this component is valid, false + * otherwise. + */ public boolean isValid() { return valid; @@ -197,12 +295,26 @@ public abstract class Component implements ImageObserver, MenuContainer, return parent.isDisplayable(); return false; } - + + /** + * Tests whether or not this component is visible. + * + * @return true if the component is visible, + * false otherwise. + */ public boolean isVisible() { return visible; } - + + /** + * Tests whether or not this component is actually being shown on + * the screen. This will be true if and only if it this component is + * visible and its parent components are all visible. + * + * @return true if the component is showing on the screen, + * false otherwise. + */ public boolean isShowing() { if (! visible || peer == null) @@ -210,82 +322,132 @@ public abstract class Component implements ImageObserver, MenuContainer, return parent == null ? true : parent.isShowing (); } - + + /** + * Tests whether or not this component is enabled. + * + * @return true if the component is enabled, + * false otherwise. + */ public boolean isEnabled() { return enabled; } - + + /** + * Enables or disables this component. + * + * @param enabled true to enable this component, + * false to disable it. + * + * @deprecated Deprecated in favor of setEnabled(). + */ public void setEnabled(boolean b) { this.enabled = b; if (peer != null) peer.setEnabled(b); } - - /** @deprecated */ + + /** + * Enables this component. + * + * @deprecated Deprecated in favor of setEnabled(). + */ public void enable() { setEnabled(true); } - - /** @deprecated */ + + /** + * Enables or disables this component. + * + * @param enabled true to enable this component, + * false to disable it. + * + * @deprecated Deprecated in favor of setEnabled(). + */ public void enable(boolean b) { setEnabled(b); } - - /** @deprecated */ + + /** + * Disables this component. + * + * @deprecated Deprecated in favor of setEnabled(). + */ public void disable() { setEnabled(false); } - + public boolean isDoubleBuffered() { return false; } - + /** @since 1.2 */ public void enableInputMethods(boolean enable) { // FIXME } - - /** @specnote 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. - We do the same to preserve compatibility for subclasses. */ + + /** + * Makes this component visible or invisible. + * + * @param visible true to make this component visible, + * false to make it invisible. + * @specnote 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. + * We do the same to preserve compatibility for subclasses. + */ public void setVisible(boolean b) { - show (b); + if (peer != null) + peer.setVisible (b); + this.visible = b; } - - /** @deprecated */ + + /** + * Makes this component visible on the screen. + * + * @deprecated Deprecated in favor of setVisible(). + */ public void show() { - if (peer != null) - peer.setVisible(true); - this.visible = true; + setVisible (true); } - - /** @deprecated */ + + /** + * Makes this component visible or invisible. + * + * @param visible true to make this component visible, + * false to make it invisible. + * + * @deprecated Deprecated in favor of setVisible(). + */ public void show(boolean b) { - if (b) - show(); - else - hide(); + setVisible (b); } - - /** @deprecated */ + + /** + * Hides this component so that it is no longer shown on the screen. + * + * @deprecated Deprecated in favor of setVisible(). + */ public void hide() { - if (peer != null) - peer.setVisible(false); - this.visible = false; + setVisible (false); } - + + /** + * Returns this component's foreground color. + * + * @return This component's foreground color. + */ public Color getForeground() { if (foreground != null) @@ -294,7 +456,12 @@ public abstract class Component implements ImageObserver, MenuContainer, return parent.getForeground(); return null; } - + + /** + * Sets this component's foreground color to the specified color. + * + * @param foreground_color The new foreground color. + */ public void setForeground(Color c) { if (peer != null) @@ -302,10 +469,14 @@ public abstract class Component implements ImageObserver, MenuContainer, this.foreground = c; } - /** @return the background color of the component. null may be - returned instead of the actual background color, if this - method is called before the component is added to the - component hierarchy. */ + /** + * Returns this component's background color. + * + * @return the background color of the component. null may be + * returned instead of the actual background color, if this + * method is called before the component is added to the + * component hierarchy. + */ public Color getBackground() { if (background != null) @@ -314,14 +485,24 @@ public abstract class Component implements ImageObserver, MenuContainer, return parent.getBackground(); return null; } - + + /** + * Sets this component's background color to the specified color. + * + * @param background_color The new background color + */ public void setBackground(Color c) { if (peer != null) peer.setBackground(c); this.background = c; } - + + /** + * Returns the font in use for this component. + * + * @return The font for this component. + */ public Font getFont() { if (font != null) @@ -330,7 +511,12 @@ public abstract class Component implements ImageObserver, MenuContainer, return parent.getFont(); return null; } - + + /** + * Sets the font for this component to the specified font. + * + * @param font The new font for this component. + */ public void setFont(Font f) { if (peer != null) @@ -338,6 +524,13 @@ public abstract class Component implements ImageObserver, MenuContainer, this.font = f; } + /** + * Returns the locale for this component. If this component does not + * have a locale, the locale of the parent component is returned. If the + * component has no parent, the system default locale is returned. + * + * @return The locale for this component. + */ public Locale getLocale() throws IllegalComponentStateException { if (locale != null) @@ -347,16 +540,26 @@ public abstract class Component implements ImageObserver, MenuContainer, ("Component has no parent: Can not determine Locale"); return parent.getLocale(); } - + + /** + * Sets the locale for this component to the specified locale. + * + * @param locale The new locale for this component. + */ public void setLocale(Locale l) { this.locale = l; - + /* new writing/layout direction perhaps, or make more/less room for localized text labels */ invalidate(); } - + + /** + * Returns the color model of the device this componet is displayed on. + * + * @return This object's color model. + */ public ColorModel getColorModel() { GraphicsConfiguration config = getGraphicsConfiguration(); @@ -367,11 +570,23 @@ public abstract class Component implements ImageObserver, MenuContainer, return getToolkit().getColorModel(); } + /** + * Returns the location of this component's top left corner relative to + * its parent component. + * + * @return The location of this component. + */ public Point getLocation() { return new Point(x, y); } + /** + * Returns the location of this component's top left corner in screen + * coordinates. + * + * @return The location of this component in screen coordinates. + */ public Point getLocationOnScreen() { if (! isShowing ()) @@ -381,47 +596,93 @@ public abstract class Component implements ImageObserver, MenuContainer, return peer.getLocationOnScreen (); } - /** @deprecated Use getLocation() instead. */ + /** + * Returns the location of this component's top left corner relative to + * its parent component. + * + * @return The location of this component. + * + * @deprecated This method is deprecated in favor of + * getLocation(). + */ public Point location() { return getLocation(); } + /** + * Moves this component to the specified location. The coordinates are + * the new upper left corner of this component. + * + * @param x The new X coordinate of this component. + * @param y The new Y coordinate of this 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); } - /** @deprecated */ + /** + * Moves this component to the specified location. The coordinates are + * the new upper left corner of this component. + * + * @param x The new X coordinate of this component. + * @param y The new Y coordinate of this component. + * + * @deprecated Deprecated in favor for setLocation. + */ public void move(int x, int y) { setLocation(x,y); } - + + /** + * Moves this component to the specified location. The coordinates are + * the new upper left corner of this component. + * + * @param p New coordinates for this component. + */ public void setLocation(Point p) { setLocation(p.x, p.y); } - + + /** + * Returns the size of this object. + * + * @return The size of this object. + */ public Dimension getSize() { return new Dimension(width, height); } - - /** @deprecated */ + + /** + * Returns the size of this object. + * + * @return The size of this object. + * + * @deprecated This method is deprecated in favor of getSize. + */ public Dimension size() { return getSize(); } - + + /** + * Sets the size of this component to the specified width and height. + * + * @param width The new width of this component. + * @param height The new height of this component. + */ public void setSize(int width, int height) { if ((this.width == width) && (this.height == height)) @@ -434,35 +695,78 @@ public abstract class Component implements ImageObserver, MenuContainer, if (peer != null) peer.setBounds(x, y, width, height); } - - /** @deprecated */ + + /** + * Sets the size of this component to the specified value. + * + * @param width The new width of the component. + * @param height The new height of the component. + * + * @deprecated This method is deprecated in favor of setSize. + */ public void resize(int width, int height) { setSize(width, height); } - + + /** + * Sets the size of this component to the specified value. + * + * @param dim The new size of this component. + */ public void setSize(Dimension d) { setSize(d.width, d.height); } - /** @deprecated */ + /** + * Sets the size of this component to the specified value. + * + * @param dim The new size of this component. + * + * @deprecated This method is deprecated in favor of setSize. + */ public void resize(Dimension d) { setSize(d.width, d.height); } + /** + * Returns a bounding rectangle for this component. Note that the + * returned rectange is relative to this component's parent, not to + * the screen. + * + * @return The bounding rectangle for this component. + */ public Rectangle getBounds() { return new Rectangle (x, y, width, height); } - /** @deprecated */ + /** + * Returns a bounding rectangle for this component. Note that the + * returned rectange is relative to this component's parent, not to + * the screen. + * + * @return The bounding rectangle for this component. + * + * @deprecated Deprecated in favor of getBounds(). + */ public Rectangle bounds() { return getBounds(); } - + + /** + * Sets the bounding rectangle for this component to the specified + * values. Note that these coordinates are relative to the parent, + * not to the screen. + * + * @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 width The width of the rectangle. + * @param height The height of the rectangle. + */ public void setBounds(int x, int y, int w, int h) { if (this.x == x @@ -481,13 +785,32 @@ public abstract class Component implements ImageObserver, MenuContainer, if (peer != null) peer.setBounds(x, y, w, h); } - - /** @deprecated */ + + /** + * Sets the bounding rectangle for this component to the specified + * values. Note that these coordinates are relative to the parent, + * not to the screen. + * + * @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 width The width of the rectangle. + * @param height The height of the rectangle. + * + * @deprecated This method is deprecated in favor of + * setBounds(int, int, int, int). + */ public void reshape(int x, int y, int width, int height) { setBounds(x, y, width, height); } - + + /** + * Sets the bounding rectangle for this component to the specified + * rectangle. Note that these coordinates are relative to the parent, + * not to the screen. + * + * @param bounding_rectangle The new bounding rectangle. + */ public void setBounds(Rectangle r) { setBounds(r.x, r.y, r.width, r.height); @@ -557,7 +880,12 @@ public abstract class Component implements ImageObserver, MenuContainer, { return (peer != null) && (peer instanceof LightweightPeer); } - + + /** + * Returns the component's preferred size. + * + * @return The component's preferred size. + */ public Dimension getPreferredSize() { if (peer == null) @@ -566,12 +894,23 @@ public abstract class Component implements ImageObserver, MenuContainer, return peer.getPreferredSize(); } - /** @deprecated */ + /** + * Returns the component's preferred size. + * + * @return The component's preferred size. + * + * @deprecated Deprecated in favor of getPreferredSize(). + */ public Dimension preferredSize() { return getPreferredSize(); } - + + /** + * Returns the component's minimum size. + * + * @return The component's minimum size. + */ public Dimension getMinimumSize() { if (peer == null) @@ -580,43 +919,82 @@ public abstract class Component implements ImageObserver, MenuContainer, return peer.getMinimumSize(); } - /** @deprecated */ + /** + * Returns the component's minimum size. + * + * @return The component's minimum size. + * + * @deprecated Deprecated in favor of getMinimumSize() + */ public Dimension minimumSize() { return getMinimumSize(); } + /** + * Returns the component's maximum size. + * + * @return The component's maximum size. + */ public Dimension getMaximumSize() { return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); } + /** + * Returns the preferred horizontal alignment of this component. The + * value returned will be one of the constants defined in this class. + * + * @return The preferred horizontal alignment of this component. + */ public float getAlignmentX() { return CENTER_ALIGNMENT; } + /** + * Returns the preferred vertical alignment of this component. The + * value returned will be one of the constants defined in this class. + * + * @return The preferred vertical alignment of this component. + */ public float getAlignmentY() { return CENTER_ALIGNMENT; } + /** + * Calls the layout manager to re-layout the component. This is called + * during validation of a container in most cases. + */ public void doLayout() { // nothing to do unless we're a container } - - /** @deprecated */ + + /** + * Calls the layout manager to re-layout the component. This is called + * during validation of a container in most cases. + * + * @deprecated This method is deprecated in favor of doLayout(). + */ public void layout() { doLayout(); } - + + /** + * Called to ensure that the layout for this component is valid. + */ public void validate() { - // nothing to do unless we're a container + valid = true; } - + + /** + * Invalidates this component and all of its parent components. This will + * cause them to have their layout redone. + */ public void invalidate() { valid = false; @@ -625,6 +1003,12 @@ public abstract class Component implements ImageObserver, MenuContainer, parent.invalidate (); } + /** + * Returns a graphics object for this component. Returns null + * if this component is not currently displayed on the screen. + * + * @return A graphics object for this component. + */ public Graphics getGraphics() { if (peer != null) @@ -646,7 +1030,14 @@ public abstract class Component implements ImageObserver, MenuContainer, } return null; } - + + /** + * Returns the font metrics for the specified font in this component. + * + * @param font The font to retrieve metrics for. + * + * @return The font metrics for the specified font. + */ public FontMetrics getFontMetrics(Font font) { if (peer == null) @@ -654,6 +1045,11 @@ public abstract class Component implements ImageObserver, MenuContainer, return peer.getFontMetrics (font); } + /** + * Sets the cursor for this component to the specified cursor. + * + * @param cursor The new cursor for this component. + */ public void setCursor(Cursor cursor) { this.cursor = cursor; @@ -661,20 +1057,45 @@ public abstract class Component implements ImageObserver, MenuContainer, peer.setCursor (cursor); } + /** + * Returns the cursor for this component. + * + * @return The cursor for this component. + */ public Cursor getCursor() { return this.cursor; } - + + /** + * Paints this component on the screen. The clipping region in the + * graphics context will indicate the region that requires painting. + * + * @param graphics The graphics context for this paint job. + */ public void paint(Graphics g) - { + { } - + + /** + * Updates this component. This method fills the component + * with the background color, then sets the foreground color of the + * specified graphics context to the foreground color of this component + * and calls the paint() method. + * // FIXME: What are the coords relative to? + * + * @param graphics The graphics context for this update. + */ public void update(Graphics g) { paint(g); } - + + /** + * Paints this entire component, including any sub-components. + * + * @param graphics The graphics context for this paint job. + */ public void paintAll(Graphics g) { if (!visible) @@ -684,22 +1105,60 @@ public abstract class Component implements ImageObserver, MenuContainer, peer.paint(g); paint(g); } - + + /** + * Repaint this entire component. The update() method + * on this component will be called as soon as possible. + * // FIXME: What are the coords relative to? + */ public void repaint() { repaint(0, 0, 0, getWidth(), getHeight()); } - + + /** + * Repaint this entire component. The update() method + * on this component will be called in approximate the specified number + * of milliseconds. + * // FIXME: What are the coords relative to? + * + * @param tm The number of milliseconds before this component should + * be repainted. + */ public void repaint(long tm) { repaint(tm, 0, 0, getWidth(), getHeight()); } - + + /** + * Repaints the specified rectangular region within this component. + * This update method on this component will be called as + * soon as possible. + * // FIXME: What are the coords relative to? + * + * @param x The X coordinate of the upper left of the region to repaint + * @param y The Y coordinate of the upper left of the region to repaint + * @param width The width of the region to repaint. + * @param height The height of the region to repaint. + */ public void repaint(int x, int y, int width, int height) { repaint(0, x, y, width, height); } - + + /** + * Repaints the specified rectangular region within this component. + * This update method on this component will be called in + * approximately the specified number of milliseconds. + * // FIXME: What are the coords relative to? + * + * @param tm The number of milliseconds before this component should + * be repainted. + * @param x The X coordinate of the upper left of the region to repaint + * @param y The Y coordinate of the upper left of the region to repaint + * @param width The width of the region to repaint. + * @param height The height of the region to repaint. + */ public void repaint(long tm, int x, int y, int width, int height) { // Handle lightweight repainting by forwarding to native parent @@ -714,16 +1173,46 @@ public abstract class Component implements ImageObserver, MenuContainer, peer.repaint(tm, x, y, width, height); } + /** + * Prints this component. This method is + * provided so that printing can be done in a different manner from + * painting. However, the implementation in this class simply calls + * the paint() method. + * + * @param graphics The graphics context of the print device. + */ public void print(Graphics g) { paint(g); } + /** + * Prints this component, including all sub-components. This method is + * provided so that printing can be done in a different manner from + * painting. However, the implementation in this class simply calls + * the paintAll() method. + * + * @param graphics The graphics context of the print device. + */ public void printAll(Graphics g) { paintAll(g); } + /** + * Called when an image has changed so that this component is + * repainted. + * + * @param image The image that has been updated. + * @param flags Flags as specified in ImageObserver. + * @param x The X coordinate + * @param y The Y coordinate + * @param width The width + * @param height The height + * + * @return true if the image has been fully loaded, + * false otherwise. + */ public boolean imageUpdate (Image img, int infoflags, int x, int y, int w, int h) { @@ -731,58 +1220,160 @@ public abstract class Component implements ImageObserver, MenuContainer, return false; } + /** + * Creates an image from the specified producer. + * + * @param producer The image procedure to create the image from. + * + * @return The resulting image. + */ public Image createImage(ImageProducer producer) { - // FIXME - return null; + return peer.createImage(producer); } + /** + * Creates an image with the specified width and height for use in + * double buffering. + * + * @param width The width of the image. + * @param height The height of the image. + * + * @return The requested image. + */ public Image createImage(int width, int height) { return getGraphicsConfiguration().createCompatibleImage(width, height); } + /** + * Prepares the specified image for rendering on this component. + * + * @param image The image to prepare for rendering. + * @param observer The image observer to notify of the status of the + * image preparation. + * + * @return true if the image is already fully prepared + * for rendering, false otherwise. + */ public boolean prepareImage(Image image, ImageObserver observer) { - // FIXME - return false; + return prepareImage(image, image.getWidth(observer), + image.getHeight(observer), observer); } - public boolean prepareImage(Image image, int width, int height, ImageObserver observer) + /** + * Prepares the specified image for rendering on this component at the + * specified scaled width and height + * + * @param image The image to prepare for rendering. + * @param width The scaled width of the image. + * @param height The scaled height of the image. + * @param observer The image observer to notify of the status of the + * image preparation. + * + * @return true if the image is already fully prepared + * for rendering, false otherwise. + */ + public boolean prepareImage(Image image, int width, int height, + ImageObserver observer) { - // FIXME - return false; + return peer.prepareImage(image, width, height, observer); } + /** + * Returns the status of the loading of the specified image. The value + * returned will be those flags defined in ImageObserver. + * + * @param image The image to check on. + * @param observer The observer to be notified as the image loading + * progresses. + * + * @return The image observer flags indicating the status of the load. + */ public int checkImage(Image image, ImageObserver observer) { - // FIXME - return 0; + return checkImage(image, image.getWidth(observer), + image.getHeight(observer), observer); } - public int checkImage (Image image, int width, int height, ImageObserver observer) + /** + * Returns the status of the loading of the specified image. The value + * returned will be those flags defined in ImageObserver. + * + * @param image The image to check on. + * @param width The scaled image width. + * @param height The scaled image height. + * @param observer The observer to be notified as the image loading + * progresses. + * + * @return The image observer flags indicating the status of the load. + */ + public int checkImage (Image image, int width, int height, + ImageObserver observer) { if (peer != null) return peer.checkImage (image, width, height, observer); return getToolkit ().checkImage (image, width, height, observer); } + /** + * Tests whether or not the specified point is contained within this + * component. Coordinates are relative to this component. + * + * @param x The X coordinate of the point to test. + * @param y The Y coordinate of the point to test. + * + * @return true if the point is within this component, + * false otherwise. + */ public boolean contains (int x, int y) { return (x >= 0) && (y >= 0) && (x < width) && (y < height); } - /** @deprecated */ + /** + * Tests whether or not the specified point is contained within this + * component. Coordinates are relative to this component. + * + * @param x The X coordinate of the point to test. + * @param y The Y coordinate of the point to test. + * + * @return true if the point is within this component, + * false otherwise. + * + * @deprecated Deprecated in favor of contains(int, int). + */ public boolean inside(int x, int y) { return contains(x,y); } + /** + * Tests whether or not the specified point is contained within this + * component. Coordinates are relative to this component. + * + * @param point The point to test. + * + * @return true if the point is within this component, + * false otherwise. + */ public boolean contains(Point p) { return contains(p.x, p.y); } + /** + * Returns the component occupying the position (x,y). This will either + * be this component, an immediate child component, or null + * if neither of the first two occupies the specified location. + * + * @param x The X coordinate to search for components at. + * @param y The Y coordinate to search for components at. + * + * @return The component at the specified location, for null + * if there is none. + */ public Component getComponentAt(int x, int y) { if (contains(x,y)) @@ -790,21 +1381,47 @@ public abstract class Component implements ImageObserver, MenuContainer, return null; } - /** @deprecated */ + /** + * Returns the component occupying the position (x,y). This will either + * be this component, an immediate child component, or null + * if neither of the first two occupies the specified location. + * + * @param x The X coordinate to search for components at. + * @param y The Y coordinate to search for components at. + * + * @return The component at the specified location, for null + * if there is none. + * + * @deprecated The method is deprecated in favor of + * getComponentAt(). + */ public Component locate(int x, int y) { return getComponentAt(x, y); } + /** + * Returns the component occupying the specified point This will either + * be this component, an immediate child component, or null + * if neither of the first two occupies the specified location. + * + * @param point The point to search for components at. + * + * @return The component at the specified location, for null + * if there is none. + */ public Component getComponentAt(Point p) { return getComponentAt(p.x, p.y); } - /** @deprecated */ + /** + * AWT 1.0 event dispatcher. + * + * @deprecated Deprecated in favor of dispatchEvent(). + */ public void deliverEvent(Event e) { - } /** Forward AWT events to processEvent() if: @@ -812,6 +1429,8 @@ public abstract class Component implements ImageObserver, MenuContainer, * OR: * - There is at least one registered listener for this type of event * + * @param event The event to dispatch + * * @specnote This method is final, but we need to be able to * override it in order to handle other event types in our * subclasses. The solution is to define a second, non-final @@ -870,31 +1489,55 @@ public abstract class Component implements ImageObserver, MenuContainer, processEvent(e); } - /** @deprecated */ + /** + * AWT 1.0 event dispatcher. + * + * @deprecated Deprecated in favor of dispatchEvent(). + */ public boolean postEvent(Event e) { return false; } - + + /** + * Adds the specified listener to this component. + * + * @param listener The new listener to add. + */ public synchronized void addComponentListener(ComponentListener l) { componentListener = AWTEventMulticaster.add(componentListener, l); if (componentListener != null) enableEvents(AWTEvent.COMPONENT_EVENT_MASK); } - + + /** + * Removes the specified listener from the component. + * + * @param listener The listener to remove. + */ public synchronized void removeComponentListener(ComponentListener l) { componentListener = AWTEventMulticaster.remove(componentListener, l); } - + + /** + * Adds the specified listener to this component. + * + * @param listener The new listener to add. + */ public synchronized void addFocusListener(FocusListener l) { focusListener = AWTEventMulticaster.add(focusListener, l); if (focusListener != null) enableEvents(AWTEvent.FOCUS_EVENT_MASK); } - + + /** + * Removes the specified listener from the component. + * + * @param listener The listener to remove. + */ public synchronized void removeFocusListener(FocusListener l) { focusListener = AWTEventMulticaster.remove(focusListener, l); @@ -931,6 +1574,11 @@ public abstract class Component implements ImageObserver, MenuContainer, AWTEventMulticaster.remove(hierarchyBoundsListener, l); } + /** + * Adds the specified listener to this component. + * + * @param listener The new listener to add. + */ public synchronized void addKeyListener(KeyListener l) { keyListener = AWTEventMulticaster.add(keyListener, l); @@ -938,11 +1586,21 @@ public abstract class Component implements ImageObserver, MenuContainer, enableEvents(AWTEvent.KEY_EVENT_MASK); } + /** + * Removes the specified listener from the component. + * + * @param listener The listener to remove. + */ public synchronized void removeKeyListener(KeyListener l) { keyListener = AWTEventMulticaster.remove(keyListener, l); } + /** + * Adds the specified listener to this component. + * + * @param listener The new listener to add. + */ public synchronized void addMouseListener(MouseListener l) { mouseListener = AWTEventMulticaster.add(mouseListener, l); @@ -950,11 +1608,21 @@ public abstract class Component implements ImageObserver, MenuContainer, enableEvents(AWTEvent.MOUSE_EVENT_MASK); } + /** + * Removes the specified listener from the component. + * + * @param listener The listener to remove. + */ public synchronized void removeMouseListener(MouseListener l) { mouseListener = AWTEventMulticaster.remove(mouseListener, l); } + /** + * Adds the specified listener to this component. + * + * @param listener The new listener to add. + */ public synchronized void addMouseMotionListener(MouseMotionListener l) { mouseMotionListener = AWTEventMulticaster.add(mouseMotionListener, l); @@ -962,6 +1630,11 @@ public abstract class Component implements ImageObserver, MenuContainer, enableEvents(AWTEvent.MOUSE_EVENT_MASK); } + /** + * Removes the specified listener from the component. + * + * @param listener The listener to remove. + */ public synchronized void removeMouseMotionListener(MouseMotionListener l) { mouseMotionListener = AWTEventMulticaster.remove(mouseMotionListener, l); @@ -1043,6 +1716,17 @@ public abstract class Component implements ImageObserver, MenuContainer, // // public InputContext getInputContext() + /** + * Enables the specified events. The events to enable are specified + * by OR-ing together the desired masks from AWTEvent. + *

+ * Events are enabled by default when a listener is attached to the + * component for that event type. This method can be used by subclasses + * to ensure the delivery of a specified event regardless of whether + * or not a listener is attached. + * + * @param enable_events The desired events to enable. + */ protected final void enableEvents(long eventsToEnable) { eventMask |= eventsToEnable; @@ -1060,6 +1744,12 @@ public abstract class Component implements ImageObserver, MenuContainer, peer.setEventMask (eventMask); } + /** + * Disables the specified events. The events to disable are specified + * by OR-ing together the desired masks from AWTEvent. + * + * @param disable_events The desired events to disable. + */ protected final void disableEvents(long eventsToDisable) { eventMask &= ~eventsToDisable; @@ -1111,7 +1801,6 @@ public abstract class Component implements ImageObserver, MenuContainer, * +--+ * */ - private PaintEvent coalescePaintEvents(PaintEvent queuedEvent, PaintEvent newEvent) { @@ -1132,12 +1821,12 @@ public abstract class Component implements ImageObserver, MenuContainer, return newEvent; } - - - - /** Forward event to the appropriate processXXXEvent method based on the - * event type. - */ + /** + * Processes the specified event. In this class, this method simply + * calls one of the more specific event handlers. + * + * @param event The event to process. + */ protected void processEvent(AWTEvent e) { @@ -1172,7 +1861,14 @@ public abstract class Component implements ImageObserver, MenuContainer, processHierarchyBoundsEvent((HierarchyEvent) e); } } - + + /** + * Called when a component event is dispatched and component events are + * enabled. This method passes the event along to any listeners + * that are attached. + * + * @param event The ComponentEvent to process. + */ protected void processComponentEvent(ComponentEvent e) { if (componentListener == null) @@ -1196,7 +1892,14 @@ public abstract class Component implements ImageObserver, MenuContainer, break; } } - + + /** + * Called when a focus event is dispatched and component events are + * enabled. This method passes the event along to any listeners + * that are attached. + * + * @param event The FocusEvent to process. + */ protected void processFocusEvent(FocusEvent e) { if (focusListener == null) @@ -1211,7 +1914,14 @@ public abstract class Component implements ImageObserver, MenuContainer, break; } } - + + /** + * Called when a key event is dispatched and component events are + * enabled. This method passes the event along to any listeners + * that are attached. + * + * @param event The KeyEvent to process. + */ protected void processKeyEvent(KeyEvent e) { if (keyListener == null) @@ -1229,7 +1939,14 @@ public abstract class Component implements ImageObserver, MenuContainer, break; } } - + + /** + * Called when a regular mouse event is dispatched and component events are + * enabled. This method passes the event along to any listeners + * that are attached. + * + * @param event The MouseEvent to process. + */ protected void processMouseEvent(MouseEvent e) { if (mouseListener == null) @@ -1254,6 +1971,13 @@ public abstract class Component implements ImageObserver, MenuContainer, } } + /** + * Called when a mouse motion event is dispatched and component events are + * enabled. This method passes the event along to any listeners + * that are attached. + * + * @param event The MouseMotionEvent to process. + */ protected void processMouseMotionEvent(MouseEvent e) { if (mouseMotionListener == null) @@ -1268,7 +1992,7 @@ public abstract class Component implements ImageObserver, MenuContainer, break; } } - + /** @since 1.2 */ protected void processInputMethodEvent(InputMethodEvent e) { @@ -1332,77 +2056,119 @@ public abstract class Component implements ImageObserver, MenuContainer, throw new IllegalArgumentException("unknown paint event"); } } - - /** @deprecated */ + + /** + * AWT 1.0 event processor. + * + * @deprecated Deprecated in favor of processEvent. + */ public boolean handleEvent(Event evt) { return false; } - - /** @deprecated */ + + /** + * AWT 1.0 mouse event. + * + * @deprecated Deprecated in favor of processMouseEvent(). + */ public boolean mouseDown(Event evt, int x, int y) { return false; } - /** @deprecated */ + /** + * AWT 1.0 mouse event. + * + * @deprecated Deprecated in favor of processMouseMotionEvent(). + */ public boolean mouseDrag(Event evt, int x, int y) { return false; } - /** @deprecated */ + /** + * AWT 1.0 mouse event. + * + * @deprecated Deprecated in favor of processMouseEvent(). + */ public boolean mouseUp(Event evt, int x, int y) { return false; } - /** @deprecated */ + /** + * AWT 1.0 mouse event. + * + * @deprecated Deprecated in favor of processMouseMotionEvent(). + */ public boolean mouseMove(Event evt, int x, int y) { return false; } - /** @deprecated */ + /** + * AWT 1.0 mouse event. + * + * @deprecated Deprecated in favor of processMouseEvent(). + */ public boolean mouseEnter(Event evt, int x, int y) { return false; } - /** @deprecated */ + /** + * AWT 1.0 mouse event. + * + * @deprecated Deprecated in favor of processMouseEvent(). + */ public boolean mouseExit(Event evt, int x, int y) { return false; } - /** @deprecated */ + /** + * AWT 1.0 key press event. + * + * @deprecated Deprecated in favor of processKeyEvent. + */ public boolean keyDown(Event evt, int key) { return false; } - /** @deprecated */ + /** + * AWT 1.0 key press event. + * + * @deprecated Deprecated in favor of processKeyEvent. + */ public boolean keyUp(Event evt, int key) { return false; } - /** @deprecated */ + /** + * AWT 1.0 action event processor. + * + * @deprecated Deprecated in favor of the ActionListener + * interface. + */ public boolean action(Event evt, Object what) { return false; } + /** + * Called to inform this component it has been added to a container. + * A native peer - if any - is created at this time. This method is + * called automatically by the AWT system and should not be called by + * user level code. + */ public void addNotify() { if (peer == null) peer = getToolkit().createComponent(this); - /* Add notify children using a template method, so that it is - possible to ensure that the new event mask delivered to the - peer. */ - addNotifyContainerChildren(); - /* Now that all the children has gotten their peers, we should have the event mask needed for this component and its lightweight subcomponents. */ @@ -1415,11 +2181,12 @@ public abstract class Component implements ImageObserver, MenuContainer, etc. */ } - void addNotifyContainerChildren() - { - // nothing to do unless we're a container - } - + /** + * Called to inform this component is has been removed from its + * container. Its native peer - if any - is destroyed at this time. + * This method is called automatically by the AWT system and should + * not be called by user level code. + */ public void removeNotify() { if (peer != null) @@ -1439,11 +2206,24 @@ public abstract class Component implements ImageObserver, MenuContainer, return false; } + /** + * Tests whether or not this component is in the group that can + * be traversed using the keyboard traversal mechanism (such as the TAB + * key). + * + * @return true if the component is traversed via the TAB + * key, false otherwise. + */ public boolean isFocusTraversable() { return enabled && visible && (peer == null || peer.isFocusTraversable ()); } + /** + * Requests that this component be given focus. The gotFocus() + * method on this event will be called when and if this request was + * successful. + */ public void requestFocus() { // If there's no peer then this component can't get the focus. We @@ -1461,6 +2241,9 @@ public abstract class Component implements ImageObserver, MenuContainer, return null; } + /** + * Transfers focus to the next component in the focus traversal order. + */ public void transferFocus() { Component next; @@ -1472,7 +2255,11 @@ public abstract class Component implements ImageObserver, MenuContainer, next.requestFocus (); } - /** @deprecated */ + /** + * AWT 1.0 focus event processor. + * + * @deprecated Deprecated in favor of transferFocus(). + */ public void nextFocus() { transferFocus(); @@ -1484,6 +2271,11 @@ public abstract class Component implements ImageObserver, MenuContainer, return hasFocus; } + /** + * Adds the specified popup menu to this component. + * + * @param menu The popup menu to be added. + */ public synchronized void add(PopupMenu popup) { if (popups == null) @@ -1491,11 +2283,21 @@ public abstract class Component implements ImageObserver, MenuContainer, popups.addElement(popup); } + /** + * Removes the specified popup menu from this component. + * + * @param menu The popup menu to remove. + */ public synchronized void remove(MenuComponent popup) { popups.removeElement(popup); } + /** + * Returns a debugging string representing this component. + * + * @return A string representing this component. + */ protected String paramString() { StringBuffer param = new StringBuffer(); @@ -1527,21 +2329,41 @@ public abstract class Component implements ImageObserver, MenuContainer, return param.toString(); } + /** + * Returns a string representation of this component. + * + * @return A string representation of this component + */ public String toString() { return this.getClass().getName() + "[" + paramString() + "]"; } + /** + * Prints a listing of this component to the standard output. + */ public void list () { list (System.out, 0); } + /** + * Prints a listing of this component to the specified print stream. + * + * @param stream The PrintStream to print to. + */ public void list (PrintStream out) { list (out, 0); } + /** + * Prints a listing of this component to the specified print stream, + * starting at the specified indentation point. + * + * @param stream The PrintStream to print to. + * @param indent The indentation point. + */ public void list (PrintStream out, int indent) { for (int i = 0; i < indent; ++i) @@ -1549,11 +2371,23 @@ public abstract class Component implements ImageObserver, MenuContainer, out.println (toString ()); } + /** + * Prints a listing of this component to the specified print writer. + * + * @param writer The PrintWrinter to print to. + */ public void list (PrintWriter out) { list (out, 0); } + /** + * Prints a listing of this component to the specified print writer, + * starting at the specified indentation point. + * + * @param writer The PrintWriter to print to. + * @param indent The indentation point. + */ public void list (PrintWriter out, int indent) { for (int i = 0; i < indent; ++i) @@ -1612,4 +2446,29 @@ public abstract class Component implements ImageObserver, MenuContainer, return accessibleContext; } */ + +/** + * AWT 1.0 focus event processor. + * + * @deprecated Deprecated in favor of processFocusEvent. + +public boolean +gotFocus(Event event, Object what) +{ + return(true); +} +*/ + +/** + * AWT 1.0 focus event processor. + * + * @deprecated Deprecated in favor of processFocusEvent. + +public boolean +lostFocus(Event event, Object what) +{ + return(true); +} +*/ + } diff --git a/libjava/java/awt/ComponentOrientation.java b/libjava/java/awt/ComponentOrientation.java index 5497d230b12b..c921cf3c9154 100644 --- a/libjava/java/awt/ComponentOrientation.java +++ b/libjava/java/awt/ComponentOrientation.java @@ -1,10 +1,31 @@ -/* Copyright (C) 2000, 2001 Free Software Foundation +/* Copyright (C) 2000, 2001, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ + +/** + * @author Bryce McKinlay + */ /* Status: Incomplete. Needs a Locale lookup table. */ diff --git a/libjava/java/awt/Container.java b/libjava/java/awt/Container.java index 595c6bfcf82b..5fd9e9420982 100644 --- a/libjava/java/awt/Container.java +++ b/libjava/java/awt/Container.java @@ -1,10 +1,27 @@ -/* Copyright (C) 1999, 2000 Free Software Foundation +/* Copyright (C) 1999, 2000, 2002 Free Software Foundation - This file is part of libjava. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt; @@ -31,21 +48,46 @@ public class Container extends Component /* Anything else is non-serializable, and should be declared "transient". */ transient ContainerListener containerListener; + /** + * Default constructor for subclasses. + */ public Container() { } + /** + * Returns the number of components in this container. + * + * @return The number of components in this container. + */ public int getComponentCount() { return ncomponents; } - /** @deprecated Use getComponentCount() instead. */ + /** + * Returns the number of components in this container. + * + * @return The number of components in this container. + * + * @deprecated This method is deprecated in favor of + * getComponentCount(). + */ public int countComponents() { return ncomponents; } + /** + * Returns the component at the specified index. + * + * @param index The index of the component to retrieve. + * + * @return The requested component. + * + * @exception ArrayIndexOutOfBoundsException If the specified index is not + * valid. + */ public Component getComponent (int n) { if (n < 0 || n >= ncomponents) @@ -53,6 +95,11 @@ public class Container extends Component return component[n]; } + /** + * Returns an array of the components in this container. + * + * @return The components in this container. + */ public Component[] getComponents() { Component[] result = new Component[ncomponents]; @@ -61,51 +108,130 @@ public class Container extends Component return result; } + /** + * Returns the insets for this container, which is the space used for + * borders, the margin, etc. + * + * @return The insets for this container. + */ public Insets getInsets() { if (peer == null) - return new Insets(0, 0, 0, 0); - + return new Insets(0, 0, 0, 0); return ((ContainerPeer) peer).getInsets(); } - /** @deprecated Use getInsets() instead. */ + /** + * Returns the insets for this container, which is the space used for + * borders, the margin, etc. + * + * @return The insets for this container. + * + * @deprecated This method is deprecated in favor of + * getInsets(). + */ public Insets insets() { return getInsets(); } - + + /** + * Adds the specified component to this container at the end of the + * component list. + * + * @param component The component to add to the container. + * + * @return The same component that was added. + */ public Component add (Component comp) { addImpl (comp, null, -1); return comp; } + /** + * Adds the specified component to the container at the end of the + * component list. This method should not be used. Instead, use + * add(Component, Object. + * + * @param name FIXME + * @param component The component to be added. + * + * @return The same component that was added. + */ public Component add (String name, Component comp) { addImpl (comp, name, -1); return comp; } + /** + * Adds the specified component to this container at the specified index + * in the component list. + * + * @param component The component to be added. + * @param index The index in the component list to insert this child + * at, or -1 to add at the end of the list. + * + * @return The same component that was added. + * + * @param throws ArrayIndexOutOfBounds If the specified index is invalid. + */ public Component add (Component comp, int index) { addImpl (comp, null, index); return comp; } + /** + * Adds the specified component to this container at the end of the + * component list. The layout manager will use the specified constraints + * when laying out this component. + * + * @param component The component to be added to this container. + * @param constraints The layout constraints for this component. + */ public void add (Component comp, Object constraints) { addImpl (comp, constraints, -1); } + /** + * Adds the specified component to this container at the specified index + * in the component list. The layout manager will use the specified + * constraints when layout out this component. + * + * @param component The component to be added. + * @param constraints The layout constraints for this component. + * @param index The index in the component list to insert this child + * at, or -1 to add at the end of the list. + * + * @param throws ArrayIndexOutOfBounds If the specified index is invalid. + */ public void add (Component comp, Object constraints, int index) { addImpl (comp, constraints, index); } + /** + * This method is called by all the add() methods to perform + * the actual adding of the component. Subclasses who wish to perform + * their own processing when a component is added should override this + * method. Any subclass doing this must call the superclass version of + * this method in order to ensure proper functioning of the container. + * + * @param component The component to be added. + * @param constraints The layout constraints for this component, or + * null if there are no constraints. + * @param index The index in the component list to insert this child + * at, or -1 to add at the end of the list. + * + * @param throws ArrayIndexOutOfBounds If the specified index is invalid. + */ protected void addImpl (Component comp, Object constraints, int index) { if (index > ncomponents + || (index < 0 && index != -1) || comp instanceof Window || (comp instanceof Container && ((Container) comp).isAncestorOf (this))) @@ -151,21 +277,29 @@ public class Container extends Component // Notify the layout manager. if (layoutMgr != null) { - if (constraints != null && layoutMgr instanceof LayoutManager2) + if (layoutMgr instanceof LayoutManager2) { LayoutManager2 lm2 = (LayoutManager2) layoutMgr; lm2.addLayoutComponent (comp, constraints); } - else + else if (constraints instanceof String) layoutMgr.addLayoutComponent ((String) constraints, comp); + else + layoutMgr.addLayoutComponent (null, comp); } + // Post event to notify of adding the container. ContainerEvent ce = new ContainerEvent (this, ContainerEvent.COMPONENT_ADDED, comp); - dispatchEvent (ce); + getToolkit().getSystemEventQueue().postEvent(ce); } + /** + * Removes the component at the specified index from this container. + * + * @param index The index of the component to remove. + */ public void remove (int index) { Component r = component[index]; @@ -181,12 +315,18 @@ public class Container extends Component if (layoutMgr != null) layoutMgr.removeLayoutComponent (r); + // Post event to notify of adding the container. ContainerEvent ce = new ContainerEvent (this, ContainerEvent.COMPONENT_REMOVED, r); - dispatchEvent (ce); + getToolkit().getSystemEventQueue().postEvent(ce); } + /** + * Removes the specified component from this container. + * + * @return component The component to remove from this container. + */ public void remove (Component comp) { for (int i = 0; i < ncomponents; ++i) @@ -199,51 +339,89 @@ public class Container extends Component } } + /** + * Removes all components from this container. + */ public void removeAll() { while (ncomponents > 0) remove (0); } + /** + * Returns the current layout manager for this container. + * + * @return The layout manager for this container. + */ public LayoutManager getLayout() { return layoutMgr; } + /** + * Sets the layout manager for this container to the specified layout + * manager. + * + * @param mgr The new layout manager for this container. + */ public void setLayout(LayoutManager mgr) { layoutMgr = mgr; invalidate (); } + /** + * Layout the components in this container. + */ public void doLayout() { if (layoutMgr != null) layoutMgr.layoutContainer (this); } - /** @deprecated Use doLayout() instead. */ + /** + * Layout the components in this container. + * + * @deprecated This method is deprecated in favor of + * doLayout(). + */ public void layout() { doLayout(); } + /** + * Invalidates this container to indicate that it (and all parent + * containers) need to be laid out. + */ public void invalidate() { super.invalidate (); } + /** + * Re-lays out the components in this container. + */ public void validate() { - if (! isValid ()) + // FIXME: use the tree lock? + synchronized (this) { - validateTree (); + if (! isValid ()) + { + validateTree (); + } } } + /** + * Recursively validates the container tree, recomputing any invalid + * layouts. + */ protected void validateTree() { - if (valid) return; + if (valid) + return; ContainerPeer cPeer = null; if ((peer != null) && !(peer instanceof LightweightPeer)) @@ -256,16 +434,19 @@ public class Container extends Component for (int i = 0; i < ncomponents; ++i) { Component comp = component[i]; - if (comp instanceof Container) + if (! comp.isValid ()) { - ((Container) comp).validateTree(); - } - else - { - component[i].validate(); + if (comp instanceof Container) + { + ((Container) comp).validateTree(); + } + else + { + component[i].validate(); + } } } - + /* children will call invalidate() when they are layed out. It is therefore imporant that valid is not set to true before after the children has been layed out. */ @@ -281,6 +462,11 @@ public class Container extends Component // FIXME, should invalidate all children with font == null } + /** + * Returns the preferred size of this container. + * + * @return The preferred size of this container. + */ public Dimension getPreferredSize() { if (layoutMgr != null) @@ -288,13 +474,25 @@ public class Container extends Component else return super.getPreferredSize (); } - - /** @deprecated Use getPreferredSize() instead */ + + /** + * Returns the preferred size of this container. + * + * @return The preferred size of this container. + * + * @deprecated This method is deprecated in favor of + * getPreferredSize(). + */ public Dimension preferredSize() { return getPreferredSize(); } - + + /** + * Returns the minimum size of this container. + * + * @return The minimum size of this container. + */ public Dimension getMinimumSize() { if (layoutMgr != null) @@ -302,13 +500,25 @@ public class Container extends Component else return super.getMinimumSize (); } - - /** @deprecated Use getMinimumSize() instead */ + + /** + * Returns the minimum size of this container. + * + * @return The minimum size of this container. + * + * @deprecated This method is deprecated in favor of + * getMinimumSize(). + */ public Dimension minimumSize() { return getMinimumSize(); } - + + /** + * Returns the maximum size of this container. + * + * @return The maximum size of this container. + */ public Dimension getMaximumSize() { if (layoutMgr != null && layoutMgr instanceof LayoutManager2) @@ -320,6 +530,13 @@ public class Container extends Component return super.getMaximumSize (); } + /** + * Returns the preferred alignment along the X axis. This is a value + * between 0 and 1 where 0 represents alignment flush left and + * 1 means alignment flush right, and 0.5 means centered. + * + * @return The preferred alignment along the X axis. + */ public float getAlignmentX() { if (layoutMgr instanceof LayoutManager2) @@ -328,9 +545,16 @@ public class Container extends Component return lm2.getLayoutAlignmentX (this); } else - return CENTER_ALIGNMENT; + return super.getAlignmentX(); } + /** + * Returns the preferred alignment along the Y axis. This is a value + * between 0 and 1 where 0 represents alignment flush top and + * 1 means alignment flush bottom, and 0.5 means centered. + * + * @return The preferred alignment along the Y axis. + */ public float getAlignmentY() { if (layoutMgr instanceof LayoutManager2) @@ -339,9 +563,18 @@ public class Container extends Component return lm2.getLayoutAlignmentY (this); } else - return CENTER_ALIGNMENT; + return super.getAlignmentY(); } + /** + * Paints this container. The implementation of this method in this + * class forwards to any lightweight components in this container. If + * this method is subclassed, this method should still be invoked as + * a superclass method so that lightweight components are properly + * drawn. + * + * @param graphics The graphics context for this paint job. + */ public void paint(Graphics g) { if (!isShowing()) @@ -365,7 +598,7 @@ public class Container extends Component * be visited. */ private void visitChildren(Graphics gfx, GfxVisitor visitor, - boolean lightweightOnly) + boolean lightweightOnly) { // FIXME: do locking @@ -408,29 +641,57 @@ public class Container extends Component visitor.visit(comp, gfx2); } + /** + * Updates this container. The implementation of this method in this + * class forwards to any lightweight components in this container. If + * this method is subclassed, this method should still be invoked as + * a superclass method so that lightweight components are properly + * drawn. + * + * @param graphics The graphics context for this update. + */ public void update(Graphics g) { super.update(g); } + /** + * Prints this container. The implementation of this method in this + * class forwards to any lightweight components in this container. If + * this method is subclassed, this method should still be invoked as + * a superclass method so that lightweight components are properly + * drawn. + * + * @param graphics The graphics context for this print job. + */ public void print(Graphics g) { super.print(g); visitChildren(g, GfxPrintVisitor.INSTANCE, true); } + /** + * Paints all of the components in this container. + * + * @param graphics The graphics context for this paint job. + */ public void paintComponents(Graphics g) { super.paint(g); visitChildren(g, GfxPaintAllVisitor.INSTANCE, true); } + /** + * Prints all of the components in this container. + * + * @param graphics The graphics context for this print job. + */ public void printComponents(Graphics g) { super.paint(g); visitChildren(g, GfxPrintAllVisitor.INSTANCE, true); } - + void dispatchEventImpl(AWTEvent e) { if ((e.id <= ContainerEvent.CONTAINER_LAST @@ -438,15 +699,28 @@ public class Container extends Component && (containerListener != null || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0)) processEvent(e); - else super.dispatchEventImpl(e); + else + super.dispatchEventImpl(e); } - public void addContainerListener(ContainerListener l) + /** + * Adds the specified container listener to this object's list of + * container listeners. + * + * @param listener The listener to add. + */ + public synchronized void addContainerListener(ContainerListener l) { containerListener = AWTEventMulticaster.add (containerListener, l); } - public void removeContainerListener(ContainerListener l) + /** + * Removes the specified container listener from this object's list of + * container listeners. + * + * @param listener The listener to remove. + */ + public synchronized void removeContainerListener(ContainerListener l) { containerListener = AWTEventMulticaster.remove(containerListener, l); } @@ -458,35 +732,70 @@ public class Container extends Component return getListenersImpl(listenerType, containerListener); else return super.getListeners(listenerType); } - + + /** + * Processes the specified event. This method calls + * processContainerEvent() if this method is a + * ContainerEvent, otherwise it calls the superclass + * method. + * + * @param event The event to be processed. + */ protected void processEvent(AWTEvent e) { if (e instanceof ContainerEvent) processContainerEvent((ContainerEvent) e); else super.processEvent(e); } - + + /** + * Called when a container event occurs if container events are enabled. + * This method calls any registered listeners. + * + * @param event The event that occurred. + */ protected void processContainerEvent(ContainerEvent e) { if (containerListener == null) return; switch (e.id) { - case ContainerEvent.COMPONENT_ADDED: - containerListener.componentAdded(e); + case ContainerEvent.COMPONENT_ADDED: + containerListener.componentAdded(e); break; - case ContainerEvent.COMPONENT_REMOVED: - containerListener.componentRemoved(e); + case ContainerEvent.COMPONENT_REMOVED: + containerListener.componentRemoved(e); break; } } - /** @deprecated */ + /** + * AWT 1.0 event processor. + * + * @param event The event that occurred. + * + * @deprecated This method is deprecated in favor of + * dispatchEvent(). + */ public void deliverEvent(Event e) { } - + + /** + * Returns the component located at the specified point. This is done + * by checking whether or not a child component claims to contain this + * point. The first child component that does is returned. If no + * child component claims the point, the container itself is returned, + * unless the point does not exist within this container, in which + * case null is returned. + * + * @param x The X coordinate of the point. + * @param y The Y coordinate of the point. + * + * @return The component containing the specified point, or + * null if there is no such point. + */ public Component getComponentAt (int x, int y) { if (! contains (x, y)) @@ -505,12 +814,40 @@ public class Container extends Component return this; } - /** @deprecated Use getComponentAt() instead */ + /** + * Returns the component located at the specified point. This is done + * by checking whether or not a child component claims to contain this + * point. The first child component that does is returned. If no + * child component claims the point, the container itself is returned, + * unless the point does not exist within this container, in which + * case null is returned. + * + * @param point The point to return the component at. + * + * @return The component containing the specified point, or null + * if there is no such point. + * + * @deprecated This method is deprecated in favor of + * getComponentAt(int, int). + */ public Component locate(int x, int y) { return getComponentAt(x, y); } + /** + * Returns the component located at the specified point. This is done + * by checking whether or not a child component claims to contain this + * point. The first child component that does is returned. If no + * child component claims the point, the container itself is returned, + * unless the point does not exist within this container, in which + * case null is returned. + * + * @param point The point to return the component at. + * + * @return The component containing the specified point, or null + * if there is no such point. + */ public Component getComponentAt(Point p) { return getComponentAt(p.x, p.y); @@ -550,12 +887,21 @@ public class Container extends Component return findComponentAt(p.x, p.y); } + /** + * Called when this container is added to another container to inform it + * to create its peer. Peers for any child components will also be + * created. + */ public void addNotify () { - super.addNotify(); + if (peer == null) + { + addNotifyContainerChildren (); + super.addNotify(); + } } - void addNotifyContainerChildren() + private void addNotifyContainerChildren() { for (int i = ncomponents; --i >= 0; ) { @@ -565,6 +911,11 @@ public class Container extends Component } } + /** + * Called when this container is removed from its parent container to + * inform it to destroy its peer. This causes the peers of all child + * component to be destroyed as well. + */ public void removeNotify() { for (int i = 0; i < ncomponents; ++i) @@ -572,6 +923,15 @@ public class Container extends Component super.removeNotify(); } + /** + * Tests whether or not the specified component is contained within + * this components subtree. + * + * @param component The component to test. + * + * @return true if this container is an ancestor of the + * specified component, false. + */ public boolean isAncestorOf (Component comp) { for (;;) @@ -584,6 +944,12 @@ public class Container extends Component } } + /** + * Returns a string representing the state of this container for + * debugging purposes. + * + * @return A string representing the state of this container. + */ protected String paramString() { String param = super.paramString(); @@ -592,7 +958,14 @@ public class Container extends Component return param; } - + + /** + * Writes a listing of this container to the specified stream starting + * at the specified indentation point. + * + * @param stream The PrintStream to write to. + * @param indent The indentation point. + */ public void list (PrintStream out, int indent) { super.list (out, indent); @@ -600,6 +973,13 @@ public class Container extends Component component[i].list (out, indent + 2); } + /** + * Writes a listing of this container to the specified stream starting + * at the specified indentation point. + * + * @param stream The PrintWriter to write to. + * @param indent The indentation point. + */ public void list(PrintWriter out, int indent) { super.list (out, indent); diff --git a/libjava/java/awt/Event.java b/libjava/java/awt/Event.java index 481f5b814323..359dc20115e8 100644 --- a/libjava/java/awt/Event.java +++ b/libjava/java/awt/Event.java @@ -1,10 +1,28 @@ -/* Copyright (C) 1999, 2000 Free Software Foundation +/* Copyright (C) 1999, 2000, 2002 Free Software Foundation - This file is part of libjava. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ package java.awt; diff --git a/libjava/java/awt/EventDispatchThread.java b/libjava/java/awt/EventDispatchThread.java index 1887fcfecc6a..e15928644dfa 100644 --- a/libjava/java/awt/EventDispatchThread.java +++ b/libjava/java/awt/EventDispatchThread.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ /** @author Bryce McKinlay */ diff --git a/libjava/java/awt/EventQueue.java b/libjava/java/awt/EventQueue.java index 7037118c0dd9..a47d34f21c54 100644 --- a/libjava/java/awt/EventQueue.java +++ b/libjava/java/awt/EventQueue.java @@ -1,10 +1,28 @@ -/* Copyright (C) 2000, 2001 Free Software Foundation +/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ package java.awt; @@ -18,13 +36,19 @@ import java.lang.reflect.InvocationTargetException; * Status: Believed complete, but untested. Check FIXME's. */ -/** @author Bryce McKinlay */ - +/** + * This class manages a queue of AWTEvent objects that + * are posted to it. The AWT system uses only one event queue for all + * events. + * + * @author Bryce McKinlay + * @author Aaron M. Renn (arenn@urbanophile.com) + */ public class EventQueue { private static final int INITIAL_QUEUE_DEPTH = 8; private AWTEvent[] queue = new AWTEvent[INITIAL_QUEUE_DEPTH]; - + private int next_in = 0; // Index where next event will be added to queue private int next_out = 0; // Index of next event to be removed from queue @@ -33,40 +57,68 @@ public class EventQueue private EventDispatchThread dispatchThread = new EventDispatchThread(this); + /** + * Initializes a new instance of EventQueue. + */ public EventQueue() { } - + + /** + * Returns the next event in the queue. This method will block until + * an event is available or until the thread is interrupted. + * + * @return The next event in the queue. + * + * @exception InterruptedException If this thread is interrupted while + * waiting for an event to be posted to the queue. + */ public synchronized AWTEvent getNextEvent() throws InterruptedException { if (next != null) return next.getNextEvent(); - + while (next_in == next_out) wait(); - + AWTEvent res = queue[next_out]; - + if (++next_out == queue.length) next_out = 0; return res; } - - /** @specnote Does not block. Returns null if there are no events on the + + /** + * Returns the next event in the queue without removing it from the queue. + * This method will block until an event is available or until the thread + * is interrupted. + * + * @return The next event in the queue. + * @specnote Does not block. Returns null if there are no events on the * queue. */ public synchronized AWTEvent peekEvent() { if (next != null) return next.peekEvent(); - + if (next_in != next_out) return queue[next_out]; else return null; } - - /** @specnote Does not block. Returns null if there are no matching events + + /** + * Returns the next event in the queue that has the specified id + * without removing it from the queue. + * This method will block until an event is available or until the thread + * is interrupted. + * + * @param id The event id to return. + * + * @return The next event in the queue. + * + * @specnote Does not block. Returns null if there are no matching events * on the queue. */ public synchronized AWTEvent peekEvent(int id) @@ -83,7 +135,12 @@ public class EventQueue } return null; } - + + /** + * Posts a new event to the queue. + * + * @param event The event to post to the queue. + */ public synchronized void postEvent(AWTEvent evt) { if (next != null) @@ -92,7 +149,7 @@ public class EventQueue return; } // FIXME: Security checks? - + /* Check for any events already on the queue with the same source and ID. */ int i = next_out; @@ -123,24 +180,24 @@ public class EventQueue queue[next_in] = evt; if (++next_in == queue.length) next_in = 0; - + if (next_in == next_out) { /* Queue is full. Extend it. */ AWTEvent[] oldQueue = queue; queue = new AWTEvent[queue.length * 2]; - + int len = oldQueue.length - next_out; System.arraycopy(oldQueue, next_out, queue, 0, len); if (next_out != 0) System.arraycopy(oldQueue, 0, queue, len, next_out); - + next_out = 0; next_in = oldQueue.length; } notify(); } - + /** @since JDK1.2 */ public static void invokeAndWait(Runnable runnable) throws InterruptedException, InvocationTargetException @@ -149,7 +206,7 @@ public class EventQueue Thread current = Thread.currentThread(); if (current == eq.dispatchThread) throw new Error("Can't call invokeAndWait from event dispatch thread"); - + InvocationEvent ie = new InvocationEvent(eq, runnable, current, true); @@ -160,11 +217,11 @@ public class EventQueue } Exception exception; - + if ((exception = ie.getException()) != null) throw new InvocationTargetException(exception); } - + /** @since JDK1.2 */ public static void invokeLater(Runnable runnable) { @@ -175,13 +232,13 @@ public class EventQueue eq.postEvent(ie); } - + public static boolean isDispatchThread() { EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue(); return (Thread.currentThread() == eq.dispatchThread); } - + /** Allows a custom EventQueue implementation to replace this one. * All pending events are transferred to the new queue. Calls to postEvent, * getNextEvent, and peekEvent are forwarded to the pushed queue until it @@ -201,21 +258,21 @@ public class EventQueue next = newEventQueue; newEventQueue.prev = this; } - + /** Transfer any pending events from this queue back to the parent queue that * was previously push()ed. Event dispatch from this queue is suspended. */ protected void pop() throws EmptyStackException { if (prev == null) throw new EmptyStackException(); - + // Don't synchronize both this and prev at the same time, or deadlock could // occur. synchronized (prev) { prev.next = null; } - + synchronized (this) { int i = next_out; @@ -228,7 +285,7 @@ public class EventQueue } } } - + protected void dispatchEvent(AWTEvent evt) { if (evt instanceof ActiveEvent) diff --git a/libjava/java/awt/FlowLayout.java b/libjava/java/awt/FlowLayout.java index d33059bf2526..a377d3021905 100644 --- a/libjava/java/awt/FlowLayout.java +++ b/libjava/java/awt/FlowLayout.java @@ -1,12 +1,30 @@ // FlowLayout.java - Grid-based layout engine -/* Copyright (C) 2000, 2001 Free Software Foundation +/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ package java.awt; @@ -17,6 +35,9 @@ import java.io.Serializable; * without horizontal clipping, a new row is started. This class * supports horizontal and vertical gaps. These are used for spacing * between components. + * + * @author Tom Tromey + * @author Aaron M. Renn (arenn@urbanophile.com) */ public class FlowLayout implements LayoutManager, Serializable { @@ -34,6 +55,9 @@ public class FlowLayout implements LayoutManager, Serializable * orientation. */ public static final int TRAILING = 4; + // Serialization constant + private static final long serialVersionUID = -7262534875583282631L; + /** Add a new component to the layout. This particular implementation * does nothing. */ @@ -42,42 +66,60 @@ public class FlowLayout implements LayoutManager, Serializable // Nothing. } - /** Return the alignment. */ + /** + * Returns the current justification value for this object. + * + * @return The current justification value for this object. + */ public int getAlignment () { return align; } - /** Return the horizontal gap. */ + /** + * Returns the horizontal gap between components. + * + * @return The horizontal gap between components. + */ public int getHgap () { return hgap; } - /** Return the vertical gap. */ + /** + * Returns the vertical gap between lines of components. + * + * @return The vertical gap between lines of components. + */ public int getVgap () { return vgap; } - /** Create a new FlowLayout with center alignment. - * Both gaps are set to 5. + /** + * Initializes a new instance of FlowLayout with a center + * justification and a default horizontal and vertical gap of 5. */ public FlowLayout () { this (CENTER, 5, 5); } - /** Create a new FlowLayout with the alignment. - * columns. Both gaps are set to 5. - * @param align Alignment + /** + * Initializes a new instance of FlowLayout with the specified + * justification and a default horizontal and vertical gap of 5. + * + * @param align The justification setting, which should be one of the + * contants in this class. */ public FlowLayout (int align) { this (align, 5, 5); } - /** Create a new FlowLayout with the specified alignment and gaps. + /** + * Initializes a new instance of FlowLayout with the specified + * justification and gap values * @param align Alignment * @param hgap The horizontal gap * @param vgap The vertical gap @@ -118,13 +160,12 @@ public class FlowLayout implements LayoutManager, Serializable boolean found_one = false; for (j = i; j < num && ! found_one; ++j) { - // FIXME: this is very inefficient. - Dimension c = comps[i].getPreferredSize (); - // Skip invisible items. if (! comps[i].visible) continue; + Dimension c = comps[i].getPreferredSize (); + int next_w = new_w + hgap + c.width; if (next_w <= d.width || ! found_one) { @@ -157,10 +198,9 @@ public class FlowLayout implements LayoutManager, Serializable for (int k = i; i < j; ++k) { - // FIXME: this is very inefficient. - Dimension c = comps[i].getPreferredSize (); if (comps[i].visible) { + Dimension c = comps[i].getPreferredSize (); comps[i].setLocation (x, y); x += c.width + vgap; } @@ -172,16 +212,22 @@ public class FlowLayout implements LayoutManager, Serializable } } - /** Get the minimum layout size of the container. + /** + * Returns the minimum layout size for the specified container using + * this layout. * @param cont The parent container + * @return The minimum layout size. */ public Dimension minimumLayoutSize (Container cont) { return getSize (cont, true); } - /** Get the preferred layout size of the container. + /** + * Returns the preferred layout size for the specified container using + * this layout. * @param cont The parent container + * @return The preferred layout size. */ public Dimension preferredLayoutSize (Container cont) { @@ -197,19 +243,24 @@ public class FlowLayout implements LayoutManager, Serializable // Nothing. } - /** Set the alignment. - * @param align The alignment + /** + * Sets the justification value for this object to the specified value. + * + * @param align The new justification value for this object, which must + * be one of the constants in this class. */ public void setAlignment (int align) { if (align != LEFT && align != RIGHT && align != CENTER && align != LEADING && align != TRAILING) - throw new IllegalArgumentException ("invalid align: " + align); + throw new IllegalArgumentException ("invalid alignment: " + align); this.align = align; } - /** Set the horizontal gap - * @param hgap The horizontal gap + /** + * Sets the horizontal gap between components to the specified value. + * + * @param hgap The new horizontal gap between components. */ public void setHgap (int hgap) { @@ -218,8 +269,10 @@ public class FlowLayout implements LayoutManager, Serializable this.hgap = hgap; } - /** Set the vertical gap. - * @param vgap The vertical gap + /** + * Sets the vertical gap between lines of components to the specified value. + * + * @param vgap The new vertical gap. */ public void setVgap (int vgap) { @@ -228,7 +281,9 @@ public class FlowLayout implements LayoutManager, Serializable this.vgap = vgap; } - /** Return String description of this object. */ + /** Return String description of this object. + * @return A string representation of this object. + */ public String toString () { return ("[" + getClass ().getName () + ",hgap=" + hgap + ",vgap=" + vgap @@ -270,9 +325,19 @@ public class FlowLayout implements LayoutManager, Serializable return new Dimension (w, h); } - // Alignment. + /** + * @serial The justification alignment of the lines of components, which + * will be one of the constants defined in this class. + */ private int align; - // The gaps. + + /** + * @serial The horizontal gap between components. + */ private int hgap; + + /** + * @serial The vertical gap between lines of components. + */ private int vgap; } diff --git a/libjava/java/awt/Frame.java b/libjava/java/awt/Frame.java index 22497f7f6b72..04f3f152cd88 100644 --- a/libjava/java/awt/Frame.java +++ b/libjava/java/awt/Frame.java @@ -1,150 +1,459 @@ -/* Copyright (C) 1999, 2000 Free Software Foundation +/* Frame.java -- AWT toplevel window + Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc. - This file is part of libjava. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ package java.awt; + import java.awt.peer.FramePeer; +import java.awt.peer.WindowPeer; +import java.awt.peer.ContainerPeer; +import java.awt.peer.ComponentPeer; +import java.io.Serializable; +import java.util.Enumeration; +import java.util.Vector; -/* A very incomplete placeholder. */ - -public class Frame extends Window implements MenuContainer +/** + * This class is a top-level window with a title bar and window + * decorations. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + */ +public class Frame extends Window implements MenuContainer, Serializable { - public static final int NORMAL = 0; - public static final int ICONIFIED = 1; - MenuBar menuBar = null; - String title; +/* + * Static Variables + */ - private transient Image iconImage; - private transient boolean isResizable = true; - private transient int state = NORMAL; +/** + * Constant for a cross-hair cursor. + * @deprecated Use Cursor.CROSSHAIR_CURSOR instead. + */ +public static final int CROSSHAIR_CURSOR = Cursor.CROSSHAIR_CURSOR; - public Frame () - { - super(); - } +/** + * Constant for a cursor over a text field. + * @deprecated Use Cursor.TEXT_CURSOR instead. + */ +public static final int TEXT_CURSOR = Cursor.TEXT_CURSOR; - public Frame(GraphicsConfiguration gc) - { - super(gc); - } +/** + * Constant for a cursor to display while waiting for an action to complete. + * @deprecated Use Cursor.WAIT_CURSOR. + */ +public static final int WAIT_CURSOR = Cursor.WAIT_CURSOR; - public Frame (String title) - { - super(); - setTitle(title); - } +/** + * Cursor used over SW corner of window decorations. + * @deprecated Use Cursor.SW_RESIZE_CURSOR instead. + */ +public static final int SW_RESIZE_CURSOR = Cursor.SW_RESIZE_CURSOR; - public Frame(String title, GraphicsConfiguration gc) - { - super(gc); - setTitle(title); - } +/** + * Cursor used over SE corner of window decorations. + * @deprecated Use Cursor.SE_RESIZE_CURSOR instead. + */ +public static final int SE_RESIZE_CURSOR = Cursor.SE_RESIZE_CURSOR; - public String getTitle() - { - return (title != null) ? title : ""; - } +/** + * Cursor used over NW corner of window decorations. + * @deprecated Use Cursor.NW_RESIZE_CURSOR instead. + */ +public static final int NW_RESIZE_CURSOR = Cursor.NW_RESIZE_CURSOR; + +/** + * Cursor used over NE corner of window decorations. + * @deprecated Use Cursor.NE_RESIZE_CURSOR instead. + */ +public static final int NE_RESIZE_CURSOR = Cursor.NE_RESIZE_CURSOR; + +/** + * Cursor used over N edge of window decorations. + * @deprecated Use Cursor.N_RESIZE_CURSOR instead. + */ +public static final int N_RESIZE_CURSOR = Cursor.N_RESIZE_CURSOR; + +/** + * Cursor used over S edge of window decorations. + * @deprecated Use Cursor.S_RESIZE_CURSOR instead. + */ +public static final int S_RESIZE_CURSOR = Cursor.S_RESIZE_CURSOR; + +/** + * Cursor used over E edge of window decorations. + * @deprecated Use Cursor.E_RESIZE_CURSOR instead. + */ +public static final int E_RESIZE_CURSOR = Cursor.E_RESIZE_CURSOR; + +/** + * Cursor used over W edge of window decorations. + * @deprecated Use Cursor.W_RESIZE_CURSOR instead. + */ +public static final int W_RESIZE_CURSOR = Cursor.W_RESIZE_CURSOR; + +/** + * Constant for a hand cursor. + * @deprecated Use Cursor.HAND_CURSOR instead. + */ +public static final int HAND_CURSOR = Cursor.HAND_CURSOR; + +/** + * Constant for a cursor used during window move operations. + * @deprecated Use Cursor.MOVE_CURSOR instead. + */ +public static final int MOVE_CURSOR = Cursor.MOVE_CURSOR; + +// Serialization version constant +private static final long serialVersionUID = 2673458971256075116L; + +/*************************************************************************/ + +/* + * Instance Variables + */ + +/** + * @serial The version of the class data being serialized + * // FIXME: what is this value? + */ +private int frameSerializedDataVersion; + +/** + * @serial Image used as the icon when this frame is minimized. + */ +private Image icon; + +/** + * @serial Constant used by the JDK Motif peer set. Not used in + * this implementation. + */ +private boolean mbManagement; + +/** + * @serial The menu bar for this frame. + */ +//private MenuBar menuBar = new MenuBar(); +private MenuBar menuBar; + +/** + * @serial A list of other top-level windows owned by this window. + */ +Vector ownedWindows = new Vector(); + +/** + * @serial Indicates whether or not this frame is resizable. + */ +private boolean resizable = true; + +/** + * @serial The state of this frame. + * // FIXME: What are the values here? + */ +private int state; + +/** + * @serial The title of the frame. + */ +private String title = ""; + +/*************************************************************************/ + +/* + * Constructors + */ + +/** + * Initializes a new instance of Frame that is not visible + * and has no title. + */ +public +Frame() +{ + this(""); +} + +/*************************************************************************/ + +/** + * Initializes a new instance of Frame that is not visible + * and has the specified title. + * + * @param title The title of this frame. + */ +public +Frame(String title) +{ + super(); + System.err.println("returned"); + this.title = title; + System.err.println("end"); +} + +public +Frame(GraphicsConfiguration gc) +{ + super(gc); +} + +public +Frame(String title, GraphicsConfiguration gc) +{ + super(gc); + setTitle(title); +} + +/*************************************************************************/ + +/* + * Instance Methods + */ + +/** + * Returns this frame's title string. + * + * @return This frame's title string. + */ +public String +getTitle() +{ + return(title); +} + +/*************************************************************************/ + +/* + * Sets this frame's title to the specified value. + * + * @param title The new frame title. + */ +public synchronized void +setTitle(String title) +{ + this.title = title; + if (peer != null) + ((FramePeer) peer).setTitle(title); +} + +/*************************************************************************/ + +/** + * Returns this frame's icon. + * + * @return This frame's icon, or null if this frame does not + * have an icon. + */ +public Image +getIconImage() +{ + return(icon); +} + +/*************************************************************************/ + +/** + * Sets this frame's icon to the specified value. + * + * @icon The new icon for this frame. + */ +public synchronized void +setIconImage(Image icon) +{ + this.icon = icon; + if (peer != null) + ((FramePeer) peer).setIconImage(icon); +} + +/*************************************************************************/ + +/** + * Returns this frame's menu bar. + * + * @return This frame's menu bar, or null if this frame + * does not have a menu bar. + */ +public MenuBar +getMenuBar() +{ + return(menuBar); +} + +/*************************************************************************/ + +/** + * Sets this frame's menu bar. + * + * @param menuBar The new menu bar for this frame. + */ +public synchronized void +setMenuBar(MenuBar menuBar) +{ + this.menuBar = menuBar; + if (peer != null) + ((FramePeer) peer).setMenuBar(menuBar); +} + +/*************************************************************************/ + +/** + * Tests whether or not this frame is resizable. This will be + * true by default. + * + * @return true if this frame is resizable, false + * otherwise. + */ +public boolean +isResizable() +{ + return(resizable); +} + +/*************************************************************************/ + +/** + * Sets the resizability of this frame to the specified value. + * + * @param resizable true to make the frame resizable, + * false to make it non-resizable. + */ +public synchronized void +setResizable(boolean resizable) +{ + this.resizable = resizable; + if (peer != null) + ((FramePeer) peer).setResizable(resizable); +} + +/*************************************************************************/ + +/** + * Returns the cursor type of the cursor for this window. This will + * be one of the constants in this class. + * + * @return The cursor type for this frame. + * + * @deprecated Use Component.getCursor() instead. + */ +public int +getCursorType() +{ + return(getCursor().getType()); +} + +/*************************************************************************/ + +/** + * Sets the cursor for this window to the specified type. The specified + * type should be one of the constants in this class. + * + * @param type The cursor type. + * + * @deprecated. Use Component.setCursor(Cursor) instead. + */ +public void +setCursor(int type) +{ + setCursor(new Cursor(type)); +} + +/*************************************************************************/ + +/** + * Removes the specified component from this frame's menu. + * + * @param menu The menu component to remove. + */ +public void +remove(MenuComponent menu) +{ + menuBar.remove(menu); +} + +/*************************************************************************/ + +/** + * Notifies this frame that it should create its native peer. + */ +public void +addNotify() +{ + if (peer == null) + peer = getToolkit ().createFrame (this); + super.addNotify(); +} + +/*************************************************************************/ + +/** + * Destroys any resources associated with this frame. This includes + * all components in the frame and all owned toplevel windows. + */ +public void +dispose() +{ + Enumeration e = ownedWindows.elements(); + while(e.hasMoreElements()) + { + Window w = (Window)e.nextElement(); + w.dispose(); + } + + super.dispose(); +} + +/*************************************************************************/ + +/** + * Returns a debugging string describing this window. + * + * @return A debugging string describing this window. + */ +protected String +paramString() +{ + return(getClass().getName()); +} + +public int +getState() +{ + /* FIXME: State might have changed in the peer... Must check. */ - public void setTitle (String title) - { - this.title = title; - if (peer != null) - ((FramePeer)peer).setTitle(title); - } + return state; +} - public Image getIconImage() - { - return iconImage; - } - - public void setIconImage(Image image) - { - iconImage = image; - if (peer != null) - ((FramePeer) peer).setIconImage(iconImage); - } - - protected void finalize() throws Throwable - { - //frames.remove(this); - /* FIXME: This won't work. Finalize will never be called if frames - has a reference to the object. We need weak references to - implement this correctly. */ - - super.finalize(); - } - - public synchronized void setMenuBar (MenuBar menuBar) - { - if (this.menuBar != menuBar) - { - //this.menuBar.removeNotify(); - this.menuBar = menuBar; - //this.menuBar.addNotify(); - } - - if (peer != null) - ((FramePeer) peer).setMenuBar(menuBar); - } - - public boolean isResizable() - { - return isResizable; - } - - public void setResizable(boolean resizable) - { - isResizable = resizable; - if (peer != null) - ((FramePeer) peer).setResizable(isResizable); - } - - public int getState() - { - /* FIXME: State might have changed in the peer... Must check. */ - - return state; - } - - - public synchronized void addNotify () - { - if (peer == null) - peer = getToolkit ().createFrame (this); - super.addNotify(); - } - - public boolean postEvent(Event evt) { return false; } // FIXME - - public void remove(MenuComponent m) - { - if (m == menuBar) - { - setMenuBar(null); - return; - } - - super.remove(m); - } - - public void removeNotify() - { - //if ((peer != null) && (menuBar != null)) menuBar.removeNotify(); - super.removeNotify(); - } - - public static Frame[] getFrames() - { - //Frame[] array = new Frames[frames.size()]; - //return frames.toArray(array); +public static Frame[] +getFrames() +{ + //Frame[] array = new Frames[frames.size()]; + //return frames.toArray(array); // see finalize() comment - String msg = "FIXME: can't be implemented without weak references"; - throw new UnsupportedOperationException(msg); - } + String msg = "FIXME: can't be implemented without weak references"; + throw new UnsupportedOperationException(msg); } + +} // class Frame + diff --git a/libjava/java/awt/Graphics.java b/libjava/java/awt/Graphics.java index 56c732fc2f1c..bd785be883e3 100644 --- a/libjava/java/awt/Graphics.java +++ b/libjava/java/awt/Graphics.java @@ -1,235 +1,793 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Graphics.java -- Abstract Java drawing class + Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc. - This file is part of libgcj. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ package java.awt; import java.awt.image.ImageObserver; /** - * @author Warren Levy - * @date March 15, 2000. + * This is the abstract superclass of classes for drawing to graphics + * devices such as the screen or printers. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Warren Levy + */ +public abstract class Graphics +{ + +/* + * Instance Variables + */ + +/*************************************************************************/ + +/* + * Constructors */ /** - * Written using on-line Java Platform 1.2 API Specification, as well - * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). - * Status: Almost complete + * Default constructor for subclasses. + */ +protected +Graphics() +{ +} + +/*************************************************************************/ + +/* + * Instance Methods */ -public abstract class Graphics -{ - protected Graphics() {} - - public abstract Graphics create(); - - public Graphics create(int x, int y, int width, int height) - { - Graphics gfx = create(); - gfx.translate(x, y); - gfx.setClip(0, y, width, height); - return gfx; - } - - public abstract void translate(int x, int y); - - public abstract Color getColor(); - - public abstract void setColor(Color color); - - public abstract void setPaintMode(); - - public abstract void setXORMode(Color altColor); - - public abstract Font getFont(); - - public abstract void setFont(Font font); - - public FontMetrics getFontMetrics() - { - return getFontMetrics(getFont()); - } - - public abstract FontMetrics getFontMetrics(Font font); - - public abstract Rectangle getClipBounds(); - - public abstract void clipRect(int x, int y, int width, int height); - - public abstract void setClip(int x, int y, int width, int height); - - public abstract Shape getClip(); - - public abstract void setClip(Shape clip); - - public abstract void copyArea(int x, int y, int width, int height, - int dx, int dy); - - public abstract void drawLine(int x1, int y1, int x2, int y2); - - public abstract void fillRect(int x, int y, int width, int height); - - public void drawRect(int x, int y, int width, int height) - { - int x1 = x; - int y1 = y; - int x2 = x + width; - int y2 = y + height; - drawLine(x1, y1, x2, y1); - drawLine(x2, y1, x2, y2); - drawLine(x2, y2, x1, y2); - drawLine(x1, y2, x1, y1); - } - - public abstract void clearRect(int x, int y, int width, int height); - - public abstract void drawRoundRect(int x, int y, int width, int height, - int arcWidth, int arcHeight); - - public abstract void fillRoundRect(int x, int y, int width, int height, - int arcWidth, int arcHeight); - - public void draw3DRect(int x, int y, int width, int height, - boolean raised) - { - Color color = getColor(); - Color tl = color.brighter(); - Color br = color.darker(); - - if (!raised) - { - Color tmp = tl; - tl = br; - br = tmp; - } - - int x1 = x; - int y1 = y; - int x2 = x + width; - int y2 = y + height; - - setColor(tl); - drawLine(x1, y1, x2, y1); - drawLine(x1, y2, x1, y1); - setColor(br); - drawLine(x2, y1, x2, y2); - drawLine(x2, y1, x1, y2); - setColor(color); - } - - public void fill3DRect(int x, int y, int width, int height, - boolean raised) - { - fillRect(x, y, width, height); - draw3DRect(x, y, width-1, height-1, raised); - } - - public abstract void drawOval(int x, int y, int width, int height); - - public abstract void fillOval(int x, int y, int width, int height); - - public abstract void drawArc(int x, int y, int width, int height, - int startAngle, int arcAngle); - - public abstract void fillArc(int x, int y, int width, int height, - int startAngle, int arcAngle); - - public abstract void drawPolyline(int[] xPoints, int[] yPoints, - int nPoints); - - public abstract void drawPolygon(int[] xPoints, int[] yPoints, - int nPoints); - - //public void drawPolygon(Polygon p); - - public abstract void fillPolygon(int[] xPoints, int[] yPoints, - int nPoints); - - //public void fillPolygon(Polygon p); - - public abstract void drawString(String str, int x, int y); - - /* - public abstract void drawString(AttributedCharacterIterator iterator, - int x, int y) +/** + * Returns a copy of this Graphics object. + * + * @return A copy of this object. */ +public abstract Graphics +create(); - public void drawChars(char[] data, int offset, int length, - int x, int y) - { - String str = new String(data, offset, length); - drawString(str, x, y); - } +/*************************************************************************/ - public void drawBytes(byte[] data, int offset, int length, - int x, int y) - { - String str = new String(data, offset, length); - drawString(str, x, y); - } +/** + * Returns a copy of this Graphics object. The origin point + * will be translated to the point (x, y) and the cliping rectangle set + * to the intersection of the clipping rectangle in this object and the + * rectangle specified by the parameters to this method. + * + * @param x The new X coordinate of the clipping region rect. + * @param y The new Y coordinate of the clipping region rect. + * @param width The width of the clipping region intersect rectangle. + * @param height The height of the clipping region intersect rectangle. + * + * @return A copy of this object, modified as specified. + */ +public Graphics +create(int x, int y, int width, int height) +{ + Graphics g = create(); - public abstract boolean drawImage(Image img, int x, int y, - ImageObserver observer); + g.translate(x, y); + // FIXME: I'm not sure if this will work. Are the old clip rect bounds + // translated above? + g.clipRect(0, 0, width, height); - public abstract boolean drawImage(Image img, int x, int y, - int width, int height, - ImageObserver observer); - - public abstract boolean drawImage(Image img, int x, int y, Color bgcolor, - ImageObserver observer); - - public abstract boolean drawImage(Image img, int x, int y, - int width, int height, Color bgcolor, - ImageObserver observer); - - public abstract boolean drawImage(Image img, - int dx1, int dy1, int dx2, int dy2, - int sx1, int sy1, int sx2, int sy2, - ImageObserver observer); - - public abstract boolean drawImage(Image img, - int dx1, int dy1, int dx2, int dy2, - int sx1, int sy1, int sx2, int sy2, - Color bgcolor, ImageObserver observer); - - public abstract void dispose(); - - public void finalize() - { - dispose(); - } - - public String toString() - { - return super.toString(); // FIXME - } - - /** @deprecated */ - public Rectangle getClipRect() - { - return getClipBounds(null); - } - - public boolean hitClip(int x, int y, int width, int height) - { - throw new UnsupportedOperationException("not implemented yet"); - } - - public Rectangle getClipBounds(Rectangle r) - { - Rectangle clipBounds = getClipBounds(); - - if (r == null) - return clipBounds; - - r.x = clipBounds.x; - r.y = clipBounds.y; - r.width = clipBounds.width; - r.height = clipBounds.height; - return r; - } + return(g); } + +/*************************************************************************/ + +/** + * Translates this context so that its new origin point is the point + * (x, y). + * + * @param x The new X coordinate of the origin. + * @param y The new Y coordinate of the origin. + */ +public abstract void +translate(int x, int y); + +/*************************************************************************/ + +/** + * Returns the current color for this object. + * + * @return The color for this object. + */ +public abstract Color +getColor(); + +/*************************************************************************/ + +/** + * Sets the current color for this object. + * + * @param color The new color. + */ +public abstract void +setColor(Color color); + +/*************************************************************************/ + +/** + * Sets this context into "paint" mode, where the target pixels are + * completely overwritten when drawn on. + */ +public abstract void +setPaintMode(); + +/*************************************************************************/ + +/** + * Sets this context info "XOR" mode, where the targe pixles are + * XOR-ed when drawn on. + * + * @param color The color to XOR against. + */ +public abstract void +setXORMode(Color color); + +/*************************************************************************/ + +/** + * Returns the current font for this graphics context. + * + * @return The current font. + */ +public abstract Font +getFont(); + +/*************************************************************************/ + +/** + * Sets the font for this graphics context to the specified value. + * + * @param font The new font. + */ +public abstract void +setFont(Font font); + +/*************************************************************************/ + +/** + * Returns the font metrics for the current font. + * + * @return The font metrics for the current font. + */ +public FontMetrics +getFontMetrics() +{ + return(getFontMetrics(getFont())); +} + +/*************************************************************************/ + +/** + * Returns the font metrics for the specified font. + * + * @param font The font to return metrics for. + * + * @return The requested font metrics. + */ +public abstract FontMetrics +getFontMetrics(Font font); + +/*************************************************************************/ + +/** + * Returns the bounding rectangle of the clipping region for this + * graphics context. + * + * @return The bounding rectangle for the clipping region. + */ +public abstract Rectangle +getClipBounds(); + +/*************************************************************************/ + +/** + * Returns the bounding rectangle of the clipping region for this + * graphics context. + * + * @return The bounding rectangle for the clipping region. + * + * @deprecated This method is deprecated in favor of + * getClipBounds(). + */ +public Rectangle +getClipRect() +{ + return(getClipBounds()); +} + +/*************************************************************************/ + +/** + * Sets the clipping region to the intersection of the current clipping + * region and the rectangle determined by the specified parameters. + * + * @param x The X coordinate of the upper left corner of the intersect rect. + * @param Y The Y coordinate of the upper left corner of the intersect rect. + * @param width The width of the intersect rect. + * @param height The height of the intersect rect. + */ +public abstract void +clipRect(int x, int y, int width, int height); + +/*************************************************************************/ + +/** + * Sets the clipping region to the rectangle determined by the specified + * parameters. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + */ +public abstract void +setClip(int x, int y, int width, int height); + +/*************************************************************************/ + +/** + * Returns the current clipping region as a Shape object. + * + * @return The clipping region as a Shape. + */ +public abstract Shape +getClip(); + +/*************************************************************************/ + +/** + * Sets the clipping region to the specified Shape. + * + * @param shape The new clipping region. + */ +public abstract void +setClip(Shape clip); + +/*************************************************************************/ + +/** + * Copies the specified rectangle to the specified offset location. + * + * @param x The X coordinate of the upper left corner of the copy rect. + * @param y The Y coordinate of the upper left corner of the copy rect. + * @param width The width of the copy rect. + * @param height The height of the copy rect. + * @param dx The offset from the X value to start drawing. + * @param dy The offset from the Y value to start drawing. + */ +public abstract void +copyArea(int x, int y, int width, int height, int dx, int dy); + +/*************************************************************************/ + +/** + * Draws a line between the two specified points. + * + * @param x1 The X coordinate of the first point. + * @param y1 The Y coordinate of the first point. + * @param x2 The X coordinate of the second point. + * @param y2 The Y coordinate of the second point. + */ +public abstract void +drawLine(int x1, int y1, int x2, int y2); + +/*************************************************************************/ + +/** + * Fills the area bounded by the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the fill rect. + * @param y The Y coordinate of the upper left corner of the fill rect. + * @param width The width of the fill rect. + * @param height The height of the fill rect. + */ +public abstract void +fillRect(int x, int y, int width, int height); + +/*************************************************************************/ + +/** + * Draws the outline of the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the draw rect. + * @param y The Y coordinate of the upper left corner of the draw rect. + * @param width The width of the draw rect. + * @param height The height of the draw rect. + */ +public void +drawRect(int x, int y, int width, int height) +{ + int x1 = x; + int y1 = y; + int x2 = x + width; + int y2 = y + height; + drawLine(x1, y1, x2, y1); + drawLine(x2, y1, x2, y2); + drawLine(x2, y2, x1, y2); + drawLine(x1, y2, x1, y1); +} + +/*************************************************************************/ + +/** + * Clears the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the clear rect. + * @param y The Y coordinate of the upper left corner of the clear rect. + * @param width The width of the clear rect. + * @param height The height of the clear rect. + */ +public abstract void +clearRect(int x, int y, int width, int height); + +/*************************************************************************/ + +/** + * Draws the outline of the specified rectangle with rounded cornders. + * + * @param x The X coordinate of the upper left corner of the draw rect. + * @param y The Y coordinate of the upper left corner of the draw rect. + * @param width The width of the draw rect. + * @param height The height of the draw rect. + * @param arcWidth The width of the corner arcs. + * @param arcHeigth The height of the corner arcs. + */ +public abstract void +drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight); + +/*************************************************************************/ + +/** + * Fills the specified rectangle with rounded cornders. + * + * @param x The X coordinate of the upper left corner of the fill rect. + * @param y The Y coordinate of the upper left corner of the fill rect. + * @param width The width of the fill rect. + * @param height The height of the fill rect. + * @param arcWidth The width of the corner arcs. + * @param arcHeigth The height of the corner arcs. + */ +public abstract void +fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight); + +/*************************************************************************/ + +public void +draw3DRect(int x, int y, int width, int height, boolean raised) +{ + Color color = getColor(); + Color tl = color.brighter(); + Color br = color.darker(); + + if (!raised) + { + Color tmp = tl; + tl = br; + br = tmp; + } + + int x1 = x; + int y1 = y; + int x2 = x + width; + int y2 = y + height; + + setColor(tl); + drawLine(x1, y1, x2, y1); + drawLine(x1, y2, x1, y1); + setColor(br); + drawLine(x2, y1, x2, y2); + drawLine(x2, y1, x1, y2); + setColor(color); +} + +/** + * Fills the specified rectangle with a 3D effect + * + * @param x The X coordinate of the upper left corner of the fill rect. + * @param y The Y coordinate of the upper left corner of the fill rect. + * @param width The width of the fill rect. + * @param height The height of the fill rect. + * @param raised true if the rectangle appears raised, + * false if it should appear etched. + */ +public void +fill3DRect(int x, int y, int width, int height, boolean raised) +{ + fillRect(x, y, width, height); + draw3DRect(x, y, width-1, height-1, raised); +} + +/*************************************************************************/ + +/** + * Draws the outline of the specified rectangle with a 3D effect + * + * @param x The X coordinate of the upper left corner of the draw rect. + * @param y The Y coordinate of the upper left corner of the draw rect. + * @param width The width of the draw rect. + * @param height The height of the draw rect. + * @param raised true if the rectangle appears raised, + * false if it should appear etched. + */ +public void +drawRoundRect(int x, int y, int width, int height, boolean raised) +{ + // FIXME: ??? +} + +/*************************************************************************/ + +/** + * Draws an oval that just fits within the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + */ +public abstract void +drawOval(int x, int y, int width, int height); + +/*************************************************************************/ + +/** + * Fills an oval that just fits within the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + */ +public abstract void +fillOval(int x, int y, int width, int height); + +/*************************************************************************/ + +/** + * Draws an arc using the specified bounding rectangle and the specified + * angle parameter. The arc is centered at the center of the rectangle. + * The arc starts at the arcAngle position and extend for arcAngle + * degrees. The degree origin is at the 3 o'clock position. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + * @param arcStart The beginning angle of the arc. + * @param arcAngle The extent of the arc. + */ +public abstract void +drawArc(int x, int y, int width, int height, int startAngle, int arcAngle); + +/*************************************************************************/ + +/** + * Fills the arc define by the specified bounding rectangle and the specified + * angle parameter. The arc is centered at the center of the rectangle. + * The arc starts at the arcAngle position and extend for arcAngle + * degrees. The degree origin is at the 3 o'clock position. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + * @param arcStart The beginning angle of the arc. + * @param arcAngle The extent of the arc. + */ +public abstract void +fillArc(int x, int y, int width, int height, int startAngle, int arcAngle); + +/*************************************************************************/ + +/** + * Draws a series of interconnected lines determined by the arrays + * of corresponding x and y coordinates. + * + * @param xPoints The X coordinate array. + * @param yPoints The Y coordinate array. + * @param npoints The number of points to draw. + */ +public abstract void +drawPolyline(int xPoints[], int yPoints[], int npoints); + +/*************************************************************************/ + +/** + * Draws a series of interconnected lines determined by the arrays + * of corresponding x and y coordinates. The figure is closed if necessary + * by connecting the first and last points. + * + * @param xPoints The X coordinate array. + * @param yPoints The Y coordinate array. + * @param npoints The number of points to draw. + */ +public abstract void +drawPolygon(int xPoints[], int yPoints[], int npoints); + +/*************************************************************************/ + +/** + * Draws the specified polygon. + * + * @param polygon The polygon to draw. + */ +public void +drawPolygon(Polygon polygon) +{ + drawPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints); +} + +/*************************************************************************/ + +/** + * Fills the polygon determined by the arrays + * of corresponding x and y coordinates. + * + * @param xPoints The X coordinate array. + * @param yPoints The Y coordinate array. + * @param npoints The number of points to draw. + */ +public abstract void +fillPolygon(int xPoints[], int yPoints[], int npoints); + +/*************************************************************************/ + +/** + * Fills the specified polygon + * + * @param polygon The polygon to fill. + */ +public void +fillPolygon(Polygon polygon) +{ + fillPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints); +} + +/*************************************************************************/ + +/** + * Draws the specified string starting at the specified point. + * + * @param string The string to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + */ +public abstract void +drawString(String string, int x, int y); + +/*************************************************************************/ + +/** + * Draws the specified characters starting at the specified point. + * + * @param data The array of characters to draw. + * @param offset The offset into the array to start drawing characters from. + * @param length The number of characters to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + */ +public void +drawChars(char data[], int offset, int length, int x, int y) +{ + drawString(new String(data, offset, length), x, y); +} + +/*************************************************************************/ + +/** + * Draws the specified bytes as text starting at the specified point. + * + * @param data The array of bytes to draw. + * @param offset The offset into the array to start drawing bytes from. + * @param length The number of bytes to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + */ +public void +drawChars(byte data[], int offset, int length, int x, int y) +{ + drawString(new String(data, offset, length), x, y); +} + +/* +public abstract void drawString(AttributedCharacterIterator iterator, + int x, int y) +*/ + +public void +drawBytes(byte[] data, int offset, int length, int x, int y) +{ + String str = new String(data, offset, length); + drawString(str, x, y); +} + +/*************************************************************************/ + +/** + * Draws all of the image that is available and returns. If the image + * is not completely loaded, false is returned and + * the specified iamge observer is notified as more data becomes + * available. + * + * @param image The image to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + * @param observer The image observer to notify as data becomes available. + * + * @return true if all the image data is available, + * false otherwise. + */ +public abstract boolean +drawImage(Image image, int x, int y, ImageObserver observer); + +/*************************************************************************/ + +/** + * Draws all of the image that is available and returns. The image + * is scaled to fit in the specified rectangle. If the image + * is not completely loaded, false is returned and + * the specified iamge observer is notified as more data becomes + * available. + * + * @param image The image to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + * @param width The width of the rectangle to draw in. + * @param height The height of the rectangle to draw in. + * @param observer The image observer to notify as data becomes available. + * + * @return true if all the image data is available, + * false otherwise. + */ +public abstract boolean +drawImage(Image image, int x, int y, int width, int height, + ImageObserver observer); + +/*************************************************************************/ + +/** + * Draws all of the image that is available and returns. If the image + * is not completely loaded, false is returned and + * the specified iamge observer is notified as more data becomes + * available. + * + * @param image The image to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + * @param bgcolor The background color to use for the image. + * @param observer The image observer to notify as data becomes available. + * + * @return true if all the image data is available, + * false otherwise. + */ +public abstract boolean +drawImage(Image image, int x, int y, Color bgcolor, ImageObserver observer); + +/*************************************************************************/ + +/** + * Draws all of the image that is available and returns. The image + * is scaled to fit in the specified rectangle. If the image + * is not completely loaded, false is returned and + * the specified iamge observer is notified as more data becomes + * available. + * + * @param image The image to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + * @param width The width of the rectangle to draw in. + * @param height The height of the rectangle to draw in. + * @param bgcolor The background color to use for the image. + * @param observer The image observer to notify as data becomes available. + * + * @return true if all the image data is available, + * false otherwise. + */ +public abstract boolean +drawImage(Image image, int x, int y, int width, int height, Color bgcolor, + ImageObserver observer); + +/*************************************************************************/ + +/** + * FIXME: Write Javadocs for this when you understand it. + */ +public abstract boolean +drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, + int sx2, int sy2, ImageObserver observer); + +/*************************************************************************/ + +/** + * FIXME: Write Javadocs for this when you understand it. + */ +public abstract boolean +drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, + int sx2, int sy2, Color bgcolor, ImageObserver observer); + +/*************************************************************************/ + +/** + * Free any resources held by this graphics context immediately instead + * of waiting for the object to be garbage collected and finalized. + */ +public abstract void +dispose(); + +/*************************************************************************/ + +/** + * Frees the resources held by this graphics context when it is + * garbage collected. + */ +public void +finalize() +{ + dispose(); +} + +/*************************************************************************/ + +/** + * Returns a string representation of this object. + * + * @param A string representation of this object. + */ +public String +toString() +{ + return(super.toString()); +} + +public boolean +hitClip(int x, int y, int width, int height) +{ + throw new UnsupportedOperationException("not implemented yet"); +} + +public Rectangle +getClipBounds(Rectangle r) +{ + Rectangle clipBounds = getClipBounds(); + + if (r == null) + return clipBounds; + + r.x = clipBounds.x; + r.y = clipBounds.y; + r.width = clipBounds.width; + r.height = clipBounds.height; + return r; +} + +} // class Graphics + diff --git a/libjava/java/awt/Graphics2D.java b/libjava/java/awt/Graphics2D.java index 0f5cce1e9835..c1cbd6dc13f0 100644 --- a/libjava/java/awt/Graphics2D.java +++ b/libjava/java/awt/Graphics2D.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt; diff --git a/libjava/java/awt/GraphicsConfiguration.java b/libjava/java/awt/GraphicsConfiguration.java index 8e4fd088165e..25e76c7381ef 100644 --- a/libjava/java/awt/GraphicsConfiguration.java +++ b/libjava/java/awt/GraphicsConfiguration.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000, 2001 Free Software Foundation +/* Copyright (C) 2000, 2001, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ /* Status: Complete, but commented out until we have the required GraphicsDevice. */ diff --git a/libjava/java/awt/Paint.java b/libjava/java/awt/Paint.java index 0836402ef914..e9b2bccedf39 100644 --- a/libjava/java/awt/Paint.java +++ b/libjava/java/awt/Paint.java @@ -1,10 +1,28 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ package java.awt; diff --git a/libjava/java/awt/Rectangle.java b/libjava/java/awt/Rectangle.java index 7e7ef728d323..a78adc0828b3 100644 --- a/libjava/java/awt/Rectangle.java +++ b/libjava/java/awt/Rectangle.java @@ -1,10 +1,28 @@ -/* Copyright (C) 1999, 2000, 2001 Free Software Foundation +/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation - This file is part of libjava. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ package java.awt; @@ -13,14 +31,42 @@ import java.io.Serializable; /* Status: Mostly complete. Some of the Java2D stuff is commented out. */ +/** + * This class represents a rectangle and all the interesting things you + * might want to do with it. Note that the coordinate system uses + * the origin (0,0) as the top left of the screen, with the x and y + * values increasing as they move to the right and down respectively. + * + * @author Warren Levy + * @author Aaron M. Renn (arenn@urbanophile.com) + */ public class Rectangle extends Rectangle2D implements Cloneable, Shape, Serializable { + /** + * The X coordinate of the top-left corner of the rectangle. + */ public int x; + + /** + * The Y coordinate of the top-left corner of the rectangle; + */ public int y; + + /** + * The width of the rectangle + */ public int width; + + /** + * The height of the rectangle + */ public int height; + /** + * Initializes a new instance of Rectangle with a top + * left corner at (0,0) and a width and height of 0. + */ public Rectangle() { x = 0; @@ -29,6 +75,12 @@ public class Rectangle extends Rectangle2D height = 0; } + /** + * Initializes a new instance of Rectangle from the + * coordinates of the specified rectangle. + * + * @param rect The rectangle to copy from. + */ public Rectangle(Rectangle r) { x = r.x; @@ -37,6 +89,15 @@ public class Rectangle extends Rectangle2D height = r.height; } + /** + * Initializes a new instance of Rectangle from the specified + * inputs. + * + * @param x The X coordinate of the top left corner of the rectangle. + * @param y The Y coordinate of the top left corner of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + */ public Rectangle(int x, int y, int width, int height) { this.x = x; @@ -45,6 +106,14 @@ public class Rectangle extends Rectangle2D this.height = height; } + /** + * Initializes a new instance of Rectangle with the specified + * width and height. The upper left corner of the rectangle will be at + * the origin (0,0). + * + * @param width The width of the rectangle. + * @param height the height of the rectange. + */ public Rectangle(int width, int height) { x = 0; @@ -53,6 +122,14 @@ public class Rectangle extends Rectangle2D this.height = height; } + /** + * Initializes a new instance of Rectangle with a top-left + * corner represented by the specified point and the width and height + * represented by the specified dimension. + * + * @param point The upper left corner of the rectangle. + * @param dim The width and height of the rectangle. + */ public Rectangle(Point p, Dimension d) { x = p.x; @@ -61,6 +138,12 @@ public class Rectangle extends Rectangle2D height = d.height; } + /** + * Initializes a new instance of Rectangle with a top left + * corner at the specified point and a width and height of zero. + * + * @param poin The upper left corner of the rectangle. + */ public Rectangle(Point p) { x = p.x; @@ -69,6 +152,13 @@ public class Rectangle extends Rectangle2D height = 0; } + /** + * Initializes a new instance of Rectangle with an + * upper left corner at the origin (0,0) and a width and height represented + * by the specified dimension. + * + * @param dim The width and height of the rectangle. + */ public Rectangle(Dimension d) { x = 0; @@ -77,11 +167,24 @@ public class Rectangle extends Rectangle2D height = d.height; } + /** + * Returns the bounding rectangle for this rectangle, which is simply + * this rectange itself. + * + * @return This rectangle. + */ public Rectangle getBounds () { return (Rectangle) this.clone(); } + /** + * Modifies this rectangle so that it represents the smallest rectangle + * that contains both the existing rectangle and the specified point. + * + * @param x The X coordinate of the point to add to this rectangle. + * @param y The Y coordinate of the point to add to this rectangle. + */ public void add(int newx, int newy) { int x = this.x > newx ? newx : this.x; @@ -92,11 +195,23 @@ public class Rectangle extends Rectangle2D this.y = y; } + /** + * Modifies this rectangle so that it represents the smallest rectangle + * that contains both the existing rectangle and the specified point. + * + * @param point The point to add to this rectangle. + */ public void add(Point pt) { add (pt.x, pt.y); } + /** + * Modifies this rectangle so that it represents the smallest rectangle + * that contains both the existing rectangle and the specified rectangle. + * + * @param rect The rectangle to add to this rectangle. + */ public void add(Rectangle r) { int x = this.x > r.x ? r.x : this.x; @@ -109,6 +224,15 @@ public class Rectangle extends Rectangle2D this.y = y; } + /** + * Tests whether or not the specified point is inside this rectangle. + * + * @param x The X coordinate of the point to test. + * @param y The Y coordinate of the point to test. + * + * @return true if the point is inside the rectangle, + * false otherwise. + */ public boolean contains(int x, int y) { return (x >= this.x && x <= this.x + this.width @@ -121,6 +245,14 @@ public class Rectangle extends Rectangle2D && y >= this.y && y + h <= this.y + this.height); } + /** + * Tests whether or not the specified point is inside this rectangle. + * + * @param point The point to test. + * + * @return true if the point is inside the rectangle, + * false otherwise. + */ public boolean contains(Point p) { return contains(p.x, p.y); @@ -131,6 +263,22 @@ public class Rectangle extends Rectangle2D return contains(r.x, r.y, r.width, r.height); } + /** + * Tests this rectangle for equality against the specified object. This + * will be true if an only if the specified object: + *

+ *

    + *
  • Is not null. + *
  • Is an instance of Rectangle. + *
  • Has X and Y coordinates identical to this rectangle. + *
  • Has a width and height identical to this rectangle. + *
+ * + * @param obj The object to test against for equality. + * + * @return true if the specified object is equal to this one, + * false otherwise. + */ public boolean equals(Object obj) { if (obj instanceof Rectangle) @@ -149,11 +297,22 @@ public class Rectangle extends Rectangle2D return (double) this.height; } + /** + * Returns the location of this rectangle, which is the coordinates of + * its upper left corner. + * + * @return The point where this rectangle is located. + */ public Point getLocation() { return new Point(x,y); } + /** + * Returns the size of this rectangle. + * + * @return The size of this rectangle. + */ public Dimension getSize() { return new Dimension(width, height); @@ -174,21 +333,49 @@ public class Rectangle extends Rectangle2D return (double) y; } + /** + * Expands the rectangle by the specified amount. The horizontal + * and vertical expansion values are applied both to the X,Y coordinate + * of this rectangle, and its width and height. Thus the width and + * height will increase by 2h and 2v accordingly. + * + * @param h The horizontal expansion value. + * @param v The vertical expansion value. + */ public void grow(int h, int v) { width += h; height += v; } - /** @deprecated Use contains() instead. */ + /** + * Tests whether or not the specified point is inside this rectangle. + * + * @param x The X coordinate of the point to test. + * @param y The Y coordinate of the point to test. + * + * @return true if the point is inside the rectangle, + * false otherwise. + * + * @deprecated This method is deprecated in favor of + * contains(int, int). + */ public boolean inside(int x, int y) { return contains(x, y); } - /** @specnote If there is no intersection, an empty rectangle at 0,0 - * is returned. - */ + /** + * Determines the rectange which is formed by the intersection of this + * rectangle with the specified rectangle. + * + * @param rect The rectange to calculate the intersection with. + * + * @return The rectangle bounding the intersection. + * + * @specnote If there is no intersection, an empty rectangle at 0,0 + * is returned. + */ public Rectangle intersection(Rectangle r) { int newx = x < r.x ? r.x : x; @@ -203,9 +390,17 @@ public class Rectangle extends Rectangle2D return new Rectangle(0, 0, 0, 0); } - /** @specnote If the intersection is at an edge or corner only (an empty - * intersection with a non-zero location), false is returned. - */ + /** + * Tests whether or not the specified rectangle intersects this rectangle. + * + * @param rect The rectangle to test against. + * + * @return true if the specified rectangle intersects this + * one, false otherwise. + * + * @specnote If the intersection is at an edge or corner only (an empty + * intersection with a non-zero location), false is returned. + */ public boolean intersects(Rectangle r) { int neww = (x + width < r.x + r.width ? @@ -215,12 +410,29 @@ public class Rectangle extends Rectangle2D return (neww > 0 && newh > 0); } + /** + * Tests whether or not this rectangle is empty. An empty rectangle + * has a width or height of zero. + * + * @return true if the rectangle is empty, false + * otherwise. + */ public boolean isEmpty() { return !(width > 0 && height > 0); } - /** @deprecated Use setLocation() instead. */ + /** + * Moves the location of this rectangle by setting its upper left + * corner to the specified coordinates. + * // FIXME: Is this true? + * + * @param x The new X coordinate for this rectangle. + * @param y The new Y coordinate for this rectangle. + * + * @deprecated This method is deprecated in favor of + * setLocation(int, int). + */ public void move(int x, int y) { setLocation(x, y); @@ -232,18 +444,44 @@ public class Rectangle extends Rectangle2D return 0; } - /** @deprecated Use setBounds() instead. */ + /** + * Updates this rectangle to have the specified dimensions. + * + * @param x The new X coordinate of the upper left hand corner. + * @param y The new Y coordinate of the upper left hand corner. + * @param width The new width of this rectangle. + * @param height The new height of this rectangle. + * + * @deprecated This method is deprecated in favor of + * setBounds(int, int, int, int). + */ public void reshape(int x, int y, int width, int height) { setBounds(x, y, width, height); } - /** @deprecated Use setSize() instead. */ + /** + * Sets the size of this rectangle based on the specified dimensions. + * + * @param width The new width of the rectangle. + * @param height The new height of the rectangle. + * + * @deprecated This method is deprecated in favor of + * setSize(int, int). + */ public void resize(int width, int height) { setSize(width, height); } + /** + * Updates this rectangle to have the specified dimensions. + * + * @param x The new X coordinate of the upper left hand corner. + * @param y The new Y coordinate of the upper left hand corner. + * @param width The new width of this rectangle. + * @param height The new height of this rectangle. + */ public void setBounds(int x, int y, int width, int height) { this.x = x; @@ -252,6 +490,12 @@ public class Rectangle extends Rectangle2D this.height = height; } + /** + * Updates this rectangle to match the dimensions of the specified + * rectangle. + * + * @param rect The rectangle to update from. + */ public void setBounds(Rectangle r) { this.x = r.x; @@ -260,12 +504,27 @@ public class Rectangle extends Rectangle2D this.height = r.height; } + /** + * Moves the location of this rectangle by setting its upper left + * corner to the specified coordinates. + * // FIXME: Is this true? + * + * @param x The new X coordinate for this rectangle. + * @param y The new Y coordinate for this rectangle. + */ public void setLocation(int x, int y) { this.x = x; this.y = y; } + /** + * Moves the location of this rectangle by setting its upper left + * corner to the specified point. + * // FIXME: Is this true? + * + * @param point The point to move the rectange to. + */ public void setLocation(Point p) { this.x = p.x; @@ -280,12 +539,23 @@ public class Rectangle extends Rectangle2D this.height = (int) height; } + /** + * Sets the size of this rectangle based on the specified dimensions. + * + * @param dim The new dimensions of the rectangle. + */ public void setSize(Dimension d) { this.width = d.width; this.height = d.height; } + /** + * Sets the size of this rectangle based on the specified dimensions. + * + * @param width The new width of the rectangle. + * @param height The new height of the rectangle. + */ public void setSize(int width, int height) { this.width = width; @@ -298,6 +568,14 @@ public class Rectangle extends Rectangle2D y += y; } + /** + * Returns the smallest rectangle that contains both this rectangle + * and the specified rectangle. + * + * @param rect The rectangle to compute the union with. + * + * @return The smallest rectangle containing both rectangles. + */ public Rectangle union(Rectangle r) { int newx = x > r.x ? r.x : x; @@ -333,9 +611,24 @@ public class Rectangle extends Rectangle2D return new Rectangle (x, y, width, height); } + /** + * Returns a string representation of this rectangle. + * + * @return A string representation of this rectangle. + */ public String toString() { return getClass().getName() + "[x=" + x + ",y=" + y + ",width=" + width + ",height=" + height + "]"; } + + /** + * Returns a hash value for this object. + * + * @return A hash value for this object. + */ + public int hashCode() + { + return x * y * width * height * 37; + } } diff --git a/libjava/java/awt/RenderingHints.java b/libjava/java/awt/RenderingHints.java index c0010cb7d610..9a4e928cf446 100644 --- a/libjava/java/awt/RenderingHints.java +++ b/libjava/java/awt/RenderingHints.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000, 2001 Free Software Foundation +/* Copyright (C) 2000, 2001, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt; diff --git a/libjava/java/awt/Toolkit.java b/libjava/java/awt/Toolkit.java index 8e4e21873f65..85a38f2a5cda 100644 --- a/libjava/java/awt/Toolkit.java +++ b/libjava/java/awt/Toolkit.java @@ -14,7 +14,7 @@ import java.beans.*; import java.awt.image.*; import java.awt.datatransfer.Clipboard; import java.util.Hashtable; -import gnu.gcj.awt.GLightweightPeer; +import gnu.java.awt.GLightweightPeer; /* A very incomplete placeholder. */ diff --git a/libjava/java/awt/Transparency.java b/libjava/java/awt/Transparency.java index c1190069839c..fc1caa699959 100644 --- a/libjava/java/awt/Transparency.java +++ b/libjava/java/awt/Transparency.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt; diff --git a/libjava/java/awt/Window.java b/libjava/java/awt/Window.java index ef661bd95998..1dba71d3a003 100644 --- a/libjava/java/awt/Window.java +++ b/libjava/java/awt/Window.java @@ -1,10 +1,29 @@ -/* Copyright (C) 1999, 2000 Free Software Foundation +/* Copyright (C) 1999, 2000, 2002 Free Software Foundation - This file is part of libgcj. + Copyright (C) 1999 Free Software Foundation, Inc. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt; import java.awt.event.WindowEvent; @@ -15,8 +34,12 @@ import java.util.EventListener; import java.util.Locale; import java.util.ResourceBundle; -/* Status: partially implemented. */ - +/** + * This class represents a top-level window with no decorations. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Warren Levy + */ public class Window extends Container { // Serialized fields, from Sun's serialization spec. @@ -46,6 +69,12 @@ public class Window extends Container graphicsConfiguration = gc; } + /** + * Initializes a new instance of Window with the specified + * parent. The window will initially be invisible. + * + * @param parent The owning Frame of this window. + */ public Window(Frame owner) { this((Window) owner); @@ -99,6 +128,9 @@ public class Window extends Container super.finalize(); } + /** + * Creates the native peer for this window. + */ public void addNotify() { if (peer == null) @@ -106,8 +138,12 @@ public class Window extends Container super.addNotify (); } - /** @specnote pack() doesn't appear to be called internally by show(), so - we duplicate some of the functionality. */ + /** + * Relays out this window's child components at their preferred size. + * + * @specnote pack() doesn't appear to be called internally by show(), so + * we duplicate some of the functionality. + */ public void pack() { if (parent != null @@ -121,31 +157,16 @@ public class Window extends Container validate(); } + /** + * Makes this window visible and brings it to the front. + */ public void show () { if (peer == null) addNotify(); - validate (); - if (isVisible()) - { - this.toFront(); - return; - } - - if (parent != null - && !parent.isDisplayable()) - parent.addNotify(); - if (peer == null) - addNotify (); - - validate (); - - super.show (); - - // FIXME: Is this call necessary or do we assume the peer takes care of - // it? - // this.toFront(); + super.show(); + toFront(); } public void hide() @@ -154,6 +175,9 @@ public class Window extends Container super.hide(); } + /** + * Called to free any resource associated with this window. + */ public void dispose() { hide(); @@ -167,6 +191,10 @@ public class Window extends Container this.removeNotify(); } + /** + * Sends this window to the back so that all other windows display in + * front of it. + */ public void toBack () { if (peer != null) @@ -176,6 +204,10 @@ public class Window extends Container } } + /** + * Brings this window to the front so that it displays in front of + * any other windows. + */ public void toFront () { if (peer != null) @@ -185,13 +217,25 @@ public class Window extends Container } } - /** @specnote Unlike Component.getToolkit, this implementation always - returns the value of Toolkit.getDefaultToolkit(). */ + /** + * Returns the toolkit used to create this window. + * + * @return The toolkit used to create this window. + * + * @specnote Unlike Component.getToolkit, this implementation always + * returns the value of Toolkit.getDefaultToolkit(). + */ public Toolkit getToolkit() { return Toolkit.getDefaultToolkit (); } + /** + * Returns the warning string that will be displayed if this window is + * popped up by an unsecure applet or application. + * + * @return The unsecure window warning message. + */ public final String getWarningString() { boolean secure = true; @@ -210,6 +254,11 @@ public class Window extends Container return null; } + /** + * Returns the locale that this window is configured for. + * + * @return The locale this window is configured for. + */ public Locale getLocale () { return locale == null ? Locale.getDefault () : locale; @@ -223,9 +272,13 @@ public class Window extends Container } */ + /** + * Sets the cursor for this window to the specifiec cursor. + * + * @param cursor The new cursor for this window. + */ public void setCursor(Cursor cursor) { - // FIXME: why different from Component.setCursor() ? super.setCursor(cursor); } @@ -242,11 +295,23 @@ public class Window extends Container return null; } + /** + * Adds the specified listener to the list of WindowListeners + * that will receive events for this window. + * + * @param listener The WindowListener to add. + */ public synchronized void addWindowListener (WindowListener listener) { windowListener = AWTEventMulticaster.add (windowListener, listener); } + /** + * Removes the specified listener from the list of + * WindowListeners that will receive events for this window. + * + * @param listener The WindowListener to remove. + */ public synchronized void removeWindowListener (WindowListener listener) { windowListener = AWTEventMulticaster.remove (windowListener, listener); @@ -272,6 +337,14 @@ public class Window extends Container super.dispatchEventImpl(e); } + /** + * Processes the specified event for this window. If the event is an + * instance of WindowEvent, then + * processWindowEvent() is called to process the event, + * otherwise the superclass version of this method is invoked. + * + * @param event The event to process. + */ protected void processEvent (AWTEvent evt) { if (evt instanceof WindowEvent) @@ -280,6 +353,14 @@ public class Window extends Container super.processEvent (evt); } + /** + * Dispatches this event to any listeners that are listening for + * WindowEvents on this window. This method only gets + * invoked if it is enabled via enableEvents() or if + * a listener has been added. + * + * @param event The event to process. + */ protected void processWindowEvent (WindowEvent evt) { if (windowListener != null) @@ -311,22 +392,40 @@ public class Window extends Container } } + /** + * Returns the child window that has focus if this window is active. + * This method returns null if this window is not active + * or no children have focus. + * + * @return The component that has focus, or null if no + * component has focus. + */ public Component getFocusOwner() { // FIXME return null; } + /** + * Post a Java 1.0 event to the event queue. + * + * @param event The event to post. + */ public boolean postEvent(Event e) { // FIXME return false; } + /** + * Tests whether or not this window is visible on the screen. + * + * @return true if this window is visible, false + * otherwise. + */ public boolean isShowing() { - // FIXME: Also check if window is within the boundary of the screen? - return isVisible(); + return super.isShowing(); } /** @since 1.2 */ diff --git a/libjava/java/awt/color/ColorSpace.java b/libjava/java/awt/color/ColorSpace.java index 8a0edcb2a666..6f84b54f3508 100644 --- a/libjava/java/awt/color/ColorSpace.java +++ b/libjava/java/awt/color/ColorSpace.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.color; diff --git a/libjava/java/awt/color/ICC_ColorSpace.java b/libjava/java/awt/color/ICC_ColorSpace.java index 7afa33d822d7..6d5374239417 100644 --- a/libjava/java/awt/color/ICC_ColorSpace.java +++ b/libjava/java/awt/color/ICC_ColorSpace.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.color; diff --git a/libjava/java/awt/color/ICC_Profile.java b/libjava/java/awt/color/ICC_Profile.java index 4a30708229b9..06bad3387e72 100644 --- a/libjava/java/awt/color/ICC_Profile.java +++ b/libjava/java/awt/color/ICC_Profile.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.color; diff --git a/libjava/java/awt/event/HierarchyBoundsAdapter.java b/libjava/java/awt/event/HierarchyBoundsAdapter.java index 39ce1ab15926..bb804723d647 100644 --- a/libjava/java/awt/event/HierarchyBoundsAdapter.java +++ b/libjava/java/awt/event/HierarchyBoundsAdapter.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.event; diff --git a/libjava/java/awt/event/HierarchyBoundsListener.java b/libjava/java/awt/event/HierarchyBoundsListener.java index aa853a0c27d9..94d9e77087f2 100644 --- a/libjava/java/awt/event/HierarchyBoundsListener.java +++ b/libjava/java/awt/event/HierarchyBoundsListener.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.event; diff --git a/libjava/java/awt/event/HierarchyEvent.java b/libjava/java/awt/event/HierarchyEvent.java index 171d8b212abd..feedc1f48872 100644 --- a/libjava/java/awt/event/HierarchyEvent.java +++ b/libjava/java/awt/event/HierarchyEvent.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.event; import java.awt.*; diff --git a/libjava/java/awt/event/HierarchyListener.java b/libjava/java/awt/event/HierarchyListener.java index b78e857a46ef..3477957e2395 100644 --- a/libjava/java/awt/event/HierarchyListener.java +++ b/libjava/java/awt/event/HierarchyListener.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.event; diff --git a/libjava/java/awt/geom/AffineTransform.java b/libjava/java/awt/geom/AffineTransform.java index 8e9b8f04cfce..5af7277d05f8 100644 --- a/libjava/java/awt/geom/AffineTransform.java +++ b/libjava/java/awt/geom/AffineTransform.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000, 2001 Free Software Foundation +/* Copyright (C) 2000, 2001, 2002 Free Software Foundation - This file is part of libjava. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.geom; import java.awt.*; diff --git a/libjava/java/awt/geom/Dimension2D.java b/libjava/java/awt/geom/Dimension2D.java index 47bfb78bdc6e..521a0732fd48 100644 --- a/libjava/java/awt/geom/Dimension2D.java +++ b/libjava/java/awt/geom/Dimension2D.java @@ -1,10 +1,27 @@ -/* Copyright (C) 1999, 2000 Free Software Foundation +/* Copyright (C) 1999, 2000, 2002 Free Software Foundation - This file is part of libjava. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.geom; diff --git a/libjava/java/awt/geom/Ellipse2D.java b/libjava/java/awt/geom/Ellipse2D.java index ab830ffea931..8c72aeb15cc8 100644 --- a/libjava/java/awt/geom/Ellipse2D.java +++ b/libjava/java/awt/geom/Ellipse2D.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libjava. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.geom; diff --git a/libjava/java/awt/geom/IllegalPathStateException.java b/libjava/java/awt/geom/IllegalPathStateException.java index d8022e54bb48..66a7bcdf50ad 100644 --- a/libjava/java/awt/geom/IllegalPathStateException.java +++ b/libjava/java/awt/geom/IllegalPathStateException.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libjava. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.geom; diff --git a/libjava/java/awt/geom/Line2D.java b/libjava/java/awt/geom/Line2D.java index 309fc5ca8b4f..9f530e5d7c04 100644 --- a/libjava/java/awt/geom/Line2D.java +++ b/libjava/java/awt/geom/Line2D.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000, 2001 Free Software Foundation +/* Copyright (C) 2000, 2001, 2002 Free Software Foundation - This file is part of libjava. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.geom; @@ -24,7 +41,15 @@ public abstract class Line2D implements Shape, Cloneable public Object clone () { - return super.clone (); + try + { + return super.clone (); + } + catch (CloneNotSupportedException _) + { + // Can't happen. + return null; + } } public boolean contains (double x, double y) diff --git a/libjava/java/awt/geom/NoninvertibleTransformException.java b/libjava/java/awt/geom/NoninvertibleTransformException.java index 2ff006f40c5c..5d441f2cb2ef 100644 --- a/libjava/java/awt/geom/NoninvertibleTransformException.java +++ b/libjava/java/awt/geom/NoninvertibleTransformException.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libjava. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.geom; diff --git a/libjava/java/awt/geom/PathIterator.java b/libjava/java/awt/geom/PathIterator.java index 49d9a3bb3c13..33baf566ddf2 100644 --- a/libjava/java/awt/geom/PathIterator.java +++ b/libjava/java/awt/geom/PathIterator.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libjava. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.geom; diff --git a/libjava/java/awt/geom/Point2D.java b/libjava/java/awt/geom/Point2D.java index df631a463be1..12fd761b0acc 100644 --- a/libjava/java/awt/geom/Point2D.java +++ b/libjava/java/awt/geom/Point2D.java @@ -1,10 +1,27 @@ -/* Copyright (C) 1999, 2000 Free Software Foundation +/* Copyright (C) 1999, 2000, 2002 Free Software Foundation - This file is part of libjava. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.geom; diff --git a/libjava/java/awt/geom/Rectangle2D.java b/libjava/java/awt/geom/Rectangle2D.java index 3e776b2c50e8..2174abdcb0c3 100644 --- a/libjava/java/awt/geom/Rectangle2D.java +++ b/libjava/java/awt/geom/Rectangle2D.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000, 2001 Free Software Foundation +/* Copyright (C) 2000, 2001, 2002 Free Software Foundation - This file is part of libjava. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.geom; diff --git a/libjava/java/awt/geom/RectangularShape.java b/libjava/java/awt/geom/RectangularShape.java index 536dd28b88f2..245d772b9bd2 100644 --- a/libjava/java/awt/geom/RectangularShape.java +++ b/libjava/java/awt/geom/RectangularShape.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libjava. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.geom; import java.awt.*; diff --git a/libjava/java/awt/geom/RoundRectangle2D.java b/libjava/java/awt/geom/RoundRectangle2D.java index f90d34255361..1b5f374d5c1f 100644 --- a/libjava/java/awt/geom/RoundRectangle2D.java +++ b/libjava/java/awt/geom/RoundRectangle2D.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libjava. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libjava License. Please consult the file "LIBJAVA_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.geom; diff --git a/libjava/java/awt/image/BufferedImage.java b/libjava/java/awt/image/BufferedImage.java index d2f332d982b9..114d70909613 100644 --- a/libjava/java/awt/image/BufferedImage.java +++ b/libjava/java/awt/image/BufferedImage.java @@ -1,10 +1,28 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ package java.awt.image; @@ -12,7 +30,7 @@ import java.awt.*; import java.awt.color.*; import java.util.*; -import gnu.gcj.awt.ComponentDataBlitOp; +import gnu.java.awt.ComponentDataBlitOp; /** * A buffered image always starts at coordinates (0, 0). diff --git a/libjava/java/awt/image/ColorModel.java b/libjava/java/awt/image/ColorModel.java index 8df1f3baee11..e69f5f91ee9f 100644 --- a/libjava/java/awt/image/ColorModel.java +++ b/libjava/java/awt/image/ColorModel.java @@ -1,17 +1,35 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 1999, 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ package java.awt.image; import java.awt.Point; import java.awt.Transparency; import java.awt.color.ColorSpace; -import gnu.gcj.awt.Buffers; +import gnu.java.awt.Buffers; /** * A color model operates with colors in several formats: @@ -47,8 +65,8 @@ import gnu.gcj.awt.Buffers; * * * @author Rolf W. Rasmussen + * @author C. Brian Jones (cbj@gnu.org) */ - public abstract class ColorModel implements Transparency { protected int pixel_bits; @@ -74,6 +92,12 @@ public abstract class ColorModel implements Transparency return array; } + /** + * Constructs the default color model. The default color model + * can be obtained by calling getRGBdefault of this + * class. + * @param b the number of bits wide used for bit size of pixel values + */ public ColorModel(int bits) { this(bits * 4, // total bits, sRGB, four channels @@ -98,6 +122,10 @@ public abstract class ColorModel implements Transparency this.transferType = transferType; } + /** + * Returns the default color model which in Sun's case is an instance + * of DirectColorModel. + */ public static ColorModel getRGBdefault() { return new DirectColorModel(8, 0xff0000, 0xff00, 0xff, 0xff000000); @@ -113,6 +141,9 @@ public abstract class ColorModel implements Transparency return isAlphaPremultiplied; } + /** + * Get get number of bits wide used for the bit size of pixel values + */ public int getPixelSize() { return pixel_bits; @@ -525,7 +556,8 @@ public abstract class ColorModel implements Transparency return sm.getTransferType() == transferType; } - public void finalize() { + public void finalize() + { } /** diff --git a/libjava/java/awt/image/ComponentColorModel.java b/libjava/java/awt/image/ComponentColorModel.java index e70984b3a3b0..75a14903c707 100644 --- a/libjava/java/awt/image/ComponentColorModel.java +++ b/libjava/java/awt/image/ComponentColorModel.java @@ -1,16 +1,33 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.image; import java.awt.color.*; import java.awt.Point; -import gnu.gcj.awt.Buffers; +import gnu.java.awt.Buffers; public class ComponentColorModel extends ColorModel { diff --git a/libjava/java/awt/image/ComponentSampleModel.java b/libjava/java/awt/image/ComponentSampleModel.java index 97c12c2515e9..b3a9962e48d9 100644 --- a/libjava/java/awt/image/ComponentSampleModel.java +++ b/libjava/java/awt/image/ComponentSampleModel.java @@ -1,14 +1,31 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.image; -import gnu.gcj.awt.Buffers; +import gnu.java.awt.Buffers; /* FIXME: This class does not yet support data type TYPE_SHORT */ diff --git a/libjava/java/awt/image/DataBuffer.java b/libjava/java/awt/image/DataBuffer.java index 0121e5bf9005..f85539e2fe3a 100644 --- a/libjava/java/awt/image/DataBuffer.java +++ b/libjava/java/awt/image/DataBuffer.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.image; diff --git a/libjava/java/awt/image/DataBufferByte.java b/libjava/java/awt/image/DataBufferByte.java index dba810143128..2d22482e81e1 100644 --- a/libjava/java/awt/image/DataBufferByte.java +++ b/libjava/java/awt/image/DataBufferByte.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.image; diff --git a/libjava/java/awt/image/DataBufferInt.java b/libjava/java/awt/image/DataBufferInt.java index 36ddbd94c579..92f30572c94e 100644 --- a/libjava/java/awt/image/DataBufferInt.java +++ b/libjava/java/awt/image/DataBufferInt.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.image; diff --git a/libjava/java/awt/image/DataBufferUShort.java b/libjava/java/awt/image/DataBufferUShort.java index 2be68d12e16d..7810668ab43c 100644 --- a/libjava/java/awt/image/DataBufferUShort.java +++ b/libjava/java/awt/image/DataBufferUShort.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.image; diff --git a/libjava/java/awt/image/DirectColorModel.java b/libjava/java/awt/image/DirectColorModel.java index b79c0af1cc6a..5931e25a5280 100644 --- a/libjava/java/awt/image/DirectColorModel.java +++ b/libjava/java/awt/image/DirectColorModel.java @@ -1,23 +1,56 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 1999, 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ package java.awt.image; import java.awt.Point; import java.awt.Transparency; import java.awt.color.ColorSpace; -import gnu.gcj.awt.Buffers; +import gnu.java.awt.Buffers; /** * @author Rolf W. Rasmussen + * @author C. Brian Jones (cbj@gnu.org) + * @author Mark Benvenuto (mcb54@columbia.edu) */ public class DirectColorModel extends PackedColorModel { + /** + * For the color model created with this constructor the pixels + * will have fully opaque alpha components with a value of 255. + * Each mask should describe a fully contiguous set of bits in the + * most likely order of alpha, red, green, blue from the most significant + * byte to the least significant byte. + * + * @param bits the number of bits wide used for bit size of pixel values + * @param rmask the bits describing the red component of a pixel + * @param gmask the bits describing the green component of a pixel + * @param bmask the bits describing the blue component of a pixel + * @param amask the bits describing the alpha component of a pixel + */ public DirectColorModel(int pixelBits, int rmask, int gmask, int bmask) { this(ColorSpace.getInstance(ColorSpace.CS_sRGB), pixelBits, @@ -27,6 +60,18 @@ public class DirectColorModel extends PackedColorModel ); } + /** + * For the color model created with this constructor the pixels + * will have fully opaque alpha components with a value of 255. + * Each mask should describe a fully contiguous set of bits in the + * most likely order of red, green, blue from the most significant + * byte to the least significant byte. + * + * @param bits the number of bits wide used for bit size of pixel values + * @param rmask the bits describing the red component of a pixel + * @param gmask the bits describing the green component of a pixel + * @param bmask the bits describing the blue component of a pixel + */ public DirectColorModel(int pixelBits, int rmask, int gmask, int bmask, int amask) { @@ -68,24 +113,41 @@ public class DirectColorModel extends PackedColorModel return hasAlpha() ? getMask(3) : 0; } + /** + * Get the red component of the given pixel. + *
+ */ public final int getRed(int pixel) { return extractAndNormalizeSample(pixel, 0); } + /** + * Get the green component of the given pixel. + *
+ */ public final int getGreen(int pixel) { return extractAndNormalizeSample(pixel, 1); } + /** + * Get the blue component of the given pixel. + *
+ */ public final int getBlue(int pixel) { return extractAndNormalizeSample(pixel, 2); } + /** + * Get the alpha component of the given pixel. + *
+ */ public final int getAlpha(int pixel) { - if (!hasAlpha()) return 0; + if (!hasAlpha()) + return 0; return extractAndScaleSample(pixel, 3); } @@ -106,15 +168,22 @@ public class DirectColorModel extends PackedColorModel (field << to8BitShift) : (field >>> (-to8BitShift)); } - - /* FIXME: The Sun docs show that this method is overridden, but I don't - see any way to improve on the superclass implementation. */ + /** + * Get the RGB color value of the given pixel using the default + * RGB color model. + *
+ * + * @param pixel a pixel value + */ public final int getRGB(int pixel) { + /* FIXME: The Sun docs show that this method is overridden, but I + don't see any way to improve on the superclass + implementation. */ return super.getRGB(pixel); } - + public int getRed(Object inData) { return getRed(getPixelFromArray(inData)); diff --git a/libjava/java/awt/image/IndexColorModel.java b/libjava/java/awt/image/IndexColorModel.java index 896d97f9372c..34b9f7298f5f 100644 --- a/libjava/java/awt/image/IndexColorModel.java +++ b/libjava/java/awt/image/IndexColorModel.java @@ -10,7 +10,7 @@ package java.awt.image; import java.awt.Transparency; import java.awt.color.ColorSpace; -import gnu.gcj.awt.Buffers; +import gnu.java.awt.Buffers; /** * @author Rolf W. Rasmussen diff --git a/libjava/java/awt/image/PackedColorModel.java b/libjava/java/awt/image/PackedColorModel.java index b2efd76bead5..d885e7ec4f7d 100644 --- a/libjava/java/awt/image/PackedColorModel.java +++ b/libjava/java/awt/image/PackedColorModel.java @@ -1,16 +1,33 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.image; import java.awt.Point; import java.awt.color.ColorSpace; -import gnu.gcj.awt.BitMaskExtent; +import gnu.java.awt.BitMaskExtent; /** * @author Rolf W. Rasmussen diff --git a/libjava/java/awt/image/Raster.java b/libjava/java/awt/image/Raster.java index 07f9da88068f..0ebc2bf0ac75 100644 --- a/libjava/java/awt/image/Raster.java +++ b/libjava/java/awt/image/Raster.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.image; diff --git a/libjava/java/awt/image/RasterOp.java b/libjava/java/awt/image/RasterOp.java index efcb65f4a4f0..7387f6fd7abd 100644 --- a/libjava/java/awt/image/RasterOp.java +++ b/libjava/java/awt/image/RasterOp.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.image; diff --git a/libjava/java/awt/image/SampleModel.java b/libjava/java/awt/image/SampleModel.java index 132257c0e2e7..c965086d111a 100644 --- a/libjava/java/awt/image/SampleModel.java +++ b/libjava/java/awt/image/SampleModel.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000, 2001 Free Software Foundation +/* Copyright (C) 2000, 2001, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.image; diff --git a/libjava/java/awt/image/SinglePixelPackedSampleModel.java b/libjava/java/awt/image/SinglePixelPackedSampleModel.java index 91979c50347b..bdf8426d43b4 100644 --- a/libjava/java/awt/image/SinglePixelPackedSampleModel.java +++ b/libjava/java/awt/image/SinglePixelPackedSampleModel.java @@ -1,15 +1,32 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.image; -import gnu.gcj.awt.BitMaskExtent; -import gnu.gcj.awt.Buffers; +import gnu.java.awt.BitMaskExtent; +import gnu.java.awt.Buffers; /** * @author Rolf W. Rasmussen diff --git a/libjava/java/awt/image/WritableRaster.java b/libjava/java/awt/image/WritableRaster.java index 5a44aaec0296..cfbaa094df8b 100644 --- a/libjava/java/awt/image/WritableRaster.java +++ b/libjava/java/awt/image/WritableRaster.java @@ -1,10 +1,27 @@ -/* Copyright (C) 2000 Free Software Foundation +/* Copyright (C) 2000, 2002 Free Software Foundation - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +As a special exception, if you link this library with other files to +produce an executable, this library does not by itself cause the +resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why the +executable file might be covered by the GNU General Public License. */ package java.awt.image;