Statistics
| Revision:

root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / colortable / ui / ColorTablePanel.java @ 12838

History | View | Annotate | Download (18.2 KB)

1 12344 bsanchez
/* 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.rastertools.colortable.ui;
20
21
import java.awt.BorderLayout;
22 12447 bsanchez
import java.awt.Color;
23 12344 bsanchez
import java.awt.Dimension;
24 12592 bsanchez
import java.awt.FlowLayout;
25 12488 bsanchez
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionListener;
27 12460 bsanchez
import java.io.File;
28
import java.util.ArrayList;
29 12344 bsanchez
30 12592 bsanchez
import javax.swing.ImageIcon;
31
import javax.swing.JButton;
32 12488 bsanchez
import javax.swing.JCheckBox;
33 12447 bsanchez
import javax.swing.JLabel;
34 12344 bsanchez
import javax.swing.JPanel;
35 12416 bsanchez
import javax.swing.JScrollPane;
36 12344 bsanchez
import javax.swing.JTabbedPane;
37 12514 bsanchez
import javax.swing.JTable;
38 12447 bsanchez
import javax.swing.JTextField;
39 12488 bsanchez
import javax.swing.event.ListSelectionEvent;
40
import javax.swing.event.ListSelectionListener;
41 12514 bsanchez
import javax.swing.event.TableModelEvent;
42
import javax.swing.event.TableModelListener;
43 12344 bsanchez
44 12553 bsanchez
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
45 12447 bsanchez
import org.gvsig.gui.beans.buttonscolor.ButtonColor;
46 12344 bsanchez
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
47
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel;
48
import org.gvsig.gui.beans.imagenavigator.ImageNavigator;
49 12624 bsanchez
import org.gvsig.gui.beans.listview.ListViewComponent;
50
import org.gvsig.gui.beans.listview.ListViewItem;
51 12514 bsanchez
import org.gvsig.gui.beans.table.exceptions.NotInitializeException;
52
import org.gvsig.gui.beans.table.models.TableColorModel;
53 12504 bsanchez
import org.gvsig.raster.datastruct.ColorItem;
54 12568 bsanchez
import org.gvsig.raster.datastruct.ColorTable;
55 12553 bsanchez
import org.gvsig.raster.datastruct.Extent;
56 12823 bsanchez
import org.gvsig.raster.datastruct.serializer.ColorTableLibraryPersistence;
57 12553 bsanchez
import org.gvsig.raster.grid.GridPalette;
58 12568 bsanchez
import org.gvsig.raster.grid.GridTransparency;
59 12553 bsanchez
import org.gvsig.raster.grid.filter.RasterFilterList;
60
import org.gvsig.raster.grid.filter.bands.ColorTableFilter;
61
import org.gvsig.raster.grid.render.Rendering;
62 12568 bsanchez
import org.gvsig.rastertools.RasterToolsUtil;
63 12344 bsanchez
import org.gvsig.rastertools.colortable.ColorTableListener;
64
import org.gvsig.rastertools.colortable.panels.ColorTInterpolated;
65
import org.gvsig.rastertools.colortable.panels.ColorTTable;
66
67
import com.iver.andami.PluginServices;
68
import com.iver.cit.gvsig.fmap.layers.FLayer;
69
/**
70
 * ColorTablePanel es el panel donde se gestionara todo el comportamiento de las
71
 * tablas de color.
72
 *
73
 * @version 26/06/2007
74 12369 bsanchez
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
75 12344 bsanchez
 */
