annotate game/Piece.java @ 2:1785f66a7beb

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 28 Jan 2011 16:53:06 +0200
parents 44f1e7b47fcf
children b8fd19e2d879
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Ristipolku
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * (C) Copyright 2011 Matti 'ccr' Hämäläinen <ccr@tnsp.org>
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 */
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 package game;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 import java.awt.*;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 import java.awt.geom.*;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 import java.awt.event.*;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 import javax.swing.*;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 import java.util.*;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 public class Piece
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 static final int numConnections = 8;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 static final int minRotation = 0;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 static final int maxRotation = 3;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 int currRotation;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 int[] connections;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 PieceType type, oldType;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 boolean rotationChanged, rotationActive,
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 typeChanged, typeActive;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 double currAngle, newAngle;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 public Piece(PieceType ptype)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 // Initialize
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 connections = new int[numConnections];
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 type = ptype;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 rotationChanged = false;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 typeChanged = false;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 rotationActive = false;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 typeActive = false;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 currRotation = 0;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 // Initialize connections between endpoints of the paths inside the piece
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 for (int i = 0; i < numConnections; i++)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 connections[i] = -1;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 Random rnd = new Random();
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 for (int i = 0; i < numConnections; i++)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 int tmp = rnd.nextInt(numConnections);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 if (connections[tmp] < 0 && connections[i] < 0)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 connections[i] = tmp;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 connections[tmp] = i;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 public Piece()
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 this(PieceType.NONE);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 public void setType(PieceType ptype)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 oldType = type;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 type = ptype;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 public int getConnection(int in)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 return connections[in];
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 public void rotate(boolean dir)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 if (type != PieceType.NORMAL)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 return;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 newRotation = currRotation + (dir ? 1 : -1);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 if (newRotation < minRotation)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 newRotation = maxRotation;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 else if (currRotation > maxRotation)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 newRotation = minRotation;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 rotationDir = dir;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 rotationChanged = true;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 public Point2D getPoint(double x, double y, double dim, int index)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 double ox = 0, oy = 0;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 double step = dim / 10;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 switch (index) {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 case 0: ox = 3.0f; oy = 0.5f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 case 1: ox = 7.0f; oy = 0.5f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 case 2: ox = 9.5f; oy = 3.0f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 case 3: ox = 9.5f; oy = 7.0f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 case 4: ox = 7.0f; oy = 9.5f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 case 5: ox = 3.0f; oy = 9.5f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 case 6: ox = 0.5f; oy = 7.0f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 case 7: ox = 0.5f; oy = 3.0f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 case -1: ox = 5; oy = 5; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 return new Point2D.Double(x + ox * step, y + oy * step);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 public void animate(double time)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 if (rotationChanged)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 rotationTime = time;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 rotationActive = true;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 if (rotationActive)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 double t = time - rotationTime;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 rotationAngle =
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 public void paint(Graphics2D g, double x, double y, double dim)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 AffineTransform save = g.getTransform();
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 g.setStroke(new BasicStroke(4.0f));
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 switch (type) {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 case NORMAL: g.setPaint(Color.green); break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 case ACTIVE: g.setPaint(Color.red); break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 case START: g.setPaint(Color.orange); break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 AffiineTransform tf = new AffineTransform();
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 tf.rotate(Math.toRadians(rotationAngle));
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 g.transform(tf);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 g.fill(new RoundRectangle2D.Double(x, y, dim, dim, dim / 10, dim / 10));
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 g.setPaint(Color.black);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 g.setStroke(new BasicStroke(4.0f));
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 g.draw(new RoundRectangle2D.Double(x, y, dim, dim, dim / 10, dim / 10));
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 if (type == PieceType.START)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 return;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 g.setStroke(new BasicStroke(6.0f));
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 // CubicCurve2D c = new CubicCurve2D.Double();
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 QuadCurve2D c = new QuadCurve2D.Double();
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 for (int i = 0; i < numConnections / 2; i++)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 Point2D start, cp1, cp2, end;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 start = getPoint(x, y, dim, i);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 end = getPoint(x, y, dim, connections[i]);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162 // cp1 = getPoint(x, y, dim, (i + 4) % 8);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 // cp2 = getPoint(x, y, dim, (connections[i] + 4) % 8);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 cp1 = getPoint(x, y, dim, -1);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 c.setCurve(start, cp1, end);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 g.draw(c);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 g.setTransform(save);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 }