KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > gui > sheet > SeriesColorsSheetPropertyComponent


1 /*
2  * Copyright (C) 2005 - 2006 JasperSoft Corporation. All rights reserved.
3  * http://www.jaspersoft.com.
4  *
5  * Unless you have purchased a commercial license agreement from JasperSoft,
6  * the following license terms apply:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as published by
10  * the Free Software Foundation.
11  *
12  * This program is distributed WITHOUT ANY WARRANTY; and without the
13  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
18  * or write to:
19  *
20  * Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330,
22  * Boston, MA USA 02111-1307
23  *
24  *
25  *
26  *
27  * SeriesColorsSheetPropertyComponent.java
28  *
29  * Created on 15 agosto 2005, 13.32
30  *
31  */

32
33 package it.businesslogic.ireport.gui.sheet;
34
35 import it.businesslogic.ireport.chart.SeriesColor;
36 import it.businesslogic.ireport.gui.FieldPatternDialog;
37 import it.businesslogic.ireport.gui.MainFrame;
38 import java.awt.Dialog JavaDoc;
39 import java.awt.Frame JavaDoc;
40 import java.awt.Window JavaDoc;
41 import java.awt.event.ActionEvent JavaDoc;
42 import java.util.List JavaDoc;
43 import javax.swing.BoxLayout JavaDoc;
44 import javax.swing.JOptionPane JavaDoc;
45 import javax.swing.SwingUtilities JavaDoc;
46 import it.businesslogic.ireport.util.I18n;
47
48 /**
49  *
50  * @author Administrator
51  */

52 public class SeriesColorsSheetPropertyComponent extends javax.swing.JPanel JavaDoc {
53     
54     private java.util.List JavaDoc listOfSeriesColor = new java.util.ArrayList JavaDoc();
55     
56     private boolean init = false;
57      
58     /** Creates new form ExpressionSheetPanel */
59     public SeriesColorsSheetPropertyComponent() {
60         initComponents();
61         
62         //javax.swing.BoxLayout bl = new javax.swing.BoxLayout(jPanelColors,javax.swing.BoxLayout.X_AXIS);
63
//jPanelColors.setLayout(bl);
64
applyI18n();
65         setListOfSeriesColor(listOfSeriesColor);
66     }
67     
68     
69     /** This method is called from within the constructor to
70      * initialize the form.
71      * WARNING: Do NOT modify this code. The content of this method is
72      * always regenerated by the Form Editor.
73      */

74     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
75
private void initComponents() {
76         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
77
78         jPanelColors = new javax.swing.JPanel JavaDoc();
79         jPanelSample = new javax.swing.JPanel JavaDoc();
80         jPanelSpacer = new javax.swing.JPanel JavaDoc();
81         jButton1 = new javax.swing.JButton JavaDoc();
82
83         setLayout(new java.awt.GridBagLayout JavaDoc());
84
85         setBackground(new java.awt.Color JavaDoc(255, 255, 255));
86         jPanelColors.setLayout(new javax.swing.BoxLayout JavaDoc(jPanelColors, javax.swing.BoxLayout.X_AXIS));
87
88         jPanelColors.setBackground(new java.awt.Color JavaDoc(255, 255, 255));
89         jPanelSample.setBorder(new javax.swing.border.LineBorder JavaDoc(new java.awt.Color JavaDoc(0, 0, 0), 1, true));
90         jPanelSample.setMaximumSize(new java.awt.Dimension JavaDoc(12, 12));
91         jPanelColors.add(jPanelSample);
92
93         jPanelSpacer.setBackground(new java.awt.Color JavaDoc(255, 255, 255));
94         jPanelColors.add(jPanelSpacer);
95
96         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
97         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
98         gridBagConstraints.weightx = 1.0;
99         gridBagConstraints.weighty = 1.0;
100         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 4, 2, 4);
101         add(jPanelColors, gridBagConstraints);
102
103         jButton1.setText("...");
104         jButton1.setMaximumSize(new java.awt.Dimension JavaDoc(19, 10));
105         jButton1.setMinimumSize(new java.awt.Dimension JavaDoc(19, 10));
106         jButton1.setPreferredSize(new java.awt.Dimension JavaDoc(19, 10));
107         jButton1.addActionListener(new java.awt.event.ActionListener JavaDoc() {
108             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
109                 jButton1ActionPerformed(evt);
110             }
111         });
112
113         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
114         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
115         gridBagConstraints.weighty = 1.0;
116         add(jButton1, gridBagConstraints);
117
118     }// </editor-fold>//GEN-END:initComponents
119

120     private void jButton1ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButton1ActionPerformed
121

122         SeriesColorsDialog dialog = null;
123         Window JavaDoc topLevel = SwingUtilities.getWindowAncestor(this);
124  
125         if (topLevel == null)
126         {
127             dialog = new SeriesColorsDialog((Frame)null,true);
128         }
129         else if (topLevel instanceof Frame) {
130             dialog = new SeriesColorsDialog((Frame)topLevel, true);
131         }
132         else if (topLevel instanceof Dialog) {
133             dialog = new SeriesColorsDialog((Dialog)topLevel, true);
134         }
135         
136         dialog.setSeriescolors( listOfSeriesColor );
137         dialog.setVisible(true);
138         
139         if (dialog.getDialogResult() == JOptionPane.OK_OPTION)
140         {
141             this.setListOfSeriesColor( dialog.getSeriescolors() );
142             fireActionListenerActionPerformed( new ActionEvent JavaDoc(this,0,"") );
143         }
144         
145     }//GEN-LAST:event_jButton1ActionPerformed
146

147     
148     // Variables declaration - do not modify//GEN-BEGIN:variables
149
private javax.swing.JButton JavaDoc jButton1;
150     private javax.swing.JPanel JavaDoc jPanelColors;
151     private javax.swing.JPanel JavaDoc jPanelSample;
152     private javax.swing.JPanel JavaDoc jPanelSpacer;
153     // End of variables declaration//GEN-END:variables
154

155     /**
156      * Utility field used by event firing mechanism.
157      */

158     private javax.swing.event.EventListenerList JavaDoc listenerList = null;
159
160     /**
161      * Registers ActionListener to receive events.
162      * @param listener The listener to register.
163      */

164     public synchronized void addActionListener(java.awt.event.ActionListener JavaDoc listener) {
165
166         if (listenerList == null ) {
167             listenerList = new javax.swing.event.EventListenerList JavaDoc();
168         }
169         listenerList.add (java.awt.event.ActionListener JavaDoc.class, listener);
170     }
171
172     /**
173      * Removes ActionListener from the list of listeners.
174      * @param listener The listener to remove.
175      */

176     public synchronized void removeActionListener(java.awt.event.ActionListener JavaDoc listener) {
177
178         listenerList.remove (java.awt.event.ActionListener JavaDoc.class, listener);
179     }
180
181     /**
182      * Notifies all registered listeners about the event.
183      *
184      * @param event The event to be fired
185      */

186     private void fireActionListenerActionPerformed(java.awt.event.ActionEvent JavaDoc event) {
187
188         if (listenerList == null) return;
189         Object JavaDoc[] listeners = listenerList.getListenerList ();
190         for (int i = listeners.length - 2; i >= 0; i -= 2) {
191             if (listeners[i]==java.awt.event.ActionListener JavaDoc.class) {
192                 ((java.awt.event.ActionListener JavaDoc)listeners[i+1]).actionPerformed (event);
193             }
194         }
195     }
196
197     public boolean isInit() {
198         return init;
199     }
200
201     public void setInit(boolean init) {
202         this.init = init;
203     }
204
205     public java.util.List JavaDoc getListOfSeriesColor() {
206         return listOfSeriesColor;
207     }
208
209     public void setListOfSeriesColor(java.util.List JavaDoc listOfSeriesColor) {
210         
211         if (listOfSeriesColor == null || !(listOfSeriesColor instanceof List JavaDoc)) return;
212         
213         this.listOfSeriesColor = listOfSeriesColor;
214         
215         // Remove all panels...
216
jPanelColors.removeAll();
217         // Add all panels from the list..
218
//jPanelColors.setLayout(new javax.swing.BoxLayout(jPanelColors, javax.swing.BoxLayout.X_AXIS));
219

220         //java.awt.GridBagConstraints gridBagConstraints = null;
221
for (int i=0; i<listOfSeriesColor.size(); ++i)
222         {
223             SeriesColor sc = (SeriesColor)listOfSeriesColor.get(i);
224             javax.swing.JPanel JavaDoc panel = new javax.swing.JPanel JavaDoc();
225             panel.setMinimumSize(new java.awt.Dimension JavaDoc(4,12));
226             panel.setPreferredSize(new java.awt.Dimension JavaDoc(12,12));
227             panel.setMaximumSize(new java.awt.Dimension JavaDoc(12,12));
228             panel.setBorder(new javax.swing.border.LineBorder JavaDoc(new java.awt.Color JavaDoc(0, 0, 0), 1, true));
229             panel.setBackground( sc.getColor() );
230             
231             //gridBagConstraints = new java.awt.GridBagConstraints();
232
//gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 1);
233
jPanelColors.add(panel); //, gridBagConstraints);
234
jPanelColors.add(javax.swing.Box.createRigidArea(new java.awt.Dimension JavaDoc(1,0)));
235         }
236         
237         
238         //gridBagConstraints = new java.awt.GridBagConstraints();
239
//gridBagConstraints.weightx = 1.0;
240
//jPanelColors.add(jPanelSpacer, gridBagConstraints);
241
jPanelColors.updateUI();
242         // Add the spacer..
243
}
244     
245     public void applyI18n(){
246                 // Start autogenerated code ----------------------
247
jButton1.setText(I18n.getString("seriesColorsSheetPropertyComponent.button1","..."));
248                 // End autogenerated code ----------------------
249
}
250 }
251
Popular Tags