76 12514 bsanchez
public class ColorTablePanel extends DefaultButtonsPanel implements ListSelectionListener, ActionListener, TableModelListener {
77 12624 bsanchez
        private static final long  serialVersionUID     = 6028780107787443656L;
78 12344 bsanchez
79 12624 bsanchez
        private ImageNavigator     imageNavigator       = null;
80
        private ColorTableListener colorTableListener   = null;
81
        private boolean            active               = false;
82
        private FLayer             fLayer               = null;
83
        private ArrayList          filterStatus         = null;
84
        private GridTransparency   initTransparency     = null;
85 12344 bsanchez
86 12707 bsanchez
        private ColorTable         lastColorTable       = null;
87
        private ColorTable         lastColorTableCloned = null;
88
89 12624 bsanchez
        //[start]Variables UI
90
        private ColorTTable        colorTTable          = null;
91
        private ColorTInterpolated colorTInterpolated   = null;
92
        private ListViewComponent  listViewComponent    = null;
93
        private JTabbedPane        tabbedPane           = null;
94
        private JPanel             panelPreview         = null;
95
        private JPanel             panelNoData          = null;
96
        private JPanel             panelButtons         = null;
97
        private JCheckBox          checkBoxInterpolated = null;
98
        private JButton            buttonAdd            = null;
99
        private JButton            buttonDel            = null;
100
        private JTextField         textFieldNoData      = null;
101
        //[end]
102
103 12488 bsanchez
        private String palettesPath = System.getProperty("user.home") +
104
                File.separator +
105 12838 bsanchez
                "gvSIG" + // PluginServices.getArguments()[0] +
106
                File.separator + "colortable";
107 12488 bsanchez
108 12344 bsanchez
        /**
109
         * Construir un nuevo ColorTablePanel
110
         */
111
        public ColorTablePanel() {
112
                super(ButtonsPanel.BUTTONS_NONE);
113
                getButtonsPanel().addButton("Guardar como predeterminado", ButtonsPanel.BUTTON_LAST + 2);
114
                getButtonsPanel().addAccept();
115
                getButtonsPanel().addApply();
116
                getButtonsPanel().addCancel();
117
                initialize();
118
        }
119
120 12624 bsanchez
        //[start] Code UI
121 12344 bsanchez
        private void initialize() {
122
                setLayout(new BorderLayout(8, 8));
123
124 12488 bsanchez
                JPanel panelLeft = new JPanel();
125 12568 bsanchez
                panelLeft.setPreferredSize(new Dimension(390,0));
126 12488 bsanchez
                panelLeft.setLayout(new BorderLayout(8, 8));
127 12624 bsanchez
                panelLeft.add(getTabbedPane(), BorderLayout.CENTER);
128
                panelLeft.add(getPanelNoData(), BorderLayout.SOUTH);
129 12460 bsanchez
130 12568 bsanchez
                JPanel jSplitPane1 = new JPanel();
131
                jSplitPane1.setLayout(new BorderLayout(8, 8));
132
                jSplitPane1.add(panelLeft, BorderLayout.WEST);
133 12624 bsanchez
                jSplitPane1.add(getPanelPreview(), BorderLayout.CENTER);
134 12488 bsanchez
135
                add(jSplitPane1, BorderLayout.CENTER);
136
137 12838 bsanchez
                ArrayList fileList = ColorTableLibraryPersistence.getPaletteFileList(palettesPath);
138 12488 bsanchez
139 12677 bsanchez
                for (int i = 0; i < fileList.size(); i++) {
140 12488 bsanchez
                        ArrayList paletteItems = new ArrayList();
141 12838 bsanchez
                        String paletteName = ColorTableLibraryPersistence.loadPalette(palettesPath, (String) fileList.get(i), paletteItems);
142 12488 bsanchez
143 12553 bsanchez
                        if (paletteItems.size() <= 0)
144
                                continue;
145
146 12707 bsanchez
                        ColorTable colorTable = new ColorTable();
147
                        colorTable.setName(paletteName);
148
                        colorTable.createPaletteFromColorItems(paletteItems, true);
149
                        colorTable.setInterpolated(true);
150
151
                        ListViewItem item = new ListViewItem(new ColorTableIconPainter(colorTable), paletteName);
152 12677 bsanchez
                        item.setTag(fileList.get(i));
153 12460 bsanchez
                        getListViewComponent().addItem(item);
154
                }
155 12553 bsanchez
                getListViewComponent().setSelectedIndex(0);
156 12707 bsanchez
                reloadTable(true);
157 12344 bsanchez
        }
158
159 12624 bsanchez
        private JTabbedPane getTabbedPane() {
160
                if (tabbedPane == null) {
161
                        tabbedPane = new JTabbedPane();
162 12488 bsanchez
163 12624 bsanchez
                        tabbedPane.addTab("Tabla", getColorTTable());
164
                        tabbedPane.addTab("Rampa", getColorTInterpolated());
165 12447 bsanchez
166
                }
167 12624 bsanchez
                return tabbedPane;
168 12447 bsanchez
        }
169 12344 bsanchez
170
        private ColorTTable getColorTTable() {
171
                if (colorTTable == null) {
172
                        colorTTable = new ColorTTable();
173 12514 bsanchez
                        colorTTable.getTableContainer().getTable().getJTable().getModel().addTableModelListener(this);
174 12344 bsanchez
                }
175
                return colorTTable;
176
        }
177
178
        private ColorTInterpolated getColorTInterpolated() {
179
                if (colorTInterpolated == null) {
180
                        colorTInterpolated = new ColorTInterpolated();
181
                }
182
                return colorTInterpolated;
183
        }
184
185
        /**
186
         * Devuelve el componente para la vista previa
187
         * @return
188
         */
189
        private ImageNavigator getImageNavigator() {
190
                if (imageNavigator == null) {
191
                        imageNavigator = new ImageNavigator(getColorTableListener());
192
                        imageNavigator.setFocusable(true);
193
                        imageNavigator.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
194
                }
195
                return imageNavigator;
196
        }
197
198
        /**
199
         * Devuelve el panel donde estar? el widget de preview
200
         * @return
201
         */
202 12624 bsanchez
        private JPanel getPanelPreview() {
203
                if (panelPreview == null) {
204
                        panelPreview = new JPanel();
205
                        panelPreview.setLayout(new BorderLayout(8, 8));
206 12553 bsanchez
207 12344 bsanchez
                        JPanel jsubpanel = new JPanel();
208
                        JPanel jsubpanel2 = new JPanel();
209
                        jsubpanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "vista_previa"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
210
                        jsubpanel.setLayout(new BorderLayout());
211
                        jsubpanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(8, 8, 8, 8));
212
                        jsubpanel2.setLayout(new BorderLayout());
213
214
                        jsubpanel2.add(getImageNavigator(), BorderLayout.CENTER);
215
                        jsubpanel.add(jsubpanel2, BorderLayout.CENTER);
216
217 12624 bsanchez
                        panelPreview.add(jsubpanel, BorderLayout.CENTER);
218 12344 bsanchez
219
                        JPanel jsubpanel3 = new JPanel();
220
                        JPanel jsubpanel4 = new JPanel();
221
                        jsubpanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "libreria"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
222
                        jsubpanel3.setLayout(new BorderLayout());
223
                        jsubpanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(8, 8, 8, 8));
224
                        jsubpanel4.setLayout(new BorderLayout());
225 12416 bsanchez
226
                        JScrollPane jScrollPane = new JScrollPane();
227
                        jScrollPane.setViewportView(getListViewComponent());
228 12488 bsanchez
                        jScrollPane.setAutoscrolls(true);
229 12416 bsanchez
230
                        jsubpanel4.add(jScrollPane, BorderLayout.CENTER);
231 12592 bsanchez
232 12344 bsanchez
                        jsubpanel3.add(jsubpanel4, BorderLayout.CENTER);
233 12624 bsanchez
                        jsubpanel3.add(getPanelButtons(), BorderLayout.SOUTH);
234 12344 bsanchez
235 12568 bsanchez
                        jsubpanel3.setPreferredSize(new Dimension(0, 192));
236 12416 bsanchez
237 12624 bsanchez
                        panelPreview.add(jsubpanel3, BorderLayout.SOUTH);
238 12344 bsanchez
                }
