diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-07-16 21:51:51 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-07-16 21:51:51 +0000 |
commit | 70d3ca5f03432c9893f4231b9037138e2c5f79d4 (patch) | |
tree | 8f67b77f9ca1944a0946a513046b6a78b7620c30 /gnu/java/awt | |
parent | 2191b1e9ed92cdbb924b5adb5be121a018eea109 (diff) | |
download | classpath-70d3ca5f03432c9893f4231b9037138e2c5f79d4.tar.gz |
2006-07-16 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD --> generics-branch for
2006/07/09 to 2006/07/16.
Diffstat (limited to 'gnu/java/awt')
-rw-r--r-- | gnu/java/awt/ClasspathToolkit.java | 22 | ||||
-rw-r--r-- | gnu/java/awt/java2d/CubicSegment.java | 22 | ||||
-rw-r--r-- | gnu/java/awt/java2d/LineSegment.java | 17 | ||||
-rw-r--r-- | gnu/java/awt/java2d/QuadSegment.java | 20 | ||||
-rw-r--r-- | gnu/java/awt/peer/ClasspathFontPeer.java | 7 | ||||
-rw-r--r-- | gnu/java/awt/peer/gtk/CairoGraphics2D.java | 95 | ||||
-rw-r--r-- | gnu/java/awt/peer/gtk/CairoSurface.java | 6 | ||||
-rw-r--r-- | gnu/java/awt/peer/gtk/ComponentGraphics.java | 17 | ||||
-rw-r--r-- | gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java | 6 | ||||
-rw-r--r-- | gnu/java/awt/peer/gtk/GtkFramePeer.java | 6 | ||||
-rw-r--r-- | gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java | 77 | ||||
-rw-r--r-- | gnu/java/awt/peer/gtk/GtkToolkit.java | 9 | ||||
-rw-r--r-- | gnu/java/awt/peer/gtk/GtkWindowPeer.java | 9 | ||||
-rw-r--r-- | gnu/java/awt/peer/x/XToolkit.java | 64 |
14 files changed, 315 insertions, 62 deletions
diff --git a/gnu/java/awt/ClasspathToolkit.java b/gnu/java/awt/ClasspathToolkit.java index 5f093b71b..968cc3b16 100644 --- a/gnu/java/awt/ClasspathToolkit.java +++ b/gnu/java/awt/ClasspathToolkit.java @@ -1,5 +1,5 @@ /* ClasspathToolkit.java -- Abstract superclass for Classpath toolkits. - Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -52,6 +52,7 @@ import java.awt.FontMetrics; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Image; +import java.awt.Point; import java.awt.Toolkit; import java.awt.font.FontRenderContext; import java.awt.image.ColorModel; @@ -188,6 +189,9 @@ public abstract class ClasspathToolkit */ public abstract Font createFont(int format, InputStream stream); + /** + * Creates a RobotPeer on a given GraphicsDevice. + */ public abstract RobotPeer createRobot (GraphicsDevice screen) throws AWTException; @@ -201,8 +205,24 @@ public abstract class ClasspathToolkit /** * Used to register ImageIO SPIs provided by the toolkit. + * + * Our default implementation does nothing. */ public void registerImageIOSpis(IIORegistry reg) { } + + /** + * Returns the number of mouse buttons. + * (used by java.awt.MouseInfo). + * + * This dummy implementation returns -1 (no mouse). + * toolkit implementors should overload this method if possible. + * @since 1.5 + */ + public int getMouseNumberOfButtons() + { + return -1; + } } + diff --git a/gnu/java/awt/java2d/CubicSegment.java b/gnu/java/awt/java2d/CubicSegment.java index 1e568f722..7d169b78e 100644 --- a/gnu/java/awt/java2d/CubicSegment.java +++ b/gnu/java/awt/java2d/CubicSegment.java @@ -78,8 +78,25 @@ public class CubicSegment extends Segment */ public Object clone() { - return new CubicSegment(P1.getX(), P1.getY(), cp1.getX(), cp1.getY(), - cp2.getX(), cp2.getY(), P2.getX(), P2.getY()); + CubicSegment segment = null; + + try + { + segment = (CubicSegment) super.clone(); + + segment.P1 = (Point2D) P1.clone(); + segment.P2 = (Point2D) P2.clone(); + segment.cp1 = (Point2D) cp1.clone(); + segment.cp2 = (Point2D) cp2.clone(); + } + catch (CloneNotSupportedException cnse) + { + InternalError ie = new InternalError(); + ie.initCause(cnse); + throw ie; + } + + return segment; } /** @@ -100,7 +117,6 @@ public class CubicSegment extends Segment double[] p1 = normal(x0, y0, x1, y1); double[] p2 = normal(x2, y2, x3, y3); - // FIXME: Doesn't compile. // return new Segment[]{s1, s2}; return new Segment[0]; diff --git a/gnu/java/awt/java2d/LineSegment.java b/gnu/java/awt/java2d/LineSegment.java index 9c0bcc7ea..4a34aa563 100644 --- a/gnu/java/awt/java2d/LineSegment.java +++ b/gnu/java/awt/java2d/LineSegment.java @@ -62,7 +62,22 @@ public class LineSegment extends Segment */ public Object clone() { - return new LineSegment(P1, P2); + LineSegment segment = null; + + try + { + segment = (LineSegment) super.clone(); + segment.P1 = (Point2D) P1.clone(); + segment.P2 = (Point2D) P2.clone(); + } + catch (CloneNotSupportedException cnse) + { + InternalError ie = new InternalError(); + ie.initCause(cnse); + throw ie; + } + + return segment; } /** diff --git a/gnu/java/awt/java2d/QuadSegment.java b/gnu/java/awt/java2d/QuadSegment.java index 9c15a8cfd..c76804840 100644 --- a/gnu/java/awt/java2d/QuadSegment.java +++ b/gnu/java/awt/java2d/QuadSegment.java @@ -88,8 +88,24 @@ public class QuadSegment extends Segment */ public Object clone() { - return new QuadSegment(P1.getX(), P1.getY(), cp.getX(), cp.getY(), - P2.getX(), P2.getY()); + QuadSegment segment = null; + + try + { + segment = (QuadSegment) super.clone(); + + segment.P1 = (Point2D) P1.clone(); + segment.P2 = (Point2D) P2.clone(); + segment.cp = (Point2D) cp.clone(); + } + catch (CloneNotSupportedException cnse) + { + InternalError ie = new InternalError(); + ie.initCause(cnse); + throw ie; + } + + return segment; } /** diff --git a/gnu/java/awt/peer/ClasspathFontPeer.java b/gnu/java/awt/peer/ClasspathFontPeer.java index 78ab3a9de..dad7bb0b0 100644 --- a/gnu/java/awt/peer/ClasspathFontPeer.java +++ b/gnu/java/awt/peer/ClasspathFontPeer.java @@ -145,7 +145,8 @@ public abstract class ClasspathFontPeer uname.equals ("SERIF") || uname.equals ("MONOSPACED") || uname.equals ("DIALOG") || - uname.equals ("DIALOGINPUT")); + uname.equals ("DIALOGINPUT") || + uname.equals ("DEFAULT")); } protected static String logicalFontNameToFaceName (String name) @@ -161,6 +162,8 @@ public abstract class ClasspathFontPeer return "Helvetica"; else if (uname.equals ("DIALOGINPUT")) return "Helvetica"; + else if (uname.equals ("DEFAULT")) + return "Dialog.plain"; else return "Helvetica"; } @@ -233,7 +236,7 @@ public abstract class ClasspathFontPeer family = (String) attribs.get (TextAttribute.FAMILY); if (name == null) - name = "SansSerif"; + name = "Default"; if (attribs.containsKey (TextAttribute.WEIGHT)) { diff --git a/gnu/java/awt/peer/gtk/CairoGraphics2D.java b/gnu/java/awt/peer/gtk/CairoGraphics2D.java index 61871ccbc..e0da71850 100644 --- a/gnu/java/awt/peer/gtk/CairoGraphics2D.java +++ b/gnu/java/awt/peer/gtk/CairoGraphics2D.java @@ -40,8 +40,8 @@ package gnu.java.awt.peer.gtk; import gnu.java.awt.ClasspathToolkit; -import java.awt.AlphaComposite; import java.awt.AWTPermission; +import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Composite; @@ -53,11 +53,11 @@ import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.Image; import java.awt.Paint; +import java.awt.Polygon; import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.Shape; import java.awt.Stroke; -import java.awt.Polygon; import java.awt.TexturePaint; import java.awt.Toolkit; import java.awt.font.FontRenderContext; @@ -66,6 +66,7 @@ import java.awt.font.TextLayout; import java.awt.geom.AffineTransform; import java.awt.geom.Arc2D; import java.awt.geom.Area; +import java.awt.geom.Ellipse2D; import java.awt.geom.GeneralPath; import java.awt.geom.NoninvertibleTransformException; import java.awt.geom.PathIterator; @@ -322,6 +323,11 @@ public abstract class CairoGraphics2D extends Graphics2D * Set the current transform matrix */ private native void cairoSetMatrix(long pointer, double[] m); + + /** + * Scaling method + */ + private native void cairoScale(long pointer, double x, double y); /** * Set the compositing operator @@ -369,6 +375,18 @@ public abstract class CairoGraphics2D extends Graphics2D */ private native void cairoRectangle(long pointer, double x, double y, double width, double height); + + /** + * Appends an arc to the current path + */ + private native void cairoArc(long pointer, double x, double y, + double radius, double angle1, double angle2); + + /** + * Save / restore a cairo path + */ + private native void cairoSave(long pointer); + private native void cairoRestore(long pointer); /** * New current path @@ -920,36 +938,71 @@ public abstract class CairoGraphics2D extends Graphics2D return; } - cairoNewPath(nativePointer); - - if (s instanceof Rectangle2D) - { - Rectangle2D r = (Rectangle2D) s; - cairoRectangle(nativePointer, shifted(r.getX(), shiftDrawCalls), - shifted(r.getY(), shiftDrawCalls), r.getWidth(), - r.getHeight()); - } - else - walkPath(s.getPathIterator(null), shiftDrawCalls); + createPath(s); cairoStroke(nativePointer); } public void fill(Shape s) { + createPath(s); + + double alpha = 1.0; + if (comp instanceof AlphaComposite) + alpha = ((AlphaComposite) comp).getAlpha(); + cairoFill(nativePointer, alpha); + } + + private void createPath(Shape s) + { cairoNewPath(nativePointer); + + // Optimize rectangles, since there is a direct Cairo function if (s instanceof Rectangle2D) { - Rectangle2D r = (Rectangle2D) s; - cairoRectangle(nativePointer, r.getX(), r.getY(), r.getWidth(), + Rectangle2D r = (Rectangle2D) s; + cairoRectangle(nativePointer, shifted(r.getX(), shiftDrawCalls), + shifted(r.getY(), shiftDrawCalls), r.getWidth(), r.getHeight()); } - else - walkPath(s.getPathIterator(null), false); - double alpha = 1.0; - if (comp instanceof AlphaComposite) - alpha = ((AlphaComposite) comp).getAlpha(); - cairoFill(nativePointer, alpha); + // We can optimize ellipses too; however we don't bother optimizing arcs: + // the iterator is fast enough (an ellipse requires 5 steps using the + // iterator, while most arcs are only 2-3) + else if (s instanceof Ellipse2D) + { + Ellipse2D e = (Ellipse2D) s; + + double radius = Math.min(e.getHeight(), e.getWidth()) / 2; + + // Cairo only draws circular shapes, but we can use a stretch to make + // them into ellipses + double xscale = 1, yscale = 1; + if (e.getHeight() != e.getWidth()) + { + cairoSave(nativePointer); + + if (e.getHeight() < e.getWidth()) + xscale = e.getWidth() / (radius * 2); + else + yscale = e.getHeight() / (radius * 2); + + if (xscale != 1 || yscale != 1) + cairoScale(nativePointer, xscale, yscale); + } + + cairoArc(nativePointer, + shifted(e.getCenterX() / xscale, shiftDrawCalls), + shifted(e.getCenterY() / yscale, shiftDrawCalls), radius, 0, + Math.PI * 2); + + if (xscale != 1 || yscale != 1) + cairoRestore(nativePointer); + } + + // All other shapes are broken down and drawn in steps using the + // PathIterator + else + walkPath(s.getPathIterator(null), shiftDrawCalls); } /** diff --git a/gnu/java/awt/peer/gtk/CairoSurface.java b/gnu/java/awt/peer/gtk/CairoSurface.java index b4d08c6ad..020d8eadd 100644 --- a/gnu/java/awt/peer/gtk/CairoSurface.java +++ b/gnu/java/awt/peer/gtk/CairoSurface.java @@ -80,10 +80,10 @@ public class CairoSurface extends DataBuffer long bufferPointer; - static ColorModel nativeModel = new DirectColorModel(32, - 0x000000FF, - 0x0000FF00, + static ColorModel nativeModel = new DirectColorModel(32, 0x00FF0000, + 0x0000FF00, + 0x000000FF, 0xFF000000); /** diff --git a/gnu/java/awt/peer/gtk/ComponentGraphics.java b/gnu/java/awt/peer/gtk/ComponentGraphics.java index cb8350265..193dec4c7 100644 --- a/gnu/java/awt/peer/gtk/ComponentGraphics.java +++ b/gnu/java/awt/peer/gtk/ComponentGraphics.java @@ -62,6 +62,8 @@ import java.awt.image.RenderedImage; */ public class ComponentGraphics extends CairoGraphics2D { + private static final boolean hasXRenderExtension = hasXRender(); + private GtkComponentPeer component; protected long cairo_t; @@ -175,7 +177,7 @@ public class ComponentGraphics extends CairoGraphics2D */ public static Graphics2D getComponentGraphics(GtkComponentPeer component) { - if( hasXRender() ) + if( hasXRenderExtension ) return new ComponentGraphics(component); Rectangle r = component.awtComponent.getBounds(); @@ -402,5 +404,18 @@ public class ComponentGraphics extends CairoGraphics2D } } + public void setClip(Shape s) + { + lock(); + try + { + super.setClip(s); + } + finally + { + unlock(); + } + } + } diff --git a/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java b/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java index 035819d1c..e095c7dad 100644 --- a/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java +++ b/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java @@ -134,5 +134,9 @@ public class GdkGraphicsEnvironment extends GraphicsEnvironment { throw new java.lang.UnsupportedOperationException (); } - + + /** + * Used by GtkMouseInfoPeer. + */ + native int[] getMouseCoordinates(); } diff --git a/gnu/java/awt/peer/gtk/GtkFramePeer.java b/gnu/java/awt/peer/gtk/GtkFramePeer.java index 6ec0b7298..faac6d71d 100644 --- a/gnu/java/awt/peer/gtk/GtkFramePeer.java +++ b/gnu/java/awt/peer/gtk/GtkFramePeer.java @@ -218,11 +218,7 @@ public class GtkFramePeer extends GtkWindowPeer // TODO Auto-generated method stub } - public void updateAlwaysOnTop() - { - // TODO Auto-generated method stub - - } + public boolean requestWindowFocus() { // TODO Auto-generated method stub diff --git a/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java b/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java new file mode 100644 index 000000000..7f54da6d3 --- /dev/null +++ b/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java @@ -0,0 +1,77 @@ +/* GtkToolkit.java -- Implements an AWT Toolkit using GTK for peers + 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.gtk; + +import java.awt.Point; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Window; +import java.awt.peer.MouseInfoPeer; + +/** + * The MouseInfoPeer is so small, I'm including it here. + */ +public class GtkMouseInfoPeer implements MouseInfoPeer +{ + private static GdkGraphicsEnvironment gde = new GdkGraphicsEnvironment(); + + public int fillPointWithCoords(Point p) + { + int[] coords = gde.getMouseCoordinates(); + p.x = coords[1]; + p.y = coords[2]; + return coords[0]; + } + + public boolean isWindowUnderMouse(Window w) + { + int[] coords = gde.getMouseCoordinates(); + GraphicsDevice[] gds = gde.getScreenDevices(); + + // Check if the screen of the Window and the cursor match + if( gds[ coords[0] ] != w.getGraphicsConfiguration().getDevice() ) + return false; + + // Return the bounds-check. + Point p = w.getLocationOnScreen(); + return (coords[1] >= p.x && coords[1] < p.x + w.getWidth() && + coords[2] >= p.y && coords[2] < p.y + w.getHeight() ); + } +} + diff --git a/gnu/java/awt/peer/gtk/GtkToolkit.java b/gnu/java/awt/peer/gtk/GtkToolkit.java index fdd7e09cb..62d497449 100644 --- a/gnu/java/awt/peer/gtk/GtkToolkit.java +++ b/gnu/java/awt/peer/gtk/GtkToolkit.java @@ -102,6 +102,7 @@ import java.awt.peer.LabelPeer; import java.awt.peer.ListPeer; import java.awt.peer.MenuBarPeer; import java.awt.peer.MenuItemPeer; +import java.awt.peer.MouseInfoPeer; import java.awt.peer.MenuPeer; import java.awt.peer.PanelPeer; import java.awt.peer.PopupMenuPeer; @@ -653,4 +654,12 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit } public static native void gtkMain(); + + protected MouseInfoPeer getMouseInfoPeer() + { + return new GtkMouseInfoPeer(); + } + + public native int getMouseNumberOfButtons(); + } // class GtkToolkit diff --git a/gnu/java/awt/peer/gtk/GtkWindowPeer.java b/gnu/java/awt/peer/gtk/GtkWindowPeer.java index d15beacb4..ca79a6d21 100644 --- a/gnu/java/awt/peer/gtk/GtkWindowPeer.java +++ b/gnu/java/awt/peer/gtk/GtkWindowPeer.java @@ -70,7 +70,7 @@ public class GtkWindowPeer extends GtkContainerPeer native void gtkWindowSetTitle (String title); native void gtkWindowSetResizable (boolean resizable); native void gtkWindowSetModal (boolean modal); - + native void gtkWindowSetAlwaysOnTop ( boolean alwaysOnTop ); native void realize (); /** Returns the cached width of the AWT window component. */ @@ -275,10 +275,13 @@ public class GtkWindowPeer extends GtkContainerPeer else q().postEvent (new WindowEvent ((Window) awtComponent, id, opposite)); } + + /** + * Update the always-on-top status of the native window. + */ public void updateAlwaysOnTop() { - // TODO Auto-generated method stub - + gtkWindowSetAlwaysOnTop( ((Window)awtComponent).isAlwaysOnTop() ); } protected void postExposeEvent (int x, int y, int width, int height) diff --git a/gnu/java/awt/peer/x/XToolkit.java b/gnu/java/awt/peer/x/XToolkit.java index 05e8a5963..343a8f44f 100644 --- a/gnu/java/awt/peer/x/XToolkit.java +++ b/gnu/java/awt/peer/x/XToolkit.java @@ -71,7 +71,6 @@ import java.awt.Window; import java.awt.datatransfer.Clipboard; import java.awt.dnd.DragGestureEvent; import java.awt.dnd.peer.DragSourceContextPeer; -import java.awt.font.FontRenderContext; import java.awt.im.InputMethodHighlight; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; @@ -101,12 +100,12 @@ import java.awt.peer.ScrollbarPeer; import java.awt.peer.TextAreaPeer; import java.awt.peer.TextFieldPeer; import java.awt.peer.WindowPeer; +import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; -import java.text.AttributedString; import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -114,6 +113,7 @@ import java.util.WeakHashMap; import javax.imageio.ImageIO; +import gnu.classpath.SystemProperties; import gnu.java.awt.ClasspathToolkit; import gnu.java.awt.EmbeddedWindow; import gnu.java.awt.peer.ClasspathFontPeer; @@ -155,7 +155,9 @@ public class XToolkit public XToolkit() { - System.setProperty("gnu.javax.swing.noGraphics2D", "true"); + SystemProperties.setProperty("gnu.javax.swing.noGraphics2D", "true"); + SystemProperties.setProperty("java.awt.graphicsenv", + "gnu.java.awt.peer.x.XGraphicsEnvironment"); } public GraphicsEnvironment getLocalGraphicsEnvironment() @@ -176,15 +178,20 @@ public class XToolkit public ClasspathFontPeer getClasspathFontPeer(String name, Map attrs) { String canonical = XFontPeer.encodeFont(name, attrs); - XFontPeer font; + ClasspathFontPeer font; if (!fontCache.containsKey(canonical)) { - font = new XFontPeer(name, attrs); + String graphics2d = + SystemProperties.getProperty("gnu.xawt.graphics2d"); + if (graphics2d != null && graphics2d.equals("gl")) + font = new XFontPeer2(name, attrs); + else + font = new XFontPeer(name, attrs); fontCache.put(canonical, font); } else { - font = (XFontPeer) fontCache.get(canonical); + font = (ClasspathFontPeer) fontCache.get(canonical); } return font; } @@ -361,7 +368,7 @@ public class XToolkit public FontMetrics getFontMetrics(Font name) { - XFontPeer peer = (XFontPeer) name.getPeer(); + ClasspathFontPeer peer = (ClasspathFontPeer) name.getPeer(); return peer.getFontMetrics(name); } @@ -459,16 +466,7 @@ public class XToolkit Image image; try { - BufferedImage buffered = ImageIO.read(url); - if (buffered != null) - { - ImageConverter conv = new ImageConverter(); - ImageProducer source = buffered.getSource(); - source.startProduction(conv); - return conv.getXImage(); - } - else return createErrorImage(); - + image = createImage(url.openStream()); } catch (IOException ex) { @@ -510,8 +508,36 @@ public class XToolkit public Image createImage(byte[] data, int offset, int len) { - // TODO: Implement this. - throw new UnsupportedOperationException("Not yet implemented."); + 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(); + } + else + { + image = createErrorImage(); + } + return image; } public PrintJob getPrintJob(Frame frame, String title, Properties props) |