1 | /* |
---|
2 | * $Id: VectorAttributeDialog.java,v 1.7 2003/08/22 23:02:40 dwd Exp $ |
---|
3 | * |
---|
4 | * This software is provided by NOAA for full, free and open release. It is |
---|
5 | * understood by the recipient/user that NOAA assumes no liability for any |
---|
6 | * errors contained in the code. Although this software is released without |
---|
7 | * conditions or restrictions in its use, it is expected that appropriate |
---|
8 | * credit be given to its author and to the National Oceanic and Atmospheric |
---|
9 | * Administration should the software be included by the recipient as an |
---|
10 | * element in other product development. |
---|
11 | */ |
---|
12 | package gov.noaa.pmel.sgt.swing.prop; |
---|
13 | |
---|
14 | import gov.noaa.pmel.sgt.JPane; |
---|
15 | |
---|
16 | import javax.swing.*; |
---|
17 | import java.awt.*; |
---|
18 | import java.util.StringTokenizer; |
---|
19 | |
---|
20 | import gov.noaa.pmel.sgt.VectorAttribute; |
---|
21 | import gov.noaa.pmel.sgt.swing.PlotMarkIcon; |
---|
22 | import gov.noaa.pmel.swing.ThreeDotsButton; |
---|
23 | import javax.swing.border.*; |
---|
24 | import java.awt.event.*; |
---|
25 | |
---|
26 | /** |
---|
27 | * Edits a <code>VectorAttribute</code>. This dialog does not |
---|
28 | * make a copy of the attribute so changes "Applied" will cause |
---|
29 | * <code>sgt</code> to redraw the plot using the new properties unless |
---|
30 | * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} |
---|
31 | * has been turned on. |
---|
32 | * |
---|
33 | * <p> Example of <code>VectorAttributeDialog</code> use: |
---|
34 | * <pre> |
---|
35 | * public void editVectorAttribute(VectorAttribute attr) { |
---|
36 | * VectorAttributeDialog lad = new VectorAttributeDialog(); |
---|
37 | * lad.setVectorAttribute(attr); |
---|
38 | * lad.setVisible(true); |
---|
39 | * } |
---|
40 | * </pre> |
---|
41 | * * |
---|
42 | * @author Donald Denbo |
---|
43 | * @version $Revision: 1.7 $, $Date: 2003/08/22 23:02:40 $ |
---|
44 | * @since 2.1 |
---|
45 | * @see PlotMarkDialog |
---|
46 | * @see ArrayEditDialog |
---|
47 | */ |
---|
48 | public class VectorAttributeDialog extends JDialog { |
---|
49 | private VectorAttribute attr_; |
---|
50 | private PlotMarkIcon pmIcon_; |
---|
51 | private int mark_; |
---|
52 | private JPane[] paneList_ = null; |
---|
53 | /** |
---|
54 | * Constructor. |
---|
55 | */ |
---|
56 | public VectorAttributeDialog(Frame parent) { |
---|
57 | super(parent); |
---|
58 | try { |
---|
59 | jbInit(); |
---|
60 | pack(); |
---|
61 | } catch(Exception ex) { |
---|
62 | ex.printStackTrace(); |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|
66 | void jbInit() throws Exception { |
---|
67 | // |
---|
68 | pmIcon_ = new PlotMarkIcon(1); |
---|
69 | { |
---|
70 | String[] tempString = new String[3]; |
---|
71 | tempString[0] = "NO_HEAD"; |
---|
72 | tempString[1] = "HEAD"; |
---|
73 | tempString[2] = "SCALED_HEAD"; |
---|
74 | for(int i=0; i < tempString.length; i++) { |
---|
75 | vectorStyleCBM.addElement(tempString[i]); |
---|
76 | } |
---|
77 | } |
---|
78 | { |
---|
79 | String[] tempString = new String[2]; |
---|
80 | tempString[0] = "NO_MARK"; |
---|
81 | tempString[1] = "MARK"; |
---|
82 | for(int i=0; i < tempString.length; i++) { |
---|
83 | originStyleCBM.addElement(tempString[i]); |
---|
84 | } |
---|
85 | } |
---|
86 | { |
---|
87 | String[] tempString = new String[3]; |
---|
88 | tempString[0] = "BUTT"; |
---|
89 | tempString[1] = "ROUND"; |
---|
90 | tempString[2] = "SQUARE"; |
---|
91 | for(int i=0; i < tempString.length; i++) { |
---|
92 | capStyleCBM.addElement(tempString[i]); |
---|
93 | } |
---|
94 | } |
---|
95 | { |
---|
96 | String[] tempString = new String[3]; |
---|
97 | tempString[0] = "MITER"; |
---|
98 | tempString[1] = "ROUND"; |
---|
99 | tempString[2] = "BEVEL"; |
---|
100 | for(int i=0; i < tempString.length; i++) { |
---|
101 | miterStyleCBM.addElement(tempString[i]); |
---|
102 | } |
---|
103 | } |
---|
104 | getContentPane().setLayout(new BorderLayout(0,0)); |
---|
105 | setSize(500,490); |
---|
106 | setVisible(false); |
---|
107 | buttonPanel.setBorder(etchedBorder1); |
---|
108 | buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
---|
109 | vectorMaxSizeTextField.setColumns(8); |
---|
110 | vectorScaleTextField.setColumns(8); |
---|
111 | JLabel5.setText("Style:"); |
---|
112 | colorPanel.setBorder(etchedBorder1); |
---|
113 | colorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
---|
114 | JLabel1.setText("Color:"); |
---|
115 | offsetAngleTextField.setColumns(8); |
---|
116 | vectorStyleComboBox.setModel(vectorStyleCBM); |
---|
117 | vectorStyleComboBox.addActionListener(new VectorAttributeDialog_vectorStyleComboBox_actionAdapter(this)); |
---|
118 | jLabel7.setText("Offset Angle:"); |
---|
119 | jLabel6.setText("Max Size:"); |
---|
120 | jLabel5.setText("Scale:"); |
---|
121 | vectorPanel.setLayout(gridBagLayout2); |
---|
122 | jLabel11.setText("Fixed Size:"); |
---|
123 | jLabel10.setText("Max Size:"); |
---|
124 | headMinSizeTextField.setColumns(8); |
---|
125 | jLabel9.setText("Min Size:"); |
---|
126 | jLabel8.setText("Scale:"); |
---|
127 | headScaleTextField.setColumns(8); |
---|
128 | headMaxSizeTextField.setColumns(8); |
---|
129 | headFixedSizeTextField.setColumns(8); |
---|
130 | headPanel.setLayout(gridBagLayout4); |
---|
131 | markHeightTextField.setColumns(8); |
---|
132 | originStyleComboBox.setModel(originStyleCBM); |
---|
133 | JLabel12.setText("Color:"); |
---|
134 | JLabel7.setText("Mark Height:"); |
---|
135 | JLabel6.setText("Mark:"); |
---|
136 | markPanel.setLayout(new GridBagLayout()); |
---|
137 | markEditor.addActionListener(new VectorAttributeDialog_markEditor_actionAdapter(this)); |
---|
138 | markEditor.setActionCommand("..."); |
---|
139 | // markEditor.setMargin(new Insets(0, 0, 0, 0)); |
---|
140 | markColorPanel.setBorder(etchedBorder1); |
---|
141 | Mark.setLayout(gridBagLayout3); |
---|
142 | jLabel4.setText("Style:"); |
---|
143 | plotMarkIconLabel.setForeground(java.awt.Color.black); |
---|
144 | plotMarkIconLabel.setIcon(pmIcon_); |
---|
145 | miterLimitTextField.setColumns(8); |
---|
146 | JLabel10.setText(" Width:"); |
---|
147 | strokePanel.setLayout(gridBagLayout1); |
---|
148 | miterStyleComboBox.setModel(miterStyleCBM); |
---|
149 | jLabel3.setText("Miter Limit:"); |
---|
150 | jLabel2.setText("Miter Style:"); |
---|
151 | jLabel1.setText("Cap Style:"); |
---|
152 | capStyleComboBox.setModel(capStyleCBM); |
---|
153 | widthTextField.setColumns(8); |
---|
154 | getContentPane().add(buttonPanel, "South"); |
---|
155 | buttonPanel.setBounds(0,263,430,39); |
---|
156 | okButton.setText("OK"); |
---|
157 | okButton.setActionCommand("OK"); |
---|
158 | buttonPanel.add(okButton); |
---|
159 | okButton.setBounds(115,7,51,25); |
---|
160 | applyButton.setText("Apply"); |
---|
161 | applyButton.setActionCommand("Apply"); |
---|
162 | buttonPanel.add(applyButton); |
---|
163 | applyButton.setBounds(171,7,65,25); |
---|
164 | cancelButton.setText("Cancel"); |
---|
165 | cancelButton.setActionCommand("Cancel"); |
---|
166 | buttonPanel.add(cancelButton); |
---|
167 | cancelButton.setBounds(241,7,73,25); |
---|
168 | //$$ etchedBorder1.move(0,300); |
---|
169 | this.getContentPane().add(jTabbedPane1, BorderLayout.CENTER); |
---|
170 | jTabbedPane1.add(vectorPanel, "Vector"); |
---|
171 | vectorPanel.add(vectorStyleComboBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 |
---|
172 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 5, 5, 5), 0, 0)); |
---|
173 | vectorPanel.add(colorPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 |
---|
174 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 15), 0, 0)); |
---|
175 | vectorPanel.add(JLabel1, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 |
---|
176 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
177 | vectorPanel.add(jLabel5, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 |
---|
178 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 6, 0, 6), 0, 0)); |
---|
179 | vectorPanel.add(jLabel6, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 |
---|
180 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
181 | vectorPanel.add(jLabel7, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 |
---|
182 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 15, 10, 5), 0, 0)); |
---|
183 | vectorPanel.add(vectorScaleTextField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 |
---|
184 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); |
---|
185 | vectorPanel.add(vectorMaxSizeTextField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 |
---|
186 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); |
---|
187 | vectorPanel.add(offsetAngleTextField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 |
---|
188 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 15, 5), 0, 0)); |
---|
189 | vectorPanel.add(JLabel5, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 |
---|
190 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 5, 0, 5), 0, 0)); |
---|
191 | jTabbedPane1.add(headPanel, "Head"); |
---|
192 | headPanel.add(jLabel8, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 |
---|
193 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
194 | headPanel.add(headScaleTextField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 |
---|
195 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); |
---|
196 | headPanel.add(jLabel9, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 |
---|
197 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
198 | headPanel.add(jLabel10, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 |
---|
199 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
200 | headPanel.add(headMinSizeTextField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 |
---|
201 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); |
---|
202 | headPanel.add(headMaxSizeTextField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 |
---|
203 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); |
---|
204 | headPanel.add(jLabel11, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 |
---|
205 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
206 | headPanel.add(headFixedSizeTextField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 |
---|
207 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); |
---|
208 | jTabbedPane1.add(Mark, "Mark"); |
---|
209 | Mark.add(markPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 |
---|
210 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); |
---|
211 | markPanel.add(plotMarkIconLabel, new GridBagConstraints(0,0,1,1,0.0,0.0, |
---|
212 | GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,5),0,0)); |
---|
213 | markPanel.add(markEditor, new GridBagConstraints(2,0,1,1,0.0,1.0, |
---|
214 | GridBagConstraints.CENTER,GridBagConstraints.VERTICAL,new Insets(0,0,0,0),0,0)); |
---|
215 | Mark.add(JLabel6, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 |
---|
216 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
217 | Mark.add(JLabel7, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 |
---|
218 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 15, 10, 5), 0, 0)); |
---|
219 | Mark.add(markHeightTextField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 |
---|
220 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 15, 5), 0, 0)); |
---|
221 | Mark.add(markColorPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 |
---|
222 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 15), 0, 0)); |
---|
223 | Mark.add(JLabel12, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 |
---|
224 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
225 | Mark.add(jLabel4, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 |
---|
226 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 5, 0, 5), 0, 0)); |
---|
227 | Mark.add(originStyleComboBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 |
---|
228 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 5, 5, 5), 0, 0)); |
---|
229 | jTabbedPane1.add(strokePanel, "Line Style"); |
---|
230 | strokePanel.add(JLabel10, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 |
---|
231 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
232 | strokePanel.add(widthTextField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 |
---|
233 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
234 | strokePanel.add(jLabel1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 |
---|
235 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
236 | strokePanel.add(jLabel2, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 |
---|
237 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
238 | strokePanel.add(capStyleComboBox, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 |
---|
239 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
240 | strokePanel.add(miterStyleComboBox, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 |
---|
241 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
242 | strokePanel.add(jLabel3, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 |
---|
243 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
244 | strokePanel.add(miterLimitTextField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 |
---|
245 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
246 | //$$ stringComboBoxModel1.move(24,300); |
---|
247 | setTitle("VectorAttribute Properties"); |
---|
248 | |
---|
249 | SymWindow aSymWindow = new SymWindow(); |
---|
250 | this.addWindowListener(aSymWindow); |
---|
251 | SymAction lSymAction = new SymAction(); |
---|
252 | cancelButton.addActionListener(lSymAction); |
---|
253 | okButton.addActionListener(lSymAction); |
---|
254 | applyButton.addActionListener(lSymAction); |
---|
255 | } |
---|
256 | |
---|
257 | /** Used internally */ |
---|
258 | public void addNotify() { |
---|
259 | // Record the size of the window prior to calling parents addNotify. |
---|
260 | Dimension d = getSize(); |
---|
261 | |
---|
262 | super.addNotify(); |
---|
263 | |
---|
264 | if (fComponentsAdjusted) |
---|
265 | return; |
---|
266 | |
---|
267 | // Adjust components according to the insets |
---|
268 | Insets ins = getInsets(); |
---|
269 | setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); |
---|
270 | Component components[] = getContentPane().getComponents(); |
---|
271 | for (int i = 0; i < components.length; i++) { |
---|
272 | Point p = components[i].getLocation(); |
---|
273 | p.translate(ins.left, ins.top); |
---|
274 | components[i].setLocation(p); |
---|
275 | } |
---|
276 | fComponentsAdjusted = true; |
---|
277 | } |
---|
278 | |
---|
279 | // Used for addNotify check. |
---|
280 | boolean fComponentsAdjusted = false; |
---|
281 | /** |
---|
282 | * Constructor. |
---|
283 | */ |
---|
284 | public VectorAttributeDialog(String title) { |
---|
285 | this(); |
---|
286 | setTitle(title); |
---|
287 | } |
---|
288 | /** |
---|
289 | * Default constructor. |
---|
290 | */ |
---|
291 | public VectorAttributeDialog() { |
---|
292 | this((Frame)null); |
---|
293 | } |
---|
294 | /** |
---|
295 | * Make the dialog visible |
---|
296 | */ |
---|
297 | public void setVisible(boolean b) { |
---|
298 | if(b) { |
---|
299 | setLocation(50, 50); |
---|
300 | } |
---|
301 | super.setVisible(b); |
---|
302 | } |
---|
303 | |
---|
304 | class SymWindow extends java.awt.event.WindowAdapter { |
---|
305 | public void windowClosing(java.awt.event.WindowEvent event) { |
---|
306 | Object object = event.getSource(); |
---|
307 | if (object == VectorAttributeDialog.this) |
---|
308 | VectorAttributeDialog_WindowClosing(event); |
---|
309 | } |
---|
310 | } |
---|
311 | |
---|
312 | void VectorAttributeDialog_WindowClosing(java.awt.event.WindowEvent event) { |
---|
313 | dispose(); |
---|
314 | } |
---|
315 | |
---|
316 | javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); |
---|
317 | javax.swing.JButton okButton = new javax.swing.JButton(); |
---|
318 | javax.swing.JButton applyButton = new javax.swing.JButton(); |
---|
319 | javax.swing.JButton cancelButton = new javax.swing.JButton(); |
---|
320 | javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); |
---|
321 | DefaultComboBoxModel vectorStyleCBM = new DefaultComboBoxModel(); |
---|
322 | DefaultComboBoxModel originStyleCBM = new DefaultComboBoxModel(); |
---|
323 | DefaultComboBoxModel capStyleCBM = new DefaultComboBoxModel(); |
---|
324 | DefaultComboBoxModel miterStyleCBM = new DefaultComboBoxModel(); |
---|
325 | JTabbedPane jTabbedPane1 = new JTabbedPane(); |
---|
326 | JTextField vectorMaxSizeTextField = new JTextField(); |
---|
327 | GridBagLayout gridBagLayout2 = new GridBagLayout(); |
---|
328 | JTextField vectorScaleTextField = new JTextField(); |
---|
329 | JLabel JLabel5 = new javax.swing.JLabel(); |
---|
330 | ColorEntryPanel colorPanel = new ColorEntryPanel(); |
---|
331 | JLabel JLabel1 = new javax.swing.JLabel(); |
---|
332 | JTextField offsetAngleTextField = new JTextField(); |
---|
333 | JComboBox vectorStyleComboBox = new javax.swing.JComboBox(); |
---|
334 | JLabel jLabel7 = new JLabel(); |
---|
335 | JLabel jLabel6 = new JLabel(); |
---|
336 | JLabel jLabel5 = new JLabel(); |
---|
337 | JPanel vectorPanel = new JPanel(); |
---|
338 | JLabel jLabel11 = new JLabel(); |
---|
339 | JLabel jLabel10 = new JLabel(); |
---|
340 | GridBagLayout gridBagLayout4 = new GridBagLayout(); |
---|
341 | JTextField headMinSizeTextField = new JTextField(); |
---|
342 | JLabel jLabel9 = new JLabel(); |
---|
343 | JLabel jLabel8 = new JLabel(); |
---|
344 | JTextField headScaleTextField = new JTextField(); |
---|
345 | JTextField headMaxSizeTextField = new JTextField(); |
---|
346 | JTextField headFixedSizeTextField = new JTextField(); |
---|
347 | JPanel headPanel = new JPanel(); |
---|
348 | JTextField markHeightTextField = new javax.swing.JTextField(); |
---|
349 | GridBagLayout gridBagLayout3 = new GridBagLayout(); |
---|
350 | JComboBox originStyleComboBox = new JComboBox(); |
---|
351 | JLabel JLabel12 = new javax.swing.JLabel(); |
---|
352 | JLabel JLabel7 = new javax.swing.JLabel(); |
---|
353 | JLabel JLabel6 = new javax.swing.JLabel(); |
---|
354 | JPanel markPanel = new javax.swing.JPanel(); |
---|
355 | ThreeDotsButton markEditor = new ThreeDotsButton(); |
---|
356 | ColorEntryPanel markColorPanel = new ColorEntryPanel(); |
---|
357 | JPanel Mark = new JPanel(); |
---|
358 | JLabel jLabel4 = new JLabel(); |
---|
359 | JLabel plotMarkIconLabel = new javax.swing.JLabel(); |
---|
360 | GridBagLayout gridBagLayout1 = new GridBagLayout(); |
---|
361 | JTextField miterLimitTextField = new JTextField(); |
---|
362 | JLabel JLabel10 = new javax.swing.JLabel(); |
---|
363 | JPanel strokePanel = new JPanel(); |
---|
364 | JComboBox miterStyleComboBox = new JComboBox(); |
---|
365 | JLabel jLabel3 = new JLabel(); |
---|
366 | JLabel jLabel2 = new JLabel(); |
---|
367 | JLabel jLabel1 = new JLabel(); |
---|
368 | JComboBox capStyleComboBox = new JComboBox(); |
---|
369 | JTextField widthTextField = new javax.swing.JTextField(); |
---|
370 | |
---|
371 | |
---|
372 | class SymAction implements java.awt.event.ActionListener { |
---|
373 | public void actionPerformed(java.awt.event.ActionEvent event) { |
---|
374 | Object object = event.getSource(); |
---|
375 | if (object == cancelButton) |
---|
376 | cancelButton_actionPerformed(event); |
---|
377 | else if (object == okButton) |
---|
378 | okButton_actionPerformed(event); |
---|
379 | else if (object == applyButton) |
---|
380 | applyButton_actionPerformed(event); |
---|
381 | else if (object == markEditor) |
---|
382 | markEditor_actionPerformed(event); |
---|
383 | } |
---|
384 | } |
---|
385 | |
---|
386 | void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { |
---|
387 | this.setVisible(false); |
---|
388 | } |
---|
389 | |
---|
390 | void okButton_actionPerformed(java.awt.event.ActionEvent event) { |
---|
391 | updateVectorAttribute(); |
---|
392 | this.setVisible(false); |
---|
393 | } |
---|
394 | |
---|
395 | void applyButton_actionPerformed(java.awt.event.ActionEvent event) { |
---|
396 | updateVectorAttribute(); |
---|
397 | } |
---|
398 | /** |
---|
399 | * Set the <code>VectorAttribute</code> for the dialog. |
---|
400 | */ |
---|
401 | public void setVectorAttribute(VectorAttribute attr) { |
---|
402 | attr_ = attr; |
---|
403 | // |
---|
404 | // Vector |
---|
405 | // |
---|
406 | // Color |
---|
407 | // |
---|
408 | colorPanel.setColor(attr_.getVectorColor()); |
---|
409 | // |
---|
410 | // style |
---|
411 | // |
---|
412 | vectorStyleComboBox.setSelectedIndex(attr_.getVectorStyle()); |
---|
413 | vectorStyle(attr_.getVectorStyle()); |
---|
414 | // |
---|
415 | // vectorScale |
---|
416 | // |
---|
417 | vectorScaleTextField.setText(Double.toString(attr_.getVectorScale())); |
---|
418 | // |
---|
419 | // vector max size |
---|
420 | // |
---|
421 | vectorMaxSizeTextField.setText(Double.toString(attr_.getVectorMaxSize())); |
---|
422 | // |
---|
423 | // offset angle |
---|
424 | // |
---|
425 | offsetAngleTextField.setText(Double.toString(attr_.getOffsetAngle())); |
---|
426 | // |
---|
427 | // head |
---|
428 | // |
---|
429 | // |
---|
430 | // scale |
---|
431 | // |
---|
432 | headScaleTextField.setText(Double.toString(attr_.getHeadScale())); |
---|
433 | // |
---|
434 | // head max size |
---|
435 | // |
---|
436 | headMaxSizeTextField.setText(Double.toString(attr_.getHeadMaxSize())); |
---|
437 | // |
---|
438 | // head min size |
---|
439 | // |
---|
440 | headMinSizeTextField.setText(Double.toString(attr_.getHeadMinSize())); |
---|
441 | // |
---|
442 | // head fixed size |
---|
443 | // |
---|
444 | headFixedSizeTextField.setText(Double.toString(attr_.getHeadFixedSize())); |
---|
445 | // |
---|
446 | // origin |
---|
447 | // |
---|
448 | // style |
---|
449 | // |
---|
450 | originStyleComboBox.setSelectedIndex(attr_.getOriginStyle()); |
---|
451 | // |
---|
452 | // mark |
---|
453 | // |
---|
454 | int mark = attr_.getMark(); |
---|
455 | changeMark(mark); |
---|
456 | // System.out.println(" mark code = " + mark); |
---|
457 | // |
---|
458 | // Color |
---|
459 | // |
---|
460 | markColorPanel.setColor(attr_.getMarkColor()); |
---|
461 | // |
---|
462 | // mark height |
---|
463 | // |
---|
464 | markHeightTextField.setText(Double.toString(attr_.getMarkHeightP())); |
---|
465 | // |
---|
466 | // Stroke line attributes |
---|
467 | // |
---|
468 | // width |
---|
469 | // |
---|
470 | widthTextField.setText(Float.toString(attr_.getWidth())); |
---|
471 | // |
---|
472 | // cap style |
---|
473 | // |
---|
474 | capStyleComboBox.setSelectedIndex(attr_.getCapStyle()); |
---|
475 | // |
---|
476 | // miter style |
---|
477 | // |
---|
478 | miterStyleComboBox.setSelectedIndex(attr_.getMiterStyle()); |
---|
479 | // |
---|
480 | // miter limit |
---|
481 | // |
---|
482 | miterLimitTextField.setText(Float.toString(attr_.getMiterLimit())); |
---|
483 | } |
---|
484 | |
---|
485 | void updateVectorAttribute() { |
---|
486 | if(paneList_ != null) { |
---|
487 | for(int i=0; i < paneList_.length; i++) { |
---|
488 | paneList_[i].setBatch(true, "VectorAttributeDialog"); |
---|
489 | } |
---|
490 | } |
---|
491 | attr_.setBatch(true); |
---|
492 | // |
---|
493 | // Vector |
---|
494 | // |
---|
495 | // |
---|
496 | // Color |
---|
497 | // |
---|
498 | attr_.setVectorColor(colorPanel.getColor()); |
---|
499 | // |
---|
500 | // style |
---|
501 | // |
---|
502 | attr_.setVectorStyle(vectorStyleComboBox.getSelectedIndex()); |
---|
503 | // |
---|
504 | // vectorScale |
---|
505 | // |
---|
506 | attr_.setVectorScale(Double.parseDouble(vectorScaleTextField.getText())); |
---|
507 | // |
---|
508 | // vector max size |
---|
509 | // |
---|
510 | attr_.setVectorMaxSize(Double.parseDouble(vectorMaxSizeTextField.getText())); |
---|
511 | // |
---|
512 | // offset angle |
---|
513 | // |
---|
514 | attr_.setOffsetAngle(Double.parseDouble(offsetAngleTextField.getText())); |
---|
515 | // |
---|
516 | // head |
---|
517 | // |
---|
518 | // |
---|
519 | // scale |
---|
520 | // |
---|
521 | attr_.setHeadScale(Double.parseDouble(headScaleTextField.getText())); |
---|
522 | // |
---|
523 | // max head size |
---|
524 | // |
---|
525 | attr_.setHeadMaxSize(Double.parseDouble(headMaxSizeTextField.getText())); |
---|
526 | // |
---|
527 | // head min size |
---|
528 | // |
---|
529 | attr_.setHeadMinSize(Double.parseDouble(headMinSizeTextField.getText())); |
---|
530 | // |
---|
531 | // head fixed size |
---|
532 | // |
---|
533 | attr_.setHeadFixedSize(Double.parseDouble(headFixedSizeTextField.getText())); |
---|
534 | // |
---|
535 | // origin |
---|
536 | // |
---|
537 | // style |
---|
538 | // |
---|
539 | attr_.setOriginStyle(originStyleComboBox.getSelectedIndex()); |
---|
540 | // |
---|
541 | // mark |
---|
542 | // |
---|
543 | attr_.setMark(mark_); |
---|
544 | // |
---|
545 | // color |
---|
546 | // |
---|
547 | attr_.setMarkColor(markColorPanel.getColor()); |
---|
548 | // |
---|
549 | // mark height |
---|
550 | // |
---|
551 | attr_.setMarkHeightP(new Double(markHeightTextField.getText()).doubleValue()); |
---|
552 | // |
---|
553 | // stroke attributes |
---|
554 | // |
---|
555 | // |
---|
556 | // width |
---|
557 | // |
---|
558 | attr_.setWidth(new Float(widthTextField.getText()).floatValue()); |
---|
559 | // |
---|
560 | // cap style |
---|
561 | // |
---|
562 | attr_.setCapStyle(capStyleComboBox.getSelectedIndex()); |
---|
563 | // |
---|
564 | // miter style |
---|
565 | // |
---|
566 | attr_.setMiterStyle(miterStyleComboBox.getSelectedIndex()); |
---|
567 | // |
---|
568 | // miter limit |
---|
569 | // |
---|
570 | attr_.setMiterLimit(new Float(miterLimitTextField.getText()).floatValue()); |
---|
571 | |
---|
572 | attr_.setBatch(false); |
---|
573 | // |
---|
574 | if(paneList_ != null) { |
---|
575 | for(int i=0; i < paneList_.length; i++) { |
---|
576 | paneList_[i].setBatch(false, "VectorAttributeDialog"); |
---|
577 | } |
---|
578 | } |
---|
579 | } |
---|
580 | |
---|
581 | private void vectorStyle(int style) { |
---|
582 | switch(style) { |
---|
583 | case VectorAttribute.NO_HEAD: |
---|
584 | headScaleTextField.setEnabled(false); |
---|
585 | headMinSizeTextField.setEnabled(false); |
---|
586 | headMaxSizeTextField.setEnabled(false); |
---|
587 | headFixedSizeTextField.setEnabled(false); |
---|
588 | break; |
---|
589 | case VectorAttribute.HEAD: |
---|
590 | headScaleTextField.setEnabled(false); |
---|
591 | headMinSizeTextField.setEnabled(false); |
---|
592 | headMaxSizeTextField.setEnabled(false); |
---|
593 | headFixedSizeTextField.setEnabled(true); |
---|
594 | break; |
---|
595 | case VectorAttribute.SCALED_HEAD: |
---|
596 | headScaleTextField.setEnabled(true); |
---|
597 | headMinSizeTextField.setEnabled(true); |
---|
598 | headMaxSizeTextField.setEnabled(true); |
---|
599 | headFixedSizeTextField.setEnabled(false); |
---|
600 | } |
---|
601 | } |
---|
602 | /** |
---|
603 | * Dialog test entry. |
---|
604 | */ |
---|
605 | public static void main(String[] args) { |
---|
606 | VectorAttribute attr = new VectorAttribute(); |
---|
607 | VectorAttributeDialog la = new VectorAttributeDialog(); |
---|
608 | la.setVectorAttribute(attr); |
---|
609 | la.setTitle("Test VectorAttribute Dialog"); |
---|
610 | la.setVisible(true); |
---|
611 | } |
---|
612 | |
---|
613 | void markEditor_actionPerformed(java.awt.event.ActionEvent event) { |
---|
614 | PlotMarkDialog pmd = new PlotMarkDialog(); |
---|
615 | Point loc = markEditor.getLocationOnScreen(); |
---|
616 | pmd.setLocation(loc.x, loc.y); |
---|
617 | int result = pmd.showDialog(mark_); |
---|
618 | if(result == PlotMarkDialog.OK_RESPONSE) { |
---|
619 | changeMark(pmd.getMark()); |
---|
620 | } |
---|
621 | } |
---|
622 | |
---|
623 | private void changeMark(int mark) { |
---|
624 | mark_ = mark; |
---|
625 | pmIcon_.setMark(mark); |
---|
626 | plotMarkIconLabel.repaint(); |
---|
627 | } |
---|
628 | /** |
---|
629 | * Set the parent <code>JPane</code>. This reference to |
---|
630 | * <code>JPane</code> is used to enable/disable |
---|
631 | * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} so |
---|
632 | * multiple property changes are made at one time. |
---|
633 | */ |
---|
634 | public void setJPane(JPane pane) { |
---|
635 | paneList_ = new JPane[1]; |
---|
636 | paneList_[0] = pane; |
---|
637 | } |
---|
638 | /** Get the first parent pane. */ |
---|
639 | public JPane getJPane() { |
---|
640 | if(paneList_ != null) { |
---|
641 | return paneList_[0]; |
---|
642 | } else { |
---|
643 | return null; |
---|
644 | } |
---|
645 | } |
---|
646 | /** |
---|
647 | * Set the parent <code>JPane</code>s. These references to |
---|
648 | * <code>JPane</code> are used to enable/disable |
---|
649 | * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} so |
---|
650 | * multiple property changes are made at one time. A second |
---|
651 | * <code>JPane</code> is often used for a <code>VectorKey</code>. |
---|
652 | */ |
---|
653 | public void setJPaneList(JPane[] list) { |
---|
654 | paneList_ = list; |
---|
655 | } |
---|
656 | /** Get an array of parent panes. */ |
---|
657 | public JPane[] getJPaneList() { |
---|
658 | return paneList_; |
---|
659 | } |
---|
660 | |
---|
661 | void vectorStyleComboBox_actionPerformed(ActionEvent e) { |
---|
662 | int style = vectorStyleComboBox.getSelectedIndex(); |
---|
663 | vectorStyle(style); |
---|
664 | } |
---|
665 | } |
---|
666 | |
---|
667 | class VectorAttributeDialog_vectorStyleComboBox_actionAdapter implements java.awt.event.ActionListener { |
---|
668 | VectorAttributeDialog adaptee; |
---|
669 | |
---|
670 | VectorAttributeDialog_vectorStyleComboBox_actionAdapter(VectorAttributeDialog adaptee) { |
---|
671 | this.adaptee = adaptee; |
---|
672 | } |
---|
673 | public void actionPerformed(ActionEvent e) { |
---|
674 | adaptee.vectorStyleComboBox_actionPerformed(e); |
---|
675 | } |
---|
676 | } |
---|
677 | |
---|
678 | class VectorAttributeDialog_markEditor_actionAdapter implements java.awt.event.ActionListener { |
---|
679 | VectorAttributeDialog adaptee; |
---|
680 | |
---|
681 | VectorAttributeDialog_markEditor_actionAdapter(VectorAttributeDialog adaptee) { |
---|
682 | this.adaptee = adaptee; |
---|
683 | } |
---|
684 | public void actionPerformed(ActionEvent e) { |
---|
685 | adaptee.markEditor_actionPerformed(e); |
---|
686 | } |
---|
687 | } |
---|