[kaffe] CVS kaffe (robilad): resynced with gnu classpath: swing fixes

Kaffe CVS cvs-commits at kaffe.org
Wed May 18 17:36:55 PDT 2005


PatchSet 6554 
Date: 2005/05/19 00:31:14
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
resynced with gnu classpath: swing fixes

Members: 
	ChangeLog:1.4080->1.4081 
	libraries/javalib/all.files:1.126->1.127 
	libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java:1.2->1.3 
	libraries/javalib/gnu/java/awt/peer/gtk/GtkComponentPeer.java:1.12->1.13 
	libraries/javalib/gnu/java/awt/peer/gtk/GtkVolatileImage.java:INITIAL->1.1 
	libraries/javalib/java/awt/BufferCapabilities.java:1.5->1.6 
	libraries/javalib/java/awt/Canvas.java:INITIAL->1.19 
	libraries/javalib/java/awt/Component.java:INITIAL->1.51 
	libraries/javalib/java/awt/Window.java:1.32->1.33 
	libraries/javalib/java/awt/image/BufferStrategy.java:1.2->1.3 
	libraries/javalib/java/awt/image/VolatileImage.java:1.3->1.4 
	libraries/javalib/java/awt/peer/ComponentPeer.java:INITIAL->1.3 
	libraries/javalib/javax/swing/AbstractButton.java:1.12->1.13 
	libraries/javalib/javax/swing/ImageIcon.java:1.6->1.7 
	libraries/javalib/javax/swing/JEditorPane.java:1.6->1.7 
	libraries/javalib/javax/swing/JSeparator.java:1.1->1.2 
	libraries/javalib/javax/swing/JTable.java:1.19->1.20 
	libraries/javalib/javax/swing/MenuSelectionManager.java:1.4->1.5 
	libraries/javalib/javax/swing/plaf/basic/BasicPopupMenuUI.java:1.7->1.8 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4080 kaffe/ChangeLog:1.4081
--- kaffe/ChangeLog:1.4080	Wed May 18 22:26:51 2005
+++ kaffe/ChangeLog	Thu May 19 00:31:14 2005
@@ -1,5 +1,115 @@
 2005-05-18  Dalibor Topic  <robilad at kaffe.org>
 
