-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEnableBoundarySequencesActionListener.java
317 lines (285 loc) · 18.6 KB
/
EnableBoundarySequencesActionListener.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
import javax.media.j3d.Appearance;
import javax.media.j3d.ColoringAttributes;
import javax.media.j3d.TransparencyAttributes;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/**
* Created by foram.joshi on 13.10.2014.
*/
public class EnableBoundarySequencesActionListener implements ActionListener {
int[][][] canvasCoordinates = new int[MainFrame.width][MainFrame.height][MainFrame.depth + 1];
int x, y, z;
@Override
public void actionPerformed(ActionEvent e) {
final JFrame enableBoundaryPlaneFrame = new JFrame("Enable Boundary Bricks");
enableBoundaryPlaneFrame.setBackground(Color.DARK_GRAY);
ImageIcon img = new ImageIcon("icons/software_logo.png");
Image imag=img.getImage();
enableBoundaryPlaneFrame.setIconImage(imag);
enableBoundaryPlaneFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
JPanel mainPanel = new JPanel();
mainPanel.setBackground(Color.DARK_GRAY);
mainPanel.setLayout(new GridBagLayout());
GridBagConstraints dimensionFrameGridBagConstraints = new GridBagConstraints();
dimensionFrameGridBagConstraints.insets = new Insets(3, 3, 3, 3);
JLabel enableBoundaryPlaneLabel = new JLabel("<html><style>h4{color:white;}</style><h4> Select Canvas Plane: </h4></html>");
final JCheckBox xMinPlaneBoundaryCheckbox = new JCheckBox("<html><style>h4{color:white;}</style><h4>Min-X Plane</h4></html>");
xMinPlaneBoundaryCheckbox.setBackground(Color.DARK_GRAY);
Icon minXBoundaryCubeIcon = new ImageIcon("icons/minXBoundaryCubeIcon.png");
JLabel minXBoundaryCubeIconLabel = new JLabel("", minXBoundaryCubeIcon, JLabel.LEFT);
if ( MainFrame.isMinXBoundaryPlaneEnabled )
xMinPlaneBoundaryCheckbox.setSelected(true);
Icon maxXBoundaryCubeIcon = new ImageIcon("icons/maxXBoundaryCubeIcon.png");
JLabel maxXBoundaryCubeIconLabel = new JLabel("", maxXBoundaryCubeIcon, JLabel.LEFT);
final JCheckBox xMaxPlaneBoundaryCheckbox = new JCheckBox("<html><style>h4{color:white;}</style><h4>Max-X Plane</h4></html>");
xMaxPlaneBoundaryCheckbox.setBackground(Color.DARK_GRAY);
if ( MainFrame.isMaxXBoundaryPlaneEnabled )
xMaxPlaneBoundaryCheckbox.setSelected(true);
Icon minYBoundaryCubeIcon = new ImageIcon("icons/minYBoundaryCubeIcon.png");
JLabel minYBoundaryCubeIconLabel = new JLabel("", minYBoundaryCubeIcon, JLabel.LEFT);
final JCheckBox yMinPlaneBoundaryCheckbox = new JCheckBox("<html><style>h4{color:white;}</style><h4>Min-Y Plane</h4></html>");
yMinPlaneBoundaryCheckbox.setBackground(Color.DARK_GRAY);
if ( MainFrame.isMinYBoundaryPlaneEnabled )
yMinPlaneBoundaryCheckbox.setSelected(true);
Icon maxYBoundaryCubeIcon = new ImageIcon("icons/maxYBoundaryCubeIcon.png");
JLabel maxYBoundaryCubeIconLabel = new JLabel("", maxYBoundaryCubeIcon, JLabel.LEFT);
final JCheckBox yMaxPlaneBoundaryCheckbox = new JCheckBox("<html><style>h4{color:white;}</style><h4>Max-Y Plane</h4></html>");
yMaxPlaneBoundaryCheckbox.setBackground(Color.DARK_GRAY);
if ( MainFrame.isMaxYBoundaryPlaneEnabled )
yMaxPlaneBoundaryCheckbox.setSelected(true);
JButton okButton = new JButton("OK");
okButton.setBackground(Color.DARK_GRAY);
dimensionFrameGridBagConstraints.gridx = 0;
dimensionFrameGridBagConstraints.gridy = 0;
mainPanel.add(enableBoundaryPlaneLabel, dimensionFrameGridBagConstraints);
dimensionFrameGridBagConstraints.gridx = 0;
dimensionFrameGridBagConstraints.gridy = 1;
mainPanel.add(xMinPlaneBoundaryCheckbox, dimensionFrameGridBagConstraints);
dimensionFrameGridBagConstraints.gridx = 1;
dimensionFrameGridBagConstraints.gridy = 1;
mainPanel.add(minXBoundaryCubeIconLabel, dimensionFrameGridBagConstraints);
dimensionFrameGridBagConstraints.gridx = 0;
dimensionFrameGridBagConstraints.gridy = 2;
mainPanel.add(xMaxPlaneBoundaryCheckbox, dimensionFrameGridBagConstraints);
dimensionFrameGridBagConstraints.gridx = 1;
dimensionFrameGridBagConstraints.gridy = 2;
mainPanel.add(maxXBoundaryCubeIconLabel, dimensionFrameGridBagConstraints);
dimensionFrameGridBagConstraints.gridx = 0;
dimensionFrameGridBagConstraints.gridy = 3;
mainPanel.add(yMinPlaneBoundaryCheckbox, dimensionFrameGridBagConstraints);
dimensionFrameGridBagConstraints.gridx = 1;
dimensionFrameGridBagConstraints.gridy = 3;
mainPanel.add(minYBoundaryCubeIconLabel, dimensionFrameGridBagConstraints);
dimensionFrameGridBagConstraints.gridx = 0;
dimensionFrameGridBagConstraints.gridy = 4;
mainPanel.add(yMaxPlaneBoundaryCheckbox, dimensionFrameGridBagConstraints);
dimensionFrameGridBagConstraints.gridx = 1;
dimensionFrameGridBagConstraints.gridy = 4;
mainPanel.add(maxYBoundaryCubeIconLabel, dimensionFrameGridBagConstraints);
dimensionFrameGridBagConstraints.gridx = 0;
dimensionFrameGridBagConstraints.gridy = 5;
mainPanel.add(okButton, dimensionFrameGridBagConstraints);
enableBoundaryPlaneFrame.add(mainPanel, BorderLayout.CENTER);
enableBoundaryPlaneFrame.pack();
enableBoundaryPlaneFrame.setVisible(true);
enableBoundaryPlaneFrame.setLocation(MainFrame.screenWidth / 3, MainFrame.screenHeight / 4);
xMinPlaneBoundaryCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (xMinPlaneBoundaryCheckbox.isSelected() == true){
IdentifyBoundaryAndProtectorBricks identifyMinXBoundary = new IdentifyBoundaryAndProtectorBricks('b');
Appearance ap = new Appearance();
TransparencyAttributes transparencyAttributes = new TransparencyAttributes(TransparencyAttributes.NICEST,0.7f);
ColoringAttributes coloringAttributes = new ColoringAttributes(1.0f, 1.0f, 0.0f, ColoringAttributes.NICEST);
ap.setTransparencyAttributes( transparencyAttributes );
ap.setColoringAttributes(coloringAttributes);
for (int j = 0 ; j < CanvasActionListener.colorCubeArrayList.size(); j++) {
x = CanvasActionListener.colorCubeArrayList.get(j).xCord;
y = CanvasActionListener.colorCubeArrayList.get(j).yCord;
z = CanvasActionListener.colorCubeArrayList.get(j).zCord;
if (identifyMinXBoundary.newIndex[x][y][z]!=-1 && identifyMinXBoundary.boundaryBrickList.get(identifyMinXBoundary.newIndex[x][y][z]).isLeftmostHalfBrick) {
DNAColorCube pickedCube = CanvasActionListener.colorCubeArrayList.get(j).canvasDNAColorCube;
pickedCube.setAppearance(ap);
}
}
}
else{
IdentifyBoundaryAndProtectorBricks identifyMinXBoundary = new IdentifyBoundaryAndProtectorBricks('b');
Appearance ap = new Appearance();
for (int j = 0 ; j < CanvasActionListener.colorCubeArrayList.size(); j++) {
x = CanvasActionListener.colorCubeArrayList.get(j).xCord;
y = CanvasActionListener.colorCubeArrayList.get(j).yCord;
z = CanvasActionListener.colorCubeArrayList.get(j).zCord;
if (identifyMinXBoundary.newIndex[x][y][z]!=-1 && identifyMinXBoundary.boundaryBrickList.get(identifyMinXBoundary.newIndex[x][y][z]).isLeftmostHalfBrick) {
DNAColorCube pickedCube = CanvasActionListener.colorCubeArrayList.get(j).canvasDNAColorCube;
pickedCube.setAppearance(ap);
}
}
}
}
});
xMaxPlaneBoundaryCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (xMaxPlaneBoundaryCheckbox.isSelected() == true){
IdentifyBoundaryAndProtectorBricks identifyMaxXBoundary = new IdentifyBoundaryAndProtectorBricks('b');
Appearance ap = new Appearance();
TransparencyAttributes transparencyAttributes = new TransparencyAttributes(TransparencyAttributes.NICEST,0.7f);
ColoringAttributes coloringAttributes = new ColoringAttributes(1.0f, 1.0f, 0.0f, ColoringAttributes.NICEST);
ap.setTransparencyAttributes( transparencyAttributes );
ap.setColoringAttributes(coloringAttributes);
for (int j = 0 ; j < CanvasActionListener.colorCubeArrayList.size(); j++) {
x = CanvasActionListener.colorCubeArrayList.get(j).xCord;
y = CanvasActionListener.colorCubeArrayList.get(j).yCord;
z = CanvasActionListener.colorCubeArrayList.get(j).zCord;
if (identifyMaxXBoundary.newIndex[x][y][z]!=-1 && identifyMaxXBoundary.boundaryBrickList.get(identifyMaxXBoundary.newIndex[x][y][z]).isRightmostHalfBrick) {
DNAColorCube pickedCube = CanvasActionListener.colorCubeArrayList.get(j).canvasDNAColorCube;
pickedCube.setAppearance(ap);
}
}
}
else{
IdentifyBoundaryAndProtectorBricks identifyMaxXBoundary = new IdentifyBoundaryAndProtectorBricks('b');
Appearance ap = new Appearance();
for (int j = 0 ; j < CanvasActionListener.colorCubeArrayList.size(); j++) {
x = CanvasActionListener.colorCubeArrayList.get(j).xCord;
y = CanvasActionListener.colorCubeArrayList.get(j).yCord;
z = CanvasActionListener.colorCubeArrayList.get(j).zCord;
if (identifyMaxXBoundary.newIndex[x][y][z]!=-1 && identifyMaxXBoundary.boundaryBrickList.get(identifyMaxXBoundary.newIndex[x][y][z]).isRightmostHalfBrick) {
DNAColorCube pickedCube = CanvasActionListener.colorCubeArrayList.get(j).canvasDNAColorCube;
pickedCube.setAppearance(ap);
}
}
}
}
});
yMinPlaneBoundaryCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (yMinPlaneBoundaryCheckbox.isSelected() == true){
IdentifyBoundaryAndProtectorBricks identifyMinYBoundary = new IdentifyBoundaryAndProtectorBricks('b');
Appearance ap = new Appearance();
TransparencyAttributes transparencyAttributes = new TransparencyAttributes(TransparencyAttributes.NICEST,0.7f);
ColoringAttributes coloringAttributes = new ColoringAttributes(1.0f, 1.0f, 0.0f, ColoringAttributes.NICEST);
ap.setTransparencyAttributes( transparencyAttributes );
ap.setColoringAttributes(coloringAttributes);
for (int j = 0 ; j < CanvasActionListener.colorCubeArrayList.size(); j++) {
x = CanvasActionListener.colorCubeArrayList.get(j).xCord;
y = CanvasActionListener.colorCubeArrayList.get(j).yCord;
z = CanvasActionListener.colorCubeArrayList.get(j).zCord;
if (identifyMinYBoundary.newIndex[x][y][z]!=-1 && identifyMinYBoundary.boundaryBrickList.get(identifyMinYBoundary.newIndex[x][y][z]).isTopmostHalfBrick) {
DNAColorCube pickedCube = CanvasActionListener.colorCubeArrayList.get(j).canvasDNAColorCube;
pickedCube.setAppearance(ap);
}
}
}
else{
IdentifyBoundaryAndProtectorBricks identifyMinYBoundary = new IdentifyBoundaryAndProtectorBricks('b');
Appearance ap = new Appearance();
for (int j = 0 ; j < CanvasActionListener.colorCubeArrayList.size(); j++) {
x = CanvasActionListener.colorCubeArrayList.get(j).xCord;
y = CanvasActionListener.colorCubeArrayList.get(j).yCord;
z = CanvasActionListener.colorCubeArrayList.get(j).zCord;
if (identifyMinYBoundary.newIndex[x][y][z]!=-1 && identifyMinYBoundary.boundaryBrickList.get(identifyMinYBoundary.newIndex[x][y][z]).isTopmostHalfBrick) {
DNAColorCube pickedCube = CanvasActionListener.colorCubeArrayList.get(j).canvasDNAColorCube;
pickedCube.setAppearance(ap);
}
}
}
}
});
yMaxPlaneBoundaryCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (yMaxPlaneBoundaryCheckbox.isSelected() == true){
IdentifyBoundaryAndProtectorBricks identifyMaxYBoundary = new IdentifyBoundaryAndProtectorBricks('b');
Appearance ap = new Appearance();
TransparencyAttributes transparencyAttributes = new TransparencyAttributes(TransparencyAttributes.NICEST,0.7f);
ColoringAttributes coloringAttributes = new ColoringAttributes(1.0f, 1.0f, 0.0f, ColoringAttributes.NICEST);
ap.setTransparencyAttributes( transparencyAttributes );
ap.setColoringAttributes(coloringAttributes);
for (int j = 0 ; j < CanvasActionListener.colorCubeArrayList.size(); j++) {
x = CanvasActionListener.colorCubeArrayList.get(j).xCord;
y = CanvasActionListener.colorCubeArrayList.get(j).yCord;
z = CanvasActionListener.colorCubeArrayList.get(j).zCord;
if (identifyMaxYBoundary.newIndex[x][y][z]!=-1 && identifyMaxYBoundary.boundaryBrickList.get(identifyMaxYBoundary.newIndex[x][y][z]).isBottommostHalfBrick) {
DNAColorCube pickedCube = CanvasActionListener.colorCubeArrayList.get(j).canvasDNAColorCube;
pickedCube.setAppearance(ap);
}
}
}
else {
IdentifyBoundaryAndProtectorBricks identifyMaxYBoundary = new IdentifyBoundaryAndProtectorBricks('b');
Appearance ap = new Appearance();
for (int j = 0 ; j < CanvasActionListener.colorCubeArrayList.size(); j++) {
x = CanvasActionListener.colorCubeArrayList.get(j).xCord;
y = CanvasActionListener.colorCubeArrayList.get(j).yCord;
z = CanvasActionListener.colorCubeArrayList.get(j).zCord;
if (identifyMaxYBoundary.newIndex[x][y][z]!=-1 && identifyMaxYBoundary.boundaryBrickList.get(identifyMaxYBoundary.newIndex[x][y][z]).isBottommostHalfBrick) {
DNAColorCube pickedCube = CanvasActionListener.colorCubeArrayList.get(j).canvasDNAColorCube;
pickedCube.setAppearance(ap);
}
}
}
}
});
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (xMinPlaneBoundaryCheckbox.isSelected() == true) {
MainFrame.isMinXBoundaryPlaneEnabled = true;
MainFrame.printLog("minimum X boundary plane enabled", Color.cyan);
}
else {
MainFrame.isMinXBoundaryPlaneEnabled = false;
}
if (xMaxPlaneBoundaryCheckbox.isSelected() == true) {
MainFrame.isMaxXBoundaryPlaneEnabled = true;
MainFrame.printLog("maximum X boundary plane enabled", Color.cyan);
}
else {
MainFrame.isMaxXBoundaryPlaneEnabled = false;
}
if (yMinPlaneBoundaryCheckbox.isSelected() == true) {
MainFrame.isMinYBoundaryPlaneEnabled = true;
MainFrame.printLog("minimum Y boundary plane enabled", Color.cyan);
}
else {
MainFrame.isMinYBoundaryPlaneEnabled = false;
}
if (yMaxPlaneBoundaryCheckbox.isSelected() == true) {
MainFrame.isMaxYBoundaryPlaneEnabled = true;
MainFrame.printLog("maximum Y boundary plane enabled", Color.cyan);
}
else {
MainFrame.isMaxYBoundaryPlaneEnabled = false;
}
MainFrame.isCSVSaved = false;
MainFrame.isPDFSaved = false;
MainFrame.isCSVBoundarySaved = false;
MainFrame.isPDFBoundarySaved = false;
switchToOriginalColor();
enableBoundaryPlaneFrame.dispose();
}
});
enableBoundaryPlaneFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
enableBoundaryPlaneFrame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
switchToOriginalColor();
}
});
}
public void switchToOriginalColor(){
MainFrame.printLog("swiching back to original color", Color.white);
Appearance ap = new Appearance();
for (int z = 0 ; z < CanvasActionListener.colorCubeArrayList.size(); z++) {
DNAColorCube pickedCube = CanvasActionListener.colorCubeArrayList.get(z).canvasDNAColorCube;
pickedCube.setAppearance(ap);
}
}
}