# HG changeset patch # User Matti Hamalainen # Date 1296230418 -7200 # Node ID 4890020bf8561e09f65e8f5094d4b2a622020568 # Parent e0e8fd08331e44c773c0202f439c8f1b8453f339 Cleanups, etc. diff -r e0e8fd08331e -r 4890020bf856 game/Piece.java --- a/game/Piece.java Fri Jan 28 17:37:01 2011 +0200 +++ b/game/Piece.java Fri Jan 28 18:00:18 2011 +0200 @@ -74,7 +74,7 @@ { return connections[in]; } - + public void rotate(boolean dir) { if (type != PieceType.NORMAL) @@ -89,88 +89,83 @@ rotationDir = dir; rotationChanged = true; - } - - public Point2D getPoint(double x, double y, double dim, int index) - { - double ox = 0, oy = 0; - double step = dim / 10; - - switch (index) { - case 0: ox = 3.0f; oy = 0.5f; break; - case 1: ox = 7.0f; oy = 0.5f; break; - case 2: ox = 9.5f; oy = 3.0f; break; - case 3: ox = 9.5f; oy = 7.0f; break; - case 4: ox = 7.0f; oy = 9.5f; break; - case 5: ox = 3.0f; oy = 9.5f; break; - case 6: ox = 0.5f; oy = 7.0f; break; - case 7: ox = 0.5f; oy = 3.0f; break; - - case -1: ox = 5; oy = 5; break; - } + } - return new Point2D.Double(x + ox * step, y + oy * step); - } - - public void animate(double time) - { - if (rotationChanged) - { - rotationTime = time; - rotationActive = true; - } - - if (rotationActive) - { - double t = time - rotationTime; - rotationAngle = - } + public Point2D getPointCoords(double x, double y, double dim, int index) + { + double ox = 0, oy = 0; + double step = dim / 10; - } + switch (index) { + case 0: ox = 3.0f; oy = 0.5f; break; + case 1: ox = 7.0f; oy = 0.5f; break; + case 2: ox = 9.5f; oy = 3.0f; break; + case 3: ox = 9.5f; oy = 7.0f; break; + case 4: ox = 7.0f; oy = 9.5f; break; + case 5: ox = 3.0f; oy = 9.5f; break; + case 6: ox = 0.5f; oy = 7.0f; break; + case 7: ox = 0.5f; oy = 3.0f; break; - public void paint(Graphics2D g, double x, double y, double dim) - { - AffineTransform save = g.getTransform(); + case -1: ox = 5.0f; oy = 5.0f; break; + } - g.setStroke(new BasicStroke(4.0f)); + return new Point2D.Double(x + ox * step, y + oy * step); + } - switch (type) { - case NORMAL: g.setPaint(Color.green); break; - case ACTIVE: g.setPaint(Color.red); break; - case START: g.setPaint(Color.orange); break; - } + public void animate(double time) + { + if (rotationChanged) + { + rotationTime = time; + rotationActive = true; + } - AffiineTransform tf = new AffineTransform(); - tf.rotate(Math.toRadians(rotationAngle)); - g.transform(tf); - g.fill(new RoundRectangle2D.Double(x, y, dim, dim, dim / 10, dim / 10)); + if (rotationActive) + { + double t = time - rotationTime; + rotationAngle = + } + + } - g.setPaint(Color.black); - g.setStroke(new BasicStroke(4.0f)); - g.draw(new RoundRectangle2D.Double(x, y, dim, dim, dim / 10, dim / 10)); + public void paint(Graphics2D g, double x, double y, double dim) + { + AffineTransform save = g.getTransform(); + + AffineTransform tf = new AffineTransform(); + tf.rotate(Math.toRadians(rotationAngle)); + g.transform(tf); - if (type == PieceType.START) - return; + switch (type) { + case NORMAL: g.setPaint(Color.green); break; + case ACTIVE: g.setPaint(Color.red); break; + case START: g.setPaint(Color.orange); break; + } + g.fill(new RoundRectangle2D.Double(x, y, dim, dim, dim / 10, dim / 10)); - g.setStroke(new BasicStroke(6.0f)); + g.setPaint(Color.black); + g.setStroke(new BasicStroke(4.0f)); + g.draw(new RoundRectangle2D.Double(x, y, dim, dim, dim / 10, dim / 10)); + + if (type == PieceType.START) + return; + + g.setStroke(new BasicStroke(6.0f)); // CubicCurve2D c = new CubicCurve2D.Double(); - QuadCurve2D c = new QuadCurve2D.Double(); + QuadCurve2D c = new QuadCurve2D.Double(); - for (int i = 0; i < numConnections / 2; i++) - { - Point2D start, cp1, cp2, end; - - start = getPoint(x, y, dim, i); - end = getPoint(x, y, dim, connections[i]); - + for (int i = 0; i < numConnections / 2; i++) + { + Point2D start, cp1, cp2, end; + start = getPoint(x, y, dim, i); + end = getPoint(x, y, dim, connections[i]); // cp1 = getPoint(x, y, dim, (i + 4) % 8); // cp2 = getPoint(x, y, dim, (connections[i] + 4) % 8); - cp1 = getPoint(x, y, dim, -1); + cp1 = getPoint(x, y, dim, -1); - c.setCurve(start, cp1, end); - g.draw(c); - } - - g.setTransform(save); - } + c.setCurve(start, cp1, end); + g.draw(c); + } + g.setTransform(save); + } }