+	* java/awt/Canvas.java, java/awt/Window.java:
+	Fix not compiling code. :)
+
+	Resynced with GNU Classpath.
+
+	005-05-18  Thomas Fitzsimmons  <fitzsim at redhat.com>
+
+        * gnu/java/awt/peer/gtk/GtkVolatileImage.java: Fix imports.
+
+	2005-05-18  Olga Rodimina  <rodimina at redhat.com>
+
+        * javax/swing/MenuSelectionManager.java
+        (processMouseEvent): Clear selected path if the mouse was released
+        over non-menu component.
+        * javax/swing/plaf/basic/BasicPopupMenuUI.java
+        (Constructor): Removed initialization of mouseInputListener.
+        (installListeners): Do not add mouseInputListener to this popup
+        menu. Instead it will be added to the root container of the popup
+        menu.
+        (uninstallListeners): Remove code that removed mouseInputListener
+        from popupMenu.
+        (popupMenuWillBecomeInvisible): If this popup menu is the last
+        menu on the screen, then stop interrupting mouse events through
+        the glass pane.
+        (popupMenuWillBecomeVisible): Add mouseInputListener to glass pane
+        if it was not added before and make glass pane visible in order to
+        interrupt mouse evevents.
+        (MouseInputHandler): Close menu hierarchy if the mouse was clicked
+        on non menu component.
+
+	2005-05-18  Roman Kennke  <roman at kennke.org>
+
+        * javax/swing/JEditorPane.java
+        (isManagingFocus): According to Suns API documentation this
+        method is not implemented in this class. Also the
+        implementation did not add any value. Removed.
+
+	2005-05-18  Roman Kennke  <roman at kennke.org>
+
+        * javax/swing/JSeparator.java
+        (isFocusTraversable): According to Suns API documentation this
+        method is not implemented in this class. Also the
+        implementation did not add any value. Removed.
+
+	2005-05-18  Roman Kennke  <roman at kennke.org>
+
+        * javax/swing/AbstractButton.java
+        (isFocusTraversable): According to Suns API documentation this
+        method is not implemented in this class. Also the
+        implementation did not add any value. Removed.
+
+	2005-05-18  Roman Kennke  <roman at kennke.org>
+
+        * javax/swing/ImageIcon.java
+        (AccessibleImageIcon): Added inner class for Accessibility support
+        in ImageIcon.
+        (getAccessibleContext): Added method for accessibility support
+        in ImageIcon.
+
+	2005-05-18  Thomas Fitzsimmons  <fitzsim at redhat.com>
+
+        * gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java
+        (createCompatibleVolatileImage(int,int)): Implement.
+        (createCompatibleVolatileImage(int,int,ImageCapabilities)):
+        Likewise.
+        * gnu/java/awt/peer/gtk/GtkComponentPeer.java (backBuffer, caps):
+        New fields.
+        (createVolatileImage): Implement.
+        (createBuffers): Likewise.
+        (getBackBuffer): Likewise.
+        (flip): Likewise.
+        (destroyBuffers): Likewise.
+        * gnu/java/awt/peer/gtk/GtkVolatileImage.java: New file.
+        * java/awt/Canvas.java (CanvasBltBufferStrategy): New class.
+        (CanvasFlipBufferStrategy): Likewise.
+        (createBufferStrategy(int)): New method.
+        (createBufferStrategy(int,BufferCapabilities)): Likewise.
+        * java/awt/Component.java (BltBufferStrategy): Implement and
+        document class.
+        (FlipBufferStrategy): Likewise.
+        * java/awt/Window.java (WindowBltBufferStrategy): New class.
+        (WindowFlipBufferStrategy): Likewise.
+        (createBufferStrategy(int)): New method.
+        (createBufferStrategy(int,BufferCapabilities)): Likewise.
+        (getBufferStrategy): Likewise.
+        * java/awt/BufferCapabilities.java (BufferCapabilities): Rename
+        front to frontCaps and back to backCaps.
+
+	2005-05-18  Roman Kennke  <roman at kennke.org>
+
+        * javax/swing/JTable.java:
+        (BooleanCellRenderer): Added default renderer for Boolean cell values.
+        (DateCellRenderer): Added default renderer for Date cell values.
+        (DoubleCellRenderer): Added default renderer for Double cell values.
+        (FloatCellRenderer): Added default renderer for Float cell values.
+        (NumberCellRenderer): Added default renderer for Number cell values.
+        (IconCellRenderer): Added default renderer for Icon cell values.
+        (createDefaultRenderers): Include new default renderers.
+        (distributeSpill): Fix algorithm to do a nice layout, if still not
+        beeing 100% perfect.
+        (doLayout): Correctly calculate the spill variable.
+
+	2005-05-18  Roman Kennke  <roman at kennke.org>
+
+        * java/awt/Window.java
+        (isShowing): A Window can be showing even if its parent is not
+        showing.
+
+2005-05-18  Dalibor Topic  <robilad at kaffe.org>
+
 	Resynced with GNU Classpath.
 
 	2005-05-18  Roman Kennke  <roman at kennke.org>
Index: kaffe/libraries/javalib/all.files
diff -u kaffe/libraries/javalib/all.files:1.126 kaffe/libraries/javalib/all.files:1.127
--- kaffe/libraries/javalib/all.files:1.126	Wed May 18 22:08:55 2005
+++ kaffe/libraries/javalib/all.files	Thu May 19 00:31:16 2005
@@ -723,6 +723,7 @@
 gnu/java/awt/peer/gtk/GtkTextComponentPeer.java
 gnu/java/awt/peer/gtk/GtkTextFieldPeer.java
 gnu/java/awt/peer/gtk/GtkToolkit.java
+gnu/java/awt/peer/gtk/GtkVolatileImage.java
 gnu/java/awt/peer/gtk/GtkWindowPeer.java
 gnu/java/beans/BeanInfoEmbryo.java
 gnu/java/beans/DummyAppletContext.java
