Here come some more fixes for the X peers:

- XGraphics.setColor() must map the RGB values to some colors that X can understand. Otherwise we get very strange looking results on systems that are not configured for 24-bit TrueColor. - XGraphics is now a subclass of Graphics, rather than Graphics2D. I don't intend to implement Graphics2D on plain X, but will implement the GLGraphics at some time later.
- I now support creating Dialogs.
- XFramePeer is now a subclass of XWindowPeer, rather than SwingFramePeer. This avoids lots of code duplication.
- A couple of smaller fixes and additions, see below.

2006-07-18  Roman Kennke  <[EMAIL PROTECTED]>

        * gnu/java/awt/peer/x/XDialogPeer.java: New class.
        * gnu/java/awt/peer/x/XEventPump.java
        (handleEvent): Cast to XWindowPeer rather than XFramePeer.
        * gnu/java/awt/peer/x/XFramePeer.java
        Made a subclass of XWindowPeer, rather than SwingFramePeer.
        * gnu/java/awt/peer/x/XGraphics.java
        Made subclass of Graphics rather than Graphics2D. Removed
        all Graphics2D specific method stubs.
        (setColor): Map colors using the X color map that is
        stored in XToolkit.
        * gnu/java/awt/peer/x/XToolkit.java
        (colorMap): New field.
        (getLocalGraphicsEnvironment): Return new XGraphicsEnvironment
        instance.
        (createDialog): Implemented.
        (createImage(ImageProducer)): Implemented.
        (createImage(InputStream)): Use createImage(ImageProducer)
        to convert the BufferedImage to an XImage.
        * gnu/java/awt/peer/x/XWindowPeer.java
        (XWindowPeer): Removed debug output.

