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