Index: kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java
diff -u kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java:1.2 kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java:1.3
--- kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java:1.2	Sat Feb 19 15:30:25 2005
+++ kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java	Thu May 19 00:31:17 2005
@@ -86,14 +86,14 @@
 
   public VolatileImage createCompatibleVolatileImage(int w, int h)
   {
-    throw new java.lang.UnsupportedOperationException ();
+    return new GtkVolatileImage(w, h);
   }
 
   public VolatileImage createCompatibleVolatileImage(int w, int h,
                                                      ImageCapabilities caps)
     throws java.awt.AWTException
   {
-    throw new java.lang.UnsupportedOperationException ();
+    return new GtkVolatileImage(w, h, caps);
   }
 
   public ColorModel getColorModel()
Index: kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkComponentPeer.java
diff -u kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkComponentPeer.java:1.12 kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkComponentPeer.java:1.13
--- kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkComponentPeer.java:1.12	Sat Feb 19 15:30:26 2005
+++ kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkComponentPeer.java	Thu May 19 00:31:17 2005
@@ -39,6 +39,7 @@
 package gnu.java.awt.peer.gtk;
 
 import java.awt.AWTEvent;
+import java.awt.AWTException;
 import java.awt.BufferCapabilities;
 import java.awt.Color;
 import java.awt.Component;
@@ -71,6 +72,9 @@
 public class GtkComponentPeer extends GtkGenericPeer
   implements ComponentPeer
 {
+  VolatileImage backBuffer;
+  BufferCapabilities caps;
+
   Component awtComponent;
 
   Insets insets;
@@ -596,35 +600,63 @@
     
   }
 
-  public VolatileImage createVolatileImage (int width, int height)
-  {
-    return null;
-  }
-
   public boolean handlesWheelScrolling ()
   {
     return false;
   }
 
-  public void createBuffers (int x, BufferCapabilities capabilities)
-    throws java.awt.AWTException
-
+  // Convenience method to create a new volatile image on the screen
+  // on which this component is displayed.
+  public VolatileImage createVolatileImage (int width, int height)
   {
-    
+    return new GtkVolatileImage (width, height);
+  }
+
+  // Creates buffers used in a buffering strategy.
+  public void createBuffers (int numBuffers, BufferCapabilities caps)
+    throws AWTException
+  {
+    // numBuffers == 2 implies double-buffering, meaning one back
+    // buffer and one front buffer.
+    if (numBuffers == 2)
+      backBuffer = new GtkVolatileImage(awtComponent.getWidth(),
+					awtComponent.getHeight(),
+					caps.getBackBufferCapabilities());
+    else
+      throw new AWTException("GtkComponentPeer.createBuffers:"
+			     + " multi-buffering not supported");
+    this.caps = caps;
   }
 
+  // Return the back buffer.
   public Image getBackBuffer ()
   {
-    return null;
+    return backBuffer;
   }
 
+  // FIXME: flip should be implemented as a fast native operation
   public void flip (BufferCapabilities.FlipContents contents)
   {
-    
+    getGraphics().drawImage(backBuffer,
+			    awtComponent.getWidth(),
+			    awtComponent.getHeight(),
+			    null);
+
+    // create new back buffer and clear it to the background color.
+    if (contents == BufferCapabilities.FlipContents.BACKGROUND)
+	{
+	  backBuffer = createVolatileImage(awtComponent.getWidth(),
+					   awtComponent.getHeight());
+	  backBuffer.getGraphics().clearRect(0, 0,
+					     awtComponent.getWidth(),
+					     awtComponent.getHeight());
+	}
+    // FIXME: support BufferCapabilities.FlipContents.PRIOR
   }
 
