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.AcopHistogramPositionEnum;
35  import de.desy.acop.chart.AcopLeadingEdgeMotionEnum;
36  import de.desy.acop.chart.AcopZoomingStyleEnum;
37  
38  public class SpecialCustomizerPanel extends JPanel implements Customizer
39  {
40  	public static final String[] SPECIAL_PROPERTIES = {
41  		"leadingEdgeGapSize","leadingEdgeMode", "histogramPosition", "zooming"
42  	};
43    private Acop acopBean; // @jve:decl-index=0:visual-constraint="61,21"
44    private JLabel zoomingParametersLabel = null;
45    private JLabel zoomingStyleLabel = null;
46    private AcopJComBox zoomingStyleBox;
47    private JLabel histogramParametersLabel = null;
48    private JLabel positionLabel = null;
49    private AcopJComBox positionBox;
50  
51    private JLabel leadingEdgeLabel = null;
52    private JLabel motionLabel = null;
53    private AcopJComBox motionBox;
54    private JLabel gapSizeLabel = null;
55    private AcopJFormattedTextField gapSizeText;
56  
57    public SpecialCustomizerPanel(LayoutManager layout, boolean isDoubleBuffered)
58    {
59      super(layout, isDoubleBuffered);
60      // TODO Auto-generated constructor stub
61      initialize();
62    }
63    public SpecialCustomizerPanel(LayoutManager layout)
64    {
65      super(layout);
66      // TODO Auto-generated constructor stub
67      initialize();
68    }
69    public SpecialCustomizerPanel(boolean isDoubleBuffered)
70    {
71      super(isDoubleBuffered);
72      // TODO Auto-generated constructor stub
73      initialize();
74    }
75    public SpecialCustomizerPanel()
76    {
77      super();
78      // TODO Auto-generated constructor stub
79      initialize();
80    }
81    /**
82     * @param args
83     */
84    public static void main(String[] args)
85    {
86      // TODO Auto-generated method stub
87    }
88    /**
89     * This method initializes this
90     * 
91     * @return void
92     */
93    private void initialize()
94    {
95      GridBagConstraints gCon;
96      setLayout(new GridBagLayout());
97      if (zoomingParametersLabel == null)
98      {
99        zoomingParametersLabel = new JLabel("-- Zooming Parameters --");
100     }
101     if (zoomingStyleLabel == null)
102     {
103       zoomingStyleLabel = new JLabel("Style:");
104     }
105     if (histogramParametersLabel == null)
106     {
107       histogramParametersLabel = new JLabel("-- Histogram Parameters --");
108     }
109     if (positionLabel == null)
110     {
111       positionLabel = new JLabel("Position:");
112     }
113 
114     if (leadingEdgeLabel == null)
115     {
116       leadingEdgeLabel = new JLabel("-- Leading Edge --");
117     }
118     if (motionLabel == null)
119     {
120       motionLabel = new JLabel("Motion:");
121     }
122     if (gapSizeLabel == null)
123     {
124       gapSizeLabel = new JLabel("Gap Size:");
125     }
126     
127     add(zoomingParametersLabel, new GridBagConstraints(0, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
128         GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
129     add(zoomingStyleLabel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
130         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
131     zoomingStyleBox = new AcopJComBox("Zooming", AcopZoomingStyleEnum.values());
132     add(zoomingStyleBox, new GridBagConstraints(1, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
133         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
134     
135     add(histogramParametersLabel, new GridBagConstraints(0, 3, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
136         GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
137     add(positionLabel, new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
138         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
139     positionBox = new AcopJComBox("HistogramPosition", AcopHistogramPositionEnum.values());
140     add(positionBox, new GridBagConstraints(1, 4, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
141         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
142     
143     
144     add(leadingEdgeLabel, new GridBagConstraints(4, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
145         GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
146     add(motionLabel, new GridBagConstraints(4, 1, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
147         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
148     motionBox = new AcopJComBox("LeadingEdgeMode", AcopLeadingEdgeMotionEnum.values());
149     add(motionBox, new GridBagConstraints(5, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
150         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
151 
152     add(gapSizeLabel, new GridBagConstraints(4, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
153         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
154     gapSizeText = new AcopJFormattedTextField("1", "LeadingEdgeGapSize", int.class);
155     add(gapSizeText, new GridBagConstraints(5, 2, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
156         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
157     
158     this.setSize(300, 200);
159   }
160   public void setAcopBean(Acop acopBean)
161   {
162     this.acopBean = acopBean;
163     zoomingStyleBox.setAcopBean(acopBean);
164     positionBox.setAcopBean(acopBean);
165     motionBox.setAcopBean(acopBean);
166     gapSizeText.setAcopBean(acopBean);
167   }
168   
169   public void setObject(Object bean) {
170 	setAcopBean((Acop)bean);
171 		
172   }
173 }