239 12624 bsanchez
                return panelPreview;
240 12344 bsanchez
        }
241
242
        /**
243
         * Obtener el componente que hara la carga pesada de los listeners
244
         * @return
245
         */
246
        private ColorTableListener getColorTableListener() {
247
                if (colorTableListener == null) {
248 12553 bsanchez
                        colorTableListener = new ColorTableListener(this);
249 12344 bsanchez
                }
250
                return colorTableListener;
251
        }
252
253 12624 bsanchez
        public ListViewComponent getListViewComponent() {
254
                if (listViewComponent == null) {
255
                        listViewComponent = new ListViewComponent();
256
                        listViewComponent.addListSelectionListener(this);
257
                        listViewComponent.setEditable(true);
258
                }
259
                return listViewComponent;
260
        }
261
262
        private JTextField getJTFNoData() {
263
                if (textFieldNoData == null) {
264
                        textFieldNoData = new JTextField();
265
                        textFieldNoData.setPreferredSize(new Dimension(50, (int) textFieldNoData.getPreferredSize().getHeight()));
266
                }
267
                return textFieldNoData;
268
        }
269
270
        private JPanel getPanelNoData() {
271
                if (panelNoData == null) {
272
                        panelNoData = new JPanel();
273
                        panelNoData.add(new JLabel("No data: "), null);
274
                        ButtonColor buttonColor = new ButtonColor();
275
                        buttonColor.setColor(Color.black);
276
                        panelNoData.add(buttonColor, null);
277
                        panelNoData.add(new JLabel("Value:"), null);
278
                        panelNoData.add(getJTFNoData(), null);
279
                        panelNoData.add(getCheckBoxInterpolated(), null);
280
                        panelNoData.setMinimumSize(new Dimension(0, 0));
281
                }
282
                return panelNoData;
283
        }