/Roman
Index: gnu/java/awt/peer/x/XDialogPeer.java
===================================================================
RCS file: gnu/java/awt/peer/x/XDialogPeer.java
diff -N gnu/java/awt/peer/x/XDialogPeer.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/peer/x/XDialogPeer.java	18 Jul 2006 10:22:34 -0000
@@ -0,0 +1,61 @@
+/* XDialogPeer.java -- The peer for AWT dialogs
+   Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.x;
+
+import java.awt.Dialog;
+import java.awt.peer.DialogPeer;
+
+public class XDialogPeer
+  extends XWindowPeer
+  implements DialogPeer
+{
+
+  XDialogPeer(Dialog target)
+  {
+    super(target);
+  }
+
+  public void setResizable(boolean resizeable)
+  {
+  }
+
+  public void setTitle(String title)
+  {
+  }
+}
Index: gnu/java/awt/peer/x/XEventPump.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/x/XEventPump.java,v
retrieving revision 1.1
diff -u -1 -2 -r1.1 XEventPump.java
--- gnu/java/awt/peer/x/XEventPump.java	29 Jun 2006 15:15:56 -0000	1.1
+++ gnu/java/awt/peer/x/XEventPump.java	18 Jul 2006 10:22:34 -0000
@@ -198,27 +198,27 @@
       ConfigureNotify c = (ConfigureNotify) xEvent;
       if (XToolkit.DEBUG)
         System.err.println("resize request for window id: " + key);
 
       // Detect and report size changes.
       if (c.width() != awtWindow.getWidth()
           || c.height() != awtWindow.getHeight())
         {
           if (XToolkit.DEBUG)
             System.err.println("Setting size on AWT window: " + c.width()
                              + ", " + c.height() + ", " + awtWindow.getWidth()
                              + ", " + awtWindow.getHeight());
-          ((XFramePeer) awtWindow.getPeer()).callback = true;
+          ((XWindowPeer) awtWindow.getPeer()).callback = true;
           awtWindow.setSize(c.width(), c.height());
-          ((XFramePeer) awtWindow.getPeer()).callback = false;
+          ((XWindowPeer) awtWindow.getPeer()).callback = false;
         }
       break;
     case Expose.CODE:
       Expose exp = (Expose) xEvent;
       if (XToolkit.DEBUG)
         System.err.println("expose request for window id: " + key);
       Rectangle r = new Rectangle(exp.x(), exp.y(), exp.width(),
                                   exp.height());
       //System.err.println("expose paint: " + r);
       // We need to clear the background of the exposed rectangle.
       Graphics g = awtWindow.getGraphics();
       g.clearRect(r.x, r.y, r.width, r.height);
Index: gnu/java/awt/peer/x/XFramePeer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/x/XFramePeer.java,v
retrieving revision 1.1
diff -u -1 -2 -r1.1 XFramePeer.java
--- gnu/java/awt/peer/x/XFramePeer.java	29 Jun 2006 15:15:56 -0000	1.1
+++ gnu/java/awt/peer/x/XFramePeer.java	18 Jul 2006 10:22:35 -0000
@@ -37,285 +37,104 @@
 
 
 package gnu.java.awt.peer.x;
 
 import java.awt.Component;
 import java.awt.EventQueue;
 import java.awt.Font;
 import java.awt.FontMetrics;
 import java.awt.Frame;
 import java.awt.Graphics;
 import java.awt.Image;
 import java.awt.Insets;
+import java.awt.MenuBar;
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.event.PaintEvent;
 import java.awt.event.WindowEvent;
+import java.awt.peer.FramePeer;
 
 import gnu.java.awt.peer.swing.SwingFramePeer;
 import gnu.x11.Window;
 import gnu.x11.event.Event;
 
 public class XFramePeer
-  extends SwingFramePeer
+  extends XWindowPeer
+  implements FramePeer
 {
 
-  private static int standardSelect = Event.BUTTON_PRESS_MASK
-                                      | Event.BUTTON_RELEASE_MASK
-                                      | Event.POINTER_MOTION_MASK
-                                      //| Event.RESIZE_REDIRECT_MASK
-                                      | Event.EXPOSURE_MASK
-                                      //| Event.PROPERTY_CHANGE_MASK
-                                      | Event.STRUCTURE_NOTIFY_MASK
-                                      | Event.KEY_PRESS_MASK
-                                      | Event.KEY_RELEASE_MASK
-                                      ;
-
-  /**
-   * The X window.
-   */
-  private Window xwindow;
-
-  /**
-   * Indicates if we are in callback mode, that is when a property (like size)
-   * is changed in reponse to a request from the X server and doesn't need
-   * to be propagated back to the X server.
-   */
-  boolean callback = false;
-
-  public XFramePeer(Frame frame)
+  XFramePeer(Frame f)
   {
-    super(frame);
-    XGraphicsDevice dev = XToolkit.getDefaultDevice();
-
-    // TODO: Maybe initialize lazily in show().
-    int x = Math.max(frame.getX(), 0);
-    int y = Math.max(frame.getY(), 0);
-    int w = Math.max(frame.getWidth(), 1);
-    int h = Math.max(frame.getHeight(), 1);
-    xwindow = new Window(dev.getDisplay().default_root, x, y, w, h);
-    xwindow.create();
-    xwindow.select_input(standardSelect);
-    dev.getEventPump().registerWindow(xwindow, frame);
+    super(f);
   }
 
   public void setIconImage(Image image)
   {
     // TODO: Implement this.
     throw new UnsupportedOperationException("Not yet implemented.");
   }
 
+  public void setMenuBar(MenuBar mb)
+  {
+    // TODO: Implement this.
+    throw new UnsupportedOperationException("Not yet implemented.");
+  }
+
   public void setResizable(boolean resizable)
   {
     // TODO: Implement this.
     throw new UnsupportedOperationException("Not yet implemented.");
   }
 
   public void setTitle(String title)
   {
     // TODO: Implement this.
     throw new UnsupportedOperationException("Not yet implemented.");
   }
 
   public int getState()
   {
     // TODO: Implement this.
     throw new UnsupportedOperationException("Not yet implemented.");
   }
 
   public void setState(int state)
   {
-    // FIXME: Implement this.
+    // TODO: Implement this.
     throw new UnsupportedOperationException("Not yet implemented.");
   }
 
   public void setMaximizedBounds(Rectangle r)
   {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented.");
-  }
-
-  public void setBoundsPrivate(int x, int y, int width, int height)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented.");
-  }
-
-  public void toBack()
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented.");
-  }
-
-  public void toFront()
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented.");
-  }
-
-  public void updateAlwaysOnTop()
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented.");
-  }
-
-  public boolean requestWindowFocus()
-  {
-    // FIXME: Implement this.
+    // TODO: Implement this.
     throw new UnsupportedOperationException("Not yet implemented.");
   }
