Statistics
| Revision:

root / trunk / libraries / libCq_CMS_praster / src / org / cresques / ui / filter / TransparencyByPixelPanel.java @ 8026

History | View | Annotate | Download (6.63 KB)

1
package org.cresques.ui.filter;
2

    
3
import java.awt.Color;
4
import java.awt.FlowLayout;
5
import java.awt.GridBagConstraints;
6
import java.awt.GridBagLayout;
7
import java.util.ArrayList;
8

    
9
import javax.swing.DefaultListModel;
10
import javax.swing.JList;
11
import javax.swing.JPanel;
12

    
13
import org.cresques.ui.raster.AddRemoveButtonsPanel;
14
import org.cresques.ui.raster.AndOrSelectorPanel;
15
import org.cresques.ui.raster.RGBInputPanel;
16

    
17
public class TransparencyByPixelPanel extends JPanel {
18

    
19
        private JPanel                                                         pBorder = null;
20
        private RGBInputPanel                                         pWest = null;
21
        private JPanel                                                         pEast = null;
22
        private JPanel                                                         pCenter = null;
23
        private AddRemoveButtonsPanel                         pButtons = null;
24
        private AndOrSelectorPanel                                 pOperation = null;
25
        private JList                                                         jList = null;
26
        private TransparencyByPixelListener         listener = null;        
27
        private DefaultListModel                                listModel = null;
28
        private boolean                                                        controlEnabled = false;                                        
29
                
30
        /**
31
         * This is the default constructor
32
         */
33
        public TransparencyByPixelPanel() {
34
                super();
35
                initialize();
36
                listener = new TransparencyByPixelListener(this);
37
        }
38

    
39
        /**
40
         * This method initializes this
41
         * 
42
         * @return void
43
         */
44
        private void initialize() {
45
                FlowLayout flowLayout1 = new FlowLayout();
46
                flowLayout1.setHgap(0);
47
                flowLayout1.setVgap(5);
48
                this.setLayout(flowLayout1);
49
                this.setSize(410, 120);
50
                this.setPreferredSize(new java.awt.Dimension(410,120));
51
                this.add(getPBorder(), null);
52
        }
53

    
54
        /**
55
         * This method initializes jPanel        
56
         *         
57
         * @return javax.swing.JPanel        
58
         */
59
        private JPanel getPBorder() {
60
                if (pBorder == null) {
61
                        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
62
                        gridBagConstraints4.insets = new java.awt.Insets(0,15,0,0);
63
                        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
64
                        gridBagConstraints2.gridx = 0;
65
                        gridBagConstraints2.gridheight = 1;
66
                        gridBagConstraints2.insets = new java.awt.Insets(0,0,0,15);
67
                        gridBagConstraints2.gridy = 0;
68
                        pBorder = new JPanel();
69
                        pBorder.setLayout(new GridBagLayout());
70
                        pBorder.setPreferredSize(new java.awt.Dimension(410,120));
71
                        pBorder.add(getPRGBInput(), gridBagConstraints2);
72
                        pBorder.add(getPCenter(), new GridBagConstraints());
73
                        pBorder.add(getPList(), gridBagConstraints4);
74
                }
75
                return pBorder;
76
        }
77

    
78
        /**
79
         * This method initializes jPanel        
80
         *         
81
         * @return javax.swing.JPanel        
82
         */
83
        public RGBInputPanel getPRGBInput() {
84
                if (pWest == null) {
85
                        FlowLayout flowLayout = new FlowLayout();
86
                        flowLayout.setHgap(1);
87
                        flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
88
                        flowLayout.setVgap(1);
89
                        pWest = new RGBInputPanel();
90
                        pWest.setLayout(flowLayout);
91
                        pWest.setPreferredSize(new java.awt.Dimension(120,90));
92
                }
93
                return pWest;
94
        }
95

    
96
        /**
97
         * This method initializes jPanel1        
98
         *         
99
         * @return javax.swing.JPanel        
100
         */
101
        public JPanel getPList() {
102
                if (pEast == null) {
103
                        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
104
                        gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH;
105
                        gridBagConstraints3.gridx = 0;
106
                        gridBagConstraints3.gridy = 0;
107
                        gridBagConstraints3.weightx = 1.0;
108
                        gridBagConstraints3.weighty = 1.0;
109
                        gridBagConstraints3.insets = new java.awt.Insets(0,0,0,0);
110
                        pEast = new JPanel();
111
                        pEast.setLayout(new GridBagLayout());
112
                        pEast.setPreferredSize(new java.awt.Dimension(170,110));
113
                        pEast.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
114
                        pEast.add(getJList(), gridBagConstraints3);
115
                }
116
                return pEast;
117
        }
118

    
119
        /**
120
         * This method initializes jPanel2        
121
         *         
122
         * @return javax.swing.JPanel        
123
         */
124
        private JPanel getPCenter() {
125
                if (pCenter == null) {
126
                        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
127
                        gridBagConstraints1.insets = new java.awt.Insets(0,0,0,0);
128
                        gridBagConstraints1.gridy = 1;
129
                        gridBagConstraints1.gridx = 0;
130
                        GridBagConstraints gridBagConstraints = new GridBagConstraints();
131
                        gridBagConstraints.insets = new java.awt.Insets(0,0,0,0);
132
                        gridBagConstraints.gridy = 0;
133
                        gridBagConstraints.gridx = 0;
134
                        pCenter = new JPanel();
135
                        pCenter.setLayout(new GridBagLayout());
136
                        pCenter.setPreferredSize(new java.awt.Dimension(65,118));
137
                        pCenter.add(getPButtons(), gridBagConstraints);
138
                        pCenter.add(getPOperation(), gridBagConstraints1);
139
                }
140
                return pCenter;
141
        }
142

    
143
        /**
144
         * This method initializes jPanel        
145
         *         
146
         * @return javax.swing.JPanel        
147
         */
148
        public JPanel getPButtons() {
149
                if (pButtons == null) {
150
                        pButtons = new AddRemoveButtonsPanel();
151
                        pButtons.setPreferredSize(new java.awt.Dimension(60,50));
152
                }
153
                return pButtons;
154
        }
155

    
156
        /**
157
         * This method initializes jPanel1        
158
         *         
159
         * @return javax.swing.JPanel        
160
         */
161
        public JPanel getPOperation() {
162
                if (pOperation == null) {
163
                        pOperation = new AndOrSelectorPanel();
164
                        pOperation.setPreferredSize(new java.awt.Dimension(60,60));
165
                }
166
                return pOperation;
167
        }
168

    
169
        /**
170
         * This method initializes jList        
171
         *         
172
         * @return javax.swing.JList        
173
         */
174
        public JList getJList() {
175
                if (jList == null) {
176
                        listModel = new DefaultListModel();
177
                        jList = new JList(listModel);
178
                        //jList.setPreferredSize(new java.awt.Dimension(120,110));
179
                        jList.setSize(new java.awt.Dimension(135,125));
180
                        jList.setFont(new java.awt.Font("Monospaced", java.awt.Font.PLAIN, 10));
181
                }
182
                return jList;
183
        }
184
        
185
        /**
186
         * Obtiene el ListModel de la lista
187
         * @return DefaultListModel
188
         */
189
        public DefaultListModel getListModel(){
190
                return listModel;
191
        }
192
        
193
        /**
194
         * Activa o desactiva el control
195
         * @param enable True activa el control y false lo desactiva
196
         */
197
        public void setControlEnabled(boolean enabled){
198
                jList.setEnabled(enabled);
199
                if(enabled)
200
                        jList.setBackground(Color.WHITE);
201
                else
202
                        jList.setBackground(this.getBackground());
203
                pWest.setControlEnabled(enabled);
204
                pButtons.setControlEnabled(enabled);
205
                pOperation.setControlEnabled(enabled);
206
                controlEnabled = enabled;
207
        }
208
        
209
        /**
210
         * Obtiene true si el control est? activo y false si no lo est?
211
         * @return
212
         */
213
        public boolean isControlEnabled(){
214
                return controlEnabled;
215
        }
216
        
217
        /**
218
         * Asigna el n?mero de bandas activas 
219
         * @param n N?mero de bandas
220
         */
221
        public void setActiveBands(int n){
222
                ((RGBInputPanel)getPRGBInput()).setActiveBands(n);
223
        }
224
        
225
        /**
226
         * Obtiene el array de entradas de valores a?adidos a la lista
227
         * @return ArrayList
228
         */
229
        public ArrayList getEntries(){
230
                return listener.getEntries();
231
        }
232
        
233
        /**
234
         * Asigna el array de entradas de valores a?adidos a la lista
235
         * @return ArrayList
236
         */
237
        public void setEntries(ArrayList list){
238
                this.listener.setEntries(list);
239
        }
240

    
241
        /**
242
         * Obtiene la clase manejadora de eventos asociada a esta
243
         * @return TransparencyByPixelListener
244
         */
245
        public TransparencyByPixelListener getListener() {
246
                return listener;
247
        }
248

    
249
        public void setEnabled(boolean enabled){
250
                super.setEnabled(enabled);
251
                setControlEnabled(enabled);
252
        }
253
}