diff --git a/core/src/main/java/edu/umd/cs/piccolo/util/PDebug.java b/core/src/main/java/edu/umd/cs/piccolo/util/PDebug.java
index 20725c9..b86af98 100644
--- a/core/src/main/java/edu/umd/cs/piccolo/util/PDebug.java
+++ b/core/src/main/java/edu/umd/cs/piccolo/util/PDebug.java
@@ -157,7 +157,7 @@
if (PDebug.debugRegionManagement) {
final Graphics2D g2 = (Graphics2D) g;
- g.setColor(PDebug.getDebugPaintColor());
+ g2.setColor(PDebug.getDebugPaintColor());
g2.fill(g.getClipBounds().getBounds2D());
}
diff --git a/core/src/main/java/edu/umd/cs/piccolo/util/PPaintContext.java b/core/src/main/java/edu/umd/cs/piccolo/util/PPaintContext.java
index 8a14e79..6c14804 100644
--- a/core/src/main/java/edu/umd/cs/piccolo/util/PPaintContext.java
+++ b/core/src/main/java/edu/umd/cs/piccolo/util/PPaintContext.java
@@ -242,7 +242,8 @@
}
/**
- * Removes the topmost transparency if the given transparency is not opaque (1f).
+ * Removes the topmost transparency if the given transparency is not opaque
+ * (1f).
*
* @param transparency transparency to be popped
*/
@@ -263,12 +264,12 @@
if (transform == null) {
return;
}
-
+
final Rectangle2D newLocalClip = (Rectangle2D) getLocalClip().clone();
transform.inverseTransform(newLocalClip, newLocalClip);
transformStack.push(graphics.getTransform());
localClipStack.push(newLocalClip);
- graphics.transform(transform);
+ graphics.transform(transform);
}
/**
@@ -321,6 +322,9 @@
graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
break;
+ default:
+ throw new RuntimeException(
+ "Render Quality must be either PPaintContext.HIGH_QUALITY_RENDERING or PPaintContext.LOW_QUALITY_RENDERING");
}
}
}
diff --git a/examples/src/main/java/edu/umd/cs/piccolo/examples/ShadowExample.java b/examples/src/main/java/edu/umd/cs/piccolo/examples/ShadowExample.java
index 6793ccd..ea8c59b 100755
--- a/examples/src/main/java/edu/umd/cs/piccolo/examples/ShadowExample.java
+++ b/examples/src/main/java/edu/umd/cs/piccolo/examples/ShadowExample.java
@@ -49,6 +49,7 @@
*/
public final class ShadowExample extends PFrame {
+ private static final Color SHADOW_PAINT = new Color(20, 20, 20, 200);
/** Default serial version UID. */
private static final long serialVersionUID = 1L;
@@ -72,22 +73,16 @@
/** {@inheritDoc} */
public void initialize() {
- BufferedImage src = new BufferedImage(75, 75, BufferedImage.TYPE_INT_ARGB);
- Paint shadowPaint = new Color(20, 20, 20, 200);
- Graphics2D g = src.createGraphics();
- g.setPaint(Color.RED);
- g.fillRect(0, 0, 75, 75);
- g.dispose();
-
- PText header1 = new PText("Shadow nodes drawn from an image, with increasing blur radius:");
- getCanvas().getLayer().addChild(header1);
+ BufferedImage src = buildRedRectangleImage();
+
+ addHeaderAt("Shadow nodes drawn from an image, with increasing blur radius:", 0, 0);
double x = 25.0d;
double y = 25.0d;
for (int blurRadius = 4; blurRadius < 28; blurRadius += 4) {
PImage node = new PImage(src);
- PShadow shadowNode = new PShadow(src, shadowPaint, blurRadius);
+ PShadow shadowNode = new PShadow(src, SHADOW_PAINT, blurRadius);
node.setOffset(x, y);
// offset the shadow to account for blur radius offset and light direction
@@ -104,16 +99,11 @@
}
}
- PText header2 = new PText("Shadow nodes drawn from node.toImage():");
- header2.setOffset(0.0d, 300.0d);
- getCanvas().getLayer().addChild(header2);
+ addHeaderAt("Shadow nodes drawn from node.toImage():", 0, 300);
- PPath rectNode = PPath.createRectangle(0.0f, 0.0f, 75.0f, 75.0f);
- rectNode.setPaint(Color.RED);
- rectNode.setStroke(null);
- rectNode.setOffset(25.0d, 325.0d);
+ PPath rectNode = buildRedRectangleNode();
- PShadow rectShadow = new PShadow(rectNode.toImage(), shadowPaint, 8);
+ PShadow rectShadow = new PShadow(rectNode.toImage(), SHADOW_PAINT, 8);
rectShadow.setOffset(25.0d - (2 * 8) + 5.0d, 325.0d - (2 * 8) + 5.0d);
getCanvas().getLayer().addChild(rectShadow);
@@ -124,13 +114,39 @@
textNode.setFont(textNode.getFont().deriveFont(36.0f));
textNode.setOffset(125.0d, 325.0d);
- PShadow textShadow = new PShadow(textNode.toImage(), shadowPaint, 8);
+ PShadow textShadow = new PShadow(textNode.toImage(), SHADOW_PAINT, 8);
textShadow.setOffset(125.0d - (2 * 8) + 2.5d, 325.0d - (2 * 8) + 2.5d);
getCanvas().getLayer().addChild(textShadow);
getCanvas().getLayer().addChild(textNode);
}
+ private PText addHeaderAt(String labelText, double x, double y) {
+ PText labelNode = new PText(labelText);
+ labelNode.setOffset(x, y);
+ getCanvas().getLayer().addChild(labelNode);
+ return labelNode;
+ }
+
+
+
+ private BufferedImage buildRedRectangleImage() {
+ BufferedImage src = new BufferedImage(75, 75, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g = src.createGraphics();
+ g.setPaint(Color.RED);
+ g.fillRect(0, 0, 75, 75);
+ g.dispose();
+ return src;
+ }
+
+ private PPath buildRedRectangleNode() {
+ PPath rectNode = PPath.createRectangle(0.0f, 0.0f, 75.0f, 75.0f);
+ rectNode.setPaint(Color.RED);
+ rectNode.setStroke(null);
+ rectNode.setOffset(25.0d, 325.0d);
+ return rectNode;
+ }
+
/**
* Main.
*
diff --git a/extras/src/build/conf/checkstyle.xml b/extras/src/build/conf/checkstyle.xml
index c04e096..2a6f0a5 100644
--- a/extras/src/build/conf/checkstyle.xml
+++ b/extras/src/build/conf/checkstyle.xml
@@ -137,7 +137,10 @@
-
+
+
+
+
diff --git a/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java b/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java
index 690572d..b344631 100644
--- a/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java
+++ b/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java
@@ -83,8 +83,8 @@
* @param fullScreenMode whether to display a full screen frame or not
* @param canvas to embed in the frame
*/
- public PFrame(final String title, final boolean fullScreenMode, final PCanvas aCanvas) {
- this(title, GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(), fullScreenMode, aCanvas);
+ public PFrame(final String title, final boolean fullScreenMode, final PCanvas canvas) {
+ this(title, GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(), fullScreenMode, canvas);
}
/**
@@ -97,7 +97,7 @@
* @param canvas to embed in the frame, may be null. If so, it'll create a
* default PCanvas
*/
- public PFrame(final String title, final GraphicsDevice aDevice, final boolean fullScreenMode, final PCanvas aCanvas) {
+ public PFrame(final String title, final GraphicsDevice aDevice, final boolean fullScreenMode, final PCanvas canvas) {
super(title, aDevice.getDefaultConfiguration());
graphicsDevice = aDevice;
@@ -113,11 +113,11 @@
System.out.println("Ignoring security exception. Assuming Applet Context.");
}
- if (aCanvas == null) {
- canvas = new PCanvas();
+ if (canvas == null) {
+ this.canvas = new PCanvas();
}
else {
- canvas = aCanvas;
+ this.canvas = canvas;
}
setContentPane(canvas);
@@ -214,6 +214,13 @@
setVisible(true);
}
+ /**
+ * Sets the display mode to the best device mode that can be determined.
+ *
+ * Used in full screen mode.
+ *
+ * @param device The graphics device being controlled.
+ */
protected void chooseBestDisplayMode(final GraphicsDevice device) {
final DisplayMode best = getBestDisplayMode(device);
if (best != null) {
@@ -221,6 +228,14 @@
}
}
+ /**
+ * Finds the best display mode the graphics device supports. Based on the
+ * preferred modes.
+ *
+ * @param device the device being inspected
+ *
+ * @return best display mode the given device supports
+ */
protected DisplayMode getBestDisplayMode(final GraphicsDevice device) {
final Iterator itr = getPreferredDisplayModes(device).iterator();
while (itr.hasNext()) {
@@ -240,6 +255,9 @@
/**
* By default return the current display mode. Subclasses may override this
* method to return other modes in the collection.
+ *
+ * @param device the device being inspected
+ * @return preferred display mode
*/
protected Collection getPreferredDisplayModes(final GraphicsDevice device) {
final ArrayList result = new ArrayList();
diff --git a/swt/src/build/conf/checkstyle.xml b/swt/src/build/conf/checkstyle.xml
index 4851327..6d38113 100644
--- a/swt/src/build/conf/checkstyle.xml
+++ b/swt/src/build/conf/checkstyle.xml
@@ -137,7 +137,10 @@
-
+
+
+
+