-
Notifications
You must be signed in to change notification settings - Fork 3
/
MainMenu.java
286 lines (247 loc) · 6.76 KB
/
MainMenu.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
// Copyright (c) 2013 Joe Davisson.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
public class MainMenu extends JMenuBar
{
public MainMenu()
{
// file menu
JMenu fileMenu = new JMenu("File");
JMenuItem newItem = new JMenuItem("New Project");
newItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
int response = JOptionPane.showConfirmDialog(SimplePCB.win, "Are You Sure?", "New Project", JOptionPane.YES_NO_OPTION);
if(response == JOptionPane.YES_OPTION)
SimplePCB.newProject();
}
} );
JMenuItem loadItem = new JMenuItem("Load Project...");
loadItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.loadProject();
}
} );
JMenuItem saveItem = new JMenuItem("Save Project...");
saveItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.saveProject();
}
} );
// export gerber
JMenu exportGerberMenu = new JMenu("Export Gerber");
JMenuItem gerberItem0 = new JMenuItem("Artwork Layer...");
gerberItem0.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.exportGerberLayer(0);
}
} );
JMenuItem gerberItem1 = new JMenuItem("Top Layer...");
gerberItem1.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.exportGerberLayer(1);
}
} );
JMenuItem gerberItem2 = new JMenuItem("Bottom Layer...");
gerberItem2.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.exportGerberLayer(2);
}
} );
exportGerberMenu.add(gerberItem0);
exportGerberMenu.add(gerberItem1);
exportGerberMenu.add(gerberItem2);
// export PNG
JMenu exportPngMenu = new JMenu("Export PNG");
JMenuItem pngItem0 = new JMenuItem("Artwork Layer...");
pngItem0.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.exportPngLayer(0);
}
} );
JMenuItem pngItem1 = new JMenuItem("Top Layer...");
pngItem1.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.exportPngLayer(1);
}
} );
JMenuItem pngItem2 = new JMenuItem("Bottom Layer...");
pngItem2.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.exportPngLayer(2);
}
} );
exportPngMenu.add(pngItem0);
exportPngMenu.add(pngItem1);
exportPngMenu.add(pngItem2);
// quit
JMenuItem quitItem = new JMenuItem("Quit");
quitItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.quit();
}
} );
fileMenu.add(newItem);
fileMenu.add(loadItem);
fileMenu.add(saveItem);
fileMenu.addSeparator();
fileMenu.add(exportGerberMenu);
fileMenu.add(exportPngMenu);
fileMenu.addSeparator();
fileMenu.add(quitItem);
add(fileMenu);
// edit menu
JMenu editMenu = new JMenu("Edit");
JMenuItem duplicateItem = new JMenuItem("Duplicate");
duplicateItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.duplicate();
}
} );
JMenuItem groupItem = new JMenuItem("Group");
groupItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.finishGroup();
}
} );
JMenuItem ungroupItem = new JMenuItem("Ungroup");
ungroupItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.unGroup();
}
} );
JMenuItem boardSizeItem = new JMenuItem("Board Size...");
boardSizeItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
new BoardSizeDialog(SimplePCB.win);
}
} );
JMenuItem traceSizeItem = new JMenuItem("Custom Trace Size...");
traceSizeItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
new TraceSizeDialog(SimplePCB.win);
}
} );
JMenuItem padSizeItem = new JMenuItem("Custom Pad Size...");
padSizeItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
new PadSizeDialog(SimplePCB.win);
}
} );
JMenuItem gridItem = new JMenuItem("Grid...");
gridItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
new GridDialog(SimplePCB.win);
}
} );
editMenu.add(duplicateItem);
editMenu.addSeparator();
editMenu.add(groupItem);
editMenu.add(ungroupItem);
editMenu.addSeparator();
editMenu.add(boardSizeItem);
editMenu.add(padSizeItem);
editMenu.add(traceSizeItem);
editMenu.addSeparator();
editMenu.add(gridItem);
add(editMenu);
// transform menu
JMenu transformMenu = new JMenu("Transform");
JMenuItem rotateItem = new JMenuItem("Rotate");
rotateItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.rotate();
}
} );
JMenuItem flipItem = new JMenuItem("Flip");
flipItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.flip();
}
} );
JMenuItem mirrorItem = new JMenuItem("Mirror");
mirrorItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.mirror();
}
} );
transformMenu.add(rotateItem);
transformMenu.add(flipItem);
transformMenu.add(mirrorItem);
add(transformMenu);
// help menu
JMenu helpMenu = new JMenu("Help");
JMenuItem aboutItem = new JMenuItem("About...");
aboutItem.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SimplePCB.about();
}
} );
helpMenu.add(aboutItem);
add(helpMenu);
}
}