Revision 12127
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/doubleslider/DoubleSlider.java | ||
---|---|---|
135 | 135 |
r = Color.DARK_GRAY.getRed(); |
136 | 136 |
color1 = new Color(r, r, r); |
137 | 137 |
r = Color.LIGHT_GRAY.getRed(); |
138 |
r = Color.WHITE.getRed(); |
|
138 | 139 |
color2 = new Color(r, r, r); |
139 | 140 |
} |
140 | 141 |
|
... | ... | |
165 | 166 |
getBufferGraphics().drawLine(i,top,i,top+10); |
166 | 167 |
} |
167 | 168 |
|
169 |
if (!isEnabled()) |
|
170 |
getBufferGraphics().setColor(Color.LIGHT_GRAY); |
|
171 |
else |
|
172 |
getBufferGraphics().setColor(Color.BLACK); |
|
173 |
getBufferGraphics().drawRect(1, top, width - 2, 10); |
|
174 |
|
|
168 | 175 |
drawTriangle(valuetopixel(x1), top, getColorPosition(valuetopixel(x1))); |
169 | 176 |
if (twoSliders) |
170 | 177 |
drawTriangle(valuetopixel(x2), top, getColorPosition(valuetopixel(x2))); |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/TranspByPixelAddRemoveButtonsPanel.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 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.rastertools.properties.panels; |
|
20 |
|
|
21 |
import java.awt.GridBagConstraints; |
|
22 |
|
|
23 |
import javax.swing.ImageIcon; |
|
24 |
import javax.swing.JButton; |
|
25 |
import javax.swing.JPanel; |
|
26 |
|
|
27 |
public class TranspByPixelAddRemoveButtonsPanel extends JPanel { |
|
28 |
private static final long serialVersionUID = 8860840036907665706L; |
|
29 |
private JButton bAdd = null; |
|
30 |
private JButton bRemove = null; |
|
31 |
|
|
32 |
/** |
|
33 |
* This is the default constructor |
|
34 |
*/ |
|
35 |
public TranspByPixelAddRemoveButtonsPanel() { |
|
36 |
initialize(); |
|
37 |
} |
|
38 |
|
|
39 |
/** |
|
40 |
* This method initializes this |
|
41 |
*/ |
|
42 |
private void initialize() { |
|
43 |
setLayout(new java.awt.GridBagLayout()); |
|
44 |
|
|
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); |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* This method initializes bAdd |
|
61 |
* |
|
62 |
* @return javax.swing.JButton |
|
63 |
*/ |
|
64 |
public JButton getBAdd() { |
|
65 |
if (bAdd == null) { |
|
66 |
bAdd = new JButton("A?adir"); |
|
67 |
bAdd.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); |
|
68 |
bAdd.setIcon(new ImageIcon("./gvSIG/extensiones/com.iver.cit.gvsig/images/forward.png")); |
|
69 |
} |
|
70 |
return bAdd; |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* This method initializes bRemove |
|
75 |
* |
|
76 |
* @return javax.swing.JButton |
|
77 |
*/ |
|
78 |
public JButton getBRemove() { |
|
79 |
if (bRemove == null) { |
|
80 |
bRemove = new JButton("Quitar"); |
|
81 |
bRemove.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
|
82 |
bRemove.setIcon(new ImageIcon("./gvSIG/extensiones/com.iver.cit.gvsig/images/backward.png")); |
|
83 |
} |
|
84 |
return bRemove; |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* Activa o desactiva el control |
|
89 |
* @param enable True activa el control y false lo desactiva |
|
90 |
*/ |
|
91 |
public void setControlEnabled(boolean enabled) { |
|
92 |
this.getBAdd().setEnabled(enabled); |
|
93 |
this.getBRemove().setEnabled(enabled); |
|
94 |
} |
|
95 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/TranspByPixelListener.java | ||
---|---|---|
26 | 26 |
import javax.swing.JCheckBox; |
27 | 27 |
import javax.swing.JList; |
28 | 28 |
import javax.swing.JRadioButton; |
29 |
import javax.swing.event.ListSelectionEvent; |
|
30 |
import javax.swing.event.ListSelectionListener; |
|
29 | 31 |
|
32 |
import org.gvsig.gui.beans.doubleslider.DoubleSliderEvent; |
|
33 |
import org.gvsig.gui.beans.doubleslider.DoubleSliderListener; |
|
30 | 34 |
import org.gvsig.raster.util.TransparencyRange; |
31 |
|
|
32 | 35 |
/** |
33 | 36 |
* Maneja los eventos para el panel de transparencia por pixel. |
34 | 37 |
* |
35 | 38 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
36 |
* |
|
37 | 39 |
*/ |
38 |
public class TranspByPixelListener implements ActionListener { |
|
39 |
private ArrayList entries = new ArrayList(); |
|
40 |
private JButton addButton = null; |
|
41 |
private JButton removeButton = null; |
|
42 |
private JCheckBox cbActivar = null; |
|
43 |
private JList list = null; |
|
44 |
private JRadioButton andRb = null; |
|
45 |
private JRadioButton orRb = null; |
|
46 |
private TranspByPixelPanel panel = null; |
|
47 |
private TranspByPixelRGBInputPanel rgbInputPanel = null; |
|
40 |
public class TranspByPixelListener implements ActionListener, ListSelectionListener, DoubleSliderListener { |
|
41 |
private ArrayList entries = new ArrayList(); |
|
42 |
private JButton addButton = null; |
|
43 |
private JButton removeButton = null; |
|
44 |
private JCheckBox cbActivar = null; |
|
45 |
private JList list = null; |
|
46 |
private JRadioButton andRb = null; |
|
47 |
private JRadioButton orRb = null; |
|
48 |
private TranspByPixelPanel panel = null; |
|
49 |
private TranspByPixelRGBInputPanel rgbInputPanel = null; |
|
50 |
boolean eventsDisabled = false; |
|
51 |
private int itemSelected = -1; |
|
48 | 52 |
|
49 | 53 |
/** |
50 | 54 |
* This is the default constructor |
51 | 55 |
*/ |
52 | 56 |
public TranspByPixelListener(TranspByPixelPanel panel) { |
53 | 57 |
this.panel = panel; |
54 |
rgbInputPanel = ((TranspByPixelRGBInputPanel) panel.getPRGBInput());
|
|
58 |
rgbInputPanel = panel.getPRGBInput();
|
|
55 | 59 |
list = panel.getJList(); |
56 | 60 |
|
57 |
addButton = ((TranspByPixelAddRemoveButtonsPanel) panel.getPButtons()).getBAdd();
|
|
58 |
removeButton = ((TranspByPixelAddRemoveButtonsPanel) panel.getPButtons()).getBRemove();
|
|
59 |
andRb = ((TranspByPixelAndOrSelectorPanel) panel.getPOperation()).getRbAnd();
|
|
60 |
orRb = ((TranspByPixelAndOrSelectorPanel) panel.getPOperation()).getRbOr();
|
|
61 |
addButton = panel.getBAdd();
|
|
62 |
removeButton = panel.getBRemove();
|
|
63 |
andRb = panel.getPOperation().getRbAnd();
|
|
64 |
orRb = panel.getPOperation().getRbOr();
|
|
61 | 65 |
cbActivar = panel.getActiveCheck(); |
62 | 66 |
|
63 | 67 |
addButton.addActionListener(this); |
... | ... | |
65 | 69 |
andRb.addActionListener(this); |
66 | 70 |
orRb.addActionListener(this); |
67 | 71 |
cbActivar.addActionListener(this); |
72 |
|
|
73 |
list.addListSelectionListener(this); |
|
74 |
|
|
75 |
panel.getPRGBInput().getTBlue().addValueChangedListener(this); |
|
76 |
panel.getPRGBInput().getTGreen().addValueChangedListener(this); |
|
77 |
panel.getPRGBInput().getTRed().addValueChangedListener(this); |
|
78 |
panel.getPRGBInput().getTAlpha().addValueChangedListener(this); |
|
68 | 79 |
} |
69 | 80 |
|
70 |
//******************************* |
|
71 |
//ActionListener |
|
81 |
/** |
|
82 |
* Obtiene el objeto TransparencyRange equivalente a los valores RGBA |
|
83 |
* seleccionados. |
|
84 |
* |
|
85 |
* @return TransparencyRange o null si la selecci?n no es correcta. |
|
86 |
*/ |
|
87 |
private TransparencyRange getEntrySelected() { |
|
88 |
if (!rgbInputPanel.isValidValue()) |
|
89 |
return null; |
|
72 | 90 |
|
73 |
public void actionPerformed(ActionEvent e) { |
|
91 |
TransparencyRange entry = new TransparencyRange(); |
|
92 |
entry.setRed(rgbInputPanel.getRangeRed()); |
|
93 |
entry.setGreen(rgbInputPanel.getRangeGreen()); |
|
94 |
entry.setBlue(rgbInputPanel.getRangeBlue()); |
|
95 |
if (rgbInputPanel.getTAlpha().isChecked()) |
|
96 |
entry.setAlpha(255 - rgbInputPanel.getTAlpha().getValue()); |
|
97 |
else |
|
98 |
entry.setAlpha(0); |
|
74 | 99 |
|
75 |
// A?ade elementos a la lista |
|
76 |
if (e.getSource() == addButton) { |
|
77 |
if (rgbInputPanel.isValidValue()) { |
|
78 |
TransparencyRange entry = new TransparencyRange(); |
|
79 |
entry.setRed(rgbInputPanel.getRangeRed()); |
|
80 |
entry.setGreen(rgbInputPanel.getRangeGreen()); |
|
81 |
entry.setBlue(rgbInputPanel.getRangeBlue()); |
|
82 |
if (rgbInputPanel.getTAlpha().isChecked()) |
|
83 |
entry.setAlpha(255 - rgbInputPanel.getTAlpha().getValue()); |
|
84 |
else |
|
85 |
entry.setAlpha(0); |
|
100 |
String textR = rgbInputPanel.getTRed().getValue() + ""; |
|
101 |
if (!rgbInputPanel.getTRed().isChecked()) |
|
102 |
textR = "*"; |
|
103 |
String textG = rgbInputPanel.getTGreen().getValue() + ""; |
|
104 |
if (!rgbInputPanel.getTGreen().isChecked()) |
|
105 |
textG = "*"; |
|
106 |
String textB = rgbInputPanel.getTBlue().getValue() + ""; |
|
107 |
if (!rgbInputPanel.getTBlue().isChecked()) |
|
108 |
textB = "*"; |
|
86 | 109 |
|
87 |
String textR = rgbInputPanel.getTRed().getValue() + ""; |
|
88 |
if (!rgbInputPanel.getTRed().isChecked()) |
|
89 |
textR = "*"; |
|
90 |
String textG = rgbInputPanel.getTGreen().getValue() + ""; |
|
91 |
if (!rgbInputPanel.getTGreen().isChecked()) |
|
92 |
textG = "*"; |
|
93 |
String textB = rgbInputPanel.getTBlue().getValue() + ""; |
|
94 |
if (!rgbInputPanel.getTBlue().isChecked()) |
|
95 |
textB = "*"; |
|
110 |
if (andRb.isSelected()) { |
|
111 |
entry.setStrEntry(textR + " & " + textG + " & " + textB); |
|
112 |
entry.setAnd(true); |
|
113 |
} |
|
96 | 114 |
|
97 |
if (andRb.isSelected()) { |
|
98 |
entry.setStrEntry(textR + " & " + textG + " & " + textB); |
|
99 |
entry.setAnd(true); |
|
100 |
} |
|
115 |
if (orRb.isSelected()) { |
|
116 |
entry.setStrEntry(textR + " | " + textG + " | " + textB); |
|
117 |
entry.setAnd(false); |
|
118 |
} |
|
119 |
return entry; |
|
120 |
} |
|
101 | 121 |
|
102 |
if (orRb.isSelected()) { |
|
103 |
entry.setStrEntry(textR + " | " + textG + " | " + textB); |
|
104 |
entry.setAnd(false); |
|
105 |
} |
|
122 |
/** |
|
123 |
* Actualiza el item seleccionado cogiendo los valores del RGB |
|
124 |
*/ |
|
125 |
private void updateData() { |
|
126 |
if (itemSelected == -1) |
|
127 |
return; |
|
106 | 128 |
|
129 |
TransparencyRange entry = getEntrySelected(); |
|
130 |
if (entry != null) { |
|
131 |
entries.set(itemSelected, entry); |
|
132 |
panel.getListModel().set(itemSelected, entry.getStrEntry()); |
|
133 |
panel.callValueChanged(); |
|
134 |
} |
|
135 |
} |
|
136 |
|
|
137 |
/* |
|
138 |
* (non-Javadoc) |
|
139 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
|
140 |
*/ |
|
141 |
public void actionPerformed(ActionEvent e) { |
|
142 |
|
|
143 |
if ((e.getSource() == andRb) || (e.getSource() == orRb)) { |
|
144 |
updateData(); |
|
145 |
return; |
|
146 |
} |
|
147 |
|
|
148 |
// A?ade elementos a la lista |
|
149 |
if (e.getSource() == addButton) { |
|
150 |
TransparencyRange entry = getEntrySelected(); |
|
151 |
if (entry != null) { |
|
152 |
entries.add(entry); |
|
153 |
itemSelected = entries.size() - 1; |
|
107 | 154 |
panel.getListModel().addElement(entry.getStrEntry()); |
108 |
entries.add(entry);
|
|
155 |
setValues(itemSelected);
|
|
109 | 156 |
|
110 |
// Limpiamos los textField |
|
111 |
rgbInputPanel.getTRed().setValue(0); |
|
112 |
rgbInputPanel.getTGreen().setValue(0); |
|
113 |
rgbInputPanel.getTBlue().setValue(0); |
|
114 |
rgbInputPanel.getTAlpha().setValue(255); |
|
115 |
rgbInputPanel.getTRed().setChecked(true); |
|
116 |
rgbInputPanel.getTGreen().setChecked(true); |
|
117 |
rgbInputPanel.getTBlue().setChecked(true); |
|
118 |
rgbInputPanel.getTAlpha().setChecked(false); |
|
157 |
removeButton.setEnabled(true); |
|
158 |
panel.callValueChanged(); |
|
119 | 159 |
} |
160 |
return; |
|
120 | 161 |
} |
121 | 162 |
|
122 | 163 |
// Elimina elementos de la lista |
123 | 164 |
if (e.getSource() == removeButton) { |
124 |
if (list.getSelectedIndex() != -1) { |
|
125 |
String rule = (String) panel.getListModel().get(list.getSelectedIndex()); |
|
126 |
String[] s = rule.split(" & "); |
|
127 |
if (s.length < 3) { |
|
128 |
s = rule.split(" \\| "); |
|
129 |
andRb.setSelected(false); |
|
130 |
orRb.setSelected(true); |
|
131 |
} else { |
|
132 |
andRb.setSelected(true); |
|
133 |
orRb.setSelected(false); |
|
134 |
} |
|
165 |
if (itemSelected != -1) { |
|
166 |
entries.remove(itemSelected); |
|
167 |
panel.getListModel().remove(itemSelected); |
|
135 | 168 |
|
136 |
for (int i = 0; i < s.length; i++) { |
|
137 |
if (s[i].equals("*")) |
|
138 |
s[i] = ""; |
|
169 |
if (itemSelected >= entries.size()) { |
|
170 |
itemSelected = entries.size() - 1; |
|
139 | 171 |
} |
172 |
setValues(itemSelected); |
|
140 | 173 |
|
141 |
if (s.length == 3) { |
|
142 |
if (s[0].trim().equals("")) { |
|
143 |
rgbInputPanel.getTRed().setValue(0); |
|
144 |
rgbInputPanel.getTRed().setChecked(false); |
|
145 |
} else { |
|
146 |
rgbInputPanel.getTRed().setValue(Integer.parseInt(s[0].trim())); |
|
147 |
rgbInputPanel.getTRed().setChecked(true); |
|
148 |
} |
|
174 |
if (entries.size() == 0) |
|
175 |
removeButton.setEnabled(false); |
|
176 |
panel.callValueChanged(); |
|
177 |
} |
|
178 |
return; |
|
179 |
} |
|
149 | 180 |
|
150 |
if (s[1].trim().equals("")) { |
|
151 |
rgbInputPanel.getTGreen().setValue(0); |
|
152 |
rgbInputPanel.getTGreen().setChecked(false); |
|
153 |
} else { |
|
154 |
rgbInputPanel.getTGreen().setValue(Integer.parseInt(s[1].trim())); |
|
155 |
rgbInputPanel.getTGreen().setChecked(true); |
|
156 |
} |
|
181 |
if (e.getSource() == cbActivar) { |
|
182 |
panel.setControlEnabled(cbActivar.isSelected()); |
|
183 |
panel.callValueChanged(); |
|
184 |
return; |
|
185 |
} |
|
186 |
} |
|
157 | 187 |
|
158 |
if (s[2].trim().equals("")) { |
|
159 |
rgbInputPanel.getTBlue().setValue(0); |
|
160 |
rgbInputPanel.getTBlue().setChecked(false); |
|
161 |
} else { |
|
162 |
rgbInputPanel.getTBlue().setValue(Integer.parseInt(s[2].trim())); |
|
163 |
rgbInputPanel.getTBlue().setChecked(true); |
|
164 |
} |
|
165 |
int alpha = 255 - ((TransparencyRange) entries.get(list.getSelectedIndex())).getAlpha(); |
|
166 |
rgbInputPanel.getTAlpha().setValue(alpha); |
|
167 |
rgbInputPanel.getTAlpha().setChecked(alpha != 255); |
|
188 |
/** |
|
189 |
* Establece los valores RGBA a sus componentes segun la seleccion |
|
190 |
* @param item |
|
191 |
*/ |
|
192 |
private void setValues(int item) { |
|
168 | 193 |
|
169 |
entries.remove(list.getSelectedIndex()); |
|
170 |
panel.getListModel().remove(list.getSelectedIndex()); |
|
171 |
} |
|
172 |
} |
|
194 |
if (item >= entries.size()) { |
|
195 |
item = entries.size() - 1; |
|
173 | 196 |
} |
174 | 197 |
|
175 |
if (e.getSource() == cbActivar) |
|
176 |
panel.setControlEnabled(cbActivar.isSelected()); |
|
198 |
if (entries.size() == 0) { |
|
199 |
rgbInputPanel.getTRed().setValue(0); |
|
200 |
rgbInputPanel.getTRed().setChecked(true); |
|
201 |
rgbInputPanel.getTGreen().setValue(0); |
|
202 |
rgbInputPanel.getTGreen().setChecked(true); |
|
203 |
rgbInputPanel.getTBlue().setValue(0); |
|
204 |
rgbInputPanel.getTBlue().setChecked(true); |
|
205 |
rgbInputPanel.getTAlpha().setValue(255); |
|
206 |
rgbInputPanel.getTAlpha().setChecked(false); |
|
207 |
andRb.setSelected(true); |
|
208 |
orRb.setSelected(false); |
|
209 |
return; |
|
210 |
} |
|
211 |
TransparencyRange tr = (TransparencyRange) entries.get(item); |
|
212 |
|
|
213 |
andRb.setSelected(tr.isAnd()); |
|
214 |
orRb.setSelected(!tr.isAnd()); |
|
215 |
|
|
216 |
if (tr.getRed() == null) { |
|
217 |
rgbInputPanel.getTRed().setValue(0); |
|
218 |
rgbInputPanel.getTRed().setChecked(false); |
|
219 |
} else { |
|
220 |
rgbInputPanel.getTRed().setValue(tr.getRed()[0]); |
|
221 |
rgbInputPanel.getTRed().setChecked(true); |
|
222 |
} |
|
223 |
|
|
224 |
if (tr.getGreen() == null) { |
|
225 |
rgbInputPanel.getTGreen().setValue(0); |
|
226 |
rgbInputPanel.getTGreen().setChecked(false); |
|
227 |
} else { |
|
228 |
rgbInputPanel.getTGreen().setValue(tr.getGreen()[0]); |
|
229 |
rgbInputPanel.getTGreen().setChecked(true); |
|
230 |
} |
|
231 |
|
|
232 |
if (tr.getBlue() == null) { |
|
233 |
rgbInputPanel.getTBlue().setValue(0); |
|
234 |
rgbInputPanel.getTBlue().setChecked(false); |
|
235 |
} else { |
|
236 |
rgbInputPanel.getTBlue().setValue(tr.getBlue()[0]); |
|
237 |
rgbInputPanel.getTBlue().setChecked(true); |
|
238 |
} |
|
239 |
|
|
240 |
int alpha = 255 - tr.getAlpha(); |
|
241 |
rgbInputPanel.getTAlpha().setValue(alpha); |
|
242 |
rgbInputPanel.getTAlpha().setChecked(alpha != 255); |
|
243 |
|
|
244 |
if (list.getSelectedIndex() != item) { |
|
245 |
list.setSelectedIndex(item); |
|
246 |
} |
|
177 | 247 |
} |
178 | 248 |
|
179 | 249 |
/** |
... | ... | |
184 | 254 |
return entries; |
185 | 255 |
} |
186 | 256 |
|
257 |
/* |
|
258 |
* (non-Javadoc) |
|
259 |
* @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) |
|
260 |
*/ |
|
261 |
public void valueChanged(ListSelectionEvent e) { |
|
262 |
eventsDisabled = true; |
|
263 |
if (list.getSelectedIndex() != -1) |
|
264 |
itemSelected = list.getSelectedIndex(); |
|
265 |
|
|
266 |
setValues(itemSelected); |
|
267 |
eventsDisabled = false; |
|
268 |
} |
|
269 |
|
|
270 |
/* |
|
271 |
* (non-Javadoc) |
|
272 |
* @see org.gvsig.gui.beans.doubleslider.DoubleSliderListener#actionValueChanged(org.gvsig.gui.beans.doubleslider.DoubleSliderEvent) |
|
273 |
*/ |
|
274 |
public void actionValueChanged(DoubleSliderEvent e) { |
|
275 |
if (eventsDisabled) |
|
276 |
return; |
|
277 |
eventsDisabled = true; |
|
278 |
updateData(); |
|
279 |
eventsDisabled = false; |
|
280 |
} |
|
281 |
|
|
187 | 282 |
/** |
188 |
* Asigna el array de entradas de valores a?adidos a la lista
|
|
189 |
* @param list ArrayList
|
|
283 |
* Habilita o deshabilita la gestion de eventos
|
|
284 |
* @param value
|
|
190 | 285 |
*/ |
191 |
public void setEntries(ArrayList list) {
|
|
192 |
entries = list;
|
|
286 |
public void setEventsDisabled(boolean value) {
|
|
287 |
eventsDisabled = value;
|
|
193 | 288 |
} |
194 | 289 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/TransparencyControl.java | ||
---|---|---|
19 | 19 |
package org.gvsig.rastertools.properties.panels; |
20 | 20 |
|
21 | 21 |
import java.util.ArrayList; |
22 |
import java.util.EventObject; |
|
22 | 23 |
|
23 | 24 |
import org.gvsig.raster.grid.GridTransparency; |
24 | 25 |
import org.gvsig.raster.util.TransparencyRange; |
25 |
|
|
26 | 26 |
/** |
27 |
* |
|
28 | 27 |
* Clase que hace de interfaz entre los objetos que contienen la informaci?n de |
29 | 28 |
* transparencia y el panel. |
30 | 29 |
* |
31 | 30 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
32 | 31 |
*/ |
33 |
public class TransparencyControl { |
|
34 |
private GridTransparency transparency = null; |
|
35 |
private TransparencyPanel tPanel = null; |
|
36 |
|
|
37 |
/** |
|
38 |
* Constructor |
|
39 |
* @param tp |
|
40 |
*/ |
|
41 |
public TransparencyControl(TransparencyPanel tp) { |
|
42 |
this.tPanel = tp; |
|
43 |
} |
|
44 |
|
|
45 |
public void setTransparencyObject(GridTransparency t) { |
|
46 |
this.transparency = t; |
|
47 |
setValuesFromGridTransparencyToPanel(); |
|
48 |
} |
|
49 |
|
|
50 |
/** |
|
51 |
* Carga los valores del panel desde el objeto con la transparencia |
|
52 |
*/ |
|
53 |
private void setValuesFromGridTransparencyToPanel() { |
|
54 |
//Asignamos la opacidad al panel |
|
55 |
if(transparency.getOpacity() != 255) { |
|
56 |
tPanel.getOpacityPanel().setControlEnabled(true); |
|
57 |
tPanel.getOpacityPanel().setValue((int)(transparency.getOpacity() * 100) / 255); |
|
58 |
}else{ |
|
59 |
tPanel.getOpacityPanel().setControlEnabled(false); |
|
60 |
tPanel.getOpacityPanel().setValue(100); |
|
61 |
} |
|
62 |
|
|
63 |
//Asignamos los rangos de transparencia al panel |
|
64 |
if(transparency.getTransparencyRange().size() > 0) { |
|
65 |
tPanel.getPTranspByPixel().clear(); |
|
32 |
public class TransparencyControl implements TranspByPixelEventListener { |
|
33 |
private GridTransparency transparency = null; |
|
34 |
private TransparencyPanel tPanel = null; |
|
35 |
|
|
36 |
/** |
|
37 |
* Constructor |
|
38 |
* @param tp |
|
39 |
*/ |
|
40 |
public TransparencyControl(TransparencyPanel tp) { |
|
41 |
this.tPanel = tp; |
|
42 |
tPanel.getPTranspByPixel().addValueChangedListener(this); |
|
43 |
} |
|
44 |
|
|
45 |
public void setTransparencyObject(GridTransparency t) { |
|
46 |
this.transparency = t; |
|
47 |
setValuesFromGridTransparencyToPanel(); |
|
48 |
} |
|
49 |
|
|
50 |
/** |
|
51 |
* Carga los valores del panel desde el objeto con la transparencia |
|
52 |
*/ |
|
53 |
private void setValuesFromGridTransparencyToPanel() { |
|
54 |
//Asignamos la opacidad al panel |
|
55 |
if (transparency.getOpacity() != 255) { |
|
56 |
tPanel.getOpacityPanel().setControlEnabled(true); |
|
57 |
tPanel.getOpacityPanel().setValue((int) (transparency.getOpacity() * 100) / 255); |
|
58 |
} else { |
|
59 |
tPanel.getOpacityPanel().setControlEnabled(false); |
|
60 |
tPanel.getOpacityPanel().setValue(100); |
|
61 |
} |
|
62 |
|
|
63 |
// Asignamos los rangos de transparencia al panel |
|
64 |
tPanel.getPTranspByPixel().getListener().setEventsDisabled(true); |
|
65 |
if (transparency.getTransparencyRange().size() > 0) { |
|
66 |
tPanel.getPTranspByPixel().clear(); |
|
66 | 67 |
tPanel.getPTranspByPixel().setControlEnabled(true); |
67 |
for(int i = 0; i < transparency.getTransparencyRange().size(); i ++) { |
|
68 |
TransparencyRange range = (TransparencyRange)transparency.getTransparencyRange().get(i); |
|
69 |
tPanel.getPTranspByPixel().addStringElement(range); |
|
70 |
} |
|
71 |
}else { |
|
72 |
tPanel.getPTranspByPixel().clear(); |
|
73 |
tPanel.getPTranspByPixel().setControlEnabled(false); |
|
74 |
} |
|
75 |
|
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* Carga los valores del objeto transparencia desde el panel |
|
80 |
*/ |
|
81 |
private void setValuesFromPanelToGridTransparency() { |
|
82 |
|
|
83 |
//Asignamos la opacidad al objeto |
|
84 |
if(tPanel.getOpacityPanel().getCheck().isSelected()) { |
|
85 |
transparency.setOpacity((int)Math.round((tPanel.getOpacityPanel().getValue() * 255) / 100)); |
|
86 |
}else |
|
87 |
transparency.setOpacity(255); |
|
88 |
|
|
89 |
//Asignamos los rangos de transparencia al objeto |
|
90 |
if(tPanel.getPTranspByPixel().getActiveCheck().isSelected()) { |
|
91 |
transparency.clearListOfTransparencyRange(); |
|
92 |
ArrayList entries = tPanel.getPTranspByPixel().getEntries(); |
|
93 |
for(int i = 0; i < entries.size(); i++) |
|
94 |
transparency.setTransparencyRange((TransparencyRange)entries.get(i)); |
|
95 |
} else |
|
96 |
transparency.clearListOfTransparencyRange(); |
|
97 |
|
|
98 |
transparency.activeTransparency(); |
|
99 |
|
|
100 |
//Redibujamos |
|
101 |
if(tPanel.getLayer() != null) |
|
102 |
tPanel.getLayer().getMapContext().invalidate(); |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
68 |
for (int i = 0; i < transparency.getTransparencyRange().size(); i++) { |
|
69 |
TransparencyRange range = (TransparencyRange) transparency.getTransparencyRange().get(i); |
|
70 |
tPanel.getPTranspByPixel().addStringElement(range); |
|
71 |
} |
|
72 |
} else { |
|
73 |
tPanel.getPTranspByPixel().clear(); |
|
74 |
tPanel.getPTranspByPixel().setControlEnabled(false); |
|
75 |
} |
|
76 |
tPanel.getPTranspByPixel().getListener().setEventsDisabled(false); |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Carga los valores del objeto transparencia desde el panel |
|
81 |
*/ |
|
82 |
private void setValuesFromPanelToGridTransparency() { |
|
83 |
// Asignamos la opacidad al objeto |
|
84 |
if (tPanel.getOpacityPanel().getCheck().isSelected()) { |
|
85 |
transparency.setOpacity((int) Math.round((tPanel.getOpacityPanel().getValue() * 255) / 100)); |
|
86 |
} else |
|
87 |
transparency.setOpacity(255); |
|
88 |
|
|
89 |
// Asignamos los rangos de transparencia al objeto |
|
90 |
if (tPanel.getPTranspByPixel().getActiveCheck().isSelected()) { |
|
91 |
transparency.clearListOfTransparencyRange(); |
|
92 |
ArrayList entries = tPanel.getPTranspByPixel().getEntries(); |
|
93 |
for (int i = 0; i < entries.size(); i++) |
|
94 |
transparency.setTransparencyRange((TransparencyRange) entries.get(i)); |
|
95 |
} else |
|
96 |
transparency.clearListOfTransparencyRange(); |
|
97 |
|
|
98 |
transparency.activeTransparency(); |
|
99 |
|
|
100 |
// Redibujamos |
|
101 |
if (tPanel.getLayer() != null) |
|
102 |
tPanel.getLayer().getMapContext().invalidate(); |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
106 | 106 |
* Acciones a ejecutar cuando se acepta |
107 | 107 |
*/ |
108 | 108 |
public void accept() { |
109 |
setValuesFromPanelToGridTransparency();
|
|
109 |
setValuesFromPanelToGridTransparency(); |
|
110 | 110 |
} |
111 |
|
|
111 |
|
|
112 | 112 |
/** |
113 | 113 |
* Acciones a ejecutar cuando se aplica |
114 | 114 |
*/ |
115 | 115 |
public void apply() { |
116 | 116 |
setValuesFromPanelToGridTransparency(); |
117 | 117 |
} |
118 |
|
|
118 |
|
|
119 | 119 |
/** |
120 | 120 |
* Acciones a ejecutar cuando se cancela |
121 | 121 |
*/ |
122 |
public void cancel(){ |
|
123 |
|
|
122 |
public void cancel() { |
|
124 | 123 |
} |
125 |
|
|
126 |
} |
|
124 |
|
|
125 |
/* |
|
126 |
* (non-Javadoc) |
|
127 |
* @see org.gvsig.rastertools.properties.panels.TranspByPixelEventListener#actionPixelListChanged(java.util.EventObject) |
|
128 |
*/ |
|
129 |
public void actionPixelListChanged(EventObject e) { |
|
130 |
apply(); |
|
131 |
} |
|
132 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/TranspByPixelEventListener.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.rastertools.properties.panels; |
|
20 |
|
|
21 |
import java.util.EventListener; |
|
22 |
import java.util.EventObject; |
|
23 |
|
|
24 |
public interface TranspByPixelEventListener extends EventListener { |
|
25 |
public void actionPixelListChanged(EventObject e); |
|
26 |
} |
|
0 | 27 |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/TranspByPixelPanel.java | ||
---|---|---|
24 | 24 |
import java.awt.GridBagConstraints; |
25 | 25 |
import java.awt.GridBagLayout; |
26 | 26 |
import java.util.ArrayList; |
27 |
import java.util.EventObject; |
|
28 |
import java.util.Iterator; |
|
27 | 29 |
|
28 | 30 |
import javax.swing.DefaultListModel; |
31 |
import javax.swing.ImageIcon; |
|
32 |
import javax.swing.JButton; |
|
29 | 33 |
import javax.swing.JCheckBox; |
30 | 34 |
import javax.swing.JList; |
31 | 35 |
import javax.swing.JPanel; |
32 | 36 |
import javax.swing.JScrollPane; |
37 |
import javax.swing.ListSelectionModel; |
|
33 | 38 |
|
34 | 39 |
import org.gvsig.raster.util.TransparencyRange; |
35 |
import org.gvsig.rastertools.properties.dialog.IResizable; |
|
36 | 40 |
|
37 | 41 |
import com.iver.andami.PluginServices; |
38 | 42 |
/** |
... | ... | |
41 | 45 |
* |
42 | 46 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
43 | 47 |
*/ |
44 |
public class TranspByPixelPanel extends JPanel implements IResizable { |
|
45 |
private static final long serialVersionUID = -1131297200332579683L; |
|
46 |
private boolean controlEnabled = false; |
|
47 |
private DefaultListModel listModel = null; |
|
48 |
private JCheckBox activeCheck = null; |
|
49 |
private JList jList = null; |
|
50 |
private JPanel pixelSelector = null; |
|
51 |
private JPanel activeControl = null; |
|
52 |
private JPanel pEast = null; |
|
53 |
private JPanel pCenter = null; |
|
54 |
private TranspByPixelRGBInputPanel pWest = null; |
|
55 |
private TranspByPixelAddRemoveButtonsPanel pButtons = null; |
|
56 |
private TranspByPixelAndOrSelectorPanel pOperation = null; |
|
57 |
private TranspByPixelListener listener = null; |
|
58 |
private JScrollPane jScrollList = null; |
|
48 |
public class TranspByPixelPanel extends JPanel { |
|
49 |
private static final long serialVersionUID = -1131297200332579683L; |
|
50 |
private boolean controlEnabled = false; |
|
51 |
private DefaultListModel listModel = null; |
|
52 |
private JCheckBox activeCheck = null; |
|
53 |
private JList jList = null; |
|
54 |
private JPanel pixelSelector = null; |
|
55 |
private JPanel activeControl = null; |
|
56 |
private JPanel pEast = null; |
|
57 |
private JPanel pCenter = null; |
|
58 |
private JPanel pButtons = null; |
|
59 |
private JButton bAdd = null; |
|
60 |
private JButton bRemove = null; |
|
61 |
private JScrollPane jScrollList = null; |
|
62 |
private TranspByPixelRGBInputPanel pWest = null; |
|
63 |
private TranspByPixelAndOrSelectorPanel pOperation = null; |
|
64 |
private TranspByPixelListener listener = null; |
|
65 |
private ArrayList actionCommandListeners = new ArrayList(); |
|
59 | 66 |
|
60 | 67 |
/** |
61 | 68 |
* This is the default constructor |
... | ... | |
180 | 187 |
return pCenter; |
181 | 188 |
} |
182 | 189 |
|
190 |
|
|
183 | 191 |
/** |
192 |
* This method initializes bAdd |
|
193 |
* |
|
194 |
* @return javax.swing.JButton |
|
195 |
*/ |
|
196 |
public JButton getBAdd() { |
|
197 |
if (bAdd == null) { |
|
198 |
bAdd = new JButton("A?adir"); |
|
199 |
bAdd.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); |
|
200 |
bAdd.setIcon(new ImageIcon("./gvSIG/extensiones/com.iver.cit.gvsig/images/forward.png")); |
|
201 |
} |
|
202 |
return bAdd; |
|
203 |
} |
|
204 |
|
|
205 |
/** |
|
206 |
* This method initializes bRemove |
|
207 |
* |
|
208 |
* @return javax.swing.JButton |
|
209 |
*/ |
|
210 |
public JButton getBRemove() { |
|
211 |
if (bRemove == null) { |
|
212 |
bRemove = new JButton("Quitar"); |
|
213 |
bRemove.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
|
214 |
bRemove.setIcon(new ImageIcon("./gvSIG/extensiones/com.iver.cit.gvsig/images/backward.png")); |
|
215 |
bRemove.setEnabled(false); |
|
216 |
} |
|
217 |
return bRemove; |
|
218 |
} |
|
219 |
|
|
220 |
|
|
221 |
/** |
|
184 | 222 |
* This method initializes jPanel |
185 | 223 |
* |
186 | 224 |
* @return javax.swing.JPanel |
187 | 225 |
*/ |
188 |
public JPanel getPButtons() {
|
|
226 |
private JPanel getPButtons() {
|
|
189 | 227 |
if (pButtons == null) { |
190 |
pButtons = new TranspByPixelAddRemoveButtonsPanel(); |
|
228 |
pButtons = new JPanel(); |
|
229 |
pButtons.setLayout(new java.awt.GridBagLayout()); |
|
230 |
|
|
231 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
232 |
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); |
|
233 |
gridBagConstraints.gridy = 0; |
|
234 |
gridBagConstraints.gridx = 0; |
|
235 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
236 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
237 |
gridBagConstraints1.insets = new java.awt.Insets(3, 3, 3, 3); |
|
238 |
gridBagConstraints1.gridy = 1; |
|
239 |
gridBagConstraints1.gridx = 0; |
|
240 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
241 |
pButtons.add(getBAdd(), gridBagConstraints); |
|
242 |
pButtons.add(getBRemove(), gridBagConstraints1); |
|
191 | 243 |
} |
192 | 244 |
return pButtons; |
193 | 245 |
} |
... | ... | |
197 | 249 |
* |
198 | 250 |
* @return javax.swing.JPanel |
199 | 251 |
*/ |
200 |
public JPanel getPOperation() {
|
|
252 |
public TranspByPixelAndOrSelectorPanel getPOperation() {
|
|
201 | 253 |
if (pOperation == null) { |
202 | 254 |
pOperation = new TranspByPixelAndOrSelectorPanel(); |
203 | 255 |
pOperation.setPreferredSize(new java.awt.Dimension(60,60)); |
... | ... | |
215 | 267 |
listModel = new DefaultListModel(); |
216 | 268 |
jList = new JList(listModel); |
217 | 269 |
jList.setFont(new java.awt.Font("Monospaced", java.awt.Font.PLAIN, 10)); |
270 |
jList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
218 | 271 |
} |
219 | 272 |
return jList; |
220 | 273 |
} |
... | ... | |
241 | 294 |
} |
242 | 295 |
|
243 | 296 |
/** |
244 |
* Asigna los tama?os de los componentes y el panel a partir del tama?o |
|
245 |
* introducido. |
|
246 |
* @param w |
|
247 |
* @param h |
|
248 |
*/ |
|
249 |
public void setComponentSize(int w, int h){ |
|
250 |
|
|
251 |
} |
|
252 |
|
|
253 |
|
|
254 |
/** |
|
255 | 297 |
* Activa o desactiva el control |
256 | 298 |
* @param enable True activa el control y false lo desactiva |
257 | 299 |
*/ |
... | ... | |
263 | 305 |
else |
264 | 306 |
jList.setBackground(this.getBackground()); |
265 | 307 |
pWest.setControlEnabled(enabled); |
266 |
pButtons.setControlEnabled(enabled); |
|
308 |
getBAdd().setEnabled(enabled); |
|
309 |
|
|
310 |
if (enabled) |
|
311 |
getBRemove().setEnabled(jList.getModel().getSize()>0); |
|
312 |
else |
|
313 |
getBRemove().setEnabled(false); |
|
314 |
|
|
267 | 315 |
pOperation.setControlEnabled(enabled); |
268 | 316 |
controlEnabled = enabled; |
269 | 317 |
} |
... | ... | |
293 | 341 |
} |
294 | 342 |
|
295 | 343 |
/** |
296 |
* Asigna el array de entradas de valores a?adidos a la lista |
|
297 |
* @return ArrayList |
|
298 |
*/ |
|
299 |
public void setEntries(ArrayList list){ |
|
300 |
this.listener.setEntries(list); |
|
301 |
} |
|
302 |
|
|
303 |
/** |
|
304 | 344 |
* Obtiene la clase manejadora de eventos asociada a esta |
305 | 345 |
* @return TransparencyByPixelListener |
306 | 346 |
*/ |
... | ... | |
313 | 353 |
* @param entry Cadena en formato definido por TransparencyRange |
314 | 354 |
*/ |
315 | 355 |
public void addStringElement(String entry){ |
356 |
getEntries().add(new TransparencyRange(entry)); |
|
316 | 357 |
getListModel().addElement(entry); |
317 |
getEntries().add(new TransparencyRange(entry)); |
|
318 | 358 |
} |
319 | 359 |
|
320 | 360 |
/** |
... | ... | |
322 | 362 |
* @param entry objeto TransparencyRange |
323 | 363 |
*/ |
324 | 364 |
public void addStringElement(TransparencyRange entry){ |
365 |
getEntries().add(entry); |
|
325 | 366 |
getListModel().addElement(entry.getStrEntry()); |
326 |
getEntries().add(entry); |
|
327 | 367 |
} |
328 | 368 |
|
329 | 369 |
/** |
... | ... | |
334 | 374 |
getListModel().clear(); |
335 | 375 |
getEntries().clear(); |
336 | 376 |
} |
377 |
|
|
378 |
/** |
|
379 |
* A?adir un listener a la lista de eventos |
|
380 |
* @param listener |
|
381 |
*/ |
|
382 |
public void addValueChangedListener(TranspByPixelEventListener listener) { |
|
383 |
if (!actionCommandListeners.contains(listener)) |
|
384 |
actionCommandListeners.add(listener); |
|
385 |
} |
|
386 |
|
|
387 |
/** |
|
388 |
* Borrar un listener de la lista de eventos |
|
389 |
* @param listener |
|
390 |
*/ |
|
391 |
public void removeValueChangedListener(TranspByPixelEventListener listener) { |
|
392 |
actionCommandListeners.remove(listener); |
|
393 |
} |
|
394 |
|
|
395 |
/** |
|
396 |
* Dispara todos los manejadores que estan apuntando a este evento |
|
397 |
*/ |
|
398 |
public void callValueChanged() { |
|
399 |
Iterator acIterator = actionCommandListeners.iterator(); |
|
400 |
while (acIterator.hasNext()) { |
|
401 |
TranspByPixelEventListener listener = (TranspByPixelEventListener) acIterator.next(); |
|
402 |
listener.actionPixelListChanged(new EventObject(this)); |
|
403 |
} |
|
404 |
} |
|
337 | 405 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/EnhancedBrightnessContrastPanel.java | ||
---|---|---|
16 | 16 |
* along with this program; if not, write to the Free Software |
17 | 17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
18 | 18 |
*/ |
19 |
|
|
20 | 19 |
package org.gvsig.rastertools.properties.panels; |
21 | 20 |
|
22 | 21 |
import java.awt.BorderLayout; |
... | ... | |
33 | 32 |
import org.gvsig.gui.beans.slidertext.SliderTextContainer; |
34 | 33 |
|
35 | 34 |
import com.iver.andami.PluginServices; |
36 |
|
|
37 |
|
|
38 | 35 |
/** |
39 | 36 |
* Panel para los controles de brillo y contrase . |
40 | 37 |
* |
... | ... | |
45 | 42 |
private InternalPanel internalPanel = null; |
46 | 43 |
private JCheckBox active = null; |
47 | 44 |
private JCheckBox preview = null; |
48 |
|
|
45 |
|
|
49 | 46 |
/** |
50 | 47 |
* Panel con los controles deslizantes de brillo y contraste |
51 | 48 |
* |
... | ... | |
55 | 52 |
final private static long serialVersionUID = 0; |
56 | 53 |
protected SliderTextContainer brightness = null; |
57 | 54 |
protected SliderTextContainer contrast = null; |
58 |
|
|
55 |
|
|
59 | 56 |
/** |
60 | 57 |
* Contructor |
61 | 58 |
*/ |
... | ... | |
66 | 63 |
contrast.setBorder(PluginServices.getText(this, "contraste")); |
67 | 64 |
init(); |
68 | 65 |
} |
69 |
|
|
66 |
|
|
70 | 67 |
private void init(){ |
71 | 68 |
this.setLayout(new GridLayout(2, 1)); |
72 | 69 |
this.add(brightness); |
73 | 70 |
this.add(contrast); |
74 | 71 |
} |
75 |
|
|
72 |
|
|
76 | 73 |
/** |
77 | 74 |
* Activa o desactiva el control |
78 | 75 |
* @param enable true activa y false desactiva los controles del panel |
... | ... | |
81 | 78 |
brightness.setControlEnabled(enabled); |
82 | 79 |
contrast.setControlEnabled(enabled); |
83 | 80 |
} |
84 |
|
|
81 |
|
|
85 | 82 |
} |
86 |
|
|
83 |
|
|
87 | 84 |
/** |
88 | 85 |
* Contructor |
89 | 86 |
*/ |
... | ... | |
92 | 89 |
internalPanel = new InternalPanel(); |
93 | 90 |
initialize(); |
94 | 91 |
} |
95 |
|
|
92 |
|
|
96 | 93 |
private void initialize() { |
97 | 94 |
setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "brillo_y_contraste"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
98 | 95 |
setLayout(new BorderLayout()); |
... | ... | |
100 | 97 |
add(internalPanel, BorderLayout.CENTER); |
101 | 98 |
add(getPreview(), BorderLayout.SOUTH); |
102 | 99 |
getActive().addActionListener(this); |
103 |
|
|
100 |
|
|
104 | 101 |
} |
105 |
|
|
102 |
|
|
106 | 103 |
/** |
107 | 104 |
* Obtiene el check de activar |
108 | 105 |
* @return |
... | ... | |
115 | 112 |
} |
116 | 113 |
return active; |
117 | 114 |
} |
118 |
|
|
115 |
|
|
119 | 116 |
/** |
120 | 117 |
* Obtiene el check de previsualizaci?n |
121 | 118 |
* @return |
... | ... | |
127 | 124 |
} |
128 | 125 |
return preview; |
129 | 126 |
} |
130 |
|
|
127 |
|
|
131 | 128 |
/** |
132 | 129 |
* Activa o desactiva el control |
133 | 130 |
* @param enable true activa y false desactiva los controles del panel |
... | ... | |
137 | 134 |
this.getPreview().setEnabled(enabled); |
138 | 135 |
internalPanel.setControlEnabled(enabled); |
139 | 136 |
} |
140 |
|
|
137 |
|
|
141 | 138 |
/** |
142 | 139 |
* Obtiene el valor del brillo que hay seleccionado en el control |
143 | 140 |
* @return double que representa el contraste seleccionado. Puede hacerse un casting a entero ya que |
... | ... | |
146 | 143 |
public double getBrightnessValue(){ |
147 | 144 |
return internalPanel.brightness.getValue(); |
148 | 145 |
} |
149 |
|
|
146 |
|
|
150 | 147 |
/** |
151 | 148 |
* Obtiene el valor del contraste que hay seleccionado en el control |
152 | 149 |
* @return double que representa el contraste seleccionado. Puede hacerse un casting a entero ya que |
... | ... | |
155 | 152 |
public double getContrastValue(){ |
156 | 153 |
return internalPanel.contrast.getValue(); |
157 | 154 |
} |
158 |
|
|
155 |
|
|
159 | 156 |
/** |
160 | 157 |
* Asigna el valor del brillo al control |
161 | 158 |
* @param value |
... | ... | |
163 | 160 |
public void setBrightnessValue(double value){ |
164 | 161 |
internalPanel.brightness.setValue(value); |
165 | 162 |
} |
166 |
|
|
163 |
|
|
167 | 164 |
/** |
168 | 165 |
* Asigna el valor del contraste al control |
169 | 166 |
* @param value |
... | ... | |
171 | 168 |
public void setContrastValue(double value){ |
172 | 169 |
internalPanel.contrast.setValue(value); |
173 | 170 |
} |
174 |
|
|
171 |
|
|
175 | 172 |
/** |
176 | 173 |
* A?ade un listener para el slider de brillo |
177 | 174 |
* @param l ChangeListener |
... | ... | |
179 | 176 |
public void addBrightnessChangeListener(ChangeListener l){ |
180 | 177 |
internalPanel.brightness.addChangeListener(l); |
181 | 178 |
} |
182 |
|
|
179 |
|
|
183 | 180 |
/** |
184 | 181 |
* A?ade un listener para el slider de contraste |
185 | 182 |
* @param l ChangeListener |
... | ... | |
187 | 184 |
public void addContrastChangeListener(ChangeListener l){ |
188 | 185 |
internalPanel.contrast.addChangeListener(l); |
189 | 186 |
} |
190 |
|
|
187 |
|
|
191 | 188 |
/** |
192 | 189 |
* A?ade un listener para el slider de brillo |
193 | 190 |
* @param l MouseListener |
... | ... | |
195 | 192 |
public void addBrightnessMouseListener(MouseListener l){ |
196 | 193 |
internalPanel.brightness.addMouseListener(l); |
197 | 194 |
} |
198 |
|
|
195 |
|
|
199 | 196 |
/** |
200 | 197 |
* A?ade un listener para el slider de contraste |
201 | 198 |
* @param l MouseListener |
... | ... | |
203 | 200 |
public void addContrastMouseListener(MouseListener l){ |
204 | 201 |
internalPanel.contrast.addMouseListener(l); |
205 | 202 |
} |
206 |
|
|
203 |
|
|
207 | 204 |
/** |
208 | 205 |
* A?ade un listener para el slider de brillo |
209 | 206 |
* @param l MouseListener |
... | ... | |
211 | 208 |
public void addBrightnessKeyListener(KeyListener l){ |
212 | 209 |
internalPanel.brightness.addKeyListener(l); |
213 | 210 |
} |
214 |
|
|
211 |
|
|
215 | 212 |
/** |
216 | 213 |
* A?ade un listener para el slider de contraste |
217 | 214 |
* @param l MouseListener |
... | ... | |
219 | 216 |
public void addContrastKeyListener(KeyListener l){ |
220 | 217 |
internalPanel.contrast.addKeyListener(l); |
221 | 218 |
} |
222 |
|
|
219 |
|
|
223 | 220 |
/** |
224 | 221 |
* Maneja eventos de activar y desactivar el panel |
225 | 222 |
*/ |
... | ... | |
231 | 228 |
setControlEnabled(false); |
232 | 229 |
} |
233 | 230 |
} |
234 |
|
|
231 |
|
|
235 | 232 |
} |
236 | 233 |
|
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/panels/TranspByPixelRGBInputPanel.java | ||
---|---|---|
38 | 38 |
* @author Nacho Brodin (brodin_ign@gva.es) |
39 | 39 |
*/ |
40 | 40 |
public class TranspByPixelRGBInputPanel extends JPanel implements DoubleSliderListener { |
41 |
private static final long serialVersionUID = 5858119425941331458L;
|
|
42 |
private int[] rangeRed = null;
|
|
43 |
private int[] rangeGreen = null;
|
|
44 |
private int[] rangeBlue = null;
|
|
45 |
private boolean validValue = true;
|
|
46 |
CheckColorSliderTextContainer tRed = null; |
|
47 |
CheckColorSliderTextContainer tGreen = null; |
|
48 |
CheckColorSliderTextContainer tBlue = null; |
|
49 |
CheckColorSliderTextContainer tAlpha = null; |
|
41 |
private static final long serialVersionUID = 5858119425941331458L;
|
|
42 |
private int[] rangeRed = null;
|
|
43 |
private int[] rangeGreen = null;
|
|
44 |
private int[] rangeBlue = null;
|
|
45 |
private boolean validValue = false;
|
|
46 |
CheckColorSliderTextContainer tRed = null;
|
|
47 |
CheckColorSliderTextContainer tGreen = null;
|
|
48 |
CheckColorSliderTextContainer tBlue = null;
|
|
49 |
CheckColorSliderTextContainer tAlpha = null;
|
|
50 | 50 |
|
51 | 51 |
/** |
52 | 52 |
* This is the default constructor |
... | ... | |
55 | 55 |
super(); |
56 | 56 |
initialize(); |
57 | 57 |
updateColors(); |
58 |
validateValues(); |
|
58 | 59 |
} |
59 | 60 |
|
60 | 61 |
/** |
... | ... | |
266 | 267 |
tBlue.setColor2(new Color(r, g, 255)); |
267 | 268 |
} |
268 | 269 |
|
269 |
public void actionValueChanged(DoubleSliderEvent e) { |
|
270 |
updateColors(); |
|
270 |
public void validateValues() { |
|
271 | 271 |
validValue = true; |
272 | 272 |
rangeRed = null; |
273 | 273 |
rangeGreen = null; |
... | ... | |
302 | 302 |
} |
303 | 303 |
} |
304 | 304 |
} |
305 |
|
|
306 |
public void actionValueChanged(DoubleSliderEvent e) { |
|
307 |
updateColors(); |
|
308 |
validateValues(); |
|
309 |
} |
|
305 | 310 |
} |
Also available in: Unified diff