-
-  public Point getLocationOnScreen()
-  {
-    return new Point(xwindow.x, xwindow.y);
-  }
-
-  /**
-   * Returns a XGraphics suitable for drawing on this frame.
-   *
-   * @return a XGraphics suitable for drawing on this frame
-   */
-  public Graphics getGraphics()
-  {
-    return new XGraphics(xwindow);
-  }
-
-  public Image createImage(int w, int h)
-  {
-    return new XImage(w, h);
-  }
-
-  /**
-   * Sets the visibility state of the component. This is called by
-   * [EMAIL PROTECTED] Component#setVisible(boolean)}.
-   *
-   * This is implemented to call setVisible() on the Swing component.
-   *
-   * @param visible <code>true</code> to make the component visible,
-   *        <code>false</code> to make it invisible
-   */
-  public void setVisible(boolean visible)
-  {
-    if (visible)
-      show();
-    else
-      hide();
-  }
-
-  /**
-   * Makes the component visible. This is called by [EMAIL PROTECTED] Component#show()}.
-   *
-   * This is implemented to call setVisible(true) on the Swing component.
-   */
-  public void show()
-  {
-//    // Prevent ResizeRedirect events.
-//    //xwindow.select_input(noResizeRedirectSelect);
-//    Window.Attributes atts = new Window.Attributes();
-//    atts.set_override_redirect(true);
-//    xwindow.change_attributes(atts);
-
-    // Prevent ResizeRedirect events.
-    //xwindow.select_input(Event.NO_EVENT_MASK);
-    //xwindow.select_input(noResizeRedirectSelect);
-
-    xwindow.map();
-    EventQueue eq = XToolkit.getDefaultToolkit().getSystemEventQueue();
-    java.awt.Window w = (java.awt.Window) super.awtComponent;
-    eq.postEvent(new WindowEvent(w, WindowEvent.WINDOW_OPENED));
-    eq.postEvent(new PaintEvent(w, PaintEvent.PAINT,
-                                new Rectangle(0, 0, w.getWidth(),
-                                              w.getHeight())));
-
-//    // Reset input selection.
-//    atts.set_override_redirect(false);
-//    xwindow.change_attributes(atts);
-  }
-
-  /**
-   * Makes the component invisible. This is called from
-   * [EMAIL PROTECTED] Component#hide()}.
-   *
-   * This is implemented to call setVisible(false) on the Swing component.
-   */
-  public void hide()
-  {
-    xwindow.unmap();
-  }
-
-  /**
-   * Notifies the peer that the bounds of this component have changed. This
-   * is called by [EMAIL PROTECTED] Component#reshape(int, int, int, int)}.
-   *
-   * This is implemented to call setBounds() on the Swing component.
-   *
-   * @param x the X coordinate of the upper left corner of the component
-   * @param y the Y coordinate of the upper left corner of the component
-   * @param width the width of the component
-   * @param height the height of the component
-   */
-  public void reshape(int x, int y, int width, int height)
-  {
-//    if (callback)
-//      return;
-
-    // Prevent ResizeRedirect events.
-//    //xwindow.select_input(noResizeRedirectSelect);
-//    Window.Attributes atts = new Window.Attributes();
-//    atts.set_override_redirect(true);
-//    xwindow.change_attributes(atts);
-
-    // Need to substract insets because AWT size is including insets,
-    // and X size is excuding insets.
-    Insets i = insets();
-    xwindow.move_resize(x - i.left, y - i.right, width - i.left - i.right,
-                        height - i.top - i.bottom);
-
-    // Reset input selection.
-//    atts = new Window.Attributes();
-//    atts.set_override_redirect(false);
-//    xwindow.change_attributes(atts);
-  }
-
-  public Insets insets()
-  {
-    Insets i = new Insets(0, 0, 0, 0);
-//    Window.GeometryReply g = xwindow.geometry();
-//    int b = g.border_width();
-//    Insets i = new Insets(b, b, b, b);
-//    Window.WMSizeHints wmSize = xwindow.wm_normal_hints();
-//    if (wmSize != null)
-//      {
-//        i.left = wmSize.x() - g.x();
-//        i.right = wmSize.width() - g.width() - i.left ;
-//        i.top = wmSize.y() - g.y();
-//        i.bottom = wmSize.height() - g.height() - i.top;
-//      }
-//    System.err.println("insets: " + i);
-    return i;
-  }
-
+  
   /**
-   * Returns the font metrics for the specified font.
-   *
-   * @return the font metrics for the specified font
+   * Check if this frame peer supports being restacked.
+   * 
+   * @return true if this frame peer can be restacked,
+   * false otherwise
+   * @since 1.5
    */
