This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi,
Craig Black implemented fill/drawRoundRect for GNU Classpath:
2004-07-30 Craig Black <craig.black@aonix.com>
* gnu/java/awt/peer/gtk/GdkGraphics.java
(drawRoundRect): Implemented.
(fillRoundRect): Implemented.
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(drawRoundRect): Reimplemented to match GdkGraphics.
(fillRoundRect): Reimplemented to match GdkGraphics.
I have committed it to the gui branch.
Cheers,
Mark
Index: gnu/java/awt/peer/gtk/GdkGraphics.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java,v
retrieving revision 1.4.16.4
diff -u -r1.4.16.4 GdkGraphics.java
--- gnu/java/awt/peer/gtk/GdkGraphics.java 24 Jul 2004 04:27:01 -0000 1.4.16.4
+++ gnu/java/awt/peer/gtk/GdkGraphics.java 30 Jul 2004 19:29:11 -0000
@@ -238,13 +238,48 @@
public void drawRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
- // System.out.println ("drawRoundRect called [UNIMPLEMENTED]");
+ if (arcWidth > width)
+ arcWidth = width;
+ if (arcHeight > height)
+ arcHeight = height;
+
+ int xx = x + width - arcWidth;
+ int yy = y + height - arcHeight;
+
+ drawArc (x, y, arcWidth, arcHeight, 90, 90);
+ drawArc (xx, y, arcWidth, arcHeight, 0, 90);
+ drawArc (xx, yy, arcWidth, arcHeight, 270, 90);
+ drawArc (x, yy, arcWidth, arcHeight, 180, 90);
+
+ int y1 = y + arcHeight / 2;
+ int y2 = y + height - arcHeight / 2;
+ drawLine (x, y1, x, y2);
+ drawLine (x + width, y1, x + width, y2);
+
+ int x1 = x + arcWidth / 2;
+ int x2 = x + width - arcWidth / 2;
+ drawLine (x1, y, x2, y);
+ drawLine (x1, y + height, x2, y + height);
}
public void fillRoundRect (int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
- // System.out.println ("fillRoundRect called [UNIMPLEMENTED]");
+ if (arcWidth > width)
+ arcWidth = width;
+ if (arcHeight > height)
+ arcHeight = height;
+
+ int xx = x + width - arcWidth;
+ int yy = y + height - arcHeight;
+
+ fillArc (x, y, arcWidth, arcHeight, 90, 90);
+ fillArc (xx, y, arcWidth, arcHeight, 0, 90);
+ fillArc (xx, yy, arcWidth, arcHeight, 270, 90);
+ fillArc (x, yy, arcWidth, arcHeight, 180, 90);
+
+ fillRect (x, y + arcHeight / 2, width, height - arcHeight + 1);
+ fillRect (x + arcWidth / 2, y, width - arcWidth + 1, height);
}
public Shape getClip ()
Index: gnu/java/awt/peer/gtk/GdkGraphics2D.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/GdkGraphics2D.java,v
retrieving revision 1.7.2.14
diff -u -r1.7.2.14 GdkGraphics2D.java
--- gnu/java/awt/peer/gtk/GdkGraphics2D.java 30 Jul 2004 14:04:40 -0000 1.7.2.14
+++ gnu/java/awt/peer/gtk/GdkGraphics2D.java 30 Jul 2004 19:29:11 -0000
@@ -1477,14 +1477,28 @@
public void drawRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
- int x1 = x + arcWidth, x2 = x + width - arcWidth;
- int y1 = y + arcHeight, y2 = y + height - arcHeight;
- fillRect (x1, y, x2 - x1, height);
- fillRect (x, y1, width, y2 - y1);
- fillArc (x, y, arcWidth, arcHeight, 90, 90);
- fillArc (x1, y, arcWidth, arcHeight, 0, 90);
- fillArc (x2, y2, arcWidth, arcHeight, 270, 90);
- fillArc (x, y2, arcWidth, arcHeight, 180, 90);
+ if (arcWidth > width)
+ arcWidth = width;
+ if (arcHeight > height)
+ arcHeight = height;
+
+ int xx = x + width - arcWidth;
+ int yy = y + height - arcHeight;
+
+ drawArc (x, y, arcWidth, arcHeight, 90, 90);
+ drawArc (xx, y, arcWidth, arcHeight, 0, 90);
+ drawArc (xx, yy, arcWidth, arcHeight, 270, 90);
+ drawArc (x, yy, arcWidth, arcHeight, 180, 90);
+
+ int y1 = y + arcHeight / 2;
+ int y2 = y + height - arcHeight / 2;
+ drawLine (x, y1, x, y2);
+ drawLine (x + width, y1, x + width, y2);
+
+ int x1 = x + arcWidth / 2;
+ int x2 = x + width - arcWidth / 2;
+ drawLine (x1, y, x2, y);
+ drawLine (x1, y + height, x2, y + height);
}
public void drawString (String str, int x, int y)
@@ -1526,14 +1540,21 @@
public void fillRoundRect (int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
- int x1 = x + arcWidth, x2 = x + width - arcWidth;
- int y1 = y + arcHeight, y2 = y + height - arcHeight;
- fillRect (x1, y, x2 - x1, height);
- fillRect (x, y1, width, y2 - y1);
+ if (arcWidth > width)
+ arcWidth = width;
+ if (arcHeight > height)
+ arcHeight = height;
+
+ int xx = x + width - arcWidth;
+ int yy = y + height - arcHeight;
+
fillArc (x, y, arcWidth, arcHeight, 90, 90);
- fillArc (x1, y, arcWidth, arcHeight, 0, 90);
- fillArc (x2, y2, arcWidth, arcHeight, 270, 90);
- fillArc (x, y2, arcWidth, arcHeight, 180, 90);
+ fillArc (xx, y, arcWidth, arcHeight, 0, 90);
+ fillArc (xx, yy, arcWidth, arcHeight, 270, 90);
+ fillArc (x, yy, arcWidth, arcHeight, 180, 90);
+
+ fillRect (x, y + arcHeight / 2, width, height - arcHeight + 1);
+ fillRect (x + arcWidth / 2, y, width - arcWidth + 1, height);
}
public Font getFont ()
Attachment:
signature.asc
Description: This is a digitally signed message part
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |