Revision: 698
Author: allain.lalonde
Date: Fri Oct 9 10:12:23 2009
Log: More CheckStyle Stuff
http://code.google.com/p/piccolo2d/source/detail?r=698
Modified:
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/util/PDebug.java
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/util/PPaintContext.java
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/ShadowExample.java
/piccolo2d.java/trunk/extras/src/build/conf/checkstyle.xml
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java
/piccolo2d.java/trunk/swt/src/build/conf/checkstyle.xml
=======================================
---
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/util/PDebug.java
Tue Aug 4 09:04:02 2009
+++
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/util/PDebug.java
Fri Oct 9 10:12:23 2009
@@ -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());
}
=======================================
---
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/util/PPaintContext.java
Thu Oct 8 21:24:11 2009
+++
/piccolo2d.java/trunk/core/src/main/java/edu/umd/cs/piccolo/util/PPaintContext.java
Fri Oct 9 10:12:23 2009
@@ -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");
}
}
}
=======================================
---
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/ShadowExample.java
Thu Aug 20 14:06:00 2009
+++
/piccolo2d.java/trunk/examples/src/main/java/edu/umd/cs/piccolo/examples/ShadowExample.java
Fri Oct 9 10:12:23 2009
@@ -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);
-
- 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);
-
- PShadow rectShadow = new PShadow(rectNode.toImage(), shadowPaint,
8);
+ addHeaderAt("Shadow nodes drawn from node.toImage():", 0, 300);
+
+ PPath rectNode = buildRedRectangleNode();
+
+ 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,12 +114,38 @@
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.
=======================================
--- /piccolo2d.java/trunk/extras/src/build/conf/checkstyle.xml Thu Oct 8
11:29:42 2009
+++ /piccolo2d.java/trunk/extras/src/build/conf/checkstyle.xml Fri Oct 9
10:12:23 2009
@@ -137,7 +137,10 @@
<module name="DoubleCheckedLocking"/> <!-- MY FAVOURITE -->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
- <module name="HiddenField"/>
+ <module name="HiddenField">
+ <property name="ignoreConstructorParameter" value="true"/>
+ <property name="ignoreSetter" value="true"/>
+ </module>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber"/>
=======================================
---
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java
Fri Oct 9 08:50:00 2009
+++
/piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/PFrame.java
Fri Oct 9 10:12:23 2009
@@ -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();
=======================================
--- /piccolo2d.java/trunk/swt/src/build/conf/checkstyle.xml Thu Oct 8
11:29:42 2009
+++ /piccolo2d.java/trunk/swt/src/build/conf/checkstyle.xml Fri Oct 9
10:12:23 2009
@@ -137,7 +137,10 @@
<module name="DoubleCheckedLocking"/> <!-- MY FAVOURITE -->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
- <module name="HiddenField"/>
+ <module name="HiddenField">
+ <property name="ignoreConstructorParameter" value="true"/>
+ <property name="ignoreSetter" value="true"/>
+ </module>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber"/>
--~--~---------~--~----~------------~-------~--~----~
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
-~----------~----~----~----~------~----~------~--~---