Revision 18268
org.gvsig.raster/tags/org.gvsig.raster-2.2.213/org.gvsig.raster.fmap/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.fmap.FmapRasterLibrary |
org.gvsig.raster/tags/org.gvsig.raster-2.2.213/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/util/ExtendedFileFilter.java | ||
---|---|---|
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.util; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.util.ArrayList; |
|
26 |
|
|
27 |
import javax.swing.filechooser.FileFilter; |
|
28 |
|
|
29 |
|
|
30 |
/** |
|
31 |
* ExtendedFileFilter es una clase para usarla junto a los JFileChooser. |
|
32 |
* Ofrece una funcionalidad simple para poder agregar extensiones de manera |
|
33 |
* comoda y rapida. Las descripciones ya las pone con un formato, asi que esto |
|
34 |
* es opcional poner una descripci?n especifica. |
|
35 |
* |
|
36 |
* Un ejemplo t?pico de como se usaria: |
|
37 |
* <pre> |
|
38 |
* // Usamos el JFileChooser de libUIComponents |
|
39 |
* JFileChooser chooser = new JFileChooser(this.getClass().toString(), (File) null); |
|
40 |
* // Desactivamos el modo de ver todos los ficheros |
|
41 |
* chooser.setAcceptAllFileFilterUsed(false); |
|
42 |
* // Activamos la multiseleccion |
|
43 |
* chooser.setMultiSelectionEnabled(true); |
|
44 |
* // Nos guardamos cada tipo de fichero en uno que contenga todos |
|
45 |
* ExtendedFileFilter allFilters = new ExtendedFileFilter(); |
|
46 |
* for (int i = 0; i < formats.length; i++) { |
|
47 |
* ExtendedFileFilter fileFilter = new ExtendedFileFilter(); |
|
48 |
* fileFilter.addExtension(formats[i]); |
|
49 |
* // Agregamos el filefilter al JFileChooser |
|
50 |
* chooser.addChoosableFileFilter(fileFilter); |
|
51 |
* // Agregamos el mismo filtro a un ExtendedFileFilter global |
|
52 |
* allFilters.addExtension(formats[i]); |
|
53 |
* } |
|
54 |
* // Poner una descripcion (OPCIONAL) para todos los ficheros. |
|
55 |
* allFilters.setDescription(PluginServices.getText(this, "todos_soportados")); |
|
56 |
* // Lo a?adimos |
|
57 |
* chooser.addChoosableFileFilter(allFilters); |
|
58 |
* // Y lo dejamos seleccionado por defecto |
|
59 |
* chooser.setFileFilter(allFilters); |
|
60 |
* </pre> |
|
61 |
* |
|
62 |
* @version 21/11/2007 |
|
63 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
64 |
*/ |
|
65 |
public class ExtendedFileFilter extends FileFilter { |
|
66 |
String description = null; |
|
67 |
|
|
68 |
ArrayList<String> extensions = new ArrayList<String>(); |
|
69 |
|
|
70 |
/** |
|
71 |
* Constructor de un ExtendedFileFilter |
|
72 |
*/ |
|
73 |
public ExtendedFileFilter() { |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Construye un ExtendedFileFilter con una extensi?n ya agregada |
|
78 |
* @param extension |
|
79 |
*/ |
|
80 |
public ExtendedFileFilter(String extension) { |
|
81 |
addExtension(extension); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* A?ade una extensi?n a la lista de extensiones soportadas |
|
86 |
* @param extension |
|
87 |
*/ |
|
88 |
public void addExtension(String extension) { |
|
89 |
if (extension == null) |
|
90 |
return; |
|
91 |
|
|
92 |
extensions.add(extension); |
|
93 |
} |
|
94 |
|
|
95 |
/* |
|
96 |
* (non-Javadoc) |
|
97 |
* @see javax.swing.filechooser.FileFilter#accept(java.io.File) |
|
98 |
*/ |
|
99 |
public boolean accept(File f) { |
|
100 |
if (f.isDirectory()) |
|
101 |
return true; |
|
102 |
|
|
103 |
String s = f.getName(); |
|
104 |
int i = s.lastIndexOf('.'); |
|
105 |
|
|
106 |
if (i > 0 && i < s.length() - 1) { |
|
107 |
String extension = s.substring(i + 1).toLowerCase(); |
|
108 |
for (int j = 0; j < extensions.size(); j++) { |
|
109 |
if (extensions.get(j).toString().toLowerCase().equals(extension)) |
|
110 |
return true; |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
return false; |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* Normaliza el nombre de un fichero, a?adiendo la extension si fuera |
|
119 |
* necesario |
|
120 |
* @param file |
|
121 |
* @return |
|
122 |
*/ |
|
123 |
public String getNormalizedFilename(File file) { |
|
124 |
String s = file.getName(); |
|
125 |
int i = s.lastIndexOf('.'); |
|
126 |
|
|
127 |
if (i > 0 && i < s.length() - 1) { |
|
128 |
String extension = s.substring(i + 1).toLowerCase(); |
|
129 |
for (int j = 0; j < extensions.size(); j++) { |
|
130 |
if (extensions.get(j).toString().toLowerCase().equals(extension)) |
|
131 |
return file.toString(); |
|
132 |
} |
|
133 |
} |
|
134 |
|
|
135 |
return file.toString() + "." + extensions.get(0).toString().toLowerCase(); |
|
136 |
} |
|
137 |
|
|
138 |
/* |
|
139 |
* (non-Javadoc) |
|
140 |
* @see javax.swing.filechooser.FileFilter#getDescription() |
|
141 |
*/ |
|
142 |
public String getDescription() { |
|
143 |
String format1 = ""; |
|
144 |
String format2 = ""; |
|
145 |
for (int j = 0; j < extensions.size(); j++) { |
|
146 |
if (format1.length() != 0) { |
|
147 |
format1 = format1 + ", "; |
|
148 |
format2 = format2 + "; "; |
|
149 |
} |
|
150 |
// Files JPG, GIF, ... (*.jpg; *.gif ...) |
|
151 |
if (j >= 4) { |
|
152 |
format1 = "..."; |
|
153 |
format2 = "..."; |
|
154 |
break; |
|
155 |
} |
|
156 |
format1 = format1 + extensions.get(j).toString().toUpperCase(); |
|
157 |
format2 = format2 + "*." + extensions.get(j).toString().toLowerCase(); |
|
158 |
} |
|
159 |
if (description == null) |
|
160 |
return "files" + " " + format1 + " (" + format2 + ")"; |
|
161 |
|
|
162 |
return description + " (" + format2 + ")"; |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* Especifica la descripcion del item |
|
167 |
* @param description the description to set |
|
168 |
*/ |
|
169 |
public void setDescription(String description) { |
|
170 |
this.description = description; |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* Borra una extension de la lista de extensiones |
|
175 |
* @param extension |
|
176 |
*/ |
|
177 |
public void removeExtension(String extension){ |
|
178 |
extensions.remove(extension); |
|
179 |
} |
|
180 |
|
|
181 |
/** |
|
182 |
* Borra todas las extensiones existentes |
|
183 |
*/ |
|
184 |
public void clearExtensions(){ |
|
185 |
extensions.clear(); |
|
186 |
} |
|
187 |
|
|
188 |
/** |
|
189 |
* Devuelve una lista con las extensiones disponibles |
|
190 |
* @return |
|
191 |
*/ |
|
192 |
public ArrayList<String> getExtensions(){ |
|
193 |
return extensions; |
|
194 |
} |
|
195 |
} |
|
0 | 196 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.213/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/util/GenericBasePanel.java | ||
---|---|---|
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.util; |
|
23 |
|
|
24 |
/** |
|
25 |
* Clase no abstracta para instanciar un BasePanel generico |
|
26 |
* 18/08/2008 |
|
27 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
28 |
*/ |
|
29 |
public class GenericBasePanel extends BasePanel { |
|
30 |
private static final long serialVersionUID = 1L; |
|
31 |
|
|
32 |
/* |
|
33 |
* (non-Javadoc) |
|
34 |
* @see org.gvsig.raster.util.BasePanel#init() |
|
35 |
*/ |
|
36 |
protected void init() { |
|
37 |
} |
|
38 |
|
|
39 |
/* |
|
40 |
* (non-Javadoc) |
|
41 |
* @see org.gvsig.raster.util.BasePanel#translate() |
|
42 |
*/ |
|
43 |
protected void translate() { |
|
44 |
} |
|
45 |
} |
|
0 | 46 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.213/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/util/BasePanel.java | ||
---|---|---|
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.util; |
|
23 |
|
|
24 |
import java.awt.Component; |
|
25 |
import java.awt.event.ActionListener; |
|
26 |
import java.awt.event.KeyListener; |
|
27 |
import java.awt.event.MouseListener; |
|
28 |
import java.util.ArrayList; |
|
29 |
|
|
30 |
import javax.swing.AbstractButton; |
|
31 |
import javax.swing.JPanel; |
|
32 |
|
|
33 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
36 |
|
|
37 |
/** |
|
38 |
* Clase base para los paneles gr?ficos. |
|
39 |
* |
|
40 |
* 17/07/2008 |
|
41 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
42 |
*/ |
|
43 |
public abstract class BasePanel extends JPanel { |
|
44 |
private static final long serialVersionUID = -8877600252349334979L; |
|
45 |
private boolean enableValueChangedEvent = true; |
|
46 |
|
|
47 |
public static final int KEYLISTENER = 0; |
|
48 |
public static final int ACTIONLISTENER = 1; |
|
49 |
public static final int MOUSELISTENER = 2; |
|
50 |
private static final Logger logger = LoggerFactory.getLogger(DefaultFLyrRaster.class); |
|
51 |
|
|
52 |
/** |
|
53 |
* Obtiene una instancia de una clase generica que hereda de BasePanel |
|
54 |
* @return BasePanel |
|
55 |
*/ |
|
56 |
public static BasePanel getInstance() { |
|
57 |
return new GenericBasePanel(); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Obtiene la traducci?n de la cadena de texto |
|
62 |
* @param parent Ventana padre |
|
63 |
* @param text Cadena a traducir |
|
64 |
* @return Cadena de texto traducida |
|
65 |
*/ |
|
66 |
public String getText(Object parent, String key) { |
|
67 |
if (key == null) |
|
68 |
return null; |
|
69 |
String translation = org.gvsig.i18n.Messages.getText(key, false); |
|
70 |
if (translation != null) |
|
71 |
return translation; |
|
72 |
else { |
|
73 |
logger.debug("Can't find translation for ''{1}''.", key); |
|
74 |
return key; |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* Obtiene la traducci?n de la cadena de texto |
|
80 |
* @param text Cadena a traducir |
|
81 |
* @return Cadena de texto traducida |
|
82 |
*/ |
|
83 |
public String getText(String text) { |
|
84 |
return getText(this, text); |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* Asigna el valor para la activaci?n y desactivaci?n del evento de cambio de valor en |
|
89 |
* las cajas de texto. |
|
90 |
* @param enableValueChangedEvent |
|
91 |
*/ |
|
92 |
public void setEnableValueChangedEvent(boolean enableValueChangedEvent) { |
|
93 |
this.enableValueChangedEvent = enableValueChangedEvent; |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* Obtiene el valor para la activaci?n y desactivaci?n del evento de cambio de valor en |
|
98 |
* las cajas de texto. |
|
99 |
* @param enableValueChangedEvent |
|
100 |
*/ |
|
101 |
public boolean isEnableValueChangedEvent() { |
|
102 |
return this.enableValueChangedEvent; |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
106 |
* Obtiene la lista de componentes del panel. Si dentro tiene alg?n BasePanel |
|
107 |
* consulta la lista de componentes de este y la devuelve. |
|
108 |
* @return |
|
109 |
*/ |
|
110 |
public ArrayList<Component> getComponentList() { |
|
111 |
ArrayList<Component> listComp = new ArrayList<Component>(); |
|
112 |
for (int i = 0; i < this.getComponentCount(); i++) { |
|
113 |
if(getComponent(i) instanceof BasePanel) { |
|
114 |
ArrayList<Component> list = ((BasePanel)getComponent(i)).getComponentList(); |
|
115 |
for (int j = 0; j < list.size(); j++) |
|
116 |
listComp.add(list.get(j)); |
|
117 |
} else |
|
118 |
listComp.add(getComponent(i)); |
|
119 |
} |
|
120 |
return listComp; |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* Registra un listener en todos los componentes contenidos en este panel. |
|
125 |
* @param type Tipo de listener definido por las variables est?ticas en esta clase |
|
126 |
* @param listener Objeto listener del tipo correcto |
|
127 |
*/ |
|
128 |
public void registerListener(int type, Object listener) { |
|
129 |
ArrayList<Component> listComp = getComponentList(); |
|
130 |
if(type == KEYLISTENER) { |
|
131 |
if(listener instanceof KeyListener) { |
|
132 |
for (int i = 0; i < listComp.size(); i++) |
|
133 |
if(listComp.get(i) instanceof Component) |
|
134 |
((Component)listComp.get(i)).addKeyListener((KeyListener)listener); |
|
135 |
} |
|
136 |
} |
|
137 |
if(type == ACTIONLISTENER) { |
|
138 |
if(listener instanceof ActionListener) { |
|
139 |
for (int i = 0; i < listComp.size(); i++) |
|
140 |
if(listComp.get(i) instanceof AbstractButton) |
|
141 |
((AbstractButton)listComp.get(i)).addActionListener((ActionListener)listener); |
|
142 |
} |
|
143 |
} |
|
144 |
if(type == MOUSELISTENER) { |
|
145 |
if(listener instanceof MouseListener) { |
|
146 |
for (int i = 0; i < listComp.size(); i++) |
|
147 |
if(listComp.get(i) instanceof Component) |
|
148 |
((Component)listComp.get(i)).addMouseListener((MouseListener)listener); |
|
149 |
} |
|
150 |
} |
|
151 |
} |
|
152 |
|
|
153 |
/** |
|
154 |
* Traducci?n centralizada de los componentes de una panel |
|
155 |
*/ |
|
156 |
protected abstract void translate(); |
|
157 |
|
|
158 |
/** |
|
159 |
* Acciones de inicializaci?n |
|
160 |
*/ |
|
161 |
protected abstract void init(); |
|
162 |
} |
|
0 | 163 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.213/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/util/CancelTaskImpl.java | ||
---|---|---|
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.util; |
|
23 |
|
|
24 |
import org.gvsig.compat.net.ICancellable; |
|
25 |
import org.gvsig.tools.task.Cancellable; |
|
26 |
|
|
27 |
/** |
|
28 |
* All tasks which use libRemoteServices need an object that implements ICancellable |
|
29 |
* to cancel processes. |
|
30 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
31 |
*/ |
|
32 |
@SuppressWarnings("deprecation") |
|
33 |
public class CancelTaskImpl implements ICancellable { |
|
34 |
private boolean cancel = false; |
|
35 |
private Cancellable c = null; |
|
36 |
|
|
37 |
public CancelTaskImpl() { |
|
38 |
} |
|
39 |
|
|
40 |
public CancelTaskImpl(Cancellable c) { |
|
41 |
this.c = c; |
|
42 |
} |
|
43 |
|
|
44 |
/* |
|
45 |
* (non-Javadoc) |
|
46 |
* @see org.gvsig.compat.net.ICancellable#getID() |
|
47 |
*/ |
|
48 |
public Object getID() { |
|
49 |
return this; |
|
50 |
} |
|
51 |
|
|
52 |
/* |
|
53 |
* (non-Javadoc) |
|
54 |
* @see org.gvsig.compat.net.ICancellable#isCanceled() |
|
55 |
*/ |
|
56 |
public boolean isCanceled() { |
|
57 |
if(c != null) |
|
58 |
return c.isCanceled(); |
|
59 |
return cancel; |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* Cancel the task |
|
64 |
* @param cancel |
|
65 |
*/ |
|
66 |
public void setCanceled(boolean cancel) { |
|
67 |
if(c != null) |
|
68 |
c.setCanceled(cancel); |
|
69 |
this.cancel = cancel; |
|
70 |
} |
|
71 |
} |
|
0 | 72 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.213/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/util/LayerVisualStatusList.java | ||
---|---|---|
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.util; |
|
23 |
|
|
24 |
import java.util.ArrayList; |
|
25 |
import java.util.List; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilter; |
|
28 |
import org.gvsig.fmap.dal.coverage.grid.render.Render; |
|
29 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
|
30 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
31 |
import org.gvsig.raster.fmap.layers.IRasterLayerActions; |
|
32 |
|
|
33 |
/** |
|
34 |
* Clase para almacenar estados visuales de una capa raster. Estos estados deben ser locales |
|
35 |
* a cada funcionalidad para que no interfieran entre ellos. Luego es posible tener una lista de |
|
36 |
* estados globales para restaurar el que nos convenga. |
|
37 |
* 07/10/2008 |
|
38 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
39 |
*/ |
|
40 |
public class LayerVisualStatusList { |
|
41 |
private ArrayList<LayerVisualStatus> list = new ArrayList<LayerVisualStatus>(); |
|
42 |
|
|
43 |
/** |
|
44 |
* Clase que contiene el estado visual de una capa raster. |
|
45 |
* 07/10/2008 |
|
46 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
47 |
*/ |
|
48 |
public class LayerVisualStatus { |
|
49 |
private List<RasterFilter> filterStatus = null; |
|
50 |
private Transparency transparency = null; |
|
51 |
|
|
52 |
/** |
|
53 |
* Obtiene el estado de la lista de filtros |
|
54 |
* @return Array con el estado de la lista de filtros |
|
55 |
*/ |
|
56 |
public List<RasterFilter> getFilterStatus() { |
|
57 |
return filterStatus; |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Asigna el estado de la lista de filtros |
|
62 |
* @return Array con el estado de la lista de filtros |
|
63 |
*/ |
|
64 |
public void setFilterStatus(List<RasterFilter> filterStatus) { |
|
65 |
this.filterStatus = filterStatus; |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* Obtiene el estado de la transparencia |
|
70 |
* @return Transparency |
|
71 |
*/ |
|
72 |
public Transparency getTransparency() { |
|
73 |
return transparency; |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Asigna el estado de la transparencia |
|
78 |
* @param Transparency |
|
79 |
*/ |
|
80 |
public void setTransparency(Transparency transparency) { |
|
81 |
this.transparency = transparency; |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* Limpia la pila de elementos |
|
87 |
*/ |
|
88 |
public void clear() { |
|
89 |
list.clear(); |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* Salva un estado al final de la lista |
|
94 |
* @param status |
|
95 |
*/ |
|
96 |
public void add(LayerVisualStatus status) { |
|
97 |
list.add(status); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Recupera el ?ltimo estado introducido en la lista |
|
102 |
* @return StatusLayer |
|
103 |
*/ |
|
104 |
public LayerVisualStatus getLast() { |
|
105 |
return (LayerVisualStatus)list.get(list.size() - 1); |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* Recupera el estado de la posici?n i |
|
110 |
* @return StatusLayer |
|
111 |
*/ |
|
112 |
public LayerVisualStatus get(int i) { |
|
113 |
return (LayerVisualStatus)list.get(i); |
|
114 |
} |
|
115 |
|
|
116 |
|
|
117 |
/** |
|
118 |
* Saca de la lista el ?ltimo estado y lo asigna a la capa indicada. |
|
119 |
* @param lyr Capa raster |
|
120 |
*/ |
|
121 |
public void restoreVisualStatus(FLyrRaster lyr) { |
|
122 |
Render rendering = lyr.getRender(); |
|
123 |
LayerVisualStatus status = getLast(); |
|
124 |
if(status != null) { |
|
125 |
if(rendering.getFilterList() != null) |
|
126 |
rendering.getFilterList().setStatus(status.filterStatus); |
|
127 |
lyr.getRender().setLastTransparency(status.transparency); |
|
128 |
if(((IRasterLayerActions)lyr).isActionEnabled(IRasterLayerActions.REMOTE_ACTIONS)) |
|
129 |
lyr.getRender().getFilterList().setStatus(status.filterStatus); |
|
130 |
} |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* Obtiene de la capa su estado de visualizaci?n y lo salva en la lista |
|
135 |
* @param lyr Capa raster |
|
136 |
*/ |
|
137 |
public void getVisualStatus(FLyrRaster lyr) { |
|
138 |
LayerVisualStatus status = new LayerVisualStatus(); |
|
139 |
status.transparency = lyr.getRender().getRenderingTransparency(); |
|
140 |
status.filterStatus = lyr.getRender().getFilterList().getStatusCloned(); |
|
141 |
add(status); |
|
142 |
} |
|
143 |
} |
|
0 | 144 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.213/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/util/RasterNotLoadException.java | ||
---|---|---|
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.util; |
|
23 |
|
|
24 |
|
|
25 |
/** |
|
26 |
* Excepci?n producida cuando no es posible cargar un raster en la vista de gvSIG. |
|
27 |
* |
|
28 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
29 |
* |
|
30 |
*/ |
|
31 |
public class RasterNotLoadException extends Exception { |
|
32 |
private static final long serialVersionUID = -3022090543908771484L; |
|
33 |
|
|
34 |
public RasterNotLoadException(String msg){ |
|
35 |
super(msg); |
|
36 |
} |
|
37 |
|
|
38 |
public RasterNotLoadException(String msg, Throwable cause){ |
|
39 |
super(msg, cause); |
|
40 |
} |
|
41 |
} |
|
0 | 42 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.213/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/util/Queue.java | ||
---|---|---|
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.util; |
|
23 |
|
|
24 |
import java.util.Vector; |
|
25 |
|
|
26 |
/** |
|
27 |
* A simple FIFO queue class which causes the calling thread to wait if the |
|
28 |
* queue is empty and notifies threads that are waiting when it is not |
|
29 |
* empty. |
|
30 |
* |
|
31 |
* @author Anil V (akv@eng.sun.com) |
|
32 |
*/ |
|
33 |
public class Queue { |
|
34 |
private Vector<Object> vector = new Vector<Object>(); |
|
35 |
|
|
36 |
/** |
|
37 |
* Put the object into the queue. |
|
38 |
* |
|
39 |
* @param object |
|
40 |
* the object to be appended to the queue. |
|
41 |
*/ |
|
42 |
public synchronized void put(Object object) { |
|
43 |
vector.addElement(object); |
|
44 |
notify(); |
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* Pull the first object out of the queue. Wait if the queue is empty. |
|
49 |
*/ |
|
50 |
public synchronized Object pull() { |
|
51 |
while (isEmpty()) |
|
52 |
try { |
|
53 |
wait(); |
|
54 |
} catch (InterruptedException ex) { |
|
55 |
} |
|
56 |
return get(); |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* Get the first object out of the queue. Return null if the queue is |
|
61 |
* empty. |
|
62 |
*/ |
|
63 |
public synchronized Object get() { |
|
64 |
Object object = peek(); |
|
65 |
if (object != null) |
|
66 |
vector.removeElementAt(0); |
|
67 |
return object; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Peek to see if something is available. |
|
72 |
*/ |
|
73 |
public Object peek() { |
|
74 |
if (isEmpty()) |
|
75 |
return null; |
|
76 |
return vector.elementAt(0); |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Is the queue empty? |
|
81 |
*/ |
|
82 |
public boolean isEmpty() { |
|
83 |
return vector.isEmpty(); |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* How many elements are there in this queue? |
|
88 |
*/ |
|
89 |
public int size() { |
|
90 |
return vector.size(); |
|
91 |
} |
|
92 |
} |
|
0 | 93 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.213/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/FmapRasterLibrary.java | ||
---|---|---|
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 |
|
|
23 |
package org.gvsig.raster.fmap; |
|
24 |
|
|
25 |
import org.gvsig.fmap.dal.DALLibrary; |
|
26 |
import org.gvsig.fmap.dal.coverage.RasterLibrary; |
|
27 |
import org.gvsig.fmap.dal.raster.CoverageStore; |
|
28 |
import org.gvsig.fmap.mapcontext.MapContextLibrary; |
|
29 |
import org.gvsig.fmap.mapcontext.layers.LayerFactory; |
|
30 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
31 |
import org.gvsig.raster.fmap.legend.ColorTableLegend; |
|
32 |
import org.gvsig.tools.library.AbstractLibrary; |
|
33 |
import org.gvsig.tools.library.Library; |
|
34 |
import org.gvsig.tools.library.LibraryException; |
|
35 |
|
|
36 |
/** |
|
37 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
38 |
*/ |
|
39 |
public class FmapRasterLibrary extends AbstractLibrary { |
|
40 |
|
|
41 |
@SuppressWarnings("deprecation") |
|
42 |
public FmapRasterLibrary() { |
|
43 |
super(FmapRasterLibrary.class, Library.TYPE.IMPL); |
|
44 |
require(DALLibrary.class); |
|
45 |
require(MapContextLibrary.class); |
|
46 |
require(RasterLibrary.class); |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
protected void doInitialize() throws LibraryException { |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
protected void doPostInitialize() throws LibraryException { |
|
55 |
DefaultFLyrRaster.registerPersistence(); |
|
56 |
//StatusLayerRaster.registerPersistence(); |
|
57 |
ColorTableLegend.registerPersistence(); |
|
58 |
LayerFactory.getInstance().registerLayerToUseForStore( |
|
59 |
CoverageStore.class, |
|
60 |
DefaultFLyrRaster.class); |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
0 | 64 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.213/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/tool/SaveRasterListenerImpl.java | ||
---|---|---|
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.fmap.tool; |
|
23 |
|
|
24 |
import java.awt.Image; |
|
25 |
import java.awt.geom.Rectangle2D; |
|
26 |
|
|
27 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
28 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
29 |
import org.gvsig.fmap.mapcontrol.tools.Events.EnvelopeEvent; |
|
30 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.RectangleListener; |
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
/** |
|
35 |
* Implementaci?n de la interfaz RectangleListener como herramienta para |
|
36 |
* realizar un Salvado a Raster. |
|
37 |
* |
|
38 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
39 |
*/ |
|
40 |
public class SaveRasterListenerImpl implements RectangleListener { |
|
41 |
protected MapControl mapCtrl; |
|
42 |
|
|
43 |
protected Rectangle2D pixelRect = null; |
|
44 |
protected Envelope rect = null; |
|
45 |
|
|
46 |
/** |
|
47 |
* Crea un nuevo RectangleListenerImpl. |
|
48 |
* |
|
49 |
* @param mapCtrl MapControl. |
|
50 |
*/ |
|
51 |
public SaveRasterListenerImpl(MapControl mapCtrl) { |
|
52 |
this.mapCtrl = mapCtrl; |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.RectangleListener#rectangle(com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent) |
|
57 |
*/ |
|
58 |
public void rectangle(EnvelopeEvent event) { |
|
59 |
rect = event.getWorldCoordRect(); |
|
60 |
pixelRect = event.getPixelCoordRect(); |
|
61 |
} |
|
62 |
|
|
63 |
// /** |
|
64 |
// * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor() |
|
65 |
// */ |
|
66 |
// public Cursor getCursor() { |
|
67 |
// return cur; |
|
68 |
// } |
|
69 |
|
|
70 |
/** |
|
71 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing() |
|
72 |
*/ |
|
73 |
public boolean cancelDrawing() { |
|
74 |
System.out.println("cancelDrawing del SaveRasterListenerImpl"); |
|
75 |
return true; |
|
76 |
} |
|
77 |
|
|
78 |
public Image getImageCursor() { |
|
79 |
return null; |
|
80 |
} |
|
81 |
|
|
82 |
} |
|
0 | 83 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.213/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/tool/behavior/TransformedRectangleBehavior.java | ||
---|---|---|
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.fmap.tool.behavior; |
|
23 |
|
|
24 |
import java.awt.BasicStroke; |
|
25 |
import java.awt.Color; |
|
26 |
import java.awt.Image; |
|
27 |
import java.awt.Point; |
|
28 |
import java.awt.Rectangle; |
|
29 |
import java.awt.RenderingHints; |
|
30 |
import java.awt.event.MouseEvent; |
|
31 |
import java.awt.geom.AffineTransform; |
|
32 |
import java.awt.geom.NoninvertibleTransformException; |
|
33 |
import java.awt.geom.Point2D; |
|
34 |
import java.awt.geom.Rectangle2D; |
|
35 |
import java.awt.image.BufferedImage; |
|
36 |
|
|
37 |
import org.gvsig.fmap.IconThemeHelper; |
|
38 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
39 |
import org.gvsig.fmap.geom.GeometryManager; |
|
40 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
41 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
42 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
43 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
44 |
import org.gvsig.fmap.mapcontrol.MapControlDrawer; |
|
45 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
46 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
|
47 |
import org.gvsig.fmap.mapcontrol.tools.Events.EnvelopeEvent; |
|
48 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.RectangleListener; |
|
49 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener; |
|
50 |
import org.slf4j.Logger; |
|
51 |
import org.slf4j.LoggerFactory; |
|
52 |
|
|
53 |
|
|
54 |
/** |
|
55 |
* Comportamiento de una selecci?n por rectangulo con una transformaci?n |
|
56 |
* aplicada. El resultado visual es la selecci?n como un rectangulo com?n con |
|
57 |
* el rectangulo transformado superpuesto. |
|
58 |
* |
|
59 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
60 |
* |
|
61 |
*/ |
|
62 |
@SuppressWarnings("deprecation") |
|
63 |
public class TransformedRectangleBehavior extends Behavior { |
|
64 |
private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
65 |
private static final Logger logger = LoggerFactory.getLogger(GeometryManager.class); |
|
66 |
/** |
|
67 |
* First point of the rectangle area, that represents a corner. |
|
68 |
*/ |
|
69 |
private Point2D m_FirstPoint = null; |
|
70 |
|
|
71 |
/** |
|
72 |
* Second point of the rectangle area, that represents the opposite corner of the first, |
|
73 |
* along the diagonal. |
|
74 |
*/ |
|
75 |
private Point2D m_LastPoint = null; |
|
76 |
|
|
77 |
/** |
|
78 |
* Tool listener used to work with the <code>MapControl</code> object. |
|
79 |
* |
|
80 |
* @see #getListener() |
|
81 |
* @see #setListener(ToolListener) |
|
82 |
*/ |
|
83 |
private RectangleListener listener = null; |
|
84 |
private AffineTransform at = null; |
|
85 |
private BasicStroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[]{5.0f}, 0.0f); |
|
86 |
|
|
87 |
/** |
|
88 |
* <p>Creates a new behavior for selecting rectangle areas.</p> |
|
89 |
* |
|
90 |
* @param zili listener used to permit this object to work with the associated <code>MapControl</code> |
|
91 |
*/ |
|
92 |
public TransformedRectangleBehavior(RectangleListener zili) { |
|
93 |
listener = zili; |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* Asigna la matriz de transformaci?n para el cuadro externo. |
|
98 |
* @param at AffineTransform |
|
99 |
*/ |
|
100 |
public void setAffineTransform(AffineTransform at) { |
|
101 |
this.at = at; |
|
102 |
} |
|
103 |
|
|
104 |
/* (non-Javadoc) |
|
105 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#getImageCursor() |
|
106 |
*/ |
|
107 |
public Image getImageCursor(){ |
|
108 |
return IconThemeHelper.getImage("rectangle-select-cursor"); |
|
109 |
} |
|
110 |
|
|
111 |
/* |
|
112 |
* (non-Javadoc) |
|
113 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics) |
|
114 |
*/ |
|
115 |
public void paintComponent(MapControlDrawer mapControlDrawer) { |
|
116 |
BufferedImage img = getMapControl().getImage(); |
|
117 |
RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
|
118 |
hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY)); |
|
119 |
mapControlDrawer.setRenderingHints(hints); |
|
120 |
mapControlDrawer.drawImage(img, 0, 0); |
|
121 |
mapControlDrawer.setColor(Color.black); |
|
122 |
//g.setXORMode(Color.white); |
|
123 |
|
|
124 |
// Borramos el anterior |
|
125 |
Rectangle r = new Rectangle(); |
|
126 |
|
|
127 |
// Dibujamos el actual |
|
128 |
if ((m_FirstPoint != null) && (m_LastPoint != null)) { |
|
129 |
r.setFrameFromDiagonal(m_FirstPoint, m_LastPoint); |
|
130 |
mapControlDrawer.drawRect(r.x, r.y, r.width, r.height); |
|
131 |
} |
|
132 |
|
|
133 |
//Dibujamos el cuadro exterior |
|
134 |
if(at != null) { |
|
135 |
Point2D.Double ul = new Point2D.Double(r.x, r.y); |
|
136 |
Point2D.Double ur = new Point2D.Double(r.x + r.width, r.y); |
|
137 |
Point2D.Double ll = new Point2D.Double(r.x, r.y + r.height); |
|
138 |
Point2D.Double lr = new Point2D.Double(r.x + r.width, r.y + r.height); |
|
139 |
|
|
140 |
Point2D center = new Point2D.Double((r.width) / 2.0, (r.height) / 2.0); |
|
141 |
AffineTransform T1 = new AffineTransform(1D, 0, 0, 1, -center.getX(), -center.getY()); |
|
142 |
AffineTransform R1 = new AffineTransform(1D, at.getShearY() / at.getScaleY(), at.getShearX() / at.getScaleX(), 1, 0, 0); |
|
143 |
AffineTransform T2 = new AffineTransform(1D, 0, 0, 1, center.getX(), center.getY()); |
|
144 |
T2.concatenate(R1); |
|
145 |
T2.concatenate(T1); |
|
146 |
|
|
147 |
try { |
|
148 |
T2.inverseTransform(ul, ul); |
|
149 |
T2.inverseTransform(ll, ll); |
|
150 |
T2.inverseTransform(ur, ur); |
|
151 |
T2.inverseTransform(lr, lr); |
|
152 |
|
|
153 |
Point2D.Double ptMin = new Point2D.Double( Math.min(Math.min(ul.getX(), ur.getX()), Math.min(ll.getX(), lr.getX())), |
|
154 |
Math.min(Math.min(ul.getY(), ur.getY()), Math.min(ll.getY(), lr.getY()))); |
|
155 |
Point2D.Double ptMax = new Point2D.Double( Math.max(Math.max(ul.getX(), ur.getX()), Math.max(ll.getX(), lr.getX())), |
|
156 |
Math.max(Math.max(ul.getY(), ur.getY()), Math.max(ll.getY(), lr.getY()))); |
|
157 |
double w = ptMax.getX() - ptMin.getX(); |
|
158 |
double h = ptMax.getY() - ptMin.getY(); |
|
159 |
|
|
160 |
mapControlDrawer.setStroke(stroke); |
|
161 |
mapControlDrawer.transform(T2); |
|
162 |
mapControlDrawer.drawRect((int)ptMin.getX(), (int)ptMin.getY(), (int)w, (int)h); |
|
163 |
mapControlDrawer.transform(at.createInverse()); |
|
164 |
} catch (NoninvertibleTransformException e) { |
|
165 |
return; |
|
166 |
} |
|
167 |
} |
|
168 |
//g.setPaintMode(); |
|
169 |
} |
|
170 |
|
|
171 |
/* |
|
172 |
* (non-Javadoc) |
|
173 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mousePressed(java.awt.event.MouseEvent) |
|
174 |
*/ |
|
175 |
public void mousePressed(MouseEvent e) { |
|
176 |
if (e.getButton() == MouseEvent.BUTTON1) { |
|
177 |
m_FirstPoint = e.getPoint(); |
|
178 |
getMapControl().repaint(); |
|
179 |
} |
|
180 |
if (listener.cancelDrawing()) { |
|
181 |
getMapControl().cancelDrawing(); |
|
182 |
getMapControl().repaint(); |
|
183 |
} |
|
184 |
} |
|
185 |
|
|
186 |
/* |
|
187 |
* (non-Javadoc) |
|
188 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseReleased(java.awt.event.MouseEvent) |
|
189 |
*/ |
|
190 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
|
191 |
if (m_FirstPoint == null) return; |
|
192 |
Point2D p1; |
|
193 |
Point2D p2; |
|
194 |
Point pScreen = e.getPoint(); |
|
195 |
|
|
196 |
ViewPort vp = getMapControl().getMapContext().getViewPort(); |
|
197 |
|
|
198 |
p1 = vp.toMapPoint(m_FirstPoint); |
|
199 |
p2 = vp.toMapPoint(pScreen); |
|
200 |
|
|
201 |
if (e.getButton() == MouseEvent.BUTTON1) { |
|
202 |
// Fijamos el nuevo extent |
|
203 |
double minX = Math.min(p1.getX(), p2.getX()); |
|
204 |
double minY = Math.min(p1.getY(), p2.getY()); |
|
205 |
double maxX = Math.max(p1.getX(), p2.getX()); |
|
206 |
double maxY = Math.max(p1.getY(), p2.getY()); |
|
207 |
Envelope env = null; |
|
208 |
try { |
|
209 |
env = geomManager.createEnvelope(minX, minY, maxX, maxY, SUBTYPES.GEOM2D); |
|
210 |
} catch (CreateEnvelopeException e1) { |
|
211 |
logger.error("Error creating the envelope", e); |
|
212 |
} |
|
213 |
|
|
214 |
Rectangle2D rectPixel = new Rectangle(); |
|
215 |
rectPixel.setFrameFromDiagonal(m_FirstPoint, pScreen); |
|
216 |
|
|
217 |
EnvelopeEvent event = new EnvelopeEvent(env, e, rectPixel); |
|
218 |
listener.rectangle(event); |
|
219 |
} |
|
220 |
|
|
221 |
m_FirstPoint = null; |
|
222 |
m_LastPoint = null; |
|
223 |
} |
|
224 |
|
|
225 |
/* |
|
226 |
* (non-Javadoc) |
|
227 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseDragged(java.awt.event.MouseEvent) |
|
228 |
*/ |
|
229 |
public void mouseDragged(MouseEvent e) { |
|
230 |
m_LastPoint = e.getPoint(); |
|
231 |
getMapControl().repaint(); |
|
232 |
} |
|
233 |
|
|
234 |
/** |
|
235 |
* <p>Sets a tool listener to work with the <code>MapControl</code> using this behavior.</p> |
|
236 |
* |
|
237 |
* @param listener a <code>RectangleListener</code> object for this behavior |
|
238 |
*/ |
|
239 |
public void setListener(ToolListener listener) { |
|
240 |
this.listener = (RectangleListener) listener; |
|
241 |
} |
|
242 |
|
|
243 |
/* |
|
244 |
* (non-Javadoc) |
|
245 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener() |
|
246 |
*/ |
|
247 |
public ToolListener getListener() { |
|
248 |
return listener; |
|
249 |
} |
|
250 |
} |
|
0 | 251 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.213/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/legend/ImageLegend.java | ||
---|---|---|
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.fmap.legend; |
|
23 |
|
|
24 |
import java.awt.Image; |
|
25 |
|
|
26 |
import org.gvsig.fmap.mapcontext.layers.operations.IHasImageLegend; |
|
27 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
28 |
import org.gvsig.fmap.mapcontext.rendering.legend.IRasterLegend; |
|
29 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendContentsChangedListener; |
|
30 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent; |
|
31 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
32 |
import org.gvsig.tools.persistence.PersistentState; |
|
33 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
34 |
|
|
35 |
/** |
|
36 |
* This object is for rasters which returns its legend as a image |
|
37 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
38 |
* |
|
39 |
*/ |
|
40 |
public class ImageLegend implements IRasterLegend, IHasImageLegend { |
|
41 |
private Image image = null; |
|
42 |
|
|
43 |
public ImageLegend(Image image) { |
|
44 |
this.image = image; |
|
45 |
} |
|
46 |
|
|
47 |
public Image getImageLegend() { |
|
48 |
return image; |
|
49 |
} |
|
50 |
|
|
51 |
public Object clone() throws CloneNotSupportedException { |
|
52 |
return new ImageLegend(image); |
|
53 |
} |
|
54 |
|
|
55 |
public void addLegendListener(LegendContentsChangedListener listener) { |
|
56 |
|
|
57 |
} |
|
58 |
|
|
59 |
public ILegend cloneLegend() { |
|
60 |
try { |
|
61 |
return (ILegend)clone(); |
|
62 |
} catch (CloneNotSupportedException e) { |
|
63 |
} |
|
64 |
return null; |
|
65 |
} |
|
66 |
|
|
67 |
public void fireDefaultSymbolChangedEvent(SymbolLegendEvent event) { |
|
68 |
|
|
69 |
} |
|
70 |
|
|
71 |
public ISymbol getDefaultSymbol() { |
|
72 |
return null; |
|
73 |
} |
|
74 |
|
|
75 |
public LegendContentsChangedListener[] getListeners() { |
|
76 |
return null; |
|
77 |
} |
|
78 |
|
|
79 |
public void removeLegendListener(LegendContentsChangedListener listener) { |
|
80 |
|
|
81 |
} |
|
82 |
|
|
83 |
public void loadFromState(PersistentState state) |
|
84 |
throws PersistenceException { |
|
85 |
|
|
86 |
} |
|
87 |
|
|
88 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
89 |
|
|
90 |
} |
|
91 |
|
|
92 |
public String getPathImage() { |
|
93 |
return null; |
|
94 |
} |
|
95 |
|
|
96 |
} |
|
0 | 97 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.213/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/legend/ColorTableLegend.java | ||
---|---|---|
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.fmap.legend; |
|
23 |
|
|
24 |
import java.awt.Color; |
|
25 |
import java.util.Arrays; |
|
26 |
import java.util.List; |
|
27 |
|
|
28 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
29 |
import org.gvsig.fmap.dal.coverage.datastruct.ColorItem; |
|
30 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
|
31 |
import org.gvsig.fmap.dal.coverage.util.MathUtils; |
|
32 |
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedLegend; |
|
33 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
34 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendContentsChangedListener; |
|
35 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent; |
|
36 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
37 |
import org.gvsig.symbology.SymbologyLocator; |
|
38 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol; |
|
39 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol; |
|
40 |
import org.gvsig.tools.ToolsLocator; |
|
41 |
import org.gvsig.tools.dynobject.DynStruct; |
|
42 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
43 |
import org.gvsig.tools.persistence.PersistentState; |
|
44 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
45 |
|
|
46 |
/** |
|
47 |
* Leyenda para tablas de color aplicadas a un raster. |
|
48 |
* |
|
49 |
* @version 27/06/2007 |
|
50 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
51 |
*/ |
|
52 |
public class ColorTableLegend implements IClassifiedLegend, ILegend { |
|
53 |
public static final String COLOR_TABLE_LEGEND_DYNCLASS_NAME = "ColorTableLegend"; |
|
54 |
private static final String FIELD_SYMBOLS = "symbols"; |
|
55 |
private static final String FIELD_DESCRIPTIONS = "descriptions"; |
|
56 |
|
|
57 |
private ISymbol[] symbols = null; |
|
58 |
private String[] desc = null; |
|
59 |
|
|
60 |
/** |
|
61 |
* Crea una leyenda de tipo ColorTableLegend a partir de un objeto ColorTable |
|
62 |
* @param colorTable |
|
63 |
* @return ColorTableLegend |
|
64 |
*/ |
|
65 |
public static ColorTableLegend createLegend(ColorTable colorTable) { |
|
66 |
if ((colorTable == null) || (colorTable.getColorItems() == null)) |
|
67 |
return null; |
|
68 |
MathUtils math = RasterLocator.getManager().getMathUtils(); |
|
69 |
|
|
70 |
ILineSymbol line = SymbologyLocator.getSymbologyManager().createSimpleLineSymbol(); |
|
71 |
line.setLineColor(Color.BLACK); |
|
72 |
ISymbol[] symbol = new ISymbol[colorTable.getColorItems().size()]; |
|
73 |
String[] desc = new String[colorTable.getColorItems().size()]; |
|
74 |
|
|
75 |
String nameClass = null; |
|
76 |
for (int i = 0; i < colorTable.getColorItems().size(); i++) { |
|
77 |
IFillSymbol s = SymbologyLocator.getSymbologyManager().createSimpleFillSymbol(); |
|
78 |
s.setOutline(line); |
|
79 |
s.setFillColor(((ColorItem) colorTable.getColorItems().get(i)).getColor()); |
|
80 |
nameClass = ((ColorItem) colorTable.getColorItems().get(i)).getNameClass(); |
|
81 |
if ((nameClass == null) || (nameClass.equals(""))){ |
|
82 |
if (i < (colorTable.getColorItems().size() - 1)){ |
|
83 |
desc[i] = "[" + math.format(((ColorItem) colorTable.getColorItems().get(i)).getValue(), 2) + " , " + math.format(((ColorItem) colorTable.getColorItems().get(i + 1)).getValue(), 2) + "[ "; |
|
84 |
}else{ |
|
85 |
desc[i] = "[" + math.format(((ColorItem) colorTable.getColorItems().get(i)).getValue(), 2) + "] "; |
|
86 |
} |
|
87 |
}else{ |
|
88 |
desc[i] = ((ColorItem) colorTable.getColorItems().get(i)).getNameClass(); |
|
89 |
} |
|
90 |
symbol[i] = s; |
|
91 |
} |
|
92 |
|
|
93 |
return new ColorTableLegend(symbol, desc); |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* Leyenda para tablas de color raster. |
|
98 |
* @param s Lista de simbolos |
|
99 |
* @param d Lista de descripciones de simbolos |
|
100 |
*/ |
|
101 |
public ColorTableLegend(ISymbol[] s, String[] d) { |
|
102 |
symbols = s; |
|
103 |
desc = d; |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* Empty constructor used only for persistence purposes. |
|
108 |
*/ |
|
109 |
public ColorTableLegend() { |
|
110 |
} |
|
111 |
|
|
112 |
/* |
|
113 |
* (non-Javadoc) |
|
114 |
* @see com.iver.cit.gvsig.fmap.rendering.IClassifiedLegend#getDescriptions() |
|
115 |
*/ |
|
116 |
public String[] getDescriptions() { |
|
117 |
return desc; |
|
118 |
} |
|
119 |
|
|
120 |
/* |
|
121 |
* (non-Javadoc) |
|
122 |
* @see com.iver.cit.gvsig.fmap.rendering.IClassifiedLegend#getSymbols() |
|
123 |
*/ |
|
124 |
public ISymbol[] getSymbols() { |
|
125 |
return symbols; |
Also available in: Unified diff