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