1 | /* |
---|
2 | * $Id: PointAttributeDialog.java,v 1.7 2003/08/22 23:02:39 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 javax.swing.*; |
---|
15 | import java.awt.*; |
---|
16 | import java.util.StringTokenizer; |
---|
17 | |
---|
18 | |
---|
19 | import gov.noaa.pmel.sgt.PointAttribute; |
---|
20 | import gov.noaa.pmel.sgt.JPane; |
---|
21 | import gov.noaa.pmel.sgt.swing.PlotMarkIcon; |
---|
22 | import gov.noaa.pmel.swing.ThreeDotsButton; |
---|
23 | |
---|
24 | /** |
---|
25 | * Edits a <code>PointAttribute</code>. This dialog does not |
---|
26 | * make a copy of the attribute so changes "Applied" will cause |
---|
27 | * <code>sgt</code> to redraw the plot using the new properties unless |
---|
28 | * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} |
---|
29 | * has been turned on. |
---|
30 | * |
---|
31 | * <p> Example of <code>PointAttributeDialog</code> use: |
---|
32 | * <pre> |
---|
33 | * public void editPointAttribute(PointAttribute attr, JPane pane) { |
---|
34 | * PointAttributeDialog pad = new PointAttributeDialog(); |
---|
35 | * pad.setPointAttribute(attr, pane); |
---|
36 | * pad.setVisible(true); |
---|
37 | * } |
---|
38 | * </pre> |
---|
39 | * |
---|
40 | * @author Donald Denbo |
---|
41 | * @version $Revision: 1.7 $, $Date: 2003/08/22 23:02:39 $ |
---|
42 | * @since 2.0 |
---|
43 | */ |
---|
44 | public class PointAttributeDialog extends JDialog { |
---|
45 | private JPane pane_ = null; |
---|
46 | private JPane[] paneList_ = null; |
---|
47 | private PointAttribute attr_; |
---|
48 | private PlotMarkIcon pmIcon_; |
---|
49 | private int mark_; |
---|
50 | private Font labelFont_; |
---|
51 | private String[] styleNames_ = {"plain", "bold", "italic", "bold-italic"}; |
---|
52 | /** |
---|
53 | * Constructor. |
---|
54 | */ |
---|
55 | public PointAttributeDialog(Frame parent) { |
---|
56 | super(parent); |
---|
57 | try { |
---|
58 | jbInit(); |
---|
59 | pack(); |
---|
60 | } catch(Exception ex) { |
---|
61 | ex.printStackTrace(); |
---|
62 | } |
---|
63 | } |
---|
64 | void jbInit() throws Exception { |
---|
65 | getContentPane().setLayout(new BorderLayout(0,0)); |
---|
66 | setSize(new Dimension(504, 320)); |
---|
67 | setVisible(false); |
---|
68 | buttonPanel.setBorder(etchedBorder1); |
---|
69 | buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
---|
70 | getContentPane().add(buttonPanel, "South"); |
---|
71 | okButton.setText("OK"); |
---|
72 | okButton.setActionCommand("OK"); |
---|
73 | buttonPanel.add(okButton); |
---|
74 | applyButton.setText("Apply"); |
---|
75 | applyButton.setActionCommand("Apply"); |
---|
76 | buttonPanel.add(applyButton); |
---|
77 | cancelButton.setText("Cancel"); |
---|
78 | cancelButton.setActionCommand("Cancel"); |
---|
79 | buttonPanel.add(cancelButton); |
---|
80 | //$$ etchedBorder1.move(0,372); |
---|
81 | getContentPane().add(JTabbedPane1, "Center"); |
---|
82 | markAttrPanel.setLayout(new GridBagLayout()); |
---|
83 | JTabbedPane1.add(markAttrPanel, "markAttrPanel"); |
---|
84 | JLabel1.setText("Color:"); |
---|
85 | markAttrPanel.add(JLabel1, new GridBagConstraints(0,0,1,1,0.0,0.0, |
---|
86 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
87 | colorPanel.setBorder(etchedBorder1); |
---|
88 | markAttrPanel.add(colorPanel, new GridBagConstraints(1,0,1,1,0.0,0.0, |
---|
89 | GridBagConstraints.WEST,GridBagConstraints.BOTH,new Insets(0,5,10,5),0,0)); |
---|
90 | JLabel6.setText("Mark:"); |
---|
91 | markAttrPanel.add(JLabel6, new GridBagConstraints(0,1,1,1,0.0,0.0,GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
92 | markPanel.setLayout(new GridBagLayout()); |
---|
93 | markAttrPanel.add(markPanel, new GridBagConstraints(1,1,1,1,0.0,0.0, |
---|
94 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,10,5),0,0)); |
---|
95 | markPanel.add(plotMarkIconLabel, new GridBagConstraints(0,0,1,1,0.0,0.0, |
---|
96 | GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,5),0,0)); |
---|
97 | plotMarkIconLabel.setForeground(java.awt.Color.black); |
---|
98 | markEditor.setActionCommand("..."); |
---|
99 | markPanel.add(markEditor, new GridBagConstraints(2,0,1,1,0.0,1.0, |
---|
100 | GridBagConstraints.CENTER,GridBagConstraints.VERTICAL,new Insets(0,0,0,0),0,0)); |
---|
101 | JLabel7.setText("Height:"); |
---|
102 | markAttrPanel.add(JLabel7, new GridBagConstraints(0,2,1,1,0.0,0.0, |
---|
103 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
104 | markHeightTextField.setColumns(10); |
---|
105 | markAttrPanel.add(markHeightTextField, new GridBagConstraints(1,2,1,1,0.0,0.0, |
---|
106 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); |
---|
107 | labelPanel.setLayout(new GridBagLayout()); |
---|
108 | JTabbedPane1.add(labelPanel, "labelPanel"); |
---|
109 | JLabel5.setText("Position:"); |
---|
110 | labelPanel.add(JLabel5, new GridBagConstraints(0,0,1,1,0.0,0.0, |
---|
111 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
112 | positionComboBox.setModel(positionCBModel); |
---|
113 | labelPanel.add(positionComboBox, new GridBagConstraints(1,0,1,1,0.0,0.0, |
---|
114 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); |
---|
115 | JLabel8.setText("Font:"); |
---|
116 | labelPanel.add(JLabel8, new GridBagConstraints(0,1,1,1,0.0,0.0, |
---|
117 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
118 | fontPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
---|
119 | labelPanel.add(fontPanel, new GridBagConstraints(1,1,1,1,0.0,0.0, |
---|
120 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); |
---|
121 | fontLabel.setText("Dialog, 12, Bold"); |
---|
122 | fontPanel.add(fontLabel); |
---|
123 | fontLabel.setForeground(java.awt.Color.black); |
---|
124 | fontEditor.setToolTipText("Edit font."); |
---|
125 | fontEditor.setActionCommand("..."); |
---|
126 | fontPanel.add(fontEditor); |
---|
127 | JLabel9.setText("Color:"); |
---|
128 | labelPanel.add(JLabel9, new GridBagConstraints(0,2,1,1,0.0,0.0, |
---|
129 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
130 | labelColorPanel.setBorder(etchedBorder1); |
---|
131 | labelColorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
---|
132 | labelPanel.add(labelColorPanel, new GridBagConstraints(1,2,1,1,0.0,0.0, |
---|
133 | GridBagConstraints.WEST,GridBagConstraints.BOTH,new Insets(0,5,5,5),0,0)); |
---|
134 | JLabel10.setText("Height:"); |
---|
135 | labelPanel.add(JLabel10, new GridBagConstraints(0,3,1,1,0.0,0.0, |
---|
136 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
137 | labelHeightTextField.setColumns(10); |
---|
138 | labelPanel.add(labelHeightTextField, new GridBagConstraints(1,3,1,1,0.0,0.0, |
---|
139 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); |
---|
140 | JLabel14.setText("Draw Label?"); |
---|
141 | labelPanel.add(JLabel14, new GridBagConstraints(0,4,1,1,0.0,0.0, |
---|
142 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
143 | labelPanel.add(drawLabelCheckBox, new GridBagConstraints(1,4,1,1,0.0,0.0, |
---|
144 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); |
---|
145 | JTabbedPane1.setSelectedIndex(0); |
---|
146 | JTabbedPane1.setTitleAt(0,"Mark"); |
---|
147 | JTabbedPane1.setTitleAt(1,"Label"); |
---|
148 | { |
---|
149 | String[] tempString = new String[9]; |
---|
150 | tempString[0] = "Centered"; |
---|
151 | tempString[1] = "North"; |
---|
152 | tempString[2] = "NorthEast"; |
---|
153 | tempString[3] = "East"; |
---|
154 | tempString[4] = "SouthEast"; |
---|
155 | tempString[5] = "South"; |
---|
156 | tempString[6] = "SouthWest"; |
---|
157 | tempString[7] = "West"; |
---|
158 | tempString[8] = "NorthWest"; |
---|
159 | for(int i=0; i < tempString.length; i++) { |
---|
160 | positionCBModel.addElement(tempString[i]); |
---|
161 | } |
---|
162 | } |
---|
163 | markAttrPanel.setBounds(2,27,425,203); |
---|
164 | labelPanel.setBounds(2,27,425,203); |
---|
165 | positionComboBox.setSelectedIndex(2); |
---|
166 | setTitle("PointAttribute Properties"); |
---|
167 | |
---|
168 | SymWindow aSymWindow = new SymWindow(); |
---|
169 | this.addWindowListener(aSymWindow); |
---|
170 | SymAction lSymAction = new SymAction(); |
---|
171 | cancelButton.addActionListener(lSymAction); |
---|
172 | okButton.addActionListener(lSymAction); |
---|
173 | applyButton.addActionListener(lSymAction); |
---|
174 | markEditor.addActionListener(lSymAction); |
---|
175 | fontEditor.addActionListener(lSymAction); |
---|
176 | // |
---|
177 | pmIcon_ = new PlotMarkIcon(1); |
---|
178 | plotMarkIconLabel.setIcon(pmIcon_); |
---|
179 | } |
---|
180 | /** Used internally */ |
---|
181 | public void addNotify() { |
---|
182 | // Record the size of the window prior to calling parents addNotify. |
---|
183 | Dimension d = getSize(); |
---|
184 | |
---|
185 | super.addNotify(); |
---|
186 | |
---|
187 | if (fComponentsAdjusted) |
---|
188 | return; |
---|
189 | |
---|
190 | // Adjust components according to the insets |
---|
191 | Insets ins = getInsets(); |
---|
192 | setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); |
---|
193 | Component components[] = getContentPane().getComponents(); |
---|
194 | for (int i = 0; i < components.length; i++) { |
---|
195 | Point p = components[i].getLocation(); |
---|
196 | p.translate(ins.left, ins.top); |
---|
197 | components[i].setLocation(p); |
---|
198 | } |
---|
199 | fComponentsAdjusted = true; |
---|
200 | } |
---|
201 | |
---|
202 | // Used for addNotify check. |
---|
203 | boolean fComponentsAdjusted = false; |
---|
204 | /** |
---|
205 | * Constructor |
---|
206 | */ |
---|
207 | public PointAttributeDialog(String title) { |
---|
208 | this(); |
---|
209 | setTitle(title); |
---|
210 | } |
---|
211 | /** |
---|
212 | * Default constructor |
---|
213 | */ |
---|
214 | public PointAttributeDialog() { |
---|
215 | this((Frame)null); |
---|
216 | } |
---|
217 | /** |
---|
218 | * Make the dialog visible |
---|
219 | */ |
---|
220 | public void setVisible(boolean b) { |
---|
221 | if(b) { |
---|
222 | setLocation(50, 50); |
---|
223 | } |
---|
224 | super.setVisible(b); |
---|
225 | } |
---|
226 | |
---|
227 | class SymWindow extends java.awt.event.WindowAdapter { |
---|
228 | public void windowClosing(java.awt.event.WindowEvent event) { |
---|
229 | Object object = event.getSource(); |
---|
230 | if (object == PointAttributeDialog.this) |
---|
231 | PointAttributeDialog_WindowClosing(event); |
---|
232 | } |
---|
233 | } |
---|
234 | |
---|
235 | void PointAttributeDialog_WindowClosing(java.awt.event.WindowEvent event) { |
---|
236 | dispose(); |
---|
237 | } |
---|
238 | |
---|
239 | javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); |
---|
240 | javax.swing.JButton okButton = new javax.swing.JButton(); |
---|
241 | javax.swing.JButton applyButton = new javax.swing.JButton(); |
---|
242 | javax.swing.JButton cancelButton = new javax.swing.JButton(); |
---|
243 | javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); |
---|
244 | javax.swing.JTabbedPane JTabbedPane1 = new javax.swing.JTabbedPane(); |
---|
245 | javax.swing.JPanel markAttrPanel = new javax.swing.JPanel(); |
---|
246 | javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); |
---|
247 | ColorEntryPanel colorPanel = new ColorEntryPanel(); |
---|
248 | javax.swing.JLabel JLabel6 = new javax.swing.JLabel(); |
---|
249 | javax.swing.JPanel markPanel = new javax.swing.JPanel(); |
---|
250 | javax.swing.JLabel plotMarkIconLabel = new javax.swing.JLabel(); |
---|
251 | ThreeDotsButton markEditor = new ThreeDotsButton(); |
---|
252 | javax.swing.JLabel JLabel7 = new javax.swing.JLabel(); |
---|
253 | javax.swing.JTextField markHeightTextField = new javax.swing.JTextField(); |
---|
254 | javax.swing.JPanel labelPanel = new javax.swing.JPanel(); |
---|
255 | javax.swing.JLabel JLabel5 = new javax.swing.JLabel(); |
---|
256 | javax.swing.JComboBox positionComboBox = new javax.swing.JComboBox(); |
---|
257 | javax.swing.JLabel JLabel8 = new javax.swing.JLabel(); |
---|
258 | javax.swing.JPanel fontPanel = new javax.swing.JPanel(); |
---|
259 | javax.swing.JLabel fontLabel = new javax.swing.JLabel(); |
---|
260 | ThreeDotsButton fontEditor = new ThreeDotsButton(); |
---|
261 | javax.swing.JLabel JLabel9 = new javax.swing.JLabel(); |
---|
262 | ColorEntryPanel labelColorPanel = new ColorEntryPanel(); |
---|
263 | javax.swing.JLabel JLabel10 = new javax.swing.JLabel(); |
---|
264 | javax.swing.JTextField labelHeightTextField = new javax.swing.JTextField(); |
---|
265 | javax.swing.JLabel JLabel14 = new javax.swing.JLabel(); |
---|
266 | javax.swing.JCheckBox drawLabelCheckBox = new javax.swing.JCheckBox(); |
---|
267 | DefaultComboBoxModel positionCBModel = new DefaultComboBoxModel(); |
---|
268 | |
---|
269 | |
---|
270 | class SymAction implements java.awt.event.ActionListener { |
---|
271 | public void actionPerformed(java.awt.event.ActionEvent event) { |
---|
272 | Object object = event.getSource(); |
---|
273 | if (object == cancelButton) |
---|
274 | cancelButton_actionPerformed(event); |
---|
275 | else if (object == okButton) |
---|
276 | okButton_actionPerformed(event); |
---|
277 | else if (object == applyButton) |
---|
278 | applyButton_actionPerformed(event); |
---|
279 | else if (object == markEditor) |
---|
280 | markEditor_actionPerformed(event); |
---|
281 | else if (object == fontEditor) |
---|
282 | fontEditor_actionPerformed(event); |
---|
283 | } |
---|
284 | } |
---|
285 | |
---|
286 | void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { |
---|
287 | this.setVisible(false); |
---|
288 | } |
---|
289 | |
---|
290 | void okButton_actionPerformed(java.awt.event.ActionEvent event) { |
---|
291 | updatePointAttribute(); |
---|
292 | this.setVisible(false); |
---|
293 | } |
---|
294 | |
---|
295 | void applyButton_actionPerformed(java.awt.event.ActionEvent event) { |
---|
296 | updatePointAttribute(); |
---|
297 | } |
---|
298 | /** |
---|
299 | * Set the <code>PointAttribute</code> to be edited and the |
---|
300 | * <code>JPane</code>. |
---|
301 | */ |
---|
302 | public void setPointAttribute(PointAttribute attr, JPane pane) { |
---|
303 | pane_ = pane; |
---|
304 | attr_ = attr; |
---|
305 | // |
---|
306 | // Mark attributes |
---|
307 | // |
---|
308 | // Color |
---|
309 | // |
---|
310 | colorPanel.setColor(attr_.getColor()); |
---|
311 | // |
---|
312 | // mark |
---|
313 | // |
---|
314 | int mark = attr_.getMark(); |
---|
315 | changeMark(mark); |
---|
316 | // |
---|
317 | // mark height |
---|
318 | // |
---|
319 | markHeightTextField.setText(Double.toString(attr_.getMarkHeightP())); |
---|
320 | // |
---|
321 | // Label attributes |
---|
322 | // |
---|
323 | // position |
---|
324 | // |
---|
325 | positionComboBox.setSelectedIndex(attr_.getLabelPosition()); |
---|
326 | // |
---|
327 | // font |
---|
328 | // |
---|
329 | labelFont_ = attr_.getLabelFont(); |
---|
330 | if(pane_ != null && labelFont_ == null) labelFont_ = pane_.getComponent().getFont(); |
---|
331 | fontLabel.setText(fontString(labelFont_)); |
---|
332 | // |
---|
333 | // color |
---|
334 | // |
---|
335 | labelColorPanel.setColor(attr_.getLabelColor()); |
---|
336 | // |
---|
337 | // width |
---|
338 | // |
---|
339 | labelHeightTextField.setText(Double.toString(attr_.getLabelHeightP())); |
---|
340 | // |
---|
341 | // draw label? |
---|
342 | // |
---|
343 | drawLabelCheckBox.setSelected(attr_.isDrawLabel()); |
---|
344 | } |
---|
345 | /** |
---|
346 | * Set the parent <code>JPane</code>. This reference to |
---|
347 | * <code>JPane</code> is used to enable/disable |
---|
348 | * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} so |
---|
349 | * multiple property changes are made at one time. |
---|
350 | */ |
---|
351 | public void setJPane(JPane pane) { |
---|
352 | paneList_ = new JPane[1]; |
---|
353 | paneList_[0] = pane; |
---|
354 | } |
---|
355 | /** |
---|
356 | * Get the first parent. |
---|
357 | */ |
---|
358 | public JPane getJPane() { |
---|
359 | if(paneList_ != null) { |
---|
360 | return paneList_[0]; |
---|
361 | } else { |
---|
362 | return null; |
---|
363 | } |
---|
364 | } |
---|
365 | /** |
---|
366 | * Set the parent <code>JPane</code>s. These references to |
---|
367 | * <code>JPane</code> are used to enable/disable |
---|
368 | * {@link gov.noaa.pmel.sgt.JPane#setBatch(boolean) batching} so |
---|
369 | * multiple property changes are made at one time. A second |
---|
370 | * <code>JPane</code> is often used for a <code>PointCollectionKey</code>. |
---|
371 | */ |
---|
372 | public void setJPaneList(JPane[] list) { |
---|
373 | paneList_ = list; |
---|
374 | } |
---|
375 | /** Get an array of parent panes. */ |
---|
376 | public JPane[] getJPaneList() { |
---|
377 | return paneList_; |
---|
378 | } |
---|
379 | |
---|
380 | void updatePointAttribute() { |
---|
381 | if(pane_ != null) pane_.setBatch(true, "PointAttributeDialog"); |
---|
382 | if(paneList_ != null) { |
---|
383 | for(int i=0; i < paneList_.length; i++) { |
---|
384 | paneList_[i].setBatch(true, "PointAttributeDialog"); |
---|
385 | } |
---|
386 | } |
---|
387 | attr_.setBatch(true); |
---|
388 | // |
---|
389 | // mark attributes |
---|
390 | // |
---|
391 | // Color |
---|
392 | // |
---|
393 | attr_.setColor(colorPanel.getColor()); |
---|
394 | // |
---|
395 | // mark |
---|
396 | // |
---|
397 | attr_.setMark(mark_); |
---|
398 | // |
---|
399 | // mark height |
---|
400 | // |
---|
401 | attr_.setMarkHeightP(new Double(markHeightTextField.getText()).doubleValue()); |
---|
402 | // |
---|
403 | // label attributes |
---|
404 | // |
---|
405 | // position |
---|
406 | // |
---|
407 | attr_.setLabelPosition(positionComboBox.getSelectedIndex()); |
---|
408 | // |
---|
409 | // font |
---|
410 | // |
---|
411 | attr_.setLabelFont(labelFont_); |
---|
412 | // |
---|
413 | // color |
---|
414 | // |
---|
415 | attr_.setLabelColor(labelColorPanel.getColor()); |
---|
416 | // |
---|
417 | // height |
---|
418 | // |
---|
419 | attr_.setLabelHeightP(new Double(labelHeightTextField.getText()).doubleValue()); |
---|
420 | // |
---|
421 | // draw label? |
---|
422 | // |
---|
423 | attr_.setDrawLabel(drawLabelCheckBox.isSelected()); |
---|
424 | |
---|
425 | attr_.setBatch(false); |
---|
426 | // |
---|
427 | if(pane_ != null) pane_.setBatch(false, "PointAttributeDialog"); |
---|
428 | if(paneList_ != null) { |
---|
429 | for(int i=0; i < paneList_.length; i++) { |
---|
430 | paneList_[i].setBatch(false, "PointAttributeDialog"); |
---|
431 | } |
---|
432 | } |
---|
433 | } |
---|
434 | /** |
---|
435 | * Test entry point |
---|
436 | */ |
---|
437 | public static void main(String[] args) { |
---|
438 | PointAttribute attr = new PointAttribute(); |
---|
439 | PointAttributeDialog la = new PointAttributeDialog(); |
---|
440 | la.setPointAttribute(attr, null); |
---|
441 | la.setTitle("Test PointAttribute Dialog"); |
---|
442 | la.setVisible(true); |
---|
443 | } |
---|
444 | |
---|
445 | void markEditor_actionPerformed(java.awt.event.ActionEvent event) { |
---|
446 | PlotMarkDialog pmd = new PlotMarkDialog(); |
---|
447 | Point loc = markEditor.getLocationOnScreen(); |
---|
448 | pmd.setLocation(loc.x, loc.y); |
---|
449 | int result = pmd.showDialog(mark_); |
---|
450 | if(result == PlotMarkDialog.OK_RESPONSE) { |
---|
451 | changeMark(pmd.getMark()); |
---|
452 | } |
---|
453 | } |
---|
454 | |
---|
455 | private void changeMark(int mark) { |
---|
456 | mark_ = mark; |
---|
457 | pmIcon_.setMark(mark); |
---|
458 | plotMarkIconLabel.repaint(); |
---|
459 | } |
---|
460 | |
---|
461 | void fontEditor_actionPerformed(java.awt.event.ActionEvent event) { |
---|
462 | FontDialog fd = new FontDialog(); |
---|
463 | int result = fd.showDialog(labelFont_); |
---|
464 | if(result == FontDialog.OK_RESPONSE) { |
---|
465 | labelFont_ = fd.getFont(); |
---|
466 | fontLabel.setText(fontString(labelFont_)); |
---|
467 | fontLabel.setFont(labelFont_); |
---|
468 | } |
---|
469 | } |
---|
470 | |
---|
471 | String fontString(Font font) { |
---|
472 | int style = (font.isBold()?1:0) + (font.isItalic()?2:0); |
---|
473 | return font.getName() + " " + styleNames_[style]; |
---|
474 | } |
---|
475 | } |
---|