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 import de.desy.acop.chart.AcopDrawStyleEnum;
35 import de.desy.acop.chart.AcopGraphStyleEnum;
36
37 public class GraphCustomizerPanel extends JPanel implements Customizer
38 {
39 public static final String[] GRAPH_PROPERTIES = {
40 "YGrid","XGrid","gridWidth","gridStyle","drawWidth","drawStyle","graphStyle"
41 };
42 private Acop acopBean;
43 private JLabel drawParametersLabel = null;
44 private JLabel graphLabel = null;
45 private AcopJComBox graphStyleBox;
46 private JLabel drawStyleLabel = null;
47 private AcopJComBox drawStyleBox;
48 private JLabel drawWidthLabel = null;
49 private AcopJFormattedTextField drawWidthText;
50
51 private JLabel gridParametersLabel = null;
52 private JLabel gridStyleLabel = null;
53 private AcopJComBox gridStyleBox;
54 private JLabel gridWidthLabel = null;
55 private AcopJFormattedTextField gridWidthText;
56 private AcopJRadioButton xgrid, ygrid;
57
58 public GraphCustomizerPanel(LayoutManager layout, boolean isDoubleBuffered)
59 {
60 super(layout, isDoubleBuffered);
61
62 initialize();
63 }
64 public GraphCustomizerPanel(LayoutManager layout)
65 {
66 super(layout);
67
68 initialize();
69 }
70 public GraphCustomizerPanel(boolean isDoubleBuffered)
71 {
72 super(isDoubleBuffered);
73
74 initialize();
75 }
76 public GraphCustomizerPanel()
77 {
78 super();
79
80 initialize();
81 }
82
83
84
85 public static void main(String[] args)
86 {
87
88 }
89
90
91
92
93
94 private void initialize()
95 {
96 GridBagConstraints gCon;
97 setLayout(new GridBagLayout());
98 if (drawParametersLabel == null)
99 {
100 drawParametersLabel = new JLabel("-- Draw Parameters --");
101 }
102 if (graphLabel == null)
103 {
104 graphLabel = new JLabel("Graph:");
105 }
106 if (drawStyleLabel == null)
107 {
108 drawStyleLabel = new JLabel("Style:");
109 }
110 if (drawWidthLabel == null)
111 {
112 drawWidthLabel = new JLabel("Width:");
113 }
114
115 if (gridParametersLabel == null)
116 {
117 gridParametersLabel = new JLabel("-- Grid Parameters --");
118 }
119 if (gridStyleLabel == null)
120 {
121 gridStyleLabel = new JLabel("Style:");
122 }
123 if (gridWidthLabel == null)
124 {
125 gridWidthLabel = new JLabel("Width:");
126 }
127
128 add(drawParametersLabel, new GridBagConstraints(0, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
129 GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
130
131 add(graphLabel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
132 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
133 graphStyleBox = new AcopJComBox("GraphStyle", AcopGraphStyleEnum.values());
134 add(graphStyleBox, new GridBagConstraints(1, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
135 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
136
137 add(drawStyleLabel, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
138 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
139 drawStyleBox = new AcopJComBox("DrawStyle", AcopDrawStyleEnum.values());
140 add(drawStyleBox, new GridBagConstraints(1, 2, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
141 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
142
143 add(drawWidthLabel, new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
144 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
145 drawWidthText = new AcopJFormattedTextField("10", "DrawWidth", int.class);
146 add(drawWidthText, new GridBagConstraints(1, 3, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
147 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
148
149 add(gridParametersLabel, new GridBagConstraints(4, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
150 GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
151 add(gridStyleLabel, new GridBagConstraints(4, 1, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
152 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
153 gridStyleBox = new AcopJComBox("GridStyle", AcopDrawStyleEnum.values());
154 add(gridStyleBox, new GridBagConstraints(5, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
155 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
156
157 add(gridWidthLabel, new GridBagConstraints(4, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
158 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
159 gridWidthText = new AcopJFormattedTextField("1", "GridWidth", int.class);
160 add(gridWidthText, new GridBagConstraints(5, 2, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
161 GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
162
163 xgrid = new AcopJRadioButton("X-Grid", "XGrid", "xGrid");
164 add(xgrid, new GridBagConstraints(4, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
165 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
166 ygrid = new AcopJRadioButton("Y-Grid", "YGrid", "yGrid");
167 add(ygrid, new GridBagConstraints(5, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
168 GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
169
170
171 this.setSize(396, 218);
172 }
173 public void setAcopBean(Acop acopBean)
174 {
175 this.acopBean = acopBean;
176 graphStyleBox.setAcopBean(acopBean);
177 drawStyleBox.setAcopBean(acopBean);
178 drawWidthText.setAcopBean(acopBean);
179 gridStyleBox.setAcopBean(acopBean);
180 gridWidthText.setAcopBean(acopBean);
181 xgrid.setAcopBean(acopBean);
182 ygrid.setAcopBean(acopBean);
183 }
184
185 public void setObject(Object bean) {
186 setAcopBean((Acop)bean);
187
188 }
189
190 }