Revision 12085
trunk/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/checkslidertext/TestCheckColorSliderTextTable.java | ||
---|---|---|
1 |
package org.gvsig.gui.beans.checkslidertext; |
|
2 |
|
|
3 |
import javax.swing.JFrame; |
|
4 |
import javax.swing.UIManager; |
|
5 |
|
|
6 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
|
7 |
|
|
8 |
public class TestCheckColorSliderTextTable { |
|
9 |
private int w = 375, h = 150; |
|
10 |
private JFrame frame=new JFrame(); |
|
11 |
private CheckColorSliderTextContainer slider = null; |
|
12 |
|
|
13 |
public TestCheckColorSliderTextTable() throws NotInitializeException{ |
|
14 |
slider = new CheckColorSliderTextContainer(0, 255, 0, "R", false); |
|
15 |
|
|
16 |
frame.getContentPane().add(slider); |
|
17 |
slider.setEnabled(true); |
|
18 |
frame.setSize(w, h); |
|
19 |
frame.setVisible(true); |
|
20 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
|
21 |
} |
|
22 |
|
|
23 |
public static void main(String[] args) { |
|
24 |
try { |
|
25 |
UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel"); |
|
26 |
} catch (Exception e) { |
|
27 |
System.err.println("No se puede cambiar al LookAndFeel"); |
|
28 |
} |
|
29 |
try { |
|
30 |
new TestCheckColorSliderTextTable(); |
|
31 |
} catch (NotInitializeException ex) { |
|
32 |
System.out.println("Tabla no inicializada"); |
|
33 |
} |
|
34 |
} |
|
35 |
} |
|
0 | 36 |
trunk/libraries/libUIComponent/src-test-ui/org/gvsig/gui/beans/slidertext/TestSliderTextTable.java | ||
---|---|---|
3 | 3 |
import javax.swing.JFrame; |
4 | 4 |
import javax.swing.UIManager; |
5 | 5 |
|
6 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
|
7 |
|
|
8 | 6 |
public class TestSliderTextTable { |
9 | 7 |
private int w = 350, h = 150; |
10 | 8 |
private JFrame frame=new JFrame(); |
11 | 9 |
private SliderTextContainer slider = null; |
12 |
|
|
13 |
public TestSliderTextTable() throws NotInitializeException{
|
|
10 |
|
|
11 |
public TestSliderTextTable() { |
|
14 | 12 |
slider = new SliderTextContainer(-255, 255, 0); |
15 |
|
|
13 |
|
|
16 | 14 |
frame.getContentPane().add(slider); |
17 | 15 |
frame.setSize(w, h); |
18 | 16 |
frame.setVisible(true); |
... | ... | |
25 | 23 |
} catch (Exception e) { |
26 | 24 |
System.err.println("No se puede cambiar al LookAndFeel"); |
27 | 25 |
} |
28 |
try { |
|
29 |
new TestSliderTextTable(); |
|
30 |
} catch (NotInitializeException ex) { |
|
31 |
System.out.println("Tabla no inicializada"); |
|
32 |
} |
|
26 |
new TestSliderTextTable(); |
|
33 | 27 |
} |
34 | 28 |
} |
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/doubleslider/DoubleSlider.java | ||
---|---|---|
46 | 46 |
int x1 = 0; |
47 | 47 |
int x2 = 100; |
48 | 48 |
|
49 |
Color color1 = Color.BLACK; |
|
50 |
Color color2 = Color.WHITE; |
|
51 |
|
|
49 | 52 |
int minimum = 0; |
50 | 53 |
int maximum = 100; |
51 | 54 |
|
55 |
boolean twoSliders = false; |
|
56 |
|
|
52 | 57 |
private ArrayList actionCommandListeners = new ArrayList(); |
53 | 58 |
private boolean bDoCallListeners = true; |
54 |
static private int eventId = Integer.MIN_VALUE; |
|
55 |
|
|
59 |
|
|
56 | 60 |
/** |
57 | 61 |
* Crea un DoubleSlider con las opciones por defecto. |
58 | 62 |
*/ |
... | ... | |
89 | 93 |
|
90 | 94 |
addMouseMotionListener(this); |
91 | 95 |
addMouseListener(this); |
92 |
|
|
96 |
|
|
93 | 97 |
refreshImage(); |
94 |
}
|
|
98 |
} |
|
95 | 99 |
|
96 | 100 |
/** |
97 | 101 |
* Crea un graphics con las dimensiones del componente si no estaba creado y |
... | ... | |
99 | 103 |
* @return Graphics |
100 | 104 |
*/ |
101 | 105 |
private Graphics getBufferGraphics() { |
102 |
int width2=getBounds().width; |
|
103 |
int height2=getBounds().height; |
|
104 |
if (width2<=0) width2=1; |
|
105 |
if (height2<=0) height2=1; |
|
106 |
int width2 = getBounds().width; |
|
107 |
int height2 = getBounds().height; |
|
108 |
if (width2 <= 0) |
|
109 |
width2 = 1; |
|
110 |
if (height2 <= 0) |
|
111 |
height2 = 1; |
|
106 | 112 |
|
107 |
if ((width!=width2) || (height!=height2)) {
|
|
113 |
if ((width!=width2) || (height!=height2)) { |
|
108 | 114 |
bufferImage = createImage(width2, height2); |
109 | 115 |
if (bufferImage == null) return null; |
110 | 116 |
bufferGraphics = bufferImage.getGraphics(); |
... | ... | |
112 | 118 |
|
113 | 119 |
width = width2; |
114 | 120 |
height = height2; |
115 |
|
|
121 |
|
|
116 | 122 |
return bufferGraphics; |
117 | 123 |
} |
118 | 124 |
|
125 |
public Color getColorPosition(int pos) { |
|
126 |
int r, g, b; |
|
127 |
|
|
128 |
Color color1 = this.color1; |
|
129 |
Color color2 = this.color2; |
|
130 |
if (!isEnabled()) { |
|
131 |
r = Color.DARK_GRAY.getRed(); |
|
132 |
color1 = new Color(r, r, r); |
|
133 |
r = Color.LIGHT_GRAY.getRed(); |
|
134 |
color2 = new Color(r, r, r); |
|
135 |
} |
|
136 |
|
|
137 |
if ((width - 1) == 0) |
|
138 |
return Color.BLACK; |
|
139 |
if (pos < 1) |
|
140 |
pos = 1; |
|
141 |
if (pos > (width - 1)) |
|
142 |
pos = width - 1; |
|
143 |
r = (color1.getRed() + ((color2.getRed() - color1.getRed()) * pos) / (width - 1)); |
|
144 |
g = (color1.getGreen() + ((color2.getGreen() - color1.getGreen()) * pos) / (width - 1)); |
|
145 |
b = (color1.getBlue() + ((color2.getBlue() - color1.getBlue()) * pos) / (width - 1)); |
|
146 |
return new Color(r, g, b); |
|
147 |
} |
|
119 | 148 |
/** |
120 | 149 |
* Redibujar el componente en el graphics temporal |
121 | 150 |
*/ |
122 | 151 |
public void redrawBuffer() { |
123 | 152 |
if (getBufferGraphics() == null) return; |
124 | 153 |
getBufferGraphics().setColor(this.getBackground()); |
125 |
|
|
154 |
|
|
126 | 155 |
getBufferGraphics().fillRect(0,0,width,height); |
127 | 156 |
|
128 |
int color = 0; |
|
157 |
int top = (height - 11)/2; |
|
158 |
top -= 6; |
|
129 | 159 |
for (int i=1; i<=(width-1); i++) { |
130 |
color = (i*255)/width; |
|
131 |
getBufferGraphics().setColor(new Color(color,color,color)); |
|
132 |
getBufferGraphics().drawLine(i,1,i,12); |
|
160 |
getBufferGraphics().setColor(getColorPosition(i)); |
|
161 |
getBufferGraphics().drawLine(i,top,i,top+10); |
|
133 | 162 |
} |
134 | 163 |
|
135 |
drawTriangle(valuetopixel(x1), Color.BLACK); |
|
136 |
drawTriangle(valuetopixel(x2), Color.WHITE); |
|
164 |
drawTriangle(valuetopixel(x1), top, getColorPosition(valuetopixel(x1))); |
|
165 |
if (twoSliders) |
|
166 |
drawTriangle(valuetopixel(x2), top, getColorPosition(valuetopixel(x2))); |
|
137 | 167 |
} |
138 | 168 |
|
139 | 169 |
/** |
... | ... | |
142 | 172 |
* @param x |
143 | 173 |
* @param color |
144 | 174 |
*/ |
145 |
private void drawTriangle(int x, Color color) { |
|
146 |
getBufferGraphics().setColor(color); |
|
147 |
getBufferGraphics().drawLine(x, 14, x, 18); |
|
148 |
getBufferGraphics().drawLine(x-1, 16, x-1, 18); |
|
149 |
getBufferGraphics().drawLine(x+1, 16, x+1, 18); |
|
150 |
getBufferGraphics().drawLine(x-2, 18, x-2, 18); |
|
151 |
getBufferGraphics().drawLine(x+2, 18, x+2, 18); |
|
175 |
private void drawTriangle(int x, int y, Color color) { |
|
176 |
if (isEnabled()) { |
|
177 |
getBufferGraphics().setColor(color); |
|
178 |
getBufferGraphics().drawLine(x, y + 12, x, y + 16); |
|
179 |
getBufferGraphics().drawLine(x-1, y + 14, x-1, y + 16); |
|
180 |
getBufferGraphics().drawLine(x+1, y + 14, x+1, y + 16); |
|
181 |
getBufferGraphics().drawLine(x-2, y + 16, x-2, y + 16); |
|
182 |
getBufferGraphics().drawLine(x+2, y + 16, x+2, y + 16); |
|
183 |
} |
|
152 | 184 |
|
153 |
getBufferGraphics().setColor(Color.BLACK); |
|
154 |
getBufferGraphics().drawLine(x, 12, x-3, 19); |
|
155 |
getBufferGraphics().drawLine(x, 12, x+3, 19); |
|
156 |
getBufferGraphics().drawLine(x-3, 19, x+3, 19); |
|
185 |
if (isEnabled()) { |
|
186 |
getBufferGraphics().setColor(Color.BLACK); |
|
187 |
} else { |
|
188 |
getBufferGraphics().setColor(Color.GRAY); |
|
189 |
} |
|
190 |
getBufferGraphics().drawLine(x, y + 10, x-3, y + 17); |
|
191 |
getBufferGraphics().drawLine(x, y + 10, x+3, y + 17); |
|
192 |
getBufferGraphics().drawLine(x-3, y + 17, x+3, y + 17); |
|
157 | 193 |
} |
158 | 194 |
|
159 | 195 |
/** |
... | ... | |
175 | 211 |
private int valuetopixel(int value) { |
176 | 212 |
return ((value-minimum)*(width-3)/(maximum-minimum)) + 1; |
177 | 213 |
} |
178 |
|
|
214 |
|
|
179 | 215 |
/** |
180 | 216 |
* Convierte un pixel al valor que deber?a tener |
181 | 217 |
* @param value |
... | ... | |
202 | 238 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) |
203 | 239 |
*/ |
204 | 240 |
public void mousePressed(MouseEvent e) { |
241 |
if (!isEnabled()) |
|
242 |
return; |
|
205 | 243 |
if (e.getButton() != MouseEvent.BUTTON1) return; |
206 | 244 |
|
207 | 245 |
int aux = pixeltovalue(e.getX()+1); |
... | ... | |
212 | 250 |
else |
213 | 251 |
valuePressed = 1; |
214 | 252 |
|
253 |
if (!twoSliders) |
|
254 |
valuePressed = 1; |
|
255 |
|
|
215 | 256 |
changeValue(e.getX()); |
216 | 257 |
} |
217 | 258 |
|
... | ... | |
229 | 270 |
private void validateValues() { |
230 | 271 |
if (x1 < minimum) x1 = minimum; |
231 | 272 |
if (x1 > maximum) x1 = maximum; |
232 |
if (x2 < minimum) x2 = minimum; |
|
233 |
if (x2 > maximum) x2 = maximum; |
|
273 |
if (twoSliders) { |
|
274 |
if (x2 < minimum) x2 = minimum; |
|
275 |
if (x2 > maximum) x2 = maximum; |
|
276 |
} |
|
234 | 277 |
} |
235 | 278 |
|
236 | 279 |
/** |
... | ... | |
239 | 282 |
*/ |
240 | 283 |
public void setX1(int value) { |
241 | 284 |
x1 = value; |
242 |
if (x1 > x2) x2 = x1; |
|
285 |
if (twoSliders) |
|
286 |
if (x1 > x2) |
|
287 |
x2 = x1; |
|
243 | 288 |
validateValues(); |
244 | 289 |
refreshImage(); |
245 | 290 |
} |
246 |
|
|
291 |
|
|
247 | 292 |
/** |
293 |
* Es lo mismo que setX1() |
|
294 |
* @param value |
|
295 |
*/ |
|
296 |
public void setValue(int value) { |
|
297 |
setX1(value); |
|
298 |
} |
|
299 |
|
|
300 |
/** |
|
248 | 301 |
* Establecer el valor del extremo derecho del slider |
249 | 302 |
* @param value |
250 | 303 |
*/ |
... | ... | |
254 | 307 |
validateValues(); |
255 | 308 |
refreshImage(); |
256 | 309 |
} |
257 |
|
|
310 |
|
|
258 | 311 |
/** |
259 | 312 |
* Obtener el valor del extremo izquierdo del componente |
260 | 313 |
* @return |
... | ... | |
262 | 315 |
public int getX1() { |
263 | 316 |
return x1; |
264 | 317 |
} |
265 |
|
|
318 |
|
|
266 | 319 |
/** |
320 |
* Devuelve lo mismo que getX1() |
|
321 |
* @return |
|
322 |
*/ |
|
323 |
public int getValue() { |
|
324 |
return getX1(); |
|
325 |
} |
|
326 |
|
|
327 |
/** |
|
267 | 328 |
* Obtener el valor del extremo derecho del componente |
268 | 329 |
* @return |
269 | 330 |
*/ |
270 | 331 |
public int getX2() { |
271 | 332 |
return x2; |
272 | 333 |
} |
273 |
|
|
334 |
|
|
274 | 335 |
/** |
275 | 336 |
* M?todo usado por los eventos del rat?n para establecer una nueva posici?n |
276 | 337 |
* del slider |
277 | 338 |
* @param pos |
278 | 339 |
*/ |
279 | 340 |
private void changeValue(int pos) { |
341 |
if (!isEnabled()) |
|
342 |
return; |
|
280 | 343 |
if (valuePressed == 0) return; |
281 |
|
|
344 |
|
|
282 | 345 |
int aux = pixeltovalue(pos + 1); |
283 |
|
|
346 |
|
|
284 | 347 |
if (valuePressed == 1) setX1(aux); |
285 | 348 |
if (valuePressed == 2) setX2(aux); |
286 | 349 |
callValueChangedListeners(); |
... | ... | |
291 | 354 |
* @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent) |
292 | 355 |
*/ |
293 | 356 |
public void mouseDragged(MouseEvent arg0) { |
357 |
if (!isEnabled()) |
|
358 |
return; |
|
294 | 359 |
changeValue(arg0.getX()); |
295 | 360 |
} |
296 | 361 |
|
... | ... | |
300 | 365 |
*/ |
301 | 366 |
public void mouseMoved(MouseEvent e) { |
302 | 367 |
} |
303 |
|
|
368 |
|
|
304 | 369 |
/* |
305 | 370 |
* (non-Javadoc) |
306 | 371 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) |
307 | 372 |
*/ |
308 | 373 |
public void mouseClicked(MouseEvent e) { |
309 | 374 |
} |
310 |
|
|
375 |
|
|
311 | 376 |
/* |
312 | 377 |
* (non-Javadoc) |
313 | 378 |
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) |
314 | 379 |
*/ |
315 | 380 |
public void mouseEntered(MouseEvent e) { |
316 | 381 |
} |
317 |
|
|
382 |
|
|
318 | 383 |
/* |
319 | 384 |
* (non-Javadoc) |
320 | 385 |
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent) |
... | ... | |
350 | 415 |
DoubleSliderListener listener = (DoubleSliderListener) acIterator.next(); |
351 | 416 |
listener.actionValueChanged(new DoubleSliderEvent(this)); |
352 | 417 |
} |
353 |
eventId++; |
|
354 | 418 |
} |
419 |
|
|
420 |
/** |
|
421 |
* @return the twoSliders |
|
422 |
*/ |
|
423 |
public boolean isTwoSliders() { |
|
424 |
return twoSliders; |
|
425 |
} |
|
426 |
|
|
427 |
/** |
|
428 |
* @param twoSliders the twoSliders to set |
|
429 |
*/ |
|
430 |
public void setTwoSliders(boolean twoSliders) { |
|
431 |
this.twoSliders = twoSliders; |
|
432 |
refreshImage(); |
|
433 |
} |
|
434 |
|
|
435 |
/** |
|
436 |
* @param color1 the color1 to set |
|
437 |
*/ |
|
438 |
public void setColor1(Color color1) { |
|
439 |
this.color1 = color1; |
|
440 |
refreshImage(); |
|
441 |
} |
|
442 |
|
|
443 |
/** |
|
444 |
* @param color2 the color2 to set |
|
445 |
*/ |
|
446 |
public void setColor2(Color color2) { |
|
447 |
this.color2 = color2; |
|
448 |
refreshImage(); |
|
449 |
} |
|
450 |
|
|
451 |
/* (non-Javadoc) |
|
452 |
* @see javax.swing.JComponent#setEnabled(boolean) |
|
453 |
*/ |
|
454 |
public void setEnabled(boolean enabled) { |
|
455 |
super.setEnabled(enabled); |
|
456 |
refreshImage(); |
|
457 |
} |
|
355 | 458 |
} |
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/checkslidertext/CheckColorSliderTextContainer.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.gui.beans.checkslidertext; |
|
20 |
|
|
21 |
import java.awt.BorderLayout; |
|
22 |
import java.awt.Dimension; |
|
23 |
import java.awt.GridBagConstraints; |
|
24 |
import java.awt.GridBagLayout; |
|
25 |
import java.awt.Insets; |
|
26 |
import java.awt.event.ActionEvent; |
|
27 |
import java.awt.event.ActionListener; |
|
28 |
|
|
29 |
import javax.swing.JCheckBox; |
|
30 |
import javax.swing.JPanel; |
|
31 |
|
|
32 |
import org.gvsig.gui.beans.slidertext.ColorSliderTextContainer; |
|
33 |
/** |
|
34 |
* A?ade un check al componente Slider ajustando el tama?o del componente a la |
|
35 |
* longitud del check. Al redimensionar el componente varia el tama?o del slider |
|
36 |
* |
|
37 |
* @version 08/06/2007 |
|
38 |
* @author Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
39 |
*/ |
|
40 |
public class CheckColorSliderTextContainer extends ColorSliderTextContainer implements ActionListener { |
|
41 |
private static final long serialVersionUID = 7047604405777061995L; |
|
42 |
public JCheckBox check = null; |
|
43 |
private JPanel pLabel = null; |
|
44 |
private String text = null; |
|
45 |
|
|
46 |
/** |
|
47 |
* Constructor |
|
48 |
* @param min Valor m?nimo del slider |
|
49 |
* @param max Valor m?ximo del slider |
|
50 |
* @param defaultPos Posici?n inicial |
|
51 |
* @param txt Texto de la etiqueta del check |
|
52 |
* @param active Valor por defecto del control.True activo y false desactivo |
|
53 |
*/ |
|
54 |
public CheckColorSliderTextContainer(int min, int max, int defaultPos, String txt, boolean active) { |
|
55 |
super(min, max, defaultPos); |
|
56 |
text = txt; |
|
57 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
58 |
gridBagConstraints1.insets = new Insets(0,0,0,0); |
|
59 |
super.add(getPCheck(), BorderLayout.WEST); |
|
60 |
check.addActionListener(this); |
|
61 |
check.setSelected(active); |
|
62 |
setControlEnabled(active); |
|
63 |
|
|
64 |
this.setMaximumSize(new Dimension(32767, 36)); |
|
65 |
this.setMinimumSize(new Dimension(250, 36)); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* This method initializes jPanel |
|
70 |
* |
|
71 |
* @return javax.swing.JPanel |
|
72 |
*/ |
|
73 |
private JPanel getPCheck() { |
|
74 |
if (pLabel == null) { |
|
75 |
pLabel = new JPanel(); |
|
76 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
77 |
gridBagConstraints1.insets = new java.awt.Insets(0, 0, 10, 0); |
|
78 |
pLabel.setLayout(new GridBagLayout()); |
|
79 |
pLabel.add(getCheck(), gridBagConstraints1); |
|
80 |
} |
|
81 |
return pLabel; |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* This method initializes JLabel |
|
86 |
* @return |
|
87 |
*/ |
|
88 |
private JCheckBox getCheck() { |
|
89 |
if (check == null) |
|
90 |
check = new JCheckBox(text); |
|
91 |
return check; |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* Activa o desactiva el control del panel |
|
96 |
* @param active |
|
97 |
*/ |
|
98 |
public void setChecked(boolean active) { |
|
99 |
getCheck().setSelected(active); |
|
100 |
super.setControlEnabled(active); |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* Devuelve si el control esta activo |
|
105 |
* @param active |
|
106 |
*/ |
|
107 |
public boolean isChecked() { |
|
108 |
return getCheck().isSelected(); |
|
109 |
} |
|
110 |
|
|
111 |
public void actionPerformed(ActionEvent e) { |
|
112 |
if (e.getSource() == check) { |
|
113 |
setControlEnabled(check.isSelected()); |
|
114 |
callChangeValue(); |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
/* (non-Javadoc) |
|
119 |
* @see javax.swing.JComponent#setEnabled(boolean) |
|
120 |
*/ |
|
121 |
public void setEnabled(boolean enabled) { |
|
122 |
getCheck().setEnabled(enabled); |
|
123 |
if (enabled) { |
|
124 |
if (!getCheck().isSelected()) { |
|
125 |
getSlider().setEnabled(false); |
|
126 |
getJSpinner().setEnabled(false); |
|
127 |
} else { |
|
128 |
super.setEnabled(enabled); |
|
129 |
} |
|
130 |
} else { |
|
131 |
super.setEnabled(enabled); |
|
132 |
} |
|
133 |
} |
|
134 |
} |
|
0 | 135 |
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/slidertext/ColorSliderTextContainer.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.gui.beans.slidertext; |
|
20 |
|
|
21 |
import java.awt.BorderLayout; |
|
22 |
import java.awt.Color; |
|
23 |
import java.awt.Dimension; |
|
24 |
import java.awt.GridBagConstraints; |
|
25 |
import java.awt.GridBagLayout; |
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.Iterator; |
|
28 |
|
|
29 |
import javax.swing.JPanel; |
|
30 |
import javax.swing.JSpinner; |
|
31 |
import javax.swing.event.ChangeEvent; |
|
32 |
import javax.swing.event.ChangeListener; |
|
33 |
|
|
34 |
import org.gvsig.gui.beans.doubleslider.DoubleSlider; |
|
35 |
import org.gvsig.gui.beans.doubleslider.DoubleSliderEvent; |
|
36 |
import org.gvsig.gui.beans.doubleslider.DoubleSliderListener; |
|
37 |
/** |
|
38 |
* Barra de deslizamiento con una ventana de texto que tiene el valor de la |
|
39 |
* posici?n de la barra. En este control podr? controlarse mediante la entrada |
|
40 |
* de datos por la caja de texto la posibilidad de introducir valores decimales. |
|
41 |
* |
|
42 |
* Nacho Brodin (nachobrodin@gmail.com) |
|
43 |
*/ |
|
44 |
public class ColorSliderTextContainer extends JPanel implements ChangeListener, DoubleSliderListener { |
|
45 |
private static final long serialVersionUID = 1876415954410511634L; |
|
46 |
private JPanel pText = null; |
|
47 |
private DoubleSlider slider = null; |
|
48 |
private JSpinner jSpinner = null; |
|
49 |
private int min = 0; |
|
50 |
private int max = 255; |
|
51 |
private int defaultPos = 0; |
|
52 |
|
|
53 |
private ArrayList actionCommandListeners = new ArrayList(); |
|
54 |
private boolean bDoCallListeners = true; |
|
55 |
|
|
56 |
/** |
|
57 |
* Contructor |
|
58 |
* @param min Valor m?nimo de la barra |
|
59 |
* @param max Valor m?ximo de la barra |
|
60 |
* @param defaultPos Posici?n por defecto |
|
61 |
*/ |
|
62 |
public ColorSliderTextContainer(int min, int max, int defaultPos) { |
|
63 |
super(); |
|
64 |
this.min = min; |
|
65 |
this.max = max; |
|
66 |
this.defaultPos = defaultPos; |
|
67 |
|
|
68 |
initialize(); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* Constructor vacio |
|
73 |
*/ |
|
74 |
public ColorSliderTextContainer() { |
|
75 |
this(0, 100, 0); |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* This method initializes this |
|
80 |
* |
|
81 |
*/ |
|
82 |
private void initialize() { |
|
83 |
this.setLayout(new BorderLayout(5, 5)); |
|
84 |
this.add(getSlider(), BorderLayout.CENTER); |
|
85 |
this.add(getPText(), BorderLayout.EAST); |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* This method initializes jPanel1 |
|
90 |
* |
|
91 |
* @return javax.swing.JPanel |
|
92 |
*/ |
|
93 |
private JPanel getPText() { |
|
94 |
if (pText == null) { |
|
95 |
pText = new JPanel(); |
|
96 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
97 |
gridBagConstraints1.insets = new java.awt.Insets(0, 10, 8, 0); |
|
98 |
pText.setLayout(new GridBagLayout()); |
|
99 |
pText.add(getJSpinner(), gridBagConstraints1); |
|
100 |
} |
|
101 |
return pText; |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* This method initializes jSlider |
|
106 |
* |
|
107 |
* @return javax.swing.JSlider |
|
108 |
*/ |
|
109 |
public DoubleSlider getSlider() { |
|
110 |
if (slider == null) { |
|
111 |
slider = new DoubleSlider(); |
|
112 |
slider.setMinimum(min); |
|
113 |
slider.setMaximum(max); |
|
114 |
slider.setValue(defaultPos); |
|
115 |
slider.addValueChangedListener(this); |
|
116 |
} |
|
117 |
return slider; |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* This method initializes jTextField |
|
122 |
* |
|
123 |
* @return javax.swing.JTextField |
|
124 |
*/ |
|
125 |
public JSpinner getJSpinner() { |
|
126 |
if (jSpinner == null) { |
|
127 |
jSpinner = new JSpinner(); |
|
128 |
jSpinner.setValue(new Integer(defaultPos)); |
|
129 |
jSpinner.setPreferredSize(new Dimension(50, 26)); |
|
130 |
jSpinner.setMinimumSize(new Dimension(50, 26)); |
|
131 |
jSpinner.addChangeListener(this); |
|
132 |
} |
|
133 |
return jSpinner; |
|
134 |
} |
|
135 |
|
|
136 |
public void setComponentSize(int w, int h){ |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* Obtiene el valor del control. |
|
141 |
* @return Valor del control en formato double. |
|
142 |
*/ |
|
143 |
public int getValue() { |
|
144 |
return new Integer(getJSpinner().getValue() + "").intValue(); |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* Asigna el valor del control. |
|
149 |
* @return Valor del control en formato double. |
|
150 |
*/ |
|
151 |
public void setValue(int value) { |
|
152 |
getJSpinner().setValue(new Integer(value)); |
|
153 |
getSlider().setValue(value); |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* Activa o desactiva el control del panel |
|
158 |
* @param active |
|
159 |
*/ |
|
160 |
public void setControlEnabled(boolean active){ |
|
161 |
getSlider().setEnabled(active); |
|
162 |
getJSpinner().setEnabled(active); |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* Obtiene el valor m?ximo del slider |
|
167 |
* @return Entero con el valor m?ximo |
|
168 |
*/ |
|
169 |
public int getMax() { |
|
170 |
return max; |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* Asigna el valor m?ximo del slider |
|
175 |
* @param Entero con el valor m?ximo |
|
176 |
* @deprecated Usar setMaximum en su lugar |
|
177 |
*/ |
|
178 |
public void setMax(int max) { |
|
179 |
this.setMaximum(max); |
|
180 |
} |
|
181 |
|
|
182 |
/** |
|
183 |
* Asigna el valor m?ximo del slider |
|
184 |
* @param Entero con el valor m?ximo |
|
185 |
*/ |
|
186 |
public void setMaximum(int max) { |
|
187 |
this.max = max; |
|
188 |
updateInterval(); |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* Obtiene el valor m?nimo del slider |
|
193 |
* @return Entero con el valor m?nimo |
|
194 |
*/ |
|
195 |
public int getMin() { |
|
196 |
return min; |
|
197 |
} |
|
198 |
|
|
199 |
/** |
|
200 |
* Asigna el valor m?nimo del slider |
|
201 |
* @param Entero con el valor m?nimo |
|
202 |
* @deprecated Usar setMinimum |
|
203 |
*/ |
|
204 |
public void setMin(int min) { |
|
205 |
this.setMinimum(min); |
|
206 |
} |
|
207 |
|
|
208 |
/** |
|
209 |
* Asigna el valor m?nimo del slider |
|
210 |
* @param Entero con el valor m?nimo |
|
211 |
*/ |
|
212 |
public void setMinimum(int min) { |
|
213 |
this.min = min; |
|
214 |
updateInterval(); |
|
215 |
} |
|
216 |
|
|
217 |
private void updateInterval() { |
|
218 |
int aux = this.getValue(); |
|
219 |
getSlider().setMinimum(min); |
|
220 |
getSlider().setMaximum(max); |
|
221 |
setValue(aux); |
|
222 |
} |
|
223 |
|
|
224 |
/** |
|
225 |
* Especificar el color izquierdo del control |
|
226 |
* @param color |
|
227 |
*/ |
|
228 |
public void setColor1(Color color) { |
|
229 |
slider.setColor1(color); |
|
230 |
} |
|
231 |
|
|
232 |
/** |
|
233 |
* Especificar el color derecho del control |
|
234 |
* @param color |
|
235 |
*/ |
|
236 |
public void setColor2(Color color) { |
|
237 |
slider.setColor2(color); |
|
238 |
} |
|
239 |
|
|
240 |
/** |
|
241 |
* Controla cuando cambia el spinner |
|
242 |
*/ |
|
243 |
public void stateChanged(ChangeEvent e) { |
|
244 |
int value = new Integer(getJSpinner().getValue().toString()).intValue(); |
|
245 |
getSlider().setValue(value); |
|
246 |
if (new Integer(getJSpinner().getValue().toString()).intValue() != getSlider().getValue()) |
|
247 |
getJSpinner().setValue(new Integer(getSlider().getValue())); |
|
248 |
|
|
249 |
callChangeValue(); |
|
250 |
} |
|
251 |
|
|
252 |
/** |
|
253 |
* Controla cuando cambia el slider |
|
254 |
*/ |
|
255 |
public void actionValueChanged(DoubleSliderEvent e) { |
|
256 |
int value = getSlider().getValue(); |
|
257 |
getJSpinner().setValue(new Integer(value)); |
|
258 |
|
|
259 |
callChangeValue(); |
|
260 |
} |
|
261 |
|
|
262 |
/** |
|
263 |
* Dispara el evento del cambio del control |
|
264 |
*/ |
|
265 |
protected void callChangeValue() { |
|
266 |
if (!bDoCallListeners) |
|
267 |
return; |
|
268 |
Iterator acIterator = actionCommandListeners.iterator(); |
|
269 |
while (acIterator.hasNext()) { |
|
270 |
DoubleSliderListener listener = (DoubleSliderListener) acIterator.next(); |
|
271 |
listener.actionValueChanged(new DoubleSliderEvent(this)); |
|
272 |
} |
|
273 |
} |
|
274 |
|
|
275 |
/** |
|
276 |
* A?adir un listener a la lista de eventos |
|
277 |
* @param listener |
|
278 |
*/ |
|
279 |
public void addValueChangedListener(DoubleSliderListener listener) { |
|
280 |
if (!actionCommandListeners.contains(listener)) |
|
281 |
actionCommandListeners.add(listener); |
|
282 |
} |
|
283 |
|
|
284 |
/** |
|
285 |
* Borrar un listener de la lista de eventos |
|
286 |
* @param listener |
|
287 |
*/ |
|
288 |
public void removeValueChangedListener(DoubleSliderListener listener) { |
|
289 |
actionCommandListeners.remove(listener); |
|
290 |
} |
|
291 |
|
|
292 |
/* (non-Javadoc) |
|
293 |
* @see javax.swing.JComponent#setEnabled(boolean) |
|
294 |
*/ |
|
295 |
public void setEnabled(boolean enabled) { |
|
296 |
super.setEnabled(enabled); |
|
297 |
jSpinner.setEnabled(enabled); |
|
298 |
slider.setEnabled(enabled); |
|
299 |
} |
|
300 |
} |
|
0 | 301 |
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/slidertext/SliderTextContainer.java | ||
---|---|---|
50 | 50 |
private int defaultPos = 0; |
51 | 51 |
private SliderTextListener listener = null; |
52 | 52 |
private boolean decimal = false; |
53 |
|
|
53 |
|
|
54 | 54 |
/** |
55 | 55 |
* Contructor |
56 | 56 |
* @param min Valor m?nimo de la barra |
... | ... | |
62 | 62 |
this.min = min; |
63 | 63 |
this.max = max; |
64 | 64 |
this.defaultPos = defaultPos; |
65 |
|
|
65 |
|
|
66 | 66 |
initialize(); |
67 | 67 |
} |
68 |
|
|
68 |
|
|
69 | 69 |
/** |
70 | 70 |
* Constructor vacio |
71 | 71 |
*/ |
... | ... | |
81 | 81 |
public void addChangeListener(ChangeListener l){ |
82 | 82 |
listener.changeListenerList.add(l); |
83 | 83 |
} |
84 |
|
|
84 |
|
|
85 | 85 |
/** |
86 | 86 |
* A?ade un MouseListener al panel. |
87 | 87 |
* @param l |
... | ... | |
89 | 89 |
public void addMouseListener(MouseListener l){ |
90 | 90 |
listener.mouseListenerList.add(l); |
91 | 91 |
} |
92 |
|
|
92 |
|
|
93 | 93 |
/** |
94 | 94 |
* A?ade un ChangeListener al panel. El m?todo stateChanged del listener registrado |
95 | 95 |
* ser? ejecutado cuando se accione el slider. |
... | ... | |
98 | 98 |
public void addKeyListener(KeyListener l){ |
99 | 99 |
listener.keyListenerList.add(l); |
100 | 100 |
} |
101 |
|
|
101 |
|
|
102 | 102 |
/** |
103 | 103 |
* Asigna un borde al componente con el texto pasado como |
104 | 104 |
* par?metro |
... | ... | |
107 | 107 |
public void setBorder(String name){ |
108 | 108 |
setBorder(javax.swing.BorderFactory.createTitledBorder(null, name, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
109 | 109 |
} |
110 |
|
|
110 |
|
|
111 | 111 |
/** |
112 | 112 |
* This method initializes this |
113 | 113 |
* |
114 | 114 |
*/ |
115 | 115 |
private void initialize() { |
116 | 116 |
listener = new SliderTextListener(this); |
117 |
this.setLayout(new BorderLayout());
|
|
118 |
this.add(getSlider(), BorderLayout.CENTER);
|
|
119 |
this.add(getPText(), BorderLayout.EAST);
|
|
120 |
this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1));
|
|
117 |
this.setLayout(new BorderLayout());
|
|
118 |
this.add(getSlider(), BorderLayout.CENTER);
|
|
119 |
this.add(getPText(), BorderLayout.EAST);
|
|
120 |
this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1));
|
|
121 | 121 |
} |
122 | 122 |
|
123 | 123 |
/** |
... | ... | |
170 | 170 |
} |
171 | 171 |
return text; |
172 | 172 |
} |
173 |
|
|
173 |
|
|
174 | 174 |
public void setComponentSize(int w, int h){ |
175 | 175 |
} |
176 |
|
|
176 |
|
|
177 | 177 |
/** |
178 | 178 |
* Obtiene el valor del control. |
179 | 179 |
* @return Valor del control en formato double. |
... | ... | |
193 | 193 |
getTextField().setText(String.valueOf((int)value)); |
194 | 194 |
getSlider().setValue((int) ((value - min) / interval)); |
195 | 195 |
} |
196 |
|
|
196 |
|
|
197 | 197 |
/** |
198 | 198 |
* Activa o desactiva el control del panel |
199 | 199 |
* @param active |
... | ... | |
205 | 205 |
getTextField().setBackground(pText.getBackground()); |
206 | 206 |
}else{ |
207 | 207 |
getTextField().setBackground(java.awt.Color.white); |
208 |
}
|
|
208 |
} |
|
209 | 209 |
} |
210 |
|
|
210 |
|
|
211 | 211 |
/** |
212 | 212 |
* Asigna el flag que dice si el valor del campo de texto ser? |
213 | 213 |
* decimal o entero |
... | ... | |
225 | 225 |
getTextField().setText(s.substring(0, index + 1)); |
226 | 226 |
} |
227 | 227 |
} |
228 |
|
|
228 |
|
|
229 | 229 |
/** |
230 | 230 |
* Obtiene el flag que dice si el valor del campo de texto es |
231 | 231 |
* decimal o entero |
... | ... | |
242 | 242 |
public int getMax() { |
243 | 243 |
return max; |
244 | 244 |
} |
245 |
|
|
245 |
|
|
246 | 246 |
/** |
247 | 247 |
* Asigna el valor m?ximo del slider |
248 | 248 |
* @param Entero con el valor m?ximo |
... | ... | |
277 | 277 |
public void setMin(int min) { |
278 | 278 |
this.setMinimum(min); |
279 | 279 |
} |
280 |
|
|
280 |
|
|
281 | 281 |
/** |
282 | 282 |
* Asigna el valor m?nimo del slider |
283 | 283 |
* @param Entero con el valor m?nimo |
... | ... | |
286 | 286 |
this.min = min; |
287 | 287 |
updateInterval(); |
288 | 288 |
} |
289 |
|
|
289 |
|
|
290 | 290 |
/** |
291 | 291 |
* Actualizar la separacion entre los Ticks |
292 | 292 |
*/ |
... | ... | |
296 | 296 |
slider.setPaintTicks(true); |
297 | 297 |
getSlider().setMinorTickSpacing(ticks); |
298 | 298 |
} |
299 |
|
|
299 |
|
|
300 | 300 |
private void updateInterval() { |
301 | 301 |
double aux = this.getValue(); |
302 | 302 |
getSlider().setMinimum(0); |
... | ... | |
312 | 312 |
interval = value; |
313 | 313 |
updateInterval(); |
314 | 314 |
} |
315 |
|
|
315 |
|
|
316 | 316 |
/** |
317 | 317 |
* Obtener el intervalo definido para el slider |
318 | 318 |
* @return |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/TranspByPixelPanel.java | ||
---|---|---|
34 | 34 |
import org.gvsig.rastertools.properties.dialog.IResizable; |
35 | 35 |
|
36 | 36 |
import com.iver.andami.PluginServices; |
37 |
|
|
38 | 37 |
/** |
39 |
* Panel con los controles para la transparencia por pixel. Incluye los |
|
40 |
* textbox para a?adir un RGB a la lista.
|
|
38 |
* Panel con los controles para la transparencia por pixel. Incluye los textbox
|
|
39 |
* para a?adir un RGB a la lista. |
|
41 | 40 |
* |
42 | 41 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
43 |
* |
|
44 | 42 |
*/ |
45 |
public class TranspByPixelPanel extends JPanel implements IResizable{ |
|
46 |
final private static long serialVersionUID = 0;
|
|
47 |
private TranspByPixelRGBInputPanel pWest = null;
|
|
48 |
private JPanel pEast = null;
|
|
49 |
private JPanel pCenter = null;
|
|
50 |
private TranspByPixelAddRemoveButtonsPanel pButtons = null;
|
|
51 |
private TranspByPixelAndOrSelectorPanel pOperation = null;
|
|
52 |
private JList jList = null;
|
|
53 |
private TranspByPixelListener listener = null;
|
|
54 |
private DefaultListModel listModel = null;
|
|
55 |
private boolean controlEnabled = false;
|
|
56 |
private JPanel pixelSelector = null;
|
|
57 |
private JPanel activeControl = null;
|
|
58 |
private JCheckBox activeCheck = null;
|
|
59 |
|
|
43 |
public class TranspByPixelPanel extends JPanel implements IResizable {
|
|
44 |
private static final long serialVersionUID = -1131297200332579683L;
|
|
45 |
private boolean controlEnabled = false;
|
|
46 |
private DefaultListModel listModel = null;
|
|
47 |
private JCheckBox activeCheck = null;
|
|
48 |
private JList jList = null;
|
|
49 |
private JPanel pixelSelector = null;
|
|
50 |
private JPanel activeControl = null;
|
|
51 |
private JPanel pEast = null;
|
|
52 |
private JPanel pCenter = null;
|
|
53 |
private TranspByPixelRGBInputPanel pWest = null;
|
|
54 |
private TranspByPixelAddRemoveButtonsPanel pButtons = null;
|
|
55 |
private TranspByPixelAndOrSelectorPanel pOperation = null;
|
|
56 |
private TranspByPixelListener listener = null;
|
|
57 |
|
|
60 | 58 |
/** |
61 | 59 |
* This is the default constructor |
62 | 60 |
*/ |
63 | 61 |
public TranspByPixelPanel() { |
64 |
super(); |
|
65 | 62 |
initialize(); |
66 | 63 |
listener = new TranspByPixelListener(this); |
67 | 64 |
this.setControlEnabled(false); |
... | ... | |
69 | 66 |
|
70 | 67 |
/** |
71 | 68 |
* This method initializes this |
72 |
* |
|
73 |
* @return void |
|
74 | 69 |
*/ |
75 | 70 |
private void initialize() { |
76 | 71 |
setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "transp_by_pixel"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
77 |
setLayout(new BorderLayout()); |
|
72 |
setLayout(new BorderLayout(5, 5));
|
|
78 | 73 |
add(getActiveControl(), BorderLayout.NORTH); |
79 | 74 |
add(getPixelSelector(), BorderLayout.CENTER); |
80 | 75 |
} |
81 | 76 |
|
82 | 77 |
/** |
83 |
* Obtiene el panel con los controles principales para introducir valores |
|
84 |
* RGB en la lista
|
|
78 |
* Obtiene el panel con los controles principales para introducir valores RGB
|
|
79 |
* en la lista |
|
85 | 80 |
* @return JPanel |
86 | 81 |
*/ |
87 |
private JPanel getPixelSelector(){ |
|
88 |
if(pixelSelector == null){ |
|
82 |
private JPanel getPixelSelector() { |
|
83 |
if (pixelSelector == null) { |
|
84 |
|
|
89 | 85 |
pixelSelector = new JPanel(); |
90 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
91 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 15); |
|
92 |
gridBagConstraints.gridx = 0; |
|
93 |
gridBagConstraints.gridy = 0; |
|
94 |
|
|
95 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
96 |
gridBagConstraints1.insets = new java.awt.Insets(0, 0, 0, 40); |
|
97 |
gridBagConstraints1.gridx = 1; |
|
98 |
gridBagConstraints1.gridy = 0; |
|
99 |
|
|
100 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
|
101 |
gridBagConstraints1.gridx = 2; |
|
102 |
gridBagConstraints1.gridy = 0; |
|
86 |
pixelSelector.setBorder(javax.swing.BorderFactory.createEmptyBorder(11, 11, 11, 11)); |
|
103 | 87 |
|
104 |
pixelSelector.setLayout(new GridBagLayout()); |
|
105 |
//setMinimumSize(new Dimension(400, 185)); |
|
106 |
|
|
107 |
pixelSelector.add(getPRGBInput(), gridBagConstraints); |
|
108 |
pixelSelector.add(getPCenter(), gridBagConstraints1); |
|
109 |
pixelSelector.add(getPList(), gridBagConstraints2); |
|
88 |
pixelSelector.setLayout(new BorderLayout(5, 5)); |
|
89 |
|
|
90 |
JPanel jpanel1 = new JPanel(); |
|
91 |
jpanel1.setLayout(new BorderLayout(5, 5)); |
|
92 |
jpanel1.add(getPRGBInput(), BorderLayout.CENTER); |
|
93 |
jpanel1.add(getPCenter(), BorderLayout.EAST); |
|
94 |
|
|
95 |
pixelSelector.add(jpanel1, BorderLayout.CENTER); |
|
96 |
pixelSelector.add(getPList(), BorderLayout.EAST); |
|
110 | 97 |
} |
111 | 98 |
return pixelSelector; |
112 | 99 |
} |
113 |
|
|
100 |
|
|
114 | 101 |
/** |
115 | 102 |
* Obtiene el panel con el control de activaci?n |
116 | 103 |
* @return JPanel |
117 | 104 |
*/ |
118 |
private JPanel getActiveControl(){ |
|
105 |
private JPanel getActiveControl() {
|
|
119 | 106 |
if(activeControl == null){ |
120 | 107 |
activeControl = new JPanel(); |
121 | 108 |
FlowLayout fl = new FlowLayout(); |
... | ... | |
125 | 112 |
} |
126 | 113 |
return activeControl; |
127 | 114 |
} |
128 |
|
|
115 |
|
|
129 | 116 |
/** |
130 | 117 |
* Obtiene el check que activa y desactiva la transparencia por pixel. |
131 | 118 |
* @return JCheckBox |
132 | 119 |
*/ |
133 |
public JCheckBox getActiveCheck(){ |
|
134 |
if(activeCheck == null){ |
|
120 |
public JCheckBox getActiveCheck() {
|
|
121 |
if(activeCheck == null) {
|
|
135 | 122 |
activeCheck = new JCheckBox(PluginServices.getText(this, "activar")); |
136 | 123 |
activeCheck.setSelected(false); |
137 | 124 |
} |
138 | 125 |
return activeCheck; |
139 | 126 |
} |
140 |
|
|
127 |
|
|
141 | 128 |
/** |
142 | 129 |
* This method initializes jPanel |
143 |
* |
|
144 |
* @return javax.swing.JPanel |
|
130 |
* @return |
|
145 | 131 |
*/ |
146 | 132 |
public TranspByPixelRGBInputPanel getPRGBInput() { |
147 | 133 |
if (pWest == null) { |
148 |
FlowLayout flowLayout = new FlowLayout(); |
|
149 |
flowLayout.setHgap(1); |
|
150 |
flowLayout.setAlignment(java.awt.FlowLayout.LEFT); |
|
151 |
flowLayout.setVgap(1); |
|
152 | 134 |
pWest = new TranspByPixelRGBInputPanel(); |
153 |
pWest.setLayout(flowLayout); |
|
154 |
pWest.setPreferredSize(new java.awt.Dimension(120,90)); |
|
155 | 135 |
} |
156 | 136 |
return pWest; |
157 | 137 |
} |
158 | 138 |
|
159 | 139 |
/** |
160 | 140 |
* This method initializes jPanel1 |
161 |
* |
|
162 | 141 |
* @return javax.swing.JPanel |
163 | 142 |
*/ |
164 | 143 |
public JPanel getPList() { |
... | ... | |
179 | 158 |
} |
180 | 159 |
|
181 | 160 |
/** |
182 |
* This method initializes jPanel2 |
|
183 |
* |
|
161 |
* This method initializes pCenter |
|
184 | 162 |
* @return javax.swing.JPanel |
185 | 163 |
*/ |
186 | 164 |
private JPanel getPCenter() { |
... | ... | |
195 | 173 |
gridBagConstraints.gridx = 0; |
196 | 174 |
pCenter = new JPanel(); |
197 | 175 |
pCenter.setLayout(new GridBagLayout()); |
198 |
pCenter.setPreferredSize(new java.awt.Dimension(65,118)); |
|
176 |
// pCenter.setPreferredSize(new java.awt.Dimension(65,118));
|
|
199 | 177 |
pCenter.add(getPButtons(), gridBagConstraints); |
200 | 178 |
pCenter.add(getPOperation(), gridBagConstraints1); |
201 | 179 |
} |
... | ... | |
210 | 188 |
public JPanel getPButtons() { |
211 | 189 |
if (pButtons == null) { |
212 | 190 |
pButtons = new TranspByPixelAddRemoveButtonsPanel(); |
213 |
pButtons.setPreferredSize(new java.awt.Dimension(60,50)); |
|
214 | 191 |
} |
215 | 192 |
return pButtons; |
216 | 193 |
} |
... | ... | |
242 | 219 |
} |
243 | 220 |
return jList; |
244 | 221 |
} |
245 |
|
|
222 |
|
|
246 | 223 |
/** |
247 | 224 |
* Obtiene el ListModel de la lista |
248 | 225 |
* @return DefaultListModel |
... | ... | |
250 | 227 |
public DefaultListModel getListModel(){ |
251 | 228 |
return listModel; |
252 | 229 |
} |
253 |
|
|
230 |
|
|
254 | 231 |
/** |
255 | 232 |
* Asigna los tama?os de los componentes y el panel a partir del tama?o |
256 | 233 |
* introducido. |
... | ... | |
258 | 235 |
* @param h |
259 | 236 |
*/ |
260 | 237 |
public void setComponentSize(int w, int h){ |
261 |
|
|
238 |
|
|
262 | 239 |
} |
263 |
|
|
264 |
|
|
240 |
|
|
241 |
|
|
265 | 242 |
/** |
266 | 243 |
* Activa o desactiva el control |
267 | 244 |
* @param enable True activa el control y false lo desactiva |
... | ... | |
269 | 246 |
public void setControlEnabled(boolean enabled){ |
270 | 247 |
this.getActiveCheck().setSelected(enabled); |
271 | 248 |
jList.setEnabled(enabled); |
272 |
if(enabled) |
|
249 |
if (enabled)
|
|
273 | 250 |
jList.setBackground(Color.WHITE); |
274 | 251 |
else |
275 | 252 |
jList.setBackground(this.getBackground()); |
... | ... | |
278 | 255 |
pOperation.setControlEnabled(enabled); |
279 | 256 |
controlEnabled = enabled; |
280 | 257 |
} |
281 |
|
|
258 |
|
|
282 | 259 |
/** |
283 | 260 |
* Obtiene true si el control est? activo y false si no lo est? |
284 | 261 |
* @return |
... | ... | |
286 | 263 |
public boolean isControlEnabled(){ |
287 | 264 |
return controlEnabled; |
288 | 265 |
} |
289 |
|
|
266 |
|
|
290 | 267 |
/** |
291 | 268 |
* Asigna el n?mero de bandas activas |
292 | 269 |
* @param n N?mero de bandas |
... | ... | |
294 | 271 |
public void setActiveBands(int n){ |
295 | 272 |
((TranspByPixelRGBInputPanel)getPRGBInput()).setActiveBands(n); |
296 | 273 |
} |
297 |
|
|
274 |
|
|
298 | 275 |
/** |
299 | 276 |
* Obtiene el array de entradas de valores a?adidos a la lista |
300 | 277 |
* @return ArrayList |
... | ... | |
302 | 279 |
public ArrayList getEntries(){ |
303 | 280 |
return listener.getEntries(); |
304 | 281 |
} |
305 |
|
|
282 |
|
|
306 | 283 |
/** |
307 | 284 |
* Asigna el array de entradas de valores a?adidos a la lista |
308 | 285 |
* @return ArrayList |
... | ... | |
327 | 304 |
getListModel().addElement(entry); |
328 | 305 |
getEntries().add(new TransparencyRange(entry)); |
329 | 306 |
} |
330 |
|
|
307 |
|
|
331 | 308 |
/** |
332 | 309 |
* A?ade una entrada a la tabla |
333 | 310 |
* @param entry objeto TransparencyRange |
... | ... | |
336 | 313 |
getListModel().addElement(entry.getStrEntry()); |
337 | 314 |
getEntries().add(entry); |
338 | 315 |
} |
339 |
|
|
316 |
|
|
340 | 317 |
/** |
341 | 318 |
* Borra las entradas de la tabla |
342 | 319 |
*/ |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/TranspByPixelAddRemoveButtonsPanel.java | ||
---|---|---|
18 | 18 |
*/ |
19 | 19 |
package org.gvsig.rastertools.properties.panels; |
20 | 20 |
|
21 |
import java.awt.FlowLayout; |
|
22 | 21 |
import java.awt.GridBagConstraints; |
23 |
import java.awt.GridBagLayout; |
|
24 | 22 |
|
25 | 23 |
import javax.swing.ImageIcon; |
26 | 24 |
import javax.swing.JButton; |
27 | 25 |
import javax.swing.JPanel; |
28 | 26 |
|
29 | 27 |
public class TranspByPixelAddRemoveButtonsPanel extends JPanel { |
30 |
final private static long serialVersionUID = 0; |
|
31 |
private JPanel pBorder = null; |
|
32 |
private JButton bAdd = null; |
|
33 |
private JButton bRemove = null; |
|
28 |
private static final long serialVersionUID = 8860840036907665706L; |
|
29 |
private JButton bAdd = null; |
|
30 |
private JButton bRemove = null; |
|
34 | 31 |
|
35 | 32 |
/** |
36 | 33 |
* This is the default constructor |
37 | 34 |
*/ |
38 | 35 |
public TranspByPixelAddRemoveButtonsPanel() { |
39 |
super(); |
|
40 | 36 |
initialize(); |
41 | 37 |
} |
42 | 38 |
|
43 | 39 |
/** |
44 | 40 |
* This method initializes this |
45 |
* |
|
46 |
* @return void |
|
47 | 41 |
*/ |
48 | 42 |
private void initialize() { |
49 |
FlowLayout flowLayout = new FlowLayout(); |
|
50 |
flowLayout.setHgap(0); |
|
51 |
flowLayout.setVgap(0); |
|
52 |
this.setLayout(flowLayout); |
|
53 |
this.setSize(26, 52); |
|
54 |
this.add(getJPanel(), null); |
|
55 |
} |
|
43 |
setLayout(new java.awt.GridBagLayout()); |
|
56 | 44 |
|
57 |
/** |
|
58 |
* This method initializes jPanel |
|
59 |
* |
|
60 |
* @return javax.swing.JPanel |
|
61 |
*/ |
|
62 |
private JPanel getJPanel() { |
|
63 |
if (pBorder == null) { |
|
64 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
65 |
gridBagConstraints1.insets = new java.awt.Insets(3,3,3,3); |
|
66 |
gridBagConstraints1.gridy = 1; |
|
67 |
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST; |
|
68 |
gridBagConstraints1.gridx = 0; |
|
69 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
70 |
gridBagConstraints.insets = new java.awt.Insets(3,3,3,3); |
|
71 |
gridBagConstraints.gridy = 0; |
|
72 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
73 |
gridBagConstraints.gridx = 0; |
|
74 |
pBorder = new JPanel(); |
|
75 |
pBorder.setLayout(new GridBagLayout()); |
|
76 |
pBorder.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,0,0)); |
|
77 |
pBorder.add(getBAdd(), gridBagConstraints); |
|
78 |
pBorder.add(getBRemove(), gridBagConstraints1); |
|
79 |
} |
|
80 |
return pBorder; |
|
45 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
46 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
|
47 |
gridBagConstraints.gridy = 0; |
|
48 |
gridBagConstraints.gridx = 0; |
|
49 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
50 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
51 |
gridBagConstraints1.insets = new java.awt.Insets(3, 3, 3, 3); |
|
52 |
gridBagConstraints1.gridy = 1; |
|
53 |
gridBagConstraints1.gridx = 0; |
|
54 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
55 |
add(getBAdd(), gridBagConstraints); |
|
56 |
add(getBRemove(), gridBagConstraints1); |
|
81 | 57 |
} |
82 | 58 |
|
83 | 59 |
/** |
84 |
* This method initializes jButton
|
|
60 |
* This method initializes bAdd
|
|
85 | 61 |
* |
86 | 62 |
* @return javax.swing.JButton |
87 | 63 |
*/ |
88 | 64 |
public JButton getBAdd() { |
89 | 65 |
if (bAdd == null) { |
90 |
bAdd = new JButton(); |
|
91 |
bAdd.setPreferredSize(new java.awt.Dimension(20,20));
|
|
66 |
bAdd = new JButton("A?adir");
|
|
67 |
bAdd.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
|
|
92 | 68 |
bAdd.setIcon(new ImageIcon("./gvSIG/extensiones/com.iver.cit.gvsig/images/forward.png")); |
93 | 69 |
} |
94 | 70 |
return bAdd; |
95 | 71 |
} |
96 | 72 |
|
97 | 73 |
/** |
98 |
* This method initializes jButton1
|
|
74 |
* This method initializes bRemove
|
|
99 | 75 |
* |
100 | 76 |
* @return javax.swing.JButton |
101 | 77 |
*/ |
102 | 78 |
public JButton getBRemove() { |
103 | 79 |
if (bRemove == null) { |
104 |
bRemove = new JButton(); |
|
105 |
bRemove.setPreferredSize(new java.awt.Dimension(20,20));
|
|
80 |
bRemove = new JButton("Quitar");
|
|
81 |
bRemove.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
|
|
106 | 82 |
bRemove.setIcon(new ImageIcon("./gvSIG/extensiones/com.iver.cit.gvsig/images/backward.png")); |
107 | 83 |
} |
108 | 84 |
return bRemove; |
109 | 85 |
} |
110 |
|
|
86 |
|
|
111 | 87 |
/** |
112 | 88 |
* Activa o desactiva el control |
113 | 89 |
* @param enable True activa el control y false lo desactiva |
114 | 90 |
*/ |
115 |
public void setControlEnabled(boolean enabled){ |
|
91 |
public void setControlEnabled(boolean enabled) {
|
|
116 | 92 |
this.getBAdd().setEnabled(enabled); |
117 | 93 |
this.getBRemove().setEnabled(enabled); |
118 | 94 |
} |
119 |
|
|
120 |
} |
|
95 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/TranspByPixelRGBInputPanel.java | ||
---|---|---|
19 | 19 |
package org.gvsig.rastertools.properties.panels; |
20 | 20 |
|
21 | 21 |
import java.awt.Color; |
22 |
import java.awt.FlowLayout; |
|
23 |
import java.awt.GridBagConstraints; |
Also available in: Unified diff