Commit 3bd483f2 by Tom Tromey Committed by 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.

From-SVN: r48896
parent c342f126
2002-01-15 Tom Tromey <tromey@redhat.com> 2002-01-15 Tom Tromey <tromey@redhat.com>
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 <tromey@redhat.com>
* java/lang/Float.java (equals): Preserve old code. * java/lang/Float.java (equals): Preserve old code.
* java/lang/Double.java (equals): Preserve old code. * java/lang/Double.java (equals): Preserve old code.
......
...@@ -583,10 +583,10 @@ gnu/awt/j2d/DirectRasterGraphics.java \ ...@@ -583,10 +583,10 @@ gnu/awt/j2d/DirectRasterGraphics.java \
gnu/awt/j2d/Graphics2DImpl.java \ gnu/awt/j2d/Graphics2DImpl.java \
gnu/awt/j2d/IntegerGraphicsState.java \ gnu/awt/j2d/IntegerGraphicsState.java \
gnu/awt/j2d/MappedRaster.java \ gnu/awt/j2d/MappedRaster.java \
gnu/gcj/awt/BitMaskExtent.java \ gnu/java/awt/BitMaskExtent.java \
gnu/gcj/awt/Buffers.java \ gnu/java/awt/Buffers.java \
gnu/gcj/awt/ComponentDataBlitOp.java \ gnu/java/awt/ComponentDataBlitOp.java \
gnu/gcj/awt/GLightweightPeer.java \ gnu/java/awt/GLightweightPeer.java \
gnu/java/beans/editors/ColorEditor.java \ gnu/java/beans/editors/ColorEditor.java \
gnu/java/beans/editors/FontEditor.java \ gnu/java/beans/editors/FontEditor.java \
gnu/java/beans/editors/NativeBooleanEditor.java \ gnu/java/beans/editors/NativeBooleanEditor.java \
......
...@@ -334,10 +334,10 @@ gnu/awt/j2d/DirectRasterGraphics.java \ ...@@ -334,10 +334,10 @@ gnu/awt/j2d/DirectRasterGraphics.java \
gnu/awt/j2d/Graphics2DImpl.java \ gnu/awt/j2d/Graphics2DImpl.java \
gnu/awt/j2d/IntegerGraphicsState.java \ gnu/awt/j2d/IntegerGraphicsState.java \
gnu/awt/j2d/MappedRaster.java \ gnu/awt/j2d/MappedRaster.java \
gnu/gcj/awt/BitMaskExtent.java \ gnu/java/awt/BitMaskExtent.java \
gnu/gcj/awt/Buffers.java \ gnu/java/awt/Buffers.java \
gnu/gcj/awt/ComponentDataBlitOp.java \ gnu/java/awt/ComponentDataBlitOp.java \
gnu/gcj/awt/GLightweightPeer.java \ gnu/java/awt/GLightweightPeer.java \
gnu/java/beans/editors/ColorEditor.java \ gnu/java/beans/editors/ColorEditor.java \
gnu/java/beans/editors/FontEditor.java \ gnu/java/beans/editors/FontEditor.java \
gnu/java/beans/editors/NativeBooleanEditor.java \ gnu/java/beans/editors/NativeBooleanEditor.java \
...@@ -1732,11 +1732,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ ...@@ -1732,11 +1732,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/awt/xlib/XGraphicsConfiguration.P \ .deps/gnu/awt/xlib/XGraphicsConfiguration.P \
.deps/gnu/awt/xlib/XPanelPeer.P .deps/gnu/awt/xlib/XToolkit.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/classpath/Configuration.P .deps/gnu/gcj/Core.P \
.deps/gnu/gcj/RawData.P .deps/gnu/gcj/awt/BitMaskExtent.P \ .deps/gnu/gcj/RawData.P .deps/gnu/gcj/convert/BytesToUnicode.P \
.deps/gnu/gcj/awt/Buffers.P .deps/gnu/gcj/awt/ComponentDataBlitOp.P \ .deps/gnu/gcj/convert/Convert.P .deps/gnu/gcj/convert/IOConverter.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/convert/Input_8859_1.P \ .deps/gnu/gcj/convert/Input_8859_1.P \
.deps/gnu/gcj/convert/Input_ASCII.P \ .deps/gnu/gcj/convert/Input_ASCII.P \
.deps/gnu/gcj/convert/Input_EUCJIS.P \ .deps/gnu/gcj/convert/Input_EUCJIS.P \
...@@ -1802,6 +1799,9 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.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/natXColor.P .deps/gnu/gcj/xlib/natXConfigureEvent.P \
.deps/gnu/gcj/xlib/natXException.P .deps/gnu/gcj/xlib/natXExposeEvent.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/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/BeanInfoEmbryo.P \
.deps/gnu/java/beans/EmptyBeanInfo.P \ .deps/gnu/java/beans/EmptyBeanInfo.P \
.deps/gnu/java/beans/ExplicitBeanInfo.P \ .deps/gnu/java/beans/ExplicitBeanInfo.P \
......
...@@ -26,7 +26,7 @@ import gnu.gcj.xlib.Colormap; ...@@ -26,7 +26,7 @@ import gnu.gcj.xlib.Colormap;
import gnu.gcj.xlib.XColor; import gnu.gcj.xlib.XColor;
import gnu.gcj.xlib.Screen; import gnu.gcj.xlib.Screen;
import gnu.gcj.xlib.Display; import gnu.gcj.xlib.Display;
import gnu.gcj.awt.Buffers; import gnu.java.awt.Buffers;
import java.util.Hashtable; import java.util.Hashtable;
public class XGraphicsConfiguration extends GraphicsConfiguration public class XGraphicsConfiguration extends GraphicsConfiguration
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ the Free Software Foundation; either version 2, or (at your option)
any later version.
package gnu.gcj.awt; 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 gnu.java.awt;
/** /**
* Simple transparent utility class that can be used to perform bit * Simple transparent utility class that can be used to perform bit
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ the Free Software Foundation; either version 2, or (at your option)
any later version.
package gnu.gcj.awt; 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 gnu.java.awt;
import java.awt.image.*; import java.awt.image.*;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ the Free Software Foundation; either version 2, or (at your option)
any later version.
package gnu.gcj.awt; 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 gnu.java.awt;
import java.awt.geom.*; import java.awt.geom.*;
import java.awt.image.*; import java.awt.image.*;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ the Free Software Foundation; either version 2, or (at your option)
any later version.
package gnu.gcj.awt; 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 gnu.java.awt;
import java.awt.*; import java.awt.*;
import java.awt.peer.*; import java.awt.peer.*;
...@@ -131,4 +148,9 @@ public class GLightweightPeer implements LightweightPeer ...@@ -131,4 +148,9 @@ public class GLightweightPeer implements LightweightPeer
public void setVisible(boolean visible) {} public void setVisible(boolean visible) {}
public void show() {} public void show() {}
public ColorModel getColorModel ()
{
return null;
}
} }
...@@ -396,6 +396,9 @@ ...@@ -396,6 +396,9 @@
/* Define as const if the declaration of iconv() needs const. */ /* Define as const if the declaration of iconv() needs const. */
#undef ICONV_CONST #undef ICONV_CONST
/* Define if your <locale.h> file defines LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
/* Required define if using POSIX threads */ /* Required define if using POSIX threads */
#undef _REENTRANT #undef _REENTRANT
......
/* 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; package java.awt;
...@@ -18,26 +36,83 @@ 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 * 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. * model. It supersedes the Event class from JDK 1.0.
* @author Warren Levy <warrenl@cygnus.com>
* @author Aaron M. Renn (arenn@urbanophile.com)
*/ */
public abstract class AWTEvent extends java.util.EventObject public abstract class AWTEvent extends java.util.EventObject
{ {
/**
* @serial Indicates whether or not this event has been consumed.
*/
protected boolean consumed; protected boolean consumed;
/**
* @serial The identifier number of this event.
*/
protected int id; protected int id;
/* Event selection masks */ /**
public static final long COMPONENT_EVENT_MASK = 1 << 0, * Mask for selecting component events.
CONTAINER_EVENT_MASK = 1 << 1, */
FOCUS_EVENT_MASK = 1 << 2, public static final long COMPONENT_EVENT_MASK = 0x001;
KEY_EVENT_MASK = 1 << 3,
MOUSE_EVENT_MASK = 1 << 4, /**
MOUSE_MOTION_EVENT_MASK = 1 << 5, * Mask for selecting container events.
WINDOW_EVENT_MASK = 1 << 6, */
ACTION_EVENT_MASK = 1 << 7, public static final long CONTAINER_EVENT_MASK = 0x002;
ADJUSTMENT_EVENT_MASK = 1 << 8,
ITEM_EVENT_MASK = 1 << 9, /**
TEXT_EVENT_MASK = 1 << 10, * Mask for selecting component focus events.
INPUT_METHOD_EVENT_MASK = 1 << 11; */
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 */ /* Additional event selection masks from JDK 1.3 javadocs */
public static final long PAINT_EVENT_MASK = 1 << 13, public static final long PAINT_EVENT_MASK = 1 << 13,
...@@ -45,41 +120,82 @@ public abstract class AWTEvent extends java.util.EventObject ...@@ -45,41 +120,82 @@ public abstract class AWTEvent extends java.util.EventObject
HIERARCHY_EVENT_MASK = 1 << 15, HIERARCHY_EVENT_MASK = 1 << 15,
HIERARCHY_BOUNDS_EVENT_MASK = 1 << 16; HIERARCHY_BOUNDS_EVENT_MASK = 1 << 16;
public static final int RESERVED_ID_MAX = 0x7cf; /**
* Initializes a new instance of <code>AWTEvent</code> 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) public AWTEvent(Event event)
{ {
// FIXME?? // FIXME??
super(event.target); super(event.target);
this.id = event.id; this.id = event.id;
} }
/**
* Initializes a new instance of <code>AWTEvent</code> 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) public AWTEvent(Object source, int id)
{ {
super(source); super(source);
this.id = id; this.id = id;
} }
/**
* Returns the id number of this event.
*
* @return The id number of this event.
*/
public int getID() public int getID()
{ {
return id; return id;
} }
/**
* Returns a string representation of this event.
*
* @return A string representation of this event.
*/
public String paramString () public String paramString ()
{ {
return ""; return "";
} }
/**
* Returns a string representation of this event.
*
* @return A string representation of this event.
*/
public String toString () public String toString ()
{ {
return getClass().getName() + "[" + paramString() + "] on " + source; return getClass().getName() + "[" + paramString() + "] on " + source;
} }
/**
* Consumes this event so that it will not be processed in the default
* manner.
*/
protected void consume() protected void consume()
{ {
consumed = true; consumed = true;
} }
/**
* Tests whether not not this event has been consumed. A consumed event
* is not processed in the default manner.
*
* @return <code>true</code> if this event has been consumed,
* <code>false</code> otherwise.
*/
protected boolean isConsumed() protected boolean isConsumed()
{ {
return consumed; return consumed;
......
/* 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; package java.awt;
...@@ -21,20 +39,65 @@ import java.io.ObjectOutputStream; ...@@ -21,20 +39,65 @@ import java.io.ObjectOutputStream;
*/ */
/** /**
* Convienience class for thread-safe multicasting of AWT events, * This class is used to implement a chain of event handlers. Dispatching
* without synchronization. * 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
* @author Bryce McKinlay * assume are firing <code>AdjustableEvent</code>'s. However, this
*/ * same approach is useful for all events in the <code>java.awt.event</code>
* package, and more if this class is subclassed.
* <p>
* <code>
* AdjustmentListener al;
*
* public void
* addAdjustmentListener(AdjustmentListener listener)
* {
* al = AWTEventMulticaster.add(al, listener);
* }
*
* public void
* removeAdjustmentListener(AdjustmentListener listener)
* {
* al = AWTEventMulticaster.remove(al, listener);
* }
* </code>
* <p>
* When it come time to process an event, simply call <code>al</code>,
* assuming it is not <code>null</code>.
* <p>
* The first time <code>add</code> is called it is passed
* <code>null</code> and <code>listener</code> as its arguments. This
* starts building the chain. This class returns <code>listener</code>
* which becomes the new <code>al</code>. The next time, <code>add</code>
* is called with <code>al</code> and <code>listener</code> 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, public class AWTEventMulticaster implements ComponentListener,
ContainerListener, FocusListener, KeyListener, MouseListener, ContainerListener, FocusListener, KeyListener, MouseListener,
MouseMotionListener, WindowListener, ActionListener, ItemListener, MouseMotionListener, WindowListener, ActionListener, ItemListener,
AdjustmentListener, TextListener, InputMethodListener, HierarchyListener, AdjustmentListener, TextListener, InputMethodListener, HierarchyListener,
HierarchyBoundsListener 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 <code>AWTEventMulticaster</code> with
* the specified event listener parameters.
*
* @param a The "a" listener object.
* @param b The "b" listener object.
*/
protected AWTEventMulticaster(EventListener a, protected AWTEventMulticaster(EventListener a,
EventListener b) EventListener b)
{ {
...@@ -42,6 +105,14 @@ public class AWTEventMulticaster implements ComponentListener, ...@@ -42,6 +105,14 @@ public class AWTEventMulticaster implements ComponentListener,
this.b = b; this.b = b;
} }
/**
* Chain <code>EventListener</code> 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) protected static EventListener addInternal(EventListener a, EventListener b)
{ {
if (a == null) if (a == null)
...@@ -50,7 +121,15 @@ public class AWTEventMulticaster implements ComponentListener, ...@@ -50,7 +121,15 @@ public class AWTEventMulticaster implements ComponentListener,
return a; return a;
else return new AWTEventMulticaster(a, b); else return new AWTEventMulticaster(a, b);
} }
/**
* Removes the listener <code>old</code> from the listener <code>lis</code>.
*
* @param lis The listener to remove <code>old</code> from.
* @param old The listener to remove.
*
* @return The resulting listener after the remove operation.
*/
protected static EventListener removeInternal(EventListener l, protected static EventListener removeInternal(EventListener l,
EventListener oldl) EventListener oldl)
{ {
...@@ -64,7 +143,17 @@ public class AWTEventMulticaster implements ComponentListener, ...@@ -64,7 +143,17 @@ public class AWTEventMulticaster implements ComponentListener,
return l; 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) protected EventListener remove(EventListener oldl)
{ {
// If oldl is an immediate child, return the other child. // If oldl is an immediate child, return the other child.
...@@ -73,7 +162,7 @@ public class AWTEventMulticaster implements ComponentListener, ...@@ -73,7 +162,7 @@ public class AWTEventMulticaster implements ComponentListener,
if (b == oldl) if (b == oldl)
return a; 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) if (a instanceof AWTEventMulticaster)
{ {
AWTEventMulticaster mc = (AWTEventMulticaster) a; AWTEventMulticaster mc = (AWTEventMulticaster) a;
...@@ -88,108 +177,236 @@ public class AWTEventMulticaster implements ComponentListener, ...@@ -88,108 +177,236 @@ public class AWTEventMulticaster implements ComponentListener,
if (newb != b) if (newb != b)
return new AWTEventMulticaster (a, newb); return new AWTEventMulticaster (a, newb);
} }
// oldl was not found. // oldl was not found.
return this; return this;
} }
/**
* Chain <code>ActionListener</code> 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) public static ActionListener add(ActionListener a, ActionListener b)
{ {
return (ActionListener) addInternal(a, b); return (ActionListener) addInternal(a, b);
} }
/**
* Chain <code>AdjustmentListener</code> 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, public static AdjustmentListener add(AdjustmentListener a,
AdjustmentListener b) AdjustmentListener b)
{ {
return (AdjustmentListener) addInternal(a, b); return (AdjustmentListener) addInternal(a, b);
} }
/**
* Chain <code>ComponentListener</code> 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) public static ComponentListener add(ComponentListener a, ComponentListener b)
{ {
return (ComponentListener) addInternal(a, b); return (ComponentListener) addInternal(a, b);
} }
/**
* Chain <code>ContainerListener</code> 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) public static ContainerListener add(ContainerListener a, ContainerListener b)
{ {
return (ContainerListener) addInternal(a, b); return (ContainerListener) addInternal(a, b);
} }
/**
* Chain <code>FocusListener</code> 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) public static FocusListener add(FocusListener a, FocusListener b)
{ {
return (FocusListener) addInternal(a, b); return (FocusListener) addInternal(a, b);
} }
public static HierarchyBoundsListener add(HierarchyBoundsListener a, public static HierarchyBoundsListener add(HierarchyBoundsListener a,
HierarchyBoundsListener b) HierarchyBoundsListener b)
{ {
return (HierarchyBoundsListener) addInternal(a, b); return (HierarchyBoundsListener) addInternal(a, b);
} }
public static HierarchyListener add(HierarchyListener a, HierarchyListener b) public static HierarchyListener add(HierarchyListener a, HierarchyListener b)
{ {
return (HierarchyListener) addInternal(a, b); return (HierarchyListener) addInternal(a, b);
} }
public static InputMethodListener add(InputMethodListener a, public static InputMethodListener add(InputMethodListener a,
InputMethodListener b) InputMethodListener b)
{ {
return (InputMethodListener) addInternal(a, b); return (InputMethodListener) addInternal(a, b);
} }
/**
* Chain <code>ItemListener</code> 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) public static ItemListener add(ItemListener a, ItemListener b)
{ {
return (ItemListener) addInternal(a, b); return (ItemListener) addInternal(a, b);
} }
/**
* Chain <code>KeyListener</code> 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) public static KeyListener add(KeyListener a, KeyListener b)
{ {
return (KeyListener) addInternal(a, b); return (KeyListener) addInternal(a, b);
} }
/**
* Chain <code>MouseListener</code> 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) public static MouseListener add(MouseListener a, MouseListener b)
{ {
return (MouseListener) addInternal(a, b); return (MouseListener) addInternal(a, b);
} }
/**
* Chain <code>MouseMotionListener</code> 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, public static MouseMotionListener add(MouseMotionListener a,
MouseMotionListener b) MouseMotionListener b)
{ {
return (MouseMotionListener) addInternal(a, b); return (MouseMotionListener) addInternal(a, b);
} }
/**
* Chain <code>AdjustmentListener</code> 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) public static TextListener add(TextListener a, TextListener b)
{ {
return (TextListener) addInternal(a, b); return (TextListener) addInternal(a, b);
} }
/**
* Chain <code>WindowListener</code> 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) public static WindowListener add(WindowListener a, WindowListener b)
{ {
return (WindowListener) addInternal(a, b); return (WindowListener) addInternal(a, b);
} }
/**
* Removes the listener <code>old</code> from the listener <code>lis</code>.
*
* @param lis The listener to remove <code>old</code> from.
* @param old The listener to remove.
*
* @return The resulting listener after the remove operation.
*/
public static ActionListener remove(ActionListener l, ActionListener oldl) public static ActionListener remove(ActionListener l, ActionListener oldl)
{ {
return (ActionListener) removeInternal(l, oldl); return (ActionListener) removeInternal(l, oldl);
} }
/**
* Removes the listener <code>old</code> from the listener <code>lis</code>.
*
* @param lis The listener to remove <code>old</code> from.
* @param old The listener to remove.
*
* @return The resulting listener after the remove operation.
*/
public static AdjustmentListener remove(AdjustmentListener l, public static AdjustmentListener remove(AdjustmentListener l,
AdjustmentListener oldl) AdjustmentListener oldl)
{ {
return (AdjustmentListener) removeInternal(l, oldl); return (AdjustmentListener) removeInternal(l, oldl);
} }
/**
* Removes the listener <code>old</code> from the listener <code>lis</code>.
*
* @param lis The listener to remove <code>old</code> from.
* @param old The listener to remove.
*
* @return The resulting listener after the remove operation.
*/
public static ComponentListener remove(ComponentListener l, public static ComponentListener remove(ComponentListener l,
ComponentListener oldl) ComponentListener oldl)
{ {
return (ComponentListener) removeInternal(l, oldl); return (ComponentListener) removeInternal(l, oldl);
} }
/**
* Removes the listener <code>old</code> from the listener <code>lis</code>.
*
* @param lis The listener to remove <code>old</code> from.
* @param old The listener to remove.
*
* @return The resulting listener after the remove operation.
*/
public static ContainerListener remove(ContainerListener l, public static ContainerListener remove(ContainerListener l,
ContainerListener oldl) ContainerListener oldl)
{ {
return (ContainerListener) removeInternal(l, oldl); return (ContainerListener) removeInternal(l, oldl);
} }
/**
* Removes the listener <code>old</code> from the listener <code>lis</code>.
*
* @param lis The listener to remove <code>old</code> from.
* @param old The listener to remove.
*
* @return The resulting listener after the remove operation.
*/
public static FocusListener remove(FocusListener l, FocusListener oldl) public static FocusListener remove(FocusListener l, FocusListener oldl)
{ {
return (FocusListener) removeInternal(l, oldl); return (FocusListener) removeInternal(l, oldl);
...@@ -213,251 +430,500 @@ public class AWTEventMulticaster implements ComponentListener, ...@@ -213,251 +430,500 @@ public class AWTEventMulticaster implements ComponentListener,
return (InputMethodListener) removeInternal(l, oldl); return (InputMethodListener) removeInternal(l, oldl);
} }
/**
* Removes the listener <code>old</code> from the listener <code>lis</code>.
*
* @param lis The listener to remove <code>old</code> from.
* @param old The listener to remove.
*
* @return The resulting listener after the remove operation.
*/
public static ItemListener remove(ItemListener l, ItemListener oldl) public static ItemListener remove(ItemListener l, ItemListener oldl)
{ {
return (ItemListener) removeInternal(l, oldl); return (ItemListener) removeInternal(l, oldl);
} }
/**
* Removes the listener <code>old</code> from the listener <code>lis</code>.
*
* @param lis The listener to remove <code>old</code> from.
* @param old The listener to remove.
*
* @return The resulting listener after the remove operation.
*/
public static KeyListener remove(KeyListener l, KeyListener oldl) public static KeyListener remove(KeyListener l, KeyListener oldl)
{ {
return (KeyListener) removeInternal(l, oldl); return (KeyListener) removeInternal(l, oldl);
} }
/**
* Removes the listener <code>old</code> from the listener <code>lis</code>.
*
* @param lis The listener to remove <code>old</code> from.
* @param old The listener to remove.
*
* @return The resulting listener after the remove operation.
*/
public static MouseListener remove(MouseListener l, MouseListener oldl) public static MouseListener remove(MouseListener l, MouseListener oldl)
{ {
return (MouseListener) removeInternal(l, oldl); return (MouseListener) removeInternal(l, oldl);
} }
/**
* Removes the listener <code>old</code> from the listener <code>lis</code>.
*
* @param lis The listener to remove <code>old</code> from.
* @param old The listener to remove.
*
* @return The resulting listener after the remove operation.
*/
public static MouseMotionListener remove(MouseMotionListener l, public static MouseMotionListener remove(MouseMotionListener l,
MouseMotionListener oldl) MouseMotionListener oldl)
{ {
return (MouseMotionListener) removeInternal(l, oldl); return (MouseMotionListener) removeInternal(l, oldl);
} }
/**
* Removes the listener <code>old</code> from the listener <code>lis</code>.
*
* @param lis The listener to remove <code>old</code> from.
* @param old The listener to remove.
*
* @return The resulting listener after the remove operation.
*/
public static TextListener remove(TextListener l, TextListener oldl) public static TextListener remove(TextListener l, TextListener oldl)
{ {
return (TextListener) removeInternal(l, oldl); return (TextListener) removeInternal(l, oldl);
} }
/**
* Removes the listener <code>old</code> from the listener <code>lis</code>.
*
* @param lis The listener to remove <code>old</code> from.
* @param old The listener to remove.
*
* @return The resulting listener after the remove operation.
*/
public static WindowListener remove(WindowListener l, WindowListener oldl) public static WindowListener remove(WindowListener l, WindowListener oldl)
{ {
return (WindowListener) removeInternal(l, 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) public void actionPerformed(ActionEvent e)
{ {
((ActionListener) a).actionPerformed(e); ((ActionListener) a).actionPerformed(e);
((ActionListener) b).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) public void adjustmentValueChanged(AdjustmentEvent e)
{ {
((AdjustmentListener) a).adjustmentValueChanged(e); ((AdjustmentListener) a).adjustmentValueChanged(e);
((AdjustmentListener) b).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) public void componentHidden(ComponentEvent e)
{ {
((ComponentListener) a).componentHidden(e); ((ComponentListener) a).componentHidden(e);
((ComponentListener) b).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) public void componentMoved(ComponentEvent e)
{ {
((ComponentListener) a).componentMoved(e); ((ComponentListener) a).componentMoved(e);
((ComponentListener) b).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) public void componentResized(ComponentEvent e)
{ {
((ComponentListener) a).componentResized(e); ((ComponentListener) a).componentResized(e);
((ComponentListener) b).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) public void componentShown(ComponentEvent e)
{ {
((ComponentListener) a).componentShown(e); ((ComponentListener) a).componentShown(e);
((ComponentListener) b).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) public void componentAdded(ContainerEvent e)
{ {
((ContainerListener) a).componentAdded(e); ((ContainerListener) a).componentAdded(e);
((ContainerListener) b).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) public void componentRemoved(ContainerEvent e)
{ {
((ContainerListener) a).componentRemoved(e); ((ContainerListener) a).componentRemoved(e);
((ContainerListener) b).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) public void focusGained(FocusEvent e)
{ {
((FocusListener) a).focusGained(e); ((FocusListener) a).focusGained(e);
((FocusListener) b).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) public void focusLost(FocusEvent e)
{ {
((FocusListener) a).focusLost(e); ((FocusListener) a).focusLost(e);
((FocusListener) b).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) public void ancestorMoved(HierarchyEvent e)
{ {
((HierarchyBoundsListener) a).ancestorMoved(e); ((HierarchyBoundsListener) a).ancestorMoved(e);
((HierarchyBoundsListener) b).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) public void ancestorResized(HierarchyEvent e)
{ {
((HierarchyBoundsListener) a).ancestorResized(e); ((HierarchyBoundsListener) a).ancestorResized(e);
((HierarchyBoundsListener) b).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) public void hierarchyChanged(HierarchyEvent e)
{ {
((HierarchyListener) a).hierarchyChanged(e); ((HierarchyListener) a).hierarchyChanged(e);
((HierarchyListener) b).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) public void caretPositionChanged(InputMethodEvent e)
{ {
((InputMethodListener) a).caretPositionChanged(e); ((InputMethodListener) a).caretPositionChanged(e);
((InputMethodListener) b).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) public void inputMethodTextChanged(InputMethodEvent e)
{ {
((InputMethodListener) a).inputMethodTextChanged(e); ((InputMethodListener) a).inputMethodTextChanged(e);
((InputMethodListener) b).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) public void itemStateChanged(ItemEvent e)
{ {
((ItemListener) a).itemStateChanged(e); ((ItemListener) a).itemStateChanged(e);
((ItemListener) b).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) public void keyPressed(KeyEvent e)
{ {
((KeyListener) a).keyPressed(e); ((KeyListener) a).keyPressed(e);
((KeyListener) b).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) public void keyReleased(KeyEvent e)
{ {
((KeyListener) a).keyReleased(e); ((KeyListener) a).keyReleased(e);
((KeyListener) b).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) public void keyTyped(KeyEvent e)
{ {
((KeyListener) a).keyTyped(e); ((KeyListener) a).keyTyped(e);
((KeyListener) b).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) public void mouseClicked(MouseEvent e)
{ {
((MouseListener) a).mouseClicked(e); ((MouseListener) a).mouseClicked(e);
((MouseListener) b).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) public void mouseEntered(MouseEvent e)
{ {
((MouseListener) a).mouseEntered(e); ((MouseListener) a).mouseEntered(e);
((MouseListener) b).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) public void mouseExited(MouseEvent e)
{ {
((MouseListener) a).mouseExited(e); ((MouseListener) a).mouseExited(e);
((MouseListener) b).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) public void mousePressed(MouseEvent e)
{ {
((MouseListener) a).mousePressed(e); ((MouseListener) a).mousePressed(e);
((MouseListener) b).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) public void mouseReleased(MouseEvent e)
{ {
((MouseListener) a).mouseReleased(e); ((MouseListener) a).mouseReleased(e);
((MouseListener) b).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) public void mouseDragged(MouseEvent e)
{ {
((MouseMotionListener) a).mouseDragged(e); ((MouseMotionListener) a).mouseDragged(e);
((MouseMotionListener) b).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) public void mouseMoved(MouseEvent e)
{ {
((MouseMotionListener) a).mouseMoved(e); ((MouseMotionListener) a).mouseMoved(e);
((MouseMotionListener) b).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) public void textValueChanged(TextEvent e)
{ {
((TextListener) a).textValueChanged(e); ((TextListener) a).textValueChanged(e);
((TextListener) b).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) public void windowActivated(WindowEvent e)
{ {
((WindowListener) a).windowActivated(e); ((WindowListener) a).windowActivated(e);
((WindowListener) b).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) public void windowClosed(WindowEvent e)
{ {
((WindowListener) a).windowClosed(e); ((WindowListener) a).windowClosed(e);
((WindowListener) b).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) public void windowClosing(WindowEvent e)
{ {
((WindowListener) a).windowClosing(e); ((WindowListener) a).windowClosing(e);
((WindowListener) b).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) public void windowDeactivated(WindowEvent e)
{ {
((WindowListener) a).windowDeactivated(e); ((WindowListener) a).windowDeactivated(e);
((WindowListener) b).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) public void windowDeiconified(WindowEvent e)
{ {
((WindowListener) a).windowDeiconified(e); ((WindowListener) a).windowDeiconified(e);
((WindowListener) b).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) public void windowIconified(WindowEvent e)
{ {
((WindowListener) a).windowIconified(e); ((WindowListener) a).windowIconified(e);
((WindowListener) b).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) public void windowOpened(WindowEvent e)
{ {
((WindowListener) a).windowOpened(e); ((WindowListener) a).windowOpened(e);
((WindowListener) b).windowOpened(e); ((WindowListener) b).windowOpened(e);
} }
protected static void save(ObjectOutputStream s, String k, EventListener l) protected static void save(ObjectOutputStream s, String k, EventListener l)
{ {
// FIXME throw new RuntimeException("Not Implemented");
} }
protected void saveInternal(ObjectOutputStream s, String k) protected void saveInternal(ObjectOutputStream s, String k)
{ {
// FIXME throw new RuntimeException("Not Implemented");
} }
} }
/* 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; 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 <rolfwr@ii.uib.no>
*/
public class BorderLayout implements LayoutManager2, java.io.Serializable public class BorderLayout implements LayoutManager2, java.io.Serializable
{ {
public static final String NORTH = "North",
SOUTH = "South", /*
EAST = "East", * Static Variables
WEST = "West", */
CENTER = "Center";
/**
// FIXME: use these too * Constant indicating the top of the container
public static final String BEFORE_FIRST_LINE = "First", */
AFTER_LAST_LINE = "Last", public static final String NORTH = "North";
BEFORE_LINE_BEGINS = "Before",
AFTER_LINE_ENDS = "After"; /**
* Constant indicating the bottom of the container
*/
// FIXME: check serialization of fields public static final String SOUTH = "South";
int hgap;
int vgap; /**
Component north, south, east, west, center; * Constant indicating the right side of the container
*/
public BorderLayout () public static final String EAST = "East";
{
this (0, 0); /**
} * Constant indicating the left side of the container
*/
public BorderLayout (int hgap, int vgap) public static final String WEST = "West";
{
this.hgap = hgap; /**
this.vgap = vgap; * Constant indicating the center of the container
} */
public static final String CENTER = "Center";
public int getHgap()
{ /**
return hgap; * Constant indicating the position just after the last line of the
} * layout.
*/
public void setHgap(int hgap) public static final String AFTER_LAST_LINE = "Last";
{
this.hgap = hgap; /**
} * Constant indicating the position just after the end of the line.
*/
public int getVgap() public static final String AFTER_LINE_ENDS = "After";
{
return vgap; /**
} * Constant indicating the position just before the first line of the
* layout.
public void setVgap(int vgap) */
{ public static final String BEFORE_FIRST_LINE = "First";
this.vgap = vgap;
} /**
* Constant indicating the position at the beginning of the line.
public void addLayoutComponent(Component comp, Object constraints) */
{ public static final String BEFORE_LINE_BEGINS = "Before";
if ((constraints == null) || CENTER.equals(constraints))
{ // Serialization constant
center = comp; private static final long serialVersionUID = -8658291919501921765L;
}
else if (NORTH.equals(constraints)) /*************************************************************************/
{
north = comp; /*
} * Instance Variables
else if (SOUTH.equals(constraints)) */
{
south = comp; /**
} * @serial
else if (EAST.equals(constraints)) */
{ private Component north;
east = comp;
} /**
else if (WEST.equals(constraints)) * @serial
{ */
west = comp; private Component south;
}
} /**
* @serial
public void addLayoutComponent(String name, Component comp) */
{ private Component east;
addLayoutComponent(comp, name);
} /**
* @serial
public void removeLayoutComponent(Component comp) */
{ private Component west;
if (center == comp)
{ /**
center = null; * @serial
} */
else if (north == comp) private Component center;
{
north = null; /**
} * @serial
else if (south == comp) */
{ private Component firstLine;
south = null;
} /**
else if (east == comp) * @serial
{ */
east = null; private Component lastLine;
}
else if (west == comp) /**
{ * @serial
west = null; */
} private Component firstItem;
}
/**
public Dimension minimumLayoutSize(Container target) * @serial
{ */
return calcSize(getMinimumSize(center), private Component lastItem;
getMinimumSize(north),
getMinimumSize(south), /**
getMinimumSize(east), * @serial The horizontal gap between components
getMinimumSize(west), */
target); private int hgap;
}
/**
public Dimension preferredLayoutSize(Container target) * @serial The vertical gap between components
{ */
return calcSize(getPreferredSize(center), private int vgap;
getPreferredSize(north),
getPreferredSize(south), /*************************************************************************/
getPreferredSize(east),
getPreferredSize(west), /*
target); * Constructors
} */
/** /**
* Completely disregards the requested maximum sizes of the * Initializes a new instance of <code>BorderLayout</code> with no
* components, and states that the container has no upper size * horiztonal or vertical gaps between components.
* limit. */
* public
* @return a dimension of width and height Integer.MAX_VALUE. BorderLayout()
*/ {
public Dimension maximumLayoutSize(Container target) this(0,0);
{ }
return (Dimension) DIM_MAX.clone();
} /*************************************************************************/
public float getLayoutAlignmentX(Container parent) /**
{ * Initializes a new instance of <code>BorderLayout</code> with the
return Component.CENTER_ALIGNMENT; * specified horiztonal and vertical gaps between components.
} *
* @param hgap The horizontal gap between components.
public float getLayoutAlignmentY(Container parent) * @param vgap The vertical gap between components.
{ */
return Component.CENTER_ALIGNMENT; public
} BorderLayout(int hgap, int vgap)
{
public void invalidateLayout(Container target) this.hgap = hgap;
{ this.vgap = vgap;
// TODO... implement caching? }
}
/*************************************************************************/
public void layoutContainer(Container target)
{ /*
Insets i = target.getInsets(); * Instance Variables
Dimension c = getPreferredSize(center); */
Dimension n = getPreferredSize(north);
Dimension s = getPreferredSize(south); /**
Dimension e = getPreferredSize(east); * Returns the horitzontal gap value.
Dimension w = getPreferredSize(west); *
Dimension t = target.getSize(); * @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
* <code>addLayoutComponent(Component, Object)</code>.
*/
public void
addLayoutComponent(String constraints, Component component)
{
addLayoutComponent(component, constraints);
}
/*************************************************************************/
/**
* Removes the specified component from the layout.
*
* @param component The component to remove from the layout.
*/
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 <code>float</code> 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 <code>float</code> 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();
/* /*
<-> hgap <-> hgap <-> hgap <-> hgap
+----------------------------+ } +----------------------------+ }
...@@ -190,65 +497,119 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable ...@@ -190,65 +497,119 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
i.left i.right i.left i.right
*/ */
int x1 = i.left; int x1 = i.left;
int x2 = x1 + w.width + hgap; int x2 = x1 + w.width + hgap;
int x3 = t.width - i.right - e.width; int x3 = t.width - i.right - e.width;
int ww = t.width - i.right - i.left; int ww = t.width - i.right - i.left;
int y1 = i.top; int y1 = i.top;
int y2 = y1 + n.height + vgap; int y2 = y1 + n.height + vgap;
int y3 = t.height - i.bottom - s.height; int y3 = t.height - i.bottom - s.height;
int hh = y3-y2-vgap; int hh = y3-y2-vgap;
setBounds(center, x2, y2, x3-x2-hgap, hh); setBounds(center, x2, y2, x3-x2-hgap, hh);
setBounds(north, x1, y1, ww, n.height); setBounds(my_north, x1, y1, ww, n.height);
setBounds(south, x1, y3, ww, s.height); setBounds(my_south, x1, y3, ww, s.height);
setBounds(west, x1, y2, w.width, hh); setBounds(my_west, x1, y2, w.width, hh);
setBounds(east, x3, y2, e.width, hh); setBounds(my_east, x3, y2, e.width, hh);
} }
public String toString() /*************************************************************************/
{
return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + "]"; /**
} * Returns a string representation of this layout manager.
*
* @return A string representation of this object.
// Support: */
public String
static final Dimension DIM_0 = new Dimension(0, 0); toString()
static final Dimension DIM_MAX = new Dimension(Integer.MAX_VALUE, {
Integer.MAX_VALUE); return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + "]";
}
void setBounds(Component comp, int x, int y, int w, int h)
{ private void
if (comp == null) setBounds(Component comp, int x, int y, int w, int h)
return; {
comp.setBounds(x, y, w, h); if (comp == null)
} return;
comp.setBounds(x, y, w, h);
Dimension getMinimumSize(Component comp) }
{
if (comp == null) // Some constants for use with calcSize().
return DIM_0; 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(); return comp.getMinimumSize();
} else if (what == MAX)
return comp.getMaximumSize();
Dimension getPreferredSize(Component comp) return comp.getPreferredSize();
{ }
if (comp == null)
return DIM_0; // This is a helper function used to compute the various sizes for
return comp.getPreferredSize(); // this layout.
} private Dimension
calcSize(Container target, int what)
Dimension calcSize(Dimension c, Dimension n, Dimension s, {
Dimension e, Dimension w, Container target) Insets ins = target.getInsets();
{
Insets i = target.getInsets(); ComponentOrientation orient = target.getComponentOrientation ();
boolean left_to_right = orient.isLeftToRight ();
return new Dimension(c.width + e.width + w.width + hgap*2 +
i.left + i.right, Component my_north = north;
c.height + n.height + s.height + vgap*2 + Component my_east = east;
i.top + i.bottom 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
// CardLayout.java - Card-based layout engine // 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. This file is part of libgcj.
...@@ -137,14 +137,9 @@ public class CardLayout implements LayoutManager2, Serializable ...@@ -137,14 +137,9 @@ public class CardLayout implements LayoutManager2, Serializable
for (int i = 0; i < num; ++i) for (int i = 0; i < num; ++i)
{ {
if (comps[i].isVisible ()) comps[i].setBounds (hgap + ins.left, vgap + ins.top,
{ width - 2 * hgap - ins.left - ins.right,
// Only resize the one we care about. height - 2 * vgap - ins.top - ins.bottom);
comps[i].setBounds (hgap + ins.left, vgap + ins.top,
width - 2 * hgap - ins.left - ins.right,
height - 2 * vgap - ins.top - ins.bottom);
break;
}
} }
} }
...@@ -272,13 +267,13 @@ public class CardLayout implements LayoutManager2, Serializable ...@@ -272,13 +267,13 @@ public class CardLayout implements LayoutManager2, Serializable
{ {
choice = i + 1; choice = i + 1;
if (choice == num) if (choice == num)
choice = num - 1; choice = 0;
} }
else if (what == PREV) else if (what == PREV)
{ {
choice = i - 1; choice = i - 1;
if (choice < 0) if (choice < 0)
choice = 0; choice = num - 1;
} }
else else
{ {
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt;
import java.awt.event.*; import java.awt.event.*;
...@@ -34,13 +51,41 @@ import java.beans.PropertyChangeListener; ...@@ -34,13 +51,41 @@ import java.beans.PropertyChangeListener;
public abstract class Component implements ImageObserver, MenuContainer, public abstract class Component implements ImageObserver, MenuContainer,
java.io.Serializable java.io.Serializable
{ {
/**
* Constant returned by the <code>getAlignmentY</code> 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;
/**
* Constant returned by the <code>getAlignmentY</code> and
* <code>getAlignmentX</code> 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;
/* Constants for use with getAlignmentX()/getAlignmentY(). */ /**
public static final float BOTTOM_ALIGNMENT = 1.0f, * Constant returned by the <code>getAlignmentY</code> method to indicate
CENTER_ALIGNMENT = 0.5f, * that the component wishes to be aligned to the top relative to
LEFT_ALIGNMENT = 0.0f, * other components.
RIGHT_ALIGNMENT = 1.0f, */
TOP_ALIGNMENT = 0.0f; public static final float TOP_ALIGNMENT = (float)0.0;
/**
* Constant returned by the <code>getAlignmentX</code> 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 <code>getAlignmentX</code> 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 /* 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 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, ...@@ -92,17 +137,30 @@ public abstract class Component implements ImageObserver, MenuContainer,
transient ComponentOrientation orientation = ComponentOrientation.UNKNOWN; transient ComponentOrientation orientation = ComponentOrientation.UNKNOWN;
/**
* Default constructor for subclasses.
*/
protected Component() protected Component()
{ {
} }
/**
* Returns the name of this component.
*
* @return The name of this component.
*/
public String getName() public String getName()
{ {
if (name == null && !nameExplicitlySet) if (name == null && !nameExplicitlySet)
name = generateName(); name = generateName();
return name; 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) public void setName(String name)
{ {
nameExplicitlySet = true; nameExplicitlySet = true;
...@@ -117,19 +175,35 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -117,19 +175,35 @@ public abstract class Component implements ImageObserver, MenuContainer,
// Component is abstract. // Component is abstract.
return null; return null;
} }
/**
* Returns the parent of this component.
*
* @return The parent of this component.
*/
public Container getParent() public Container getParent()
{ {
return parent; return parent;
} }
/** @deprecated */ // Sets the peer for this component.
// However, Classpath's Gtk peers rely on it. 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() public java.awt.peer.ComponentPeer getPeer()
{ {
return peer; return peer;
} }
// FIXME: java.awt.dnd classes not yet implemented // FIXME: java.awt.dnd classes not yet implemented
/* /*
public void setDropTarget(DropTarget dt) public void setDropTarget(DropTarget dt)
...@@ -167,11 +241,28 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -167,11 +241,28 @@ public abstract class Component implements ImageObserver, MenuContainer,
return null; 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() public final Object getTreeLock()
{ {
return treeLock; 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() public Toolkit getToolkit()
{ {
if (peer != null) if (peer != null)
...@@ -185,6 +276,13 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -185,6 +276,13 @@ public abstract class Component implements ImageObserver, MenuContainer,
return Toolkit.getDefaultToolkit (); return Toolkit.getDefaultToolkit ();
} }
/**
* Tests whether or not this component is valid. A invalid component needs
* to have its layout redone.
*
* @return <code>true</code> if this component is valid, <code>false</code>
* otherwise.
*/
public boolean isValid() public boolean isValid()
{ {
return valid; return valid;
...@@ -197,12 +295,26 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -197,12 +295,26 @@ public abstract class Component implements ImageObserver, MenuContainer,
return parent.isDisplayable(); return parent.isDisplayable();
return false; return false;
} }
/**
* Tests whether or not this component is visible.
*
* @return <code>true</code> if the component is visible,
* <code>false</code> otherwise.
*/
public boolean isVisible() public boolean isVisible()
{ {
return visible; 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 <code>true</code> if the component is showing on the screen,
* <code>false</code> otherwise.
*/
public boolean isShowing() public boolean isShowing()
{ {
if (! visible || peer == null) if (! visible || peer == null)
...@@ -210,82 +322,132 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -210,82 +322,132 @@ public abstract class Component implements ImageObserver, MenuContainer,
return parent == null ? true : parent.isShowing (); return parent == null ? true : parent.isShowing ();
} }
/**
* Tests whether or not this component is enabled.
*
* @return <code>true</code> if the component is enabled,
* <code>false</code> otherwise.
*/
public boolean isEnabled() public boolean isEnabled()
{ {
return enabled; return enabled;
} }
/**
* Enables or disables this component.
*
* @param enabled <code>true</code> to enable this component,
* <code>false</code> to disable it.
*
* @deprecated Deprecated in favor of <code>setEnabled()</code>.
*/
public void setEnabled(boolean b) public void setEnabled(boolean b)
{ {
this.enabled = b; this.enabled = b;
if (peer != null) if (peer != null)
peer.setEnabled(b); peer.setEnabled(b);
} }
/** @deprecated */ /**
* Enables this component.
*
* @deprecated Deprecated in favor of <code>setEnabled()</code>.
*/
public void enable() public void enable()
{ {
setEnabled(true); setEnabled(true);
} }
/** @deprecated */ /**
* Enables or disables this component.
*
* @param enabled <code>true</code> to enable this component,
* <code>false</code> to disable it.
*
* @deprecated Deprecated in favor of <code>setEnabled()</code>.
*/
public void enable(boolean b) public void enable(boolean b)
{ {
setEnabled(b); setEnabled(b);
} }
/** @deprecated */ /**
* Disables this component.
*
* @deprecated Deprecated in favor of <code>setEnabled()</code>.
*/
public void disable() public void disable()
{ {
setEnabled(false); setEnabled(false);
} }
public boolean isDoubleBuffered() public boolean isDoubleBuffered()
{ {
return false; return false;
} }
/** @since 1.2 */ /** @since 1.2 */
public void enableInputMethods(boolean enable) public void enableInputMethods(boolean enable)
{ {
// FIXME // FIXME
} }
/** @specnote Inspection by subclassing shows that Sun's implementation /**
calls show(boolean) which then calls show() or hide(). It is * Makes this component visible or invisible.
the show() method that is overriden in subclasses like Window. *
We do the same to preserve compatibility for subclasses. */ * @param visible <code>true</code> to make this component visible,
* </code>false</code> 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) 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 <code>setVisible()</code>.
*/
public void show() public void show()
{ {
if (peer != null) setVisible (true);
peer.setVisible(true);
this.visible = true;
} }
/** @deprecated */ /**
* Makes this component visible or invisible.
*
* @param visible <code>true</code> to make this component visible,
* </code>false</code> to make it invisible.
*
* @deprecated Deprecated in favor of <code>setVisible()</code>.
*/
public void show(boolean b) public void show(boolean b)
{ {
if (b) setVisible (b);
show();
else
hide();
} }
/** @deprecated */ /**
* Hides this component so that it is no longer shown on the screen.
*
* @deprecated Deprecated in favor of <code>setVisible()</code>.
*/
public void hide() public void hide()
{ {
if (peer != null) setVisible (false);
peer.setVisible(false);
this.visible = false;
} }
/**
* Returns this component's foreground color.
*
* @return This component's foreground color.
*/
public Color getForeground() public Color getForeground()
{ {
if (foreground != null) if (foreground != null)
...@@ -294,7 +456,12 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -294,7 +456,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
return parent.getForeground(); return parent.getForeground();
return null; return null;
} }
/**
* Sets this component's foreground color to the specified color.
*
* @param foreground_color The new foreground color.
*/
public void setForeground(Color c) public void setForeground(Color c)
{ {
if (peer != null) if (peer != null)
...@@ -302,10 +469,14 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -302,10 +469,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
this.foreground = c; this.foreground = c;
} }
/** @return the background color of the component. null may be /**
returned instead of the actual background color, if this * Returns this component's background color.
method is called before the component is added to the *
component hierarchy. */ * @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() public Color getBackground()
{ {
if (background != null) if (background != null)
...@@ -314,14 +485,24 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -314,14 +485,24 @@ public abstract class Component implements ImageObserver, MenuContainer,
return parent.getBackground(); return parent.getBackground();
return null; return null;
} }
/**
* Sets this component's background color to the specified color.
*
* @param background_color The new background color
*/
public void setBackground(Color c) public void setBackground(Color c)
{ {
if (peer != null) if (peer != null)
peer.setBackground(c); peer.setBackground(c);
this.background = c; this.background = c;
} }
/**
* Returns the font in use for this component.
*
* @return The font for this component.
*/
public Font getFont() public Font getFont()
{ {
if (font != null) if (font != null)
...@@ -330,7 +511,12 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -330,7 +511,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
return parent.getFont(); return parent.getFont();
return null; 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) public void setFont(Font f)
{ {
if (peer != null) if (peer != null)
...@@ -338,6 +524,13 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -338,6 +524,13 @@ public abstract class Component implements ImageObserver, MenuContainer,
this.font = f; 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 public Locale getLocale() throws IllegalComponentStateException
{ {
if (locale != null) if (locale != null)
...@@ -347,16 +540,26 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -347,16 +540,26 @@ public abstract class Component implements ImageObserver, MenuContainer,
("Component has no parent: Can not determine Locale"); ("Component has no parent: Can not determine Locale");
return parent.getLocale(); 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) public void setLocale(Locale l)
{ {
this.locale = l; this.locale = l;
/* new writing/layout direction perhaps, or make more/less /* new writing/layout direction perhaps, or make more/less
room for localized text labels */ room for localized text labels */
invalidate(); invalidate();
} }
/**
* Returns the color model of the device this componet is displayed on.
*
* @return This object's color model.
*/
public ColorModel getColorModel() public ColorModel getColorModel()
{ {
GraphicsConfiguration config = getGraphicsConfiguration(); GraphicsConfiguration config = getGraphicsConfiguration();
...@@ -367,11 +570,23 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -367,11 +570,23 @@ public abstract class Component implements ImageObserver, MenuContainer,
return getToolkit().getColorModel(); 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() public Point getLocation()
{ {
return new Point(x, y); 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() public Point getLocationOnScreen()
{ {
if (! isShowing ()) if (! isShowing ())
...@@ -381,47 +596,93 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -381,47 +596,93 @@ public abstract class Component implements ImageObserver, MenuContainer,
return peer.getLocationOnScreen (); 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
* <code>getLocation()</code>.
*/
public Point location() public Point location()
{ {
return getLocation(); 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) public void setLocation (int x, int y)
{ {
if ((this.x == x) && (this.y == y)) if ((this.x == x) && (this.y == y))
return; return;
invalidate(); invalidate();
this.x = x; this.x = x;
this.y = y; this.y = y;
if (peer != null) if (peer != null)
peer.setBounds(x, y, width, height); 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 <code>setLocation</code>.
*/
public void move(int x, int y) public void move(int x, int y)
{ {
setLocation(x,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) public void setLocation(Point p)
{ {
setLocation(p.x, p.y); setLocation(p.x, p.y);
} }
/**
* Returns the size of this object.
*
* @return The size of this object.
*/
public Dimension getSize() public Dimension getSize()
{ {
return new Dimension(width, height); 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 <code>getSize</code>.
*/
public Dimension size() public Dimension size()
{ {
return getSize(); 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) public void setSize(int width, int height)
{ {
if ((this.width == width) && (this.height == height)) if ((this.width == width) && (this.height == height))
...@@ -434,35 +695,78 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -434,35 +695,78 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (peer != null) if (peer != null)
peer.setBounds(x, y, width, height); 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 <code>setSize</code>.
*/
public void resize(int width, int height) public void resize(int width, int height)
{ {
setSize(width, 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) public void setSize(Dimension d)
{ {
setSize(d.width, d.height); 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 <code>setSize</code>.
*/
public void resize(Dimension d) public void resize(Dimension d)
{ {
setSize(d.width, d.height); 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() public Rectangle getBounds()
{ {
return new Rectangle (x, y, width, height); 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 <code>getBounds()</code>.
*/
public Rectangle bounds() public Rectangle bounds()
{ {
return getBounds(); 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) public void setBounds(int x, int y, int w, int h)
{ {
if (this.x == x if (this.x == x
...@@ -481,13 +785,32 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -481,13 +785,32 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (peer != null) if (peer != null)
peer.setBounds(x, y, w, h); 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
* <code>setBounds(int, int, int, int)</code>.
*/
public void reshape(int x, int y, int width, int height) public void reshape(int x, int y, int width, int height)
{ {
setBounds(x, y, width, 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) public void setBounds(Rectangle r)
{ {
setBounds(r.x, r.y, r.width, r.height); setBounds(r.x, r.y, r.width, r.height);
...@@ -557,7 +880,12 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -557,7 +880,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
{ {
return (peer != null) && (peer instanceof LightweightPeer); return (peer != null) && (peer instanceof LightweightPeer);
} }
/**
* Returns the component's preferred size.
*
* @return The component's preferred size.
*/
public Dimension getPreferredSize() public Dimension getPreferredSize()
{ {
if (peer == null) if (peer == null)
...@@ -566,12 +894,23 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -566,12 +894,23 @@ public abstract class Component implements ImageObserver, MenuContainer,
return peer.getPreferredSize(); return peer.getPreferredSize();
} }
/** @deprecated */ /**
* Returns the component's preferred size.
*
* @return The component's preferred size.
*
* @deprecated Deprecated in favor of <code>getPreferredSize()</code>.
*/
public Dimension preferredSize() public Dimension preferredSize()
{ {
return getPreferredSize(); return getPreferredSize();
} }
/**
* Returns the component's minimum size.
*
* @return The component's minimum size.
*/
public Dimension getMinimumSize() public Dimension getMinimumSize()
{ {
if (peer == null) if (peer == null)
...@@ -580,43 +919,82 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -580,43 +919,82 @@ public abstract class Component implements ImageObserver, MenuContainer,
return peer.getMinimumSize(); return peer.getMinimumSize();
} }
/** @deprecated */ /**
* Returns the component's minimum size.
*
* @return The component's minimum size.
*
* @deprecated Deprecated in favor of <code>getMinimumSize()</code>
*/
public Dimension minimumSize() public Dimension minimumSize()
{ {
return getMinimumSize(); return getMinimumSize();
} }
/**
* Returns the component's maximum size.
*
* @return The component's maximum size.
*/
public Dimension getMaximumSize() public Dimension getMaximumSize()
{ {
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); 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() public float getAlignmentX()
{ {
return CENTER_ALIGNMENT; 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() public float getAlignmentY()
{ {
return CENTER_ALIGNMENT; 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() public void doLayout()
{ {
// nothing to do unless we're a container // 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 <code>doLayout()</code>.
*/
public void layout() public void layout()
{ {
doLayout(); doLayout();
} }
/**
* Called to ensure that the layout for this component is valid.
*/
public void validate() 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() public void invalidate()
{ {
valid = false; valid = false;
...@@ -625,6 +1003,12 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -625,6 +1003,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
parent.invalidate (); parent.invalidate ();
} }
/**
* Returns a graphics object for this component. Returns <code>null</code>
* if this component is not currently displayed on the screen.
*
* @return A graphics object for this component.
*/
public Graphics getGraphics() public Graphics getGraphics()
{ {
if (peer != null) if (peer != null)
...@@ -646,7 +1030,14 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -646,7 +1030,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
} }
return null; 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) public FontMetrics getFontMetrics(Font font)
{ {
if (peer == null) if (peer == null)
...@@ -654,6 +1045,11 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -654,6 +1045,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
return peer.getFontMetrics (font); 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) public void setCursor(Cursor cursor)
{ {
this.cursor = cursor; this.cursor = cursor;
...@@ -661,20 +1057,45 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -661,20 +1057,45 @@ public abstract class Component implements ImageObserver, MenuContainer,
peer.setCursor (cursor); peer.setCursor (cursor);
} }
/**
* Returns the cursor for this component.
*
* @return The cursor for this component.
*/
public Cursor getCursor() public Cursor getCursor()
{ {
return this.cursor; 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) 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 <code>paint()</code> method.
* // FIXME: What are the coords relative to?
*
* @param graphics The graphics context for this update.
*/
public void update(Graphics g) public void update(Graphics g)
{ {
paint(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) public void paintAll(Graphics g)
{ {
if (!visible) if (!visible)
...@@ -684,22 +1105,60 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -684,22 +1105,60 @@ public abstract class Component implements ImageObserver, MenuContainer,
peer.paint(g); peer.paint(g);
paint(g); paint(g);
} }
/**
* Repaint this entire component. The <code>update()</code> method
* on this component will be called as soon as possible.
* // FIXME: What are the coords relative to?
*/
public void repaint() public void repaint()
{ {
repaint(0, 0, 0, getWidth(), getHeight()); repaint(0, 0, 0, getWidth(), getHeight());
} }
/**
* Repaint this entire component. The <code>update()</code> 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) public void repaint(long tm)
{ {
repaint(tm, 0, 0, getWidth(), getHeight()); repaint(tm, 0, 0, getWidth(), getHeight());
} }
/**
* Repaints the specified rectangular region within this component.
* This <code>update</code> 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) public void repaint(int x, int y, int width, int height)
{ {
repaint(0, x, y, width, height); repaint(0, x, y, width, height);
} }
/**
* Repaints the specified rectangular region within this component.
* This <code>update</code> 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) public void repaint(long tm, int x, int y, int width, int height)
{ {
// Handle lightweight repainting by forwarding to native parent // Handle lightweight repainting by forwarding to native parent
...@@ -714,16 +1173,46 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -714,16 +1173,46 @@ public abstract class Component implements ImageObserver, MenuContainer,
peer.repaint(tm, x, y, width, height); 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 <code>paint()</code> method.
*
* @param graphics The graphics context of the print device.
*/
public void print(Graphics g) public void print(Graphics g)
{ {
paint(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 <code>paintAll()</code> method.
*
* @param graphics The graphics context of the print device.
*/
public void printAll(Graphics g) public void printAll(Graphics g)
{ {
paintAll(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 <code>ImageObserver</code>.
* @param x The X coordinate
* @param y The Y coordinate
* @param width The width
* @param height The height
*
* @return <code>true</code> if the image has been fully loaded,
* <code>false</code> otherwise.
*/
public boolean imageUpdate (Image img, int infoflags, int x, int y, public boolean imageUpdate (Image img, int infoflags, int x, int y,
int w, int h) int w, int h)
{ {
...@@ -731,58 +1220,160 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -731,58 +1220,160 @@ public abstract class Component implements ImageObserver, MenuContainer,
return false; 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) public Image createImage(ImageProducer producer)
{ {
// FIXME return peer.createImage(producer);
return null;
} }
/**
* 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) public Image createImage(int width, int height)
{ {
return getGraphicsConfiguration().createCompatibleImage(width, 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 <code>true</code> if the image is already fully prepared
* for rendering, <code>false</code> otherwise.
*/
public boolean prepareImage(Image image, ImageObserver observer) public boolean prepareImage(Image image, ImageObserver observer)
{ {
// FIXME return prepareImage(image, image.getWidth(observer),
return false; 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 <code>true</code> if the image is already fully prepared
* for rendering, <code>false</code> otherwise.
*/
public boolean prepareImage(Image image, int width, int height,
ImageObserver observer)
{ {
// FIXME return peer.prepareImage(image, width, height, observer);
return false;
} }
/**
* Returns the status of the loading of the specified image. The value
* returned will be those flags defined in <code>ImageObserver</code>.
*
* @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) public int checkImage(Image image, ImageObserver observer)
{ {
// FIXME return checkImage(image, image.getWidth(observer),
return 0; 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 <code>ImageObserver</code>.
*
* @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) if (peer != null)
return peer.checkImage (image, width, height, observer); return peer.checkImage (image, width, height, observer);
return getToolkit ().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 <code>true</code> if the point is within this component,
* <code>false</code> otherwise.
*/
public boolean contains (int x, int y) public boolean contains (int x, int y)
{ {
return (x >= 0) && (y >= 0) && (x < width) && (y < height); 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 <code>true</code> if the point is within this component,
* <code>false</code> otherwise.
*
* @deprecated Deprecated in favor of <code>contains(int, int)</code>.
*/
public boolean inside(int x, int y) public boolean inside(int x, int y)
{ {
return contains(x,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 <code>true</code> if the point is within this component,
* <code>false</code> otherwise.
*/
public boolean contains(Point p) public boolean contains(Point p)
{ {
return contains(p.x, p.y); 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 <code>null</code>
* 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 <code>null</code>
* if there is none.
*/
public Component getComponentAt(int x, int y) public Component getComponentAt(int x, int y)
{ {
if (contains(x,y)) if (contains(x,y))
...@@ -790,21 +1381,47 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -790,21 +1381,47 @@ public abstract class Component implements ImageObserver, MenuContainer,
return null; return null;
} }
/** @deprecated */ /**
* Returns the component occupying the position (x,y). This will either
* be this component, an immediate child component, or <code>null</code>
* 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 <code>null</code>
* if there is none.
*
* @deprecated The method is deprecated in favor of
* <code>getComponentAt()</code>.
*/
public Component locate(int x, int y) public Component locate(int x, int y)
{ {
return getComponentAt(x, y); return getComponentAt(x, y);
} }
/**
* Returns the component occupying the specified point This will either
* be this component, an immediate child component, or <code>null</code>
* 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 <code>null</code>
* if there is none.
*/
public Component getComponentAt(Point p) public Component getComponentAt(Point p)
{ {
return getComponentAt(p.x, p.y); return getComponentAt(p.x, p.y);
} }
/** @deprecated */ /**
* AWT 1.0 event dispatcher.
*
* @deprecated Deprecated in favor of <code>dispatchEvent()</code>.
*/
public void deliverEvent(Event e) public void deliverEvent(Event e)
{ {
} }
/** Forward AWT events to processEvent() if: /** Forward AWT events to processEvent() if:
...@@ -812,6 +1429,8 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -812,6 +1429,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
* OR: * OR:
* - There is at least one registered listener for this type of event * - 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 * @specnote This method is final, but we need to be able to
* override it in order to handle other event types in our * override it in order to handle other event types in our
* subclasses. The solution is to define a second, non-final * subclasses. The solution is to define a second, non-final
...@@ -870,31 +1489,55 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -870,31 +1489,55 @@ public abstract class Component implements ImageObserver, MenuContainer,
processEvent(e); processEvent(e);
} }
/** @deprecated */ /**
* AWT 1.0 event dispatcher.
*
* @deprecated Deprecated in favor of <code>dispatchEvent()</code>.
*/
public boolean postEvent(Event e) public boolean postEvent(Event e)
{ {
return false; return false;
} }
/**
* Adds the specified listener to this component.
*
* @param listener The new listener to add.
*/
public synchronized void addComponentListener(ComponentListener l) public synchronized void addComponentListener(ComponentListener l)
{ {
componentListener = AWTEventMulticaster.add(componentListener, l); componentListener = AWTEventMulticaster.add(componentListener, l);
if (componentListener != null) if (componentListener != null)
enableEvents(AWTEvent.COMPONENT_EVENT_MASK); enableEvents(AWTEvent.COMPONENT_EVENT_MASK);
} }
/**
* Removes the specified listener from the component.
*
* @param listener The listener to remove.
*/
public synchronized void removeComponentListener(ComponentListener l) public synchronized void removeComponentListener(ComponentListener l)
{ {
componentListener = AWTEventMulticaster.remove(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) public synchronized void addFocusListener(FocusListener l)
{ {
focusListener = AWTEventMulticaster.add(focusListener, l); focusListener = AWTEventMulticaster.add(focusListener, l);
if (focusListener != null) if (focusListener != null)
enableEvents(AWTEvent.FOCUS_EVENT_MASK); enableEvents(AWTEvent.FOCUS_EVENT_MASK);
} }
/**
* Removes the specified listener from the component.
*
* @param listener The listener to remove.
*/
public synchronized void removeFocusListener(FocusListener l) public synchronized void removeFocusListener(FocusListener l)
{ {
focusListener = AWTEventMulticaster.remove(focusListener, l); focusListener = AWTEventMulticaster.remove(focusListener, l);
...@@ -931,6 +1574,11 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -931,6 +1574,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
AWTEventMulticaster.remove(hierarchyBoundsListener, l); AWTEventMulticaster.remove(hierarchyBoundsListener, l);
} }
/**
* Adds the specified listener to this component.
*
* @param listener The new listener to add.
*/
public synchronized void addKeyListener(KeyListener l) public synchronized void addKeyListener(KeyListener l)
{ {
keyListener = AWTEventMulticaster.add(keyListener, l); keyListener = AWTEventMulticaster.add(keyListener, l);
...@@ -938,11 +1586,21 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -938,11 +1586,21 @@ public abstract class Component implements ImageObserver, MenuContainer,
enableEvents(AWTEvent.KEY_EVENT_MASK); enableEvents(AWTEvent.KEY_EVENT_MASK);
} }
/**
* Removes the specified listener from the component.
*
* @param listener The listener to remove.
*/
public synchronized void removeKeyListener(KeyListener l) public synchronized void removeKeyListener(KeyListener l)
{ {
keyListener = AWTEventMulticaster.remove(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) public synchronized void addMouseListener(MouseListener l)
{ {
mouseListener = AWTEventMulticaster.add(mouseListener, l); mouseListener = AWTEventMulticaster.add(mouseListener, l);
...@@ -950,11 +1608,21 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -950,11 +1608,21 @@ public abstract class Component implements ImageObserver, MenuContainer,
enableEvents(AWTEvent.MOUSE_EVENT_MASK); enableEvents(AWTEvent.MOUSE_EVENT_MASK);
} }
/**
* Removes the specified listener from the component.
*
* @param listener The listener to remove.
*/
public synchronized void removeMouseListener(MouseListener l) public synchronized void removeMouseListener(MouseListener l)
{ {
mouseListener = AWTEventMulticaster.remove(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) public synchronized void addMouseMotionListener(MouseMotionListener l)
{ {
mouseMotionListener = AWTEventMulticaster.add(mouseMotionListener, l); mouseMotionListener = AWTEventMulticaster.add(mouseMotionListener, l);
...@@ -962,6 +1630,11 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -962,6 +1630,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
enableEvents(AWTEvent.MOUSE_EVENT_MASK); enableEvents(AWTEvent.MOUSE_EVENT_MASK);
} }
/**
* Removes the specified listener from the component.
*
* @param listener The listener to remove.
*/
public synchronized void removeMouseMotionListener(MouseMotionListener l) public synchronized void removeMouseMotionListener(MouseMotionListener l)
{ {
mouseMotionListener = AWTEventMulticaster.remove(mouseMotionListener, l); mouseMotionListener = AWTEventMulticaster.remove(mouseMotionListener, l);
...@@ -1043,6 +1716,17 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1043,6 +1716,17 @@ public abstract class Component implements ImageObserver, MenuContainer,
// //
// public InputContext getInputContext() // public InputContext getInputContext()
/**
* Enables the specified events. The events to enable are specified
* by OR-ing together the desired masks from <code>AWTEvent</code>.
* <p>
* 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) protected final void enableEvents(long eventsToEnable)
{ {
eventMask |= eventsToEnable; eventMask |= eventsToEnable;
...@@ -1060,6 +1744,12 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1060,6 +1744,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
peer.setEventMask (eventMask); peer.setEventMask (eventMask);
} }
/**
* Disables the specified events. The events to disable are specified
* by OR-ing together the desired masks from <code>AWTEvent</code>.
*
* @param disable_events The desired events to disable.
*/
protected final void disableEvents(long eventsToDisable) protected final void disableEvents(long eventsToDisable)
{ {
eventMask &= ~eventsToDisable; eventMask &= ~eventsToDisable;
...@@ -1111,7 +1801,6 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1111,7 +1801,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
* +--+ * +--+
* </pre> * </pre>
*/ */
private PaintEvent coalescePaintEvents(PaintEvent queuedEvent, private PaintEvent coalescePaintEvents(PaintEvent queuedEvent,
PaintEvent newEvent) PaintEvent newEvent)
{ {
...@@ -1132,12 +1821,12 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1132,12 +1821,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
return newEvent; return newEvent;
} }
/**
* Processes the specified event. In this class, this method simply
* calls one of the more specific event handlers.
/** Forward event to the appropriate processXXXEvent method based on the *
* event type. * @param event The event to process.
*/ */
protected void processEvent(AWTEvent e) protected void processEvent(AWTEvent e)
{ {
...@@ -1172,7 +1861,14 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1172,7 +1861,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
processHierarchyBoundsEvent((HierarchyEvent) e); 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 <code>ComponentEvent</code> to process.
*/
protected void processComponentEvent(ComponentEvent e) protected void processComponentEvent(ComponentEvent e)
{ {
if (componentListener == null) if (componentListener == null)
...@@ -1196,7 +1892,14 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1196,7 +1892,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
break; 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 <code>FocusEvent</code> to process.
*/
protected void processFocusEvent(FocusEvent e) protected void processFocusEvent(FocusEvent e)
{ {
if (focusListener == null) if (focusListener == null)
...@@ -1211,7 +1914,14 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1211,7 +1914,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
break; 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 <code>KeyEvent</code> to process.
*/
protected void processKeyEvent(KeyEvent e) protected void processKeyEvent(KeyEvent e)
{ {
if (keyListener == null) if (keyListener == null)
...@@ -1229,7 +1939,14 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1229,7 +1939,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
break; 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 <code>MouseEvent</code> to process.
*/
protected void processMouseEvent(MouseEvent e) protected void processMouseEvent(MouseEvent e)
{ {
if (mouseListener == null) if (mouseListener == null)
...@@ -1254,6 +1971,13 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -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 <code>MouseMotionEvent</code> to process.
*/
protected void processMouseMotionEvent(MouseEvent e) protected void processMouseMotionEvent(MouseEvent e)
{ {
if (mouseMotionListener == null) if (mouseMotionListener == null)
...@@ -1268,7 +1992,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1268,7 +1992,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
break; break;
} }
} }
/** @since 1.2 */ /** @since 1.2 */
protected void processInputMethodEvent(InputMethodEvent e) protected void processInputMethodEvent(InputMethodEvent e)
{ {
...@@ -1332,77 +2056,119 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1332,77 +2056,119 @@ public abstract class Component implements ImageObserver, MenuContainer,
throw new IllegalArgumentException("unknown paint event"); throw new IllegalArgumentException("unknown paint event");
} }
} }
/** @deprecated */ /**
* AWT 1.0 event processor.
*
* @deprecated Deprecated in favor of <code>processEvent</code>.
*/
public boolean handleEvent(Event evt) public boolean handleEvent(Event evt)
{ {
return false; return false;
} }
/** @deprecated */ /**
* AWT 1.0 mouse event.
*
* @deprecated Deprecated in favor of <code>processMouseEvent()</code>.
*/
public boolean mouseDown(Event evt, int x, int y) public boolean mouseDown(Event evt, int x, int y)
{ {
return false; return false;
} }
/** @deprecated */ /**
* AWT 1.0 mouse event.
*
* @deprecated Deprecated in favor of <code>processMouseMotionEvent()</code>.
*/
public boolean mouseDrag(Event evt, int x, int y) public boolean mouseDrag(Event evt, int x, int y)
{ {
return false; return false;
} }
/** @deprecated */ /**
* AWT 1.0 mouse event.
*
* @deprecated Deprecated in favor of <code>processMouseEvent()</code>.
*/
public boolean mouseUp(Event evt, int x, int y) public boolean mouseUp(Event evt, int x, int y)
{ {
return false; return false;
} }
/** @deprecated */ /**
* AWT 1.0 mouse event.
*
* @deprecated Deprecated in favor of <code>processMouseMotionEvent()</code>.
*/
public boolean mouseMove(Event evt, int x, int y) public boolean mouseMove(Event evt, int x, int y)
{ {
return false; return false;
} }
/** @deprecated */ /**
* AWT 1.0 mouse event.
*
* @deprecated Deprecated in favor of <code>processMouseEvent()</code>.
*/
public boolean mouseEnter(Event evt, int x, int y) public boolean mouseEnter(Event evt, int x, int y)
{ {
return false; return false;
} }
/** @deprecated */ /**
* AWT 1.0 mouse event.
*
* @deprecated Deprecated in favor of <code>processMouseEvent()</code>.
*/
public boolean mouseExit(Event evt, int x, int y) public boolean mouseExit(Event evt, int x, int y)
{ {
return false; return false;
} }
/** @deprecated */ /**
* AWT 1.0 key press event.
*
* @deprecated Deprecated in favor of <code>processKeyEvent</code>.
*/
public boolean keyDown(Event evt, int key) public boolean keyDown(Event evt, int key)
{ {
return false; return false;
} }
/** @deprecated */ /**
* AWT 1.0 key press event.
*
* @deprecated Deprecated in favor of <code>processKeyEvent</code>.
*/
public boolean keyUp(Event evt, int key) public boolean keyUp(Event evt, int key)
{ {
return false; return false;
} }
/** @deprecated */ /**
* AWT 1.0 action event processor.
*
* @deprecated Deprecated in favor of the <code>ActionListener</code>
* interface.
*/
public boolean action(Event evt, Object what) public boolean action(Event evt, Object what)
{ {
return false; 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() public void addNotify()
{ {
if (peer == null) if (peer == null)
peer = getToolkit().createComponent(this); 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 /* Now that all the children has gotten their peers, we should
have the event mask needed for this component and its have the event mask needed for this component and its
lightweight subcomponents. */ lightweight subcomponents. */
...@@ -1415,11 +2181,12 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1415,11 +2181,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
etc. */ etc. */
} }
void addNotifyContainerChildren() /**
{ * Called to inform this component is has been removed from its
// nothing to do unless we're a container * 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() public void removeNotify()
{ {
if (peer != null) if (peer != null)
...@@ -1439,11 +2206,24 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1439,11 +2206,24 @@ public abstract class Component implements ImageObserver, MenuContainer,
return false; 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 <code>true</code> if the component is traversed via the TAB
* key, <code>false</code> otherwise.
*/
public boolean isFocusTraversable() public boolean isFocusTraversable()
{ {
return enabled && visible && (peer == null || peer.isFocusTraversable ()); return enabled && visible && (peer == null || peer.isFocusTraversable ());
} }
/**
* Requests that this component be given focus. The <code>gotFocus()</code>
* method on this event will be called when and if this request was
* successful.
*/
public void requestFocus() public void requestFocus()
{ {
// If there's no peer then this component can't get the focus. We // 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, ...@@ -1461,6 +2241,9 @@ public abstract class Component implements ImageObserver, MenuContainer,
return null; return null;
} }
/**
* Transfers focus to the next component in the focus traversal order.
*/
public void transferFocus() public void transferFocus()
{ {
Component next; Component next;
...@@ -1472,7 +2255,11 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1472,7 +2255,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
next.requestFocus (); next.requestFocus ();
} }
/** @deprecated */ /**
* AWT 1.0 focus event processor.
*
* @deprecated Deprecated in favor of <code>transferFocus()</code>.
*/
public void nextFocus() public void nextFocus()
{ {
transferFocus(); transferFocus();
...@@ -1484,6 +2271,11 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1484,6 +2271,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
return hasFocus; return hasFocus;
} }
/**
* Adds the specified popup menu to this component.
*
* @param menu The popup menu to be added.
*/
public synchronized void add(PopupMenu popup) public synchronized void add(PopupMenu popup)
{ {
if (popups == null) if (popups == null)
...@@ -1491,11 +2283,21 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1491,11 +2283,21 @@ public abstract class Component implements ImageObserver, MenuContainer,
popups.addElement(popup); popups.addElement(popup);
} }
/**
* Removes the specified popup menu from this component.
*
* @param menu The popup menu to remove.
*/
public synchronized void remove(MenuComponent popup) public synchronized void remove(MenuComponent popup)
{ {
popups.removeElement(popup); popups.removeElement(popup);
} }
/**
* Returns a debugging string representing this component.
*
* @return A string representing this component.
*/
protected String paramString() protected String paramString()
{ {
StringBuffer param = new StringBuffer(); StringBuffer param = new StringBuffer();
...@@ -1527,21 +2329,41 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1527,21 +2329,41 @@ public abstract class Component implements ImageObserver, MenuContainer,
return param.toString(); return param.toString();
} }
/**
* Returns a string representation of this component.
*
* @return A string representation of this component
*/
public String toString() public String toString()
{ {
return this.getClass().getName() + "[" + paramString() + "]"; return this.getClass().getName() + "[" + paramString() + "]";
} }
/**
* Prints a listing of this component to the standard output.
*/
public void list () public void list ()
{ {
list (System.out, 0); list (System.out, 0);
} }
/**
* Prints a listing of this component to the specified print stream.
*
* @param stream The <code>PrintStream</code> to print to.
*/
public void list (PrintStream out) public void list (PrintStream out)
{ {
list (out, 0); list (out, 0);
} }
/**
* Prints a listing of this component to the specified print stream,
* starting at the specified indentation point.
*
* @param stream The <code>PrintStream</code> to print to.
* @param indent The indentation point.
*/
public void list (PrintStream out, int indent) public void list (PrintStream out, int indent)
{ {
for (int i = 0; i < indent; ++i) for (int i = 0; i < indent; ++i)
...@@ -1549,11 +2371,23 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1549,11 +2371,23 @@ public abstract class Component implements ImageObserver, MenuContainer,
out.println (toString ()); out.println (toString ());
} }
/**
* Prints a listing of this component to the specified print writer.
*
* @param writer The <code>PrintWrinter</code> to print to.
*/
public void list (PrintWriter out) public void list (PrintWriter out)
{ {
list (out, 0); list (out, 0);
} }
/**
* Prints a listing of this component to the specified print writer,
* starting at the specified indentation point.
*
* @param writer The <code>PrintWriter</code> to print to.
* @param indent The indentation point.
*/
public void list (PrintWriter out, int indent) public void list (PrintWriter out, int indent)
{ {
for (int i = 0; i < indent; ++i) for (int i = 0; i < indent; ++i)
...@@ -1612,4 +2446,29 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1612,4 +2446,29 @@ public abstract class Component implements ImageObserver, MenuContainer,
return accessibleContext; return accessibleContext;
} }
*/ */
/**
* AWT 1.0 focus event processor.
*
* @deprecated Deprecated in favor of <code>processFocusEvent</code>.
public boolean
gotFocus(Event event, Object what)
{
return(true);
}
*/
/**
* AWT 1.0 focus event processor.
*
* @deprecated Deprecated in favor of <code>processFocusEvent</code>.
public boolean
lostFocus(Event event, Object what)
{
return(true);
}
*/
} }
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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 <bryce@albatross.co.nz>
*/
/* Status: Incomplete. Needs a Locale lookup table. */ /* Status: Incomplete. Needs a Locale lookup table. */
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBJAVA_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt;
...@@ -31,21 +48,46 @@ public class Container extends Component ...@@ -31,21 +48,46 @@ public class Container extends Component
/* Anything else is non-serializable, and should be declared "transient". */ /* Anything else is non-serializable, and should be declared "transient". */
transient ContainerListener containerListener; transient ContainerListener containerListener;
/**
* Default constructor for subclasses.
*/
public Container() public Container()
{ {
} }
/**
* Returns the number of components in this container.
*
* @return The number of components in this container.
*/
public int getComponentCount() public int getComponentCount()
{ {
return ncomponents; 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
* <code>getComponentCount()</code>.
*/
public int countComponents() public int countComponents()
{ {
return ncomponents; 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) public Component getComponent (int n)
{ {
if (n < 0 || n >= ncomponents) if (n < 0 || n >= ncomponents)
...@@ -53,6 +95,11 @@ public class Container extends Component ...@@ -53,6 +95,11 @@ public class Container extends Component
return component[n]; return component[n];
} }
/**
* Returns an array of the components in this container.
*
* @return The components in this container.
*/
public Component[] getComponents() public Component[] getComponents()
{ {
Component[] result = new Component[ncomponents]; Component[] result = new Component[ncomponents];
...@@ -61,51 +108,130 @@ public class Container extends Component ...@@ -61,51 +108,130 @@ public class Container extends Component
return result; 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() public Insets getInsets()
{ {
if (peer == null) if (peer == null)
return new Insets(0, 0, 0, 0); return new Insets(0, 0, 0, 0);
return ((ContainerPeer) peer).getInsets(); 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
* <code>getInsets()</code>.
*/
public Insets insets() public Insets insets()
{ {
return getInsets(); 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) public Component add (Component comp)
{ {
addImpl (comp, null, -1); addImpl (comp, null, -1);
return comp; return comp;
} }
/**
* Adds the specified component to the container at the end of the
* component list. This method should not be used. Instead, use
* <code>add(Component, Object</code>.
*
* @param name FIXME
* @param component The component to be added.
*
* @return The same component that was added.
*/
public Component add (String name, Component comp) public Component add (String name, Component comp)
{ {
addImpl (comp, name, -1); addImpl (comp, name, -1);
return comp; 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) public Component add (Component comp, int index)
{ {
addImpl (comp, null, index); addImpl (comp, null, index);
return comp; 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) public void add (Component comp, Object constraints)
{ {
addImpl (comp, constraints, -1); 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) public void add (Component comp, Object constraints, int index)
{ {
addImpl (comp, constraints, index); addImpl (comp, constraints, index);
} }
/**
* This method is called by all the <code>add()</code> 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
* <code>null</code> 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) protected void addImpl (Component comp, Object constraints, int index)
{ {
if (index > ncomponents if (index > ncomponents
|| (index < 0 && index != -1)
|| comp instanceof Window || comp instanceof Window
|| (comp instanceof Container || (comp instanceof Container
&& ((Container) comp).isAncestorOf (this))) && ((Container) comp).isAncestorOf (this)))
...@@ -151,21 +277,29 @@ public class Container extends Component ...@@ -151,21 +277,29 @@ public class Container extends Component
// Notify the layout manager. // Notify the layout manager.
if (layoutMgr != null) if (layoutMgr != null)
{ {
if (constraints != null && layoutMgr instanceof LayoutManager2) if (layoutMgr instanceof LayoutManager2)
{ {
LayoutManager2 lm2 = (LayoutManager2) layoutMgr; LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
lm2.addLayoutComponent (comp, constraints); lm2.addLayoutComponent (comp, constraints);
} }
else else if (constraints instanceof String)
layoutMgr.addLayoutComponent ((String) constraints, comp); layoutMgr.addLayoutComponent ((String) constraints, comp);
else
layoutMgr.addLayoutComponent (null, comp);
} }
// Post event to notify of adding the container.
ContainerEvent ce = new ContainerEvent (this, ContainerEvent ce = new ContainerEvent (this,
ContainerEvent.COMPONENT_ADDED, ContainerEvent.COMPONENT_ADDED,
comp); 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) public void remove (int index)
{ {
Component r = component[index]; Component r = component[index];
...@@ -181,12 +315,18 @@ public class Container extends Component ...@@ -181,12 +315,18 @@ public class Container extends Component
if (layoutMgr != null) if (layoutMgr != null)
layoutMgr.removeLayoutComponent (r); layoutMgr.removeLayoutComponent (r);
// Post event to notify of adding the container.
ContainerEvent ce = new ContainerEvent (this, ContainerEvent ce = new ContainerEvent (this,
ContainerEvent.COMPONENT_REMOVED, ContainerEvent.COMPONENT_REMOVED,
r); 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) public void remove (Component comp)
{ {
for (int i = 0; i < ncomponents; ++i) for (int i = 0; i < ncomponents; ++i)
...@@ -199,51 +339,89 @@ public class Container extends Component ...@@ -199,51 +339,89 @@ public class Container extends Component
} }
} }
/**
* Removes all components from this container.
*/
public void removeAll() public void removeAll()
{ {
while (ncomponents > 0) while (ncomponents > 0)
remove (0); remove (0);
} }
/**
* Returns the current layout manager for this container.
*
* @return The layout manager for this container.
*/
public LayoutManager getLayout() public LayoutManager getLayout()
{ {
return layoutMgr; 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) public void setLayout(LayoutManager mgr)
{ {
layoutMgr = mgr; layoutMgr = mgr;
invalidate (); invalidate ();
} }
/**
* Layout the components in this container.
*/
public void doLayout() public void doLayout()
{ {
if (layoutMgr != null) if (layoutMgr != null)
layoutMgr.layoutContainer (this); layoutMgr.layoutContainer (this);
} }
/** @deprecated Use doLayout() instead. */ /**
* Layout the components in this container.
*
* @deprecated This method is deprecated in favor of
* <code>doLayout()</code>.
*/
public void layout() public void layout()
{ {
doLayout(); doLayout();
} }
/**
* Invalidates this container to indicate that it (and all parent
* containers) need to be laid out.
*/
public void invalidate() public void invalidate()
{ {
super.invalidate (); super.invalidate ();
} }
/**
* Re-lays out the components in this container.
*/
public void validate() 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() protected void validateTree()
{ {
if (valid) return; if (valid)
return;
ContainerPeer cPeer = null; ContainerPeer cPeer = null;
if ((peer != null) && !(peer instanceof LightweightPeer)) if ((peer != null) && !(peer instanceof LightweightPeer))
...@@ -256,16 +434,19 @@ public class Container extends Component ...@@ -256,16 +434,19 @@ public class Container extends Component
for (int i = 0; i < ncomponents; ++i) for (int i = 0; i < ncomponents; ++i)
{ {
Component comp = component[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 /* children will call invalidate() when they are layed out. It
is therefore imporant that valid is not set to true is therefore imporant that valid is not set to true
before after the children has been layed out. */ before after the children has been layed out. */
...@@ -281,6 +462,11 @@ public class Container extends Component ...@@ -281,6 +462,11 @@ public class Container extends Component
// FIXME, should invalidate all children with font == null // 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() public Dimension getPreferredSize()
{ {
if (layoutMgr != null) if (layoutMgr != null)
...@@ -288,13 +474,25 @@ public class Container extends Component ...@@ -288,13 +474,25 @@ public class Container extends Component
else else
return super.getPreferredSize (); 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
* <code>getPreferredSize()</code>.
*/
public Dimension preferredSize() public Dimension preferredSize()
{ {
return getPreferredSize(); return getPreferredSize();
} }
/**
* Returns the minimum size of this container.
*
* @return The minimum size of this container.
*/
public Dimension getMinimumSize() public Dimension getMinimumSize()
{ {
if (layoutMgr != null) if (layoutMgr != null)
...@@ -302,13 +500,25 @@ public class Container extends Component ...@@ -302,13 +500,25 @@ public class Container extends Component
else else
return super.getMinimumSize (); 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
* <code>getMinimumSize()</code>.
*/
public Dimension minimumSize() public Dimension minimumSize()
{ {
return getMinimumSize(); return getMinimumSize();
} }
/**
* Returns the maximum size of this container.
*
* @return The maximum size of this container.
*/
public Dimension getMaximumSize() public Dimension getMaximumSize()
{ {
if (layoutMgr != null && layoutMgr instanceof LayoutManager2) if (layoutMgr != null && layoutMgr instanceof LayoutManager2)
...@@ -320,6 +530,13 @@ public class Container extends Component ...@@ -320,6 +530,13 @@ public class Container extends Component
return super.getMaximumSize (); 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() public float getAlignmentX()
{ {
if (layoutMgr instanceof LayoutManager2) if (layoutMgr instanceof LayoutManager2)
...@@ -328,9 +545,16 @@ public class Container extends Component ...@@ -328,9 +545,16 @@ public class Container extends Component
return lm2.getLayoutAlignmentX (this); return lm2.getLayoutAlignmentX (this);
} }
else 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() public float getAlignmentY()
{ {
if (layoutMgr instanceof LayoutManager2) if (layoutMgr instanceof LayoutManager2)
...@@ -339,9 +563,18 @@ public class Container extends Component ...@@ -339,9 +563,18 @@ public class Container extends Component
return lm2.getLayoutAlignmentY (this); return lm2.getLayoutAlignmentY (this);
} }
else 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) public void paint(Graphics g)
{ {
if (!isShowing()) if (!isShowing())
...@@ -365,7 +598,7 @@ public class Container extends Component ...@@ -365,7 +598,7 @@ public class Container extends Component
* be visited. * be visited.
*/ */
private void visitChildren(Graphics gfx, GfxVisitor visitor, private void visitChildren(Graphics gfx, GfxVisitor visitor,
boolean lightweightOnly) boolean lightweightOnly)
{ {
// FIXME: do locking // FIXME: do locking
...@@ -408,29 +641,57 @@ public class Container extends Component ...@@ -408,29 +641,57 @@ public class Container extends Component
visitor.visit(comp, gfx2); 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) public void update(Graphics g)
{ {
super.update(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) public void print(Graphics g)
{ {
super.print(g); super.print(g);
visitChildren(g, GfxPrintVisitor.INSTANCE, true); 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) public void paintComponents(Graphics g)
{ {
super.paint(g); super.paint(g);
visitChildren(g, GfxPaintAllVisitor.INSTANCE, true); 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) public void printComponents(Graphics g)
{ {
super.paint(g); super.paint(g);
visitChildren(g, GfxPrintAllVisitor.INSTANCE, true); visitChildren(g, GfxPrintAllVisitor.INSTANCE, true);
} }
void dispatchEventImpl(AWTEvent e) void dispatchEventImpl(AWTEvent e)
{ {
if ((e.id <= ContainerEvent.CONTAINER_LAST if ((e.id <= ContainerEvent.CONTAINER_LAST
...@@ -438,15 +699,28 @@ public class Container extends Component ...@@ -438,15 +699,28 @@ public class Container extends Component
&& (containerListener != null && (containerListener != null
|| (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0)) || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0))
processEvent(e); 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); 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); containerListener = AWTEventMulticaster.remove(containerListener, l);
} }
...@@ -458,35 +732,70 @@ public class Container extends Component ...@@ -458,35 +732,70 @@ public class Container extends Component
return getListenersImpl(listenerType, containerListener); return getListenersImpl(listenerType, containerListener);
else return super.getListeners(listenerType); else return super.getListeners(listenerType);
} }
/**
* Processes the specified event. This method calls
* <code>processContainerEvent()</code> if this method is a
* <code>ContainerEvent</code>, otherwise it calls the superclass
* method.
*
* @param event The event to be processed.
*/
protected void processEvent(AWTEvent e) protected void processEvent(AWTEvent e)
{ {
if (e instanceof ContainerEvent) if (e instanceof ContainerEvent)
processContainerEvent((ContainerEvent) e); processContainerEvent((ContainerEvent) e);
else super.processEvent(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) protected void processContainerEvent(ContainerEvent e)
{ {
if (containerListener == null) if (containerListener == null)
return; return;
switch (e.id) switch (e.id)
{ {
case ContainerEvent.COMPONENT_ADDED: case ContainerEvent.COMPONENT_ADDED:
containerListener.componentAdded(e); containerListener.componentAdded(e);
break; break;
case ContainerEvent.COMPONENT_REMOVED: case ContainerEvent.COMPONENT_REMOVED:
containerListener.componentRemoved(e); containerListener.componentRemoved(e);
break; break;
} }
} }
/** @deprecated */ /**
* AWT 1.0 event processor.
*
* @param event The event that occurred.
*
* @deprecated This method is deprecated in favor of
* <code>dispatchEvent()</code>.
*/
public void deliverEvent(Event e) 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 <code>null</code> 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
* <code>null</code> if there is no such point.
*/
public Component getComponentAt (int x, int y) public Component getComponentAt (int x, int y)
{ {
if (! contains (x, y)) if (! contains (x, y))
...@@ -505,12 +814,40 @@ public class Container extends Component ...@@ -505,12 +814,40 @@ public class Container extends Component
return this; 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 <code>null</code> is returned.
*
* @param point The point to return the component at.
*
* @return The component containing the specified point, or <code>null</code>
* if there is no such point.
*
* @deprecated This method is deprecated in favor of
* <code>getComponentAt(int, int)</code>.
*/
public Component locate(int x, int y) public Component locate(int x, int y)
{ {
return getComponentAt(x, 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 <code>null</code> is returned.
*
* @param point The point to return the component at.
*
* @return The component containing the specified point, or <code>null</code>
* if there is no such point.
*/
public Component getComponentAt(Point p) public Component getComponentAt(Point p)
{ {
return getComponentAt(p.x, p.y); return getComponentAt(p.x, p.y);
...@@ -550,12 +887,21 @@ public class Container extends Component ...@@ -550,12 +887,21 @@ public class Container extends Component
return findComponentAt(p.x, p.y); 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 () public void addNotify ()
{ {
super.addNotify(); if (peer == null)
{
addNotifyContainerChildren ();
super.addNotify();
}
} }
void addNotifyContainerChildren() private void addNotifyContainerChildren()
{ {
for (int i = ncomponents; --i >= 0; ) for (int i = ncomponents; --i >= 0; )
{ {
...@@ -565,6 +911,11 @@ public class Container extends Component ...@@ -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() public void removeNotify()
{ {
for (int i = 0; i < ncomponents; ++i) for (int i = 0; i < ncomponents; ++i)
...@@ -572,6 +923,15 @@ public class Container extends Component ...@@ -572,6 +923,15 @@ public class Container extends Component
super.removeNotify(); super.removeNotify();
} }
/**
* Tests whether or not the specified component is contained within
* this components subtree.
*
* @param component The component to test.
*
* @return <code>true</code> if this container is an ancestor of the
* specified component, <code>false</code>.
*/
public boolean isAncestorOf (Component comp) public boolean isAncestorOf (Component comp)
{ {
for (;;) for (;;)
...@@ -584,6 +944,12 @@ public class Container extends Component ...@@ -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() protected String paramString()
{ {
String param = super.paramString(); String param = super.paramString();
...@@ -592,7 +958,14 @@ public class Container extends Component ...@@ -592,7 +958,14 @@ public class Container extends Component
return param; return param;
} }
/**
* Writes a listing of this container to the specified stream starting
* at the specified indentation point.
*
* @param stream The <code>PrintStream</code> to write to.
* @param indent The indentation point.
*/
public void list (PrintStream out, int indent) public void list (PrintStream out, int indent)
{ {
super.list (out, indent); super.list (out, indent);
...@@ -600,6 +973,13 @@ public class Container extends Component ...@@ -600,6 +973,13 @@ public class Container extends Component
component[i].list (out, indent + 2); 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 <code>PrintWriter</code> to write to.
* @param indent The indentation point.
*/
public void list(PrintWriter out, int indent) public void list(PrintWriter out, int indent)
{ {
super.list (out, indent); super.list (out, indent);
......
/* 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; package java.awt;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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 */ /** @author Bryce McKinlay */
......
/* 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; package java.awt;
...@@ -18,13 +36,19 @@ import java.lang.reflect.InvocationTargetException; ...@@ -18,13 +36,19 @@ import java.lang.reflect.InvocationTargetException;
* Status: Believed complete, but untested. Check FIXME's. * Status: Believed complete, but untested. Check FIXME's.
*/ */
/** @author Bryce McKinlay */ /**
* This class manages a queue of <code>AWTEvent</code> 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 public class EventQueue
{ {
private static final int INITIAL_QUEUE_DEPTH = 8; private static final int INITIAL_QUEUE_DEPTH = 8;
private AWTEvent[] queue = new AWTEvent[INITIAL_QUEUE_DEPTH]; 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_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 private int next_out = 0; // Index of next event to be removed from queue
...@@ -33,40 +57,68 @@ public class EventQueue ...@@ -33,40 +57,68 @@ public class EventQueue
private EventDispatchThread dispatchThread = new EventDispatchThread(this); private EventDispatchThread dispatchThread = new EventDispatchThread(this);
/**
* Initializes a new instance of <code>EventQueue</code>.
*/
public 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() public synchronized AWTEvent getNextEvent()
throws InterruptedException throws InterruptedException
{ {
if (next != null) if (next != null)
return next.getNextEvent(); return next.getNextEvent();
while (next_in == next_out) while (next_in == next_out)
wait(); wait();
AWTEvent res = queue[next_out]; AWTEvent res = queue[next_out];
if (++next_out == queue.length) if (++next_out == queue.length)
next_out = 0; next_out = 0;
return res; 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. * queue.
*/ */
public synchronized AWTEvent peekEvent() public synchronized AWTEvent peekEvent()
{ {
if (next != null) if (next != null)
return next.peekEvent(); return next.peekEvent();
if (next_in != next_out) if (next_in != next_out)
return queue[next_out]; return queue[next_out];
else return null; 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. * on the queue.
*/ */
public synchronized AWTEvent peekEvent(int id) public synchronized AWTEvent peekEvent(int id)
...@@ -83,7 +135,12 @@ public class EventQueue ...@@ -83,7 +135,12 @@ public class EventQueue
} }
return null; return null;
} }
/**
* Posts a new event to the queue.
*
* @param event The event to post to the queue.
*/
public synchronized void postEvent(AWTEvent evt) public synchronized void postEvent(AWTEvent evt)
{ {
if (next != null) if (next != null)
...@@ -92,7 +149,7 @@ public class EventQueue ...@@ -92,7 +149,7 @@ public class EventQueue
return; return;
} }
// FIXME: Security checks? // FIXME: Security checks?
/* Check for any events already on the queue with the same source /* Check for any events already on the queue with the same source
and ID. */ and ID. */
int i = next_out; int i = next_out;
...@@ -123,24 +180,24 @@ public class EventQueue ...@@ -123,24 +180,24 @@ public class EventQueue
queue[next_in] = evt; queue[next_in] = evt;
if (++next_in == queue.length) if (++next_in == queue.length)
next_in = 0; next_in = 0;
if (next_in == next_out) if (next_in == next_out)
{ {
/* Queue is full. Extend it. */ /* Queue is full. Extend it. */
AWTEvent[] oldQueue = queue; AWTEvent[] oldQueue = queue;
queue = new AWTEvent[queue.length * 2]; queue = new AWTEvent[queue.length * 2];
int len = oldQueue.length - next_out; int len = oldQueue.length - next_out;
System.arraycopy(oldQueue, next_out, queue, 0, len); System.arraycopy(oldQueue, next_out, queue, 0, len);
if (next_out != 0) if (next_out != 0)
System.arraycopy(oldQueue, 0, queue, len, next_out); System.arraycopy(oldQueue, 0, queue, len, next_out);
next_out = 0; next_out = 0;
next_in = oldQueue.length; next_in = oldQueue.length;
} }
notify(); notify();
} }
/** @since JDK1.2 */ /** @since JDK1.2 */
public static void invokeAndWait(Runnable runnable) public static void invokeAndWait(Runnable runnable)
throws InterruptedException, InvocationTargetException throws InterruptedException, InvocationTargetException
...@@ -149,7 +206,7 @@ public class EventQueue ...@@ -149,7 +206,7 @@ public class EventQueue
Thread current = Thread.currentThread(); Thread current = Thread.currentThread();
if (current == eq.dispatchThread) if (current == eq.dispatchThread)
throw new Error("Can't call invokeAndWait from event dispatch thread"); throw new Error("Can't call invokeAndWait from event dispatch thread");
InvocationEvent ie = InvocationEvent ie =
new InvocationEvent(eq, runnable, current, true); new InvocationEvent(eq, runnable, current, true);
...@@ -160,11 +217,11 @@ public class EventQueue ...@@ -160,11 +217,11 @@ public class EventQueue
} }
Exception exception; Exception exception;
if ((exception = ie.getException()) != null) if ((exception = ie.getException()) != null)
throw new InvocationTargetException(exception); throw new InvocationTargetException(exception);
} }
/** @since JDK1.2 */ /** @since JDK1.2 */
public static void invokeLater(Runnable runnable) public static void invokeLater(Runnable runnable)
{ {
...@@ -175,13 +232,13 @@ public class EventQueue ...@@ -175,13 +232,13 @@ public class EventQueue
eq.postEvent(ie); eq.postEvent(ie);
} }
public static boolean isDispatchThread() public static boolean isDispatchThread()
{ {
EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue(); EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
return (Thread.currentThread() == eq.dispatchThread); return (Thread.currentThread() == eq.dispatchThread);
} }
/** Allows a custom EventQueue implementation to replace this one. /** Allows a custom EventQueue implementation to replace this one.
* All pending events are transferred to the new queue. Calls to postEvent, * All pending events are transferred to the new queue. Calls to postEvent,
* getNextEvent, and peekEvent are forwarded to the pushed queue until it * getNextEvent, and peekEvent are forwarded to the pushed queue until it
...@@ -201,21 +258,21 @@ public class EventQueue ...@@ -201,21 +258,21 @@ public class EventQueue
next = newEventQueue; next = newEventQueue;
newEventQueue.prev = this; newEventQueue.prev = this;
} }
/** Transfer any pending events from this queue back to the parent queue that /** Transfer any pending events from this queue back to the parent queue that
* was previously push()ed. Event dispatch from this queue is suspended. */ * was previously push()ed. Event dispatch from this queue is suspended. */
protected void pop() throws EmptyStackException protected void pop() throws EmptyStackException
{ {
if (prev == null) if (prev == null)
throw new EmptyStackException(); throw new EmptyStackException();
// Don't synchronize both this and prev at the same time, or deadlock could // Don't synchronize both this and prev at the same time, or deadlock could
// occur. // occur.
synchronized (prev) synchronized (prev)
{ {
prev.next = null; prev.next = null;
} }
synchronized (this) synchronized (this)
{ {
int i = next_out; int i = next_out;
...@@ -228,7 +285,7 @@ public class EventQueue ...@@ -228,7 +285,7 @@ public class EventQueue
} }
} }
} }
protected void dispatchEvent(AWTEvent evt) protected void dispatchEvent(AWTEvent evt)
{ {
if (evt instanceof ActiveEvent) if (evt instanceof ActiveEvent)
......
// FlowLayout.java - Grid-based layout engine // 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; package java.awt;
...@@ -17,6 +35,9 @@ import java.io.Serializable; ...@@ -17,6 +35,9 @@ import java.io.Serializable;
* without horizontal clipping, a new row is started. This class * without horizontal clipping, a new row is started. This class
* supports horizontal and vertical gaps. These are used for spacing * supports horizontal and vertical gaps. These are used for spacing
* between components. * between components.
*
* @author Tom Tromey <tromey@redhat.com>
* @author Aaron M. Renn (arenn@urbanophile.com)
*/ */
public class FlowLayout implements LayoutManager, Serializable public class FlowLayout implements LayoutManager, Serializable
{ {
...@@ -34,6 +55,9 @@ public class FlowLayout implements LayoutManager, Serializable ...@@ -34,6 +55,9 @@ public class FlowLayout implements LayoutManager, Serializable
* orientation. */ * orientation. */
public static final int TRAILING = 4; public static final int TRAILING = 4;
// Serialization constant
private static final long serialVersionUID = -7262534875583282631L;
/** Add a new component to the layout. This particular implementation /** Add a new component to the layout. This particular implementation
* does nothing. * does nothing.
*/ */
...@@ -42,42 +66,60 @@ public class FlowLayout implements LayoutManager, Serializable ...@@ -42,42 +66,60 @@ public class FlowLayout implements LayoutManager, Serializable
// Nothing. // Nothing.
} }
/** Return the alignment. */ /**
* Returns the current justification value for this object.
*
* @return The current justification value for this object.
*/
public int getAlignment () public int getAlignment ()
{ {
return align; return align;
} }
/** Return the horizontal gap. */ /**
* Returns the horizontal gap between components.
*
* @return The horizontal gap between components.
*/
public int getHgap () public int getHgap ()
{ {
return hgap; 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 () public int getVgap ()
{ {
return vgap; return vgap;
} }
/** Create a new FlowLayout with center alignment. /**
* Both gaps are set to 5. * Initializes a new instance of <code>FlowLayout</code> with a center
* justification and a default horizontal and vertical gap of 5.
*/ */
public FlowLayout () public FlowLayout ()
{ {
this (CENTER, 5, 5); this (CENTER, 5, 5);
} }
/** Create a new FlowLayout with the alignment. /**
* columns. Both gaps are set to 5. * Initializes a new instance of <code>FlowLayout</code> with the specified
* @param align Alignment * 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) public FlowLayout (int align)
{ {
this (align, 5, 5); this (align, 5, 5);
} }
/** Create a new FlowLayout with the specified alignment and gaps. /**
* Initializes a new instance of <code>FlowLayout</code> with the specified
* justification and gap values
* @param align Alignment * @param align Alignment
* @param hgap The horizontal gap * @param hgap The horizontal gap
* @param vgap The vertical gap * @param vgap The vertical gap
...@@ -118,13 +160,12 @@ public class FlowLayout implements LayoutManager, Serializable ...@@ -118,13 +160,12 @@ public class FlowLayout implements LayoutManager, Serializable
boolean found_one = false; boolean found_one = false;
for (j = i; j < num && ! found_one; ++j) for (j = i; j < num && ! found_one; ++j)
{ {
// FIXME: this is very inefficient.
Dimension c = comps[i].getPreferredSize ();
// Skip invisible items. // Skip invisible items.
if (! comps[i].visible) if (! comps[i].visible)
continue; continue;
Dimension c = comps[i].getPreferredSize ();
int next_w = new_w + hgap + c.width; int next_w = new_w + hgap + c.width;
if (next_w <= d.width || ! found_one) if (next_w <= d.width || ! found_one)
{ {
...@@ -157,10 +198,9 @@ public class FlowLayout implements LayoutManager, Serializable ...@@ -157,10 +198,9 @@ public class FlowLayout implements LayoutManager, Serializable
for (int k = i; i < j; ++k) for (int k = i; i < j; ++k)
{ {
// FIXME: this is very inefficient.
Dimension c = comps[i].getPreferredSize ();
if (comps[i].visible) if (comps[i].visible)
{ {
Dimension c = comps[i].getPreferredSize ();
comps[i].setLocation (x, y); comps[i].setLocation (x, y);
x += c.width + vgap; x += c.width + vgap;
} }
...@@ -172,16 +212,22 @@ public class FlowLayout implements LayoutManager, Serializable ...@@ -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 * @param cont The parent container
* @return The minimum layout size.
*/ */
public Dimension minimumLayoutSize (Container cont) public Dimension minimumLayoutSize (Container cont)
{ {
return getSize (cont, true); 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 * @param cont The parent container
* @return The preferred layout size.
*/ */
public Dimension preferredLayoutSize (Container cont) public Dimension preferredLayoutSize (Container cont)
{ {
...@@ -197,19 +243,24 @@ public class FlowLayout implements LayoutManager, Serializable ...@@ -197,19 +243,24 @@ public class FlowLayout implements LayoutManager, Serializable
// Nothing. // 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) public void setAlignment (int align)
{ {
if (align != LEFT && align != RIGHT && align != CENTER if (align != LEFT && align != RIGHT && align != CENTER
&& align != LEADING && align != TRAILING) && align != LEADING && align != TRAILING)
throw new IllegalArgumentException ("invalid align: " + align); throw new IllegalArgumentException ("invalid alignment: " + align);
this.align = 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) public void setHgap (int hgap)
{ {
...@@ -218,8 +269,10 @@ public class FlowLayout implements LayoutManager, Serializable ...@@ -218,8 +269,10 @@ public class FlowLayout implements LayoutManager, Serializable
this.hgap = hgap; 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) public void setVgap (int vgap)
{ {
...@@ -228,7 +281,9 @@ public class FlowLayout implements LayoutManager, Serializable ...@@ -228,7 +281,9 @@ public class FlowLayout implements LayoutManager, Serializable
this.vgap = vgap; 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 () public String toString ()
{ {
return ("[" + getClass ().getName () + ",hgap=" + hgap + ",vgap=" + vgap return ("[" + getClass ().getName () + ",hgap=" + hgap + ",vgap=" + vgap
...@@ -270,9 +325,19 @@ public class FlowLayout implements LayoutManager, Serializable ...@@ -270,9 +325,19 @@ public class FlowLayout implements LayoutManager, Serializable
return new Dimension (w, h); 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; private int align;
// The gaps.
/**
* @serial The horizontal gap between components.
*/
private int hgap; private int hgap;
/**
* @serial The vertical gap between lines of components.
*/
private int vgap; private int vgap;
} }
/* 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; package java.awt;
import java.awt.peer.FramePeer; 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;
/**
* 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
{
/*
* Static Variables
*/
/**
* Constant for a cross-hair cursor.
* @deprecated Use <code>Cursor.CROSSHAIR_CURSOR</code> instead.
*/
public static final int CROSSHAIR_CURSOR = Cursor.CROSSHAIR_CURSOR;
/**
* Constant for a cursor over a text field.
* @deprecated Use <code>Cursor.TEXT_CURSOR</code> instead.
*/
public static final int TEXT_CURSOR = Cursor.TEXT_CURSOR;
/**
* Constant for a cursor to display while waiting for an action to complete.
* @deprecated Use <code>Cursor.WAIT_CURSOR</code>.
*/
public static final int WAIT_CURSOR = Cursor.WAIT_CURSOR;
/**
* Cursor used over SW corner of window decorations.
* @deprecated Use <code>Cursor.SW_RESIZE_CURSOR</code> instead.
*/
public static final int SW_RESIZE_CURSOR = Cursor.SW_RESIZE_CURSOR;
/**
* Cursor used over SE corner of window decorations.
* @deprecated Use <code>Cursor.SE_RESIZE_CURSOR</code> instead.
*/
public static final int SE_RESIZE_CURSOR = Cursor.SE_RESIZE_CURSOR;
/**
* Cursor used over NW corner of window decorations.
* @deprecated Use <code>Cursor.NW_RESIZE_CURSOR</code> instead.
*/
public static final int NW_RESIZE_CURSOR = Cursor.NW_RESIZE_CURSOR;
/**
* Cursor used over NE corner of window decorations.
* @deprecated Use <code>Cursor.NE_RESIZE_CURSOR</code> instead.
*/
public static final int NE_RESIZE_CURSOR = Cursor.NE_RESIZE_CURSOR;
/**
* Cursor used over N edge of window decorations.
* @deprecated Use <code>Cursor.N_RESIZE_CURSOR</code> instead.
*/
public static final int N_RESIZE_CURSOR = Cursor.N_RESIZE_CURSOR;
/**
* Cursor used over S edge of window decorations.
* @deprecated Use <code>Cursor.S_RESIZE_CURSOR</code> instead.
*/
public static final int S_RESIZE_CURSOR = Cursor.S_RESIZE_CURSOR;
/**
* Cursor used over E edge of window decorations.
* @deprecated Use <code>Cursor.E_RESIZE_CURSOR</code> instead.
*/
public static final int E_RESIZE_CURSOR = Cursor.E_RESIZE_CURSOR;
/**
* Cursor used over W edge of window decorations.
* @deprecated Use <code>Cursor.W_RESIZE_CURSOR</code> instead.
*/
public static final int W_RESIZE_CURSOR = Cursor.W_RESIZE_CURSOR;
/**
* Constant for a hand cursor.
* @deprecated Use <code>Cursor.HAND_CURSOR</code> instead.
*/
public static final int HAND_CURSOR = Cursor.HAND_CURSOR;
/**
* Constant for a cursor used during window move operations.
* @deprecated Use <code>Cursor.MOVE_CURSOR</code> 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;
/* A very incomplete placeholder. */ /**
* @serial Constant used by the JDK Motif peer set. Not used in
* this implementation.
*/
private boolean mbManagement;
public class Frame extends Window implements MenuContainer /**
* @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 <code>Frame</code> that is not visible
* and has no title.
*/
public
Frame()
{
this("");
}
/*************************************************************************/
/**
* Initializes a new instance of <code>Frame</code> 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)
{ {
public static final int NORMAL = 0; super(gc);
public static final int ICONIFIED = 1; }
MenuBar menuBar = null; public
String title; Frame(String title, GraphicsConfiguration gc)
{
super(gc);
setTitle(title);
}
private transient Image iconImage; /*************************************************************************/
private transient boolean isResizable = true;
private transient int state = NORMAL;
public Frame () /*
{ * Instance Methods
super(); */
}
public Frame(GraphicsConfiguration gc) /**
{ * Returns this frame's title string.
super(gc); *
} * @return This frame's title string.
*/
public String
getTitle()
{
return(title);
}
public Frame (String title) /*************************************************************************/
{
super();
setTitle(title);
}
public Frame(String title, GraphicsConfiguration gc) /*
{ * Sets this frame's title to the specified value.
super(gc); *
setTitle(title); * @param title The new frame title.
} */
public synchronized void
setTitle(String title)
{
this.title = title;
if (peer != null)
((FramePeer) peer).setTitle(title);
}
public String getTitle() /*************************************************************************/
{
return (title != null) ? title : ""; /**
} * Returns this frame's icon.
*
public void setTitle (String title) * @return This frame's icon, or <code>null</code> if this frame does not
{ * have an icon.
this.title = title; */
if (peer != null) public Image
((FramePeer)peer).setTitle(title); getIconImage()
} {
return(icon);
public Image getIconImage() }
{
return iconImage; /*************************************************************************/
}
/**
public void setIconImage(Image image) * Sets this frame's icon to the specified value.
{ *
iconImage = image; * @icon The new icon for this frame.
if (peer != null) */
((FramePeer) peer).setIconImage(iconImage); public synchronized void
} setIconImage(Image icon)
{
protected void finalize() throws Throwable this.icon = icon;
{ if (peer != null)
//frames.remove(this); ((FramePeer) peer).setIconImage(icon);
/* 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(); /**
} * Returns this frame's menu bar.
*
public synchronized void setMenuBar (MenuBar menuBar) * @return This frame's menu bar, or <code>null</code> if this frame
{ * does not have a menu bar.
if (this.menuBar != menuBar) */
{ public MenuBar
//this.menuBar.removeNotify(); getMenuBar()
this.menuBar = menuBar; {
//this.menuBar.addNotify(); return(menuBar);
} }
if (peer != null) /*************************************************************************/
((FramePeer) peer).setMenuBar(menuBar);
} /**
* Sets this frame's menu bar.
public boolean isResizable() *
{ * @param menuBar The new menu bar for this frame.
return isResizable; */
} public synchronized void
setMenuBar(MenuBar menuBar)
public void setResizable(boolean resizable) {
{ this.menuBar = menuBar;
isResizable = resizable; if (peer != null)
if (peer != null) ((FramePeer) peer).setMenuBar(menuBar);
((FramePeer) peer).setResizable(isResizable); }
}
/*************************************************************************/
public int getState()
{ /**
/* FIXME: State might have changed in the peer... Must check. */ * Tests whether or not this frame is resizable. This will be
* <code>true</code> by default.
return state; *
} * @return <code>true</code> if this frame is resizable, <code>false</code>
* otherwise.
*/
public synchronized void addNotify () public boolean
{ isResizable()
if (peer == null) {
peer = getToolkit ().createFrame (this); return(resizable);
super.addNotify(); }
}
/*************************************************************************/
public boolean postEvent(Event evt) { return false; } // FIXME
/**
public void remove(MenuComponent m) * Sets the resizability of this frame to the specified value.
{ *
if (m == menuBar) * @param resizable <code>true</code> to make the frame resizable,
{ * <code>false</code> to make it non-resizable.
setMenuBar(null); */
return; public synchronized void
} setResizable(boolean resizable)
{
super.remove(m); this.resizable = resizable;
} if (peer != null)
((FramePeer) peer).setResizable(resizable);
public void removeNotify() }
{
//if ((peer != null) && (menuBar != null)) menuBar.removeNotify(); /*************************************************************************/
super.removeNotify();
} /**
* 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 <code>Component.getCursor()</code> 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 <code>Component.setCursor(Cursor)</code> 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 static Frame[] getFrames() return state;
{ }
//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 // see finalize() comment
String msg = "FIXME: can't be implemented without weak references"; String msg = "FIXME: can't be implemented without weak references";
throw new UnsupportedOperationException(msg); throw new UnsupportedOperationException(msg);
}
} }
} // class Frame
/* 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; package java.awt;
import java.awt.image.ImageObserver; import java.awt.image.ImageObserver;
/** /**
* @author Warren Levy <warrenl@cygnus.com> * This is the abstract superclass of classes for drawing to graphics
* @date March 15, 2000. * devices such as the screen or printers.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Warren Levy <warrenl@cygnus.com>
*/
public abstract class Graphics
{
/*
* Instance Variables
*/
/*************************************************************************/
/*
* Constructors
*/ */
/** /**
* Written using on-line Java Platform 1.2 API Specification, as well * Default constructor for subclasses.
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). */
* Status: Almost complete protected
Graphics()
{
}
/*************************************************************************/
/*
* Instance Methods
*/ */
public abstract class Graphics /**
* Returns a copy of this <code>Graphics</code> object.
*
* @return A copy of this object.
*/
public abstract Graphics
create();
/*************************************************************************/
/**
* Returns a copy of this <code>Graphics</code> 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)
{ {
protected Graphics() {} Graphics g = create();
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);
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);
public abstract Graphics create(); /*************************************************************************/
public Graphics create(int x, int y, int width, int height) /**
{ * Returns the current font for this graphics context.
Graphics gfx = create(); *
gfx.translate(x, y); * @return The current font.
gfx.setClip(0, y, width, height); */
return gfx; public abstract Font
} getFont();
public abstract void translate(int x, int y); /*************************************************************************/
public abstract Color getColor(); /**
* Sets the font for this graphics context to the specified value.
*
* @param font The new font.
*/
public abstract void
setFont(Font font);
public abstract void setColor(Color color); /*************************************************************************/
public abstract void setPaintMode(); /**
* Returns the font metrics for the current font.
*
* @return The font metrics for the current font.
*/
public FontMetrics
getFontMetrics()
{
return(getFontMetrics(getFont()));
}
public abstract void setXORMode(Color altColor); /*************************************************************************/
public abstract Font 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);
public abstract void setFont(Font font); /*************************************************************************/
public FontMetrics getFontMetrics() /**
{ * Returns the bounding rectangle of the clipping region for this
return getFontMetrics(getFont()); * graphics context.
} *
* @return The bounding rectangle for the clipping region.
*/
public abstract Rectangle
getClipBounds();
public abstract FontMetrics getFontMetrics(Font font); /*************************************************************************/
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
* <code>getClipBounds()</code>.
*/
public Rectangle
getClipRect()
{
return(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); /**
* 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);
public abstract Shape getClip(); /*************************************************************************/
public abstract void setClip(Shape clip); /**
* 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);
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); /**
* Returns the current clipping region as a <code>Shape</code> object.
public abstract void fillRect(int x, int y, int width, int height); *
* @return The clipping region as a <code>Shape</code>.
public void drawRect(int x, int y, int width, int height) */
{ public abstract Shape
int x1 = x; getClip();
int y1 = y;
int x2 = x + width; /*************************************************************************/
int y2 = y + height;
drawLine(x1, y1, x2, y1); /**
drawLine(x2, y1, x2, y2); * Sets the clipping region to the specified <code>Shape</code>.
drawLine(x2, y2, x1, y2); *
drawLine(x1, y2, x1, y1); * @param shape The new clipping region.
} */
public abstract void
public abstract void clearRect(int x, int y, int width, int height); setClip(Shape clip);
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, * Copies the specified rectangle to the specified offset location.
int arcWidth, int arcHeight); *
* @param x The X coordinate of the upper left corner of the copy rect.
public void draw3DRect(int x, int y, int width, int height, * @param y The Y coordinate of the upper left corner of the copy rect.
boolean raised) * @param width The width of the copy rect.
{ * @param height The height of the copy rect.
Color color = getColor(); * @param dx The offset from the X value to start drawing.
Color tl = color.brighter(); * @param dy The offset from the Y value to start drawing.
Color br = color.darker(); */
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) if (!raised)
{ {
Color tmp = tl; Color tmp = tl;
tl = br; tl = br;
br = tmp; br = tmp;
} }
int x1 = x; int x1 = x;
int y1 = y; int y1 = y;
int x2 = x + width; int x2 = x + width;
int y2 = y + height; int y2 = y + height;
setColor(tl); setColor(tl);
drawLine(x1, y1, x2, y1); drawLine(x1, y1, x2, y1);
drawLine(x1, y2, x1, y1); drawLine(x1, y2, x1, y1);
setColor(br); setColor(br);
drawLine(x2, y1, x2, y2); drawLine(x2, y1, x2, y2);
drawLine(x2, y1, x1, y2); drawLine(x2, y1, x1, y2);
setColor(color); setColor(color);
} }
public void fill3DRect(int x, int y, int width, int height, /**
boolean raised) * Fills the specified rectangle with a 3D effect
{ *
fillRect(x, y, width, height); * @param x The X coordinate of the upper left corner of the fill rect.
draw3DRect(x, y, width-1, height-1, raised); * @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 drawOval(int x, int y, int width, int height); * @param raised <code>true</code> if the rectangle appears raised,
* <code>false</code> if it should appear etched.
public abstract void fillOval(int x, int y, int width, int height); */
public void
public abstract void drawArc(int x, int y, int width, int height, fill3DRect(int x, int y, int width, int height, boolean raised)
int startAngle, int arcAngle); {
fillRect(x, y, width, height);
public abstract void fillArc(int x, int y, int width, int height, draw3DRect(x, y, width-1, height-1, raised);
int startAngle, int arcAngle); }
public abstract void drawPolyline(int[] xPoints, int[] yPoints, /*************************************************************************/
int nPoints);
/**
public abstract void drawPolygon(int[] xPoints, int[] yPoints, * Draws the outline of the specified rectangle with a 3D effect
int nPoints); *
* @param x The X coordinate of the upper left corner of the draw rect.
//public void drawPolygon(Polygon p); * @param y The Y coordinate of the upper left corner of the draw rect.
* @param width The width of the draw rect.
public abstract void fillPolygon(int[] xPoints, int[] yPoints, * @param height The height of the draw rect.
int nPoints); * @param raised <code>true</code> if the rectangle appears raised,
* <code>false</code> 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);
/*************************************************************************/
//public void fillPolygon(Polygon p); /**
* 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);
}
public abstract void drawString(String str, int x, int 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, public abstract void drawString(AttributedCharacterIterator iterator,
int x, int y) 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, <code>false</code> 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 <code>true</code> if all the image data is available,
* <code>false</code> otherwise.
*/ */
public abstract boolean
drawImage(Image image, int x, int y, ImageObserver observer);
/*************************************************************************/
public void drawChars(char[] data, int offset, int length, /**
int x, int y) * Draws all of the image that is available and returns. The image
{ * is scaled to fit in the specified rectangle. If the image
String str = new String(data, offset, length); * is not completely loaded, <code>false</code> is returned and
drawString(str, x, y); * 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 <code>true</code> if all the image data is available,
* <code>false</code> otherwise.
*/
public abstract boolean
drawImage(Image image, int x, int y, int width, int height,
ImageObserver observer);
/*************************************************************************/
public void drawBytes(byte[] data, int offset, int length, /**
int x, int y) * Draws all of the image that is available and returns. If the image
{ * is not completely loaded, <code>false</code> is returned and
String str = new String(data, offset, length); * the specified iamge observer is notified as more data becomes
drawString(str, x, y); * 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 <code>true</code> if all the image data is available,
* <code>false</code> otherwise.
*/
public abstract boolean
drawImage(Image image, int x, int y, Color bgcolor, ImageObserver observer);
/*************************************************************************/
public abstract boolean drawImage(Image img, 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, <code>false</code> 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 <code>true</code> if all the image data is available,
* <code>false</code> otherwise.
*/
public abstract boolean
drawImage(Image image, int x, int y, int width, int height, Color bgcolor,
ImageObserver observer);
/*************************************************************************/
public abstract boolean drawImage(Image img, int x, int y, /**
int width, int height, * FIXME: Write Javadocs for this when you understand it.
ImageObserver observer); */
public abstract boolean
drawImage(Image image, 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 x, int y, Color bgcolor, /*************************************************************************/
ImageObserver observer);
/**
public abstract boolean drawImage(Image img, int x, int y, * FIXME: Write Javadocs for this when you understand it.
int width, int height, Color bgcolor, */
ImageObserver observer); 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);
/*************************************************************************/
public abstract boolean drawImage(Image img, /**
int dx1, int dy1, int dx2, int dy2, * Free any resources held by this graphics context immediately instead
int sx1, int sy1, int sx2, int sy2, * of waiting for the object to be garbage collected and finalized.
ImageObserver observer); */
public abstract void
dispose();
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); * Frees the resources held by this graphics context when it is
* garbage collected.
*/
public void
finalize()
{
dispose();
}
public abstract void 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();
public void finalize() if (r == null)
{ return clipBounds;
dispose();
} r.x = clipBounds.x;
r.y = clipBounds.y;
public String toString() r.width = clipBounds.width;
{ r.height = clipBounds.height;
return super.toString(); // FIXME return r;
}
/** @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;
}
} }
} // class Graphics
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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 /* Status: Complete, but commented out until we have the required
GraphicsDevice. */ GraphicsDevice. */
......
/* 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; package java.awt;
......
/* 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; package java.awt;
...@@ -13,14 +31,42 @@ import java.io.Serializable; ...@@ -13,14 +31,42 @@ import java.io.Serializable;
/* Status: Mostly complete. Some of the Java2D stuff is commented out. */ /* 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 <warrenl@cygnus.com>
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public class Rectangle extends Rectangle2D public class Rectangle extends Rectangle2D
implements Cloneable, Shape, Serializable implements Cloneable, Shape, Serializable
{ {
/**
* The X coordinate of the top-left corner of the rectangle.
*/
public int x; public int x;
/**
* The Y coordinate of the top-left corner of the rectangle;
*/
public int y; public int y;
/**
* The width of the rectangle
*/
public int width; public int width;
/**
* The height of the rectangle
*/
public int height; public int height;
/**
* Initializes a new instance of <code>Rectangle</code> with a top
* left corner at (0,0) and a width and height of 0.
*/
public Rectangle() public Rectangle()
{ {
x = 0; x = 0;
...@@ -29,6 +75,12 @@ public class Rectangle extends Rectangle2D ...@@ -29,6 +75,12 @@ public class Rectangle extends Rectangle2D
height = 0; height = 0;
} }
/**
* Initializes a new instance of <code>Rectangle</code> from the
* coordinates of the specified rectangle.
*
* @param rect The rectangle to copy from.
*/
public Rectangle(Rectangle r) public Rectangle(Rectangle r)
{ {
x = r.x; x = r.x;
...@@ -37,6 +89,15 @@ public class Rectangle extends Rectangle2D ...@@ -37,6 +89,15 @@ public class Rectangle extends Rectangle2D
height = r.height; height = r.height;
} }
/**
* Initializes a new instance of <code>Rectangle</code> 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) public Rectangle(int x, int y, int width, int height)
{ {
this.x = x; this.x = x;
...@@ -45,6 +106,14 @@ public class Rectangle extends Rectangle2D ...@@ -45,6 +106,14 @@ public class Rectangle extends Rectangle2D
this.height = height; this.height = height;
} }
/**
* Initializes a new instance of <code>Rectangle</code> 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) public Rectangle(int width, int height)
{ {
x = 0; x = 0;
...@@ -53,6 +122,14 @@ public class Rectangle extends Rectangle2D ...@@ -53,6 +122,14 @@ public class Rectangle extends Rectangle2D
this.height = height; this.height = height;
} }
/**
* Initializes a new instance of <code>Rectangle</code> 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) public Rectangle(Point p, Dimension d)
{ {
x = p.x; x = p.x;
...@@ -61,6 +138,12 @@ public class Rectangle extends Rectangle2D ...@@ -61,6 +138,12 @@ public class Rectangle extends Rectangle2D
height = d.height; height = d.height;
} }
/**
* Initializes a new instance of <code>Rectangle</code> 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) public Rectangle(Point p)
{ {
x = p.x; x = p.x;
...@@ -69,6 +152,13 @@ public class Rectangle extends Rectangle2D ...@@ -69,6 +152,13 @@ public class Rectangle extends Rectangle2D
height = 0; height = 0;
} }
/**
* Initializes a new instance of <code>Rectangle</code> 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) public Rectangle(Dimension d)
{ {
x = 0; x = 0;
...@@ -77,11 +167,24 @@ public class Rectangle extends Rectangle2D ...@@ -77,11 +167,24 @@ public class Rectangle extends Rectangle2D
height = d.height; height = d.height;
} }
/**
* Returns the bounding rectangle for this rectangle, which is simply
* this rectange itself.
*
* @return This rectangle.
*/
public Rectangle getBounds () public Rectangle getBounds ()
{ {
return (Rectangle) this.clone(); 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) public void add(int newx, int newy)
{ {
int x = this.x > newx ? newx : this.x; int x = this.x > newx ? newx : this.x;
...@@ -92,11 +195,23 @@ public class Rectangle extends Rectangle2D ...@@ -92,11 +195,23 @@ public class Rectangle extends Rectangle2D
this.y = y; 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) public void add(Point pt)
{ {
add (pt.x, pt.y); 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) public void add(Rectangle r)
{ {
int x = this.x > r.x ? r.x : this.x; int x = this.x > r.x ? r.x : this.x;
...@@ -109,6 +224,15 @@ public class Rectangle extends Rectangle2D ...@@ -109,6 +224,15 @@ public class Rectangle extends Rectangle2D
this.y = y; 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 <code>true</code> if the point is inside the rectangle,
* <code>false</code> otherwise.
*/
public boolean contains(int x, int y) public boolean contains(int x, int y)
{ {
return (x >= this.x && x <= this.x + this.width return (x >= this.x && x <= this.x + this.width
...@@ -121,6 +245,14 @@ public class Rectangle extends Rectangle2D ...@@ -121,6 +245,14 @@ public class Rectangle extends Rectangle2D
&& y >= this.y && y + h <= this.y + this.height); && 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 <code>true</code> if the point is inside the rectangle,
* <code>false</code> otherwise.
*/
public boolean contains(Point p) public boolean contains(Point p)
{ {
return contains(p.x, p.y); return contains(p.x, p.y);
...@@ -131,6 +263,22 @@ public class Rectangle extends Rectangle2D ...@@ -131,6 +263,22 @@ public class Rectangle extends Rectangle2D
return contains(r.x, r.y, r.width, r.height); 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:
* <p>
* <ul>
* <li>Is not <code>null</code>.
* <li>Is an instance of <code>Rectangle</code>.
* <li>Has X and Y coordinates identical to this rectangle.
* <li>Has a width and height identical to this rectangle.
* </ul>
*
* @param obj The object to test against for equality.
*
* @return <code>true</code> if the specified object is equal to this one,
* <code>false</code> otherwise.
*/
public boolean equals(Object obj) public boolean equals(Object obj)
{ {
if (obj instanceof Rectangle) if (obj instanceof Rectangle)
...@@ -149,11 +297,22 @@ public class Rectangle extends Rectangle2D ...@@ -149,11 +297,22 @@ public class Rectangle extends Rectangle2D
return (double) this.height; 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() public Point getLocation()
{ {
return new Point(x,y); return new Point(x,y);
} }
/**
* Returns the size of this rectangle.
*
* @return The size of this rectangle.
*/
public Dimension getSize() public Dimension getSize()
{ {
return new Dimension(width, height); return new Dimension(width, height);
...@@ -174,21 +333,49 @@ public class Rectangle extends Rectangle2D ...@@ -174,21 +333,49 @@ public class Rectangle extends Rectangle2D
return (double) y; 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) public void grow(int h, int v)
{ {
width += h; width += h;
height += v; 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 <code>true</code> if the point is inside the rectangle,
* <code>false</code> otherwise.
*
* @deprecated This method is deprecated in favor of
* <code>contains(int, int)</code>.
*/
public boolean inside(int x, int y) public boolean inside(int x, int y)
{ {
return contains(x, 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) public Rectangle intersection(Rectangle r)
{ {
int newx = x < r.x ? r.x : x; int newx = x < r.x ? r.x : x;
...@@ -203,9 +390,17 @@ public class Rectangle extends Rectangle2D ...@@ -203,9 +390,17 @@ public class Rectangle extends Rectangle2D
return new Rectangle(0, 0, 0, 0); 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 <code>true</code> if the specified rectangle intersects this
* one, <code>false</code> 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) public boolean intersects(Rectangle r)
{ {
int neww = (x + width < r.x + r.width ? int neww = (x + width < r.x + r.width ?
...@@ -215,12 +410,29 @@ public class Rectangle extends Rectangle2D ...@@ -215,12 +410,29 @@ public class Rectangle extends Rectangle2D
return (neww > 0 && newh > 0); return (neww > 0 && newh > 0);
} }
/**
* Tests whether or not this rectangle is empty. An empty rectangle
* has a width or height of zero.
*
* @return <code>true</code> if the rectangle is empty, <code>false</code>
* otherwise.
*/
public boolean isEmpty() public boolean isEmpty()
{ {
return !(width > 0 && height > 0); 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
* <code>setLocation(int, int)</code>.
*/
public void move(int x, int y) public void move(int x, int y)
{ {
setLocation(x, y); setLocation(x, y);
...@@ -232,18 +444,44 @@ public class Rectangle extends Rectangle2D ...@@ -232,18 +444,44 @@ public class Rectangle extends Rectangle2D
return 0; 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
* <code>setBounds(int, int, int, int)</code>.
*/
public void reshape(int x, int y, int width, int height) public void reshape(int x, int y, int width, int height)
{ {
setBounds(x, y, width, 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
* <code>setSize(int, int)</code>.
*/
public void resize(int width, int height) public void resize(int width, int height)
{ {
setSize(width, 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) public void setBounds(int x, int y, int width, int height)
{ {
this.x = x; this.x = x;
...@@ -252,6 +490,12 @@ public class Rectangle extends Rectangle2D ...@@ -252,6 +490,12 @@ public class Rectangle extends Rectangle2D
this.height = height; 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) public void setBounds(Rectangle r)
{ {
this.x = r.x; this.x = r.x;
...@@ -260,12 +504,27 @@ public class Rectangle extends Rectangle2D ...@@ -260,12 +504,27 @@ public class Rectangle extends Rectangle2D
this.height = r.height; 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) public void setLocation(int x, int y)
{ {
this.x = x; this.x = x;
this.y = y; 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) public void setLocation(Point p)
{ {
this.x = p.x; this.x = p.x;
...@@ -280,12 +539,23 @@ public class Rectangle extends Rectangle2D ...@@ -280,12 +539,23 @@ public class Rectangle extends Rectangle2D
this.height = (int) height; 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) public void setSize(Dimension d)
{ {
this.width = d.width; this.width = d.width;
this.height = d.height; 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) public void setSize(int width, int height)
{ {
this.width = width; this.width = width;
...@@ -298,6 +568,14 @@ public class Rectangle extends Rectangle2D ...@@ -298,6 +568,14 @@ public class Rectangle extends Rectangle2D
y += y; 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) public Rectangle union(Rectangle r)
{ {
int newx = x > r.x ? r.x : x; int newx = x > r.x ? r.x : x;
...@@ -333,9 +611,24 @@ public class Rectangle extends Rectangle2D ...@@ -333,9 +611,24 @@ public class Rectangle extends Rectangle2D
return new Rectangle (x, y, width, height); return new Rectangle (x, y, width, height);
} }
/**
* Returns a string representation of this rectangle.
*
* @return A string representation of this rectangle.
*/
public String toString() public String toString()
{ {
return getClass().getName() + "[x=" + x + ",y=" + y + ",width=" + width + return getClass().getName() + "[x=" + x + ",y=" + y + ",width=" + width +
",height=" + height + "]"; ",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;
}
} }
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt;
......
...@@ -14,7 +14,7 @@ import java.beans.*; ...@@ -14,7 +14,7 @@ import java.beans.*;
import java.awt.image.*; import java.awt.image.*;
import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.Clipboard;
import java.util.Hashtable; import java.util.Hashtable;
import gnu.gcj.awt.GLightweightPeer; import gnu.java.awt.GLightweightPeer;
/* A very incomplete placeholder. */ /* A very incomplete placeholder. */
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt;
......
/* 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 This file is part of GNU Classpath.
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; package java.awt;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
...@@ -15,8 +34,12 @@ import java.util.EventListener; ...@@ -15,8 +34,12 @@ import java.util.EventListener;
import java.util.Locale; import java.util.Locale;
import java.util.ResourceBundle; 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 <warrenl@cygnus.com>
*/
public class Window extends Container public class Window extends Container
{ {
// Serialized fields, from Sun's serialization spec. // Serialized fields, from Sun's serialization spec.
...@@ -46,6 +69,12 @@ public class Window extends Container ...@@ -46,6 +69,12 @@ public class Window extends Container
graphicsConfiguration = gc; graphicsConfiguration = gc;
} }
/**
* Initializes a new instance of <code>Window</code> with the specified
* parent. The window will initially be invisible.
*
* @param parent The owning <code>Frame</code> of this window.
*/
public Window(Frame owner) public Window(Frame owner)
{ {
this((Window) owner); this((Window) owner);
...@@ -99,6 +128,9 @@ public class Window extends Container ...@@ -99,6 +128,9 @@ public class Window extends Container
super.finalize(); super.finalize();
} }
/**
* Creates the native peer for this window.
*/
public void addNotify() public void addNotify()
{ {
if (peer == null) if (peer == null)
...@@ -106,8 +138,12 @@ public class Window extends Container ...@@ -106,8 +138,12 @@ public class Window extends Container
super.addNotify (); 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() public void pack()
{ {
if (parent != null if (parent != null
...@@ -121,31 +157,16 @@ public class Window extends Container ...@@ -121,31 +157,16 @@ public class Window extends Container
validate(); validate();
} }
/**
* Makes this window visible and brings it to the front.
*/
public void show () public void show ()
{ {
if (peer == null) if (peer == null)
addNotify(); addNotify();
validate ();
if (isVisible())
{
this.toFront();
return;
}
if (parent != null
&& !parent.isDisplayable())
parent.addNotify();
if (peer == null)
addNotify ();
validate (); super.show();
toFront();
super.show ();
// FIXME: Is this call necessary or do we assume the peer takes care of
// it?
// this.toFront();
} }
public void hide() public void hide()
...@@ -154,6 +175,9 @@ public class Window extends Container ...@@ -154,6 +175,9 @@ public class Window extends Container
super.hide(); super.hide();
} }
/**
* Called to free any resource associated with this window.
*/
public void dispose() public void dispose()
{ {
hide(); hide();
...@@ -167,6 +191,10 @@ public class Window extends Container ...@@ -167,6 +191,10 @@ public class Window extends Container
this.removeNotify(); this.removeNotify();
} }
/**
* Sends this window to the back so that all other windows display in
* front of it.
*/
public void toBack () public void toBack ()
{ {
if (peer != null) if (peer != null)
...@@ -176,6 +204,10 @@ public class Window extends Container ...@@ -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 () public void toFront ()
{ {
if (peer != null) if (peer != null)
...@@ -185,13 +217,25 @@ public class Window extends Container ...@@ -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() public Toolkit getToolkit()
{ {
return Toolkit.getDefaultToolkit (); 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() public final String getWarningString()
{ {
boolean secure = true; boolean secure = true;
...@@ -210,6 +254,11 @@ public class Window extends Container ...@@ -210,6 +254,11 @@ public class Window extends Container
return null; return null;
} }
/**
* Returns the locale that this window is configured for.
*
* @return The locale this window is configured for.
*/
public Locale getLocale () public Locale getLocale ()
{ {
return locale == null ? Locale.getDefault () : locale; return locale == null ? Locale.getDefault () : locale;
...@@ -223,9 +272,13 @@ public class Window extends Container ...@@ -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) public void setCursor(Cursor cursor)
{ {
// FIXME: why different from Component.setCursor() ?
super.setCursor(cursor); super.setCursor(cursor);
} }
...@@ -242,11 +295,23 @@ public class Window extends Container ...@@ -242,11 +295,23 @@ public class Window extends Container
return null; return null;
} }
/**
* Adds the specified listener to the list of <code>WindowListeners</code>
* that will receive events for this window.
*
* @param listener The <code>WindowListener</code> to add.
*/
public synchronized void addWindowListener (WindowListener listener) public synchronized void addWindowListener (WindowListener listener)
{ {
windowListener = AWTEventMulticaster.add (windowListener, listener); windowListener = AWTEventMulticaster.add (windowListener, listener);
} }
/**
* Removes the specified listener from the list of
* <code>WindowListeners</code> that will receive events for this window.
*
* @param listener The <code>WindowListener</code> to remove.
*/
public synchronized void removeWindowListener (WindowListener listener) public synchronized void removeWindowListener (WindowListener listener)
{ {
windowListener = AWTEventMulticaster.remove (windowListener, listener); windowListener = AWTEventMulticaster.remove (windowListener, listener);
...@@ -272,6 +337,14 @@ public class Window extends Container ...@@ -272,6 +337,14 @@ public class Window extends Container
super.dispatchEventImpl(e); super.dispatchEventImpl(e);
} }
/**
* Processes the specified event for this window. If the event is an
* instance of <code>WindowEvent</code>, then
* <code>processWindowEvent()</code> 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) protected void processEvent (AWTEvent evt)
{ {
if (evt instanceof WindowEvent) if (evt instanceof WindowEvent)
...@@ -280,6 +353,14 @@ public class Window extends Container ...@@ -280,6 +353,14 @@ public class Window extends Container
super.processEvent (evt); super.processEvent (evt);
} }
/**
* Dispatches this event to any listeners that are listening for
* <code>WindowEvents</code> on this window. This method only gets
* invoked if it is enabled via <code>enableEvents()</code> or if
* a listener has been added.
*
* @param event The event to process.
*/
protected void processWindowEvent (WindowEvent evt) protected void processWindowEvent (WindowEvent evt)
{ {
if (windowListener != null) if (windowListener != null)
...@@ -311,22 +392,40 @@ public class Window extends Container ...@@ -311,22 +392,40 @@ public class Window extends Container
} }
} }
/**
* Returns the child window that has focus if this window is active.
* This method returns <code>null</code> if this window is not active
* or no children have focus.
*
* @return The component that has focus, or <code>null</code> if no
* component has focus.
*/
public Component getFocusOwner() public Component getFocusOwner()
{ {
// FIXME // FIXME
return null; return null;
} }
/**
* Post a Java 1.0 event to the event queue.
*
* @param event The event to post.
*/
public boolean postEvent(Event e) public boolean postEvent(Event e)
{ {
// FIXME // FIXME
return false; return false;
} }
/**
* Tests whether or not this window is visible on the screen.
*
* @return <code>true</code> if this window is visible, <code>false</code>
* otherwise.
*/
public boolean isShowing() public boolean isShowing()
{ {
// FIXME: Also check if window is within the boundary of the screen? return super.isShowing();
return isVisible();
} }
/** @since 1.2 */ /** @since 1.2 */
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.color;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.color;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.color;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.event;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.event;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.event;
import java.awt.*; import java.awt.*;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.event;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBJAVA_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.geom;
import java.awt.*; import java.awt.*;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBJAVA_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.geom;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBJAVA_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.geom;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBJAVA_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.geom;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBJAVA_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.geom;
...@@ -24,7 +41,15 @@ public abstract class Line2D implements Shape, Cloneable ...@@ -24,7 +41,15 @@ public abstract class Line2D implements Shape, Cloneable
public Object clone () public Object clone ()
{ {
return super.clone (); try
{
return super.clone ();
}
catch (CloneNotSupportedException _)
{
// Can't happen.
return null;
}
} }
public boolean contains (double x, double y) public boolean contains (double x, double y)
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBJAVA_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.geom;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBJAVA_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.geom;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBJAVA_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.geom;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBJAVA_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.geom;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBJAVA_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.geom;
import java.awt.*; import java.awt.*;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libjava License. Please consult the file "LIBJAVA_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.geom;
......
/* 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; package java.awt.image;
...@@ -12,7 +30,7 @@ import java.awt.*; ...@@ -12,7 +30,7 @@ import java.awt.*;
import java.awt.color.*; import java.awt.color.*;
import java.util.*; import java.util.*;
import gnu.gcj.awt.ComponentDataBlitOp; import gnu.java.awt.ComponentDataBlitOp;
/** /**
* A buffered image always starts at coordinates (0, 0). * A buffered image always starts at coordinates (0, 0).
......
/* 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; package java.awt.image;
import java.awt.Point; import java.awt.Point;
import java.awt.Transparency; import java.awt.Transparency;
import java.awt.color.ColorSpace; import java.awt.color.ColorSpace;
import gnu.gcj.awt.Buffers; import gnu.java.awt.Buffers;
/** /**
* A color model operates with colors in several formats: * A color model operates with colors in several formats:
...@@ -47,8 +65,8 @@ import gnu.gcj.awt.Buffers; ...@@ -47,8 +65,8 @@ import gnu.gcj.awt.Buffers;
* </ul> * </ul>
* *
* @author Rolf W. Rasmussen <rolfwr@ii.uib.no> * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
* @author C. Brian Jones (cbj@gnu.org)
*/ */
public abstract class ColorModel implements Transparency public abstract class ColorModel implements Transparency
{ {
protected int pixel_bits; protected int pixel_bits;
...@@ -74,6 +92,12 @@ public abstract class ColorModel implements Transparency ...@@ -74,6 +92,12 @@ public abstract class ColorModel implements Transparency
return array; return array;
} }
/**
* Constructs the default color model. The default color model
* can be obtained by calling <code>getRGBdefault</code> of this
* class.
* @param b the number of bits wide used for bit size of pixel values
*/
public ColorModel(int bits) public ColorModel(int bits)
{ {
this(bits * 4, // total bits, sRGB, four channels this(bits * 4, // total bits, sRGB, four channels
...@@ -98,6 +122,10 @@ public abstract class ColorModel implements Transparency ...@@ -98,6 +122,10 @@ public abstract class ColorModel implements Transparency
this.transferType = transferType; this.transferType = transferType;
} }
/**
* Returns the default color model which in Sun's case is an instance
* of <code>DirectColorModel</code>.
*/
public static ColorModel getRGBdefault() public static ColorModel getRGBdefault()
{ {
return new DirectColorModel(8, 0xff0000, 0xff00, 0xff, 0xff000000); return new DirectColorModel(8, 0xff0000, 0xff00, 0xff, 0xff000000);
...@@ -113,6 +141,9 @@ public abstract class ColorModel implements Transparency ...@@ -113,6 +141,9 @@ public abstract class ColorModel implements Transparency
return isAlphaPremultiplied; return isAlphaPremultiplied;
} }
/**
* Get get number of bits wide used for the bit size of pixel values
*/
public int getPixelSize() public int getPixelSize()
{ {
return pixel_bits; return pixel_bits;
...@@ -525,7 +556,8 @@ public abstract class ColorModel implements Transparency ...@@ -525,7 +556,8 @@ public abstract class ColorModel implements Transparency
return sm.getTransferType() == transferType; return sm.getTransferType() == transferType;
} }
public void finalize() { public void finalize()
{
} }
/** /**
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.image;
import java.awt.color.*; import java.awt.color.*;
import java.awt.Point; import java.awt.Point;
import gnu.gcj.awt.Buffers; import gnu.java.awt.Buffers;
public class ComponentColorModel extends ColorModel public class ComponentColorModel extends ColorModel
{ {
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; 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 */ /* FIXME: This class does not yet support data type TYPE_SHORT */
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.image;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.image;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.image;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.image;
......
/* 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; package java.awt.image;
import java.awt.Point; import java.awt.Point;
import java.awt.Transparency; import java.awt.Transparency;
import java.awt.color.ColorSpace; import java.awt.color.ColorSpace;
import gnu.gcj.awt.Buffers; import gnu.java.awt.Buffers;
/** /**
* @author Rolf W. Rasmussen <rolfwr@ii.uib.no> * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
* @author C. Brian Jones (cbj@gnu.org)
* @author Mark Benvenuto (mcb54@columbia.edu)
*/ */
public class DirectColorModel extends PackedColorModel 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) public DirectColorModel(int pixelBits, int rmask, int gmask, int bmask)
{ {
this(ColorSpace.getInstance(ColorSpace.CS_sRGB), pixelBits, this(ColorSpace.getInstance(ColorSpace.CS_sRGB), pixelBits,
...@@ -27,6 +60,18 @@ public class DirectColorModel extends PackedColorModel ...@@ -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, public DirectColorModel(int pixelBits,
int rmask, int gmask, int bmask, int amask) int rmask, int gmask, int bmask, int amask)
{ {
...@@ -68,24 +113,41 @@ public class DirectColorModel extends PackedColorModel ...@@ -68,24 +113,41 @@ public class DirectColorModel extends PackedColorModel
return hasAlpha() ? getMask(3) : 0; return hasAlpha() ? getMask(3) : 0;
} }
/**
* Get the red component of the given pixel.
* <br>
*/
public final int getRed(int pixel) public final int getRed(int pixel)
{ {
return extractAndNormalizeSample(pixel, 0); return extractAndNormalizeSample(pixel, 0);
} }
/**
* Get the green component of the given pixel.
* <br>
*/
public final int getGreen(int pixel) public final int getGreen(int pixel)
{ {
return extractAndNormalizeSample(pixel, 1); return extractAndNormalizeSample(pixel, 1);
} }
/**
* Get the blue component of the given pixel.
* <br>
*/
public final int getBlue(int pixel) public final int getBlue(int pixel)
{ {
return extractAndNormalizeSample(pixel, 2); return extractAndNormalizeSample(pixel, 2);
} }
/**
* Get the alpha component of the given pixel.
* <br>
*/
public final int getAlpha(int pixel) public final int getAlpha(int pixel)
{ {
if (!hasAlpha()) return 0; if (!hasAlpha())
return 0;
return extractAndScaleSample(pixel, 3); return extractAndScaleSample(pixel, 3);
} }
...@@ -106,15 +168,22 @@ public class DirectColorModel extends PackedColorModel ...@@ -106,15 +168,22 @@ public class DirectColorModel extends PackedColorModel
(field << to8BitShift) : (field << to8BitShift) :
(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.
* <br>
*
* @param pixel a pixel value
*/
public final int getRGB(int pixel) 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); return super.getRGB(pixel);
} }
public int getRed(Object inData) public int getRed(Object inData)
{ {
return getRed(getPixelFromArray(inData)); return getRed(getPixelFromArray(inData));
......
...@@ -10,7 +10,7 @@ package java.awt.image; ...@@ -10,7 +10,7 @@ package java.awt.image;
import java.awt.Transparency; import java.awt.Transparency;
import java.awt.color.ColorSpace; import java.awt.color.ColorSpace;
import gnu.gcj.awt.Buffers; import gnu.java.awt.Buffers;
/** /**
* @author Rolf W. Rasmussen <rolfwr@ii.uib.no> * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.image;
import java.awt.Point; import java.awt.Point;
import java.awt.color.ColorSpace; import java.awt.color.ColorSpace;
import gnu.gcj.awt.BitMaskExtent; import gnu.java.awt.BitMaskExtent;
/** /**
* @author Rolf W. Rasmussen <rolfwr@ii.uib.no> * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.image;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.image;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.image;
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.image;
import gnu.gcj.awt.BitMaskExtent; import gnu.java.awt.BitMaskExtent;
import gnu.gcj.awt.Buffers; import gnu.java.awt.Buffers;
/** /**
* @author Rolf W. Rasmussen <rolfwr@ii.uib.no> * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
......
/* 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 GNU Classpath is free software; you can redistribute it and/or modify
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for it under the terms of the GNU General Public License as published by
details. */ 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; package java.awt.image;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment