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.AcopCaptionLocationEnum;
35  import de.desy.acop.chart.AcopConst;
36  import de.desy.acop.chart.AcopTextPositionEnum;
37  import de.desy.acop.chart.AcopTextStickyAttributeEnum;
38  
39  public class FrameCustomizerPanel extends JPanel implements Customizer
40  {
41  	
42  	public static final String[] FRAME_PROPERTIES = {
43  	    "reuseText", "textDepth", "printTextStickyAttribute", "printTextLocation", 
44  	    "frameTopOffset", "frameBottomOffset", "frameLeftOffset", "frameRightOffset",
45  	    "frameWidth", "captionLocation", "caption"
46  	};
47    private Acop acopBean; // @jve:decl-index=0:visual-constraint="61,21"
48    private JLabel frameLabel = null;
49    private JLabel captionLabel = null;
50    private JLabel textLabel = null;
51    private AcopJFormattedTextField captionText;
52    private JLabel captionLocationLabel = null;
53    private AcopJComBox captionLocationBox;  
54    private JLabel widthLabel;
55    private AcopJFormattedTextField widthText;
56    private JLabel widthOffsetLabel = null;
57    private JLabel topLabel, bottomLabel, leftLabel, rightLabel;
58    private AcopJFormattedTextField frameTopText, frameBottomText, frameLeftText, frameRightText;
59    
60    private JLabel textPositionLabel = null;
61    private AcopJComBox textPositionBox;
62    private JLabel stickyParamLabel = null;
63    private AcopJComBox stickyParamBox;
64    private JLabel textBufferLabel;
65    private AcopJFormattedTextField textDepthText;
66    private AcopJRadioButton reuseText;
67     
68    public FrameCustomizerPanel(LayoutManager layout, boolean isDoubleBuffered)
69    {
70      super(layout, isDoubleBuffered);
71      // TODO Auto-generated constructor stub
72      initialize();
73    }
74    public FrameCustomizerPanel(LayoutManager layout)
75    {
76      super(layout);
77      // TODO Auto-generated constructor stub
78      initialize();
79    }
80    public FrameCustomizerPanel(boolean isDoubleBuffered)
81    {
82      super(isDoubleBuffered);
83      // TODO Auto-generated constructor stub
84      initialize();
85    }
86    public FrameCustomizerPanel()
87    {
88      super();
89      // TODO Auto-generated constructor stub
90      initialize();
91    }
92    /**
93     * @param args
94     */
95    public static void main(String[] args)
96    {
97      // TODO Auto-generated method stub
98    }
99    /**
100    * This method initializes this
101    * 
102    * @return void
103    */
104   private void initialize()
105   {
106     GridBagConstraints gCon;
107     setLayout(new GridBagLayout());
108     if (frameLabel == null)
109     {
110       frameLabel = new JLabel("-- Frame Parameters --");
111     }
112     if (captionLabel == null)
113     {
114       captionLabel = new JLabel("Caption:");
115     }
116     if (captionLocationLabel == null)
117     {
118       captionLocationLabel = new JLabel("Caption Location:");
119     }
120     if (widthLabel == null)
121     {
122       widthLabel = new JLabel("Width:");
123     }
124 
125     if (textLabel == null)
126     {
127       textLabel = new JLabel("-- Text Parameters --");
128     }
129     if (widthOffsetLabel == null)
130     {
131       widthOffsetLabel = new JLabel("-- Width Offset --");
132     }
133     if (topLabel == null)
134     {
135       topLabel = new JLabel("Top:");
136     }
137     if (bottomLabel == null)
138     {
139       bottomLabel = new JLabel("Bottom:");
140     }
141     if (leftLabel == null)
142     {
143       leftLabel = new JLabel("Left:");
144     }
145     if (rightLabel == null)
146     {
147       rightLabel = new JLabel("Right:");
148     }
149     if (textPositionLabel == null)
150     {
151       textPositionLabel = new JLabel("Position:");
152     }
153     if (stickyParamLabel == null)
154     {
155       stickyParamLabel = new JLabel("StickyAttribute:");
156     }
157     if (textBufferLabel == null)
158     {
159       textBufferLabel = new JLabel("#Text Buffers:");
160     }
161 
162     add(frameLabel, new GridBagConstraints(0, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
163         GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
164 
165     add(captionLabel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
166         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
167     captionText = new AcopJFormattedTextField("Test", "Caption", String.class);
168     add(captionText, new GridBagConstraints(1, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
169         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
170 
171     add(captionLocationLabel, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
172         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
173     captionLocationBox = new AcopJComBox("CaptionLocation", AcopCaptionLocationEnum.values());
174     add(captionLocationBox, new GridBagConstraints(1, 2, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
175         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
176    
177     add(widthLabel, new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
178         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
179     widthText = new AcopJFormattedTextField("10", "FrameWidth", int.class);
180     add(widthText, new GridBagConstraints(1, 3, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
181         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
182     
183     add(widthOffsetLabel, new GridBagConstraints(0, 4, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
184         GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
185 
186     add(topLabel, new GridBagConstraints(0, 5, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
187         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
188     frameTopText = new AcopJFormattedTextField("1", "FrameTopOffset", int.class);
189     add(frameTopText, new GridBagConstraints(1, 5, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
190         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
191    
192     add(bottomLabel, new GridBagConstraints(2, 5, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
193         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
194     frameBottomText = new AcopJFormattedTextField("1", "FrameBottomOffset", int.class);
195     add(frameBottomText, new GridBagConstraints(3, 5, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
196         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
197     
198     add(leftLabel, new GridBagConstraints(0, 6, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
199         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
200     frameLeftText = new AcopJFormattedTextField("1", "FrameLeftOffset", int.class);
201     add(frameLeftText, new GridBagConstraints(1, 6, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
202         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
203    
204     add(rightLabel, new GridBagConstraints(2, 6, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
205         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
206     frameRightText = new AcopJFormattedTextField("1", "FrameRightOffset", int.class);
207     add(frameRightText, new GridBagConstraints(3, 6, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
208         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
209 
210     add(textLabel, new GridBagConstraints(4, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER,
211         GridBagConstraints.CENTER, new Insets(4, 4, 4, 4), 0, 0));
212     add(textPositionLabel, new GridBagConstraints(4, 1, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
213         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
214     textPositionBox = new AcopJComBox("PrintTextLocation", AcopTextPositionEnum.values());
215     add(textPositionBox, new GridBagConstraints(5, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
216         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
217 
218     add(stickyParamLabel, new GridBagConstraints(4, 2, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
219         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
220     stickyParamBox = new AcopJComBox("PrintTextStickyAttribute", AcopTextStickyAttributeEnum.values());
221     add(stickyParamBox, new GridBagConstraints(5, 2, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
222         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
223     
224     add(textBufferLabel, new GridBagConstraints(4, 3, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
225         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
226     textDepthText = new AcopJFormattedTextField("1", "TextDepth", int.class, true, 1,
227         AcopConst.MAX_DISPLAY);
228     add(textDepthText, new GridBagConstraints(5, 3, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
229         GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
230     reuseText = new AcopJRadioButton("Reuse Text", "ReuseText", "reuseText");
231     add(reuseText, new GridBagConstraints(4, 4, 2, 1, 1.0, 1.0, GridBagConstraints.EAST,
232         GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
233 
234     this.setSize(300, 200);
235   }
236   public void setAcopBean(Acop acopBean)
237   {
238     this.acopBean = acopBean;
239     captionText.setAcopBean(acopBean);
240     captionLocationBox.setAcopBean(acopBean);
241     widthText.setAcopBean(acopBean);
242     frameTopText.setAcopBean(acopBean);
243     frameBottomText.setAcopBean(acopBean);
244     frameLeftText.setAcopBean(acopBean);
245     frameRightText.setAcopBean(acopBean);
246     textPositionBox.setAcopBean(acopBean);
247     stickyParamBox.setAcopBean(acopBean);
248     reuseText.setAcopBean(acopBean);
249     textDepthText.setAcopBean(acopBean);
250   }
251   
252   public void setObject(Object bean) {
253 	setAcopBean((Acop)bean);
254 		
255   }
256 }