-  public FontMetrics getFontMetrics(Font font)
+  public boolean isRestackSupported()
   {
-    XFontPeer fontPeer = (XFontPeer) font.getPeer();
-    return fontPeer.getFontMetrics(font);
+    // TODO: Implement this.
+    throw new UnsupportedOperationException("Not yet implemented.");
   }
-
+  
   /**
-   * Unregisters the window in the event pump when it is closed.
+   * Sets the bounds of this frame peer.
+   * 
+   * @param x the new x co-ordinate
+   * @param y the new y co-ordinate
+   * @param width the new width
+   * @param height the new height
+   * @since 1.5
    */
-  protected void finalize()
+  public void setBoundsPrivate(int x, int y, int width, int height)
   {
-    XGraphicsDevice dev = XToolkit.getDefaultDevice();
-    dev.getEventPump().unregisterWindow(xwindow);
+    // TODO: Implement this.
+    throw new UnsupportedOperationException("Not yet implemented.");
   }
 
-  public Rectangle getBounds()
-  {
-    return new Rectangle(xwindow.x, xwindow.y, xwindow.width, xwindow.height);
-  }
 }
Index: gnu/java/awt/peer/x/XGraphics.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/x/XGraphics.java,v
retrieving revision 1.2
diff -u -1 -2 -r1.2 XGraphics.java
--- gnu/java/awt/peer/x/XGraphics.java	17 Jul 2006 15:08:04 -0000	1.2
+++ gnu/java/awt/peer/x/XGraphics.java	18 Jul 2006 10:22:35 -0000
@@ -29,58 +29,59 @@
 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.x;
 
+import gnu.x11.Colormap;
 import gnu.x11.Drawable;
 import gnu.x11.GC;
 import gnu.x11.Pixmap;
 import gnu.x11.Point;
 
 import java.awt.AWTError;
 import java.awt.Color;
 import java.awt.Composite;
 import java.awt.Font;
 import java.awt.FontMetrics;
 import java.awt.Graphics;
-import java.awt.Graphics2D;
 import java.awt.GraphicsConfiguration;
 import java.awt.Image;
 import java.awt.Paint;
 import java.awt.Rectangle;
 import java.awt.RenderingHints;
 import java.awt.Shape;
 import java.awt.Stroke;
+import java.awt.Toolkit;
 import java.awt.RenderingHints.Key;
 import java.awt.font.FontRenderContext;
 import java.awt.font.GlyphVector;
 import java.awt.geom.AffineTransform;
 import java.awt.image.BufferedImage;
 import java.awt.image.BufferedImageOp;
 import java.awt.image.ImageObserver;
 import java.awt.image.ImageProducer;
 import java.awt.image.RenderedImage;
 import java.awt.image.renderable.RenderableImage;
 import java.text.AttributedCharacterIterator;
-import java.util.Map;
+import java.util.HashMap;
 
 public class XGraphics
