1 | /* |
---|
2 | * $Id: ContourLineAttributeDialog.java,v 1.11 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 | import gov.noaa.pmel.sgt.ContourLineAttribute; |
---|
19 | import gov.noaa.pmel.sgt.LineAttribute; |
---|
20 | import gov.noaa.pmel.swing.ThreeDotsButton; |
---|
21 | import javax.swing.border.*; |
---|
22 | import java.awt.event.*; |
---|
23 | |
---|
24 | /** |
---|
25 | * Edits a <code>ContourLineAttribute</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>ContourLineAttributeDialog</code> use: |
---|
32 | * <pre> |
---|
33 | * public void editCLAttribute(ContourLineAttribute cla) { |
---|
34 | * ContourLineAttributeDialog clad = new ContourLineAttributeDialog(); |
---|
35 | * clad.showDialog(cla); |
---|
36 | * } |
---|
37 | * </pre> |
---|
38 | * |
---|
39 | * @author Donald Denbo |
---|
40 | * @version $Revision: 1.11 $, $Date: 2003/08/22 23:02:39 $ |
---|
41 | * @since 2.0 |
---|
42 | */ |
---|
43 | public class ContourLineAttributeDialog extends JDialog { |
---|
44 | private ContourLineAttribute attr_; |
---|
45 | private Font labelFont_; |
---|
46 | private int result_; |
---|
47 | private String[] styleNames_ = {"plain", "bold", "italic", "bold-italic"}; |
---|
48 | /** OK button was selected */ |
---|
49 | public static int OK_RESPONSE = 1; |
---|
50 | /** Cancel button was selected */ |
---|
51 | public static int CANCEL_RESPONSE = 2; |
---|
52 | /** |
---|
53 | * Constructor. |
---|
54 | */ |
---|
55 | public ContourLineAttributeDialog(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 | { |
---|
66 | String[] tempString = new String[7]; |
---|
67 | tempString[0] = "SOLID"; |
---|
68 | tempString[1] = "DASHED"; |
---|
69 | tempString[2] = "HEAVY"; |
---|
70 | tempString[3] = "HIGHLIGHT"; |
---|
71 | tempString[4] = "MARK"; |
---|
72 | tempString[5] = "MARK & SOLID"; |
---|
73 | tempString[6] = "STROKE"; |
---|
74 | for(int i=0; i < tempString.length; i++) { |
---|
75 | lineStyleCBM.addElement(tempString[i]); |
---|
76 | } |
---|
77 | } |
---|
78 | { |
---|
79 | String[] tempString = new String[3]; |
---|
80 | tempString[0] = "BUTT"; |
---|
81 | tempString[1] = "ROUND"; |
---|
82 | tempString[2] = "SQUARE"; |
---|
83 | for(int i=0; i < tempString.length; i++) { |
---|
84 | capStyleCBM.addElement(tempString[i]); |
---|
85 | } |
---|
86 | } |
---|
87 | { |
---|
88 | String[] tempString = new String[3]; |
---|
89 | tempString[0] = "MITER"; |
---|
90 | tempString[1] = "ROUND"; |
---|
91 | tempString[2] = "BEVEL"; |
---|
92 | for(int i=0; i < tempString.length; i++) { |
---|
93 | miterStyleCBM.addElement(tempString[i]); |
---|
94 | } |
---|
95 | } |
---|
96 | titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(142, 142, 142)),"Stroke Line Attributes"); |
---|
97 | getContentPane().setLayout(new BorderLayout(0,0)); |
---|
98 | setSize(new Dimension(587, 410)); |
---|
99 | setVisible(false); |
---|
100 | strokePanel.setBorder(titledBorder1); |
---|
101 | strokePanel.setLayout(gridBagLayout1); |
---|
102 | dashArrayUseDefault.setActionCommand("dashArray"); |
---|
103 | JLabel110.setText(" Width:"); |
---|
104 | dashPhaseTextField.setColumns(10); |
---|
105 | JLabel27.setText("Dash Phase:"); |
---|
106 | JLabel28.setText("Dash Array:"); |
---|
107 | widthTextField.setColumns(10); |
---|
108 | arrayEditor.setActionCommand("..."); |
---|
109 | arrayEditor.setToolTipText("Edit dash array."); |
---|
110 | dashArrayPanel.setLayout(new GridBagLayout()); |
---|
111 | dashPhaseUseDefault.setActionCommand("dashPhase"); |
---|
112 | widthUseDefault.setActionCommand("width"); |
---|
113 | jLabel1.setText("Cap Style:"); |
---|
114 | jLabel2.setText("Miter Style:"); |
---|
115 | jLabel3.setText("Miter Limit:"); |
---|
116 | miterLimitTextField.setColumns(10); |
---|
117 | capStyleComboBox.setModel(capStyleCBM); |
---|
118 | miterStyleComboBox.setModel(miterStyleCBM); |
---|
119 | lineStyleComboBox.addActionListener(new ContourLineAttributeDialog_lineStyleComboBox_actionAdapter(this)); |
---|
120 | capStyleUseDefault.setActionCommand("capStyle"); |
---|
121 | miterStyleUseDefault.setActionCommand("miterStyle"); |
---|
122 | miterLimitUseDefault.setActionCommand("miterLimit"); |
---|
123 | getContentPane().add(TabbedPane, "Center"); |
---|
124 | linePanel.setLayout(new GridBagLayout()); |
---|
125 | TabbedPane.add(linePanel, "linePanel"); |
---|
126 | labelPanel.setLayout(new GridBagLayout()); |
---|
127 | TabbedPane.add(labelPanel, "labelPanel"); |
---|
128 | labelPanel.setBounds(2,27,476,260); |
---|
129 | labelPanel.setVisible(false); |
---|
130 | JLabel23.setText("Property"); |
---|
131 | labelPanel.add(JLabel23, new GridBagConstraints(0,0,1,1,0.0,0.0, |
---|
132 | GridBagConstraints.SOUTH,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); |
---|
133 | JLabel23.setForeground(java.awt.Color.darkGray); |
---|
134 | JPanel3.setLayout(new GridBagLayout()); |
---|
135 | labelPanel.add(JPanel3, new GridBagConstraints(1,0,1,1,0.0,0.0, |
---|
136 | GridBagConstraints.SOUTH,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); |
---|
137 | JLabel24.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); |
---|
138 | JLabel24.setText("Use"); |
---|
139 | JPanel3.add(JLabel24, new GridBagConstraints(0,0,1,1,1.0,1.0, |
---|
140 | GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(5,0,0,0),0,0)); |
---|
141 | JLabel24.setForeground(java.awt.Color.darkGray); |
---|
142 | JLabel25.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); |
---|
143 | JLabel25.setText("Default"); |
---|
144 | JPanel3.add(JLabel25, new GridBagConstraints(0,1,1,1,1.0,1.0, |
---|
145 | GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0)); |
---|
146 | JLabel25.setForeground(java.awt.Color.darkGray); |
---|
147 | JLabel26.setText("Value"); |
---|
148 | labelPanel.add(JLabel26, new GridBagConstraints(2,0,1,1,0.0,0.0, |
---|
149 | GridBagConstraints.SOUTH,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); |
---|
150 | JLabel26.setForeground(java.awt.Color.darkGray); |
---|
151 | JPanel4.setBorder(etchedBorder1); |
---|
152 | JPanel4.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
---|
153 | labelPanel.add(JPanel4, new GridBagConstraints(0,1,3,1,0.0,0.0, |
---|
154 | GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(2,5,7,5),0,-12)); |
---|
155 | JLabel11.setText("Color:"); |
---|
156 | labelPanel.add(JLabel11, new GridBagConstraints(0,2,1,1,0.0,0.0, |
---|
157 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
158 | labelColorUseDefault.setActionCommand("labelColor"); |
---|
159 | labelPanel.add(labelColorUseDefault, new GridBagConstraints(1,2,1,1,0.0,0.0, |
---|
160 | GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); |
---|
161 | textColorPanel.setBorder(etchedBorder1); |
---|
162 | textColorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
---|
163 | labelPanel.add(textColorPanel, new GridBagConstraints(2,2,1,1,0.0,0.0, |
---|
164 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
165 | JLabel15.setText("Font:"); |
---|
166 | labelPanel.add(JLabel15, new GridBagConstraints(0,3,1,1,0.0,0.0, |
---|
167 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
168 | labelFontUseDefault.setActionCommand("labelFont"); |
---|
169 | labelPanel.add(labelFontUseDefault, new GridBagConstraints(1,3,1,1,0.0,0.0, |
---|
170 | GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); |
---|
171 | fontPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
---|
172 | labelPanel.add(fontPanel, new GridBagConstraints(2,3,1,1,0.0,0.0, |
---|
173 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
174 | fontLabel.setText("Dialog, 12, Bold"); |
---|
175 | fontPanel.add(fontLabel); |
---|
176 | fontLabel.setForeground(java.awt.Color.black); |
---|
177 | fontEditor.setToolTipText("Edit font."); |
---|
178 | fontEditor.setActionCommand("..."); |
---|
179 | fontPanel.add(fontEditor); |
---|
180 | JLabel16.setText("HeightP:"); |
---|
181 | labelPanel.add(JLabel16, new GridBagConstraints(0,4,1,1,0.0,0.0, |
---|
182 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
183 | heightPUseDefault.setActionCommand("heightP"); |
---|
184 | labelPanel.add(heightPUseDefault, new GridBagConstraints(1,4,1,1,0.0,0.0, |
---|
185 | GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); |
---|
186 | heightTextField.setColumns(10); |
---|
187 | labelPanel.add(heightTextField, new GridBagConstraints(2,4,1,1,1.0,0.0, |
---|
188 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); |
---|
189 | JLabel6.setText("Text:"); |
---|
190 | labelPanel.add(JLabel6, new GridBagConstraints(0,6,1,1,0.0,0.0, |
---|
191 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
192 | labelPanel.add(textTextField, new GridBagConstraints(2,6,1,1,0.0,0.0, |
---|
193 | GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,5,2,5),0,0)); |
---|
194 | JLabel22.setText("Format:"); |
---|
195 | labelPanel.add(JLabel22, new GridBagConstraints(0,7,1,1,0.0,0.0, |
---|
196 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
197 | labelFormatUseDefault.setActionCommand("labelFormat"); |
---|
198 | labelPanel.add(labelFormatUseDefault, new GridBagConstraints(1,7,1,1,0.0,0.0, |
---|
199 | GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); |
---|
200 | labelFormatTextField.setColumns(10); |
---|
201 | labelPanel.add(labelFormatTextField, new GridBagConstraints(2,7,1,1,0.0,0.0, |
---|
202 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); |
---|
203 | JLabel17.setText("Auto Label:"); |
---|
204 | labelPanel.add(JLabel17, new GridBagConstraints(0,5,1,1,0.0,0.0, |
---|
205 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
206 | labelPanel.add(autoLabelCheckBox, new GridBagConstraints(2,5,1,1,0.0,0.0, |
---|
207 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
208 | JLabel7.setText("Enabled:"); |
---|
209 | labelPanel.add(JLabel7, new GridBagConstraints(0,8,1,1,0.0,0.0, |
---|
210 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(5,5,0,5),0,0)); |
---|
211 | labelEnabledUseDefault.setActionCommand("labelEnabled"); |
---|
212 | labelPanel.add(labelEnabledUseDefault, new GridBagConstraints(1,8,1,1,0.0,0.0, |
---|
213 | GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0)); |
---|
214 | labelEnabledCheckBox.setSelected(true); |
---|
215 | labelPanel.add(labelEnabledCheckBox, new GridBagConstraints(2,8,1,1,0.0,0.0, |
---|
216 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,5,5,5),0,0)); |
---|
217 | TabbedPane.setSelectedComponent(linePanel); |
---|
218 | TabbedPane.setSelectedIndex(0); |
---|
219 | buttonPanel.setBorder(etchedBorder1); |
---|
220 | buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
---|
221 | getContentPane().add(buttonPanel, "South"); |
---|
222 | okButton.setText("OK"); |
---|
223 | okButton.setActionCommand("OK"); |
---|
224 | buttonPanel.add(okButton); |
---|
225 | applyButton.setText("Apply"); |
---|
226 | applyButton.setActionCommand("Apply"); |
---|
227 | buttonPanel.add(applyButton); |
---|
228 | cancelButton.setText("Cancel"); |
---|
229 | cancelButton.setActionCommand("Cancel"); |
---|
230 | buttonPanel.add(cancelButton); |
---|
231 | //$$ etchedBorder1.move(0,384); |
---|
232 | linePanel.setBounds(2,27,476,260); |
---|
233 | linePanel.setVisible(false); |
---|
234 | JLabel1.setText("Color:"); |
---|
235 | linePanel.add(JLabel1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 |
---|
236 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
237 | colorUseDefault.setActionCommand("color"); |
---|
238 | linePanel.add(colorUseDefault, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 |
---|
239 | ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); |
---|
240 | lineColorPanel.setBorder(etchedBorder1); |
---|
241 | lineColorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
---|
242 | linePanel.add(lineColorPanel, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 |
---|
243 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
244 | JLabel5.setText("Line Style:"); |
---|
245 | linePanel.add(JLabel5, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 |
---|
246 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 28, 0, 5), 0, 0)); |
---|
247 | styleUseDefault.setActionCommand("style"); |
---|
248 | linePanel.add(styleUseDefault, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 |
---|
249 | ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); |
---|
250 | lineStyleComboBox.setModel(lineStyleCBM); |
---|
251 | linePanel.add(lineStyleComboBox, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 |
---|
252 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
253 | JLabel18.setText("Property"); |
---|
254 | linePanel.add(JLabel18, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 |
---|
255 | ,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); |
---|
256 | JLabel18.setForeground(java.awt.Color.darkGray); |
---|
257 | JPanel1.setLayout(new GridBagLayout()); |
---|
258 | linePanel.add(JPanel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 |
---|
259 | ,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); |
---|
260 | JLabel19.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); |
---|
261 | JLabel19.setText("Use"); |
---|
262 | JPanel1.add(JLabel19, new GridBagConstraints(0,0,1,1,1.0,1.0, |
---|
263 | GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(5,0,0,0),0,0)); |
---|
264 | JLabel19.setForeground(java.awt.Color.darkGray); |
---|
265 | JLabel20.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); |
---|
266 | JLabel20.setText("Default"); |
---|
267 | JPanel1.add(JLabel20, new GridBagConstraints(0,1,1,1,1.0,1.0, |
---|
268 | GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0)); |
---|
269 | JLabel20.setForeground(java.awt.Color.darkGray); |
---|
270 | JLabel21.setText("Value"); |
---|
271 | linePanel.add(JLabel21, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 |
---|
272 | ,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); |
---|
273 | JLabel21.setForeground(java.awt.Color.darkGray); |
---|
274 | JPanel2.setBorder(etchedBorder1); |
---|
275 | JPanel2.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
---|
276 | linePanel.add(JPanel2, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0 |
---|
277 | ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 7, 0), 0, -12)); |
---|
278 | linePanel.add(strokePanel, new GridBagConstraints(0, 5, 3, 1, 1.0, 0.0 |
---|
279 | ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0)); |
---|
280 | strokePanel.add(dashArrayUseDefault, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 |
---|
281 | ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); |
---|
282 | strokePanel.add(JLabel110, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 |
---|
283 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
284 | strokePanel.add(dashPhaseTextField, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 |
---|
285 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
286 | strokePanel.add(JLabel27, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 |
---|
287 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
288 | strokePanel.add(JLabel28, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 |
---|
289 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
290 | strokePanel.add(widthTextField, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 |
---|
291 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
292 | strokePanel.add(dashArrayPanel, new GridBagConstraints(2, 1, 1, 1, 1.0, 0.0 |
---|
293 | ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0)); |
---|
294 | dashArrayPanel.add(dashArrayTextField, new GridBagConstraints(0,0,1,1,1.0,0.0, |
---|
295 | GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); |
---|
296 | dashArrayPanel.add(arrayEditor, new GridBagConstraints(1,0,1,1,0.0,1.0, |
---|
297 | GridBagConstraints.CENTER,GridBagConstraints.VERTICAL,new Insets(0,0,0,0),0,0)); |
---|
298 | strokePanel.add(dashPhaseUseDefault, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 |
---|
299 | ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); |
---|
300 | strokePanel.add(widthUseDefault, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 |
---|
301 | ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); |
---|
302 | strokePanel.add(jLabel1, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 |
---|
303 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
304 | strokePanel.add(jLabel2, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 |
---|
305 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
306 | strokePanel.add(jLabel3, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0 |
---|
307 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
308 | strokePanel.add(capStyleUseDefault, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0 |
---|
309 | ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); |
---|
310 | strokePanel.add(miterStyleUseDefault, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 |
---|
311 | ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); |
---|
312 | strokePanel.add(miterLimitUseDefault, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0 |
---|
313 | ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 15, 0, 10), 0, 0)); |
---|
314 | strokePanel.add(capStyleComboBox, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0 |
---|
315 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
316 | strokePanel.add(miterStyleComboBox, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0 |
---|
317 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
318 | strokePanel.add(miterLimitTextField, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0 |
---|
319 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
320 | TabbedPane.setTitleAt(0,"Line"); |
---|
321 | TabbedPane.setTitleAt(1,"Label"); |
---|
322 | //$$ stringComboBoxModel1.move(24,384); |
---|
323 | lineStyleComboBox.setSelectedIndex(0); |
---|
324 | setTitle("ContourLineAttribute Properties"); |
---|
325 | |
---|
326 | SymWindow aSymWindow = new SymWindow(); |
---|
327 | this.addWindowListener(aSymWindow); |
---|
328 | SymAction lSymAction = new SymAction(); |
---|
329 | cancelButton.addActionListener(lSymAction); |
---|
330 | okButton.addActionListener(lSymAction); |
---|
331 | applyButton.addActionListener(lSymAction); |
---|
332 | fontEditor.addActionListener(lSymAction); |
---|
333 | autoLabelCheckBox.addActionListener(lSymAction); |
---|
334 | labelEnabledCheckBox.addActionListener(lSymAction); |
---|
335 | arrayEditor.addActionListener(lSymAction); |
---|
336 | |
---|
337 | // |
---|
338 | // Use Default checkbox's have their own action listener |
---|
339 | // |
---|
340 | CBAction cbAction = new CBAction(); |
---|
341 | colorUseDefault.addActionListener(cbAction); |
---|
342 | styleUseDefault.addActionListener(cbAction); |
---|
343 | labelColorUseDefault.addActionListener(cbAction); |
---|
344 | labelFontUseDefault.addActionListener(cbAction); |
---|
345 | heightPUseDefault.addActionListener(cbAction); |
---|
346 | labelFormatUseDefault.addActionListener(cbAction); |
---|
347 | labelEnabledUseDefault.addActionListener(cbAction); |
---|
348 | dashArrayUseDefault.addActionListener(cbAction); |
---|
349 | dashPhaseUseDefault.addActionListener(cbAction); |
---|
350 | widthUseDefault.addActionListener(cbAction); |
---|
351 | capStyleUseDefault.addActionListener(cbAction); |
---|
352 | miterStyleUseDefault.addActionListener(cbAction); |
---|
353 | miterLimitUseDefault.addActionListener(cbAction); |
---|
354 | |
---|
355 | // Insets pup = new Insets(0, 0, 0, 0); |
---|
356 | // fontEditor.setMargin(pup); |
---|
357 | // arrayEditor.setMargin(pup); |
---|
358 | } |
---|
359 | /** Used internally. */ |
---|
360 | public void addNotify() { |
---|
361 | // Record the size of the window prior to calling parents addNotify. |
---|
362 | Dimension d = getSize(); |
---|
363 | |
---|
364 | super.addNotify(); |
---|
365 | |
---|
366 | if (fComponentsAdjusted) |
---|
367 | return; |
---|
368 | |
---|
369 | // Adjust components according to the insets |
---|
370 | Insets ins = getInsets(); |
---|
371 | setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); |
---|
372 | Component components[] = getContentPane().getComponents(); |
---|
373 | for (int i = 0; i < components.length; i++) { |
---|
374 | Point p = components[i].getLocation(); |
---|
375 | p.translate(ins.left, ins.top); |
---|
376 | components[i].setLocation(p); |
---|
377 | } |
---|
378 | fComponentsAdjusted = true; |
---|
379 | } |
---|
380 | |
---|
381 | // Used for addNotify check. |
---|
382 | boolean fComponentsAdjusted = false; |
---|
383 | /** |
---|
384 | * Constructor. |
---|
385 | */ |
---|
386 | public ContourLineAttributeDialog(String title) { |
---|
387 | this(); |
---|
388 | setTitle(title); |
---|
389 | } |
---|
390 | /** |
---|
391 | * Default constructor. |
---|
392 | */ |
---|
393 | public ContourLineAttributeDialog() { |
---|
394 | this((Frame)null); |
---|
395 | } |
---|
396 | /** |
---|
397 | * Make the dialog visible. |
---|
398 | */ |
---|
399 | public void setVisible(boolean b) { |
---|
400 | if(b) { |
---|
401 | setLocation(50, 50); |
---|
402 | } |
---|
403 | super.setVisible(b); |
---|
404 | } |
---|
405 | |
---|
406 | class SymWindow extends java.awt.event.WindowAdapter { |
---|
407 | public void windowClosing(java.awt.event.WindowEvent event) { |
---|
408 | Object object = event.getSource(); |
---|
409 | if (object == ContourLineAttributeDialog.this) |
---|
410 | ContourLineAttributeDialog_WindowClosing(event); |
---|
411 | } |
---|
412 | } |
---|
413 | |
---|
414 | void ContourLineAttributeDialog_WindowClosing(java.awt.event.WindowEvent event) { |
---|
415 | dispose(); |
---|
416 | } |
---|
417 | |
---|
418 | javax.swing.JTabbedPane TabbedPane = new javax.swing.JTabbedPane(); |
---|
419 | javax.swing.JPanel linePanel = new javax.swing.JPanel(); |
---|
420 | javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); |
---|
421 | javax.swing.JCheckBox colorUseDefault = new javax.swing.JCheckBox(); |
---|
422 | ColorEntryPanel lineColorPanel = new ColorEntryPanel(); |
---|
423 | javax.swing.JLabel JLabel5 = new javax.swing.JLabel(); |
---|
424 | javax.swing.JCheckBox styleUseDefault = new javax.swing.JCheckBox(); |
---|
425 | javax.swing.JComboBox lineStyleComboBox = new javax.swing.JComboBox(); |
---|
426 | javax.swing.JLabel JLabel18 = new javax.swing.JLabel(); |
---|
427 | javax.swing.JPanel JPanel1 = new javax.swing.JPanel(); |
---|
428 | javax.swing.JLabel JLabel19 = new javax.swing.JLabel(); |
---|
429 | javax.swing.JLabel JLabel20 = new javax.swing.JLabel(); |
---|
430 | javax.swing.JLabel JLabel21 = new javax.swing.JLabel(); |
---|
431 | javax.swing.JPanel JPanel2 = new javax.swing.JPanel(); |
---|
432 | javax.swing.JPanel labelPanel = new javax.swing.JPanel(); |
---|
433 | javax.swing.JLabel JLabel23 = new javax.swing.JLabel(); |
---|
434 | javax.swing.JPanel JPanel3 = new javax.swing.JPanel(); |
---|
435 | javax.swing.JLabel JLabel24 = new javax.swing.JLabel(); |
---|
436 | javax.swing.JLabel JLabel25 = new javax.swing.JLabel(); |
---|
437 | javax.swing.JLabel JLabel26 = new javax.swing.JLabel(); |
---|
438 | javax.swing.JPanel JPanel4 = new javax.swing.JPanel(); |
---|
439 | javax.swing.JLabel JLabel11 = new javax.swing.JLabel(); |
---|
440 | javax.swing.JCheckBox labelColorUseDefault = new javax.swing.JCheckBox(); |
---|
441 | ColorEntryPanel textColorPanel = new ColorEntryPanel(); |
---|
442 | javax.swing.JLabel JLabel15 = new javax.swing.JLabel(); |
---|
443 | javax.swing.JCheckBox labelFontUseDefault = new javax.swing.JCheckBox(); |
---|
444 | javax.swing.JPanel fontPanel = new javax.swing.JPanel(); |
---|
445 | javax.swing.JLabel fontLabel = new javax.swing.JLabel(); |
---|
446 | ThreeDotsButton fontEditor = new ThreeDotsButton(); |
---|
447 | javax.swing.JLabel JLabel16 = new javax.swing.JLabel(); |
---|
448 | javax.swing.JCheckBox heightPUseDefault = new javax.swing.JCheckBox(); |
---|
449 | javax.swing.JTextField heightTextField = new javax.swing.JTextField(); |
---|
450 | javax.swing.JLabel JLabel6 = new javax.swing.JLabel(); |
---|
451 | javax.swing.JTextField textTextField = new javax.swing.JTextField(); |
---|
452 | javax.swing.JLabel JLabel22 = new javax.swing.JLabel(); |
---|
453 | javax.swing.JCheckBox labelFormatUseDefault = new javax.swing.JCheckBox(); |
---|
454 | javax.swing.JTextField labelFormatTextField = new javax.swing.JTextField(); |
---|
455 | javax.swing.JLabel JLabel17 = new javax.swing.JLabel(); |
---|
456 | javax.swing.JCheckBox autoLabelCheckBox = new javax.swing.JCheckBox(); |
---|
457 | javax.swing.JLabel JLabel7 = new javax.swing.JLabel(); |
---|
458 | javax.swing.JCheckBox labelEnabledUseDefault = new javax.swing.JCheckBox(); |
---|
459 | javax.swing.JCheckBox labelEnabledCheckBox = new javax.swing.JCheckBox(); |
---|
460 | javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); |
---|
461 | javax.swing.JButton okButton = new javax.swing.JButton(); |
---|
462 | javax.swing.JButton applyButton = new javax.swing.JButton(); |
---|
463 | javax.swing.JButton cancelButton = new javax.swing.JButton(); |
---|
464 | javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); |
---|
465 | DefaultComboBoxModel lineStyleCBM = new DefaultComboBoxModel(); |
---|
466 | DefaultComboBoxModel capStyleCBM = new DefaultComboBoxModel(); |
---|
467 | DefaultComboBoxModel miterStyleCBM = new DefaultComboBoxModel(); |
---|
468 | JPanel strokePanel = new JPanel(); |
---|
469 | TitledBorder titledBorder1; |
---|
470 | GridBagLayout gridBagLayout1 = new GridBagLayout(); |
---|
471 | JCheckBox dashArrayUseDefault = new javax.swing.JCheckBox(); |
---|
472 | JLabel JLabel110 = new javax.swing.JLabel(); |
---|
473 | JTextField dashPhaseTextField = new javax.swing.JTextField(); |
---|
474 | JLabel JLabel27 = new javax.swing.JLabel(); |
---|
475 | JLabel JLabel28 = new javax.swing.JLabel(); |
---|
476 | JTextField dashArrayTextField = new javax.swing.JTextField(); |
---|
477 | JTextField widthTextField = new javax.swing.JTextField(); |
---|
478 | ThreeDotsButton arrayEditor = new ThreeDotsButton(); |
---|
479 | JPanel dashArrayPanel = new javax.swing.JPanel(); |
---|
480 | JCheckBox dashPhaseUseDefault = new javax.swing.JCheckBox(); |
---|
481 | JCheckBox widthUseDefault = new javax.swing.JCheckBox(); |
---|
482 | JLabel jLabel1 = new JLabel(); |
---|
483 | JLabel jLabel2 = new JLabel(); |
---|
484 | JLabel jLabel3 = new JLabel(); |
---|
485 | JCheckBox capStyleUseDefault = new JCheckBox(); |
---|
486 | JCheckBox miterStyleUseDefault = new JCheckBox(); |
---|
487 | JCheckBox miterLimitUseDefault = new JCheckBox(); |
---|
488 | JComboBox capStyleComboBox = new JComboBox(); |
---|
489 | JComboBox miterStyleComboBox = new JComboBox(); |
---|
490 | JTextField miterLimitTextField = new JTextField(); |
---|
491 | |
---|
492 | |
---|
493 | class SymAction implements java.awt.event.ActionListener { |
---|
494 | public void actionPerformed(java.awt.event.ActionEvent event) { |
---|
495 | Object object = event.getSource(); |
---|
496 | if (object == cancelButton) |
---|
497 | cancelButton_actionPerformed(event); |
---|
498 | else if (object == okButton) |
---|
499 | okButton_actionPerformed(event); |
---|
500 | else if (object == applyButton) |
---|
501 | applyButton_actionPerformed(event); |
---|
502 | else if (object == fontEditor) |
---|
503 | fontEditor_actionPerformed(event); |
---|
504 | else if (object == autoLabelCheckBox) |
---|
505 | autoLabelCheckBox_actionPerformed(event); |
---|
506 | else if (object == labelEnabledCheckBox) |
---|
507 | labelEnabledCheckBox_actionPerformed(event); |
---|
508 | else if (object == arrayEditor) |
---|
509 | arrayEditor_actionPerformed(event); |
---|
510 | } |
---|
511 | } |
---|
512 | |
---|
513 | void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { |
---|
514 | this.setVisible(false); |
---|
515 | result_ = CANCEL_RESPONSE; |
---|
516 | } |
---|
517 | |
---|
518 | void okButton_actionPerformed(java.awt.event.ActionEvent event) { |
---|
519 | result_ = OK_RESPONSE; |
---|
520 | updateContourLineAttribute(); |
---|
521 | this.setVisible(false); |
---|
522 | } |
---|
523 | |
---|
524 | void applyButton_actionPerformed(java.awt.event.ActionEvent event) { |
---|
525 | result_ = OK_RESPONSE; |
---|
526 | updateContourLineAttribute(); |
---|
527 | } |
---|
528 | |
---|
529 | class CBAction implements java.awt.event.ActionListener { |
---|
530 | public void actionPerformed(java.awt.event.ActionEvent event) { |
---|
531 | Object object = event.getSource(); |
---|
532 | if(object instanceof JCheckBox) |
---|
533 | checkBox_actionPerformed(event); |
---|
534 | } |
---|
535 | } |
---|
536 | |
---|
537 | void checkBox_actionPerformed(java.awt.event.ActionEvent event) { |
---|
538 | String action = event.getActionCommand(); |
---|
539 | useDefault(action); |
---|
540 | } |
---|
541 | |
---|
542 | private void useDefault(String action) { |
---|
543 | boolean enable; |
---|
544 | boolean stroke = lineStyleComboBox.getSelectedIndex() == LineAttribute.STROKE; |
---|
545 | if(action.equals("color")) { |
---|
546 | enable = !colorUseDefault.isSelected(); |
---|
547 | lineColorPanel.setEnabled(enable); |
---|
548 | } else if(action.equals("style")) { |
---|
549 | lineStyleComboBox.setEnabled(!styleUseDefault.isSelected()); |
---|
550 | } else if(action.equals("width")) { |
---|
551 | widthTextField.setEnabled(!widthUseDefault.isSelected() && stroke); |
---|
552 | } else if(action.equals("dashArray")) { |
---|
553 | enable = !dashArrayUseDefault.isSelected() && stroke; |
---|
554 | dashArrayTextField.setEnabled(enable); |
---|
555 | arrayEditor.setEnabled(enable); |
---|
556 | } else if(action.equals("dashPhase")) { |
---|
557 | dashPhaseTextField.setEnabled(!dashPhaseUseDefault.isSelected() && stroke); |
---|
558 | } else if(action.equals("capStyle")) { |
---|
559 | capStyleComboBox.setEnabled(!capStyleUseDefault.isSelected() && stroke); |
---|
560 | } else if(action.equals("miterStyle")) { |
---|
561 | miterStyleComboBox.setEnabled(!miterStyleUseDefault.isSelected() && stroke); |
---|
562 | } else if(action.equals("miterLimit")) { |
---|
563 | miterLimitTextField.setEnabled(!miterLimitUseDefault.isSelected() && stroke); |
---|
564 | } else if(action.equals("labelColor")) { |
---|
565 | enable = !labelColorUseDefault.isSelected(); |
---|
566 | textColorPanel.setEnabled(enable); |
---|
567 | } else if(action.equals("labelFont")) { |
---|
568 | enable = !labelFontUseDefault.isSelected(); |
---|
569 | fontLabel.setEnabled(enable); |
---|
570 | fontEditor.setEnabled(enable); |
---|
571 | } else if(action.equals("heightP")) { |
---|
572 | heightTextField.setEnabled(!heightPUseDefault.isSelected()); |
---|
573 | } else if(action.equals("labelFormat")) { |
---|
574 | labelFormatTextField.setEnabled(!labelFormatUseDefault.isSelected()); |
---|
575 | } else if(action.equals("labelEnabled")) { |
---|
576 | labelEnabledCheckBox.setEnabled(!labelEnabledUseDefault.isSelected()); |
---|
577 | } else { |
---|
578 | System.out.println("Action " + action + " not found."); |
---|
579 | } |
---|
580 | } |
---|
581 | |
---|
582 | private void useDefaultAll() { |
---|
583 | useDefault("color"); |
---|
584 | useDefault("style"); |
---|
585 | useDefault("width"); |
---|
586 | useDefault("dashArray"); |
---|
587 | useDefault("dashPhase"); |
---|
588 | useDefault("capStyle"); |
---|
589 | useDefault("miterStyle"); |
---|
590 | useDefault("miterLimit"); |
---|
591 | useDefault("labelColor"); |
---|
592 | useDefault("labelFont"); |
---|
593 | useDefault("heightP"); |
---|
594 | useDefault("labelFormat"); |
---|
595 | useDefault("labelEnabled"); |
---|
596 | } |
---|
597 | /** |
---|
598 | * Show the dialog and wait for a response |
---|
599 | * |
---|
600 | * @return result, either CANCE_RESPONSE or OK_RESPONSE |
---|
601 | */ |
---|
602 | public int showDialog(ContourLineAttribute attr) { |
---|
603 | setContourLineAttribute(attr); |
---|
604 | result_ = CANCEL_RESPONSE; |
---|
605 | setModal(true); |
---|
606 | super.setVisible(true); |
---|
607 | return result_; |
---|
608 | } |
---|
609 | /** |
---|
610 | * Set the <code>ContourLineAttribute</code> for editing. |
---|
611 | */ |
---|
612 | public void setContourLineAttribute(ContourLineAttribute attr) { |
---|
613 | attr_ = attr; |
---|
614 | // |
---|
615 | // Line attributes |
---|
616 | // |
---|
617 | // Color |
---|
618 | // |
---|
619 | lineColorPanel.setColor(attr_.getColor()); |
---|
620 | colorUseDefault.setSelected(!attr_.isColorOverridden()); |
---|
621 | // |
---|
622 | // style |
---|
623 | // |
---|
624 | lineStyleComboBox.setSelectedIndex(attr_.getStyle()); |
---|
625 | styleUseDefault.setSelected(!attr_.isStyleOverridden()); |
---|
626 | strokePanelEnabled(attr_.getStyle() == LineAttribute.STROKE); |
---|
627 | // |
---|
628 | // width |
---|
629 | // |
---|
630 | widthTextField.setText(Float.toString(attr_.getWidth())); |
---|
631 | widthUseDefault.setSelected(!attr_.isWidthOverridden()); |
---|
632 | // |
---|
633 | // dash Array |
---|
634 | // |
---|
635 | float[] da = attr_.getDashArray(); |
---|
636 | dashArrayTextField.setText(dashArrayString(da)); |
---|
637 | dashArrayUseDefault.setSelected(!attr_.isDashArrayOverridden()); |
---|
638 | // |
---|
639 | // dash phase |
---|
640 | // |
---|
641 | dashPhaseTextField.setText(Float.toString(attr_.getDashPhase())); |
---|
642 | dashPhaseUseDefault.setSelected(!attr_.isDashPhaseOverridden()); |
---|
643 | // |
---|
644 | // cap style |
---|
645 | // |
---|
646 | capStyleComboBox.setSelectedIndex(attr_.getCapStyle()); |
---|
647 | capStyleUseDefault.setSelected(!attr_.isCapStyleOverridden()); |
---|
648 | // |
---|
649 | // miter style |
---|
650 | // |
---|
651 | miterStyleComboBox.setSelectedIndex(attr_.getMiterStyle()); |
---|
652 | miterStyleUseDefault.setSelected(!attr_.isMiterStyleOverridden()); |
---|
653 | // |
---|
654 | // miter limit |
---|
655 | // |
---|
656 | miterLimitTextField.setText(Float.toString(attr_.getMiterLimit())); |
---|
657 | miterLimitUseDefault.setSelected(!attr_.isMiterLimitOverridden()); |
---|
658 | // |
---|
659 | // Label attributes |
---|
660 | // |
---|
661 | // color |
---|
662 | // |
---|
663 | textColorPanel.setColor(attr_.getLabelColor()); |
---|
664 | labelColorUseDefault.setSelected(!attr_.isLabelColorOverridden()); |
---|
665 | // |
---|
666 | // font |
---|
667 | // |
---|
668 | labelFont_ = attr_.getLabelFont(); |
---|
669 | if(labelFont_ == null) { |
---|
670 | fontLabel.setText("Default Font"); |
---|
671 | } else { |
---|
672 | fontLabel.setText(fontString(labelFont_)); |
---|
673 | fontLabel.setFont(labelFont_); |
---|
674 | } |
---|
675 | labelFontUseDefault.setSelected(!attr_.isLabelFontOverridden()); |
---|
676 | // |
---|
677 | // heightP |
---|
678 | // |
---|
679 | heightTextField.setText(Double.toString(attr_.getLabelHeightP())); |
---|
680 | heightPUseDefault.setSelected(!attr_.isLabelHeightPOverridden()); |
---|
681 | // |
---|
682 | // autoLabel |
---|
683 | // |
---|
684 | autoLabelCheckBox.setSelected(attr_.isAutoLabel()); |
---|
685 | autoLabel(); |
---|
686 | // |
---|
687 | // text |
---|
688 | // |
---|
689 | textTextField.setText(attr_.getLabelText()); |
---|
690 | // |
---|
691 | // label format |
---|
692 | labelFormatTextField.setText(attr_.getLabelFormat()); |
---|
693 | labelFormatUseDefault.setSelected(!attr_.isLabelFormatOverridden()); |
---|
694 | // |
---|
695 | // enabled |
---|
696 | // |
---|
697 | labelEnabledCheckBox.setSelected(attr_.isLabelEnabled()); |
---|
698 | labelEnabledUseDefault.setSelected(!attr_.isLabelEnabledOverridden()); |
---|
699 | labelEnabled(); |
---|
700 | // |
---|
701 | useDefaultAll(); |
---|
702 | } |
---|
703 | |
---|
704 | private void autoLabel() { |
---|
705 | textTextField.setEnabled(!autoLabelCheckBox.isSelected()); |
---|
706 | } |
---|
707 | |
---|
708 | private void labelEnabled() { |
---|
709 | boolean enabled = labelEnabledCheckBox.isSelected(); |
---|
710 | textTextField.setEnabled(enabled); |
---|
711 | textColorPanel.setEnabled(enabled); |
---|
712 | fontLabel.setEnabled(enabled); |
---|
713 | labelFontUseDefault.setEnabled(enabled); |
---|
714 | fontEditor.setEnabled(enabled); |
---|
715 | heightTextField.setEnabled(enabled); |
---|
716 | heightPUseDefault.setEnabled(enabled); |
---|
717 | autoLabelCheckBox.setEnabled(enabled); |
---|
718 | labelFormatTextField.setEnabled(enabled); |
---|
719 | labelFormatUseDefault.setEnabled(enabled); |
---|
720 | // |
---|
721 | useDefaultAll(); |
---|
722 | } |
---|
723 | |
---|
724 | private String dashArrayString(float[] da) { |
---|
725 | if(da == null) { |
---|
726 | return "null"; |
---|
727 | } |
---|
728 | StringBuffer sbuf = new StringBuffer("{"); |
---|
729 | for(int i=0; i < da.length; i++) { |
---|
730 | sbuf.append(Float.toString(da[i]) + ", "); |
---|
731 | } |
---|
732 | sbuf.setLength(sbuf.length()-2); |
---|
733 | sbuf.append("}"); |
---|
734 | return sbuf.toString(); |
---|
735 | } |
---|
736 | |
---|
737 | private float[] dashArray() { |
---|
738 | String arrayString = dashArrayTextField.getText(); |
---|
739 | int start = arrayString.indexOf("{"); |
---|
740 | int stop = arrayString.indexOf("}"); |
---|
741 | String sub = arrayString.substring(start+1,stop); |
---|
742 | // |
---|
743 | // parse array |
---|
744 | // |
---|
745 | StringTokenizer token = new StringTokenizer(sub, ","); |
---|
746 | int index = 0; |
---|
747 | float[] array = new float[token.countTokens()]; |
---|
748 | while(token.hasMoreTokens()) { |
---|
749 | array[index] = new Float(token.nextToken()).floatValue(); |
---|
750 | index++; |
---|
751 | } |
---|
752 | return array; |
---|
753 | } |
---|
754 | |
---|
755 | void updateContourLineAttribute() { |
---|
756 | // |
---|
757 | // Line attributes |
---|
758 | // |
---|
759 | // Color |
---|
760 | // |
---|
761 | attr_.setColor(lineColorPanel.getColor()); |
---|
762 | attr_.setColorOverridden(!colorUseDefault.isSelected()); |
---|
763 | // |
---|
764 | // style |
---|
765 | // |
---|
766 | attr_.setStyle(lineStyleComboBox.getSelectedIndex()); |
---|
767 | attr_.setStyleOverridden(!styleUseDefault.isSelected()); |
---|
768 | // |
---|
769 | // width |
---|
770 | // |
---|
771 | attr_.setWidth(new Float(widthTextField.getText()).floatValue()); |
---|
772 | attr_.setWidthOverridden(!widthUseDefault.isSelected()); |
---|
773 | // |
---|
774 | // dash array |
---|
775 | // |
---|
776 | attr_.setDashArray(dashArray()); |
---|
777 | attr_.setDashArrayOverridden(!dashArrayUseDefault.isSelected()); |
---|
778 | // |
---|
779 | // dash phase |
---|
780 | // |
---|
781 | attr_.setDashPhase(new Float(dashPhaseTextField.getText()).floatValue()); |
---|
782 | attr_.setDashPhaseOverridden(!dashPhaseUseDefault.isSelected()); |
---|
783 | // |
---|
784 | // cap style |
---|
785 | // |
---|
786 | attr_.setCapStyle(capStyleComboBox.getSelectedIndex()); |
---|
787 | attr_.setCapStyleOverridden(!capStyleUseDefault.isSelected()); |
---|
788 | // |
---|
789 | // miter style |
---|
790 | // |
---|
791 | attr_.setMiterStyle(miterStyleComboBox.getSelectedIndex()); |
---|
792 | attr_.setMiterStyleOverridden(!miterStyleUseDefault.isSelected()); |
---|
793 | // |
---|
794 | // miter limit |
---|
795 | // |
---|
796 | attr_.setMiterLimit(new Float(miterLimitTextField.getText()).floatValue()); |
---|
797 | attr_.setMiterLimitOverridden(!miterLimitUseDefault.isSelected()); |
---|
798 | // |
---|
799 | // Label attributes |
---|
800 | // |
---|
801 | // color |
---|
802 | // |
---|
803 | attr_.setLabelColor(textColorPanel.getColor()); |
---|
804 | attr_.setLabelColorOverridden(!labelColorUseDefault.isSelected()); |
---|
805 | // |
---|
806 | // font |
---|
807 | // |
---|
808 | if(labelFont_ != null) attr_.setLabelFont(labelFont_); |
---|
809 | attr_.setLabelFontOverridden(!labelFontUseDefault.isSelected()); |
---|
810 | // |
---|
811 | // heightP |
---|
812 | // |
---|
813 | attr_.setLabelHeightP(new Double(heightTextField.getText()).doubleValue()); |
---|
814 | attr_.setLabelHeightPOverridden(!heightPUseDefault.isSelected()); |
---|
815 | // |
---|
816 | // autoLabel |
---|
817 | // |
---|
818 | attr_.setAutoLabel(autoLabelCheckBox.isSelected()); |
---|
819 | // |
---|
820 | // text |
---|
821 | // |
---|
822 | attr_.setLabelText(textTextField.getText()); |
---|
823 | // |
---|
824 | // label format |
---|
825 | // |
---|
826 | attr_.setLabelFormat(labelFormatTextField.getText()); |
---|
827 | attr_.setLabelFormatOverridden(!labelFormatUseDefault.isSelected()); |
---|
828 | // |
---|
829 | // enabled |
---|
830 | // |
---|
831 | attr_.setLabelEnabled(labelEnabledCheckBox.isSelected()); |
---|
832 | attr_.setLabelEnabledOverridden(!labelEnabledUseDefault.isSelected()); |
---|
833 | } |
---|
834 | /** |
---|
835 | * Get the modified attribute |
---|
836 | */ |
---|
837 | public ContourLineAttribute getContourLineAttribute() { |
---|
838 | return attr_; |
---|
839 | } |
---|
840 | /** |
---|
841 | * Dialog test. |
---|
842 | */ |
---|
843 | public static void main(String[] args) { |
---|
844 | ContourLineAttribute attr = new ContourLineAttribute(); |
---|
845 | ContourLineAttributeDialog la = new ContourLineAttributeDialog(); |
---|
846 | la.setContourLineAttribute(attr); |
---|
847 | la.setTitle("Test ContourLineAttribute Dialog"); |
---|
848 | la.setVisible(true); |
---|
849 | } |
---|
850 | |
---|
851 | void arrayEditor_actionPerformed(java.awt.event.ActionEvent event) { |
---|
852 | ArrayEditDialog aed = new ArrayEditDialog(); |
---|
853 | Point loc = arrayEditor.getLocationOnScreen(); |
---|
854 | aed.setLocation(loc.x, loc.y); |
---|
855 | aed.setArray(dashArray()); |
---|
856 | int result = aed.showDialog(); |
---|
857 | if(result == ArrayEditDialog.OK_RESPONSE) { |
---|
858 | dashArrayTextField.setText(dashArrayString(aed.getFloatArray())); |
---|
859 | } |
---|
860 | } |
---|
861 | |
---|
862 | void fontEditor_actionPerformed(java.awt.event.ActionEvent event) { |
---|
863 | FontDialog fd = new FontDialog(); |
---|
864 | int result = fd.showDialog(labelFont_); |
---|
865 | if(result == FontDialog.OK_RESPONSE) { |
---|
866 | labelFont_ = fd.getFont(); |
---|
867 | fontLabel.setText(fontString(labelFont_)); |
---|
868 | fontLabel.setFont(labelFont_); |
---|
869 | } |
---|
870 | } |
---|
871 | |
---|
872 | |
---|
873 | void autoLabelCheckBox_actionPerformed(java.awt.event.ActionEvent event) { |
---|
874 | autoLabel(); |
---|
875 | } |
---|
876 | |
---|
877 | void labelEnabledCheckBox_actionPerformed(java.awt.event.ActionEvent event) { |
---|
878 | labelEnabled(); |
---|
879 | } |
---|
880 | |
---|
881 | String fontString(Font font) { |
---|
882 | int style = (font.isBold()?1:0) + (font.isItalic()?2:0); |
---|
883 | return font.getName() + " " + styleNames_[style]; |
---|
884 | } |
---|
885 | |
---|
886 | void lineStyleComboBox_actionPerformed(ActionEvent e) { |
---|
887 | int index = lineStyleComboBox.getSelectedIndex(); |
---|
888 | strokePanelEnabled(index == LineAttribute.STROKE); |
---|
889 | if(index == LineAttribute.MARK || index == LineAttribute.MARK_LINE) { |
---|
890 | JOptionPane.showMessageDialog(this, |
---|
891 | "Line stytle MARK or MARK & SOLID not valid for ContourLine", |
---|
892 | "Illegal Line Style", JOptionPane.ERROR_MESSAGE); |
---|
893 | lineStyleComboBox.setSelectedIndex(attr_.getStyle()); |
---|
894 | } |
---|
895 | } |
---|
896 | |
---|
897 | public void strokePanelEnabled(boolean enabled) { |
---|
898 | widthUseDefault.setEnabled(enabled); |
---|
899 | dashArrayUseDefault.setEnabled(enabled); |
---|
900 | dashArrayUseDefault.setEnabled(enabled); |
---|
901 | dashPhaseUseDefault.setEnabled(enabled); |
---|
902 | capStyleUseDefault.setEnabled(enabled); |
---|
903 | miterStyleUseDefault.setEnabled(enabled); |
---|
904 | miterLimitUseDefault.setEnabled(enabled); |
---|
905 | useDefault("width"); |
---|
906 | useDefault("dashArray"); |
---|
907 | useDefault("dashPhase"); |
---|
908 | useDefault("capStyle"); |
---|
909 | useDefault("miterStyle"); |
---|
910 | useDefault("miterLimit"); |
---|
911 | } |
---|
912 | } |
---|
913 | |
---|
914 | class ContourLineAttributeDialog_lineStyleComboBox_actionAdapter implements java.awt.event.ActionListener { |
---|
915 | ContourLineAttributeDialog adaptee; |
---|
916 | |
---|
917 | ContourLineAttributeDialog_lineStyleComboBox_actionAdapter(ContourLineAttributeDialog adaptee) { |
---|
918 | this.adaptee = adaptee; |
---|
919 | } |
---|
920 | public void actionPerformed(ActionEvent e) { |
---|
921 | adaptee.lineStyleComboBox_actionPerformed(e); |
---|
922 | } |
---|
923 | } |
---|