classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] RFC: Naive GdkGraphics2D.copyArea() implementation


From: Mark Wielaard
Subject: [cp-patches] RFC: Naive GdkGraphics2D.copyArea() implementation
Date: Sat, 01 Oct 2005 23:40:29 +0200

Hi,

Here is a somewhat naive implementation of GdkGraphics2D.copyArea() that
Wolfgang and I made up during DevJam to get Jump started.

2005-10-01  Mark Wielaard  <address@hidden>

    * gnu/java/awt/peer/gtk/GdkGraphics2D.java
    (GdkGraphics2D(GdkGraphics2D,int, int, int,int)): New constructor.
    (create(int,int,int,int)): Use new constructor.
    (copyArea): Implement through create() and gdkDrawDrawable().

It doesn't really work correctly in all cases since gdkDrawDrawable()
really wants to have a GdkGraphics2D with a backing store. But at least
it makes some things work better (although sometimes things look garbled
when gdDrawDrawable copies garbage from a GdGraphics without backing
store).

Comments?

Cheers,

Mar
Index: gnu/java/awt/peer/gtk/GdkGraphics2D.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java,v
retrieving revision 1.50
diff -u -r1.50 GdkGraphics2D.java
--- gnu/java/awt/peer/gtk/GdkGraphics2D.java    24 Sep 2005 22:01:11 -0000      
1.50
+++ gnu/java/awt/peer/gtk/GdkGraphics2D.java    1 Oct 2005 21:38:32 -0000
@@ -154,7 +154,7 @@
 
   public Graphics create(int x, int y, int width, int height)
   {
-    return new GdkGraphics2D(width, height);
+    return new GdkGraphics2D(this, x, y, width, height);
   }
 
   private void fail_g2d ()
@@ -209,6 +209,13 @@
     stateStack = new Stack();
   }
 
+  GdkGraphics2D(GdkGraphics2D g, int x, int y, int widht, int height)
+  {
+    this(g);
+    translate(x, y);
+    clipRect(0, 0, widht, height);
+  }
+
   GdkGraphics2D(int width, int height)
   {
     if (!GtkToolkit.useGraphics2D ())
@@ -1394,7 +1401,8 @@
 
   public void copyArea(int x, int y, int width, int height, int dx, int dy)
   {
-    throw new java.lang.UnsupportedOperationException();
+    GdkGraphics2D g = (GdkGraphics2D) create(x, y, width, height);
+    gdkDrawDrawable(g, x + dx, y + dy);
   }
 
   public void drawArc(int x, int y, int width, int height, int startAngle,

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]