1 | /* |
---|
2 | * $Id: RulerDialog.java,v 1.2 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 gov.noaa.pmel.sgt.*; |
---|
15 | import gov.noaa.pmel.util.*; |
---|
16 | import gov.noaa.pmel.swing.ThreeDotsButton; |
---|
17 | import java.awt.*; |
---|
18 | import javax.swing.*; |
---|
19 | |
---|
20 | /** |
---|
21 | * Edits a <code>Ruler</code>. This dialog does not |
---|
22 | * make a copy of the object so changes "Applied" will cause |
---|
23 | * <code>sgt</code> to redraw the plot using the new properties. |
---|
24 | * |
---|
25 | * <p> Example of <code>RulerDialog</code> use: |
---|
26 | * <pre> |
---|
27 | * public void editRuler(Ruler axis, JPane pane) { |
---|
28 | * RulerDialog sad = new RulerDialog(); |
---|
29 | * sad.setRuler(axis, pane); |
---|
30 | * sad.setVisible(true); |
---|
31 | * } |
---|
32 | * </pre> |
---|
33 | * |
---|
34 | * @author Donald Denbo |
---|
35 | * @version $Revision: 1.2 $, $Date: 2003/08/22 23:02:39 $ |
---|
36 | * @since 3.0 |
---|
37 | */ |
---|
38 | public class RulerDialog extends JDialog { |
---|
39 | private JPane pane_; |
---|
40 | private Ruler scale_; |
---|
41 | private Font labelFont_; |
---|
42 | private String[] styleNames_ = {"plain", "bold", "italic", "bold-italic"}; |
---|
43 | /** |
---|
44 | * Constructor. |
---|
45 | */ |
---|
46 | public RulerDialog(Frame parent) { |
---|
47 | super(parent); |
---|
48 | try { |
---|
49 | jbInit(); |
---|
50 | pack(); |
---|
51 | } catch(Exception ex) { |
---|
52 | ex.printStackTrace(); |
---|
53 | } |
---|
54 | } |
---|
55 | void jbInit() throws Exception { |
---|
56 | getContentPane().setLayout(new BorderLayout(0,0)); |
---|
57 | setSize(new Dimension(531, 358)); |
---|
58 | setVisible(false); |
---|
59 | buttonPanel.setBorder(etchedBorder1); |
---|
60 | buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
---|
61 | jLabel1.setText("Line Color:"); |
---|
62 | physicalBorder.setTitle("Physical Bounds"); |
---|
63 | jLabel5.setText("Height:"); |
---|
64 | heightPhysicalTextField.setColumns(10); |
---|
65 | getContentPane().add(buttonPanel, "South"); |
---|
66 | okButton.setText("OK"); |
---|
67 | okButton.setActionCommand("OK"); |
---|
68 | buttonPanel.add(okButton); |
---|
69 | applyButton.setText("Apply"); |
---|
70 | applyButton.setActionCommand("Apply"); |
---|
71 | buttonPanel.add(applyButton); |
---|
72 | cancelButton.setText("Cancel"); |
---|
73 | cancelButton.setActionCommand("Cancel"); |
---|
74 | buttonPanel.add(cancelButton); |
---|
75 | //$$ etchedBorder1.move(0,348); |
---|
76 | getContentPane().add(TabbedPane, "Center"); |
---|
77 | labelPanel.setLayout(new GridBagLayout()); |
---|
78 | TabbedPane.add(labelPanel, "labelPanel"); |
---|
79 | labelPanel.setBounds(2,27,452,275); |
---|
80 | labelPanel.setVisible(false); |
---|
81 | JLabel3.setText("Interval:"); |
---|
82 | labelPanel.add(JLabel3, new GridBagConstraints(0,0,1,1,0.0,0.0, |
---|
83 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
84 | intervalTextField.setColumns(5); |
---|
85 | labelPanel.add(intervalTextField, new GridBagConstraints(1,0,1,1,0.0,0.0, |
---|
86 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); |
---|
87 | JLabel4.setText("Sig Digits:"); |
---|
88 | labelPanel.add(JLabel4, new GridBagConstraints(0,1,1,1,0.0,0.0, |
---|
89 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
90 | sigDigitsTextField.setColumns(5); |
---|
91 | labelPanel.add(sigDigitsTextField, new GridBagConstraints(1,1,1,1,0.0,0.0, |
---|
92 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); |
---|
93 | JLabel5.setText("Format:"); |
---|
94 | labelPanel.add(JLabel5, new GridBagConstraints(0,2,1,1,0.0,0.0, |
---|
95 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
96 | formatTextField.setColumns(10); |
---|
97 | labelPanel.add(formatTextField, new GridBagConstraints(1,2,1,1,0.0,0.0, |
---|
98 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); |
---|
99 | JLabel11.setText("Color:"); |
---|
100 | labelPanel.add(JLabel11, new GridBagConstraints(0,3,1,1,0.0,0.0, |
---|
101 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(15,5,0,5),0,0)); |
---|
102 | textColorPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
---|
103 | labelPanel.add(textColorPanel, new GridBagConstraints(1,3,2,1,0.0,0.0, |
---|
104 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(15,5,0,5),0,0)); |
---|
105 | JLabel15.setText("Font:"); |
---|
106 | labelPanel.add(JLabel15, new GridBagConstraints(0,4,1,1,0.0,0.0, |
---|
107 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
108 | fontPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
---|
109 | labelPanel.add(fontPanel, new GridBagConstraints(1,4,2,1,0.0,0.0, |
---|
110 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
111 | fontLabel.setText("Dialog, 12, Bold"); |
---|
112 | fontPanel.add(fontLabel); |
---|
113 | fontLabel.setForeground(java.awt.Color.black); |
---|
114 | fontEditor.setToolTipText("Edit font."); |
---|
115 | fontEditor.setActionCommand("..."); |
---|
116 | fontPanel.add(fontEditor); |
---|
117 | JLabel16.setText("Height:"); |
---|
118 | labelPanel.add(JLabel16, new GridBagConstraints(0,5,1,1,0.0,0.0, |
---|
119 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(15,5,0,5),0,0)); |
---|
120 | heightTextField.setColumns(10); |
---|
121 | labelPanel.add(heightTextField, new GridBagConstraints(1,5,1,1,0.0,0.0, |
---|
122 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(15,5,5,5),0,0)); |
---|
123 | JLabel1.setText("Position:"); |
---|
124 | labelPanel.add(JLabel1, new GridBagConstraints(0,6,1,1,0.0,0.0, |
---|
125 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
126 | positionComboBox.setModel(positionCBModel); |
---|
127 | labelPanel.add(positionComboBox, new GridBagConstraints(1,6,1,1,0.0,0.0, |
---|
128 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); |
---|
129 | rangePanel.setLayout(new GridBagLayout()); |
---|
130 | TabbedPane.add(rangePanel, "rangePanel"); |
---|
131 | rangePanel.setBounds(2,27,452,275); |
---|
132 | rangePanel.setVisible(false); |
---|
133 | userPanel.setBorder(userBorder); |
---|
134 | userPanel.setLayout(new GridBagLayout()); |
---|
135 | rangePanel.add(userPanel, new GridBagConstraints(0,0,1,1,0.0,0.0, |
---|
136 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,5,0),20,15)); |
---|
137 | JLabel8.setText("Minimum:"); |
---|
138 | userPanel.add(JLabel8, new GridBagConstraints(0,0,1,1,0.0,0.0, |
---|
139 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
140 | minUserTextField.setColumns(25); |
---|
141 | userPanel.add(minUserTextField, new GridBagConstraints(1,0,1,1,0.0,0.0, |
---|
142 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); |
---|
143 | JLabel9.setText("Maximum:"); |
---|
144 | userPanel.add(JLabel9, new GridBagConstraints(0,1,1,1,0.0,0.0, |
---|
145 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
146 | maxUserTextField.setColumns(25); |
---|
147 | userPanel.add(maxUserTextField, new GridBagConstraints(1,1,1,1,0.0,0.0, |
---|
148 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); |
---|
149 | JLabel2.setText("Delta:"); |
---|
150 | userPanel.add(JLabel2, new GridBagConstraints(0,2,1,1,0.0,0.0, |
---|
151 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
152 | incUserTextField.setColumns(25); |
---|
153 | userPanel.add(incUserTextField, new GridBagConstraints(1,2,1,1,0.0,0.0, |
---|
154 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(0,5,5,5),0,0)); |
---|
155 | physicalPanel.setBorder(physicalBorder); |
---|
156 | physicalPanel.setLayout(new GridBagLayout()); |
---|
157 | rangePanel.add(physicalPanel, new GridBagConstraints(0,1,1,1,0.0,0.0, |
---|
158 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,0,5,0),20,15)); |
---|
159 | JLabel10.setText("X:"); |
---|
160 | physicalPanel.add(JLabel10, new GridBagConstraints(0,0,1,1,0.0,0.0, |
---|
161 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
162 | xPhysicalTextField.setColumns(10); |
---|
163 | physicalPanel.add(xPhysicalTextField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0 |
---|
164 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
165 | JLabel17.setText("Y:"); |
---|
166 | physicalPanel.add(JLabel17, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0 |
---|
167 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
168 | yPhysicalTextField.setColumns(10); |
---|
169 | physicalPanel.add(yPhysicalTextField, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0 |
---|
170 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
171 | originLabel.setText("Width:"); |
---|
172 | physicalPanel.add(originLabel, new GridBagConstraints(0,2,1,1,0.0,0.0, |
---|
173 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
174 | widthPhysicalTextField.setColumns(10); |
---|
175 | physicalPanel.add(widthPhysicalTextField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 |
---|
176 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
177 | physicalPanel.add(jLabel5, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 |
---|
178 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
179 | physicalPanel.add(heightPhysicalTextField, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 |
---|
180 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
181 | ticsStylePanel.setLayout(new GridBagLayout()); |
---|
182 | TabbedPane.add(ticsStylePanel, "ticsStylePanel"); |
---|
183 | ticsStylePanel.setBounds(2,27,452,275); |
---|
184 | ticsStylePanel.setVisible(false); |
---|
185 | ticsPanel.setBorder(ticsBorder); |
---|
186 | ticsPanel.setLayout(new GridBagLayout()); |
---|
187 | ticsStylePanel.add(ticsPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 |
---|
188 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 10, 10)); |
---|
189 | JLabel18.setText("Large Tic Height:"); |
---|
190 | ticsPanel.add(JLabel18, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 |
---|
191 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
192 | largeTicTextField.setColumns(15); |
---|
193 | ticsPanel.add(largeTicTextField, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0 |
---|
194 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
195 | JLabel19.setText("Small Tic Height:"); |
---|
196 | ticsPanel.add(JLabel19, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 |
---|
197 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
198 | smallTicTextField.setColumns(15); |
---|
199 | ticsPanel.add(smallTicTextField, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0 |
---|
200 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
201 | JLabel20.setText("Number of Small Tics:"); |
---|
202 | ticsPanel.add(JLabel20, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 |
---|
203 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
204 | numSmallTicsTextField.setColumns(5); |
---|
205 | ticsPanel.add(numSmallTicsTextField, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0 |
---|
206 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
207 | JLabel21.setText("Tic Position:"); |
---|
208 | ticsPanel.add(JLabel21, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 |
---|
209 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
210 | ticPositionComboBox.setModel(ticPositionCBModel); |
---|
211 | ticsPanel.add(ticPositionComboBox, new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0 |
---|
212 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
213 | ticsPanel.add(lineColorPanel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0 |
---|
214 | ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); |
---|
215 | stylePanel.setBorder(styleBorder); |
---|
216 | stylePanel.setLayout(new GridBagLayout()); |
---|
217 | ticsStylePanel.add(stylePanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 |
---|
218 | ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 20, 10)); |
---|
219 | JLabel7.setText("Visible:"); |
---|
220 | stylePanel.add(JLabel7, new GridBagConstraints(0,1,1,1,0.0,0.0, |
---|
221 | GridBagConstraints.EAST,GridBagConstraints.NONE,new Insets(0,5,0,5),0,0)); |
---|
222 | axislVisibleCheckBox.setSelected(true); |
---|
223 | stylePanel.add(axislVisibleCheckBox, new GridBagConstraints(1,1,1,1,0.0,0.0, |
---|
224 | GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(5,5,5,5),0,0)); |
---|
225 | JLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
---|
226 | JLabel6.setText("Selectable:"); |
---|
227 | stylePanel.add(JLabel6, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 |
---|
228 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 61, 0)); |
---|
229 | axisSelectableCheckBox.setSelected(true); |
---|
230 | stylePanel.add(axisSelectableCheckBox, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 |
---|
231 | ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); |
---|
232 | ticsPanel.add(jLabel1, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 |
---|
233 | ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); |
---|
234 | TabbedPane.setSelectedComponent(labelPanel); |
---|
235 | TabbedPane.setSelectedIndex(0); |
---|
236 | TabbedPane.setTitleAt(0,"Label"); |
---|
237 | TabbedPane.setTitleAt(1,"Range"); |
---|
238 | TabbedPane.setTitleAt(2,"Tics/Style"); |
---|
239 | TabbedPane.setTitleAt(3,"Attach"); |
---|
240 | { |
---|
241 | String[] tempString = new String[3]; |
---|
242 | tempString[0] = "LEFT"; |
---|
243 | tempString[1] = "CENTER"; |
---|
244 | tempString[2] = "RIGHT"; |
---|
245 | for(int i=0; i < tempString.length; i++) { |
---|
246 | horizCBModel.addElement(tempString[i]); |
---|
247 | } |
---|
248 | } |
---|
249 | { |
---|
250 | String[] tempString = new String[3]; |
---|
251 | tempString[0] = "TOP"; |
---|
252 | tempString[1] = "MIDDLE"; |
---|
253 | tempString[2] = "BOTTOM"; |
---|
254 | for(int i=0; i < tempString.length; i++) { |
---|
255 | vertCBModel.addElement(tempString[i]); |
---|
256 | } |
---|
257 | } |
---|
258 | { |
---|
259 | String[] tempString = new String[3]; |
---|
260 | tempString[0] = "POSITIVE_SIDE"; |
---|
261 | tempString[1] = "NEGATIVE_SIDE"; |
---|
262 | tempString[2] = "NO_LABEL"; |
---|
263 | for(int i=0; i < tempString.length; i++) { |
---|
264 | positionCBModel.addElement(tempString[i]); |
---|
265 | } |
---|
266 | } |
---|
267 | { |
---|
268 | String[] tempString = new String[3]; |
---|
269 | tempString[0] = "POSITIVE_SIDE"; |
---|
270 | tempString[1] = "NEGATIVE_SIDE"; |
---|
271 | tempString[2] = "BOTH_SIDES"; |
---|
272 | for(int i=0; i < tempString.length; i++) { |
---|
273 | ticPositionCBModel.addElement(tempString[i]); |
---|
274 | } |
---|
275 | } |
---|
276 | positionComboBox.setSelectedIndex(1); |
---|
277 | ticPositionComboBox.setSelectedIndex(1); |
---|
278 | setTitle("TimeAxis"); |
---|
279 | |
---|
280 | SymWindow aSymWindow = new SymWindow(); |
---|
281 | this.addWindowListener(aSymWindow); |
---|
282 | SymAction lSymAction = new SymAction(); |
---|
283 | cancelButton.addActionListener(lSymAction); |
---|
284 | okButton.addActionListener(lSymAction); |
---|
285 | fontEditor.addActionListener(lSymAction); |
---|
286 | applyButton.addActionListener(lSymAction); |
---|
287 | minUserTextField.addActionListener(lSymAction); |
---|
288 | maxUserTextField.addActionListener(lSymAction); |
---|
289 | widthPhysicalTextField.addActionListener(lSymAction); |
---|
290 | |
---|
291 | // Insets pup = new Insets(0, 0, 0, 0); |
---|
292 | // fontEditor.setMargin(pup); |
---|
293 | } |
---|
294 | /** Used internally. */ |
---|
295 | public void addNotify() { |
---|
296 | // Record the size of the window prior to calling parents addNotify. |
---|
297 | Dimension d = getSize(); |
---|
298 | |
---|
299 | super.addNotify(); |
---|
300 | |
---|
301 | if (fComponentsAdjusted) |
---|
302 | return; |
---|
303 | |
---|
304 | // Adjust components according to the insets |
---|
305 | Insets ins = getInsets(); |
---|
306 | setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); |
---|
307 | Component components[] = getContentPane().getComponents(); |
---|
308 | for (int i = 0; i < components.length; i++) { |
---|
309 | Point p = components[i].getLocation(); |
---|
310 | p.translate(ins.left, ins.top); |
---|
311 | components[i].setLocation(p); |
---|
312 | } |
---|
313 | fComponentsAdjusted = true; |
---|
314 | } |
---|
315 | |
---|
316 | // Used for addNotify check. |
---|
317 | boolean fComponentsAdjusted = false; |
---|
318 | /** |
---|
319 | * Constructor. |
---|
320 | */ |
---|
321 | public RulerDialog(String title) { |
---|
322 | this(); |
---|
323 | setTitle(title); |
---|
324 | } |
---|
325 | /** |
---|
326 | * Default constructor. |
---|
327 | */ |
---|
328 | public RulerDialog() { |
---|
329 | this((Frame)null); |
---|
330 | } |
---|
331 | /** |
---|
332 | * Make the dialog visible |
---|
333 | */ |
---|
334 | public void setVisible(boolean b) { |
---|
335 | if(b) { |
---|
336 | setLocation(50, 50); |
---|
337 | } |
---|
338 | super.setVisible(b); |
---|
339 | } |
---|
340 | |
---|
341 | class SymWindow extends java.awt.event.WindowAdapter { |
---|
342 | public void windowClosing(java.awt.event.WindowEvent event) { |
---|
343 | Object object = event.getSource(); |
---|
344 | if (object == RulerDialog.this) |
---|
345 | FontDialog_WindowClosing(event); |
---|
346 | } |
---|
347 | } |
---|
348 | |
---|
349 | void FontDialog_WindowClosing(java.awt.event.WindowEvent event) { |
---|
350 | dispose(); |
---|
351 | } |
---|
352 | |
---|
353 | //{{DECLARE_CONTROLS |
---|
354 | javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); |
---|
355 | javax.swing.JButton okButton = new javax.swing.JButton(); |
---|
356 | javax.swing.JButton applyButton = new javax.swing.JButton(); |
---|
357 | javax.swing.JButton cancelButton = new javax.swing.JButton(); |
---|
358 | javax.swing.border.EtchedBorder etchedBorder1 = new javax.swing.border.EtchedBorder(); |
---|
359 | javax.swing.JTabbedPane TabbedPane = new javax.swing.JTabbedPane(); |
---|
360 | javax.swing.JPanel labelPanel = new javax.swing.JPanel(); |
---|
361 | javax.swing.JLabel JLabel3 = new javax.swing.JLabel(); |
---|
362 | javax.swing.JTextField intervalTextField = new javax.swing.JTextField(); |
---|
363 | javax.swing.JLabel JLabel4 = new javax.swing.JLabel(); |
---|
364 | javax.swing.JTextField sigDigitsTextField = new javax.swing.JTextField(); |
---|
365 | javax.swing.JLabel JLabel5 = new javax.swing.JLabel(); |
---|
366 | javax.swing.JTextField formatTextField = new javax.swing.JTextField(); |
---|
367 | javax.swing.JLabel JLabel11 = new javax.swing.JLabel(); |
---|
368 | ColorEntryPanel textColorPanel = new ColorEntryPanel(); |
---|
369 | javax.swing.JLabel JLabel15 = new javax.swing.JLabel(); |
---|
370 | javax.swing.JPanel fontPanel = new javax.swing.JPanel(); |
---|
371 | javax.swing.JLabel fontLabel = new javax.swing.JLabel(); |
---|
372 | ThreeDotsButton fontEditor = new ThreeDotsButton(); |
---|
373 | javax.swing.JLabel JLabel16 = new javax.swing.JLabel(); |
---|
374 | javax.swing.JTextField heightTextField = new javax.swing.JTextField(); |
---|
375 | javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); |
---|
376 | javax.swing.JComboBox positionComboBox = new javax.swing.JComboBox(); |
---|
377 | javax.swing.JPanel rangePanel = new javax.swing.JPanel(); |
---|
378 | javax.swing.JPanel userPanel = new javax.swing.JPanel(); |
---|
379 | javax.swing.JLabel JLabel8 = new javax.swing.JLabel(); |
---|
380 | javax.swing.JTextField minUserTextField = new javax.swing.JTextField(); |
---|
381 | javax.swing.JLabel JLabel9 = new javax.swing.JLabel(); |
---|
382 | javax.swing.JTextField maxUserTextField = new javax.swing.JTextField(); |
---|
383 | javax.swing.JLabel JLabel2 = new javax.swing.JLabel(); |
---|
384 | javax.swing.JTextField incUserTextField = new javax.swing.JTextField(); |
---|
385 | javax.swing.JPanel physicalPanel = new javax.swing.JPanel(); |
---|
386 | javax.swing.JLabel JLabel10 = new javax.swing.JLabel(); |
---|
387 | javax.swing.JTextField xPhysicalTextField = new javax.swing.JTextField(); |
---|
388 | javax.swing.JLabel JLabel17 = new javax.swing.JLabel(); |
---|
389 | javax.swing.JTextField yPhysicalTextField = new javax.swing.JTextField(); |
---|
390 | javax.swing.JLabel originLabel = new javax.swing.JLabel(); |
---|
391 | javax.swing.JTextField widthPhysicalTextField = new javax.swing.JTextField(); |
---|
392 | javax.swing.JPanel ticsStylePanel = new javax.swing.JPanel(); |
---|
393 | javax.swing.JPanel ticsPanel = new javax.swing.JPanel(); |
---|
394 | javax.swing.JLabel JLabel18 = new javax.swing.JLabel(); |
---|
395 | javax.swing.JTextField largeTicTextField = new javax.swing.JTextField(); |
---|
396 | javax.swing.JLabel JLabel19 = new javax.swing.JLabel(); |
---|
397 | javax.swing.JTextField smallTicTextField = new javax.swing.JTextField(); |
---|
398 | javax.swing.JLabel JLabel20 = new javax.swing.JLabel(); |
---|
399 | javax.swing.JTextField numSmallTicsTextField = new javax.swing.JTextField(); |
---|
400 | javax.swing.JLabel JLabel21 = new javax.swing.JLabel(); |
---|
401 | javax.swing.JComboBox ticPositionComboBox = new javax.swing.JComboBox(); |
---|
402 | javax.swing.JPanel stylePanel = new javax.swing.JPanel(); |
---|
403 | javax.swing.JLabel JLabel7 = new javax.swing.JLabel(); |
---|
404 | javax.swing.JCheckBox axislVisibleCheckBox = new javax.swing.JCheckBox(); |
---|
405 | javax.swing.JLabel JLabel6 = new javax.swing.JLabel(); |
---|
406 | javax.swing.JCheckBox axisSelectableCheckBox = new javax.swing.JCheckBox(); |
---|
407 | DefaultComboBoxModel horizCBModel = new DefaultComboBoxModel(); |
---|
408 | DefaultComboBoxModel vertCBModel = new DefaultComboBoxModel(); |
---|
409 | DefaultComboBoxModel positionCBModel = new DefaultComboBoxModel(); |
---|
410 | javax.swing.border.TitledBorder userBorder = new javax.swing.border.TitledBorder("User Range"); |
---|
411 | javax.swing.border.TitledBorder physicalBorder = new javax.swing.border.TitledBorder("Physical Range"); |
---|
412 | javax.swing.border.TitledBorder ticsBorder = new javax.swing.border.TitledBorder("Tics"); |
---|
413 | javax.swing.border.TitledBorder styleBorder = new javax.swing.border.TitledBorder("Axis Style"); |
---|
414 | DefaultComboBoxModel ticPositionCBModel = new DefaultComboBoxModel(); |
---|
415 | private ColorEntryPanel lineColorPanel = new ColorEntryPanel(); |
---|
416 | private JLabel jLabel1 = new JLabel(); |
---|
417 | private JLabel jLabel5 = new JLabel(); |
---|
418 | private JTextField heightPhysicalTextField = new JTextField(); |
---|
419 | |
---|
420 | class SymAction implements java.awt.event.ActionListener { |
---|
421 | public void actionPerformed(java.awt.event.ActionEvent event) { |
---|
422 | Object object = event.getSource(); |
---|
423 | if (object == cancelButton) |
---|
424 | cancelButton_actionPerformed(event); |
---|
425 | else if (object == okButton) |
---|
426 | okButton_actionPerformed(event); |
---|
427 | else if (object == fontEditor) |
---|
428 | fontEditor_actionPerformed(event); |
---|
429 | else if (object == applyButton) |
---|
430 | applyButton_actionPerformed(event); |
---|
431 | } |
---|
432 | } |
---|
433 | |
---|
434 | void cancelButton_actionPerformed(java.awt.event.ActionEvent event) { |
---|
435 | this.setVisible(false); |
---|
436 | } |
---|
437 | |
---|
438 | void okButton_actionPerformed(java.awt.event.ActionEvent event) { |
---|
439 | updateRuler(); |
---|
440 | this.setVisible(false); |
---|
441 | } |
---|
442 | |
---|
443 | void applyButton_actionPerformed(java.awt.event.ActionEvent event) { |
---|
444 | updateRuler(); |
---|
445 | } |
---|
446 | /** |
---|
447 | * Test entry point |
---|
448 | */ |
---|
449 | public static void main(String[] args) { |
---|
450 | RulerDialog la = new RulerDialog(); |
---|
451 | la.setFont(null); |
---|
452 | la.setTitle("Test Ruler Dialog"); |
---|
453 | la.setVisible(true); |
---|
454 | } |
---|
455 | /** |
---|
456 | * Set the <code>Ruler</code> to be edited and the |
---|
457 | * <code>JPane</code> |
---|
458 | */ |
---|
459 | public void setRuler(Ruler scale, JPane pane) { |
---|
460 | setJPane(pane); |
---|
461 | setRuler(scale); |
---|
462 | } |
---|
463 | /** |
---|
464 | * Set the <code>Ruler</code> to be edited |
---|
465 | */ |
---|
466 | public void setRuler(Ruler scale) { |
---|
467 | scale_ = scale; |
---|
468 | setRuler(); |
---|
469 | } |
---|
470 | /** |
---|
471 | * Get the edited <code>Ruler</code> |
---|
472 | */ |
---|
473 | public Ruler getRuler() { |
---|
474 | return scale_; |
---|
475 | } |
---|
476 | /** |
---|
477 | * Set the parent <code>JPane</code>. |
---|
478 | */ |
---|
479 | public void setJPane(JPane pane) { |
---|
480 | pane_ = pane; |
---|
481 | } |
---|
482 | /** |
---|
483 | * Get the parent <code>JPane</code>. |
---|
484 | */ |
---|
485 | public JPane getJPane() { |
---|
486 | return pane_; |
---|
487 | } |
---|
488 | |
---|
489 | private void setRuler() { |
---|
490 | // |
---|
491 | // time axis ID |
---|
492 | // |
---|
493 | setTitle("Ruler - " + scale_.getId()); |
---|
494 | // |
---|
495 | // label |
---|
496 | // |
---|
497 | intervalTextField.setText(Integer.toString(scale_.getLabelInterval())); |
---|
498 | sigDigitsTextField.setText(Integer.toString(scale_.getSignificantDigits())); |
---|
499 | formatTextField.setText(scale_.getLabelFormat()); |
---|
500 | |
---|
501 | Color col = scale_.getLabelColor(); |
---|
502 | if(col == null) col = pane_.getComponent().getForeground(); |
---|
503 | textColorPanel.setColor(col); |
---|
504 | |
---|
505 | labelFont_ = scale_.getLabelFont(); |
---|
506 | if(labelFont_ == null) labelFont_ = pane_.getComponent().getFont(); |
---|
507 | fontLabel.setText(fontString(labelFont_)); |
---|
508 | |
---|
509 | heightTextField.setText(String.valueOf(scale_.getLabelHeightP())); |
---|
510 | // |
---|
511 | // range |
---|
512 | // |
---|
513 | Range2D urange = scale_.getRangeU(); |
---|
514 | minUserTextField.setText(String.valueOf(urange.start)); |
---|
515 | maxUserTextField.setText(String.valueOf(urange.end)); |
---|
516 | incUserTextField.setText(String.valueOf(urange.delta)); |
---|
517 | Rectangle2D.Double bounds = scale_.getBoundsP(); |
---|
518 | // Range2D range = sa_.getRangeP(); |
---|
519 | xPhysicalTextField.setText(String.valueOf(bounds.x)); |
---|
520 | yPhysicalTextField.setText(String.valueOf(bounds.y)); |
---|
521 | widthPhysicalTextField.setText(String.valueOf(bounds.width)); |
---|
522 | heightPhysicalTextField.setText(String.valueOf(bounds.height)); |
---|
523 | // Point2D.Double pt = sa_.getLocationU(); |
---|
524 | // TimePoint tt = null; |
---|
525 | // double point = 0.0; |
---|
526 | |
---|
527 | // if(pt == null) { |
---|
528 | // originIsGeoDate_ = true; |
---|
529 | // tt = sa_.getTimeLocationU(); |
---|
530 | // tOrigin_ = tt.t; |
---|
531 | // } else { |
---|
532 | // originIsGeoDate_ = false; |
---|
533 | // if(sa_.getOrientation() == Axis.HORIZONTAL) { |
---|
534 | // point = pt.y; |
---|
535 | // } else { |
---|
536 | // point = pt.x; |
---|
537 | // } |
---|
538 | // } |
---|
539 | |
---|
540 | if(scale_.getOrientation() == Axis.HORIZONTAL) { |
---|
541 | originLabel.setText("Y Origin:"); |
---|
542 | } else { |
---|
543 | originLabel.setText("X Origin:"); |
---|
544 | } |
---|
545 | // if(originIsGeoDate_) { |
---|
546 | // originDateEditor.setEnabled(true); |
---|
547 | // originTextField.setText(tOrigin_.toString()); |
---|
548 | // } else { |
---|
549 | // originDateEditor.setEnabled(false); |
---|
550 | // originTextField.setText(String.valueOf(point)); |
---|
551 | // } |
---|
552 | // |
---|
553 | // tics |
---|
554 | // |
---|
555 | largeTicTextField.setText(String.valueOf(scale_.getLargeTicHeightP())); |
---|
556 | smallTicTextField.setText(String.valueOf(scale_.getSmallTicHeightP())); |
---|
557 | numSmallTicsTextField.setText(String.valueOf(scale_.getNumberSmallTics())); |
---|
558 | ticPositionComboBox.setSelectedIndex(scale_.getTicPosition()); |
---|
559 | |
---|
560 | Color lcol = scale_.getLineColor(); |
---|
561 | if(lcol == null) col = pane_.getComponent().getForeground(); |
---|
562 | lineColorPanel.setColor(col); |
---|
563 | |
---|
564 | // |
---|
565 | // axis style |
---|
566 | // |
---|
567 | axislVisibleCheckBox.setSelected(scale_.isVisible()); |
---|
568 | axisSelectableCheckBox.setSelected(scale_.isSelectable()); |
---|
569 | // |
---|
570 | // attachments |
---|
571 | // |
---|
572 | // boolean test = sa_.getNumberRegisteredTransforms() > 0; |
---|
573 | // transformCheckBox.setSelected(test); |
---|
574 | |
---|
575 | // if(sa_.getOrientation() == Axis.HORIZONTAL) { |
---|
576 | //// test = sa_.getGraph().getNumberXAxis() >= 2; |
---|
577 | // axisLabel.setEnabled(test); |
---|
578 | // axisCheckBox.setEnabled(test); |
---|
579 | // axisLabel.setText("Attach X Axis to Axis:"); |
---|
580 | // test = sa_.getNumberRegisteredAxes() > 0; |
---|
581 | // axisCheckBox.setSelected(test); |
---|
582 | // } else { |
---|
583 | // test = sa_.getGraph().getNumberYAxis() >= 2; |
---|
584 | // axisLabel.setEnabled(test); |
---|
585 | // axisCheckBox.setEnabled(test); |
---|
586 | // axisLabel.setText("Attach Y Axis to Axis:"); |
---|
587 | // test = sa_.getNumberRegisteredAxes() > 0; |
---|
588 | // axisCheckBox.setSelected(test); |
---|
589 | // } |
---|
590 | |
---|
591 | } |
---|
592 | |
---|
593 | private void updateRuler() { |
---|
594 | pane_.setBatch(true, "RulerDialog"); |
---|
595 | // |
---|
596 | // label |
---|
597 | // |
---|
598 | scale_.setLabelInterval(Integer.parseInt(intervalTextField.getText())); |
---|
599 | scale_.setSignificantDigits(Integer.parseInt(sigDigitsTextField.getText())); |
---|
600 | scale_.setLabelFormat(formatTextField.getText()); |
---|
601 | |
---|
602 | scale_.setLabelColor(textColorPanel.getColor()); |
---|
603 | if(labelFont_ != null) scale_.setLabelFont(labelFont_); |
---|
604 | |
---|
605 | scale_.setLabelHeightP(Double.valueOf(heightTextField.getText()).doubleValue()); |
---|
606 | scale_.setLabelPosition(positionComboBox.getSelectedIndex()); |
---|
607 | // |
---|
608 | // range |
---|
609 | // |
---|
610 | double min = Double.valueOf(minUserTextField.getText()).doubleValue(); |
---|
611 | double max = Double.valueOf(maxUserTextField.getText()).doubleValue(); |
---|
612 | double inc = Double.valueOf(incUserTextField.getText()).doubleValue(); |
---|
613 | scale_.setRangeU(new Range2D(min, max, inc)); |
---|
614 | double x = Double.valueOf(xPhysicalTextField.getText()).doubleValue(); |
---|
615 | double y = Double.valueOf(yPhysicalTextField.getText()).doubleValue(); |
---|
616 | double width = Double.valueOf(widthPhysicalTextField.getText()).doubleValue(); |
---|
617 | double height = Double.valueOf(heightPhysicalTextField.getText()).doubleValue(); |
---|
618 | scale_.setBoundsP(new Rectangle2D.Double(x, y, width, height)); |
---|
619 | // sa_.setRangeP(new Range2D(min, max)); |
---|
620 | // if(originIsGeoDate_) { |
---|
621 | // TimePoint pt = sa_.getTimeLocationU(); |
---|
622 | // pt.t = tOrigin_; |
---|
623 | // sa_.setLocationU(pt); |
---|
624 | // } else { |
---|
625 | // Point2D.Double pt = sa_.getLocationU(); |
---|
626 | // if(sa_.getOrientation() == Axis.HORIZONTAL) { |
---|
627 | // pt.y = Double.valueOf(originTextField.getText()).doubleValue(); |
---|
628 | // } else { |
---|
629 | // pt.x = Double.valueOf(originTextField.getText()).doubleValue(); |
---|
630 | // } |
---|
631 | // sa_.setLocationU(pt); |
---|
632 | // } |
---|
633 | // |
---|
634 | // tics |
---|
635 | // |
---|
636 | scale_.setLargeTicHeightP(Double.valueOf(largeTicTextField.getText()).doubleValue()); |
---|
637 | scale_.setSmallTicHeightP(Double.valueOf(smallTicTextField.getText()).doubleValue()); |
---|
638 | scale_.setNumberSmallTics(Integer.parseInt(numSmallTicsTextField.getText())); |
---|
639 | scale_.setTicPosition(ticPositionComboBox.getSelectedIndex()); |
---|
640 | |
---|
641 | scale_.setLineColor(lineColorPanel.getColor()); |
---|
642 | // |
---|
643 | // axis style |
---|
644 | // |
---|
645 | scale_.setVisible(axislVisibleCheckBox.isSelected()); |
---|
646 | scale_.setSelectable(axisSelectableCheckBox.isSelected()); |
---|
647 | // |
---|
648 | // attach |
---|
649 | // |
---|
650 | // boolean test; |
---|
651 | /* if(transformCheckBox.isSelected() && (sa_.getNumberRegisteredTransforms() < 1)) { |
---|
652 | if(sa_.getOrientation() == Axis.HORIZONTAL) { |
---|
653 | sa_.register(sa_.getGraph().getXTransform()); |
---|
654 | } else { |
---|
655 | sa_.register(sa_.getGraph().getYTransform()); |
---|
656 | } |
---|
657 | } else { |
---|
658 | if(sa_.getNumberRegisteredTransforms() > 0) sa_.clearAllRegisteredTransforms(); |
---|
659 | } |
---|
660 | if(sa_.getOrientation() == Axis.HORIZONTAL) { |
---|
661 | test = (sa_.getGraph().getNumberXAxis() >= 2) && |
---|
662 | (sa_.getNumberRegisteredAxes() < 1); |
---|
663 | if(axisCheckBox.isSelected() && test) { |
---|
664 | Axis ax; |
---|
665 | for(Enumeration it = sa_.getGraph().xAxisElements(); |
---|
666 | it.hasMoreElements();) { |
---|
667 | ax = (Axis)it.nextElement(); |
---|
668 | if(ax.getId() != sa_.getId()) sa_.register(ax); |
---|
669 | } |
---|
670 | } else { |
---|
671 | if(sa_.getNumberRegisteredAxes() > 0) sa_.clearAllRegisteredAxes(); |
---|
672 | } |
---|
673 | } else { // vertical axis |
---|
674 | test = (sa_.getGraph().getNumberYAxis() >= 2) && |
---|
675 | (sa_.getNumberRegisteredAxes() < 1); |
---|
676 | if(axisCheckBox.isSelected() && test) { |
---|
677 | Axis ax; |
---|
678 | for(Enumeration it = sa_.getGraph().yAxisElements(); |
---|
679 | it.hasMoreElements();) { |
---|
680 | ax = (Axis)it.nextElement(); |
---|
681 | if(ax.getId() != sa_.getId()) sa_.register(ax); |
---|
682 | } |
---|
683 | } else { |
---|
684 | if(sa_.getNumberRegisteredAxes() > 0) sa_.clearAllRegisteredAxes(); |
---|
685 | } |
---|
686 | } */ |
---|
687 | |
---|
688 | pane_.setBatch(false, "RulerDialog"); |
---|
689 | } |
---|
690 | |
---|
691 | void fontEditor_actionPerformed(java.awt.event.ActionEvent event) { |
---|
692 | FontDialog fd = new FontDialog(); |
---|
693 | int result = fd.showDialog(labelFont_); |
---|
694 | if(result == FontDialog.OK_RESPONSE) { |
---|
695 | labelFont_ = fd.getFont(); |
---|
696 | fontLabel.setText(fontString(labelFont_)); |
---|
697 | fontLabel.setFont(labelFont_); |
---|
698 | } |
---|
699 | } |
---|
700 | |
---|
701 | String fontString(Font font) { |
---|
702 | int style = (font.isBold()?1:0) + (font.isItalic()?2:0); |
---|
703 | return font.getName() + " " + styleNames_[style]; |
---|
704 | } |
---|
705 | |
---|
706 | |
---|
707 | // void widthPhysicalTextField_actionPerformed(java.awt.event.ActionEvent event) { |
---|
708 | /* if(originIsGeoDate_) { |
---|
709 | try { |
---|
710 | tOrigin_ = new GeoDate(originTextField.getText(), dateFormat_); |
---|
711 | } catch (IllegalTimeValue e) { |
---|
712 | originTextField.setText(tOrigin_.toString()); |
---|
713 | } |
---|
714 | } */ |
---|
715 | // } |
---|
716 | |
---|
717 | // void originDateEditor_actionPerformed(java.awt.event.ActionEvent event) { |
---|
718 | /* GeoDateDialog gd = new GeoDateDialog(); |
---|
719 | Point loc = originDateEditor.getLocationOnScreen(); |
---|
720 | int result = gd.showDialog(tOrigin_, loc.x, loc.y); |
---|
721 | if(result == GeoDateDialog.OK_RESPONSE) { |
---|
722 | tOrigin_ = gd.getGeoDate(); |
---|
723 | originTextField.setText(tOrigin_.toString()); |
---|
724 | } */ |
---|
725 | // } |
---|
726 | } |
---|