Revision 12939 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/colortable/panels/TabInterpolated.java
TabInterpolated.java | ||
---|---|---|
18 | 18 |
*/ |
19 | 19 |
package org.gvsig.rastertools.colortable.panels; |
20 | 20 |
|
21 |
import java.awt.BorderLayout; |
|
21 |
import java.awt.GridBagConstraints; |
|
22 |
import java.awt.GridBagLayout; |
|
22 | 23 |
|
23 | 24 |
import javax.swing.JPanel; |
24 | 25 |
|
25 |
import org.gvsig.gui.beans.colorchooser.ColorChooser; |
|
26 |
import org.gvsig.gui.beans.colorbutton.ColorButton; |
|
27 |
import org.gvsig.gui.beans.colorbutton.ColorButtonEvent; |
|
28 |
import org.gvsig.gui.beans.colorbutton.ColorButtonListener; |
|
26 | 29 |
import org.gvsig.gui.beans.colorslideredition.ColorSliderEdition; |
30 |
import org.gvsig.gui.beans.colorslideredition.ColorSliderEvent; |
|
31 |
import org.gvsig.gui.beans.colorslideredition.ColorSliderListener; |
|
32 |
import org.gvsig.gui.beans.colorslideredition.ItemColorSlider; |
|
27 | 33 |
/** |
28 | 34 |
* |
29 | 35 |
* @version 27/06/2007 |
30 | 36 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
31 | 37 |
*/ |
32 |
public class TabInterpolated extends JPanel { |
|
38 |
public class TabInterpolated extends JPanel implements ColorSliderListener, ColorButtonListener {
|
|
33 | 39 |
private static final long serialVersionUID = -5208861410196059899L; |
34 | 40 |
|
35 | 41 |
//[start]Variables UI |
36 | 42 |
private ColorSliderEdition colorSliderEdition = null; |
37 |
private ColorChooser colorChooser = null;
|
|
43 |
private ColorButton colorButton = null;
|
|
38 | 44 |
//[end] |
39 | 45 |
|
40 | 46 |
//[start] Code UI |
... | ... | |
43 | 49 |
} |
44 | 50 |
|
45 | 51 |
public void initialize() { |
46 |
setLayout(new BorderLayout()); |
|
47 |
add(getColorSliderEdition(), BorderLayout.CENTER); |
|
48 |
add(getColorChooser(), BorderLayout.SOUTH); |
|
52 |
setLayout(new GridBagLayout()); |
|
53 |
|
|
54 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
55 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; |
|
56 |
gridBagConstraints.weightx = 1.0; |
|
57 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 2, 5); |
|
58 |
|
|
59 |
add(getColorSliderEdition(), gridBagConstraints); |
|
60 |
|
|
61 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
62 |
gridBagConstraints.gridx = 0; |
|
63 |
gridBagConstraints.gridy = 1; |
|
64 |
gridBagConstraints.insets = new java.awt.Insets(2, 5, 5, 5); |
|
65 |
add(getColorButton(), gridBagConstraints); |
|
49 | 66 |
} |
50 | 67 |
|
51 |
private ColorSliderEdition getColorSliderEdition() {
|
|
68 |
public ColorSliderEdition getColorSliderEdition() {
|
|
52 | 69 |
if (colorSliderEdition == null) { |
53 | 70 |
colorSliderEdition = new ColorSliderEdition(); |
71 |
colorSliderEdition.addValueChangedListener(this); |
|
72 |
colorSliderEdition.addSelectionChangedListener(this); |
|
54 | 73 |
} |
55 | 74 |
return colorSliderEdition; |
56 | 75 |
} |
57 | 76 |
|
58 |
private ColorChooser getColorChooser() { |
|
59 |
if (colorChooser == null) { |
|
60 |
colorChooser = new ColorChooser(); |
|
77 |
private ColorButton getColorButton() { |
|
78 |
if (colorButton == null) { |
|
79 |
colorButton = new ColorButton(); |
|
80 |
colorButton.addValueChangedListener(this); |
|
61 | 81 |
} |
62 |
return colorChooser;
|
|
82 |
return colorButton;
|
|
63 | 83 |
} |
64 | 84 |
//[end] |
65 | 85 |
|
66 | 86 |
public void setInterpolated(boolean value) { |
67 | 87 |
getColorSliderEdition().setInterpolated(value); |
68 | 88 |
} |
89 |
|
|
90 |
public void actionSelectionChanged(ColorSliderEvent e) { |
|
91 |
ItemColorSlider itemColorSlider = colorSliderEdition.getSelectedItem(); |
|
92 |
if ((itemColorSlider != null) && (itemColorSlider.getSelected() == 1)) { |
|
93 |
getColorButton().setColor(itemColorSlider.getColor()); |
|
94 |
getColorButton().setEnabled(true); |
|
95 |
} else { |
|
96 |
getColorButton().setEnabled(false); |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
public void actionValueChanged(ColorSliderEvent e) { |
|
101 |
System.out.println("actionValueChanged(ColorSliderEvent e)"); |
|
102 |
} |
|
103 |
|
|
104 |
public void actionValueDragged(ColorSliderEvent e) { |
|
105 |
} |
|
106 |
|
|
107 |
private void callValueColorChanged() { |
|
108 |
ItemColorSlider itemColorSlider = colorSliderEdition.getSelectedItem(); |
|
109 |
if (itemColorSlider != null) { |
|
110 |
itemColorSlider.setColor(getColorButton().getColor()); |
|
111 |
colorSliderEdition.repaint(); |
|
112 |
} |
|
113 |
} |
|
114 |
|
|
115 |
public void actionValueDragged(ColorButtonEvent e) { |
|
116 |
callValueColorChanged(); |
|
117 |
} |
|
118 |
|
|
119 |
public void actionValueChanged(ColorButtonEvent e) { |
|
120 |
callValueColorChanged(); |
|
121 |
System.out.println("actionValueChanged(ColorButtonEvent e)"); |
|
122 |
} |
|
123 |
|
|
124 |
public void initialState() { |
|
125 |
colorSliderEdition.repaint(); |
|
126 |
getColorButton().setEnabled(false); |
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* Borra todas las filas de la tabla. |
|
131 |
*/ |
|
132 |
public void clearTable() { |
|
133 |
colorSliderEdition.removeAllItems(); |
|
134 |
} |
|
69 | 135 |
} |
Also available in: Unified diff