annotate game/Piece.java @ 3:b8fd19e2d879

Indentation.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 28 Jan 2011 16:59:36 +0200
parents 1785f66a7beb
children 4890020bf856
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 {
3
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
16 static final int numConnections = 8;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
17 static final int minRotation = 0;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
18 static final int maxRotation = 3;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
19 int currRotation;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
20 int[] connections;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
21 PieceType type, oldType;
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22
3
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
23 boolean rotationChanged, rotationActive,
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
24 typeChanged, typeActive;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
25 double currAngle, newAngle;
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
3
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
27 public Piece(PieceType ptype)
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
28 {
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
29 // Initialize
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
30 connections = new int[numConnections];
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
31 type = ptype;
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32
3
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
33 rotationChanged = false;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
34 typeChanged = false;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
35 rotationActive = false;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
36 typeActive = false;
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
3
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
38 currRotation = 0;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
39 currAngle = 0;
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41
3
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
42 // Initialize connections between endpoints of the paths inside the piece
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
43 for (int i = 0; i < numConnections; i++)
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
44 connections[i] = -1;
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45
3
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
46 Random rnd = new Random();
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
47 for (int i = 0; i < numConnections; i++)
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
48 {
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
49 while (connections[i] < 0)
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
50 {
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
51 int tmp = rnd.nextInt(numConnections);
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
52 if (connections[tmp] < 0)
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
53 {
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
54 connections[i] = tmp;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
55 connections[tmp] = i;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
56 }
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
57 }
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
58 }
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
59 }
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
60
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
61 public Piece()
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
62 {
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
63 this(PieceType.NONE);
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
64 }
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65
3
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
66 public void setType(PieceType ptype)
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
67 {
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
68 typeChanged = (oldType != ptype);
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
69 oldType = type;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
70 type = ptype;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
71 }
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72
3
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
73 public int getConnection(int in)
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
74 {
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
75 return connections[in];
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
76 }
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77
3
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
78 public void rotate(boolean dir)
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
79 {
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
80 if (type != PieceType.NORMAL)
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
81 return;
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82
3
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
83 newRotation = currRotation + (dir ? 1 : -1);
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84
3
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
85 if (newRotation < minRotation)
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
86 newRotation = maxRotation;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
87 else if (currRotation > maxRotation)
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
88 newRotation = minRotation;
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89
3
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
90 rotationDir = dir;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
91 rotationChanged = true;
b8fd19e2d879 Indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
92 }
1
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 public Point2D getPoint(double x, double y, double dim, int index)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 double ox = 0, oy = 0;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 double step = dim / 10;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 switch (index) {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 case 0: ox = 3.0f; oy = 0.5f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 case 1: ox = 7.0f; oy = 0.5f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 case 2: ox = 9.5f; oy = 3.0f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 case 3: ox = 9.5f; oy = 7.0f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 case 4: ox = 7.0f; oy = 9.5f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 case 5: ox = 3.0f; oy = 9.5f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 case 6: ox = 0.5f; oy = 7.0f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 case 7: ox = 0.5f; oy = 3.0f; break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 case -1: ox = 5; oy = 5; break;
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
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 return new Point2D.Double(x + ox * step, y + oy * step);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 }
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 public void animate(double time)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 if (rotationChanged)
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 rotationTime = time;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 rotationActive = true;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 if (rotationActive)
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 double t = time - rotationTime;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 rotationAngle =
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 }
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 }
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 public void paint(Graphics2D g, double x, double y, double dim)
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 AffineTransform save = g.getTransform();
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 g.setStroke(new BasicStroke(4.0f));
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 switch (type) {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 case NORMAL: g.setPaint(Color.green); break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 case ACTIVE: g.setPaint(Color.red); break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 case START: g.setPaint(Color.orange); break;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 AffiineTransform tf = new AffineTransform();
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 tf.rotate(Math.toRadians(rotationAngle));
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 g.transform(tf);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 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
147
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 g.setPaint(Color.black);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 g.setStroke(new BasicStroke(4.0f));
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 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
151
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 if (type == PieceType.START)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 return;
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 g.setStroke(new BasicStroke(6.0f));
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 // CubicCurve2D c = new CubicCurve2D.Double();
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 QuadCurve2D c = new QuadCurve2D.Double();
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 for (int i = 0; i < numConnections / 2; i++)
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 {
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 Point2D start, cp1, cp2, end;
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 start = getPoint(x, y, dim, i);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 end = getPoint(x, y, dim, connections[i]);
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 // cp1 = getPoint(x, y, dim, (i + 4) % 8);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 // cp2 = getPoint(x, y, dim, (connections[i] + 4) % 8);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 cp1 = getPoint(x, y, dim, -1);
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 c.setCurve(start, cp1, end);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 g.draw(c);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 g.setTransform(save);
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 }
44f1e7b47fcf Preliminary work ... puuh.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 }