284
285 12344 bsanchez
        /**
286 12624 bsanchez
         * Obtiene el jCBInterpolated
287
         * @return
288
         */
289
        public JCheckBox getCheckBoxInterpolated() {
290
                if (checkBoxInterpolated == null) {
291
                        checkBoxInterpolated = new JCheckBox("Interpolado");
292
                        checkBoxInterpolated.setSelected(true);
293
                        checkBoxInterpolated.addActionListener(this);
294
                }
295
                return checkBoxInterpolated;
296
        }
297
298
        /**
299
         * Devuelve el panel de botones de la libreria de a?adir y borrar
300
         * @return
301
         */
302
        private JPanel getPanelButtons() {
303
                if (panelButtons == null) {
304
                        panelButtons = new JPanel();
305
                        panelButtons.setPreferredSize(new Dimension(0, 21));
306
307
                        FlowLayout flowLayout5 = new FlowLayout();
308
                        flowLayout5.setHgap(5);
309
                        flowLayout5.setVgap(0);
310
                        flowLayout5.setAlignment(java.awt.FlowLayout.CENTER);
311
                        panelButtons.setLayout(flowLayout5);
312
313
                        panelButtons.add(getButtonAdd(), null);
314
                        panelButtons.add(getButtonDel(), null);
315
                }
316
                return panelButtons;
317
        }
318
319
        /**
320
         * Devuelve el jButtonAdd
321
         * @return
322
         */
323
        public JButton getButtonAdd() {
324
                if (buttonAdd == null) {
325
                        buttonAdd = new JButton(new ImageIcon("./gvSIG/extensiones/com.iver.cit.gvsig/images/addlayer.png"));
326
                        buttonAdd.setPreferredSize(new Dimension(22, 19));
327
                        buttonAdd.addActionListener(this);
328
                }
329
                return buttonAdd;
330
        }
331
332
        /**
333
         * Devuelve el jButtonDel
334
         * @return
335
         */
336
        public JButton getButtonDel() {
337
                if (buttonDel == null) {
338
                        buttonDel = new JButton(new ImageIcon("./gvSIG/extensiones/com.iver.cit.gvsig/images/delall.png"));
339
                        buttonDel.setPreferredSize(new Dimension(22, 19));
340
                        buttonDel.addActionListener(this);
341
                }
342
                return buttonDel;
343
        }
344
        //[end]
345
346
        /**
347 12344 bsanchez
         * Especificar el layer para el recorte
348
         * @param layer
349
         */
350 12553 bsanchez
        public void setLayer(FLayer fLayer) {
351
                this.fLayer = fLayer;
352
                Extent extent2 = ((FLyrRasterSE) fLayer).getDatasource().getExtent();
353
                getImageNavigator().setViewDimensions(extent2.getMin().getX(), extent2.getMax().getY(), extent2.getMax().getX(), extent2.getMin().getY());
354
                getImageNavigator().setZoom(1.0/((FLyrRasterSE) fLayer).getDatasource().getXCellSize());
355
                getImageNavigator().setAutoAdjusted();
356
357
                Rendering rendering = ((FLyrRasterSE) getLayer()).getRender();
358
359 12568 bsanchez
                RasterFilterList rasterFilterList = rendering.getFilterList();
360 12553 bsanchez
361 12568 bsanchez
                filterStatus = rasterFilterList.getStatusCloned();
362
                initTransparency = rendering.getLastTransparency();
363
364
                ColorTableFilter colorTableFilter = (ColorTableFilter) rasterFilterList.getByName(ColorTableFilter.names[0]);
365
                if (colorTableFilter != null) {
366
                        GridPalette gridPalette = new GridPalette((ColorTable) colorTableFilter.getColorTable().clone());
367
                        if (gridPalette.isCompressible()) {
368
                                if (RasterToolsUtil.messageBoxYesOrNot("La paleta se puede comprimir. ?Deseas hacerlo?", this))
369
                                        gridPalette.compressPalette();
370
                        }
371 12707 bsanchez
372
                        ColorTable colorTable = new ColorTable();
373
                        colorTable.setName("Ninguno");
374
                        colorTable.createPaletteFromColorItems(gridPalette.getColorItems(), false);
375
                        colorTable.setInterpolated(true);
376
377
                        ListViewItem item = new ListViewItem(new ColorTableIconPainter(colorTable), "Ninguno");
378 12553 bsanchez
                        getListViewComponent().addItem(0, item);
379
                        getListViewComponent().setSelectedIndex(0);
380 12707 bsanchez
                        reloadTable(true);
381 12553 bsanchez
                }
382 12344 bsanchez
        }
