# HG changeset patch # User Matti Hamalainen # Date 1298349011 -7200 # Node ID 79185dababf2dfb64e22b15d3171915411efced1 # Parent 698c6bcc4aecbf9fde25560c6faa0b366bd30238 Add comments. diff -r 698c6bcc4aec -r 79185dababf2 game/Piece.java --- a/game/Piece.java Tue Feb 22 06:03:51 2011 +0200 +++ b/game/Piece.java Tue Feb 22 06:30:11 2011 +0200 @@ -230,8 +230,10 @@ public void paint(Graphics2D g, float x, float y, float dim) { + // Transform drawing by current angle g.rotate(currAngle, x + dim / 2.0f, y + dim / 2.0f); + // Color piece by type switch (type) { case LOCKED: g.setPaint(Color.green); break; case ACTIVE: g.setPaint(Color.red); break; @@ -240,10 +242,11 @@ g.fill(new RoundRectangle2D.Float(x, y, dim, dim, dim / 10, dim / 10)); - + // Start pieces (center piece) do not have border, etc. if (type == PieceType.START) return; + // Active piece has a throbbing "ghost" border if (type == PieceType.ACTIVE) { float offs1 = throbTime * 10.0f, @@ -251,12 +254,15 @@ g.setPaint(new Color(0.0f, 0.0f, 0.0f, (float) (1.0f - throbTime) )); g.setStroke(new BasicStroke(2.0f + throbTime * 2.0f)); - g.draw(new RoundRectangle2D.Float(x - offs1, y - offs1, dim + offs2, dim + offs2, dim / 10, dim / 10)); + g.draw(new RoundRectangle2D.Float( + x - offs1, y - offs1, + dim + offs2, dim + offs2, + dim / 10, dim / 10)); } + // Draw the connections g.setStroke(new BasicStroke(5.0f)); CubicCurve2D c = new CubicCurve2D.Float(); -// QuadCurve2D c = new QuadCurve2D.Float(); boolean[] drawn = new boolean[numConnections]; for (int i = 0; i < numConnections; i++) if (!drawn[i]) @@ -275,10 +281,12 @@ c.setCurve(start, cp1, cp2, end); g.draw(c); + // Mark connection drawn, so we don't overdraw drawn[i] = true; drawn[connections[i]] = true; } + // Draw piece border g.setPaint(Color.black); g.setStroke(new BasicStroke(5.0f)); g.draw(new RoundRectangle2D.Float(x, y, dim, dim, dim / 10, dim / 10));