natGC.cc (fillPolygon): New method.
authorScott Gilbertson <scottg@mantatest.com>
Wed, 15 Jan 2003 23:53:49 +0000 (23:53 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Wed, 15 Jan 2003 23:53:49 +0000 (23:53 +0000)
2003-01-15  Scott Gilbertson  <scottg@mantatest.com>

* gnu/gcj/xlib/natGC.cc (fillPolygon): New method.
* gnu/gcj/xlib/GC.java (fillPolygon): Declare.
* gnu/awt/xlib/XGraphics.java (fillPolygon): Added translateX and
translateY arguments.  Implement.
* gnu/awt/j2d/IntegerGraphicsState.java (fillPolygon): Pass
down translation arguments.
(drawPolyline, drawPolygon): Fix incorrect tests.
* gnu/awt/j2d/DirectRasterGraphics.java (fillPolygon): Added
translateX and translateY arguments.

From-SVN: r61369

libjava/ChangeLog
libjava/gnu/awt/j2d/DirectRasterGraphics.java
libjava/gnu/awt/j2d/IntegerGraphicsState.java
libjava/gnu/awt/xlib/XGraphics.java
libjava/gnu/gcj/xlib/GC.java
libjava/gnu/gcj/xlib/natGC.cc

index 081ce99c6b7f747ef9dedf09e1aa1116f64649e9..62f54b556f968475c37e66d5dfa87491d536dc8c 100644 (file)
@@ -1,3 +1,15 @@
+2003-01-15  Scott Gilbertson  <scottg@mantatest.com>
+
+       * gnu/gcj/xlib/natGC.cc (fillPolygon): New method.
+       * gnu/gcj/xlib/GC.java (fillPolygon): Declare.
+       * gnu/awt/xlib/XGraphics.java (fillPolygon): Added translateX and
+       translateY arguments.  Implement.
+       * gnu/awt/j2d/IntegerGraphicsState.java (fillPolygon): Pass
+       down translation arguments.
+       (drawPolyline, drawPolygon): Fix incorrect tests.
+       * gnu/awt/j2d/DirectRasterGraphics.java (fillPolygon): Added
+       translateX and translateY arguments.
+
 2003-01-15  Scott Gilbertson  <scottg@mantatest.com>
 
        * Makefile.in: Rebuilt.
index 8d25b88d0186f49d93c7b88ea4c77558f50b13fa..28aad9b040442f8afca6a48e5236f160a04a47f7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000  Free Software Foundation
+/* Copyright (C) 2000, 2003  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -61,7 +61,8 @@ public interface DirectRasterGraphics extends Cloneable
   
   public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints);
   
-  public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
+  public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints,
+                         int translateX, int translateY);
   
   public void drawString(String str, int x, int y);
   
index 90a1a4d2ab59e18e1769f71ce3170d12256d9fc0..bfea6611ca56efccac03b1bd28755036d3996563 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000  Free Software Foundation
+/* Copyright (C) 2000, 2003  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -212,7 +212,7 @@ public class IntegerGraphicsState extends AbstractGraphicsState
   
   public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
   {
-    if ((tx == 0) || (ty == 0))
+    if ((tx == 0) && (ty == 0))
       {
        directGfx.drawPolyline(xPoints, yPoints, nPoints);
        return;
@@ -223,7 +223,7 @@ public class IntegerGraphicsState extends AbstractGraphicsState
 
   public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
   {
-    if ((tx == 0) || (ty == 0))
+    if ((tx == 0) && (ty == 0))
       {
        directGfx.drawPolygon(xPoints, yPoints, nPoints);
        return;
@@ -232,15 +232,11 @@ public class IntegerGraphicsState extends AbstractGraphicsState
     throw new UnsupportedOperationException("translate not implemented");
   }
   
-  public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
+  public void fillPolygon (int[] xPoints, int[] yPoints, int nPoints)
   {
-    if ((tx == 0) || (ty == 0))
-      {
-       directGfx.fillPolygon(xPoints, yPoints, nPoints);
-       return;
-      }
-    
-    throw new UnsupportedOperationException("translate not implemented");
+    // FIXME: remove tx & ty args once translation via AffineTransform
+    // is implemented.
+    directGfx.fillPolygon (xPoints, yPoints, nPoints, tx, ty);
   }
 
   public boolean drawImage(Image image, int x, int y,
index 27b07a2369a631481171cf88ef8d7292c2078b92..90f53880e85fcf0fdf63641aff1a919bf79e2118 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000  Free Software Foundation
+/* Copyright (C) 2000, 2003  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -176,10 +176,10 @@ public class XGraphics implements Cloneable, DirectRasterGraphics
     throw new UnsupportedOperationException("not implemented");
   }
     
-  public void fillPolygon(int[] xPoints, int[] yPoints, int
-                         nPoints)
+  public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints,
+                         int translateX, int translateY)
   {
-    throw new UnsupportedOperationException("not implemented");
+    context.fillPolygon(xPoints, yPoints, nPoints, translateX, translateY);
   }
 
   public void drawString(String str, int x, int y)
index 6b33715cf6cd7e2d718fca6071f5226f01953c67..1806c2ae5694834443282d6067a7f8b2a59dfb82 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000  Free Software Foundation
+/* Copyright (C) 2000, 2003  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -84,6 +84,8 @@ public class GC implements Cloneable
   public native void drawRectangle(int x, int y, int w, int h);
 
   public native void fillRectangle(int x, int y, int w, int h);
+  public native void fillPolygon(int[] xPoints, int[] yPoints, int nPoints,
+                                int translateX, int translateY);
 
   /** 
    * 
index 66de35f868b22245106a1bdc4cc5d22e1d47b159..1a1bd586d8ed8408416573e205e9f29cddeee4ef 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000  Free Software Foundation
+/* Copyright (C) 2000, 2003  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -11,6 +11,7 @@ details.  */
 #include <X11/Xlib.h>
 
 #include <gcj/cni.h>
+#include <gcj/array.h>
 #include <gnu/gcj/RawData.h>
 #include <java/lang/String.h>
 #include <java/awt/Rectangle.h>
@@ -154,6 +155,27 @@ void gnu::gcj::xlib::GC::fillRectangle(jint x, jint y, jint w, jint h)
   // no fast fail
 }
 
+void gnu::gcj::xlib::GC::fillPolygon(jintArray xPoints, jintArray yPoints,
+                                    jint nPoints,
+                                    jint translateX, jint translateY)
+{
+  Display* display = target->getDisplay();
+  ::Display* dpy = (::Display*) (display->display);
+  ::Drawable drawableXID = target->getXID();
+  ::GC gc = (::GC) structure;
+  typedef ::XPoint xpoint;
+  std::vector<xpoint> points(nPoints+1);
+  for (int i=0; i<nPoints; i++)
+    {
+      points[i].x = elements(xPoints)[i] + translateX;
+      points[i].y = elements(yPoints)[i] + translateY;
+    }
+  points[nPoints] = points[0];
+  XFillPolygon(dpy, drawableXID, gc, &(points.front()), nPoints,
+              Complex, CoordModeOrigin);
+  // no fast fail
+}
+
 void gnu::gcj::xlib::GC::clearArea(jint x, jint y, jint w, jint h,
                                   jboolean exposures)
 {