383
384
        /**
385
         * Especificar el layer para el recorte
386
         * @param layer
387
         */
388
        public FLayer getLayer() {
389 12553 bsanchez
                return fLayer;
390 12344 bsanchez
        }
391 12416 bsanchez
392 12707 bsanchez
        /**
393
         * Recarga la tabla de elementos
394
         * @param isNewSelection
395
         */
396
        public void reloadTable(boolean isNewSelection) {
397 12514 bsanchez
                active = false;
398 12553 bsanchez
                ArrayList colorItems = ((ColorTableIconPainter) getListViewComponent().getSelectedValue().getIcon()).getColorItems();
399 12707 bsanchez
                lastColorTable = ((ColorTableIconPainter) getListViewComponent().getSelectedValue().getIcon()).getColorTable();
400
                if (isNewSelection) {
401
                        lastColorTableCloned = (ColorTable) ((ColorTableIconPainter) getListViewComponent().getSelectedValue().getIcon()).getColorTable().clone();
402
                }
403 12504 bsanchez
                getColorTTable().clearTable();
404 12568 bsanchez
                for (int i = 0; i < colorItems.size(); i++) {
405 12504 bsanchez
                        ColorItem c1 = (ColorItem) colorItems.get(i);
406
                        Double toRange = null;
407 12568 bsanchez
                        if (i + 1 < colorItems.size())
408 12554 nacho
                                toRange = new Double(((ColorItem) colorItems.get(i + 1)).getValue());
409
                        getColorTTable().addRowToTable(c1.getColor(), c1.getNameClass(), new Double(c1.getValue()), toRange, c1.getColor().getAlpha() + "");
410 12504 bsanchez
                }
411 12514 bsanchez
                active = true;
412 12553 bsanchez
                getImageNavigator().updateBuffer();
413 12488 bsanchez
        }
414
415 12707 bsanchez
        /**
416
         * Comprueba si el usuario ha cambiado los valores de la tabla de colores,
417
         * si es as?, le pregunta al usuario si quiere guardar los datos, y seg?n la
418
         * selecci?n, restaura los datos antiguos o los machaca.
419
         */
420
        public void testLibraryChanged() {
421
                if (!lastColorTable.equals(lastColorTableCloned)) {
422
                        if (RasterToolsUtil.messageBoxYesOrNot("?Desea guardar los cambios?", this)) {
423
424
                        } else {
425 12836 bsanchez
426 12707 bsanchez
                        }
427
                }
428
        }
429
430
        /**
431
         * Accion que se ejecuta cuando cambia la seleccion de un item del
432
         * ListViewComponent
433
         */
434 12553 bsanchez
        public void valueChanged(ListSelectionEvent e) {
435 12707 bsanchez
                testLibraryChanged();
436
                reloadTable(true);
437 12553 bsanchez
        }
