View Javadoc

1   /*
2    * Copyright (c) 2006 Stiftung Deutsches Elektronen-Synchroton,
3    * Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY.
4    *
5    * THIS SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "../AS IS" BASIS.
6    * WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
7    * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR PARTICULAR PURPOSE AND
8    * NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
9    * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
10   * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
11   * THE USE OR OTHER DEALINGS IN THE SOFTWARE. SHOULD THE SOFTWARE PROVE DEFECTIVE
12   * IN ANY RESPECT, THE USER ASSUMES THE COST OF ANY NECESSARY SERVICING, REPAIR OR
13   * CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
14   * NO USE OF ANY SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
15   * DESY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
16   * OR MODIFICATIONS.
17   * THE FULL LICENSE SPECIFYING FOR THE SOFTWARE THE REDISTRIBUTION, MODIFICATION,
18   * USAGE AND OTHER RIGHTS AND OBLIGATIONS IS INCLUDED WITH THE DISTRIBUTION OF THIS
19   * PROJECT IN THE FILE LICENSE.HTML. IF THE LICENSE IS NOT INCLUDED YOU MAY FIND A COPY
20   * AT HTTP://WWW.DESY.DE/LEGAL/LICENSE.HTM
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.AcopCursorMarkerModeEnum;
35  import de.desy.acop.chart.AcopMarkerModeEnum;
36  
37  public class MarkersCustomizerPanel extends JPanel implements Customizer
38  {
39  	public static final String[] MARKERS_PROPERTIES = {
40  		"leadingEdgeYExtent","leadingEdgeXExtent","leadingEdgeWidth","leadingEdgeStyle",
41  		"leadingEdgeMode", "markerYExtent","markerXExtent","markerWidth",
42  		"markerStyle","markerMode"
43  	};
44    private Acop acopBean; // @jve:decl-index=0:visual-constraint="61,21"
45    private JLabel markerLabel = null;
46    private JLabel modeLabel = null;
47    private AcopJComBox modeBox;
48    private JLabel styleLabel = null;
49    private AcopJComBox styleBox;
50    private JLabel widthLabel = null;
51    private AcopJFormattedTextField widthText;
52    private JLabel extendXLabel, extendYLabel;
53    private AcopJFormattedTextField extXText, extYText;
54    
55    private JLabel cursorLabel = null;
56    private JLabel cursormodeLabel = null;
57    private AcopJComBox cursormodeBox;
58    private JLabel cursorstyleLabel = null;
59    private AcopJComBox cursorstyleBox;
60    private JLabel cursorwidthLabel = null;
61    private AcopJFormattedTextField cursorwidthText;
62    private JLabel cursorextendXLabel, cursorextendYLabel;
63    private AcopJFormattedTextField cursorextXText, cursorextYText;
64    
65    private JLabel leadingLabel = null;
66    private JLabel leadingmodeLabel = null;
67    private AcopJComBox leadingmodeBox;
68    private JLabel leadingstyleLabel = null;
69    private AcopJComBox leadingstyleBox;
70    private JLabel leadingwidthLabel = null;
71    private AcopJFormattedTextField leadingwidthText;
72    private JLabel leadingextendXLabel, leadingextendYLabel;
73    private AcopJFormattedTextField leadingextXText, leadingextYText;
74    
75    public MarkersCustomizerPanel(LayoutManager layout, boolean isDoubleBuffered)
76    {
77      super(layout, isDoubleBuffered);
78      // TODO Auto-generated constructor stub
79      initialize();
80    }
81    public MarkersCustomizerPanel(LayoutManager layout)
82    {
83      super(layout);
84      // TODO Auto-generated constructor stub
85      initialize();
86    }
87    public MarkersCustomizerPanel(boolean isDoubleBuffered)
88    {
89      super(isDoubleBuffered);
90      // TODO Auto-generated constructor stub
91      initialize();
92    }
93    public MarkersCustomizerPanel()
94    {
95      super();
96      // TODO Auto-generated constructor stub
97      initialize();
98    }
99    /**
100    * @param args
101    */
102   public static void main(String[] args)
103   {
104     // TODO Auto-generated method stub
105   }
106   /**
107    * This method initializes this
108    * 
109    * @return void
110    */
111   private void initialize()
112   {
113    GridBagConstraints gCon;
114    setLayout(new GridBagLayout());
115    if (markerLabel == null)
116    {
117      markerLabel = new JLabel("-- Display Marker --");
118    }
119    if (modeLabel == null)
120    {
121      modeLabel = new JLabel("Mode:");
122    }
123    if (styleLabel == null)
124    {
125      styleLabel = new JLabel("Style:");
126    }
127    if (widthLabel == null)
128    {
129      widthLabel = new JLabel("Width:");
130    }
131    if (extendXLabel == null)
132    {
133      extendXLabel = new JLabel("X-Extent:");
134    }
135    if (extendYLabel == null)
136    {
137      extendYLabel = new JLabel("Y-Exttnt:");
138    }
139 
140    if (cursorLabel == null)
141    {
142      cursorLabel = new JLabel("-- Cursor Marker --");
143    }
144    if (cursormodeLabel == null)
145    {
146      cursormodeLabel = new JLabel("Mode:");
147    }
148    if (cursorstyleLabel == null)
149    {
150      cursorstyleLabel = new JLabel("Style:");
151    }
152    if (cursorwidthLabel == null)
153    {
154      cursorwidthLabel = new JLabel("Width:");
155    }
156    if (cursorextendXLabel == null)
157    {
158      cursorextendXLabel = new JLabel("X-Extent:");
159    }
160    if (cursorextendYLabel == null)
161    {
162      cursorextendYLabel = new JLabel("Y-Exttnt:");
163    }
164 
165    if (leadingLabel == null)
166    {
167      leadingLabel = new JLabel("-- Leading Edge --");
168    }
169    if (leadingmodeLabel == null)
170    {
171      leadingmodeLabel = new JLabel("Mode:");
172    }
173    if (leadingstyleLabel == null)
174    {
175      leadingstyleLabel = new JLabel("Style:");
176    }
177    if (leadingwidthLabel == null)
178    {
179      leadingwidthLabel = new JLabel("Width:");
180    }
181    if (leadingextendXLabel == null)
182    {
183      leadingextendXLabel = new JLabel("X-Extent:");
184    }
185    if (leadingextendYLabel == null)
186    {
187      leadingextendYLabel = new JLabel("Y-Exttnt:");
188    }
189 
190    add(markerLabel, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER,
191        GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
192    add(modeLabel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
193        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
194    modeBox = new AcopJComBox("MarkerMode", AcopMarkerModeEnum.values());
195    add(modeBox, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
196        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
197    
198    add(styleLabel, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
199        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
200    styleBox = new AcopJComBox("MarkerStyle", AcopCursorMarkerModeEnum.values());
201    add(styleBox, new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
202        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
203 
204    add(widthLabel, new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
205        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
206    widthText = new AcopJFormattedTextField("10", "MarkerWidth", int.class);
207    add(widthText, new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
208        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
209    
210    add(extendXLabel, new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
211        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
212    extXText = new AcopJFormattedTextField("10", "MarkerXExtent", double.class);
213    add(extXText, new GridBagConstraints(1, 4, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
214        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
215 
216    add(extendYLabel, new GridBagConstraints(0, 5, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
217        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
218    extYText = new AcopJFormattedTextField("10", "MarkerYExtent", double.class);
219    add(extYText, new GridBagConstraints(1, 5, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
220        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
221   
222 
223    add(cursorLabel, new GridBagConstraints(2, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER,
224        GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
225 
226    add(cursormodeLabel, new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
227        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
228    cursormodeBox = new AcopJComBox("MarkerMode", AcopMarkerModeEnum.values());
229    add(cursormodeBox, new GridBagConstraints(3, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
230        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
231    
232    add(cursorstyleLabel, new GridBagConstraints(2, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
233        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
234    cursorstyleBox = new AcopJComBox("MarkerStyle", AcopCursorMarkerModeEnum.values());
235    add(cursorstyleBox, new GridBagConstraints(3, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
236        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
237 
238    add(cursorwidthLabel, new GridBagConstraints(2, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
239        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
240    cursorwidthText = new AcopJFormattedTextField("10", "MarkerWidth", int.class);
241    add(cursorwidthText, new GridBagConstraints(3, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
242        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
243    
244    add(cursorextendXLabel, new GridBagConstraints(2, 4, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
245        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
246    cursorextXText = new AcopJFormattedTextField("10", "MarkerXExtent", double.class);
247    add(cursorextXText, new GridBagConstraints(3, 4, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
248        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
249 
250    add(cursorextendYLabel, new GridBagConstraints(2, 5, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
251        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
252    cursorextYText = new AcopJFormattedTextField("10", "MarkerYExtent", double.class);
253    add(cursorextYText, new GridBagConstraints(3, 5, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
254        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
255    
256    
257    add(leadingLabel, new GridBagConstraints(4, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER,
258        GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
259    add(leadingmodeLabel, new GridBagConstraints(4, 1, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
260        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
261    leadingmodeBox = new AcopJComBox("LeadingEdgeMode", AcopMarkerModeEnum.values());
262    add(leadingmodeBox, new GridBagConstraints(5, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
263        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
264    
265    add(leadingstyleLabel, new GridBagConstraints(4, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
266        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
267    leadingstyleBox = new AcopJComBox("LeadingEdgeStyle", AcopCursorMarkerModeEnum.values());
268    add(leadingstyleBox, new GridBagConstraints(5, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
269        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
270 
271    add(leadingwidthLabel, new GridBagConstraints(4, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
272        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
273    leadingwidthText = new AcopJFormattedTextField("10", "LeadingEdgeWidth", int.class);
274    add(leadingwidthText, new GridBagConstraints(5, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
275        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
276    
277    add(leadingextendXLabel, new GridBagConstraints(4, 4, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
278        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
279    leadingextXText = new AcopJFormattedTextField("10", "LeadingEdgeXExtent", double.class);
280    add(leadingextXText, new GridBagConstraints(5, 4, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
281        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
282 
283    add(leadingextendYLabel, new GridBagConstraints(4, 5, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
284        GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
285    leadingextYText = new AcopJFormattedTextField("10", "LeadingEdgeYExtent", double.class);
286    add(leadingextYText, new GridBagConstraints(5, 5, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
287        GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
288    
289    this.setSize(300, 200);
290   }
291   public void setAcopBean(Acop acopBean)
292   {
293     this.acopBean = acopBean;
294     modeBox.setAcopBean(acopBean);
295     styleBox.setAcopBean(acopBean);
296     widthText.setAcopBean(acopBean);
297     extXText.setAcopBean(acopBean);
298     extYText.setAcopBean(acopBean);
299     
300     cursormodeBox.setAcopBean(acopBean);
301     cursorstyleBox.setAcopBean(acopBean);
302     cursorwidthText.setAcopBean(acopBean);
303     cursorextXText.setAcopBean(acopBean);
304     cursorextYText.setAcopBean(acopBean);
305 
306     leadingmodeBox.setAcopBean(acopBean);
307     leadingstyleBox.setAcopBean(acopBean);
308     leadingwidthText.setAcopBean(acopBean);
309     leadingextXText.setAcopBean(acopBean);
310     leadingextYText.setAcopBean(acopBean);
311   }
312   
313   public void setObject(Object bean) {
314 	setAcopBean((Acop)bean);
315 		
316   }
317 }