root / tags / v1_1_Build_1009 / libraries / libCq_CMS_praster / src / org / cresques / ui / filter / TransparencyByPixelPanel.java @ 12649
History | View | Annotate | Download (7.36 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.IResize; |
16 |
import org.cresques.ui.raster.RGBInputPanel; |
17 |
|
18 |
public class TransparencyByPixelPanel extends JPanel implements IResize{ |
19 |
|
20 |
|
21 |
private int wComp = 410, hComp = 120; |
22 |
private int wEast = wComp - 240, hEast = hComp - 10; |
23 |
private int wList = wEast-10, hList = hEast-10; |
24 |
|
25 |
private JPanel pBorder = null; |
26 |
private RGBInputPanel pWest = null; |
27 |
private JPanel pEast = null; |
28 |
private JPanel pCenter = null; |
29 |
private AddRemoveButtonsPanel pButtons = null; |
30 |
private AndOrSelectorPanel pOperation = null; |
31 |
private JList jList = null; |
32 |
private TransparencyByPixelListener listener = null; |
33 |
private DefaultListModel listModel = null; |
34 |
private boolean controlEnabled = false; |
35 |
|
36 |
/**
|
37 |
* This is the default constructor
|
38 |
*/
|
39 |
public TransparencyByPixelPanel() {
|
40 |
super();
|
41 |
initialize(); |
42 |
listener = new TransparencyByPixelListener(this); |
43 |
} |
44 |
|
45 |
/**
|
46 |
* This method initializes this
|
47 |
*
|
48 |
* @return void
|
49 |
*/
|
50 |
private void initialize() { |
51 |
FlowLayout flowLayout1 = new FlowLayout(); |
52 |
flowLayout1.setHgap(0);
|
53 |
flowLayout1.setVgap(5);
|
54 |
this.setLayout(flowLayout1);
|
55 |
this.setSize(wComp, hComp);
|
56 |
this.setPreferredSize(new java.awt.Dimension(wComp,hComp)); |
57 |
this.add(getPBorder(), null); |
58 |
this.setComponentSize(wComp, hComp);
|
59 |
} |
60 |
|
61 |
/**
|
62 |
* This method initializes jPanel
|
63 |
*
|
64 |
* @return javax.swing.JPanel
|
65 |
*/
|
66 |
private JPanel getPBorder() { |
67 |
if (pBorder == null) { |
68 |
GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
69 |
gridBagConstraints4.insets = new java.awt.Insets(0,15,0,0); |
70 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
71 |
gridBagConstraints2.gridx = 0;
|
72 |
gridBagConstraints2.gridheight = 1;
|
73 |
gridBagConstraints2.insets = new java.awt.Insets(0,0,0,15); |
74 |
gridBagConstraints2.gridy = 0;
|
75 |
pBorder = new JPanel(); |
76 |
pBorder.setLayout(new GridBagLayout()); |
77 |
pBorder.setPreferredSize(new java.awt.Dimension(wComp,hComp));
|
78 |
pBorder.add(getPRGBInput(), gridBagConstraints2); |
79 |
pBorder.add(getPCenter(), new GridBagConstraints()); |
80 |
pBorder.add(getPList(), gridBagConstraints4); |
81 |
} |
82 |
return pBorder;
|
83 |
} |
84 |
|
85 |
/**
|
86 |
* This method initializes jPanel
|
87 |
*
|
88 |
* @return javax.swing.JPanel
|
89 |
*/
|
90 |
public RGBInputPanel getPRGBInput() {
|
91 |
if (pWest == null) { |
92 |
FlowLayout flowLayout = new FlowLayout(); |
93 |
flowLayout.setHgap(1);
|
94 |
flowLayout.setAlignment(java.awt.FlowLayout.LEFT); |
95 |
flowLayout.setVgap(1);
|
96 |
pWest = new RGBInputPanel();
|
97 |
pWest.setLayout(flowLayout); |
98 |
pWest.setPreferredSize(new java.awt.Dimension(120,90)); |
99 |
} |
100 |
return pWest;
|
101 |
} |
102 |
|
103 |
/**
|
104 |
* This method initializes jPanel1
|
105 |
*
|
106 |
* @return javax.swing.JPanel
|
107 |
*/
|
108 |
public JPanel getPList() { |
109 |
if (pEast == null) { |
110 |
GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
111 |
gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH; |
112 |
gridBagConstraints3.gridx = 0;
|
113 |
gridBagConstraints3.gridy = 0;
|
114 |
gridBagConstraints3.weightx = 1.0;
|
115 |
gridBagConstraints3.weighty = 1.0;
|
116 |
gridBagConstraints3.insets = new java.awt.Insets(0,0,0,0); |
117 |
pEast = new JPanel(); |
118 |
pEast.setLayout(new GridBagLayout()); |
119 |
pEast.setPreferredSize(new java.awt.Dimension(wEast,hEast));
|
120 |
pEast.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED)); |
121 |
pEast.add(getJList(), gridBagConstraints3); |
122 |
} |
123 |
return pEast;
|
124 |
} |
125 |
|
126 |
/**
|
127 |
* This method initializes jPanel2
|
128 |
*
|
129 |
* @return javax.swing.JPanel
|
130 |
*/
|
131 |
private JPanel getPCenter() { |
132 |
if (pCenter == null) { |
133 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
134 |
gridBagConstraints1.insets = new java.awt.Insets(0,0,0,0); |
135 |
gridBagConstraints1.gridy = 1;
|
136 |
gridBagConstraints1.gridx = 0;
|
137 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
138 |
gridBagConstraints.insets = new java.awt.Insets(0,0,0,0); |
139 |
gridBagConstraints.gridy = 0;
|
140 |
gridBagConstraints.gridx = 0;
|
141 |
pCenter = new JPanel(); |
142 |
pCenter.setLayout(new GridBagLayout()); |
143 |
pCenter.setPreferredSize(new java.awt.Dimension(65,118)); |
144 |
pCenter.add(getPButtons(), gridBagConstraints); |
145 |
pCenter.add(getPOperation(), gridBagConstraints1); |
146 |
} |
147 |
return pCenter;
|
148 |
} |
149 |
|
150 |
/**
|
151 |
* This method initializes jPanel
|
152 |
*
|
153 |
* @return javax.swing.JPanel
|
154 |
*/
|
155 |
public JPanel getPButtons() { |
156 |
if (pButtons == null) { |
157 |
pButtons = new AddRemoveButtonsPanel();
|
158 |
pButtons.setPreferredSize(new java.awt.Dimension(60,50)); |
159 |
} |
160 |
return pButtons;
|
161 |
} |
162 |
|
163 |
/**
|
164 |
* This method initializes jPanel1
|
165 |
*
|
166 |
* @return javax.swing.JPanel
|
167 |
*/
|
168 |
public JPanel getPOperation() { |
169 |
if (pOperation == null) { |
170 |
pOperation = new AndOrSelectorPanel();
|
171 |
pOperation.setPreferredSize(new java.awt.Dimension(60,60)); |
172 |
} |
173 |
return pOperation;
|
174 |
} |
175 |
|
176 |
/**
|
177 |
* This method initializes jList
|
178 |
*
|
179 |
* @return javax.swing.JList
|
180 |
*/
|
181 |
public JList getJList() { |
182 |
if (jList == null) { |
183 |
listModel = new DefaultListModel(); |
184 |
jList = new JList(listModel); |
185 |
//jList.setPreferredSize(new java.awt.Dimension(120,110));
|
186 |
jList.setSize(new java.awt.Dimension(wList,hList));
|
187 |
jList.setFont(new java.awt.Font("Monospaced", java.awt.Font.PLAIN, 10)); |
188 |
} |
189 |
return jList;
|
190 |
} |
191 |
|
192 |
/**
|
193 |
* Obtiene el ListModel de la lista
|
194 |
* @return DefaultListModel
|
195 |
*/
|
196 |
public DefaultListModel getListModel(){ |
197 |
return listModel;
|
198 |
} |
199 |
|
200 |
/**
|
201 |
* Asigna los tama?os de los componentes y el panel a partir del tama?o
|
202 |
* introducido.
|
203 |
* @param w
|
204 |
* @param h
|
205 |
*/
|
206 |
public void setComponentSize(int w, int h){ |
207 |
wComp = w; hComp = h; |
208 |
wEast = wComp - 240; hEast = hComp - 10; |
209 |
wList = wEast-10; hList = hEast-10; |
210 |
|
211 |
this.setSize(wComp, hComp);
|
212 |
this.setPreferredSize(new java.awt.Dimension(wComp,hComp)); |
213 |
pBorder.setPreferredSize(new java.awt.Dimension(wComp,hComp));
|
214 |
pEast.setPreferredSize(new java.awt.Dimension(wEast,hEast));
|
215 |
jList.setSize(new java.awt.Dimension(wList,hList));
|
216 |
|
217 |
} |
218 |
|
219 |
|
220 |
/**
|
221 |
* Activa o desactiva el control
|
222 |
* @param enable True activa el control y false lo desactiva
|
223 |
*/
|
224 |
public void setControlEnabled(boolean enabled){ |
225 |
jList.setEnabled(enabled); |
226 |
if(enabled)
|
227 |
jList.setBackground(Color.WHITE);
|
228 |
else
|
229 |
jList.setBackground(this.getBackground());
|
230 |
pWest.setControlEnabled(enabled); |
231 |
pButtons.setControlEnabled(enabled); |
232 |
pOperation.setControlEnabled(enabled); |
233 |
controlEnabled = enabled; |
234 |
} |
235 |
|
236 |
/**
|
237 |
* Obtiene true si el control est? activo y false si no lo est?
|
238 |
* @return
|
239 |
*/
|
240 |
public boolean isControlEnabled(){ |
241 |
return controlEnabled;
|
242 |
} |
243 |
|
244 |
/**
|
245 |
* Asigna el n?mero de bandas activas
|
246 |
* @param n N?mero de bandas
|
247 |
*/
|
248 |
public void setActiveBands(int n){ |
249 |
((RGBInputPanel)getPRGBInput()).setActiveBands(n); |
250 |
} |
251 |
|
252 |
/**
|
253 |
* Obtiene el array de entradas de valores a?adidos a la lista
|
254 |
* @return ArrayList
|
255 |
*/
|
256 |
public ArrayList getEntries(){ |
257 |
return listener.getEntries();
|
258 |
} |
259 |
|
260 |
/**
|
261 |
* Asigna el array de entradas de valores a?adidos a la lista
|
262 |
* @return ArrayList
|
263 |
*/
|
264 |
public void setEntries(ArrayList list){ |
265 |
this.listener.setEntries(list);
|
266 |
} |
267 |
|
268 |
/**
|
269 |
* Obtiene la clase manejadora de eventos asociada a esta
|
270 |
* @return TransparencyByPixelListener
|
271 |
*/
|
272 |
public TransparencyByPixelListener getListener() {
|
273 |
return listener;
|
274 |
} |
275 |
|
276 |
} |