438
439 12488 bsanchez
        public void actionPerformed(ActionEvent e) {
440 12624 bsanchez
                if (e.getSource() == getCheckBoxInterpolated()) {
441 12488 bsanchez
                        for (int i = 0; i < getListViewComponent().getItems().size(); i++) {
442 12624 bsanchez
                                ((ColorTableIconPainter) ((ListViewItem) getListViewComponent().getItems().get(i)).getIcon()).setInterpolated(getCheckBoxInterpolated().isSelected());
443 12488 bsanchez
                        }
444
                        getListViewComponent().repaint();
445 12553 bsanchez
                        getImageNavigator().updateBuffer();
446 12624 bsanchez
                        return;
447 12488 bsanchez
                }
448 12624 bsanchez
                if (e.getSource() == getButtonAdd()) {
449 12707 bsanchez
                        ColorTable colorTable = new ColorTable();
450
                        colorTable.setName("NewLibrary");
451
                        colorTable.createPaletteFromColorItems(new ArrayList(), true);
452
                        colorTable.setInterpolated(true);
453
454
                        ListViewItem item = new ListViewItem(new ColorTableIconPainter(colorTable), "NewLibrary");
455 12624 bsanchez
                        getListViewComponent().addItem(item);
456 12632 bsanchez
                        getListViewComponent().setSelectedIndex(getListViewComponent().getItems().size() - 1);
457 12707 bsanchez
                        reloadTable(true);
458 12624 bsanchez
                }
459
                if (e.getSource() == getButtonDel()) {
460
                        if (getListViewComponent().getSelectedIndices().length > 0) {
461
                                if (RasterToolsUtil.messageBoxYesOrNot("?Deseas borrar las librer?as seleccionadas?", this)) {
462 12632 bsanchez
                                        int pos = getListViewComponent().getSelectedIndices()[0];
463 12624 bsanchez
                                        getListViewComponent().removeSelecteds();
464 12632 bsanchez
                                        getListViewComponent().setSelectedIndex(pos - 1);
465 12707 bsanchez
                                        reloadTable(true);
466 12624 bsanchez
                                }
467
                        }
468
                        return;
469
                }
470 12488 bsanchez
        }
471 12514 bsanchez
472
        /**
473
         * Convierte la tabla en un array de objetos para poder crear con el el objeto Palette
474
         * @return
475
         * @throws NotInitializeException
476
         */
477
        public ArrayList getTablePalette() {
478
                ArrayList arrayList = new ArrayList();
479
                JTable jTable = getColorTTable().getTableContainer().getTable().getJTable();
480
                TableColorModel model = (TableColorModel) jTable.getModel();
481
                for (int iRow = 0; iRow < jTable.getRowCount(); iRow++) {
482
                        Color rgb = (Color) model.getValueAt(iRow, 0);
483
                        ColorItem colorItem = new ColorItem();
484
                        colorItem.setColor(new Color(
485
                                        rgb.getRed(),
486
                                        rgb.getGreen(),
487
                                        rgb.getBlue(),
488
                                        Integer.valueOf((String) model.getValueAt(iRow, 5)).intValue()));
489
490 12553 bsanchez
                        if (model.getValueAt(iRow, 3) != null)
491
                                colorItem.setValue(((Double) model.getValueAt(iRow, 3)).doubleValue());
492 12514 bsanchez
                        // TODO: Hacer algo para conservar el valor de interpolacion
493
                        colorItem.setNameClass((String) model.getValueAt(iRow, 1));
494
                        arrayList.add(colorItem);
495
                }
496
497
                return arrayList;
498
        }
499
500
        public void tableChanged(TableModelEvent e) {
501
                if (!active)
502
                        return;
503
504 12624 bsanchez
                ((ColorTableIconPainter) getListViewComponent().getSelectedValue().getIcon()).setColorItems(getTablePalette(), getCheckBoxInterpolated().isSelected(), false);
505 12514 bsanchez
                getListViewComponent().repaint();
506 12553 bsanchez
507 12707 bsanchez
                reloadTable(false);
508 12514 bsanchez
        }
509 12553 bsanchez
510
        public GridPalette getGridPalette() {
511
                return new GridPalette(((ColorTableIconPainter) getListViewComponent().getSelectedValue().getIcon()).getColorTable());
512
        }
513 12568 bsanchez
514
        /**
515
         * Cuando se aceptan los cambios en el panel ejecutaremos el aceptar del
516
         * listener
517
         */
518
        public void accept() {
519
                colorTableListener.accept();
520
        }
521
522
        /**
523
         * Volvemos todo a la normalidad cuando se cancela
524
         */
525
        public void cancel() {
526
                getLayer().getMapContext().invalidate();
527
        }
528
529
        /**
530
         * Volvemos todo a la normalidad cuando se cancela
531
         */
532
        public void restoreFilters() {
533
                Rendering rendering = ((FLyrRasterSE) getLayer()).getRender();
534
                rendering.getFilterList().setStatus(getFilterStatus());
535
                rendering.setLastTransparency(initTransparency);
536
        }
537
538
        /**
539
         * Devuelve el arrayList de filtros inicial
540
         * @return
541
         */
542
        public ArrayList getFilterStatus() {
543
                return filterStatus;
544
        }
545 12344 bsanchez
}