+  // Release the resources allocated to back buffers.
   public void destroyBuffers ()
   {
-    
+    backBuffer.flush();
   }
 }
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkVolatileImage.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkVolatileImage.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/awt/peer/gtk/GtkVolatileImage.java	Thu May 19 00:36:55 2005
@@ -0,0 +1,118 @@
+/* GtkVolatileImage.java -- a hardware-accelerated image buffer
+   Copyright (C) 2005  Free Software Foundation, Inc.
+
+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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.awt.peer.gtk;
+
+import java.awt.ImageCapabilities;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.image.BufferedImage;
+import java.awt.image.ImageObserver;
+import java.awt.image.VolatileImage;
+
+public class GtkVolatileImage extends VolatileImage
+{
+  private int width;
+  private int height;
+  private ImageCapabilities caps;
+
+  public GtkVolatileImage(int width, int height)
+  {
+    this(width, height, null);
+  }
+
+  public GtkVolatileImage(int width, int height, ImageCapabilities caps)
+  {
+    this.width = width;
+    this.height = height;
+    this.caps = caps;
+  }
+
+  // FIXME: should return a buffered image snapshot of the accelerated
+  // visual
+  public BufferedImage getSnapshot()
+  {
+    return null;
+  }
+
+  public int getWidth()
+  {
+    return width;
+  }
+
+  public int getHeight()
+  {
+    return height;
+  }
+
+  // FIXME: should return a graphics wrapper around this image's
+  // visual
+  public Graphics2D createGraphics()
+  {
+    return null;
+  }
+
+  public int validate(GraphicsConfiguration gc)
+  {
+    return VolatileImage.IMAGE_OK;
+  }
+
+  public boolean contentsLost()
+  {
+    return false;
+  }
+
+  public ImageCapabilities getCapabilities()
+  {
+    return caps;
+  }
+
+  public synchronized Object getProperty (String name, ImageObserver observer)
+  {
+    return null;
+  }
+
+  public synchronized int getWidth (ImageObserver observer)
+  {
+    return width;
+  }
+  
+  public synchronized int getHeight (ImageObserver observer)
+  {
+    return height;
+  }
+}
Index: kaffe/libraries/javalib/java/awt/BufferCapabilities.java
diff -u kaffe/libraries/javalib/java/awt/BufferCapabilities.java:1.5 kaffe/libraries/javalib/java/awt/BufferCapabilities.java:1.6
--- kaffe/libraries/javalib/java/awt/BufferCapabilities.java:1.5	Sun May 15 17:25:11 2005
+++ kaffe/libraries/javalib/java/awt/BufferCapabilities.java	Thu May 19 00:31:17 2005
@@ -132,22 +132,22 @@
   /**
    * Creates a buffer capabilities object.
    *
-   * @param front front buffer capabilities descriptor
-   * @param back back buffer capabilities descriptor
+   * @param frontCaps front buffer capabilities descriptor
+   * @param backCaps back buffer capabilities descriptor
    * @param flip the results of a flip operation or null if
    * flipping is not supported
    *
-   * @exception IllegalArgumentException if front or back is
+   * @exception IllegalArgumentException if frontCaps or backCaps is
    * null
    */
