View Javadoc

1   // %1117737442015:hoplugins.seriesstats%
2   /*
3    * Created on 24.11.2004
4    */
5   package hoplugins.seriesstats;
6   
7   /***
8    */
9   import java.awt.Color;
10  import java.awt.Graphics2D;
11  import java.awt.GridBagConstraints;
12  import java.awt.GridBagLayout;
13  import java.awt.Insets;
14  import java.awt.event.ActionListener;
15  import java.awt.event.ItemListener;
16  import java.awt.image.BufferedImage;
17  
18  import javax.swing.ImageIcon;
19  import javax.swing.JCheckBox;
20  import javax.swing.JLabel;
21  import javax.swing.JPanel;
22  
23  
24  /***
25   * TODO Missing Class Documentation
26   *
27   * @author TODO Author Name
28   */
29  public class LegendeCheckBox extends JPanel {
30      //~ Instance fields ----------------------------------------------------------------------------
31  
32      /*** TODO Missing Parameter Documentation */
33      public boolean isSelected = true;
34      private JCheckBox jcbBox; // a 
35      private JLabel jlLabel; // _fldif
36  
37      //~ Constructors -------------------------------------------------------------------------------
38  
39      /***
40       * Creates a new instance of LegendeComboBox
41       */
42      public LegendeCheckBox() {
43          this("", null, true);
44      }
45  
46      /***
47       * Creates a new LegendeCheckBox object.
48       *
49       * @param s TODO Missing Constructuor Parameter Documentation
50       */
51      public LegendeCheckBox(String s) {
52          this(s, null, true);
53      }
54  
55      /***
56       * Creates a new LegendeCheckBox object.
57       *
58       * @param s TODO Missing Constructuor Parameter Documentation
59       * @param imageicon TODO Missing Constructuor Parameter Documentation
60       */
61      public LegendeCheckBox(String s, ImageIcon imageicon) {
62          this(s, imageicon, true);
63      }
64  
65      /***
66       * Creates a new LegendeCheckBox object.
67       *
68       * @param s TODO Missing Constructuor Parameter Documentation
69       * @param color TODO Missing Constructuor Parameter Documentation
70       */
71      public LegendeCheckBox(String s, Color color) {
72          this(s, _col2imic(color), true);
73      }
74  
75      /***
76       * Creates a new LegendeCheckBox object.
77       *
78       * @param s TODO Missing Constructuor Parameter Documentation
79       * @param imageicon TODO Missing Constructuor Parameter Documentation
80       * @param flag TODO Missing Constructuor Parameter Documentation
81       */
82      public LegendeCheckBox(String s, ImageIcon imageicon, boolean flag) {
83          this(s, imageicon, flag, 4);
84      }
85  
86      /***
87       * Creates a new LegendeCheckBox object.
88       *
89       * @param s TODO Missing Constructuor Parameter Documentation
90       * @param imageicon TODO Missing Constructuor Parameter Documentation
91       * @param flag TODO Missing Constructuor Parameter Documentation
92       * @param i TODO Missing Constructuor Parameter Documentation
93       */
94      public LegendeCheckBox(String s, ImageIcon imageicon, boolean flag, int i) {
95          jcbBox = new JCheckBox();
96          jlLabel = new JLabel();
97  
98          GridBagLayout gridbaglayout = new GridBagLayout();
99          GridBagConstraints gridbagconstraints = new GridBagConstraints();
100         gridbagconstraints.fill = 2;
101         gridbagconstraints.weightx = 0.0D;
102         gridbagconstraints.weighty = 0.0D;
103         gridbagconstraints.insets = new Insets(0, 0, 0, 0);
104         setLayout(gridbaglayout);
105 
106         gridbagconstraints.gridx = 0;
107         gridbagconstraints.gridy = 0;
108         gridbagconstraints.weightx = 0.0D;
109         jcbBox.setSelected(flag);
110         jcbBox.setOpaque(false);
111         gridbaglayout.setConstraints(jcbBox, gridbagconstraints);
112         add(jcbBox);
113 
114         gridbagconstraints.gridx = 1;
115         gridbagconstraints.gridy = 0;
116         gridbagconstraints.weightx = 1.0D;
117         jlLabel.setHorizontalTextPosition(i);
118         jlLabel.setText(s);
119         jlLabel.setIcon(imageicon);
120         jlLabel.setOpaque(false);
121         gridbaglayout.setConstraints(jlLabel, gridbagconstraints);
122         add(jlLabel);
123     }
124 
125     //~ Methods ------------------------------------------------------------------------------------
126 
127     /***
128      * TODO Missing Method Documentation
129      *
130      * @return TODO Missing Return Method Documentation
131      */
132     public JCheckBox getBox() {
133         return jcbBox;
134     }
135 
136     /***
137      * TODO Missing Method Documentation
138      *
139      * @param AL TODO Missing Method Parameter Documentation
140      */
141     public void aAL(ActionListener AL) {
142         jcbBox.addActionListener(AL);
143     }
144 
145     /***
146      * TODO Missing Method Documentation
147      *
148      * @param IL TODO Missing Method Parameter Documentation
149      */
150     public void aIL(ItemListener IL) {
151         jcbBox.addItemListener(IL);
152     }
153 
154     /***
155      * TODO Missing Method Documentation
156      *
157      * @return TODO Missing Return Method Documentation
158      */
159     public boolean is() {
160         if (isSelected) {
161             isSelected = false;
162         } else {
163             isSelected = true;
164         }
165 
166         return isSelected;
167     }
168 
169     /***
170      * TODO Missing Method Documentation
171      *
172      * @param AL TODO Missing Method Parameter Documentation
173      */
174     public void rAL(ActionListener AL) {
175         jcbBox.removeActionListener(AL);
176     }
177 
178     /***
179      * TODO Missing Method Documentation
180      *
181      * @param color TODO Missing Method Parameter Documentation
182      *
183      * @return TODO Missing Return Method Documentation
184      */
185     private static ImageIcon _col2imic(Color color) {
186         BufferedImage bufferedimage = new BufferedImage(14, 14, 2);
187         Graphics2D graphics2d = (Graphics2D) bufferedimage.getGraphics();
188         graphics2d.setColor(color);
189         graphics2d.fillRect(0, 0, 13, 13);
190         return new ImageIcon(bufferedimage);
191     }
192 }