1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package de.desy.acop.chart.customizer;
24
25 import java.awt.GridBagConstraints;
26 import java.awt.GridBagLayout;
27 import java.awt.Insets;
28 import java.awt.LayoutManager;
29 import java.beans.Customizer;
30
31 import javax.swing.JLabel;
32 import javax.swing.JPanel;
33 import de.desy.acop.chart.Acop;
34
35 public class AxisCustomizerPanel extends JPanel implements Customizer
36 {
37
38 public static final String[] AXIS_PROPERTIES = {
39 "secondaryYTickText","secondaryYFineTicks","secondaryYTicks","secondaryYBestScale","secondaryYLogOn",
40 "secondaryYAxisOn","secondaryYMax","secondaryYMin","secondaryYAxisLabel","YTickText","YFineTicks",
41 "YTicks","leftYLabel","YBestScale","YScale","YShift","YMax","YMin","YAxisLabel","XTickText","XFineTicks",
42 "XTicks","leftTimeLabel","bottomXLabel","XBestScale","XScale","XShift","XMax","XMin","XAxisLabel"
43 };
44 private Acop acopBean;
45 private JLabel xAxisLabel = null;
46 private JLabel xLabel = null;
47 private AcopJFormattedTextField xLabelText;
48 private JLabel xMinLabel, xMaxLabel, xShiftLabel, xScaleLabel;
49 private AcopJFormattedTextField xMinText, xMaxText, xShiftText, xScaleText;
50 private AcopJRadioButton xBestScale, xBottomLabel, xLeftTime;
51 private JLabel xTickLabel = null;
52 private JLabel xTicksLabel, xFTicksLabel;
53 private AcopJFormattedTextField xTickText, xFTickText;
54 private AcopJRadioButton xTickTextButton;
55
56 private JLabel yAxisLabel = null;
57 private JLabel yLabel = null;
58 private AcopJFormattedTextField yLabelText;
59 private JLabel yMinLabel, yMaxLabel, yShiftLabel, yScaleLabel;
60 private AcopJFormattedTextField yMinText, yMaxText, yShiftText, yScaleText;
61 private AcopJRadioButton yBestScale, yLeftLabel;
62 private JLabel yTickLabel = null;
63 private JLabel yTicksLabel, yFTicksLabel;
64 private AcopJFormattedTextField yTickText, yFTickText;
65 private AcopJRadioButton yTickTextButton;
66
67 private JLabel y2AxisLabel = null;
68 private JLabel y2Label = null;
69 private AcopJFormattedTextField y2LabelText;
70 private JLabel y2MinLabel, y2MaxLabel;
71 private AcopJFormattedTextField y2MinText, y2MaxText;
72 private AcopJRadioButton y2AxisOn, y2LogOn;
73 private AcopJRadioButton y2BestScale;
74 private JLabel y2TickLabel = null;
75 private JLabel y2TicksLabel, y2FTicksLabel;
76 private AcopJFormattedTextField y2TickText, y2FTickText;
77 private AcopJRadioButton y2TickTextButton;
78
79 public AxisCustomizerPanel(LayoutManager layout, boolean isDoubleBuffered)
80 {
81 super(layout, isDoubleBuffered);
82
83 initialize();
84 }
85 public AxisCustomizerPanel(LayoutManager layout)
86 {
87 super(layout);
88
89 initialize();
90 }
91 public AxisCustomizerPanel(boolean isDoubleBuffered)
92 {
93 super(isDoubleBuffered);
94
95 initialize();
96 }
97 public AxisCustomizerPanel()
98 {
99 super();
100
101 initialize();
102 }
103
104
105
106 public static void main(String[] args)
107 {
108
109 }
110
111
112
113
114
115 private void initialize()
116 {
117 GridBagConstraints gCon;
118 setLayout(new GridBagLayout());
119 if (xAxisLabel == null)
120 {
121 xAxisLabel = new JLabel("-- X-Axis --");
122 }
123 if (xLabel == null)
124 {
125 xLabel = new JLabel("Label:");
126 }
127 if (xMinLabel == null)
128 {
129 xMinLabel = new JLabel("Min:");
130 }
131 if (xMaxLabel == null)
132 {
133 xMaxLabel = new JLabel("Max:");
134 }
135 if (xShiftLabel == null)
136 {
137 xShiftLabel = new JLabel("Shift:");
138 }
139 if (xScaleLabel == null)
140 {
141 xScaleLabel = new JLabel("Scale:");
142 }
143 if (xTickLabel == null)
144 {
145 xTickLabel = new JLabel("-- Ticks --");
146 }
147 if (xTicksLabel == null)
148 {
149 xTicksLabel = new JLabel("C:");
150 }
151 if (xFTicksLabel == null)
152 {
153 xFTicksLabel = new JLabel("F:");
154 }
155
156 if (yAxisLabel == null)
157 {
158 yAxisLabel = new JLabel("-- Y-Axis --");
159 }
160 if (yLabel == null)
161 {
162 yLabel = new JLabel("Label:");
163 }
164 if (yMinLabel == null)
165 {
166 yMinLabel = new JLabel("Min:");
167 }
168 if (yMaxLabel == null)
169 {
170 yMaxLabel = new JLabel("Max:");
171 }
172 if (yShiftLabel == null)
173 {
174 yShiftLabel = new JLabel("Shift:");
175 }
176 if (yScaleLabel == null)
177 {
178 yScaleLabel = new JLabel("Scale:");
179 }
180 if (yTickLabel == null)
181 {
182 yTickLabel = new JLabel("-- Ticks --");
183 }
184 if (yTicksLabel == null)
185 {
186 yTicksLabel = new JLabel("C:");
187 }
188 if (yFTicksLabel == null)
189 {
190 yFTicksLabel = new JLabel("F:");
191 }
192
193 if (y2AxisLabel == null)
194 {
195 y2AxisLabel = new JLabel("-- Secondary Y-Axis --");
196 }
197 if (y2Label == null)
198 {
199 y2Label = new JLabel("Label:");
200 }
201 if (y2MinLabel == null)
202 {
203 y2MinLabel = new JLabel("Min:");
204 }
205 if (y2MaxLabel == null)
206 {
207 y2MaxLabel = new JLabel("Max:");
208 }
209 if (y2TickLabel == null)
210 {
211 y2TickLabel = new JLabel("-- Ticks --");
212 }
213 if (y2TicksLabel == null)
214 {
215 y2TicksLabel = new JLabel("C:");
216 }
217 if (y2FTicksLabel == null)
218 {
219 y2FTicksLabel = new JLabel("F:");
220 }
221
222 add(xAxisLabel, new GridBagConstraints(0, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
223 GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
224 add(xLabel, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, GridBagConstraints.EAST,
225 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
226 xLabelText = new AcopJFormattedTextField("xAxis", "XAxisLabel", String.class);
227 add(xLabelText, new GridBagConstraints(2, 1, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER,
228 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
229
230 add(xMinLabel, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
231 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
232 xMinText = new AcopJFormattedTextField("1", "XMin", double.class);
233 add(xMinText, new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
234 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
235 add(xMaxLabel, new GridBagConstraints(2, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
236 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
237 xMaxText = new AcopJFormattedTextField("1", "XMax", double.class);
238 add(xMaxText, new GridBagConstraints(3, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
239 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
240 add(xShiftLabel, new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
241 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
242 xShiftText = new AcopJFormattedTextField("1", "XShift", double.class);
243 add(xShiftText, new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
244 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
245 add(xScaleLabel, new GridBagConstraints(2, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
246 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
247 xScaleText = new AcopJFormattedTextField("1", "XScale", double.class);
248 add(xScaleText, new GridBagConstraints(3, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
249 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
250
251 xBestScale = new AcopJRadioButton("Best Scale", "XBestScale", "xBestScale");
252 add(xBestScale, new GridBagConstraints(1, 4, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
253 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
254 xBottomLabel = new AcopJRadioButton("Bottom X Label", "BottomXLabel", "bottomXLabel");
255 add(xBottomLabel, new GridBagConstraints(2, 4, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
256 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
257 xLeftTime = new AcopJRadioButton("LeftTimeLabel", "LeftTimeLabel", "leftTimeLabel");
258 add(xLeftTime, new GridBagConstraints(3, 4, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
259 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
260 add(xTickLabel, new GridBagConstraints(0, 6, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
261 GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
262
263 add(xTicksLabel, new GridBagConstraints(0, 7, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
264 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
265 xTickText = new AcopJFormattedTextField("-1", "XTicks", int.class);
266 add(xTickText, new GridBagConstraints(1, 7, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
267 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
268 add(xFTicksLabel, new GridBagConstraints(2, 7, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
269 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
270 xFTickText = new AcopJFormattedTextField("-1", "XFineTicks", int.class);
271 add(xFTickText, new GridBagConstraints(3, 7, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
272 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
273 xTickTextButton = new AcopJRadioButton("TickText", "XTickText", "xTickText");
274 add(xTickTextButton, new GridBagConstraints(1, 8, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
275 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
276
277
278 add(yAxisLabel, new GridBagConstraints(4, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
279 GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
280 add(yLabel, new GridBagConstraints(4, 1, 2, 1, 1.0, 1.0, GridBagConstraints.EAST,
281 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
282 yLabelText = new AcopJFormattedTextField("yAxis", "YAxisLabel", String.class);
283 add(yLabelText, new GridBagConstraints(6, 1, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER,
284 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
285
286 add(yMinLabel, new GridBagConstraints(4, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
287 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
288 yMinText = new AcopJFormattedTextField("1", "YMin", double.class);
289 add(yMinText, new GridBagConstraints(5, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
290 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
291 add(yMaxLabel, new GridBagConstraints(6, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
292 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
293 yMaxText = new AcopJFormattedTextField("1", "YMax", double.class);
294 add(yMaxText, new GridBagConstraints(7, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
295 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
296 add(yShiftLabel, new GridBagConstraints(4, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
297 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
298 yShiftText = new AcopJFormattedTextField("1", "YShift", double.class);
299 add(yShiftText, new GridBagConstraints(5, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
300 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
301 add(yScaleLabel, new GridBagConstraints(6, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
302 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
303 yScaleText = new AcopJFormattedTextField("1", "YScale", double.class);
304 add(yScaleText, new GridBagConstraints(7, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
305 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
306
307 yBestScale = new AcopJRadioButton("Best Scale", "YBestScale", "yBestScale");
308 add(yBestScale, new GridBagConstraints(5, 4, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
309 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
310 yLeftLabel = new AcopJRadioButton("Left Y Label", "LeftYLabel", "leftYLabel");
311 add(yLeftLabel, new GridBagConstraints(7, 4, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
312 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
313 add(yTickLabel, new GridBagConstraints(4, 6, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
314 GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
315
316
317 add(yTicksLabel, new GridBagConstraints(4, 7, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
318 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
319 yTickText = new AcopJFormattedTextField("-1", "YTicks", int.class);
320 add(yTickText, new GridBagConstraints(5, 7, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
321 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
322 add(yFTicksLabel, new GridBagConstraints(6, 7, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
323 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
324 yFTickText = new AcopJFormattedTextField("-1", "YFineTicks", int.class);
325 add(yFTickText, new GridBagConstraints(7, 7, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
326 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
327 yTickTextButton = new AcopJRadioButton("TickText", "YTickText", "yTickText");
328 add(yTickTextButton, new GridBagConstraints(5, 8, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
329 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
330
331
332 add(y2AxisLabel, new GridBagConstraints(8, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
333 GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
334 add(y2Label, new GridBagConstraints(8, 1, 2, 1, 1.0, 1.0, GridBagConstraints.EAST,
335 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
336 y2LabelText = new AcopJFormattedTextField("secondaryYAxis", "SecondaryYAxisLabel", String.class);
337 add(y2LabelText, new GridBagConstraints(10, 1, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER,
338 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
339
340 add(y2MinLabel, new GridBagConstraints(8, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
341 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
342 y2MinText = new AcopJFormattedTextField("1", "SecondaryYMin", double.class);
343 add(y2MinText, new GridBagConstraints(9, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
344 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
345 add(y2MaxLabel, new GridBagConstraints(10, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
346 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
347 y2MaxText = new AcopJFormattedTextField("1", "SecondaryYMax", double.class);
348 add(y2MaxText, new GridBagConstraints(11, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
349 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
350
351 y2AxisOn = new AcopJRadioButton("Axis On", "SecondaryYAxisOn", "secondaryYAxisOn");
352 add(y2AxisOn, new GridBagConstraints(9, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
353 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
354 y2LogOn = new AcopJRadioButton("Log On", "SecondaryYLogOn", "secondaryYAxisOn");
355 add(y2LogOn, new GridBagConstraints(11, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
356 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
357
358 y2BestScale = new AcopJRadioButton("Best Scale", "SecondaryYBestScale", "secondaryYBestScale");
359 add(y2BestScale, new GridBagConstraints(9, 4, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
360 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
361 add(y2TickLabel, new GridBagConstraints(8, 6, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
362 GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
363
364 add(y2TicksLabel, new GridBagConstraints(8, 7, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
365 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
366 y2TickText = new AcopJFormattedTextField("-1", "SecondaryYTicks", int.class);
367 add(y2TickText, new GridBagConstraints(9, 7, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
368 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
369 add(y2FTicksLabel, new GridBagConstraints(10, 7, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
370 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
371 y2FTickText = new AcopJFormattedTextField("-1", "SecondaryYFineTicks", int.class);
372 add(y2FTickText, new GridBagConstraints(11, 7, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
373 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
374 y2TickTextButton = new AcopJRadioButton("TickText", "SecondaryYTickText", "secondaryYTickText");
375 add(y2TickTextButton, new GridBagConstraints(9, 8, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
376 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
377
378 this.setSize(300, 200);
379 }
380 public void setAcopBean(Acop acopBean)
381 {
382 this.acopBean = acopBean;
383 xLabelText.setAcopBean(acopBean);
384 xMinText.setAcopBean(acopBean);
385 xMaxText.setAcopBean(acopBean);
386 xShiftText.setAcopBean(acopBean);
387 xScaleText.setAcopBean(acopBean);
388 xBestScale.setAcopBean(acopBean);
389 xBottomLabel.setAcopBean(acopBean);
390 xLeftTime.setAcopBean(acopBean);
391 xTickText.setAcopBean(acopBean);
392 xFTickText.setAcopBean(acopBean);
393 xTickTextButton.setAcopBean(acopBean);
394
395 yLabelText.setAcopBean(acopBean);
396 yMinText.setAcopBean(acopBean);
397 yMaxText.setAcopBean(acopBean);
398 yShiftText.setAcopBean(acopBean);
399 yScaleText.setAcopBean(acopBean);
400 yBestScale.setAcopBean(acopBean);
401 yLeftLabel.setAcopBean(acopBean);
402 yTickText.setAcopBean(acopBean);
403 yFTickText.setAcopBean(acopBean);
404 yTickTextButton.setAcopBean(acopBean);
405
406 y2LabelText.setAcopBean(acopBean);
407 y2MinText.setAcopBean(acopBean);
408 y2MaxText.setAcopBean(acopBean);
409 y2BestScale.setAcopBean(acopBean);
410 y2AxisOn.setAcopBean(acopBean);
411 y2LogOn.setAcopBean(acopBean);
412 y2TickText.setAcopBean(acopBean);
413 y2FTickText.setAcopBean(acopBean);
414 y2TickTextButton.setAcopBean(acopBean);
415 }
416 public void setObject(Object bean) {
417 setAcopBean((Acop)bean);
418
419 }
420 }