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.AcopAveragingMode;
35  import de.desy.acop.chart.AcopConst;
36  import de.desy.acop.chart.AcopDisplayMode;
37  import de.desy.acop.chart.AcopFFTEnum;
38  
39  public class DisplayCustomizerPanel extends JPanel implements Customizer
40  {
41  	
42  	public static final String[] DISPLAY_PROPERTIES = new String[]{
43  		"displayMode", "invert", "FFT", "wrapAround", "tagging", "XExtent", "YExtent",
44  		"colorFilled", "randomData", "averagingMode", "averagingDepth", "screenDepth",
45  		"reuseScreen"
46  	};
47    private Acop acopBean; // @jve:decl-index=0:visual-constraint="61,21"
48    private JLabel displayLabel = null;
49    private JLabel modeLabel = null;
50    private AcopJComBox displayModeBox;
51    private JLabel fftLabel = null;
52    private AcopJComBox fftBox;
53    private AcopJRadioButton acopReverseY, Wraparound, Tagging, colorFill, randomData, reuseScreen;
54    private JLabel extendXLabel, extendYLabel;
55    private AcopJFormattedTextField extXText, extYText;
56    private JLabel averageLabel = null;
57    private JLabel averModeLabel = null;
58    private AcopJComBox averModeBox;
59    private JLabel averageDepthLabel;
60    private AcopJFormattedTextField averDepthText;
61    private JLabel screenLabel = null;
62    private JLabel screenDepthLabel;
63    private AcopJFormattedTextField screenDepthText;
64    public DisplayCustomizerPanel(LayoutManager layout, boolean isDoubleBuffered)
65    {
66      super(layout, isDoubleBuffered);
67      // TODO Auto-generated constructor stub
68      initialize();
69    }
70    public DisplayCustomizerPanel(LayoutManager layout)
71    {
72      super(layout);
73      // TODO Auto-generated constructor stub
74      initialize();
75    }
76    public DisplayCustomizerPanel(boolean isDoubleBuffered)
77    {
78      super(isDoubleBuffered);
79      // TODO Auto-generated constructor stub
80      initialize();
81    }
82    public DisplayCustomizerPanel()
83    {
84      super();
85      // TODO Auto-generated constructor stub
86      initialize();
87    }
88    /**
89     * @param args
90     */
91    public static void main(String[] args)
92    {
93      // TODO Auto-generated method stub
94    }
95    /**
96     * This method initializes this
97     * 
98     * @return void
99     */
100   private void initialize()
101   {
102     // GridBagLayout gbl = new GridBagLayout();
103     // this.setLayout(gbl);
104     int offX, offY;
105     GridBagConstraints gCon;
106     setLayout(new GridBagLayout());
107     if (displayLabel == null)
108     {
109       displayLabel = new JLabel("-- Display Parameters --");
110     }
111     if (modeLabel == null)
112     {
113       modeLabel = new JLabel("Mode:");
114     }
115     if (fftLabel == null)
116     {
117       fftLabel = new JLabel("FFT:");
118     }
119     if (extendXLabel == null)
120     {
121       extendXLabel = new JLabel("Extent-X:");
122     }
123     if (extendYLabel == null)
124     {
125       extendYLabel = new JLabel("Extent-Y:");
126     }
127     if (averageLabel == null)
128     {
129       averageLabel = new JLabel("-- Averagin Parameters --");
130     }
131     if (averModeLabel == null)
132     {
133       averModeLabel = new JLabel("AverMode:");
134     }
135     if (averageDepthLabel == null)
136     {
137       averageDepthLabel = new JLabel("AverDepth:");
138     }
139     if (screenLabel == null)
140     {
141       screenLabel = new JLabel("-- Screen Parameters --");
142     }
143     if (screenDepthLabel == null)
144     {
145       screenDepthLabel = new JLabel("#Screen Buffers:");
146     }
147     add(displayLabel, new GridBagConstraints(0, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
148         GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
149     // GridBagConstraints clearConstraints = new
150     // GridBagConstraints(0,1,1,1,1.0,1.0,GridBagConstraints.EAST,GridBagConstraints.NONE,
151     // new Insets(4,4,4,4),0,0);
152     // gbl.setConstraints(modeLabel, clearConstraints);
153     // this.add(modeLabel);
154     add(modeLabel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
155         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
156     displayModeBox = new AcopJComBox("DisplayMode", AcopDisplayMode.values());
157     add(displayModeBox, new GridBagConstraints(1, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
158         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
159     add(fftLabel, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
160         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
161     fftBox = new AcopJComBox("FFT", AcopFFTEnum.values());
162     add(fftBox, new GridBagConstraints(1, 2, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
163         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
164     gCon = new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
165         new Insets(4, 4, 4, 4), 0, 0);
166     acopReverseY = new AcopJRadioButton("1/y", "Invert", "invert");
167     add(acopReverseY, gCon);
168     gCon.gridx = 1;
169     Wraparound = new AcopJRadioButton("wrapAround", "WrapAround", "wrapAround");
170     add(Wraparound, gCon);
171     gCon.gridx = 2;
172     gCon.gridwidth = 1;
173     Tagging = new AcopJRadioButton("tagging", "Tagging", "tagging");
174     add(Tagging, gCon);
175     add(extendXLabel, new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
176         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
177     extXText = new AcopJFormattedTextField("1", "XExtent", double.class);
178     add(extXText, new GridBagConstraints(1, 4, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
179         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
180     add(extendYLabel, new GridBagConstraints(2, 4, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
181         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
182     extYText = new AcopJFormattedTextField("1", "YExtent", double.class);
183     add(extYText, new GridBagConstraints(3, 4, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
184         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
185     gCon = new GridBagConstraints(1, 5, 1, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
186         new Insets(4, 4, 4, 4), 0, 0);
187     colorFill = new AcopJRadioButton("Color Fill", "ColorFilled", "colorFilled");
188     add(colorFill, gCon);
189     gCon.gridx = 3;
190     randomData = new AcopJRadioButton("Random Data", "RandomData", "randomData");
191     add(randomData, gCon);
192     // averagging:
193     offX = 4;
194     add(averageLabel, new GridBagConstraints(offX + 0, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
195         GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
196     add(averModeLabel, new GridBagConstraints(offX + 0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
197         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
198     averModeBox = new AcopJComBox("AveragingMode", AcopAveragingMode.values());
199     add(averModeBox, new GridBagConstraints(offX + 1, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
200         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
201     add(averageDepthLabel, new GridBagConstraints(offX + 0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
202         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
203     averDepthText = new AcopJFormattedTextField("1", "AveragingDepth", int.class, true, 0,
204         AcopConst.N_DEF_DISPLAY);
205     add(averDepthText, new GridBagConstraints(offX + 1, 2, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
206         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
207     add(screenLabel, new GridBagConstraints(offX + 0, 3, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
208         GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
209     add(screenDepthLabel, new GridBagConstraints(offX + 0, 4, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
210         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
211     screenDepthText = new AcopJFormattedTextField("1", "ScreenDepth", int.class, true, 1,
212         AcopConst.MAX_DISPLAY);
213     add(screenDepthText, new GridBagConstraints(offX + 1, 4, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
214         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
215     reuseScreen = new AcopJRadioButton("Reuse Screen", "ReuseScreen", "reuseScreen");
216     add(reuseScreen, new GridBagConstraints(offX + 0, 5, 3, 1, 1.0, 1.0, GridBagConstraints.EAST,
217         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
218     this.setSize(478, 297);
219   }
220   public void setAcopBean(Acop acopBean)
221   {
222     this.acopBean = acopBean;
223     displayModeBox.setAcopBean(acopBean);
224     fftBox.setAcopBean(acopBean);
225     acopReverseY.setAcopBean(acopBean);
226     Wraparound.setAcopBean(acopBean);
227     Tagging.setAcopBean(acopBean);
228     extXText.setAcopBean(acopBean);
229     extYText.setAcopBean(acopBean);
230     colorFill.setAcopBean(acopBean);
231     randomData.setAcopBean(acopBean);
232     averModeBox.setAcopBean(acopBean);
233     averDepthText.setAcopBean(acopBean);
234     screenDepthText.setAcopBean(acopBean);
235     reuseScreen.setAcopBean(acopBean);
236   }
237 	public void setObject(Object bean) {
238 		setAcopBean((Acop)bean);
239 		
240 	}
241 } // @jve:decl-index=0:visual-constraint="10,10"