diff options
37 files changed, 1180 insertions, 1159 deletions
@@ -1,3 +1,42 @@ +2007-02-12 Francis Kung <fkung@redhat.com> + + * gnu/java/awt/ClasspathToolkit.java: + * gnu/java/awt/peer/gtk/AsyncImage.java, + * gnu/java/awt/peer/gtk/BufferedImageGraphics.java, + * gnu/java/awt/peer/gtk/CairoGraphics2D.java, + * gnu/java/awt/peer/gtk/CairoSurface.java, + * gnu/java/awt/peer/gtk/ComponentGraphics.java, + * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java, + * gnu/java/awt/peer/gtk/GdkFontPeer.java, + * gnu/java/awt/peer/gtk/GdkPixbufDecoder.java, + * gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java, + * gnu/java/awt/peer/gtk/GtkCheckboxPeer.java, + * gnu/java/awt/peer/gtk/GtkChoicePeer.java, + * gnu/java/awt/peer/gtk/GtkClipboard.java, + * gnu/java/awt/peer/gtk/GtkClipboardNotifier.java, + * gnu/java/awt/peer/gtk/GtkComponentPeer.java, + * gnu/java/awt/peer/gtk/GtkFileDialogPeer.java, + * gnu/java/awt/peer/gtk/GtkFramePeer.java, + * gnu/java/awt/peer/gtk/GtkImage.java, + * gnu/java/awt/peer/gtk/GtkImageConsumer.java, + * gnu/java/awt/peer/gtk/GtkLabelPeer.java, + * gnu/java/awt/peer/gtk/GtkListPeer.java, + * gnu/java/awt/peer/gtk/GtkMainThread.java, + * gnu/java/awt/peer/gtk/GtkMenuBarPeer.java, + * gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java, + * gnu/java/awt/peer/gtk/GtkMenuPeer.java, + * gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java, + * gnu/java/awt/peer/gtk/GtkScrollbarPeer.java, + * gnu/java/awt/peer/gtk/GtkScrollPanePeer.java, + * gnu/java/awt/peer/gtk/GtkSelection.java, + * gnu/java/awt/peer/gtk/GtkTextAreaPeer.java, + * gnu/java/awt/peer/gtk/GtkTextFieldPeer.java, + * gnu/java/awt/peer/gtk/GtkToolkit.java, + * gnu/java/awt/peer/gtk/GtkWindowPeer.java, + * gnu/java/awt/peer/gtk/VolatileImageGraphics.java, + * java/awt/RenderingHints.java, + * java/awt/image/BufferedImage.java: Reformatted and added generics. + 2007-02-12 Tom Tromey <tromey@redhat.com> * java/net/Socket.java (bind): Typo fix. diff --git a/gnu/java/awt/ClasspathToolkit.java b/gnu/java/awt/ClasspathToolkit.java index 968cc3b16..2819bdf55 100644 --- a/gnu/java/awt/ClasspathToolkit.java +++ b/gnu/java/awt/ClasspathToolkit.java @@ -38,36 +38,24 @@ exception statement from your version. */ package gnu.java.awt; -import gnu.java.awt.EmbeddedWindow; import gnu.java.awt.peer.ClasspathFontPeer; import gnu.java.awt.peer.EmbeddedWindowPeer; import gnu.java.security.action.SetAccessibleAction; import java.awt.AWTException; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.DisplayMode; import java.awt.Font; -import java.awt.FontMetrics; +import java.awt.FontFormatException; 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; -import java.awt.image.ImageProducer; +import java.awt.font.TextAttribute; import java.awt.peer.RobotPeer; -import java.io.File; +import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.net.MalformedURLException; -import java.net.URL; -import java.text.AttributedString; -import java.util.HashMap; -import java.util.Map; import java.security.AccessController; +import java.util.Map; import javax.imageio.spi.IIORegistry; @@ -118,7 +106,8 @@ public abstract class ClasspathToolkit * this font peer should have, such as size, weight, family name, or * transformation. */ - public abstract ClasspathFontPeer getClasspathFontPeer (String name, Map attrs); + public abstract ClasspathFontPeer getClasspathFontPeer (String name, + Map<?,?> attrs); /** * Creates a {@link Font}, in a platform-specific manner. @@ -137,9 +126,8 @@ public abstract class ClasspathToolkit try { Constructor fontConstructor = Font.class.getDeclaredConstructor - (new Class[] { String.class, Map.class }); - AccessController.doPrivileged - (new SetAccessibleAction(fontConstructor)); + (new Class[] { String.class, Map.class }); + AccessController.doPrivileged(new SetAccessibleAction(fontConstructor)); f = (Font) fontConstructor.newInstance(new Object[] { name, attrs }); } catch (IllegalAccessException e) diff --git a/gnu/java/awt/peer/gtk/AsyncImage.java b/gnu/java/awt/peer/gtk/AsyncImage.java index 5238bfe74..dad537aa7 100644 --- a/gnu/java/awt/peer/gtk/AsyncImage.java +++ b/gnu/java/awt/peer/gtk/AsyncImage.java @@ -61,11 +61,11 @@ public class AsyncImage private class NullImageSource implements ImageProducer { - private ArrayList consumers; + private ArrayList<ImageConsumer> consumers; NullImageSource() { - consumers = new ArrayList(); + consumers = new ArrayList<ImageConsumer>(); } public void addConsumer(ImageConsumer ic) @@ -145,14 +145,14 @@ public class AsyncImage * * This is package private to avoid accessor methods. */ - HashSet observers; + HashSet<ImageObserver> observers; /** * Creates a new AsyncImage that loads from the specified URL. */ AsyncImage(URL url) { - observers = new HashSet(); + observers = new HashSet<ImageObserver>(); Loader l = new Loader(url); Thread t = new Thread(l); t.start(); @@ -221,7 +221,7 @@ public class AsyncImage { // This field gets null when image loading is complete and we don't // need to store any more observers. - HashSet observs = observers; + HashSet<ImageObserver> observs = observers; if (observs != null) { observs.add(obs); diff --git a/gnu/java/awt/peer/gtk/BufferedImageGraphics.java b/gnu/java/awt/peer/gtk/BufferedImageGraphics.java index 18182a77c..d5d26ee7e 100644 --- a/gnu/java/awt/peer/gtk/BufferedImageGraphics.java +++ b/gnu/java/awt/peer/gtk/BufferedImageGraphics.java @@ -87,7 +87,8 @@ public class BufferedImageGraphics extends CairoGraphics2D /** * Cache BufferedImageGraphics surfaces. */ - static WeakHashMap bufferedImages = new WeakHashMap(); + static WeakHashMap<BufferedImage, CairoSurface> bufferedImages + = new WeakHashMap<BufferedImage, CairoSurface>(); /** * Its corresponding cairo_t. @@ -108,24 +109,24 @@ public class BufferedImageGraphics extends CairoGraphics2D hasFastCM = false; else if(bi.getColorModel().equals(CairoSurface.cairoCM_opaque)) { - hasFastCM = true; - hasAlpha = false; + hasFastCM = true; + hasAlpha = false; } else if(bi.getColorModel().equals(CairoSurface.cairoColorModel)) { - hasFastCM = true; - hasAlpha = true; + hasFastCM = true; + hasAlpha = true; } else hasFastCM = false; // Cache surfaces. if( bufferedImages.get( bi ) != null ) - surface = (CairoSurface)bufferedImages.get( bi ); + surface = bufferedImages.get( bi ); else { - surface = new CairoSurface( imageWidth, imageHeight ); - bufferedImages.put(bi, surface); + surface = new CairoSurface( imageWidth, imageHeight ); + bufferedImages.put(bi, surface); } cairo_t = surface.newCairoContext(); @@ -154,7 +155,8 @@ public class BufferedImageGraphics extends CairoGraphics2D int scanline = sm.getScanlineStride(); for (int i = 0; i < imageHeight; i++) - System.arraycopy(pixels, (i - minY) * scanline - minX, pixels2, i * imageWidth, imageWidth); + System.arraycopy(pixels, (i - minY) * scanline - minX, pixels2, + i * imageWidth, imageWidth); pixels = pixels2; } @@ -166,7 +168,8 @@ public class BufferedImageGraphics extends CairoGraphics2D } else { - pixels = CairoGraphics2D.findSimpleIntegerArray(image.getColorModel(),image.getData()); + pixels = CairoGraphics2D.findSimpleIntegerArray(image.getColorModel(), + image.getData()); } surface.setPixels( pixels ); @@ -393,7 +396,7 @@ public class BufferedImageGraphics extends CairoGraphics2D // Find translated bounds Rectangle2D bounds = new Rectangle(bImg.getMinX(), bImg.getMinY(), - bImg.getWidth(), bImg.getHeight()); + bImg.getWidth(), bImg.getHeight()); if (xform != null) bounds = getTransformedBounds(bounds, xform); diff --git a/gnu/java/awt/peer/gtk/CairoGraphics2D.java b/gnu/java/awt/peer/gtk/CairoGraphics2D.java index eaf2463f8..5e9893bc7 100644 --- a/gnu/java/awt/peer/gtk/CairoGraphics2D.java +++ b/gnu/java/awt/peer/gtk/CairoGraphics2D.java @@ -251,7 +251,7 @@ public abstract class CairoGraphics2D extends Graphics2D if (g.fg.getAlpha() != -1) foreground = new Color(g.fg.getRed(), g.fg.getGreen(), g.fg.getBlue(), - g.fg.getAlpha()); + g.fg.getAlpha()); else foreground = new Color(g.fg.getRGB()); @@ -321,8 +321,8 @@ public abstract class CairoGraphics2D extends Graphics2D public abstract GraphicsConfiguration getDeviceConfiguration(); - protected abstract void copyAreaImpl(int x, int y, - int width, int height, int dx, int dy); + protected abstract void copyAreaImpl(int x, int y, int width, int height, + int dx, int dy); /** @@ -355,8 +355,8 @@ public abstract class CairoGraphics2D extends Graphics2D int g2, int b2, int a2, boolean cyclic); private native void setPaintPixels(long pointer, int[] pixels, int w, - int h, int stride, boolean repeat, - int x, int y); + int h, int stride, boolean repeat, + int x, int y); /** * Set the current transform matrix @@ -718,33 +718,35 @@ public abstract class CairoGraphics2D extends Graphics2D setColor((Color) paint); customPaint = false; } + else if (paint instanceof TexturePaint) { - TexturePaint tp = (TexturePaint) paint; - BufferedImage img = tp.getImage(); + TexturePaint tp = (TexturePaint) paint; + BufferedImage img = tp.getImage(); - // map the image to the anchor rectangle - int width = (int) tp.getAnchorRect().getWidth(); - int height = (int) tp.getAnchorRect().getHeight(); + // map the image to the anchor rectangle + int width = (int) tp.getAnchorRect().getWidth(); + int height = (int) tp.getAnchorRect().getHeight(); - double scaleX = width / (double) img.getWidth(); - double scaleY = height / (double) img.getHeight(); + double scaleX = width / (double) img.getWidth(); + double scaleY = height / (double) img.getHeight(); - AffineTransform at = new AffineTransform(scaleX, 0, 0, scaleY, 0, 0); - AffineTransformOp op = new AffineTransformOp(at, getRenderingHints()); - BufferedImage texture = op.filter(img, null); - int[] pixels = texture.getRGB(0, 0, width, height, null, 0, width); - setPaintPixels(nativePointer, pixels, width, height, width, true, 0, 0); + AffineTransform at = new AffineTransform(scaleX, 0, 0, scaleY, 0, 0); + AffineTransformOp op = new AffineTransformOp(at, getRenderingHints()); + BufferedImage texture = op.filter(img, null); + int[] pixels = texture.getRGB(0, 0, width, height, null, 0, width); + setPaintPixels(nativePointer, pixels, width, height, width, true, 0, 0); customPaint = false; } + else if (paint instanceof GradientPaint) { - GradientPaint gp = (GradientPaint) paint; - Point2D p1 = gp.getPoint1(); - Point2D p2 = gp.getPoint2(); - Color c1 = gp.getColor1(); - Color c2 = gp.getColor2(); - setGradient(nativePointer, p1.getX(), p1.getY(), p2.getX(), p2.getY(), + GradientPaint gp = (GradientPaint) paint; + Point2D p1 = gp.getPoint1(); + Point2D p2 = gp.getPoint2(); + Color c1 = gp.getColor1(); + Color c2 = gp.getColor2(); + setGradient(nativePointer, p1.getX(), p1.getY(), p2.getX(), p2.getY(), c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha(), c2.getRed(), c2.getGreen(), c2.getBlue(), c2.getAlpha(), gp.isCyclic()); @@ -858,21 +860,22 @@ public abstract class CairoGraphics2D extends Graphics2D stroke = st; if (stroke instanceof BasicStroke) { - BasicStroke bs = (BasicStroke) stroke; - cairoSetLine(nativePointer, bs.getLineWidth(), bs.getEndCap(), - bs.getLineJoin(), bs.getMiterLimit()); - - float[] dashes = bs.getDashArray(); - if (dashes != null) - { - double[] double_dashes = new double[dashes.length]; - for (int i = 0; i < dashes.length; i++) - double_dashes[i] = dashes[i]; - cairoSetDash(nativePointer, double_dashes, double_dashes.length, - (double) bs.getDashPhase()); - } - else - cairoSetDash(nativePointer, new double[0], 0, 0.0); + BasicStroke bs = (BasicStroke) stroke; + cairoSetLine(nativePointer, bs.getLineWidth(), bs.getEndCap(), + bs.getLineJoin(), bs.getMiterLimit()); + + float[] dashes = bs.getDashArray(); + if (dashes != null) + { + double[] double_dashes = new double[dashes.length]; + for (int i = 0; i < dashes.length; i++) + double_dashes[i] = dashes[i]; + + cairoSetDash(nativePointer, double_dashes, double_dashes.length, + (double) bs.getDashPhase()); + } + else + cairoSetDash(nativePointer, new double[0], 0, 0.0); } } @@ -930,6 +933,7 @@ public abstract class CairoGraphics2D extends Graphics2D { if (fg == null) fg = Color.BLACK; + cairoSetRGBAColor(nativePointer, fg.getRed() / 255.0, fg.getGreen() / 255.0,fg.getBlue() / 255.0, fg.getAlpha() / 255.0); @@ -1001,8 +1005,8 @@ public abstract class CairoGraphics2D extends Graphics2D // initial clip properly. if( firstClip ) { - originalClip = s; - firstClip = false; + originalClip = s; + firstClip = false; } clip = s; @@ -1062,7 +1066,7 @@ public abstract class CairoGraphics2D extends Graphics2D if (comp instanceof AlphaComposite) { - AlphaComposite a = (AlphaComposite) comp; + AlphaComposite a = (AlphaComposite) comp; cairoSetOperator(nativePointer, a.getRule()); } @@ -1325,12 +1329,12 @@ public abstract class CairoGraphics2D extends Graphics2D // FIXME: does this handle a rotation transform properly? // (the width/height might not be correct) Point2D pos = transform.transform(new Point2D.Double(ox, oy), - (Point2D) null); + (Point2D) null); Point2D dim = transform.transform(new Point2D.Double(ox + owidth, - oy + oheight), - (Point2D) null); + oy + oheight), + (Point2D) null); Point2D p2 = transform.transform(new Point2D.Double(ox + odx, oy + ody), - (Point2D) null); + (Point2D) null); int x = (int)pos.getX(); int y = (int)pos.getY(); int width = (int)(dim.getX() - pos.getX()); @@ -1352,14 +1356,14 @@ public abstract class CairoGraphics2D extends Graphics2D // Clip edges if necessary if( x + dx < r.getX() ) // left { - width = x + dx + width; - x = (int)r.getX() - dx; + width = x + dx + width; + x = (int)r.getX() - dx; } if( y + dy < r.getY() ) // top { - height = y + dy + height; - y = (int)r.getY() - dy; + height = y + dy + height; + y = (int)r.getY() - dy; } if( x + dx + width >= r.getWidth() ) // right @@ -1386,10 +1390,10 @@ public abstract class CairoGraphics2D extends Graphics2D return hints.get(hintKey); } - public void setRenderingHints(Map hints) + public void setRenderingHints(Map<?,?> hints) { this.hints = new RenderingHints(getDefaultHints()); - this.hints.add(new RenderingHints(hints)); + this.hints.putAll(hints); shiftDrawCalls = hints.containsValue(RenderingHints.VALUE_STROKE_NORMALIZE) || hints.containsValue(RenderingHints.VALUE_STROKE_DEFAULT); @@ -1403,7 +1407,7 @@ public abstract class CairoGraphics2D extends Graphics2D public void addRenderingHints(Map hints) { - this.hints.add(new RenderingHints(hints)); + this.hints.putAll(hints); } public RenderingHints getRenderingHints() @@ -1475,12 +1479,12 @@ public abstract class CairoGraphics2D extends Graphics2D try { - invertedXform = xform.createInverse(); + invertedXform = xform.createInverse(); } catch (NoninvertibleTransformException e) { - throw new ImagingOpException("Unable to invert transform " - + xform.toString()); + throw new ImagingOpException("Unable to invert transform " + + xform.toString()); } // Unrecognized image - convert to a BufferedImage @@ -1490,10 +1494,10 @@ public abstract class CairoGraphics2D extends Graphics2D img = AsyncImage.realImage(img, obs); if( !(img instanceof BufferedImage) ) { - ImageProducer source = img.getSource(); - if (source == null) - return false; - img = Toolkit.getDefaultToolkit().createImage(source); + ImageProducer source = img.getSource(); + if (source == null) + return false; + img = Toolkit.getDefaultToolkit().createImage(source); } BufferedImage b = (BufferedImage) img; @@ -1506,7 +1510,7 @@ public abstract class CairoGraphics2D extends Graphics2D // use the cached CairoSurface that BIG is drawing onto if( BufferedImageGraphics.bufferedImages.get( b ) != null ) - raster = (Raster)BufferedImageGraphics.bufferedImages.get( b ); + raster = BufferedImageGraphics.bufferedImages.get( b ); else raster = b.getRaster(); @@ -1518,10 +1522,10 @@ public abstract class CairoGraphics2D extends Graphics2D if(raster instanceof CairoSurface) { - ((CairoSurface)raster).drawSurface(nativePointer, i2u, alpha, + ((CairoSurface)raster).drawSurface(nativePointer, i2u, alpha, getInterpolation()); updateColor(); - return true; + return true; } if( bgcolor != null ) @@ -1547,7 +1551,8 @@ public abstract class CairoGraphics2D extends Graphics2D cairoResetClip(nativePointer); Rectangle2D bounds = new Rectangle2D.Double(0, 0, width, height); bounds = getTransformedBounds(bounds, xform); - cairoRectangle(nativePointer, bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); + cairoRectangle(nativePointer, bounds.getX(), bounds.getY(), + bounds.getWidth(), bounds.getHeight()); cairoClip(nativePointer); drawPixels(nativePointer, pixels, width, height, width, i2u, alpha, @@ -1724,11 +1729,11 @@ public abstract class CairoGraphics2D extends Graphics2D setFont (gv.getFont ()); GdkFontPeer fontPeer = (GdkFontPeer) font.getPeer(); - synchronized (fontPeer) - { - cairoDrawGlyphVector(nativePointer, fontPeer, - x, y, n, codes, positions); - } + synchronized (fontPeer) + { + cairoDrawGlyphVector(nativePointer, fontPeer, + x, y, n, codes, positions); + } } else { @@ -1803,9 +1808,9 @@ public abstract class CairoGraphics2D extends Graphics2D { if( onStroke ) { - Shape stroked = stroke.createStrokedShape( s ); - return stroked.intersects( (double)rect.x, (double)rect.y, - (double)rect.width, (double)rect.height ); + Shape stroked = stroke.createStrokedShape( s ); + return stroked.intersects( (double)rect.x, (double)rect.y, + (double)rect.width, (double)rect.height ); } return s.intersects( (double)rect.x, (double)rect.y, (double)rect.width, (double)rect.height ); @@ -1848,34 +1853,34 @@ public abstract class CairoGraphics2D extends Graphics2D imageToUser.getMatrix(i2u); else { - i2u[0] = 1; - i2u[1] = 0; - i2u[2] = 0; - i2u[3] = 1; - i2u[4] = 0; - i2u[5] = 0; + i2u[0] = 1; + i2u[1] = 0; + i2u[2] = 0; + i2u[3] = 1; + i2u[4] = 0; + i2u[5] = 0; } int[] pixels = findSimpleIntegerArray(cm, r); if (pixels == null) { - // FIXME: I don't think this code will work correctly with a non-RGB - // MultiPixelPackedSampleModel. Although this entire method should - // probably be rewritten to better utilize Cairo's different supported - // data formats. - if (sm instanceof MultiPixelPackedSampleModel) - { - pixels = r.getPixels(0, 0, r.getWidth(), r.getHeight(), pixels); - for (int i = 0; i < pixels.length; i++) - pixels[i] = cm.getRGB(pixels[i]); - } - else - { - pixels = new int[r.getWidth() * r.getHeight()]; - for (int i = 0; i < pixels.length; i++) - pixels[i] = cm.getRGB(db.getElem(i)); - } + // FIXME: I don't think this code will work correctly with a non-RGB + // MultiPixelPackedSampleModel. Although this entire method should + // probably be rewritten to better utilize Cairo's different supported + // data formats. + if (sm instanceof MultiPixelPackedSampleModel) + { + pixels = r.getPixels(0, 0, r.getWidth(), r.getHeight(), pixels); + for (int i = 0; i < pixels.length; i++) + pixels[i] = cm.getRGB(pixels[i]); + } + else + { + pixels = new int[r.getWidth() * r.getHeight()]; + for (int i = 0; i < pixels.length; i++) + pixels[i] = cm.getRGB(db.getElem(i)); + } } // Change all transparent pixels in the image to the specified bgcolor, @@ -1883,20 +1888,21 @@ public abstract class CairoGraphics2D extends Graphics2D // correctly. if (cm.hasAlpha()) { - if (bgcolor != null && cm.hasAlpha()) - for (int i = 0; i < pixels.length; i++) - { - if (cm.getAlpha(pixels[i]) == 0) - pixels[i] = bgcolor.getRGB(); - } + if (bgcolor != null && cm.hasAlpha()) + for (int i = 0; i < pixels.length; i++) + { + if (cm.getAlpha(pixels[i]) == 0) + pixels[i] = bgcolor.getRGB(); + } } else for (int i = 0; i < pixels.length; i++) - pixels[i] |= 0xFF000000; + pixels[i] |= 0xFF000000; double alpha = 1.0; if (comp instanceof AlphaComposite) alpha = ((AlphaComposite) comp).getAlpha(); + drawPixels(nativePointer, pixels, r.getWidth(), r.getHeight(), r.getWidth(), i2u, alpha, getInterpolation()); @@ -1950,53 +1956,54 @@ public abstract class CairoGraphics2D extends Graphics2D cairoSetFillRule(nativePointer, p.getWindingRule()); for (; ! p.isDone(); p.next()) { - int seg = p.currentSegment(coords); - switch (seg) - { - case PathIterator.SEG_MOVETO: - x = shiftX(coords[0], doShift); - y = shiftY(coords[1], doShift); - cairoMoveTo(nativePointer, x, y); - break; - case PathIterator.SEG_LINETO: - x = shiftX(coords[0], doShift); - y = shiftY(coords[1], doShift); - cairoLineTo(nativePointer, x, y); - break; - case PathIterator.SEG_QUADTO: - // splitting a quadratic bezier into a cubic: - // see: http://pfaedit.sourceforge.net/bezier.html - double x1 = x + (2.0 / 3.0) * (shiftX(coords[0], doShift) - x); - double y1 = y + (2.0 / 3.0) * (shiftY(coords[1], doShift) - y); - - double x2 = x1 + (1.0 / 3.0) * (shiftX(coords[2], doShift) - x); - double y2 = y1 + (1.0 / 3.0) * (shiftY(coords[3], doShift) - y); - - x = shiftX(coords[2], doShift); - y = shiftY(coords[3], doShift); - cairoCurveTo(nativePointer, x1, y1, x2, y2, x, y); - break; - case PathIterator.SEG_CUBICTO: - x = shiftX(coords[4], doShift); - y = shiftY(coords[5], doShift); - cairoCurveTo(nativePointer, shiftX(coords[0], doShift), - shiftY(coords[1], doShift), - shiftX(coords[2], doShift), - shiftY(coords[3], doShift), x, y); - break; - case PathIterator.SEG_CLOSE: - cairoClosePath(nativePointer); - break; - } + int seg = p.currentSegment(coords); + switch (seg) + { + case PathIterator.SEG_MOVETO: + x = shiftX(coords[0], doShift); + y = shiftY(coords[1], doShift); + cairoMoveTo(nativePointer, x, y); + break; + case PathIterator.SEG_LINETO: + x = shiftX(coords[0], doShift); + y = shiftY(coords[1], doShift); + cairoLineTo(nativePointer, x, y); + break; + case PathIterator.SEG_QUADTO: + // splitting a quadratic bezier into a cubic: + // see: http://pfaedit.sourceforge.net/bezier.html + double x1 = x + (2.0 / 3.0) * (shiftX(coords[0], doShift) - x); + double y1 = y + (2.0 / 3.0) * (shiftY(coords[1], doShift) - y); + + double x2 = x1 + (1.0 / 3.0) * (shiftX(coords[2], doShift) - x); + double y2 = y1 + (1.0 / 3.0) * (shiftY(coords[3], doShift) - y); + + x = shiftX(coords[2], doShift); + y = shiftY(coords[3], doShift); + cairoCurveTo(nativePointer, x1, y1, x2, y2, x, y); + break; + case PathIterator.SEG_CUBICTO: + x = shiftX(coords[4], doShift); + y = shiftY(coords[5], doShift); + cairoCurveTo(nativePointer, shiftX(coords[0], doShift), + shiftY(coords[1], doShift), + shiftX(coords[2], doShift), + shiftY(coords[3], doShift), x, y); + break; + case PathIterator.SEG_CLOSE: + cairoClosePath(nativePointer); + break; + } } } /** * Used by setRenderingHints() */ - private Map getDefaultHints() + private Map<RenderingHints.Key, Object> getDefaultHints() { - HashMap defaultHints = new HashMap(); + HashMap<RenderingHints.Key, Object> defaultHints = + new HashMap<RenderingHints.Key, Object>(); defaultHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); diff --git a/gnu/java/awt/peer/gtk/CairoSurface.java b/gnu/java/awt/peer/gtk/CairoSurface.java index 5b63e62e7..d217c796d 100644 --- a/gnu/java/awt/peer/gtk/CairoSurface.java +++ b/gnu/java/awt/peer/gtk/CairoSurface.java @@ -188,36 +188,36 @@ public class CairoSurface extends WritableRaster // Swap ordering from GdkPixbuf to Cairo if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) { - for (int i = 0; i < data.length; i++ ) - { - // On a big endian system we get a RRGGBBAA data array. - int alpha = data[i] & 0xFF; - if( alpha == 0 ) // I do not know why we need this, but it works. - data[i] = 0; - else - { - // Cairo needs a ARGB32 native array. - data[i] = (data[i] >>> 8) | (alpha << 24); - } - } + for (int i = 0; i < data.length; i++ ) + { + // On a big endian system we get a RRGGBBAA data array. + int alpha = data[i] & 0xFF; + if( alpha == 0 ) // I do not know why we need this, but it works. + data[i] = 0; + else + { + // Cairo needs a ARGB32 native array. + data[i] = (data[i] >>> 8) | (alpha << 24); + } + } } else { - for (int i = 0; i < data.length; i++ ) - { - // On a little endian system we get a AABBGGRR data array. - int alpha = data[i] & 0xFF000000; - if( alpha == 0 ) // I do not know why we need this, but it works. - data[i] = 0; - else - { - int b = (data[i] & 0xFF0000) >> 16; - int g = (data[i] & 0xFF00); - int r = (data[i] & 0xFF) << 16; - // Cairo needs a ARGB32 native array. - data[i] = alpha | r | g | b; - } - } + for (int i = 0; i < data.length; i++ ) + { + // On a little endian system we get a AABBGGRR data array. + int alpha = data[i] & 0xFF000000; + if( alpha == 0 ) // I do not know why we need this, but it works. + data[i] = 0; + else + { + int b = (data[i] & 0xFF0000) >> 16; + int g = (data[i] & 0xFF00); + int r = (data[i] & 0xFF) << 16; + // Cairo needs a ARGB32 native array. + data[i] = alpha | r | g | b; + } + } } setPixels( data ); @@ -289,7 +289,7 @@ public class CairoSurface extends WritableRaster public int getElem(int bank, int i) { if(bank != 0 || i < 0 || i >= width * height) - throw new IndexOutOfBoundsException(i+" size: "+width * height); + throw new IndexOutOfBoundsException(i+" size: "+width * height); return nativeGetElem(bufferPointer, i); } @@ -299,7 +299,7 @@ public class CairoSurface extends WritableRaster public void setElem(int bank, int i, int val) { if(bank != 0 || i < 0 || i >= width*height) - throw new IndexOutOfBoundsException(i+" size: "+width * height); + throw new IndexOutOfBoundsException(i+" size: "+width * height); nativeSetElem(bufferPointer, i, val); } } diff --git a/gnu/java/awt/peer/gtk/ComponentGraphics.java b/gnu/java/awt/peer/gtk/ComponentGraphics.java index 763ad7dfd..fc05264a1 100644 --- a/gnu/java/awt/peer/gtk/ComponentGraphics.java +++ b/gnu/java/awt/peer/gtk/ComponentGraphics.java @@ -52,7 +52,6 @@ import java.awt.Shape; import java.awt.Toolkit; import java.awt.font.GlyphVector; import java.awt.geom.AffineTransform; -import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; @@ -78,7 +77,7 @@ public class ComponentGraphics extends CairoGraphics2D protected long cairo_t; private BufferedImage buffer, componentBuffer; - private static ThreadLocal hasLock = new ThreadLocal(); + private static ThreadLocal<Integer> hasLock = new ThreadLocal<Integer>(); private static Integer ONE = Integer.valueOf(1); ComponentGraphics() @@ -117,8 +116,8 @@ public class ComponentGraphics extends CairoGraphics2D Integer i = (Integer) hasLock.get(); if (i == null) { - start_gdk_drawing(); - hasLock.set(ONE); + start_gdk_drawing(); + hasLock.set(ONE); } else hasLock.set(Integer.valueOf(i.intValue() + 1)); @@ -131,8 +130,8 @@ public class ComponentGraphics extends CairoGraphics2D throw new IllegalStateException(); if (i == ONE) { - hasLock.set(null); - end_gdk_drawing(); + hasLock.set(null); + end_gdk_drawing(); } else hasLock.set(Integer.valueOf(i.intValue() - 1)); @@ -180,11 +179,11 @@ public class ComponentGraphics extends CairoGraphics2D private static native Pointer nativeGrab(GtkComponentPeer component); private native void copyAreaNative(GtkComponentPeer component, int x, int y, - int width, int height, int dx, int dy); + int width, int height, int dx, int dy); private native void drawVolatile(GtkComponentPeer component, - long vimg, int x, int y, - int width, int height, int cx, int cy, + long vimg, int x, int y, + int width, int height, int cx, int cy, int cw, int ch); /** @@ -254,7 +253,7 @@ public class ComponentGraphics extends CairoGraphics2D } finally { - unlock(); + unlock(); } } @@ -280,7 +279,7 @@ public class ComponentGraphics extends CairoGraphics2D } finally { - unlock(); + unlock(); } } @@ -305,7 +304,7 @@ public class ComponentGraphics extends CairoGraphics2D } finally { - unlock(); + unlock(); } } @@ -352,12 +351,12 @@ public class ComponentGraphics extends CairoGraphics2D rv = drawComposite(new Rectangle2D.Double(origin.getX(), origin.getY(), pt.getX(), pt.getY()), - obs); + obs); } } finally { - unlock(); + unlock(); } return rv; } @@ -387,7 +386,7 @@ public class ComponentGraphics extends CairoGraphics2D } finally { - unlock(); + unlock(); } } @@ -417,8 +416,8 @@ public class ComponentGraphics extends CairoGraphics2D (int) r.getHeight()); return true; } - else - return super.drawImage(vimg.getSnapshot(), x, y, observer); + else + return super.drawImage(vimg.getSnapshot(), x, y, observer); } BufferedImage bimg; @@ -426,7 +425,7 @@ public class ComponentGraphics extends CairoGraphics2D bimg = (BufferedImage) img; else { - ImageProducer source = img.getSource(); + ImageProducer source = img.getSource(); if (source == null) return false; bimg = (BufferedImage) Toolkit.getDefaultToolkit().createImage(source); @@ -462,9 +461,9 @@ public class ComponentGraphics extends CairoGraphics2D (int) r.getHeight()); return true; } - else - return super.drawImage(vimg.getSnapshot(), x, y, - width, height, observer); + else + return super.drawImage(vimg.getSnapshot(), x, y, + width, height, observer); } BufferedImage bimg; @@ -473,7 +472,7 @@ public class ComponentGraphics extends CairoGraphics2D bimg = (BufferedImage) img; else { - ImageProducer source = img.getSource(); + ImageProducer source = img.getSource(); if (source == null) return false; bimg = (BufferedImage) Toolkit.getDefaultToolkit().createImage(source); @@ -486,11 +485,11 @@ public class ComponentGraphics extends CairoGraphics2D lock(); try { - super.setClip(s); + super.setClip(s); } finally { - unlock(); + unlock(); } } @@ -516,8 +515,8 @@ public class ComponentGraphics extends CairoGraphics2D transform.transform(points, 0, points, 0, 2); Rectangle2D deviceBounds = new Rectangle2D.Double(points[0], points[1], - points[2] - points[0], - points[3] - points[1]); + points[2] - points[0], + points[3] - points[1]); Rectangle2D.intersect(deviceBounds, this.getClipInDevSpace(), deviceBounds); @@ -579,8 +578,8 @@ public class ComponentGraphics extends CairoGraphics2D new Point(0,0)); componentBuffer = new BufferedImage(GtkVolatileImage.gdkColorModel, rst, - GtkVolatileImage.gdkColorModel.isAlphaPremultiplied(), - new Hashtable()); + GtkVolatileImage.gdkColorModel.isAlphaPremultiplied(), + new Hashtable()); } } diff --git a/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java b/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java index 131a96448..71105ae89 100644 --- a/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java +++ b/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java @@ -112,11 +112,11 @@ public class FreetypeGlyphVector extends GlyphVector getGlyphs(); if( flags == Font.LAYOUT_RIGHT_TO_LEFT ) { - // reverse the glyph ordering. - int[] temp = new int[ nGlyphs ]; - for(int i = 0; i < nGlyphs; i++) - temp[ i ] = glyphCodes[ nGlyphs - i - 1]; - glyphCodes = temp; + // reverse the glyph ordering. + int[] temp = new int[ nGlyphs ]; + for(int i = 0; i < nGlyphs; i++) + temp[i] = glyphCodes[nGlyphs - i - 1]; + glyphCodes = temp; } performDefaultLayout(); } @@ -152,8 +152,8 @@ public class FreetypeGlyphVector extends GlyphVector if( gv.metricsCache != null ) { - metricsCache = new GlyphMetrics[ nGlyphs ]; - System.arraycopy(gv.metricsCache, 0, metricsCache, 0, nGlyphs); + metricsCache = new GlyphMetrics[ nGlyphs ]; + System.arraycopy(gv.metricsCache, 0, metricsCache, 0, nGlyphs); } glyphCodes = new int[ nGlyphs ]; @@ -180,11 +180,11 @@ public class FreetypeGlyphVector extends GlyphVector for(int i = 0; i < nGlyphs; i++) { - codePoints[i] = s.codePointAt( stringIndex ); + codePoints[i] = s.codePointAt( stringIndex ); // UTF32 surrogate handling - if( codePoints[i] != (int)s.charAt( stringIndex ) ) - stringIndex ++; - stringIndex ++; + if( codePoints[i] != (int)s.charAt( stringIndex ) ) + stringIndex ++; + stringIndex ++; if (Character.isISOControl(codePoints[i])) { @@ -291,7 +291,7 @@ public class FreetypeGlyphVector extends GlyphVector * Returns multiple glyphcodes. */ public int[] getGlyphCodes(int beginGlyphIndex, int numEntries, - int[] codeReturn) + int[] codeReturn) { int[] rval; @@ -335,26 +335,25 @@ public class FreetypeGlyphVector extends GlyphVector for(int i = 0; i < nGlyphs; i++) { - GlyphMetrics gm = (GlyphMetrics) - peer.getGlyphMetrics( glyphCodes[ i ] ); - if( gm == null ) - { - double[] val = getMetricsNative( glyphCodes[ i ] ); - if( val == null ) - gm = null; - else - { - gm = new GlyphMetrics( true, - (float)val[1], - (float)val[2], - new Rectangle2D.Double - ( val[3], val[4], - val[5], val[6] ), - GlyphMetrics.STANDARD ); - peer.putGlyphMetrics( glyphCodes[ i ], gm ); - } - } - metricsCache[ i ] = gm; + GlyphMetrics gm = (GlyphMetrics) + peer.getGlyphMetrics( glyphCodes[ i ] ); + if( gm == null ) + { + double[] val = getMetricsNative( glyphCodes[ i ] ); + if( val == null ) + gm = null; + else + { + gm = new GlyphMetrics(true, + (float)val[1], + (float)val[2], + new Rectangle2D.Double(val[3], val[4], + val[5], val[6] ), + GlyphMetrics.STANDARD ); + peer.putGlyphMetrics( glyphCodes[ i ], gm ); + } + } + metricsCache[ i ] = gm; } } @@ -432,7 +431,6 @@ public class FreetypeGlyphVector extends GlyphVector return logicalBounds; Rectangle2D rect = (Rectangle2D)getGlyphLogicalBounds( 0 ); - AffineTransform tx = new AffineTransform(); for( int i = 1; i < nGlyphs; i++ ) { Rectangle2D r2 = (Rectangle2D)getGlyphLogicalBounds( i ); diff --git a/gnu/java/awt/peer/gtk/GdkFontPeer.java b/gnu/java/awt/peer/gtk/GdkFontPeer.java index 5f5126ac5..c3c94d8a9 100644 --- a/gnu/java/awt/peer/gtk/GdkFontPeer.java +++ b/gnu/java/awt/peer/gtk/GdkFontPeer.java @@ -67,7 +67,7 @@ public class GdkFontPeer extends ClasspathFontPeer * The size of the cache has been chosen so that relativly large GUIs with * text documents are still efficient. */ - HashMap textLayoutCache = new GtkToolkit.LRUCache(500); + HashMap<String,TextLayout> textLayoutCache = new GtkToolkit.LRUCache<String,TextLayout>(500); private class GdkFontMetrics extends FontMetrics { @@ -79,7 +79,7 @@ public class GdkFontPeer extends ClasspathFontPeer public int stringWidth (String str) { - TextLayout tl = (TextLayout) textLayoutCache.get(str); + TextLayout tl = textLayoutCache.get(str); if (tl == null) { tl = new TextLayout(str, font, DEFAULT_CTX); @@ -140,7 +140,7 @@ public class GdkFontPeer extends ClasspathFontPeer /** * Cache GlyphMetrics objects. */ - private HashMap metricsCache; + private HashMap<Integer,GlyphMetrics> metricsCache; private static final int FONT_METRICS_ASCENT = 0; private static final int FONT_METRICS_MAX_ASCENT = 1; @@ -235,7 +235,7 @@ public class GdkFontPeer extends ClasspathFontPeer super(name, style, size); initState (); setFont (this.familyName, this.style, (int)this.size); - metricsCache = new HashMap(); + metricsCache = new HashMap<Integer,GlyphMetrics>(); setupMetrics(); } @@ -244,7 +244,7 @@ public class GdkFontPeer extends ClasspathFontPeer super(name, attributes); initState (); setFont (this.familyName, this.style, (int)this.size); - metricsCache = new HashMap(); + metricsCache = new HashMap<Integer,GlyphMetrics>(); setupMetrics(); } @@ -261,9 +261,9 @@ public class GdkFontPeer extends ClasspathFontPeer return font; else { - ClasspathToolkit toolkit; - toolkit = (ClasspathToolkit) Toolkit.getDefaultToolkit(); - return toolkit.getFont(font.getName(), font.getAttributes()); + ClasspathToolkit toolkit; + toolkit = (ClasspathToolkit) Toolkit.getDefaultToolkit(); + return toolkit.getFont(font.getName(), font.getAttributes()); } } @@ -294,9 +294,9 @@ public class GdkFontPeer extends ClasspathFontPeer name = getName(NameDecoder.NAME_SUBFAMILY, locale); if (name == null) { - name = getName(NameDecoder.NAME_SUBFAMILY, Locale.ENGLISH); - if ("Regular".equals(name)) - name = null; + name = getName(NameDecoder.NAME_SUBFAMILY, Locale.ENGLISH); + if ("Regular".equals(name)) + name = null; } return name; @@ -340,12 +340,12 @@ public class GdkFontPeer extends ClasspathFontPeer { if (nameTable == null) { - byte[] data = getTrueTypeTable((byte)'n', (byte) 'a', - (byte) 'm', (byte) 'e'); - if( data == null ) - return null; + byte[] data = getTrueTypeTable((byte)'n', (byte) 'a', + (byte) 'm', (byte) 'e'); + if( data == null ) + return null; - nameTable = ByteBuffer.wrap( data ); + nameTable = ByteBuffer.wrap( data ); } return NameDecoder.getName(nameTable, name, locale); @@ -492,8 +492,8 @@ public class GdkFontPeer extends ClasspathFontPeer char[] chars, int start, int limit, int flags) { - return new FreetypeGlyphVector( font, chars, start, limit - start, - frc, flags); + return new FreetypeGlyphVector(font, chars, start, limit - start, + frc, flags); } public LineMetrics getLineMetrics (Font font, String str, @@ -515,13 +515,13 @@ public class GdkFontPeer extends ClasspathFontPeer */ GlyphMetrics getGlyphMetrics( int glyphCode ) { - return (GlyphMetrics)metricsCache.get( new Integer( glyphCode ) ); + return metricsCache.get(new Integer(glyphCode)); } /** * Put a GlyphMetrics object in the cache. */ - void putGlyphMetrics( int glyphCode, Object metrics ) + void putGlyphMetrics( int glyphCode, GlyphMetrics metrics ) { metricsCache.put( new Integer( glyphCode ), metrics ); } diff --git a/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java b/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java index 6d0a52b91..6f6ea560d 100644 --- a/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java +++ b/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java @@ -184,22 +184,22 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder int len = 0; synchronized(pixbufLock) { - initState(); + initState(); } needsClose = true; // Note: We don't want the pixbufLock while reading from the InputStream. while ((len = is.read (bytes)) != -1) { - synchronized(pixbufLock) - { - pumpBytes (bytes, len); - } + synchronized(pixbufLock) + { + pumpBytes (bytes, len); + } } synchronized(pixbufLock) { - pumpDone(); + pumpDone(); } needsClose = false; @@ -217,7 +217,7 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder { synchronized(pixbufLock) { - finish(needsClose); + finish(needsClose); } } @@ -226,8 +226,8 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder { public String name; public boolean writable = false; - public ArrayList mimeTypes = new ArrayList(); - public ArrayList extensions = new ArrayList(); + public ArrayList<String> mimeTypes = new ArrayList<String>(); + public ArrayList<String> extensions = new ArrayList<String>(); public ImageFormatSpec(String name, boolean writable) { @@ -246,7 +246,7 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder } } - static ArrayList imageFormatSpecs; + static ArrayList<ImageFormatSpec> imageFormatSpecs; public static ImageFormatSpec registerFormat(String name, boolean writable) { @@ -254,7 +254,7 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder synchronized(GdkPixbufDecoder.class) { if (imageFormatSpecs == null) - imageFormatSpecs = new ArrayList(); + imageFormatSpecs = new ArrayList<ImageFormatSpec>(); imageFormatSpecs.add(ifs); } return ifs; @@ -262,13 +262,13 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder static String[] getFormatNames(boolean writable) { - ArrayList names = new ArrayList(); + ArrayList<String> names = new ArrayList<String>(); synchronized (imageFormatSpecs) { - Iterator i = imageFormatSpecs.iterator(); + Iterator<ImageFormatSpec> i = imageFormatSpecs.iterator(); while (i.hasNext()) { - ImageFormatSpec ifs = (ImageFormatSpec) i.next(); + ImageFormatSpec ifs = i.next(); if (writable && !ifs.writable) continue; names.add(ifs.name); @@ -279,62 +279,50 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder * This generally means "all the extensions people might use". */ - Iterator j = ifs.extensions.iterator(); + Iterator<String> j = ifs.extensions.iterator(); while (j.hasNext()) - names.add((String) j.next()); + names.add(j.next()); } } - Object[] objs = names.toArray(); - String[] strings = new String[objs.length]; - for (int i = 0; i < objs.length; ++i) - strings[i] = (String) objs[i]; - return strings; + return names.toArray(new String[names.size()]); } static String[] getFormatExtensions(boolean writable) { - ArrayList extensions = new ArrayList(); + ArrayList<String> extensions = new ArrayList<String>(); synchronized (imageFormatSpecs) { - Iterator i = imageFormatSpecs.iterator(); + Iterator<ImageFormatSpec> i = imageFormatSpecs.iterator(); while (i.hasNext()) { - ImageFormatSpec ifs = (ImageFormatSpec) i.next(); + ImageFormatSpec ifs = i.next(); if (writable && !ifs.writable) continue; - Iterator j = ifs.extensions.iterator(); + Iterator<String> j = ifs.extensions.iterator(); while (j.hasNext()) - extensions.add((String) j.next()); + extensions.add(j.next()); } } - Object[] objs = extensions.toArray(); - String[] strings = new String[objs.length]; - for (int i = 0; i < objs.length; ++i) - strings[i] = (String) objs[i]; - return strings; + return extensions.toArray(new String[extensions.size()]); } static String[] getFormatMimeTypes(boolean writable) { - ArrayList mimeTypes = new ArrayList(); + ArrayList<String> mimeTypes = new ArrayList<String>(); synchronized (imageFormatSpecs) { - Iterator i = imageFormatSpecs.iterator(); + Iterator<ImageFormatSpec> i = imageFormatSpecs.iterator(); while (i.hasNext()) { - ImageFormatSpec ifs = (ImageFormatSpec) i.next(); + ImageFormatSpec ifs = i.next(); if (writable && !ifs.writable) continue; - Iterator j = ifs.mimeTypes.iterator(); + Iterator<String> j = ifs.mimeTypes.iterator(); while (j.hasNext()) - mimeTypes.add((String) j.next()); + mimeTypes.add(j.next()); } } - Object[] objs = mimeTypes.toArray(); - String[] strings = new String[objs.length]; - for (int i = 0; i < objs.length; ++i) - strings[i] = (String) objs[i]; - return strings; + return mimeTypes.toArray(new String[mimeTypes.size()]); } @@ -348,10 +336,10 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder String str = (String) ext; - Iterator i = imageFormatSpecs.iterator(); + Iterator<ImageFormatSpec> i = imageFormatSpecs.iterator(); while (i.hasNext()) { - ImageFormatSpec ifs = (ImageFormatSpec) i.next(); + ImageFormatSpec ifs = i.next(); if (needWritable && !ifs.writable) continue; @@ -359,10 +347,10 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder if (ifs.name.equals(str)) return str; - Iterator j = ifs.extensions.iterator(); + Iterator<String> j = ifs.extensions.iterator(); while (j.hasNext()) { - String extension = (String)j.next(); + String extension = j.next(); if (extension.equals(str)) return ifs.name; } @@ -370,7 +358,7 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder j = ifs.mimeTypes.iterator(); while (j.hasNext()) { - String mimeType = (String)j.next(); + String mimeType = j.next(); if (mimeType.equals(str)) return ifs.name; } @@ -510,10 +498,10 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder if (pixels == null) { - BufferedImage img; - if(model != null && model.hasAlpha()) - img = CairoSurface.getBufferedImage(width, height); - img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + BufferedImage img; + if(model != null && model.hasAlpha()) + img = CairoSurface.getBufferedImage(width, height); + img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); int[] pix = new int[4]; for (int y = 0; y < height; ++y) for (int x = 0; x < width; ++x) @@ -527,10 +515,10 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder workerThread.start(); processImageStarted(1); synchronized(pixbufLock) - { - streamImage(pixels, this.ext, width, height, model.hasAlpha(), - this); - } + { + streamImage(pixels, this.ext, width, height, model.hasAlpha(), + this); + } synchronized(data) { data.add(DATADONE); @@ -539,18 +527,18 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder while (workerThread.isAlive()) { - try - { - workerThread.join(); - } - catch (InterruptedException ioe) - { - // Ignored. - } + try + { + workerThread.join(); + } + catch (InterruptedException ioe) + { + // Ignored. + } } if (exception != null) - throw exception; + throw exception; processImageComplete(); } @@ -566,7 +554,7 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder * Needs to be synchronized for access. * The special object DATADONE is added when all data has been delivered. */ - private ArrayList data = new ArrayList(); + private ArrayList<Object> data = new ArrayList<Object>(); /** * Holds any IOException thrown by the run method that needs @@ -643,7 +631,8 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder this.ext = findFormatName(ext, false); } - public GdkPixbufReader(GdkPixbufReaderSpi ownerSpi, Object ext, GdkPixbufDecoder d) + public GdkPixbufReader(GdkPixbufReaderSpi ownerSpi, Object ext, + GdkPixbufDecoder d) { this(ownerSpi, ext); dec = d; @@ -680,10 +669,12 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder if (bufferedImage == null) { - if(model != null && model.hasAlpha()) - bufferedImage = new BufferedImage (width, height, BufferedImage.TYPE_INT_ARGB); - else - bufferedImage = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB); + if(model != null && model.hasAlpha()) + bufferedImage = new BufferedImage (width, height, + BufferedImage.TYPE_INT_ARGB); + else + bufferedImage = new BufferedImage (width, height, + BufferedImage.TYPE_INT_RGB); } int pixels2[]; @@ -735,11 +726,11 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder return null; } - public Iterator getImageTypes(int imageIndex) + public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IOException { BufferedImage img = getBufferedImage(); - Vector vec = new Vector(); + Vector<ImageTypeSpecifier> vec = new Vector<ImageTypeSpecifier>(); vec.add(new ImageTypeSpecifier(img)); return vec.iterator(); } @@ -767,8 +758,8 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder else if (get instanceof DataInput) dec = new GdkPixbufDecoder((DataInput) get); else - throw new IllegalArgumentException("input object not supported: " - + get); + throw new IllegalArgumentException("input object not supported: " + + get); } public BufferedImage read(int imageIndex, ImageReadParam param) diff --git a/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java b/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java index 62116a322..a69c6f065 100644 --- a/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java +++ b/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java @@ -188,7 +188,7 @@ class GdkScreenGraphicsDevice extends GraphicsDevice displayModes = nativeGetDisplayModes(env); } - ArrayList list = new ArrayList(); + ArrayList<DisplayMode> list = new ArrayList<DisplayMode>(); for(int i=0;i<displayModes.length;i++) for(int j=0;j<displayModes[i].rates.length;j++) list.add(new DisplayMode(displayModes[i].width, @@ -196,7 +196,7 @@ class GdkScreenGraphicsDevice extends GraphicsDevice DisplayMode.BIT_DEPTH_MULTI, displayModes[i].rates[j])); - return (DisplayMode[]) list.toArray(new DisplayMode[list.size()]); + return list.toArray(new DisplayMode[list.size()]); } native X11DisplayMode[] nativeGetDisplayModes(GdkGraphicsEnvironment env); diff --git a/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java b/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java index 90d16c572..4a41d0696 100644 --- a/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java +++ b/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java @@ -57,7 +57,8 @@ public class GtkCheckboxPeer extends GtkComponentPeer private boolean currentState; // A map from CheckboxGroup to GSList* GTK option group pointer. - private static WeakHashMap groupMap = new WeakHashMap(); + private static WeakHashMap<CheckboxGroup,Long> groupMap + = new WeakHashMap<CheckboxGroup,Long>(); public native void createCheckButton (); public native void createRadioButton (long groupPointer); @@ -98,7 +99,7 @@ public class GtkCheckboxPeer extends GtkComponentPeer Long groupPointer = null; synchronized (groupMap) { - groupPointer = (Long) groupMap.get(current_group); + groupPointer = groupMap.get(current_group); } if (groupPointer == null) @@ -133,8 +134,8 @@ public class GtkCheckboxPeer extends GtkComponentPeer { if (currentState != state) { - currentState = state; - gtkToggleButtonSetActive(state); + currentState = state; + gtkToggleButtonSetActive(state); } } @@ -158,7 +159,7 @@ public class GtkCheckboxPeer extends GtkComponentPeer Long groupPointer = null; synchronized (groupMap) { - groupPointer = (Long) groupMap.get(current_group); + groupPointer = groupMap.get(current_group); } if (groupPointer == null) @@ -203,7 +204,7 @@ public class GtkCheckboxPeer extends GtkComponentPeer Long groupPointer = null; synchronized (groupMap) { - groupPointer = (Long) groupMap.get(current_group); + groupPointer = groupMap.get(current_group); } if (groupPointer == null) @@ -230,9 +231,9 @@ public class GtkCheckboxPeer extends GtkComponentPeer // Only fire event is state actually changed. if (currentState != state) { - currentState = state; - super.postItemEvent(awtComponent, - state ? ItemEvent.SELECTED : ItemEvent.DESELECTED); + currentState = state; + super.postItemEvent(awtComponent, + state ? ItemEvent.SELECTED : ItemEvent.DESELECTED); } } diff --git a/gnu/java/awt/peer/gtk/GtkChoicePeer.java b/gnu/java/awt/peer/gtk/GtkChoicePeer.java index d866cefd3..ff061d35c 100644 --- a/gnu/java/awt/peer/gtk/GtkChoicePeer.java +++ b/gnu/java/awt/peer/gtk/GtkChoicePeer.java @@ -55,12 +55,12 @@ public class GtkChoicePeer extends GtkComponentPeer int count = c.getItemCount (); if (count > 0) { - for (int i = 0; i < count; i++) - add( c.getItem(i), i ); + for (int i = 0; i < count; i++) + add(c.getItem(i), i); - selected = c.getSelectedIndex(); - if( selected >= 0 ) - select( selected ); + selected = c.getSelectedIndex(); + if (selected >= 0) + select( selected ); } else selected = -1; @@ -121,9 +121,9 @@ public class GtkChoicePeer extends GtkComponentPeer { if( selected != index ) { - selected = index; - postItemEvent (((Choice) awtComponent).getItem( selected ), - ItemEvent.SELECTED); + selected = index; + postItemEvent (((Choice) awtComponent).getItem( selected ), + ItemEvent.SELECTED); } } @@ -133,11 +133,11 @@ public class GtkChoicePeer extends GtkComponentPeer */ public void handleEvent (AWTEvent event) { - super.handleEvent( event ); - if( event instanceof ItemEvent ) - if( ((ItemEvent)event).getItemSelectable() == awtComponent && - ((ItemEvent)event).getStateChange() == ItemEvent.SELECTED ) - ((Choice)awtComponent).select( selected ); + super.handleEvent (event); + if (event instanceof ItemEvent) + if (((ItemEvent)event).getItemSelectable() == awtComponent + && ((ItemEvent)event).getStateChange() == ItemEvent.SELECTED) + ((Choice)awtComponent).select( selected ); } } diff --git a/gnu/java/awt/peer/gtk/GtkClipboard.java b/gnu/java/awt/peer/gtk/GtkClipboard.java index f520fe224..e41754641 100644 --- a/gnu/java/awt/peer/gtk/GtkClipboard.java +++ b/gnu/java/awt/peer/gtk/GtkClipboard.java @@ -71,9 +71,9 @@ public class GtkClipboard extends Clipboard // cached by GtkSelection. True if // gdk_display_supports_selection_notification. static final boolean canCache = initNativeState(clipboard, selection, - stringMimeType, - imageMimeType, - filesMimeType); + stringMimeType, + imageMimeType, + filesMimeType); /** * Creates the clipboard and sets the initial contents to the @@ -140,8 +140,8 @@ public class GtkClipboard extends Clipboard if (contents == null) { - advertiseContent(null, false, false, false); - return; + advertiseContent(null, false, false, false); + return; } // We don't need to do anything for a GtkSelection facade. @@ -153,46 +153,45 @@ public class GtkClipboard extends Clipboard boolean files = false; if (contents instanceof StringSelection - || contents.isDataFlavorSupported(DataFlavor.stringFlavor) - || contents.isDataFlavorSupported(DataFlavor.plainTextFlavor) - || contents.isDataFlavorSupported(DataFlavor - .getTextPlainUnicodeFlavor())) + || contents.isDataFlavorSupported(DataFlavor.stringFlavor) + || contents.isDataFlavorSupported(DataFlavor.plainTextFlavor) + || contents.isDataFlavorSupported(DataFlavor.getTextPlainUnicodeFlavor())) text = true; DataFlavor[] flavors = contents.getTransferDataFlavors(); String[] mimeTargets = new String[flavors.length]; for (int i = 0; i < flavors.length; i++) { - DataFlavor flavor = flavors[i]; - String mimeType = flavor.getMimeType(); - mimeTargets[i] = mimeType; - - if (! text) - if ("text".equals(flavor.getPrimaryType()) - || flavor.isRepresentationClassReader()) - text = true; - - if (! images && flavors[i].equals(DataFlavor.imageFlavor)) - { - try - { - Object o = contents.getTransferData(DataFlavor.imageFlavor); - if (o instanceof Image) - images = true; - } - catch (UnsupportedFlavorException ufe) - { - } - catch (IOException ioe) - { - } - catch (ClassCastException cce) - { - } - } - - if (flavors[i].equals(DataFlavor.javaFileListFlavor)) - files = true; + DataFlavor flavor = flavors[i]; + String mimeType = flavor.getMimeType(); + mimeTargets[i] = mimeType; + + if (! text) + if ("text".equals(flavor.getPrimaryType()) + || flavor.isRepresentationClassReader()) + text = true; + + if (! images && flavors[i].equals(DataFlavor.imageFlavor)) + { + try + { + Object o = contents.getTransferData(DataFlavor.imageFlavor); + if (o instanceof Image) + images = true; + } + catch (UnsupportedFlavorException ufe) + { + } + catch (IOException ioe) + { + } + catch (ClassCastException cce) + { + } + } + + if (flavors[i].equals(DataFlavor.javaFileListFlavor)) + files = true; } advertiseContent(mimeTargets, text, images, files); @@ -207,9 +206,9 @@ public class GtkClipboard extends Clipboard * selection has explicitly been erased. */ private native void advertiseContent(String[] targets, - boolean text, - boolean images, - boolean files); + boolean text, + boolean images, + boolean files); /** * Called by the gtk+ clipboard when an application has requested @@ -228,7 +227,7 @@ public class GtkClipboard extends Clipboard try { return (String) contents.getTransferData(DataFlavor.stringFlavor); - } + } catch (UnsupportedFlavorException ufe) { } @@ -244,20 +243,20 @@ public class GtkClipboard extends Clipboard // turn the result into a string. try { - DataFlavor plainText = DataFlavor.getTextPlainUnicodeFlavor(); - Reader r = plainText.getReaderForText(contents); - if (r != null) - { - StringBuffer sb = new StringBuffer(); - char[] cs = new char[1024]; - int l = r.read(cs); - while (l != -1) - { - sb.append(cs, 0, l); - l = r.read(cs); - } - return sb.toString(); - } + DataFlavor plainText = DataFlavor.getTextPlainUnicodeFlavor(); + Reader r = plainText.getReaderForText(contents); + if (r != null) + { + StringBuffer sb = new StringBuffer(); + char[] cs = new char[1024]; + int l = r.read(cs); + while (l != -1) + { + sb.append(cs, 0, l); + l = r.read(cs); + } + return sb.toString(); + } } catch (IllegalArgumentException iae) { @@ -288,11 +287,11 @@ public class GtkClipboard extends Clipboard try { - Object o = contents.getTransferData(DataFlavor.imageFlavor); - if( o instanceof GtkImage ) - return (GtkImage) o; - else - return new GtkImage(((Image)o).getSource()); + Object o = contents.getTransferData(DataFlavor.imageFlavor); + if( o instanceof GtkImage ) + return (GtkImage) o; + else + return new GtkImage(((Image)o).getSource()); } catch (UnsupportedFlavorException ufe) { @@ -321,14 +320,13 @@ public class GtkClipboard extends Clipboard try { - List list = (List) contents.getTransferData - (DataFlavor.javaFileListFlavor); - String[] uris = new String[list.size()]; - int u = 0; - Iterator it = list.iterator(); - while (it.hasNext()) - uris[u++] = ((File) it.next()).toURI().toString(); - return uris; + List list = (List) contents.getTransferData(DataFlavor.javaFileListFlavor); + String[] uris = new String[list.size()]; + int u = 0; + Iterator it = list.iterator(); + while (it.hasNext()) + uris[u++] = ((File) it.next()).toURI().toString(); + return uris; } catch (UnsupportedFlavorException ufe) { @@ -365,34 +363,34 @@ public class GtkClipboard extends Clipboard // the other provideXXX() methods. try { - DataFlavor flavor = new DataFlavor(target); - Object o = contents.getTransferData(flavor); - - if (o instanceof byte[]) - return (byte[]) o; - - if (o instanceof InputStream) - { - InputStream is = (InputStream) o; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] bs = new byte[1024]; - int l = is.read(bs); - while (l != -1) - { - baos.write(bs, 0, l); - l = is.read(bs); - } - return baos.toByteArray(); - } - - if (o instanceof Serializable) - { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(o); - oos.close(); - return baos.toByteArray(); - } + DataFlavor flavor = new DataFlavor(target); + Object o = contents.getTransferData(flavor); + + if (o instanceof byte[]) + return (byte[]) o; + + if (o instanceof InputStream) + { + InputStream is = (InputStream) o; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] bs = new byte[1024]; + int l = is.read(bs); + while (l != -1) + { + baos.write(bs, 0, l); + l = is.read(bs); + } + return baos.toByteArray(); + } + + if (o instanceof Serializable) + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(o); + oos.close(); + return baos.toByteArray(); + } } catch (ClassNotFoundException cnfe) { @@ -416,8 +414,8 @@ public class GtkClipboard extends Clipboard * Clipboard can be cached (gdk_display_supports_selection_notification). */ private static native boolean initNativeState(GtkClipboard clipboard, - GtkClipboard selection, - String stringTarget, - String imageTarget, - String filesTarget); + GtkClipboard selection, + String stringTarget, + String imageTarget, + String filesTarget); } diff --git a/gnu/java/awt/peer/gtk/GtkClipboardNotifier.java b/gnu/java/awt/peer/gtk/GtkClipboardNotifier.java index 61df796dc..8e5934557 100644 --- a/gnu/java/awt/peer/gtk/GtkClipboardNotifier.java +++ b/gnu/java/awt/peer/gtk/GtkClipboardNotifier.java @@ -74,11 +74,11 @@ class GtkClipboardNotifier extends Thread { synchronized (notifier) { - if (clipboard == GtkClipboard.clipboard) - announceClipboardChange = true; - else - announcePrimaryChange = true; - notifier.notifyAll(); + if (clipboard == GtkClipboard.clipboard) + announceClipboardChange = true; + else + announcePrimaryChange = true; + notifier.notifyAll(); } } @@ -87,44 +87,43 @@ class GtkClipboardNotifier extends Thread GtkClipboard clipboard; while (true) { - synchronized (this) - { - while (! announceClipboardChange && ! announcePrimaryChange) - { - try - { - this.wait(); - } - catch (InterruptedException ie) - { - // ignore - } - } - - if (announceClipboardChange) - { - clipboard = GtkClipboard.clipboard; - announceClipboardChange = false; - } - else - { - clipboard = GtkClipboard.selection; - announcePrimaryChange = false; - } - } - - // Do the actual announcement without the lock held. We will - // notice a new change after this notification has finished. - try - { - clipboard.setContents(new GtkSelection(clipboard), null); - } - catch (Throwable t) - { - // should never happen, but might if we have some faulty - // listener. - t.printStackTrace(); - } + synchronized (this) + { + while (! announceClipboardChange && ! announcePrimaryChange) + { + try + { + this.wait(); + } + catch (InterruptedException ie) + { + // ignore + } + } + + if (announceClipboardChange) + { + clipboard = GtkClipboard.clipboard; + announceClipboardChange = false; + } + else + { + clipboard = GtkClipboard.selection; + announcePrimaryChange = false; + } + } + + // Do the actual announcement without the lock held. We will + // notice a new change after this notification has finished. + try + { + clipboard.setContents(new GtkSelection(clipboard), null); + } + catch (Throwable t) + { + // should never happen, but might if we have some faulty listener. + t.printStackTrace(); + } } } } diff --git a/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/gnu/java/awt/peer/gtk/GtkComponentPeer.java index b1ef09d6e..a7ae8e17f 100644 --- a/gnu/java/awt/peer/gtk/GtkComponentPeer.java +++ b/gnu/java/awt/peer/gtk/GtkComponentPeer.java @@ -109,7 +109,7 @@ public class GtkComponentPeer extends GtkGenericPeer native void gtkWidgetGetLocationOnScreen (int[] point); native void gtkWidgetSetCursor (int type, GtkImage image, int x, int y); native void gtkWidgetSetCursorUnlocked (int type, GtkImage image, - int x, int y); + int x, int y); native void gtkWidgetSetBackground (int red, int green, int blue); native void gtkWidgetSetForeground (int red, int green, int blue); native void gtkWidgetSetSensitive (boolean sensitive); @@ -206,7 +206,7 @@ public class GtkComponentPeer extends GtkGenericPeer } public int checkImage (Image image, int width, int height, - ImageObserver observer) + ImageObserver observer) { return getToolkit().checkImage(image, width, height, observer); } @@ -402,7 +402,7 @@ public class GtkComponentPeer extends GtkGenericPeer } public boolean prepareImage (Image image, int width, int height, - ImageObserver observer) + ImageObserver observer) { return getToolkit().prepareImage(image, width, height, observer); } @@ -539,17 +539,17 @@ public class GtkComponentPeer extends GtkGenericPeer int type = cursor.getType(); if (cursor instanceof GtkCursor) { - GtkCursor gtkCursor = (GtkCursor) cursor; - image = gtkCursor.getGtkImage(); - Point hotspot = gtkCursor.getHotspot(); - x = hotspot.x; - y = hotspot.y; + GtkCursor gtkCursor = (GtkCursor) cursor; + image = gtkCursor.getGtkImage(); + Point hotspot = gtkCursor.getHotspot(); + x = hotspot.x; + y = hotspot.y; } else { - image = null; - x = 0; - y = 0; + image = null; + x = 0; + y = 0; } if (Thread.currentThread() == GtkMainThread.mainThread) @@ -597,7 +597,7 @@ public class GtkComponentPeer extends GtkGenericPeer if (b && ! (awtComponent instanceof Window)) { Rectangle bounds = awtComponent.getBounds(); - b = (bounds.width > 0) && (bounds.height > 0); + b = (bounds.width > 0) && (bounds.height > 0); } if (Thread.currentThread() == GtkMainThread.mainThread) @@ -617,23 +617,23 @@ public class GtkComponentPeer extends GtkGenericPeer } protected void postMouseEvent(int id, long when, int mods, int x, int y, - int clickCount, boolean popupTrigger) + int clickCount, boolean popupTrigger) { q().postEvent(new MouseEvent(awtComponent, id, when, mods, x, y, - clickCount, popupTrigger)); + clickCount, popupTrigger)); } /** * Callback for component_scroll_cb. */ protected void postMouseWheelEvent(int id, long when, int mods, - int x, int y, int clickCount, - boolean popupTrigger, - int type, int amount, int rotation) + int x, int y, int clickCount, + boolean popupTrigger, + int type, int amount, int rotation) { q().postEvent(new MouseWheelEvent(awtComponent, id, when, mods, - x, y, clickCount, popupTrigger, - type, amount, rotation)); + x, y, clickCount, popupTrigger, + type, amount, rotation)); } protected void postExposeEvent (int x, int y, int width, int height) @@ -659,12 +659,12 @@ public class GtkComponentPeer extends GtkGenericPeer && keyCode != KeyEvent.VK_ALT)) { synchronized(q) - { - q.postEvent(keyEvent); - keyEvent = new KeyEvent(awtComponent, KeyEvent.KEY_TYPED, when, - mods, KeyEvent.VK_UNDEFINED, keyChar, - keyLocation); - q.postEvent(keyEvent); + { + q.postEvent(keyEvent); + keyEvent = new KeyEvent(awtComponent, KeyEvent.KEY_TYPED, when, + mods, KeyEvent.VK_UNDEFINED, keyChar, + keyLocation); + q.postEvent(keyEvent); } } else @@ -685,8 +685,8 @@ public class GtkComponentPeer extends GtkGenericPeer protected void postItemEvent (Object item, int stateChange) { q().postEvent (new ItemEvent ((ItemSelectable)awtComponent, - ItemEvent.ITEM_STATE_CHANGED, - item, stateChange)); + ItemEvent.ITEM_STATE_CHANGED, + item, stateChange)); } protected void postTextEvent () @@ -828,8 +828,8 @@ public class GtkComponentPeer extends GtkGenericPeer // buffer and one front buffer. if (numBuffers == 2) backBuffer = new GtkVolatileImage(this, awtComponent.getWidth(), - awtComponent.getHeight(), - caps.getBackBufferCapabilities()); + awtComponent.getHeight(), + caps.getBackBufferCapabilities()); else throw new AWTException("GtkComponentPeer.createBuffers:" + " multi-buffering not supported"); @@ -846,18 +846,18 @@ public class GtkComponentPeer extends GtkGenericPeer public void flip (BufferCapabilities.FlipContents contents) { getGraphics().drawImage(backBuffer, - awtComponent.getWidth(), - awtComponent.getHeight(), - null); + 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()); + awtComponent.getHeight()); backBuffer.getGraphics().clearRect(0, 0, - awtComponent.getWidth(), - awtComponent.getHeight()); + awtComponent.getWidth(), + awtComponent.getHeight()); } // FIXME: support BufferCapabilities.FlipContents.PRIOR } diff --git a/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java b/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java index 8650578f7..7d5ef91de 100644 --- a/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java +++ b/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java @@ -40,7 +40,6 @@ package gnu.java.awt.peer.gtk; import java.awt.Dialog; import java.awt.FileDialog; -import java.awt.Graphics; import java.awt.event.PaintEvent; import java.awt.peer.FileDialogPeer; import java.io.File; @@ -160,7 +159,8 @@ public class GtkFileDialogPeer extends GtkDialogPeer implements FileDialogPeer in turn call the filter's accept() method and give back the return value. */ // called back by native side: filename_filter_cb - boolean filenameFilterCallback (String fullname) { + boolean filenameFilterCallback (String fullname) + { String filename = fullname.substring(fullname.lastIndexOf(FS) + 1); String dirname = fullname.substring(0, fullname.lastIndexOf(FS)); File dir = new File(dirname); @@ -205,19 +205,19 @@ public class GtkFileDialogPeer extends GtkDialogPeer implements FileDialogPeer if (sepIndex < 0) { /* This should never happen on Unix (all paths start with '/') */ - currentFile = fileName; + currentFile = fileName; } else { if (fileName.length() > (sepIndex + 1)) - { - String fn = fileName.substring (sepIndex + 1); - currentFile = fn; - } - else - { + { + String fn = fileName.substring (sepIndex + 1); + currentFile = fn; + } + else + { currentFile = null; - } + } String dn = fileName.substring (0, sepIndex + 1); currentDirectory = dn; diff --git a/gnu/java/awt/peer/gtk/GtkFramePeer.java b/gnu/java/awt/peer/gtk/GtkFramePeer.java index d113e92f5..8c4a582ef 100644 --- a/gnu/java/awt/peer/gtk/GtkFramePeer.java +++ b/gnu/java/awt/peer/gtk/GtkFramePeer.java @@ -176,13 +176,13 @@ public class GtkFramePeer extends GtkWindowPeer public void setIconImage (Image image) { - if (image != null) - { - if (image instanceof GtkImage) - nativeSetIconImage((GtkImage) image); - else - nativeSetIconImage(new GtkImage(image.getSource())); - } + if (image != null) + { + if (image instanceof GtkImage) + nativeSetIconImage((GtkImage) image); + else + nativeSetIconImage(new GtkImage(image.getSource())); + } } protected void postConfigureEvent (int x, int y, int width, int height) diff --git a/gnu/java/awt/peer/gtk/GtkImage.java b/gnu/java/awt/peer/gtk/GtkImage.java index 0fd98bbd7..db84858cc 100644 --- a/gnu/java/awt/peer/gtk/GtkImage.java +++ b/gnu/java/awt/peer/gtk/GtkImage.java @@ -71,7 +71,7 @@ public class GtkImage extends Image /** * Properties. */ - Hashtable props; + Hashtable<?,?> props; /** * Loaded or not flag, for asynchronous compatibility. @@ -87,7 +87,7 @@ public class GtkImage extends Image /** * Observer queue. */ - Vector observers; + Vector<ImageObserver> observers; /** * Error flag for loading. @@ -103,10 +103,10 @@ public class GtkImage extends Image * The 32-bit AABBGGRR format the GDK uses. */ static ColorModel nativeModel = new DirectColorModel(32, - 0x000000FF, - 0x0000FF00, - 0x00FF0000, - 0xFF000000); + 0x000000FF, + 0x0000FF00, + 0x00FF0000, + 0xFF000000); /** * The singleton GtkImage that is returned on errors by GtkToolkit. @@ -178,7 +178,7 @@ public class GtkImage extends Image public GtkImage (ImageProducer producer) { isLoaded = false; - observers = new Vector(); + observers = new Vector<ImageObserver>(); source = producer; errorLoading = false; source.startProduction(new GtkImageConsumer(this, source)); @@ -194,7 +194,7 @@ public class GtkImage extends Image { isLoaded = true; observers = null; - props = new Hashtable(); + props = new Hashtable<String,Object>(); errorLoading = false; } @@ -208,26 +208,26 @@ public class GtkImage extends Image File f = new File(filename); try { - String path = f.getCanonicalPath(); - synchronized(pixbufLock) - { - if (loadPixbuf(f.getCanonicalPath()) != true) - throw new IllegalArgumentException("Couldn't load image: " - + filename); - } + String path = f.getCanonicalPath(); + synchronized(pixbufLock) + { + if (loadPixbuf(f.getCanonicalPath()) != true) + throw new IllegalArgumentException("Couldn't load image: " + + filename); + } } catch(IOException e) { - IllegalArgumentException iae; - iae = new IllegalArgumentException("Couldn't load image: " - + filename); - iae.initCause(e); - throw iae; + IllegalArgumentException iae; + iae = new IllegalArgumentException("Couldn't load image: " + + filename); + iae.initCause(e); + throw iae; } isLoaded = true; observers = null; - props = new Hashtable(); + props = new Hashtable<String,Object>(); } /** @@ -240,13 +240,13 @@ public class GtkImage extends Image { synchronized(pixbufLock) { - if (loadImageFromData (data) != true) - throw new IllegalArgumentException ("Couldn't load image."); + if (loadImageFromData (data) != true) + throw new IllegalArgumentException ("Couldn't load image."); } isLoaded = true; observers = null; - props = new Hashtable(); + props = new Hashtable<String,Object>(); errorLoading = false; } @@ -256,7 +256,7 @@ public class GtkImage extends Image public GtkImage (URL url) { isLoaded = false; - observers = new Vector(); + observers = new Vector<ImageObserver>(); errorLoading = false; if( url == null) return; @@ -269,23 +269,23 @@ public class GtkImage extends Image int n = 0; while ((n = bis.read(buf)) != -1) - baos.write(buf, 0, n); + baos.write(buf, 0, n); bis.close(); } catch(IOException e) { - throw new IllegalArgumentException ("Couldn't load image."); + throw new IllegalArgumentException ("Couldn't load image."); } byte[] array = baos.toByteArray(); synchronized(pixbufLock) { - if (loadImageFromData(array) != true) - throw new IllegalArgumentException ("Couldn't load image."); + if (loadImageFromData(array) != true) + throw new IllegalArgumentException ("Couldn't load image."); } isLoaded = true; observers = null; - props = new Hashtable(); + props = new Hashtable<String,Object>(); } /** @@ -295,14 +295,14 @@ public class GtkImage extends Image { this.width = width; this.height = height; - props = new Hashtable(); + props = new Hashtable<String,Object>(); isLoaded = true; observers = null; // Use the GDK scaling method. synchronized(pixbufLock) { - createScaledPixbuf(src, hints); + createScaledPixbuf(src, hints); } } @@ -315,11 +315,11 @@ public class GtkImage extends Image this.pixbuf = pixbuf; synchronized(pixbufLock) { - createFromPixbuf(); + createFromPixbuf(); } isLoaded = true; observers = null; - props = new Hashtable(); + props = new Hashtable<String,Object>(); } /** @@ -331,7 +331,7 @@ public class GtkImage extends Image { this.width = width; this.height = height; - props = new Hashtable(); + props = new Hashtable<String,Object>(); isLoaded = true; observers = null; initFromBuffer( bufferPointer ); @@ -346,8 +346,8 @@ public class GtkImage extends Image { if (errorImage == null) { - errorImage = new GtkImage(); - errorImage.errorLoading = true; + errorImage = new GtkImage(); + errorImage.errorLoading = true; } return errorImage; } @@ -362,24 +362,24 @@ public class GtkImage extends Image * Callback from the image consumer. */ public void setImage(int width, int height, - int[] pixels, Hashtable properties) + int[] pixels, Hashtable<?,?> properties) { this.width = width; this.height = height; - props = (properties != null) ? properties : new Hashtable(); + props = (properties != null) ? properties : new Hashtable<String,Object>(); if (width <= 0 || height <= 0 || pixels == null) { - errorLoading = true; - return; + errorLoading = true; + return; } isLoaded = true; deliver(); synchronized(pixbufLock) { - createPixbuf(); - setPixels(pixels); + createPixbuf(); + setPixels(pixels); } } @@ -427,7 +427,7 @@ public class GtkImage extends Image return null; } return new MemoryImageSource(width, height, nativeModel, pixels, - 0, width); + 0, width); } /** @@ -436,19 +436,19 @@ public class GtkImage extends Image public Graphics getGraphics () { throw new IllegalAccessError("This method only works for off-screen" - +" Images."); + +" Images."); } /** * Returns a scaled instance of this pixbuf. */ public Image getScaledInstance(int width, - int height, - int hints) + int height, + int hints) { if (width <= 0 || height <= 0) - throw new IllegalArgumentException("Width and height of scaled bitmap"+ - "must be >= 0"); + throw new IllegalArgumentException("Width and height of scaled bitmap" + + "must be >= 0"); return new GtkImage(this, width, height, hints); } @@ -465,13 +465,13 @@ public class GtkImage extends Image { if (isLoaded && source != null) { - observers = new Vector(); - isLoaded = false; - synchronized(pixbufLock) + observers = new Vector<ImageObserver>(); + isLoaded = false; + synchronized(pixbufLock) { freePixbuf(); } - source.startProduction(new GtkImageConsumer(this, source)); + source.startProduction(new GtkImageConsumer(this, source)); } } @@ -479,10 +479,10 @@ public class GtkImage extends Image { if (isLoaded) { - synchronized(pixbufLock) - { - freePixbuf(); - } + synchronized(pixbufLock) + { + freePixbuf(); + } } } @@ -493,10 +493,10 @@ public class GtkImage extends Image { if (addObserver(observer)) { - if (errorLoading == true) - return ImageObserver.ERROR; - else - return 0; + if (errorLoading == true) + return ImageObserver.ERROR; + else + return 0; } return ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT; @@ -517,8 +517,8 @@ public class GtkImage extends Image if (observers != null) for(int i=0; i < observers.size(); i++) - ((ImageObserver)observers.elementAt(i)). - imageUpdate(this, flags, 0, 0, width, height); + ((ImageObserver)observers.elementAt(i)).imageUpdate(this, flags, 0, 0, + width, height); observers = null; } @@ -531,10 +531,10 @@ public class GtkImage extends Image { if (!isLoaded) { - if(observer != null) - if (!observers.contains (observer)) - observers.addElement (observer); - return true; + if(observer != null) + if (!observers.contains (observer)) + observers.addElement (observer); + return true; } return false; } diff --git a/gnu/java/awt/peer/gtk/GtkImageConsumer.java b/gnu/java/awt/peer/gtk/GtkImageConsumer.java index 53e97bb1a..44cfaf926 100644 --- a/gnu/java/awt/peer/gtk/GtkImageConsumer.java +++ b/gnu/java/awt/peer/gtk/GtkImageConsumer.java @@ -55,7 +55,7 @@ public class GtkImageConsumer implements ImageConsumer { private GtkImage target; private int width, height; - private Hashtable properties; + private Hashtable<?,?> properties; private int[] pixelCache = null; private ImageProducer source; @@ -97,55 +97,55 @@ public class GtkImageConsumer implements ImageConsumer } public synchronized void setPixels (int x, int y, int width, int height, - ColorModel cm, byte[] pixels, - int offset, int scansize) + ColorModel cm, byte[] pixels, + int offset, int scansize) { setPixels (x, y, width, height, cm, convertPixels (pixels), offset, scansize); } public synchronized void setPixels (int x, int y, int width, int height, - ColorModel cm, int[] pixels, - int offset, int scansize) + ColorModel cm, int[] pixels, + int offset, int scansize) { if (pixelCache == null) return; // Not sure this should ever happen. if (cm.equals(GtkImage.nativeModel)) for (int i = 0; i < height; i++) - System.arraycopy (pixels, offset + (i * scansize), - pixelCache, (y + i) * this.width + x, - width); + System.arraycopy (pixels, offset + (i * scansize), + pixelCache, (y + i) * this.width + x, + width); else { - if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) - { - for (int i = 0; i < height; i++) - for (int j = 0; j < width; j++) - { - // get in RRGGBBAA and convert to AARRGGBB - int pix = cm.getRGB(pixels[offset + (i * scansize) + x + j]); - int a = ((pix & 0xFF000000) >> 24) & 0xFF; - int rgb = (pix & 0x00FFFFFF) << 8; - pix = rgb | a; - pixelCache[(y + i) * this.width + x + j] = pix; - } - } - else - { - for (int i = 0; i < height; i++) - for (int j = 0; j < width; j++) - { - // get in AARRGGBB and convert to AABBGGRR - int pix = cm.getRGB(pixels[offset + (i * scansize) + x + j]); - byte b = (byte)(pix & 0xFF); - byte r = (byte)(((pix & 0x00FF0000) >> 16) & 0xFF); - pix &= 0xFF00FF00; - pix |= ((b & 0xFF) << 16); - pix |= (r & 0xFF); - pixelCache[(y + i) * this.width + x + j] = pix; - } - } + if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) + { + for (int i = 0; i < height; i++) + for (int j = 0; j < width; j++) + { + // get in RRGGBBAA and convert to AARRGGBB + int pix = cm.getRGB(pixels[offset + (i * scansize) + x + j]); + int a = ((pix & 0xFF000000) >> 24) & 0xFF; + int rgb = (pix & 0x00FFFFFF) << 8; + pix = rgb | a; + pixelCache[(y + i) * this.width + x + j] = pix; + } + } + else + { + for (int i = 0; i < height; i++) + for (int j = 0; j < width; j++) + { + // get in AARRGGBB and convert to AABBGGRR + int pix = cm.getRGB(pixels[offset + (i * scansize) + x + j]); + byte b = (byte)(pix & 0xFF); + byte r = (byte)(((pix & 0x00FF0000) >> 16) & 0xFF); + pix &= 0xFF00FF00; + pix |= ((b & 0xFF) << 16); + pix |= (r & 0xFF); + pixelCache[(y + i) * this.width + x + j] = pix; + } + } } } @@ -162,7 +162,7 @@ public class GtkImageConsumer implements ImageConsumer return ret; } - public synchronized void setProperties (Hashtable props) + public synchronized void setProperties (Hashtable<?,?> props) { this.properties = props; } diff --git a/gnu/java/awt/peer/gtk/GtkLabelPeer.java b/gnu/java/awt/peer/gtk/GtkLabelPeer.java index 02db90d72..76f8e5fe3 100644 --- a/gnu/java/awt/peer/gtk/GtkLabelPeer.java +++ b/gnu/java/awt/peer/gtk/GtkLabelPeer.java @@ -90,11 +90,11 @@ public class GtkLabelPeer extends GtkComponentPeer switch (alignment) { case Label.LEFT: - return 0.0f; + return 0.0f; case Label.CENTER: - return 0.5f; + return 0.5f; case Label.RIGHT: - return 1.0f; + return 1.0f; } return 0.0f; diff --git a/gnu/java/awt/peer/gtk/GtkListPeer.java b/gnu/java/awt/peer/gtk/GtkListPeer.java index bd6ec0aef..f943a75d1 100644 --- a/gnu/java/awt/peer/gtk/GtkListPeer.java +++ b/gnu/java/awt/peer/gtk/GtkListPeer.java @@ -148,33 +148,33 @@ public class GtkListPeer extends GtkComponentPeer { // Only generate the ActionEvent on the second click of a // multiple click. - MouseEvent me = (MouseEvent) e; - if (!me.isConsumed () - && (me.getModifiersEx () & MouseEvent.BUTTON1_DOWN_MASK) != 0 - && me.getClickCount() == 2) - { + MouseEvent me = (MouseEvent) e; + if (!me.isConsumed () + && (me.getModifiersEx () & MouseEvent.BUTTON1_DOWN_MASK) != 0 + && me.getClickCount() == 2) + { String selectedItem = ((List) awtComponent).getSelectedItem (); // Double-click only generates an Action event if // something is selected. if (selectedItem != null) - postActionEvent (((List) awtComponent).getSelectedItem (), - me.getModifiersEx ()); - } + postActionEvent (((List) awtComponent).getSelectedItem (), + me.getModifiersEx ()); + } } if (e.getID () == KeyEvent.KEY_PRESSED) { - KeyEvent ke = (KeyEvent) e; - if (!ke.isConsumed () && ke.getKeyCode () == KeyEvent.VK_ENTER) - { + KeyEvent ke = (KeyEvent) e; + if (!ke.isConsumed () && ke.getKeyCode () == KeyEvent.VK_ENTER) + { String selectedItem = ((List) awtComponent).getSelectedItem (); // Enter only generates an Action event if something is // selected. if (selectedItem != null) - postActionEvent (selectedItem, ke.getModifiersEx ()); - } + postActionEvent (selectedItem, ke.getModifiersEx ()); + } } super.handleEvent (e); diff --git a/gnu/java/awt/peer/gtk/GtkMainThread.java b/gnu/java/awt/peer/gtk/GtkMainThread.java index a4e280fe4..e40a04eed 100644 --- a/gnu/java/awt/peer/gtk/GtkMainThread.java +++ b/gnu/java/awt/peer/gtk/GtkMainThread.java @@ -40,8 +40,6 @@ package gnu.java.awt.peer.gtk; import gnu.java.awt.peer.NativeEventLoopRunningEvent; -import java.awt.AWTEvent; - /** * The Java thread representing the native GTK main loop, that is, * GtkMainThread.mainThread, terminates when GtkToolkit.gtkMain() @@ -172,9 +170,9 @@ public class GtkMainThread extends Thread { synchronized (nWindowsLock) { - if (numberOfWindows == 0) - startMainThread(); - numberOfWindows++; + if (numberOfWindows == 0) + startMainThread(); + numberOfWindows++; } } @@ -182,9 +180,9 @@ public class GtkMainThread extends Thread { synchronized (nWindowsLock) { - numberOfWindows--; - if (numberOfWindows == 0) - endMainThread(); + numberOfWindows--; + if (numberOfWindows == 0) + endMainThread(); } } } diff --git a/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java b/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java index 898f224f5..c3427b18f 100644 --- a/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java +++ b/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java @@ -76,15 +76,15 @@ public class GtkMenuBarPeer extends GtkMenuComponentPeer { if (hasHelpMenu) { - // Remove the (help) menu, which is after all the other items. - delMenu(((MenuBar) awtWidget).getMenuCount()); - hasHelpMenu = false; + // Remove the (help) menu, which is after all the other items. + delMenu(((MenuBar) awtWidget).getMenuCount()); + hasHelpMenu = false; } if (menu != null) { - addMenu(menu); - hasHelpMenu = true; + addMenu(menu); + hasHelpMenu = true; } } @@ -103,9 +103,9 @@ public class GtkMenuBarPeer extends GtkMenuComponentPeer // Make sure the help menu is the last one. if (hasHelpMenu) { - addHelpMenu(null); - addMenu((GtkMenuPeer) m.getPeer()); - addHelpMenu(((MenuBar) awtWidget).getHelpMenu()); + addHelpMenu(null); + addMenu((GtkMenuPeer) m.getPeer()); + addHelpMenu(((MenuBar) awtWidget).getHelpMenu()); } else addMenu((GtkMenuPeer) m.getPeer()); diff --git a/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java b/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java index 55b95a18d..1e37cefc1 100644 --- a/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java +++ b/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java @@ -64,9 +64,9 @@ public abstract class GtkMenuComponentPeer extends GtkGenericPeer if (f == null) { MenuContainer parent = mc.getParent (); - // Submenus inherit the font of their containing Menu(Bar). - if (parent instanceof MenuComponent) - f = parent.getFont (); + // Submenus inherit the font of their containing Menu(Bar). + if (parent instanceof MenuComponent) + f = parent.getFont (); } setFont(f); diff --git a/gnu/java/awt/peer/gtk/GtkMenuPeer.java b/gnu/java/awt/peer/gtk/GtkMenuPeer.java index 1d581c1a1..ff6bdca9f 100644 --- a/gnu/java/awt/peer/gtk/GtkMenuPeer.java +++ b/gnu/java/awt/peer/gtk/GtkMenuPeer.java @@ -96,8 +96,8 @@ public class GtkMenuPeer extends GtkMenuItemPeer MenuShortcut ms = item.getShortcut (); if (ms != null) { - key = ms.getKey (); - shiftModifier = ms.usesShiftModifier (); + key = ms.getKey (); + shiftModifier = ms.usesShiftModifier (); } addItem ((MenuItemPeer) item.getPeer (), key, shiftModifier); @@ -110,8 +110,8 @@ public class GtkMenuPeer extends GtkMenuItemPeer if (ms != null) { - key = ms.getKey (); - shiftModifier = ms.usesShiftModifier (); + key = ms.getKey (); + shiftModifier = ms.usesShiftModifier (); } addItem (item, key, shiftModifier); diff --git a/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java b/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java index 02bf84d4e..7aea50991 100644 --- a/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java +++ b/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java @@ -53,9 +53,9 @@ public class GtkMouseInfoPeer implements MouseInfoPeer public int fillPointWithCoords(Point p) { int[] coords = gde.getMouseCoordinates(); - p.x = coords[1]; - p.y = coords[2]; - return coords[0]; + p.x = coords[1]; + p.y = coords[2]; + return coords[0]; } public boolean isWindowUnderMouse(Window w) diff --git a/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java b/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java index 69f8b4946..657a27608 100644 --- a/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java +++ b/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java @@ -74,10 +74,8 @@ public class GtkScrollPanePeer extends GtkContainerPeer // If the child is in this range, GTK adds both scrollbars, but // the AWT doesn't. So set the peer's scroll policy to // GTK_POLICY_NEVER. - if ((width > dim[0] - getVScrollbarWidth () - && width <= dim[0]) - && (height > dim[1] - getHScrollbarHeight () - && height <= dim[1])) + if ((width > dim[0] - getVScrollbarWidth () && width <= dim[0]) + && (height > dim[1] - getHScrollbarHeight () && height <= dim[1])) setPolicy (ScrollPane.SCROLLBARS_NEVER); else setPolicy (((ScrollPane) awtComponent).getScrollbarDisplayPolicy ()); diff --git a/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java b/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java index e4147d36c..c29706f40 100644 --- a/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java +++ b/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java @@ -50,14 +50,14 @@ public class GtkScrollbarPeer extends GtkComponentPeer Scrollbar sb = (Scrollbar) awtComponent; create (sb.getOrientation (), sb.getValue (), - sb.getMinimum (), sb.getMaximum (), - sb.getUnitIncrement (), sb.getBlockIncrement (), - sb.getVisibleAmount ()); + sb.getMinimum (), sb.getMaximum (), + sb.getUnitIncrement (), sb.getBlockIncrement (), + sb.getVisibleAmount ()); } native void create (int orientation, int value, - int min, int max, int stepIncr, int pageIncr, - int visibleAmount); + int min, int max, int stepIncr, int pageIncr, + int visibleAmount); native void connectSignals (); @@ -86,7 +86,7 @@ public class GtkScrollbarPeer extends GtkComponentPeer { Scrollbar bar = (Scrollbar) awtComponent; q().postEvent(new AdjustmentEvent(bar, - AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, - type, value, true)); + AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, + type, value, true)); } } diff --git a/gnu/java/awt/peer/gtk/GtkSelection.java b/gnu/java/awt/peer/gtk/GtkSelection.java index 6a92f86e8..967a2edb4 100644 --- a/gnu/java/awt/peer/gtk/GtkSelection.java +++ b/gnu/java/awt/peer/gtk/GtkSelection.java @@ -130,7 +130,7 @@ public class GtkSelection implements Transferable * Set as response to a requestURIs() call. Only valid when * urisDelivered is true */ - private List uris; + private List<File> uris; /** * Indicates a requestBytes(String) call was made and the @@ -163,51 +163,51 @@ public class GtkSelection implements Transferable DataFlavor[] result; synchronized (requestLock) { - // Did we request already and cache the result? - if (mimeTypesDelivered) - result = (DataFlavor[]) dataFlavors.clone(); - else - { - // Wait till there are no pending requests. - while (requestInProgress) - { - try - { - requestLock.wait(); - } - catch (InterruptedException ie) - { - // ignored - } - } - - // If nobody else beat us and cached the result we try - // ourselves to get it. - if (! mimeTypesDelivered) - { - requestInProgress = true; - requestMimeTypes(clipboard); - while (! mimeTypesDelivered) - { - try - { - requestLock.wait(); - } - catch (InterruptedException ie) - { - // ignored - } - } - requestInProgress = false; - } - result = dataFlavors; - if (! GtkClipboard.canCache) - { - dataFlavors = null; - mimeTypesDelivered = false; - } - requestLock.notifyAll(); - } + // Did we request already and cache the result? + if (mimeTypesDelivered) + result = (DataFlavor[]) dataFlavors.clone(); + else + { + // Wait till there are no pending requests. + while (requestInProgress) + { + try + { + requestLock.wait(); + } + catch (InterruptedException ie) + { + // ignored + } + } + + // If nobody else beat us and cached the result we try + // ourselves to get it. + if (! mimeTypesDelivered) + { + requestInProgress = true; + requestMimeTypes(clipboard); + while (! mimeTypesDelivered) + { + try + { + requestLock.wait(); + } + catch (InterruptedException ie) + { + // ignored + } + } + requestInProgress = false; + } + result = dataFlavors; + if (! GtkClipboard.canCache) + { + dataFlavors = null; + mimeTypesDelivered = false; + } + requestLock.notifyAll(); + } } return result; } @@ -220,53 +220,55 @@ public class GtkSelection implements Transferable { synchronized (requestLock) { - if (mimeTypes == null) - dataFlavors = new DataFlavor[0]; - else - { - // Most likely the mimeTypes include text in which case we add an - // extra element. - ArrayList flavorsList = new ArrayList(mimeTypes.length + 1); - for (int i = 0; i < mimeTypes.length; i++) - { - try - { - if (mimeTypes[i] == GtkClipboard.stringMimeType) - { - // XXX - Fix DataFlavor.getTextPlainUnicodeFlavor() - // and also add it to the list. - flavorsList.add(DataFlavor.stringFlavor); - flavorsList.add(DataFlavor.plainTextFlavor); - } - else if (mimeTypes[i] == GtkClipboard.imageMimeType) - flavorsList.add(DataFlavor.imageFlavor); - else if (mimeTypes[i] == GtkClipboard.filesMimeType) - flavorsList.add(DataFlavor.javaFileListFlavor); - else - { - // We check the target to prevent duplicates - // of the "magic" targets above. - DataFlavor target = new DataFlavor(mimeTypes[i]); - if (! flavorsList.contains(target)) - flavorsList.add(target); - } - } - catch (ClassNotFoundException cnfe) - { - cnfe.printStackTrace(); - } - catch (NullPointerException npe) - { - npe.printStackTrace(); - } - } + if (mimeTypes == null) + dataFlavors = new DataFlavor[0]; + else + { + // Most likely the mimeTypes include text in which case we add an + // extra element. + ArrayList<DataFlavor> flavorsList = + new ArrayList<DataFlavor>(mimeTypes.length + 1); + + for (int i = 0; i < mimeTypes.length; i++) + { + try + { + if (mimeTypes[i] == GtkClipboard.stringMimeType) + { + // XXX - Fix DataFlavor.getTextPlainUnicodeFlavor() + // and also add it to the list. + flavorsList.add(DataFlavor.stringFlavor); + flavorsList.add(DataFlavor.plainTextFlavor); + } + else if (mimeTypes[i] == GtkClipboard.imageMimeType) + flavorsList.add(DataFlavor.imageFlavor); + else if (mimeTypes[i] == GtkClipboard.filesMimeType) + flavorsList.add(DataFlavor.javaFileListFlavor); + else + { + // We check the target to prevent duplicates + // of the "magic" targets above. + DataFlavor target = new DataFlavor(mimeTypes[i]); + if (! flavorsList.contains(target)) + flavorsList.add(target); + } + } + catch (ClassNotFoundException cnfe) + { + cnfe.printStackTrace(); + } + catch (NullPointerException npe) + { + npe.printStackTrace(); + } + } - dataFlavors = new DataFlavor[flavorsList.size()]; - flavorsList.toArray(dataFlavors); - } + dataFlavors = new DataFlavor[flavorsList.size()]; + flavorsList.toArray(dataFlavors); + } - mimeTypesDelivered = true; - requestLock.notifyAll(); + mimeTypesDelivered = true; + requestLock.notifyAll(); } } @@ -279,7 +281,7 @@ public class GtkSelection implements Transferable DataFlavor[] dfs = getTransferDataFlavors(); for (int i = 0; i < dfs.length; i++) if (flavor.equals(dfs[i])) - return true; + return true; return false; } @@ -294,51 +296,51 @@ public class GtkSelection implements Transferable String result; synchronized (requestLock) { - // Did we request already and cache the result? - if (textDelivered) - result = text; - else - { - // Wait till there are no pending requests. - while (requestInProgress) - { - try - { - requestLock.wait(); - } - catch (InterruptedException ie) - { - // ignored - } - } - - // If nobody else beat us we try ourselves to get and - // caching the result. - if (! textDelivered) - { - requestInProgress = true; - requestText(clipboard); - while (! textDelivered) - { - try - { - requestLock.wait(); - } - catch (InterruptedException ie) - { - // ignored - } - } - requestInProgress = false; - } - result = text; - if (! GtkClipboard.canCache) - { - text = null; - textDelivered = false; - } - requestLock.notifyAll(); - } + // Did we request already and cache the result? + if (textDelivered) + result = text; + else + { + // Wait till there are no pending requests. + while (requestInProgress) + { + try + { + requestLock.wait(); + } + catch (InterruptedException ie) + { + // ignored + } + } + + // If nobody else beat us we try ourselves to get and + // caching the result. + if (! textDelivered) + { + requestInProgress = true; + requestText(clipboard); + while (! textDelivered) + { + try + { + requestLock.wait(); + } + catch (InterruptedException ie) + { + // ignored + } + } + requestInProgress = false; + } + result = text; + if (! GtkClipboard.canCache) + { + text = null; + textDelivered = false; + } + requestLock.notifyAll(); + } } return result; } @@ -351,9 +353,9 @@ public class GtkSelection implements Transferable { synchronized (requestLock) { - this.text = text; - textDelivered = true; - requestLock.notifyAll(); + this.text = text; + textDelivered = true; + requestLock.notifyAll(); } } @@ -367,54 +369,56 @@ public class GtkSelection implements Transferable Image result; synchronized (requestLock) { - // Did we request already and cache the result? - if (imageDelivered) - result = image; - else - { - // Wait till there are no pending requests. - while (requestInProgress) - { - try - { - requestLock.wait(); - } - catch (InterruptedException ie) - { - // ignored - } - } - - // If nobody else beat us we try ourselves to get and - // caching the result. - if (! imageDelivered) - { - requestInProgress = true; - requestImage(clipboard); - while (! imageDelivered) - { - try - { - requestLock.wait(); - } - catch (InterruptedException ie) - { - // ignored - } - } - requestInProgress = false; - } - if (imagePointer != null) - image = new GtkImage(imagePointer); - imagePointer = null; - result = image; - if (! GtkClipboard.canCache) - { - image = null; - imageDelivered = false; - } - requestLock.notifyAll(); - } + // Did we request already and cache the result? + if (imageDelivered) + result = image; + else + { + // Wait till there are no pending requests. + while (requestInProgress) + { + try + { + requestLock.wait(); + } + catch (InterruptedException ie) + { + // ignored + } + } + + // If nobody else beat us we try ourselves to get and + // caching the result. + if (! imageDelivered) + { + requestInProgress = true; + requestImage(clipboard); + while (! imageDelivered) + { + try + { + requestLock.wait(); + } + catch (InterruptedException ie) + { + // ignored + } + } + requestInProgress = false; + } + + if (imagePointer != null) + image = new GtkImage(imagePointer); + + imagePointer = null; + result = image; + if (! GtkClipboard.canCache) + { + image = null; + imageDelivered = false; + } + requestLock.notifyAll(); + } } return result; } @@ -430,9 +434,9 @@ public class GtkSelection implements Transferable { synchronized (requestLock) { - this.imagePointer = pointer; - imageDelivered = true; - requestLock.notifyAll(); + this.imagePointer = pointer; + imageDelivered = true; + requestLock.notifyAll(); } } @@ -441,56 +445,56 @@ public class GtkSelection implements Transferable * URIs/Files and if not requests them and waits till they are * available. */ - private List getURIs() + private List<File> getURIs() { - List result; + List<File> result; synchronized (requestLock) { - // Did we request already and cache the result? - if (urisDelivered) - result = uris; - else - { - // Wait till there are no pending requests. - while (requestInProgress) - { - try - { - requestLock.wait(); - } - catch (InterruptedException ie) - { - // ignored - } - } - - // If nobody else beat us we try ourselves to get and - // caching the result. - if (! urisDelivered) - { - requestInProgress = true; - requestURIs(clipboard); - while (! urisDelivered) - { - try - { - requestLock.wait(); - } - catch (InterruptedException ie) - { - // ignored - } - } - requestInProgress = false; - } - result = uris; - if (! GtkClipboard.canCache) - { - uris = null; - urisDelivered = false; - } - requestLock.notifyAll(); - } + // Did we request already and cache the result? + if (urisDelivered) + result = uris; + else + { + // Wait till there are no pending requests. + while (requestInProgress) + { + try + { + requestLock.wait(); + } + catch (InterruptedException ie) + { + // ignored + } + } + + // If nobody else beat us we try ourselves to get and + // caching the result. + if (! urisDelivered) + { + requestInProgress = true; + requestURIs(clipboard); + while (! urisDelivered) + { + try + { + requestLock.wait(); + } + catch (InterruptedException ie) + { + // ignored + } + } + requestInProgress = false; + } + result = uris; + if (! GtkClipboard.canCache) + { + uris = null; + urisDelivered = false; + } + requestLock.notifyAll(); + } } return result; } @@ -503,26 +507,26 @@ public class GtkSelection implements Transferable { synchronized (requestLock) { - if (uris != null && uris.length != 0) - { - ArrayList list = new ArrayList(uris.length); - for (int i = 0; i < uris.length; i++) - { - try - { - URI uri = new URI(uris[i]); - if (uri.getScheme().equals("file")) - list.add(new File(uri)); - } - catch (URISyntaxException use) - { - } - } - this.uris = list; - } - - urisDelivered = true; - requestLock.notifyAll(); + if (uris != null && uris.length != 0) + { + ArrayList<File> list = new ArrayList<File>(uris.length); + for (int i = 0; i < uris.length; i++) + { + try + { + URI uri = new URI(uris[i]); + if (uri.getScheme().equals("file")) + list.add(new File(uri)); + } + catch (URISyntaxException use) + { + } + } + this.uris = list; + } + + urisDelivered = true; + requestLock.notifyAll(); } } @@ -537,39 +541,39 @@ public class GtkSelection implements Transferable byte[] result; synchronized (requestLock) { - // Wait till there are no pending requests. - while (requestInProgress) - { - try - { - requestLock.wait(); - } - catch (InterruptedException ie) - { - // ignored - } - } - - // Request bytes and wait till they are available. - requestInProgress = true; - requestBytes(clipboard, target); - while (! bytesDelivered) - { - try - { - requestLock.wait(); - } - catch (InterruptedException ie) - { - // ignored - } - } - result = bytes; - bytes = null; - bytesDelivered = false; - requestInProgress = false; + // Wait till there are no pending requests. + while (requestInProgress) + { + try + { + requestLock.wait(); + } + catch (InterruptedException ie) + { + // ignored + } + } + + // Request bytes and wait till they are available. + requestInProgress = true; + requestBytes(clipboard, target); + while (! bytesDelivered) + { + try + { + requestLock.wait(); + } + catch (InterruptedException ie) + { + // ignored + } + } + result = bytes; + bytes = null; + bytesDelivered = false; + requestInProgress = false; - requestLock.notifyAll(); + requestLock.notifyAll(); } return result; } @@ -583,9 +587,9 @@ public class GtkSelection implements Transferable { synchronized (requestLock) { - this.bytes = bytes; - bytesDelivered = true; - requestLock.notifyAll(); + this.bytes = bytes; + bytesDelivered = true; + requestLock.notifyAll(); } } @@ -596,30 +600,30 @@ public class GtkSelection implements Transferable // try one more time through getBytes(). if (flavor.equals(DataFlavor.stringFlavor)) { - String text = getText(); - if (text != null) - return text; + String text = getText(); + if (text != null) + return text; } if (flavor.equals(DataFlavor.plainTextFlavor)) { - String text = getText(); - if (text != null) - return new StringBufferInputStream(text); + String text = getText(); + if (text != null) + return new StringBufferInputStream(text); } if (flavor.equals(DataFlavor.imageFlavor)) { - Image image = getImage(); - if (image != null) - return image; + Image image = getImage(); + if (image != null) + return image; } if (flavor.equals(DataFlavor.javaFileListFlavor)) { - List uris = getURIs(); - if (uris != null) - return uris; + List<File> uris = getURIs(); + if (uris != null) + return uris; } byte[] bytes = getBytes(flavor.getMimeType()); @@ -628,20 +632,20 @@ public class GtkSelection implements Transferable if (flavor.isMimeTypeSerializedObject()) { - try - { - ByteArrayInputStream bais = new ByteArrayInputStream(bytes); - ObjectInputStream ois = new ObjectInputStream(bais); - return ois.readObject(); - } - catch (IOException ioe) - { - ioe.printStackTrace(); - } - catch (ClassNotFoundException cnfe) - { - cnfe.printStackTrace(); - } + try + { + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + ObjectInputStream ois = new ObjectInputStream(bais); + return ois.readObject(); + } + catch (IOException ioe) + { + ioe.printStackTrace(); + } + catch (ClassNotFoundException cnfe) + { + cnfe.printStackTrace(); + } } if (flavor.isRepresentationClassInputStream()) diff --git a/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java b/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java index 5d9be1aec..0c7d3a860 100644 --- a/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java +++ b/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java @@ -100,8 +100,8 @@ public class GtkTextAreaPeer extends GtkComponentPeer // GtkComponent.create. if (f == null) { - f = new Font ("Dialog", Font.PLAIN, 12); - awtComponent.setFont (f); + f = new Font ("Dialog", Font.PLAIN, 12); + awtComponent.setFont (f); } FontMetrics fm = getFontMetrics (f); @@ -154,11 +154,11 @@ public class GtkTextAreaPeer extends GtkComponentPeer int width = 0; if (ta.getScrollbarVisibility () == TextArea.SCROLLBARS_BOTH - || ta.getScrollbarVisibility () == TextArea.SCROLLBARS_HORIZONTAL_ONLY) + || ta.getScrollbarVisibility () == TextArea.SCROLLBARS_HORIZONTAL_ONLY) height = getHScrollbarHeight (); if (ta.getScrollbarVisibility () == TextArea.SCROLLBARS_BOTH - || ta.getScrollbarVisibility () == TextArea.SCROLLBARS_VERTICAL_ONLY) + || ta.getScrollbarVisibility () == TextArea.SCROLLBARS_VERTICAL_ONLY) width = getVScrollbarWidth (); Font f = awtComponent.getFont (); @@ -183,11 +183,11 @@ public class GtkTextAreaPeer extends GtkComponentPeer int width = 0; if (ta.getScrollbarVisibility () == TextArea.SCROLLBARS_BOTH - || ta.getScrollbarVisibility () == TextArea.SCROLLBARS_HORIZONTAL_ONLY) + || ta.getScrollbarVisibility () == TextArea.SCROLLBARS_HORIZONTAL_ONLY) height = getHScrollbarHeight (); if (ta.getScrollbarVisibility () == TextArea.SCROLLBARS_BOTH - || ta.getScrollbarVisibility () == TextArea.SCROLLBARS_VERTICAL_ONLY) + || ta.getScrollbarVisibility () == TextArea.SCROLLBARS_VERTICAL_ONLY) width = getVScrollbarWidth (); Font f = awtComponent.getFont (); diff --git a/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java b/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java index 763304864..9e62c8e79 100644 --- a/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java +++ b/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java @@ -94,8 +94,8 @@ public class GtkTextFieldPeer extends GtkComponentPeer // GtkComponent.create. if (f == null) { - f = new Font ("Dialog", Font.PLAIN, 12); - awtComponent.setFont (f); + f = new Font ("Dialog", Font.PLAIN, 12); + awtComponent.setFont (f); } FontMetrics fm = getFontMetrics (f); diff --git a/gnu/java/awt/peer/gtk/GtkToolkit.java b/gnu/java/awt/peer/gtk/GtkToolkit.java index dc3e00ac0..d686336dc 100644 --- a/gnu/java/awt/peer/gtk/GtkToolkit.java +++ b/gnu/java/awt/peer/gtk/GtkToolkit.java @@ -85,9 +85,9 @@ import java.awt.dnd.DragGestureEvent; import java.awt.dnd.DragGestureListener; import java.awt.dnd.DragGestureRecognizer; import java.awt.dnd.DragSource; -import java.awt.event.KeyEvent; import java.awt.dnd.InvalidDnDOperationException; import java.awt.dnd.peer.DragSourceContextPeer; +import java.awt.font.TextAttribute; import java.awt.im.InputMethodHighlight; import java.awt.image.ColorModel; import java.awt.image.DirectColorModel; @@ -106,8 +106,8 @@ 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.MouseInfoPeer; import java.awt.peer.PanelPeer; import java.awt.peer.PopupMenuPeer; import java.awt.peer.RobotPeer; @@ -169,14 +169,14 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit private native void getScreenSizeDimensions(int[] xy); public int checkImage (Image image, int width, int height, - ImageObserver observer) + ImageObserver observer) { int status = ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT; if (image instanceof GtkImage) - return ((GtkImage) image).checkImage (observer); + return ((GtkImage) image).checkImage (observer); if (image instanceof AsyncImage) return ((AsyncImage) image).checkImage(observer); @@ -210,11 +210,11 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit Image image; try { - image = CairoSurface.getBufferedImage( new GtkImage( filename ) ); + image = CairoSurface.getBufferedImage( new GtkImage( filename ) ); } catch (IllegalArgumentException iae) { - image = null; + image = null; } return imageOrError(image); } @@ -232,11 +232,11 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit Image image; try { - image = CairoSurface.getBufferedImage( new GtkImage( producer ) ); + image = CairoSurface.getBufferedImage( new GtkImage( producer ) ); } catch (IllegalArgumentException iae) { - image = null; + image = null; } return imageOrError(image); } @@ -247,13 +247,13 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit Image image; try { - byte[] data = new byte[ imagelength ]; - System.arraycopy(imagedata, imageoffset, data, 0, imagelength); - image = CairoSurface.getBufferedImage( new GtkImage( data ) ); + byte[] data = new byte[ imagelength ]; + System.arraycopy(imagedata, imageoffset, data, 0, imagelength); + image = CairoSurface.getBufferedImage( new GtkImage( data ) ); } catch (IllegalArgumentException iae) { - image = null; + image = null; } return imageOrError(image); } @@ -277,22 +277,22 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit { /* Return the GDK-native ABGR format */ return new DirectColorModel(32, - 0x000000FF, - 0x0000FF00, - 0x00FF0000, - 0xFF000000); + 0x000000FF, + 0x0000FF00, + 0x00FF0000, + 0xFF000000); } public String[] getFontList () { return (new String[] { "Dialog", - "DialogInput", - "Monospaced", - "Serif", - "SansSerif" }); + "DialogInput", + "Monospaced", + "Serif", + "SansSerif" }); } - static class LRUCache extends LinkedHashMap + static class LRUCache<K,V> extends LinkedHashMap<K,V> { int max_entries; public LRUCache(int max) @@ -306,8 +306,9 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit } } - private LRUCache fontCache = new LRUCache(50); - private LRUCache imageCache = new LRUCache(50); + private LRUCache<Map,ClasspathFontPeer> fontCache = + new LRUCache<Map,ClasspathFontPeer>(50); + private LRUCache<Object,Image> imageCache = new LRUCache<Object,Image>(50); public FontMetrics getFontMetrics (Font font) { @@ -317,7 +318,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit public Image getImage (String filename) { if (imageCache.containsKey(filename)) - return (Image) imageCache.get(filename); + return imageCache.get(filename); else { Image im = createImage(filename); @@ -329,7 +330,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit public Image getImage (URL url) { if (imageCache.containsKey(url)) - return (Image) imageCache.get(url); + return imageCache.get(url); else { Image im = createImage(url); @@ -380,12 +381,12 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit * assumes the image is already prepared for rendering. */ public boolean prepareImage (Image image, int width, int height, - ImageObserver observer) + ImageObserver observer) { /* GtkImages are always prepared, as long as they're loaded. */ if (image instanceof GtkImage) - return ((((GtkImage)image).checkImage (observer) & - ImageObserver.ALLBITS) != 0); + return ((((GtkImage)image).checkImage (observer) + & ImageObserver.ALLBITS) != 0); if (image instanceof AsyncImage) { @@ -413,11 +414,11 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit /* Make the Peer reflect the state of the Component */ if (! (c instanceof Window)) { - cp.setCursor (c.getCursor ()); + cp.setCursor (c.getCursor ()); - Rectangle bounds = c.getBounds (); - cp.setBounds (bounds.x, bounds.y, bounds.width, bounds.height); - cp.setVisible (c.isVisible ()); + Rectangle bounds = c.getBounds (); + cp.setBounds (bounds.x, bounds.y, bounds.width, bounds.height); + cp.setVisible (c.isVisible ()); } } @@ -565,7 +566,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit */ private FontPeer getFontPeer (String name, int style, int size) { - Map attrs = new HashMap (); + Map<TextAttribute,Object> attrs = new HashMap<TextAttribute,Object>(); ClasspathFontPeer.copyStyleToAttrs (style, attrs); ClasspathFontPeer.copySizeToAttrs (size, attrs); return getClasspathFontPeer (name, attrs); @@ -577,16 +578,17 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit * model, hence "ClasspathFontPeer". */ - public ClasspathFontPeer getClasspathFontPeer (String name, Map attrs) + public ClasspathFontPeer getClasspathFontPeer (String name, + Map<?,?> attrs) { - Map keyMap = new HashMap (attrs); + Map<Object,Object> keyMap = new HashMap<Object,Object>(attrs); // We don't know what kind of "name" the user requested (logical, face, // family), and we don't actually *need* to know here. The worst case // involves failure to consolidate fonts with the same backend in our // cache. This is harmless. keyMap.put ("GtkToolkit.RequestedFontName", name); if (fontCache.containsKey (keyMap)) - return (ClasspathFontPeer) fontCache.get (keyMap); + return fontCache.get (keyMap); else { ClasspathFontPeer newPeer = new GdkFontPeer (name, attrs); @@ -621,11 +623,10 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit return new GtkDragSourceContextPeer(e); } - public DragGestureRecognizer createDragGestureRecognizer(Class recognizer, - DragSource ds, - Component comp, - int actions, - DragGestureListener l) + public <T extends DragGestureRecognizer> T + createDragGestureRecognizer(Class<T> recognizer, DragSource ds, + Component comp, int actions, + DragGestureListener l) { if (recognizer.getName().equals("java.awt.dnd.MouseDragGestureRecognizer") && ! GraphicsEnvironment.isHeadless()) @@ -633,7 +634,8 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit GtkMouseDragGestureRecognizer gestureRecognizer = new GtkMouseDragGestureRecognizer(ds, comp, actions, l); gestureRecognizer.registerListeners(); - return gestureRecognizer; + recognizer.asSubclass(gestureRecognizer.getClass()); + return recognizer.cast(gestureRecognizer); } else { @@ -641,7 +643,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit } } - public Map mapInputMethodHighlight(InputMethodHighlight highlight) + public Map<TextAttribute,?> mapInputMethodHighlight(InputMethodHighlight highlight) { throw new Error("not implemented"); } diff --git a/gnu/java/awt/peer/gtk/GtkWindowPeer.java b/gnu/java/awt/peer/gtk/GtkWindowPeer.java index 8d49719b1..1451dd933 100644 --- a/gnu/java/awt/peer/gtk/GtkWindowPeer.java +++ b/gnu/java/awt/peer/gtk/GtkWindowPeer.java @@ -172,19 +172,17 @@ public class GtkWindowPeer extends GtkContainerPeer public void setBounds (int x, int y, int width, int height) { - if (x != getX() - || y != getY() - || width != getWidth() - || height != getHeight()) + if (x != getX() || y != getY() || width != getWidth() + || height != getHeight()) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; + this.x = x; + this.y = y; + this.width = width; + this.height = height; - nativeSetBounds (x, y, - width - insets.left - insets.right, - height - insets.top - insets.bottom); + nativeSetBounds (x, y, + width - insets.left - insets.right, + height - insets.top - insets.bottom); } } @@ -211,7 +209,7 @@ public class GtkWindowPeer extends GtkContainerPeer width = awtComponent.getWidth(); height = awtComponent.getHeight(); setSize (width - insets.left - insets.right, - height - insets.top - insets.bottom); + height - insets.top - insets.bottom); gtkWindowSetResizable (resizable); } @@ -253,22 +251,20 @@ public class GtkWindowPeer extends GtkContainerPeer awtComponent.dispatchEvent(ev); } - if (frame_width != getWidth() - || frame_height != getHeight()) + if (frame_width != getWidth() || frame_height != getHeight()) { - this.width = frame_width; - this.height = frame_height; - q().postEvent(new ComponentEvent(awtComponent, - ComponentEvent.COMPONENT_RESIZED)); + this.width = frame_width; + this.height = frame_height; + q().postEvent(new ComponentEvent(awtComponent, + ComponentEvent.COMPONENT_RESIZED)); } - if (frame_x != getX() - || frame_y != getY()) + if (frame_x != getX() || frame_y != getY()) { - this.x = frame_x; - this.y = frame_y; - q().postEvent(new ComponentEvent(awtComponent, - ComponentEvent.COMPONENT_MOVED)); + this.x = frame_x; + this.y = frame_y; + q().postEvent(new ComponentEvent(awtComponent, + ComponentEvent.COMPONENT_MOVED)); } } @@ -287,8 +283,8 @@ public class GtkWindowPeer extends GtkContainerPeer { if (id == WindowEvent.WINDOW_STATE_CHANGED) { - if (windowState != newState) - { + if (windowState != newState) + { // Post old styleWindowEvent with WINDOW_ICONIFIED or // WINDOW_DEICONIFIED if appropriate. if ((windowState & Frame.ICONIFIED) != 0 @@ -302,10 +298,10 @@ public class GtkWindowPeer extends GtkContainerPeer WindowEvent.WINDOW_ICONIFIED, opposite, 0, 0)); // Post new-style WindowStateEvent. - q().postEvent (new WindowEvent ((Window) awtComponent, id, + q().postEvent (new WindowEvent ((Window) awtComponent, id, opposite, windowState, newState)); - windowState = newState; - } + windowState = newState; + } } else q().postEvent (new WindowEvent ((Window) awtComponent, id, opposite)); @@ -384,7 +380,7 @@ public class GtkWindowPeer extends GtkContainerPeer } protected void postMouseEvent(int id, long when, int mods, int x, int y, - int clickCount, boolean popupTrigger) + int clickCount, boolean popupTrigger) { // Translate AWT co-ordinates, which include a window frame's // insets, to GTK co-ordinates, which do not include a window @@ -392,8 +388,8 @@ public class GtkWindowPeer extends GtkContainerPeer // insets but GtkFramePeer and GtkDialogPeer insets will be // non-zero. super.postMouseEvent (id, when, mods, - x + insets.left, y + insets.top, - clickCount, popupTrigger); + x + insets.left, y + insets.top, + clickCount, popupTrigger); } // We override this to keep it in sync with our internal diff --git a/gnu/java/awt/peer/gtk/VolatileImageGraphics.java b/gnu/java/awt/peer/gtk/VolatileImageGraphics.java index 62dbb45d8..88438862b 100644 --- a/gnu/java/awt/peer/gtk/VolatileImageGraphics.java +++ b/gnu/java/awt/peer/gtk/VolatileImageGraphics.java @@ -207,11 +207,11 @@ public class VolatileImageGraphics extends ComponentGraphics if (img instanceof GtkVolatileImage && (comp == null || comp instanceof AlphaComposite)) { - owner.drawVolatile( ((GtkVolatileImage)img).nativePointer, - x, y, - ((GtkVolatileImage)img).width, - ((GtkVolatileImage)img).height ); - return true; + owner.drawVolatile( ((GtkVolatileImage)img).nativePointer, + x, y, + ((GtkVolatileImage)img).width, + ((GtkVolatileImage)img).height ); + return true; } return super.drawImage( img, x, y, observer ); } @@ -222,9 +222,9 @@ public class VolatileImageGraphics extends ComponentGraphics if ((img instanceof GtkVolatileImage) && (comp == null || comp instanceof AlphaComposite)) { - owner.drawVolatile( ((GtkVolatileImage)img).nativePointer, - x, y, width, height ); - return true; + owner.drawVolatile( ((GtkVolatileImage)img).nativePointer, + x, y, width, height ); + return true; } return super.drawImage( img, x, y, width, height, observer ); } @@ -254,8 +254,8 @@ public class VolatileImageGraphics extends ComponentGraphics transform.transform(points, 0, points, 0, 2); Rectangle2D deviceBounds = new Rectangle2D.Double(points[0], points[1], - points[2] - points[0], - points[3] - points[1]); + points[2] - points[0], + points[3] - points[1]); Rectangle2D.intersect(deviceBounds, this.getClipInDevSpace(), deviceBounds); current = current.getSubimage((int)deviceBounds.getX(), diff --git a/java/awt/RenderingHints.java b/java/awt/RenderingHints.java index ce327e369..e98a00c5b 100644 --- a/java/awt/RenderingHints.java +++ b/java/awt/RenderingHints.java @@ -158,7 +158,7 @@ public class RenderingHints } } // class KeyImpl - private HashMap hintMap = new HashMap(); + private HashMap<Object,Object> hintMap = new HashMap<Object,Object>(); /** * A key for the 'antialiasing' hint. Permitted values are: @@ -711,9 +711,9 @@ public class RenderingHints Iterator iterator = m.keySet().iterator(); while (iterator.hasNext()) { - Key key = (Key) iterator.next(); - if (!key.isCompatibleValue(m.get(key))) - throw new IllegalArgumentException(); + Key key = (Key) iterator.next(); + if (!key.isCompatibleValue(m.get(key))) + throw new IllegalArgumentException(); } // map is OK, update hintMap.putAll(m); @@ -783,7 +783,7 @@ public class RenderingHints try { RenderingHints copy = (RenderingHints) super.clone(); - copy.hintMap = (HashMap) hintMap.clone(); + copy.hintMap = new HashMap<Object,Object>(hintMap); return copy; } catch (CloneNotSupportedException e) diff --git a/java/awt/image/BufferedImage.java b/java/awt/image/BufferedImage.java index 526f12c99..98e1b4ad6 100644 --- a/java/awt/image/BufferedImage.java +++ b/java/awt/image/BufferedImage.java @@ -83,7 +83,7 @@ public class BufferedImage extends Image /** * Vector of TileObservers (or null) */ - Vector tileObservers; + Vector<TileObserver> tileObservers; /** * The image's WritableRaster @@ -572,7 +572,7 @@ public class BufferedImage extends Image { return new ImageProducer() { - Vector consumers = new Vector(); + Vector<ImageConsumer> consumers = new Vector<ImageConsumer>(); public void addConsumer(ImageConsumer ic) { @@ -608,9 +608,9 @@ public class BufferedImage extends Image consumers.add(ic); - for(int i=0;i<consumers.size();i++) + for(int i = 0; i < consumers.size(); i++) { - ImageConsumer c = (ImageConsumer) consumers.elementAt(i); + ImageConsumer c = consumers.elementAt(i); c.setHints(ImageConsumer.SINGLEPASS); c.setDimensions(getWidth(), getHeight()); c.setPixels(x, y, width, height, model, pixels, offset, stride); @@ -794,7 +794,7 @@ public class BufferedImage extends Image public void addTileObserver (TileObserver to) { if (tileObservers == null) - tileObservers = new Vector (); + tileObservers = new Vector<TileObserver>(); tileObservers.add (to); } |