-  public BufferCapabilities(ImageCapabilities front,
-			    ImageCapabilities back,
+  public BufferCapabilities(ImageCapabilities frontCaps,
+			    ImageCapabilities backCaps,
                             FlipContents flip)
   {
-    if (front ==  null || back == null)
+    if (frontCaps ==  null || backCaps == null)
       throw new IllegalArgumentException();
-    this.front = front;
-    this.back = back;
+    this.front = frontCaps;
+    this.back = backCaps;
     this.flip = flip;
   }
 
===================================================================
Checking out kaffe/libraries/javalib/java/awt/Canvas.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/java/awt/Canvas.java,v
VERS: 1.19
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/java/awt/Canvas.java	Thu May 19 00:36:55 2005
@@ -0,0 +1,353 @@
+/* Canvas.java --
+   Copyright (C) 1999, 2000, 2002, 2004  Free Software Foundation
+
+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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt;
+
+import java.awt.image.BufferStrategy;
+import java.awt.peer.ComponentPeer;
+import java.io.Serializable;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+
+/**
+ * The <code>Canvas</code> component provides a blank rectangular
+ * area, which the client application can use for drawing and for
+ * capturing events.  By overriding the <code>paint()</code> method,
+ * the canvas can be used for anything from simple line drawings to
+ * full-scale custom components.
+ *
+ * @author Original author unknown
+ * @author Tom Tromey  (tromey at redhat.com)
+ * @author Andrew John Hughes  (gnu_andrew at member.fsf.org)
+ * @since 1.0
+ */
+
+public class Canvas
+  extends Component
+  implements Serializable, Accessible
+{
+
+  /**
+   * Compatible with Sun's JDK.
+   */
+  private static final long serialVersionUID = -2284879212465893870L;
+
+  /**
+   * The graphics configuration associated with the canvas.
+   */
+  transient GraphicsConfiguration graphicsConfiguration;
+
+  /**
+   * The buffer strategy associated with this canvas.
+   */
+  transient BufferStrategy bufferStrategy;
+
+  /**
+   * Initializes a new instance of <code>Canvas</code>.
+   */
+  public Canvas() 
+  { 
+  }
+
+  /**
+   * Initializes a new instance of <code>Canvas</code>
+   * with the supplied graphics configuration.
+   *
+   * @param graphicsConfiguration the graphics configuration to use
+   *        for this particular canvas.
+   */
+  public Canvas(GraphicsConfiguration graphicsConfiguration)
+  {
+    this.graphicsConfiguration = graphicsConfiguration;
+  }
+
+  GraphicsConfiguration getGraphicsConfigurationImpl()
+  {
+    if (graphicsConfiguration != null)
+      return graphicsConfiguration;
+    return super.getGraphicsConfigurationImpl();
+  }
+
+  /**
+   * Creates the native peer for this object.
+   */
+  public void addNotify()
+  {
+    if (peer == null)
+      peer = (ComponentPeer) getToolkit().createCanvas(this);
+    super.addNotify();
+  }
+
+  /**
+   * Repaints the canvas window.  This method should be overridden by 
+   * a subclass to do something useful, as this method simply paints
+   * the window with the background color.
+   *
+   * @param gfx the <code>Graphics</code> to use for painting
+   */
+  public void paint(Graphics gfx)
+  {
+    /* This implementation doesn't make much sense since the filling
+      of background color is guaranteed for heavyweight components
+      such as this.  But there's no need to worry, since paint() is
+      usually overridden anyway.  */
+    gfx.setColor(getBackground());
+    Dimension size = getSize();
+    gfx.fillRect(0, 0, size.width, size.height);
+  }
+
+  /**
+   * This class provides accessibility support for the canvas.
+   */
+  protected class AccessibleAWTCanvas
+    extends AccessibleAWTComponent
+  {
+    /**
+     * For compatability with Sun's JDK
+     */
+    private static final long serialVersionUID = -6325592262103146699L;
+
+    /**
+     * Constructor for the accessible canvas.
+     */
+    protected AccessibleAWTCanvas()
+    {
+    }
+
+    /**
+     * Returns the accessible role for the canvas.
+     *
+     * @return an instance of <code>AccessibleRole</code>, describing
+     *         the role of the canvas.
+     */
+    public AccessibleRole getAccessibleRole()
+    {
+      return AccessibleRole.CANVAS;
+    }
+    
+  }
+
+  /**
+   * Gets the AccessibleContext associated with this <code>Canvas</code>.
+   * The context is created, if necessary.
+   *
+   * @return the associated context
+   */
+  public AccessibleContext getAccessibleContext()
+  {
+    /* Create the context if this is the first request */
+    if (accessibleContext == null)
+      accessibleContext = new AccessibleAWTCanvas();
+    return accessibleContext;
+  }
+
+  /**
+   * A BltBufferStrategy for canvases.
+   */
+  private class CanvasBltBufferStrategy extends BltBufferStrategy
+  {
+    /**
+     * Creates a block transfer strategy for this canvas.
+     *
+     * @param numBuffers the number of buffers in this strategy
+     * @param accelerated true if the buffer should be accelerated,
+     * false otherwise
+     */
+    CanvasBltBufferStrategy(int numBuffers, boolean accelerated)
+    {
+      super(numBuffers,
+	    new BufferCapabilities(new ImageCapabilities(accelerated),
+				   new ImageCapabilities(accelerated),
+				   BufferCapabilities.FlipContents.COPIED));
+    }
+  }
+
+  /**
+   * A FlipBufferStrategy for canvases.
+   */
+  private class CanvasFlipBufferStrategy extends FlipBufferStrategy
+  {
+    /**
+     * Creates a flip buffer strategy for this canvas.
+     *
+     * @param numBuffers the number of buffers in this strategy
+     *
+     * @throws AWTException if the requested number of buffers is not
+     * supported
+     */
+    CanvasFlipBufferStrategy(int numBuffers)
+      throws AWTException
+    {
+      super(numBuffers,
+	    new BufferCapabilities(new ImageCapabilities(true),
+				   new ImageCapabilities(true),
+				   BufferCapabilities.FlipContents.COPIED));
+    }
+  }
+
+  /**
+   * Creates a buffering strategy that manages how this canvas is
+   * repainted.  This method attempts to create the optimum strategy
+   * based on the desired number of buffers.  Hardware or software
+   * acceleration may be used.
+   *
+   * createBufferStrategy attempts different levels of optimization,
+   * but guarantees that some strategy with the requested number of
+   * buffers will be created even if it is not optimal.  First it
+   * attempts to create a page flipping strategy, then an accelerated
+   * blitting strategy, then an unaccelerated blitting strategy.
+   *
+   * Calling this method causes any existing buffer strategy to be
+   * destroyed.
+   *
+   * @param numBuffers the number of buffers in this strategy
+   *
+   * @throws IllegalArgumentException if requested number of buffers
+   * is less than one
+   * @throws IllegalStateException if this canvas is not displayable
+   *
+   * @since 1.4
+   */
+  public void createBufferStrategy(int numBuffers)
+  {
+    if (numBuffers < 1)
+      throw new IllegalArgumentException("Canvas.createBufferStrategy: number"
+					 + " of buffers is less than one");
+
+    if (!isDisplayable())
+      throw new IllegalStateException("Canvas.createBufferStrategy: canvas is"
+				      + " not displayable");
+
+    // try a flipping strategy
+    try
+      {
+	bufferStrategy = new CanvasFlipBufferStrategy(numBuffers);
+	return;
+      }
+    catch (AWTException e)
+      {
+      }
+
+    // try an accelerated blitting strategy
+    bufferStrategy = new CanvasBltBufferStrategy(numBuffers, true);
+
+    // fall back to an unaccelerated blitting strategy
+    bufferStrategy = new CanvasBltBufferStrategy(numBuffers, false);
+  }
+
+  /**
+   * Creates a buffering strategy that manages how this canvas is
+   * repainted.  This method attempts to create a strategy based on
+   * the specified capabilities and throws an exception if the
+   * requested strategy is not supported.
+   *
+   * Calling this method causes any existing buffer strategy to be
+   * destroyed.
+   *
+   * @param numBuffers the number of buffers in this strategy
+   * @param caps the requested buffering capabilities
+   *
+   * @throws AWTException if the requested capabilities are not
+   * supported
+   * @throws IllegalArgumentException if requested number of buffers
+   * is less than one or if caps is null
+   *
+   * @since 1.4
+   */
+  public void createBufferStrategy(int numBuffers,
+				   BufferCapabilities caps)
+  {
+    if (numBuffers < 1)
+      throw new IllegalArgumentException("Canvas.createBufferStrategy: number"
+					 + " of buffers is less than one");
+
+    if (caps == null)
+      throw new IllegalArgumentException("Canvas.createBufferStrategy:"
+					 + " capabilities object is null");
+
+    // a flipping strategy was requested
+    if (caps.isPageFlipping())
+      {
+	try
+	  {
+	    bufferStrategy = new CanvasFlipBufferStrategy(numBuffers);
+	  }
+	catch (AWTException e)
+	  {
+	  }
+      }
+    else
+      bufferStrategy = new CanvasBltBufferStrategy(numBuffers, true);
+  }
+
+  /**
+   * Returns the buffer strategy used by the canvas.
+   *
+   * @return the buffer strategy.
+   * @since 1.4
+   */
+  public BufferStrategy getBufferStrategy()
+  {
+    return bufferStrategy;
+  }
+
+  /**
+   * Updates the canvas in response to a request to
+   * <code>repaint()</code> it.  The canvas is cleared
+   * with the current background colour, before <code>paint()</code>
+   * is called to add the new contents.  Subclasses
+   * which override this method should either call this
+   * method via <code>super.update(graphics)</code> or re-implement
+   * this behaviour, so as to ensure that the canvas is
+   * clear before painting takes place.
+   *
+   * @param graphics the graphics context.
+   */
+  public void update(Graphics graphics)
+  {
+    Dimension size;
+
+    /* Clear the canvas */
+    size = getSize();
+    graphics.clearRect(0, 0, size.width, size.height);
+    /* Call the paint method */
+    paint(graphics);
+  }
+}
===================================================================
Checking out kaffe/libraries/javalib/java/awt/Component.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/java/awt/Component.java,v
VERS: 1.51
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/java/awt/Component.java	Thu May 19 00:36:55 2005
@@ -0,0 +1,6005 @@
+/* Component.java -- a graphics component
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004  Free Software Foundation
+
+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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt;
+
+import java.awt.dnd.DropTarget;
+import java.awt.event.ActionEvent;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.HierarchyBoundsListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
+import java.awt.event.InputEvent;
+import java.awt.event.InputMethodEvent;
+import java.awt.event.InputMethodListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
+import java.awt.event.PaintEvent;
+import java.awt.event.WindowEvent;
+import java.awt.im.InputContext;
+import java.awt.im.InputMethodRequests;
+import java.awt.image.BufferStrategy;
+import java.awt.image.ColorModel;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.image.VolatileImage;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.LightweightPeer;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.util.Collections;
+import java.util.EventListener;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleComponent;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+
+/**
+ * The root of all evil. All graphical representations are subclasses of this
+ * giant class, which is designed for screen display and user interaction.
+ * This class can be extended directly to build a lightweight component (one
+ * not associated with a native window); lightweight components must reside
+ * inside a heavyweight window.
+ *
+ * <p>This class is Serializable, which has some big implications. A user can
+ * save the state of all graphical components in one VM, and reload them in
+ * another. Note that this class will only save Serializable listeners, and
+ * ignore the rest, without causing any serialization exceptions. However, by
+ * making a listener serializable, and adding it to another element, you link
+ * in that entire element to the state of this component. To get around this,
+ * use the idiom shown in the example below - make listeners non-serializable
+ * in inner classes, rather than using this object itself as the listener, if
+ * external objects do not need to save the state of this object.
+ *
+ * <pre>
+ * import java.awt.*;
+ * import java.awt.event.*;
+ * import java.io.Serializable;
+ * class MyApp implements Serializable
+ * {
+ *   BigObjectThatShouldNotBeSerializedWithAButton bigOne;
+ *   // Serializing aButton will not suck in an instance of MyApp, with its
+ *   // accompanying field bigOne.
+ *   Button aButton = new Button();
+ *   class MyActionListener implements ActionListener
+ *   {
+ *     public void actionPerformed(ActionEvent e)
+ *     {
+ *       System.out.println("Hello There");
+ *     }
+ *   }
+ *   MyApp()
+ *   {
+ *     aButton.addActionListener(new MyActionListener());
+ *   }
+ * }
+ * </pre>
+ *
+ * <p>Status: Incomplete. The event dispatch mechanism is implemented. All
+ * other methods defined in the J2SE 1.3 API javadoc exist, but are mostly
+ * incomplete or only stubs; except for methods relating to the Drag and
+ * Drop, Input Method, and Accessibility frameworks: These methods are
+ * present but commented out.
+ *
+ * @author original author unknown
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.0
+ * @status still missing 1.4 support
+ */
+public abstract class Component
+  implements ImageObserver, MenuContainer, Serializable
+{
+  // Word to the wise - this file is huge. Search for '\f' (^L) for logical
+  // sectioning by fields, public API, private API, and nested classes.
+
+
+  /**
+   * Compatible with JDK 1.0+.
+   */
+  private static final long serialVersionUID = -7644114512714619750L;
+
+  /**
+   * Constant returned by the <code>getAlignmentY</code> method to indicate
+   * that the component wishes to be aligned to the top relative to
+   * other components.
+   *
+   * @see #getAlignmentY()
+   */
+  public static final float TOP_ALIGNMENT = 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.
+   *
+   * @see #getAlignmentX()
+   * @see #getAlignmentY()
+   */
+  public static final float CENTER_ALIGNMENT = 0.5f;
+
+  /**
+   * Constant returned by the <code>getAlignmentY</code> method to indicate
+   * that the component wishes to be aligned to the bottom relative to
+   * other components.
+   *
+   * @see #getAlignmentY()
+   */
+  public static final float BOTTOM_ALIGNMENT = 1;
+
+  /**
+   * Constant returned by the <code>getAlignmentX</code> method to indicate
+   * that the component wishes to be aligned to the right relative to

*** Patch too long, truncated ***




More information about the kaffe mailing list