-  extends Graphics2D
+  extends Graphics
   implements Cloneable
 {
 
   /**
    * The X Drawable to draw on.
    */
   private Drawable xdrawable;
 
   /**
    * The X graphics context (GC).
    */
   private GC xgc;
@@ -162,25 +163,36 @@
   }
 
   /**
    * Sets the current foreground color. A <code>null</code> value doesn't
    * change the current setting.
    *
    * @param c the foreground color to set
    */
   public void setColor(Color c)
   {
     if (c != null)
       {
-        xgc.set_foreground(c.getRGB());
+        XToolkit tk = (XToolkit) Toolkit.getDefaultToolkit();
+        HashMap colorMap = tk.colorMap;
+        gnu.x11.Color col = (gnu.x11.Color) colorMap.get(c);
+        if (col == null)
+          {
+            Colormap map = xdrawable.display.default_colormap;
+            col = map.alloc_color (c.getRed() * 256,
+                                   c.getGreen() * 256,
+                                   c.getBlue() * 256);
+            colorMap.put(c, col);
+          }
+        xgc.set_foreground(col);
         foreground = c;
       }
   }
 
   public void setPaintMode()
   {
     // FIXME: Implement this.
     throw new UnsupportedOperationException("Not yet implemented");
   }
 
   public void setXORMode(Color color)
   {
@@ -581,231 +593,24 @@
    * Frees any resources associated with this object.
    */
   public void dispose()
   {
     xdrawable.display.flush();
     if (! disposed)
       {
         xgc.free();
         disposed = true;
       }
   }
 
-  // Additional Graphics2D methods.
-  
-  public void draw(Shape shape)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public boolean drawImage(Image image, AffineTransform xform, ImageObserver obs)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void drawRenderedImage(RenderedImage image, AffineTransform xform)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void drawRenderableImage(RenderableImage image, AffineTransform xform)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void drawString(String text, float x, float y)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void drawString(AttributedCharacterIterator iterator, float x, float y)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void fill(Shape shape)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public boolean hit(Rectangle rect, Shape text, boolean onStroke)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public GraphicsConfiguration getDeviceConfiguration()
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void setComposite(Composite comp)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void setPaint(Paint paint)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void setStroke(Stroke stroke)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void setRenderingHint(Key hintKey, Object hintValue)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public Object getRenderingHint(Key hintKey)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void setRenderingHints(Map hints)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void addRenderingHints(Map hints)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public RenderingHints getRenderingHints()
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void translate(double tx, double ty)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void rotate(double theta)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void rotate(double theta, double x, double y)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void scale(double scaleX, double scaleY)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void shear(double shearX, double shearY)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void transform(AffineTransform Tx)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void setTransform(AffineTransform Tx)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public AffineTransform getTransform()
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public Paint getPaint()
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public Composite getComposite()
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void setBackground(Color color)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public Color getBackground()
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public Stroke getStroke()
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void clip(Shape s)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public FontRenderContext getFontRenderContext()
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-  public void drawGlyphVector(GlyphVector g, float x, float y)
-  {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
-  }
-
-
   // Additional helper methods.
 
   /**
    * Creates and returns an exact copy of this XGraphics.
    */
   protected Object clone()
   {
     try
       {
         XGraphics copy = (XGraphics) super.clone();
         copy.xgc = xgc.copy();
 
Index: gnu/java/awt/peer/x/XToolkit.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/x/XToolkit.java,v
retrieving revision 1.4
diff -u -1 -2 -r1.4 XToolkit.java
--- gnu/java/awt/peer/x/XToolkit.java	17 Jul 2006 08:30:37 -0000	1.4
+++ gnu/java/awt/peer/x/XToolkit.java	18 Jul 2006 10:22:35 -0000
@@ -123,24 +123,29 @@
 import gnu.java.awt.peer.swing.SwingPanelPeer;
 
 public class XToolkit
   extends ClasspathToolkit
 {
 
   /**
    * Set to true to enable debug output.
    */
   static boolean DEBUG = false;
 
   /**
+   * Maps AWT colors to X colors.
+   */
+  HashMap colorMap = new HashMap();
+
+  /**
    * The system event queue.
    */
   private EventQueue eventQueue;
 
   /**
    * The default color model of this toolkit.
    */
   private ColorModel colorModel;
 
   /**
    * Maps image URLs to Image instances.
    */
@@ -151,26 +156,25 @@
    */
   private WeakHashMap fontCache = new WeakHashMap();
 
   public XToolkit()
   {
     SystemProperties.setProperty("gnu.javax.swing.noGraphics2D", "true");
     SystemProperties.setProperty("java.awt.graphicsenv",
                                  "gnu.java.awt.peer.x.XGraphicsEnvironment");
   }
 
   public GraphicsEnvironment getLocalGraphicsEnvironment()
   {
-    assert false : "Don't call this";
-    return null;
+    return new XGraphicsEnvironment();
   }
 
   /**
    * Returns the font peer for a font with the specified name and attributes.
    *
    * @param name the font name
    * @param attrs the font attributes
    *
    * @return the font peer for a font with the specified name and attributes
    */
   public ClasspathFontPeer getClasspathFontPeer(String name, Map attrs)
   {
@@ -277,26 +281,25 @@
   protected PanelPeer createPanel(Panel target)
   {
     return new SwingPanelPeer(target);
   }
 
   protected WindowPeer createWindow(Window target)
   {
     return new XWindowPeer(target);
   }
 
   protected DialogPeer createDialog(Dialog target)
   {
-    // TODO: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented.");
+    return new XDialogPeer(target);
   }
 
   protected MenuBarPeer createMenuBar(MenuBar target)
   {
     // TODO: Implement this.
     throw new UnsupportedOperationException("Not yet implemented.");
   }
 
   protected MenuPeer createMenu(Menu target)
   {
     // TODO: Implement this.
     throw new UnsupportedOperationException("Not yet implemented.");
@@ -490,54 +493,54 @@
     // Images are loaded synchronously, so we don't bother and return true.
     return true;
   }
 
   public int checkImage(Image image, int width, int height, ImageObserver observer)
   {
     // TODO: Implement this.
     throw new UnsupportedOperationException("Not yet implemented.");
   }
 
   public Image createImage(ImageProducer producer)
   {
-    // TODO: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented.");
+    ImageConverter conv = new ImageConverter();
+    producer.startProduction(conv);
+    Image image = conv.getXImage();
+    return image;
   }
 
   public Image createImage(byte[] data, int offset, int len)
   {
     Image image;
     try
       {
         ByteArrayInputStream i = new ByteArrayInputStream(data, offset, len);
         image = createImage(i);
       }
     catch (IOException ex)
       {
         image = createErrorImage();
       }
     return image;
   }
 
   private Image createImage(InputStream i)
     throws IOException
   {
     Image image;
     BufferedImage buffered = ImageIO.read(i);
     if (buffered != null)
       {
-        ImageConverter conv = new ImageConverter();
         ImageProducer source = buffered.getSource();
-        source.startProduction(conv);
-        image = conv.getXImage();
+        image = createImage(source);
       }
     else
       {
         image = createErrorImage();
       }
     return image;
   }
 
   public PrintJob getPrintJob(Frame frame, String title, Properties props)
   {
     // TODO: Implement this.
     throw new UnsupportedOperationException("Not yet implemented.");
Index: gnu/java/awt/peer/x/XWindowPeer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/x/XWindowPeer.java,v
retrieving revision 1.1
diff -u -1 -2 -r1.1 XWindowPeer.java
--- gnu/java/awt/peer/x/XWindowPeer.java	29 Jun 2006 15:15:56 -0000	1.1
+++ gnu/java/awt/peer/x/XWindowPeer.java	18 Jul 2006 10:22:35 -0000
@@ -76,25 +76,24 @@
    * to be propagated back to the X server.
    */
   boolean callback = false;
 
   /**
    * The X window.
    */
   private Window xwindow;
 
   XWindowPeer(java.awt.Window window)
   {
     super(window);
-    System.err.println("new XWindowPeer");
     XGraphicsDevice dev = XToolkit.getDefaultDevice();
 
     // TODO: Maybe initialize lazily in show().
     // FIXME: Howto generate a Window without decorations?
     int x = Math.max(window.getX(), 0);
     int y = Math.max(window.getY(), 0);
     int w = Math.max(window.getWidth(), 1);
     int h = Math.max(window.getHeight(), 1);
     xwindow = new Window(dev.getDisplay().default_root, x, y, w, h);
     xwindow.create();
     xwindow.select_input(standardSelect);
     dev.getEventPump().registerWindow(xwindow, window);

Reply via email to