gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / colortable / ui / library / ColorTableLibraryPanel.java @ 1357
History | View | Annotate | Download (19 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.tools.app.basic.tool.colortable.ui.library; |
23 |
|
24 |
import java.awt.BorderLayout; |
25 |
import java.awt.Dimension; |
26 |
import java.awt.FlowLayout; |
27 |
import java.awt.event.ActionEvent; |
28 |
import java.awt.event.ActionListener; |
29 |
import java.io.File; |
30 |
import java.io.IOException; |
31 |
import java.util.ArrayList; |
32 |
import java.util.EventObject; |
33 |
import java.util.Iterator; |
34 |
|
35 |
import javax.swing.ImageIcon; |
36 |
import javax.swing.JButton; |
37 |
import javax.swing.JFileChooser; |
38 |
import javax.swing.JOptionPane; |
39 |
import javax.swing.JPanel; |
40 |
import javax.swing.JScrollPane; |
41 |
|
42 |
import org.gvsig.andami.IconThemeHelper; |
43 |
import org.gvsig.andami.Launcher; |
44 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
45 |
import org.gvsig.fmap.dal.coverage.RasterManager; |
46 |
import org.gvsig.fmap.dal.coverage.datastruct.ColorItem; |
47 |
import org.gvsig.fmap.dal.coverage.datastruct.ColorTableLibrary; |
48 |
import org.gvsig.fmap.dal.coverage.exception.FilePaletteException; |
49 |
import org.gvsig.fmap.dal.coverage.exception.RasterLegendIONotFound; |
50 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
51 |
import org.gvsig.gui.beans.listview.ListViewComponent; |
52 |
import org.gvsig.gui.beans.listview.ListViewItem; |
53 |
import org.gvsig.gui.beans.listview.ListViewListener; |
54 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
55 |
import org.gvsig.raster.tools.app.basic.tool.colortable.data.ColorTableData; |
56 |
import org.gvsig.raster.util.BasePanel; |
57 |
import org.gvsig.raster.util.ExtendedFileFilter; |
58 |
/**
|
59 |
* Panel que aparece en la parte inferior derecha que contiene la lista
|
60 |
* de librerias disponibles para las tablas de color, con sus botones correspondientes
|
61 |
* para importar, exportar, borrar y a?adir librerias.
|
62 |
*
|
63 |
* 19/02/2008
|
64 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
65 |
*/
|
66 |
public class ColorTableLibraryPanel extends BasePanel implements ActionListener, ListViewListener { |
67 |
private static final long serialVersionUID = 1L; |
68 |
private JPanel panelButtons = null; |
69 |
private JButton buttonAdd = null; |
70 |
private JButton buttonDel = null; |
71 |
private JButton buttonImport = null; |
72 |
private JButton buttonExport = null; |
73 |
private ListViewComponent listViewComponent = null; |
74 |
private boolean hasChanged = false; |
75 |
private ArrayList<ColorTableLibraryListener> |
76 |
actionCommandListeners = new ArrayList<ColorTableLibraryListener>(); |
77 |
private ColorTableData colorTableData = null; |
78 |
private ColorTable currentColorTable = null; |
79 |
public static String palettesPath = Launcher.getAppHomeDir() + File.separator + "colortable"; |
80 |
private ColorTableLibrary tableLib = null; |
81 |
private RasterManager rManager = null; |
82 |
|
83 |
/**
|
84 |
*Inicializa componentes gr?ficos y traduce
|
85 |
*/
|
86 |
public ColorTableLibraryPanel() {
|
87 |
init(); |
88 |
translate(); |
89 |
} |
90 |
|
91 |
public ColorTableLibraryPanel(ColorTableData colorTableData){
|
92 |
this.colorTableData = colorTableData;
|
93 |
init(); |
94 |
translate(); |
95 |
} |
96 |
|
97 |
/*
|
98 |
* (non-Javadoc)
|
99 |
* @see org.gvsig.raster.util.BasePanel#init()
|
100 |
*/
|
101 |
protected void init() { |
102 |
rManager = RasterLocator.getManager(); |
103 |
tableLib = rManager.getDataStructFactory().getColorTableLibrary(); |
104 |
setLayout(new BorderLayout()); |
105 |
|
106 |
JPanel panel = new JPanel(); |
107 |
panel.setLayout(new BorderLayout()); |
108 |
panel.setBorder(javax.swing.BorderFactory.createEmptyBorder(8, 8, 8, 8)); |
109 |
|
110 |
JScrollPane jScrollPane = new JScrollPane(); |
111 |
jScrollPane.setViewportView(getListViewComponent()); |
112 |
jScrollPane.setAutoscrolls(true);
|
113 |
|
114 |
panel.add(jScrollPane, BorderLayout.CENTER);
|
115 |
add(panel, BorderLayout.CENTER);
|
116 |
add(getPanelButtons(), BorderLayout.SOUTH);
|
117 |
setPreferredSize(new Dimension(0, 192)); |
118 |
|
119 |
loadDiskLibrary(); |
120 |
} |
121 |
|
122 |
/*
|
123 |
* (non-Javadoc)
|
124 |
* @see org.gvsig.raster.util.BasePanel#translate()
|
125 |
*/
|
126 |
protected void translate() { |
127 |
} |
128 |
|
129 |
private void loadDiskLibrary() { |
130 |
try {
|
131 |
ArrayList<String> fileList = tableLib.getPaletteFileList(palettesPath); |
132 |
for (int i = 0; i < fileList.size(); i++) { |
133 |
ArrayList<ColorItem> paletteItems = new ArrayList<ColorItem>(); |
134 |
String paletteName = tableLib.loadPalette(palettesPath, (String) fileList.get(i), paletteItems); |
135 |
|
136 |
if (paletteItems.size() <= 0) |
137 |
continue;
|
138 |
|
139 |
ColorTable colorTable = tableLib.createColorTable(); |
140 |
colorTable.setName(paletteName); |
141 |
colorTable.createPaletteFromColorItems(paletteItems, true);
|
142 |
colorTable.setInterpolated(true);
|
143 |
|
144 |
ListViewItem item = new ListViewItem(new ColorTableIconPainter(colorTable), paletteName); |
145 |
item.setTag(fileList.get(i)); |
146 |
getListViewComponent().addItem(item); |
147 |
} |
148 |
getListViewComponent().sort(); |
149 |
getListViewComponent().setSelectedIndex(0);
|
150 |
callColorTableChanged(); |
151 |
} catch (FilePaletteException e) {
|
152 |
RasterToolsUtil.messageBoxError(e.getMessage(), this, e);
|
153 |
} |
154 |
} |
155 |
|
156 |
/**
|
157 |
* Devuelve el jButtonAdd
|
158 |
* @return
|
159 |
*/
|
160 |
private JButton getButtonAdd() { |
161 |
if (buttonAdd == null) { |
162 |
ImageIcon icon = null; |
163 |
try {
|
164 |
icon = IconThemeHelper.getImageIcon("addlayer-icon");
|
165 |
} catch (NullPointerException n) { |
166 |
// No ha encontrado el icono, no lo muestra.
|
167 |
} |
168 |
|
169 |
buttonAdd = new JButton(icon); |
170 |
buttonAdd.setPreferredSize(new Dimension(22, 19)); |
171 |
buttonAdd.addActionListener(this);
|
172 |
buttonAdd.setToolTipText(getText(this, "nueva_libreria_title")); |
173 |
} |
174 |
return buttonAdd;
|
175 |
} |
176 |
|
177 |
/**
|
178 |
* Devuelve el jButtonDel
|
179 |
* @return
|
180 |
*/
|
181 |
private JButton getButtonDel() { |
182 |
if (buttonDel == null) { |
183 |
ImageIcon icon = null; |
184 |
try {
|
185 |
icon = IconThemeHelper.getImageIcon("delall-icon");
|
186 |
} catch (NullPointerException n) { |
187 |
// No ha encontrado el icono, no lo muestra.
|
188 |
} |
189 |
buttonDel = new JButton(icon); |
190 |
buttonDel.setPreferredSize(new Dimension(22, 19)); |
191 |
buttonDel.addActionListener(this);
|
192 |
buttonDel.setToolTipText(getText(this, "borrar_libreria")); |
193 |
} |
194 |
return buttonDel;
|
195 |
} |
196 |
|
197 |
/**
|
198 |
* Devuelve el jButtonDel
|
199 |
* @return
|
200 |
*/
|
201 |
private JButton getButtonImport() { |
202 |
if (buttonImport == null) { |
203 |
ImageIcon icon = null; |
204 |
try {
|
205 |
icon = IconThemeHelper.getImageIcon("import-icon");
|
206 |
} catch (NullPointerException n) { |
207 |
// No ha encontrado el icono, no lo muestra.
|
208 |
} |
209 |
buttonImport = new JButton(icon); |
210 |
buttonImport.setPreferredSize(new Dimension(22, 19)); |
211 |
buttonImport.addActionListener(this);
|
212 |
buttonImport.setToolTipText(getText(this, "import_libreria")); |
213 |
} |
214 |
return buttonImport;
|
215 |
} |
216 |
|
217 |
/**
|
218 |
* Devuelve el jButtonDel
|
219 |
* @return
|
220 |
*/
|
221 |
private JButton getButtonExport() { |
222 |
if (buttonExport == null) { |
223 |
ImageIcon icon = null; |
224 |
try {
|
225 |
icon = IconThemeHelper.getImageIcon("view-export-image");
|
226 |
} catch (NullPointerException n) { |
227 |
// No ha encontrado el icono, no lo muestra.
|
228 |
} |
229 |
buttonExport = new JButton(icon); |
230 |
buttonExport.setPreferredSize(new Dimension(22, 19)); |
231 |
buttonExport.addActionListener(this);
|
232 |
buttonExport.setToolTipText(getText(this, "export_libreria")); |
233 |
} |
234 |
return buttonExport;
|
235 |
} |
236 |
|
237 |
/**
|
238 |
* Devuelve el panel de botones de la libreria de a?adir y borrar
|
239 |
* @return
|
240 |
*/
|
241 |
private JPanel getPanelButtons() { |
242 |
if (panelButtons == null) { |
243 |
panelButtons = new JPanel(); |
244 |
panelButtons.setPreferredSize(new Dimension(0, 21)); |
245 |
|
246 |
FlowLayout flowLayout5 = new FlowLayout(); |
247 |
flowLayout5.setHgap(5);
|
248 |
flowLayout5.setVgap(0);
|
249 |
flowLayout5.setAlignment(java.awt.FlowLayout.CENTER); |
250 |
panelButtons.setLayout(flowLayout5); |
251 |
|
252 |
panelButtons.add(getButtonAdd(), null);
|
253 |
panelButtons.add(getButtonExport(), null);
|
254 |
panelButtons.add(getButtonImport(), null);
|
255 |
panelButtons.add(getButtonDel(), null);
|
256 |
} |
257 |
return panelButtons;
|
258 |
} |
259 |
|
260 |
private ListViewComponent getListViewComponent() {
|
261 |
if (listViewComponent == null) { |
262 |
listViewComponent = new ListViewComponent();
|
263 |
listViewComponent.addListSelectionListener(this);
|
264 |
listViewComponent.setEditable(true);
|
265 |
} |
266 |
return listViewComponent;
|
267 |
} |
268 |
|
269 |
private void callColorTableChanged() { |
270 |
Iterator<ColorTableLibraryListener> acIterator = actionCommandListeners.iterator();
|
271 |
while (acIterator.hasNext()) {
|
272 |
ColorTableLibraryListener listener = (ColorTableLibraryListener) acIterator.next(); |
273 |
listener.actionColorTableChanged(new ColorTableLibraryEvent(this)); |
274 |
} |
275 |
} |
276 |
|
277 |
/**
|
278 |
* Accion que se ejecuta cuando se disparan los siguientes eventos:
|
279 |
* - Checkbox de interpolacion.
|
280 |
* - Checkbox de habilitacion de colortables.
|
281 |
* - Boton de a?adir un colortable nuevo.
|
282 |
* - Boton de borrar un colortable seleccionado.
|
283 |
*/
|
284 |
public void actionPerformed(ActionEvent e) { |
285 |
if (e.getSource() == getButtonAdd()) {
|
286 |
AddLibraryWindow addLibrary = new AddLibraryWindow();
|
287 |
if (addLibrary.showConfirm(this) == JOptionPane.OK_OPTION) { |
288 |
ColorTable colorTable = addLibrary.getColorTable(); |
289 |
if (colorTable != null) { |
290 |
ListViewItem item = new ListViewItem(new ColorTableIconPainter(colorTable), colorTable.getName()); |
291 |
item.setTag(item.getName() + ".xml");
|
292 |
getListViewComponent().addItem(item); |
293 |
getListViewComponent().setSelectedIndex(getListViewComponent().getItems().size() - 1);
|
294 |
((ColorTableIconPainter) item.getIcon()).getColorTable().setName(item.getName()); |
295 |
colorTable.setName(((ColorTableIconPainter) item.getIcon()).getColorTable().getName()); |
296 |
tableLib.save_to_1_1(palettesPath, colorTable); |
297 |
callColorTableChanged(); |
298 |
} |
299 |
} |
300 |
getListViewComponent().sort(); |
301 |
} |
302 |
|
303 |
if (e.getSource() == getButtonExport()) {
|
304 |
JFileChooser chooser = new JFileChooser(); |
305 |
chooser.setAcceptAllFileFilterUsed(false);
|
306 |
|
307 |
String[] formats = tableLib.getFormats(); |
308 |
ExtendedFileFilter fileFilter = null;
|
309 |
ExtendedFileFilter firstFileFilter = null;
|
310 |
for (int i = 0; i < formats.length; i++) { |
311 |
fileFilter = new ExtendedFileFilter();
|
312 |
fileFilter.addExtension(formats[i]); |
313 |
|
314 |
try {
|
315 |
String s = RasterLocator.getManager().getFileUtils().getExtensionFromFileName(formats[i]);
|
316 |
String desc = rManager.getRasterLegendIO(s).getDescription();
|
317 |
if (desc != null) |
318 |
fileFilter.setDescription(desc); |
319 |
} catch (RasterLegendIONotFound e1) {
|
320 |
// Si no puedo pillar la descripcion no pasa nada
|
321 |
} |
322 |
if (firstFileFilter == null) |
323 |
firstFileFilter = fileFilter; |
324 |
|
325 |
chooser.addChoosableFileFilter(fileFilter); |
326 |
} |
327 |
if (firstFileFilter != null) |
328 |
chooser.setFileFilter(firstFileFilter); |
329 |
|
330 |
int returnVal = chooser.showSaveDialog(this); |
331 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
332 |
try {
|
333 |
if (colorTableData != null){ |
334 |
tableLib.save_to_1_1(ColorTableLibraryPanel.palettesPath, colorTableData.getColorTable()); |
335 |
} |
336 |
ExtendedFileFilter filter = (ExtendedFileFilter) chooser.getFileFilter(); |
337 |
String file = filter.getNormalizedFilename(chooser.getSelectedFile());
|
338 |
|
339 |
String s = RasterLocator.getManager().getFileUtils().getExtensionFromFileName(file);
|
340 |
rManager.getRasterLegendIO(s).write(getColorTableSelected(), new File(file)); |
341 |
} catch (IOException e1) { |
342 |
e1.printStackTrace(); |
343 |
} catch (RasterLegendIONotFound e1) {
|
344 |
e1.printStackTrace(); |
345 |
} |
346 |
} |
347 |
} |
348 |
|
349 |
if (e.getSource() == getButtonImport()) {
|
350 |
JFileChooser chooser = new JFileChooser(); |
351 |
chooser.setAcceptAllFileFilterUsed(false);
|
352 |
chooser.setMultiSelectionEnabled(true);
|
353 |
|
354 |
String[] formats = tableLib.getFormats(); |
355 |
ExtendedFileFilter allFilters = new ExtendedFileFilter();
|
356 |
ExtendedFileFilter fileFilter = null;
|
357 |
for (int i = 0; i < formats.length; i++) { |
358 |
fileFilter = new ExtendedFileFilter();
|
359 |
fileFilter.addExtension(formats[i]); |
360 |
allFilters.addExtension(formats[i]); |
361 |
|
362 |
try {
|
363 |
String s = RasterLocator.getManager().getFileUtils().getExtensionFromFileName((formats[i]));
|
364 |
String desc = rManager.getRasterLegendIO(s).getDescription();
|
365 |
if (desc != null) |
366 |
fileFilter.setDescription(desc); |
367 |
} catch (RasterLegendIONotFound e1) {
|
368 |
// Si no puedo pillar la descripcion no pasa nada
|
369 |
} |
370 |
|
371 |
chooser.addChoosableFileFilter(fileFilter); |
372 |
} |
373 |
allFilters.setDescription(getText(this, "todos_soportados")); |
374 |
chooser.addChoosableFileFilter(allFilters); |
375 |
chooser.setFileFilter(allFilters); |
376 |
|
377 |
int returnVal = chooser.showOpenDialog(this); |
378 |
|
379 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
380 |
try {
|
381 |
for (int file = 0; file<chooser.getSelectedFiles().length; file++) { |
382 |
fileFilter = null;
|
383 |
for (int i = 0; i < formats.length; i++) { |
384 |
fileFilter = new ExtendedFileFilter();
|
385 |
fileFilter.addExtension(formats[i]); |
386 |
if (fileFilter.accept(chooser.getSelectedFiles()[file])) {
|
387 |
ColorTable colorTable = rManager.getRasterLegendIO(formats[i]).read(chooser.getSelectedFiles()[file]); |
388 |
|
389 |
if (colorTable != null){ |
390 |
colorTable.setInterpolated(true);
|
391 |
|
392 |
ListViewItem item = new ListViewItem(new ColorTableIconPainter(colorTable), colorTable.getName()); |
393 |
item.setTag(item.getName() + ".xml");
|
394 |
getListViewComponent().addItem(item); |
395 |
getListViewComponent().setSelectedIndex(getListViewComponent().getItems().size() - 1);
|
396 |
((ColorTableIconPainter) item.getIcon()).getColorTable().setName(item.getName()); |
397 |
colorTable.setName(((ColorTableIconPainter) item.getIcon()).getColorTable().getName()); |
398 |
tableLib.save_to_1_1(palettesPath, colorTable); |
399 |
callColorTableChanged(); |
400 |
} else {
|
401 |
RasterToolsUtil.messageBoxError("error_importando_tabla_color_rmf", this); |
402 |
} |
403 |
break;
|
404 |
} |
405 |
} |
406 |
} |
407 |
} catch (IOException e1) { |
408 |
e1.printStackTrace(); |
409 |
RasterToolsUtil.messageBoxError("error_importando_tabla_color_rmf", this); |
410 |
} catch (RasterLegendIONotFound e1) {
|
411 |
e1.printStackTrace(); |
412 |
} |
413 |
} |
414 |
} |
415 |
|
416 |
if (e.getSource() == getButtonDel()) {
|
417 |
if (getListViewComponent().getSelectedIndices().length > 0) { |
418 |
if (RasterToolsUtil.messageBoxYesOrNot("desea_borrar_librerias", this)) { |
419 |
File oldFile = new File(palettesPath + File.separator + getListViewComponent().getSelectedValue().getTag()); |
420 |
oldFile.delete(); |
421 |
int pos = getListViewComponent().getSelectedIndices()[0]; |
422 |
getListViewComponent().removeSelecteds(); |
423 |
|
424 |
if (getListViewComponent().getItems().size() == 0) { |
425 |
loadDiskLibrary(); |
426 |
} else {
|
427 |
getListViewComponent().setSelectedIndex(pos - 1);
|
428 |
callColorTableChanged(); |
429 |
} |
430 |
} |
431 |
} |
432 |
return;
|
433 |
} |
434 |
} |
435 |
|
436 |
/*
|
437 |
* (non-Javadoc)
|
438 |
* @see org.gvsig.gui.beans.listview.ListViewListener#actionItemNameChanged(java.util.EventObject, java.lang.String, org.gvsig.gui.beans.listview.ListViewItem)
|
439 |
*/
|
440 |
public void actionItemNameChanged(EventObject e, String oldName, ListViewItem item) { |
441 |
File oldFile = new File(palettesPath + File.separator + oldName + ".xml"); |
442 |
oldFile.delete(); |
443 |
|
444 |
getColorTableSelected().setName(item.getName()); |
445 |
item.setTag(item.getName() + ".xml");
|
446 |
|
447 |
tableLib.save_to_1_1(palettesPath, getColorTableSelected()); |
448 |
|
449 |
callColorTableChanged(); |
450 |
} |
451 |
|
452 |
/**
|
453 |
* Comprueba si el usuario ha cambiado los valores de la tabla de colores,
|
454 |
* si es as?, le pregunta al usuario si quiere guardar los datos, y seg?n la
|
455 |
* selecci?n, restaura los datos antiguos o los machaca.
|
456 |
*/
|
457 |
private void testLibraryChanged() { |
458 |
if (hasChanged) {
|
459 |
if (RasterToolsUtil.messageBoxYesOrNot("desea_guardar_cambios", this)) { |
460 |
tableLib.save_to_1_1(palettesPath, getColorTableSelected()); |
461 |
getListViewComponent().repaint(); |
462 |
} |
463 |
hasChanged = false;
|
464 |
} |
465 |
} |
466 |
|
467 |
/**
|
468 |
* Selecciona la tabla de color por defecto.
|
469 |
*/
|
470 |
public void selectDefault() { |
471 |
int selected = 0; |
472 |
for (int i = 0; i < getListViewComponent().getItems().size(); i++) { |
473 |
if (((ListViewItem) getListViewComponent().getItems().get(i)).getName().equals("Default")) { |
474 |
selected = i; |
475 |
break;
|
476 |
} |
477 |
} |
478 |
getListViewComponent().setSelectedIndex(selected); |
479 |
callColorTableChanged(); |
480 |
} |
481 |
|
482 |
/**
|
483 |
* Inserta una tabla de color en la posicion especificada y selecciona.
|
484 |
*/
|
485 |
public void addColorTable(int pos, ColorTable colorTable) { |
486 |
ListViewItem item = new ListViewItem(new ColorTableIconPainter(colorTable), getText(this, "tabla_actual")); |
487 |
getListViewComponent().addItem(pos, item); |
488 |
getListViewComponent().setSelectedIndex(pos); |
489 |
callColorTableChanged(); |
490 |
} |
491 |
|
492 |
/**
|
493 |
* Accion que se ejecuta cuando cambia la seleccion de un item del
|
494 |
* ListViewComponent
|
495 |
*/
|
496 |
public void actionValueChanged(EventObject e) { |
497 |
currentColorTable = ((ColorTableIconPainter) getListViewComponent().getSelectedValue().getIcon()).getColorTable(); |
498 |
testLibraryChanged(); |
499 |
callColorTableChanged(); |
500 |
} |
501 |
|
502 |
/**
|
503 |
* Define si se visualizara el componente con interpolacion o no.
|
504 |
* @param enabled
|
505 |
*/
|
506 |
public void setInterpolated(boolean enabled) { |
507 |
for (int i = 0; i < getListViewComponent().getItems().size(); i++) |
508 |
((ColorTableIconPainter) ((ListViewItem) getListViewComponent().getItems().get(i)).getIcon()).setInterpolated(enabled); |
509 |
getListViewComponent().repaint(); |
510 |
} |
511 |
|
512 |
/**
|
513 |
* A?adir un listener a la lista de eventos
|
514 |
* @param listener
|
515 |
*/
|
516 |
public void addColorTableLibraryListener(ColorTableLibraryListener listener) { |
517 |
if (!actionCommandListeners.contains(listener))
|
518 |
actionCommandListeners.add(listener); |
519 |
} |
520 |
|
521 |
/**
|
522 |
* Borrar un listener de la lista de eventos
|
523 |
* @param listener
|
524 |
*/
|
525 |
public void removeColorTableLibraryListener(ColorTableLibraryListener listener) { |
526 |
actionCommandListeners.remove(listener); |
527 |
} |
528 |
|
529 |
/**
|
530 |
* Devuelve la tabla de color que hay seleccionada en ese momento
|
531 |
* @return
|
532 |
*/
|
533 |
public ColorTable getColorTableSelected() {
|
534 |
if (getListViewComponent().getSelectedValue() != null){ |
535 |
currentColorTable = ((ColorTableIconPainter) getListViewComponent().getSelectedValue().getIcon()).getColorTable(); |
536 |
} |
537 |
return currentColorTable;
|
538 |
} |
539 |
|
540 |
/**
|
541 |
* Reescribe la tabla de color en la posicion seleccionada
|
542 |
* @param colorTable
|
543 |
*/
|
544 |
public void setColorTableSelected(ColorTable colorTable) { |
545 |
hasChanged = true;
|
546 |
((ColorTableIconPainter) getListViewComponent().getSelectedValue().getIcon()).getColorTable().createPaletteFromColorItems(colorTable.getColorItems(), false);
|
547 |
getListViewComponent().repaint(); |
548 |
} |
549 |
|
550 |
} |