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.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; // @jve:decl-index=0:visual-constraint="61,21"
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      // TODO Auto-generated constructor stub
62      initialize();
63    }
64    public GraphCustomizerPanel(LayoutManager layout)
65    {
66      super(layout);
67      // TODO Auto-generated constructor stub
68      initialize();
69    }
70    public GraphCustomizerPanel(boolean isDoubleBuffered)
71    {
72      super(isDoubleBuffered);
73      // TODO Auto-generated constructor stub
74      initialize();
75    }
76    public GraphCustomizerPanel()
77    {
78      super();
79      // TODO Auto-generated constructor stub
80      initialize();
81    }
82    /**
83     * @param args
84     */
85    public static void main(String[] args)
86    {
87      // TODO Auto-generated method stub
88    }
89    /**
90     * This method initializes this
91     * 
92     * @return void
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 }  //  @jve:decl-index=0:visual-constraint="118,10"