File: add_roundrectangle

package info (click to toggle)
piccolo 1.2-1.1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 1,668 kB
  • sloc: java: 16,496; xml: 259; sh: 18; makefile: 13
file content (53 lines) | stat: -rw-r--r-- 2,577 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Description: Add RoundRectangle to Ppath
 Add the RoundRectangle function as defined in later versions of Piccolo.
 This is a requirement for Storymaps, which uses this function.
Origin: upstream
Last-Update: <2012-05-12>

--- piccolo-1.2.orig/src/edu/umd/cs/piccolo/nodes/PPath.java
+++ piccolo-1.2/src/edu/umd/cs/piccolo/nodes/PPath.java
@@ -39,6 +39,7 @@ import java.awt.geom.Ellipse2D;
 import java.awt.geom.GeneralPath;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
@@ -96,6 +97,7 @@ public class PPath extends PNode {
     public static final int PROPERTY_CODE_PATH = 1 << 18;
 	
 	private static final Rectangle2D.Float TEMP_RECTANGLE = new Rectangle2D.Float();
+        private static final RoundRectangle2D.Float TEMP_ROUNDRECTANGLE = new RoundRectangle2D.Float();
 	private static final Ellipse2D.Float TEMP_ELLIPSE = new Ellipse2D.Float();
 	private static final PAffineTransform TEMP_TRANSFORM = new PAffineTransform();
 	private static final BasicStroke DEFAULT_STROKE = new BasicStroke(1.0f);
@@ -107,7 +109,27 @@ public class PPath extends PNode {
 	private transient boolean updatingBoundsFromPath;
 	private Paint strokePaint;
 
-	public static PPath createRectangle(float x, float y, float width, float height) {
+        /**
+         * Creates a PPath object in the shape of a rounded rectangle.
+         * 
+         * @param x left of the rectangle
+         * @param y top of the rectangle
+         * @param width width of the rectangle
+         * @param height height of the rectangle
+         * @param arcWidth the arc width at the corners of the rectangle
+         * @param arcHeight the arc height at the corners of the rectangle
+         * 
+         * @return created rounded rectangle
+         */
+        public static PPath createRoundRectangle(final float x, final float y, final float width, final float height,
+                final float arcWidth, final float arcHeight) {
+            TEMP_ROUNDRECTANGLE.setRoundRect(x, y, width, height, arcWidth, arcHeight);
+            final PPath result = new PPath(TEMP_ROUNDRECTANGLE);
+            result.setPaint(Color.white);
+            return result;
+        }
+
+        public static PPath createRectangle(float x, float y, float width, float height) {
 		TEMP_RECTANGLE.setFrame(x, y, width, height);
 		PPath result = new PPath(TEMP_RECTANGLE);
 		result.setPaint(Color.white);