root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / colortable / data / ColorTableData.java @ 16552
History | View | Annotate | Download (3.08 KB)
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.colortable.data; |
20 |
|
21 |
import java.util.ArrayList; |
22 |
import java.util.Hashtable; |
23 |
import java.util.Iterator; |
24 |
|
25 |
import org.gvsig.raster.datastruct.ColorTable; |
26 |
/**
|
27 |
*
|
28 |
* @version 27/09/2007
|
29 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
30 |
*/
|
31 |
public class ColorTableData { |
32 |
private ArrayList actionCommandListeners = new ArrayList(); |
33 |
private Hashtable options = new Hashtable(); |
34 |
|
35 |
/**
|
36 |
* @return the colorTable
|
37 |
*/
|
38 |
public ColorTable getColorTable() {
|
39 |
return (ColorTable) options.get("colorTable"); |
40 |
} |
41 |
|
42 |
/**
|
43 |
* @param colorTable the colorTable to set
|
44 |
*/
|
45 |
public void setColorTable(ColorTable colorTable) { |
46 |
setOption("colorTable", colorTable);
|
47 |
} |
48 |
|
49 |
/**
|
50 |
* @return the hasChanged
|
51 |
*/
|
52 |
public boolean isChanged() { |
53 |
Boolean n = (Boolean) options.get("changed"); |
54 |
if (n != null) |
55 |
return n.booleanValue();
|
56 |
return false; |
57 |
} |
58 |
|
59 |
/**
|
60 |
* @param hasChanged the hasChanged to set
|
61 |
*/
|
62 |
public void setHasChanged(boolean changed) { |
63 |
setOption("changed", new Boolean(changed)); |
64 |
} |
65 |
|
66 |
/**
|
67 |
* Refresca la vista previa
|
68 |
*/
|
69 |
public void refreshPreview() { |
70 |
setOption("refreshPreview", new Boolean(true)); |
71 |
} |
72 |
|
73 |
/**
|
74 |
* Especifica el valor de una variable
|
75 |
* @param name
|
76 |
* @param value
|
77 |
*/
|
78 |
public void setOption(String name, Object value) { |
79 |
options.put(name, value); |
80 |
callValueChangedListeners(name, value); |
81 |
} |
82 |
|
83 |
/**
|
84 |
* A?adir un listener a la lista de eventos
|
85 |
* @param listener
|
86 |
*/
|
87 |
public void addValueChangedListener(ColorTableDataListener listener) { |
88 |
if (!actionCommandListeners.contains(listener))
|
89 |
actionCommandListeners.add(listener); |
90 |
} |
91 |
|
92 |
/**
|
93 |
* Borrar un listener de la lista de eventos
|
94 |
* @param listener
|
95 |
*/
|
96 |
public void removeValueChangedListener(ColorTableDataListener listener) { |
97 |
actionCommandListeners.remove(listener); |
98 |
} |
99 |
|
100 |
/**
|
101 |
* Invocar a los eventos asociados al componente
|
102 |
*/
|
103 |
private void callValueChangedListeners(String name, Object value) { |
104 |
Iterator acIterator = actionCommandListeners.iterator();
|
105 |
while (acIterator.hasNext()) {
|
106 |
ColorTableDataListener listener = (ColorTableDataListener) acIterator.next(); |
107 |
listener.actionValueChanged(new ColorTableDataEvent(this, name, value)); |
108 |
} |
109 |
} |
110 |
} |