Revision 1334

View differences:

org.gvsig.raster/tags/buildNumber_29/org.gvsig.raster/mvnraster
1
#/bin/sh
2

  
3
PLATFORM="linux"
4
COMPILER="gcc4"
5
ARCH="i386"
6
DISTRIBUTION="all"
7
TYPE="dynamic"
8
CLASSIFIER=$PLATFORM"-"$DISTRIBUTION"-"$COMPILER"-"$ARCH"-"$TYPE
9

  
10

  
11
if [ "$1" = "--help" ] ; then
12
   echo "Usage: First parameter:"
13
   echo "          -installer: mvn install create-installer"
14
   echo "          -install: mvn install"
15
   echo "          -eclipse: mvn eclipse"
16
   echo "          -deploy: mvn deploy"
17
   echo "          -eclipseclean: mvn eclipse:clean"
18
   echo "          -clean: mvn clean"
19
   echo "       Second parameter:"
20
   echo "          without second parameter only base projects"
21
   echo "          -all: all projects"
22
   echo "          -remote: base projects plus remote services"
23
   echo "          -formats: base projects plus other formats \(ecw, mrsid, netcdf, time support\)"
24
   exit
25
fi
26

  
27
ADDITIONAL_PARAMS="-Dnative-platform="$PLATFORM" -Dnative-compiler="$COMPILER" -Dnative-arch="$ARCH" -Dnative-distribution="$DISTRIBUTION" -Dlibrary-type="$TYPE" -Dnative-classifier="$CLASSIFIER" -Pinstall-extensions -Dmaven.test.skip"
28

  
29
PARAMS_INSTALL="install "$ADDITIONAL_PARAMS" -Pinstall-extensions -Dmaven.test.skip"
30
PARAMS_ECLIPSE="eclipse:eclipse "$ADDITIONAL_PARAMS
31
PARAMS_DEPLOY="deploy "$ADDITIONAL_PARAMS" -Pinstall-extensions -Dmaven.test.skip"
32
PARAMS_CLEAN="clean"
33
PARAMS_ECLIPSECLEAN="eclipse:clean"
34
PARAMS_CREATE_INSTALLER="install "$ADDITIONAL_PARAMS" -Pcreate-installer"
35

  
36
PATHS_BASE="org.gvsig.raster.cache org.gvsig.raster org.gvsig.raster.gdal org.gvsig.raster.tilecache org.gvsig.raster.tools"
37
PATHS_REMOTE="org.gvsig.raster.wmts org.gvsig.raster.wms org.gvsig.raster.wcs"
38
PATHS_FORMATS="org.gvsig.raster.ermapper org.gvsig.raster.lizardtech org.gvsig.raster.netcdf org.gvsig.raster.postgis"
39
# org.gvsig.raster.mosaic"
40

  
41
PATHS=$PATHS_BASE;
42

  
43
if [ "$2" = "-remote" ] ; then
44
   PATHS=$PATHS" "$PATHS_REMOTE;
45
fi
46

  
47
if [ "$2" = "-formats" ] ; then
48
   PATHS=$PATHS" "$PATHS_FORMATS;
49
fi
50

  
51
if [ "$2" = "-all" ] ; then
52
   PATHS=$PATHS" "$PATHS_FORMATS" "$PATHS_REMOTE;
53
fi
54

  
55
echo "***********************************"
56
echo "Command: mvn "$1
57
echo "Projects: "$PATHS
58
echo "***********************************"
59

  
60

  
61
for i in $PATHS 
62
do
63
 #echo "$i"
64
 cd $i
65

  
66
 if  [ "$1" = "-create-installer" ] ; then
67
	mvn $PARAMS_CREATE_INSTALLER;
68
 else
69
  if  [ "$1" = "-install" ] ; then
70
	mvn $PARAMS_INSTALL;
71
  else
72
    if  [ "$1" = "-eclipse" ] ; then
73
      mvn $PARAMS_ECLIPSE;
74
    else
75
      if  [ "$1" = "-deploy" ] ; then
76
	 mvn $PARAMS_DEPLOY;
77
      else
78
        if  [ "$1" = "-clean" ] ; then
79
	  mvn $PARAMS_CLEAN;
80
        else
81
          if  [ "$1" = "-eclipseclean" ] ; then
82
	    mvn $PARAMS_ECLIPSECLEAN;
83
          fi
84
        fi
85
      fi
86
    fi
87
  fi
88
fi
89

  
90
 cd ..
91
done
92

  
93

  
0 94

  
org.gvsig.raster/tags/buildNumber_29/org.gvsig.raster/package.sh
1
#/bin/sh
2

  
3
if [ "$1" = "--help" ] ; then
4
   echo "Usage: First parameter:"
5
   echo "          -update"
6
   echo "          -install"
7
   echo "          -package: crear paquetes"
8
   echo "          -upload: subir al repositorio"
9
   echo "          -tags: crear tags buildNumber_VERSION"
10
   echo "          -commit: subir build number"
11
   echo "          -ticket: crear fichero de texto con las URLS de los índices para el ticket" 
12
   echo "Para hacer nuevo empaquetado"
13
   echo "   1-Comprobar variables VERSION, FIX_VERSION, RELEASE, PACKAGE_DIRECTORY, URL, URL_TAGS, USER y PASS. Ojo! Si el directorio para el plugin no está creado en pool dará un error"
14
   echo "   2-Si se ha metido algún paquete nuevo actualizar la variable PROJECT y PLUGINS o ARCH_DEP_PLUGIN si fuera necesario"
15
   echo "   3-Ejecutar ./package.sh -update para actualizar los proyectos"
16
   echo "   4-Ejecutar ./package.sh -install para limpiar e instalar los proyectos"
17
   echo "   5-Ejecutar ./package.sh -package para empaquetar en PACKAGE_DIRECTORY"
18
   echo "   6-Ejecutar ./package.sh -upload para subir a URL"
19
   echo "   7-Ejecutar ./package.sh -commit para subir los buildnumber"
20
   echo "   8-Ejecutar ./package.sh -tags para crear tags en URL_TAGS"
21
   echo "   9-Ejecutar ./package.sh -ticket para generar el fichero con las urls de los índices"
22
   echo "Para revertir cambios del SVN ./package.sh -revert"
23
   exit
24
fi
25

  
26
VERSION=2.0.0
27
FIX_VERSION=SNAPSHOT
28
RELEASE=devel
29
URL=https://devel.gvsig.org/download/projects/Raster/pool/
30
URL_TAGS=https://devel.gvsig.org/svn/gvsig-raster/
31
PACKAGE_DIRECTORY=/home/nacho/Workspaces/gvsig-2.0/build/product/install/pool
32
PATH_TICKET=/tmp/ticket.txt
33
USER=nbrodin
34
PASS=
35

  
36
PLATFORM="linux"
37
COMPILER="gcc4"
38
ARCH="i386"
39
DISTRIBUTION="all"
40
TYPE="dynamic"
41

  
42
PLATFORM_B="win"
43
COMPILER_B="vs8"
44
DISTRIBUTION_B="nt"
45

  
46
#pool packages
47
MAIN_PACKAGE=0 #Posición 1 obligatoria tilecache en ARCH_DEP_PLUGINS
48

  
49
#Plugin list
50
PLUGINS="org.gvsig.raster.gdal/org.gvsig.raster.gdal.app 
51
org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic 
52
org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.multifile
53
org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.reproject
54
org.gvsig.raster.wmts/org.gvsig.raster.wmts.app/org.gvsig.raster.wmts.app.wmtsclient 
55
org.gvsig.raster.wms/org.gvsig.raster.wms.app/org.gvsig.raster.wms.app.wmsclient 
56
org.gvsig.raster.wcs/org.gvsig.raster.wcs.app/org.gvsig.raster.wcs.app.wcsclient 
57
org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.app/org.gvsig.raster.netcdf.app.netcdfclient 
58
org.gvsig.raster.postgis/org.gvsig.raster.postgis.app/org.gvsig.raster.postgis.app.postgisrasterclient"
59

  
60
ARCH_DEP_PLUGINS="org.gvsig.raster.tilecache/org.gvsig.raster.tilecache.app
61
org.gvsig.raster.ermapper/org.gvsig.raster.ermapper.app
62
org.gvsig.raster.lizardtech/org.gvsig.raster.lizardtech.app"
63
 
64
#eclipse projects
65
PROJECTS="org.gvsig.raster.cache 
66
org.gvsig.raster 
67
org.gvsig.raster.gdal 
68
org.gvsig.raster.tilecache 
69
org.gvsig.raster.tools 
70
org.gvsig.raster.wmts 
71
org.gvsig.raster.wms 
72
org.gvsig.raster.wcs 
73
org.gvsig.raster.ermapper 
74
org.gvsig.raster.lizardtech 
75
org.gvsig.raster.netcdf 
76
org.gvsig.raster.postgis"
77

  
78

  
79
CLASSIFIER=$PLATFORM"-"$DISTRIBUTION"-"$COMPILER"-"$ARCH"-"$TYPE
80

  
81
COMMAND_PARAMS="install -P create-installer -Dnative-platform="$PLATFORM" -Dnative-compiler="$COMPILER" -Dnative-arch="$ARCH" -Dnative-distribution="$DISTRIBUTION" -Dlibrary-type="$TYPE" -Dnative-classifier="$CLASSIFIER" -Pinstall-extensions -Dmaven.test.skip"
82

  
83
#-------------------------------------------------
84
#Gets the number of the version
85
#$1: Project name
86
#-------------------------------------------------
87
getVersionProject( ) {
88
  c=-1;
89
  for i in $PLUGINS
90
    do
91
      let "c=c+1";
92
      AUX=`echo $i | grep "$1\/"`; 
93
      if [ "$AUX" != "" ]; then
94
        echo ${VER[c]}
95
        return;
96
      fi
97
    done
98
  c=-1;
99
  for i in $ARCH_DEP_PLUGINS
100
    do
101
      let "c=c+1";
102
      AUX=`echo $i | grep "$1\/"`; 
103
      if [ "$AUX" != "" ]; then
104
        echo ${VER_ARCH_DEP[c]}
105
        return;
106
      fi
107
    done
108
  echo ${VER_ARCH_DEP[MAIN_PACKAGE]}
109
}
110

  
111
#-------------------------------------------------
112
#Loads the array of versions
113
#Be careful. It has to be called after package generation
114
#-------------------------------------------------
115
loadVersion() {
116
  cont=0;
117
  CURRENT_DIR=`pwd`
118
  for i in $PLUGINS
119
   do
120
     if [ -d $i ]; then
121
       cd $i
122
       if [ -f buildNumber.properties ]; then
123
         VER[cont]=`cat buildNumber.properties | grep "buildNumber=" | cut -d'=' -f2`
124
	 #echo "===>>>>$i---->${VER[cont]}"
125
         let "cont=cont+1"; 
126
       fi
127
     fi
128
     cd $CURRENT_DIR
129
   done
130

  
131
  cont=0;
132
  for i in $ARCH_DEP_PLUGINS
133
   do
134
     if [ -d $i ]; then
135
       cd $i
136
       if [ -f buildNumber.properties ]; then
137
         VER_ARCH_DEP[cont]=`cat buildNumber.properties | grep "buildNumber=" | cut -d'=' -f2`
138
	 #echo "===>>>*$i---->${VER_ARCH_DEP[cont]}"
139
         let "cont=cont+1"; 
140
       fi
141
     fi
142
     cd $CURRENT_DIR
143
   done
144
}
145

  
146

  
147
#-------------------------------------------------
148
if [ "$1" = "-update" ] ; then
149
 for i in $PROJECTS
150
    do
151
      cd $i
152
      echo "-----------------"
153
      echo "Cambiando a"....$i
154
      echo "Ejecutando svn update "
155
      svn update;
156
      cd ..
157
    done
158
fi
159

  
160

  
161
#-------------------------------------------------
162
if [ "$1" = "-commit" ] ; then
163
 for i in $PROJECTS
164
    do
165
      cd $i
166
      echo "-----------------"
167
      echo "Cambiando a"....$i
168
      echo "Ejecutando svn commit "
169
      svn commit * -m "new build number $PVERSION";
170
      cd ..
171
    done
172
fi
173
#-------------------------------------------------
174

  
175
if [ "$1" = "-install" ] ; then
176

  
177
  
178
  echo "***********************************"
179
  echo "Clean and install"
180
  echo "***********************************"
181

  
182

  
183
  INSTALL_PARAMS="install -Dnative-platform="$PLATFORM" -Dnative-compiler="$COMPILER" -Dnative-arch="$ARCH" -Dnative-distribution="$DISTRIBUTION" -Dlibrary-type="$TYPE" -Dnative-classifier="$CLASSIFIER" -Dmaven.test.skip"
184

  
185
  for i in $PROJECTS
186
    do
187
      cd $i
188
      echo "-----------------"
189
      echo "Cambiando a"....$i
190
      echo "Ejecutando mvn "$COMMAND_PARAMS
191
      mvn clean
192
      mvn $INSTALL_PARAMS;
193
      cd ..
194
    done
195

  
196
fi
197

  
198
#-------------------------------------------------
199

  
200
#-------------------------------------------------
201
if [ "$1" = "-package" ] ; then
202

  
203

  
204
  echo "***********************************"
205
  echo "Generating Packages"
206
  echo "************i***********************"
207

  
208
  DIR_BASE=`pwd`
209

  
210
  for i in $PLUGINS
211
    do
212
      cd $i
213
      echo "-----------------"
214
      echo "Cambiando a"....$i
215
      echo "Ejecutando mvn "$COMMAND_PARAMS
216
      mvn $COMMAND_PARAMS;
217
      cd $DIR_BASE
218
    done
219

  
220
  CLASSIFIER_B=$PLATFORM_B"-"$DISTRIBUTION_B"-"$COMPILER_B"-"$ARCH"-"$TYPE
221

  
222
  COMMAND_PARAMS_PLATFORM_B="install -P create-installer -Dnative-platform="$PLATFORM_B" -Dnative-compiler="$COMPILER_B" -Dnative-arch="$ARCH" -Dnative-distribution="$DISTRIBUTION_B" -Dlibrary-type="$TYPE" -Dnative-classifier="$CLASSIFIER_B" -Pinstall-extensions -Dmaven.test.skip"
223

  
224
  for i in $ARCH_DEP_PLUGINS #Plugins architecture dependent
225
    do
226
      pad=`echo $i | cut -d/ -f1` #Projects architecture dependent
227
      cd $pad
228
      echo "-----------------"
229
      echo "Cambiando a"....$pad
230
      echo "Ejecutando mvn "$COMMAND_PARAMS
231
      mvn $COMMAND_PARAMS;
232
      svn revert --recursive .
233
      mvn $COMMAND_PARAMS_PLATFORM_B;
234
      cd $DIR_BASE
235
   done
236

  
237
fi
238

  
239

  
240
loadVersion
241

  
242
#-------------------------------------------------
243
#SOLO TEST
244
#-------------------------------------------------
245
if [ "$1" = "-revert" ] ; then
246
 for i in $PROJECTS
247
    do
248
      cd $i
249
      echo "-----------------"
250
      echo "Cambiando a"....$i
251
      echo "Ejecutando svn update "
252
      svn revert --recursive .
253
      cd ..
254
    done
255
fi
256

  
257
#-------------------------------------------------
258
#SOLO TEST
259
#-------------------------------------------------
260
if [ "$1" = "-ticket" ] ; then
261
 rm $PATH_TICKET 2> /dev/null
262
 cont=0;
263
 for i in $PLUGINS
264
    do
265
      package=`echo $i | cut -d/ -f3`
266
      if [ "$package" == "" ] ; then 
267
          package=`echo $i | cut -d/ -f2`
268
      fi
269
      echo "$URL$package/gvSIG-desktop-$VERSION-$package-$VERSION-$FIX_VERSION-${VER[$cont]}-$RELEASE-all-all-j1_5.gvspki" >> $PATH_TICKET
270
      echo "" >> $PATH_TICKET
271
      let "cont=cont+1";
272
    done
273
 cont=0;
274
 for i in $ARCH_DEP_PLUGINS
275
    do
276
      package=`echo $i | cut -d/ -f3`
277
      if [ "$package" == "" ] ; then 
278
          package=`echo $i | cut -d/ -f2`
279
      fi
280
      echo "$URL$package/gvSIG-desktop-$VERSION-$package-$VERSION-$FIX_VERSION-${VER_ARCH_DEP[$cont]}-$RELEASE-lin-x86-j1_5.gvspki" >> $PATH_TICKET
281
      echo "" >> $PATH_TICKET
282
      echo "$URL$package/gvSIG-desktop-$VERSION-$package-$VERSION-$FIX_VERSION-${VER_ARCH_DEP[$cont]}-$RELEASE-win-x86-j1_5.gvspki" >> $PATH_TICKET
283
      echo "" >> $PATH_TICKET
284
      let "cont=cont+1";
285
    done
286
  echo "Creado fichero de URLs en "$PATH_TICKET
287
fi
288

  
289
#-------------------------------------------------
290
if [ "$1" = "-tags" ] ; then
291

  
292
 echo "***********************************"
293
 echo "Creating tags"
294
 echo "***********************************"
295

  
296

  
297
 for i in $PROJECTS
298
   do
299
     PVERSION=`getVersionProject $i`
300
     #echo "svn copy $URL_TAGS$i/trunk $URL_TAGS$i/tags/buildNumber_$PVERSION -m \"Tag build $PVERSION\""
301
     svn copy $URL_TAGS$i/trunk $URL_TAGS$i/tags/buildNumber_$PVERSION -m "Tag build $PVERSION"
302
   done 
303
fi 
304

  
305

  
306

  
307
#-------------------------------------------------
308
if [ "$1" != "-upload" ] ; then
309
  exit
310
fi  
311

  
312
echo "***********************************"
313
echo "Uploading"
314
echo "***********************************"
315

  
316
CURRENT_DIRECTORY=`pwd`;
317
echo "Cambiando a..."$PACKAGE_DIRECTORY
318
cd $PACKAGE_DIRECTORY
319

  
320
cont=0;
321
for i in $PLUGINS
322
do
323
package=`echo $i | cut -d/ -f3`
324
if [ "$package" == "" ] ; then 
325
package=`echo $i | cut -d/ -f2`
326
fi
327
/usr/bin/expect <<EOD
328
spawn cadaver $URL
329
expect (y/n)
330
send y\r
331
expect dav:/download/projects/Raster/pool/>
332
send "cd $package\r"
333
expect $package/>
334
send "lcd $package\r"
335
expect $package/>
336
send "put gvSIG-desktop-$VERSION-$package-$VERSION-$FIX_VERSION-${VER[$cont]}-$RELEASE-all-all-j1_5.gvspkg\r"
337
expect "Nombre de usuario:"
338
send $USER\r
339
expect "Contraseña:"
340
send $PASS\r
341
expect $package/>
342
send "put gvSIG-desktop-$VERSION-$package-$VERSION-$FIX_VERSION-${VER[$cont]}-$RELEASE-all-all-j1_5.gvspki\r"
343
expect $package/>
344
send quit\r
345
expect "cerrada."
346
EOD
347
let "cont=cont+1";
348
done
349

  
350

  
351
cont=0;
352
for i in $ARCH_DEP_PLUGINS
353
do
354
pckgad=`echo $i | cut -d/ -f2` #Packages architecture dependent
355
/usr/bin/expect <<EOD
356
spawn cadaver $URL
357
expect (y/n)
358
send y\r
359
expect dav:/download/projects/Raster/pool/>
360
send "cd $pckgad\r"
361
expect $pckgad/>
362
send "lcd $pckgad\r"
363
expect $pckgad/>
364
send "put gvSIG-desktop-$VERSION-$pckgad-$VERSION-$FIX_VERSION-${VER_ARCH_DEP[$cont]}-$RELEASE-lin-x86-j1_5.gvspkg\r"
365
expect "Nombre de usuario:"
366
send $USER\r
367
expect "Contraseña:"
368
send $PASS\r
369
expect $pckgad/>
370
send "put gvSIG-desktop-$VERSION-$pckgad-$VERSION-$FIX_VERSION-${VER_ARCH_DEP[$cont]}-$RELEASE-lin-x86-j1_5.gvspki\r"
371
expect $pckgad/>
372
send "put gvSIG-desktop-$VERSION-$pckgad-$VERSION-$FIX_VERSION-${VER_ARCH_DEP[$cont]}-$RELEASE-win-x86-j1_5.gvspkg\r"
373
expect $pckgad/>
374
send "put gvSIG-desktop-$VERSION-$pckgad-$VERSION-$FIX_VERSION-${VER_ARCH_DEP[$cont]}-$RELEASE-win-x86-j1_5.gvspki\r"
375
expect $pckgad/>
376
send quit\r
377
expect "cerrada."
378
EOD
379
let "cont=cont+1";
380
done
381

  
382
cd $CURRENT_DIRECTORY
0 383

  
org.gvsig.raster/tags/buildNumber_29/org.gvsig.raster/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 getComponentList() {
111
		ArrayList listComp = new ArrayList();
112
		for (int i = 0; i < this.getComponentCount(); i++) {
113
			if(getComponent(i) instanceof BasePanel) {
114
				ArrayList 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 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/buildNumber_29/org.gvsig.raster/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
public class CancelTaskImpl implements ICancellable {
33
	private boolean       cancel = false;
34
	private Cancellable   c      = null;
35
	
36
	public CancelTaskImpl() {
37
	}
38
	
39
	public CancelTaskImpl(Cancellable c) {
40
		this.c = c;
41
	}
42
	
43
	/*
44
	 * (non-Javadoc)
45
	 * @see org.gvsig.compat.net.ICancellable#getID()
46
	 */
47
	public Object getID() {
48
		return this;
49
	}
50

  
51
	/*
52
	 * (non-Javadoc)
53
	 * @see org.gvsig.compat.net.ICancellable#isCanceled()
54
	 */
55
	public boolean isCanceled() {
56
		if(c != null)
57
			return c.isCanceled();
58
		return cancel;
59
	}
60
	
61
	/**
62
	 * Cancel the task
63
	 * @param cancel
64
	 */
65
	public void setCanceled(boolean cancel) {
66
		if(c != null)
67
			c.setCanceled(cancel);
68
		this.cancel = cancel;
69
	}
70
}
0 71

  
org.gvsig.raster/tags/buildNumber_29/org.gvsig.raster/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

  
26
import org.gvsig.fmap.dal.coverage.grid.RasterFilter;
27
import org.gvsig.fmap.dal.coverage.grid.render.Render;
28
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
29
import org.gvsig.raster.fmap.layers.FLyrRaster;
30
import org.gvsig.raster.fmap.layers.IRasterLayerActions;
31

  
32
/**
33
 * Clase para almacenar estados visuales de una capa raster. Estos estados deben ser locales
34
 * a cada funcionalidad para que no interfieran entre ellos. Luego es posible tener una lista de
35
 * estados globales para restaurar el que nos convenga.
36
 * 07/10/2008
37
 * @author Nacho Brodin nachobrodin@gmail.com
38
 */
39
public class LayerVisualStatusList {
40
	private ArrayList<LayerVisualStatus> list = new ArrayList<LayerVisualStatus>();
41
	
42
	/**
43
	 * Clase que contiene el estado visual de una capa raster.
44
	 * 07/10/2008
45
	 * @author Nacho Brodin nachobrodin@gmail.com
46
	 */
47
	public class LayerVisualStatus {
48
		private ArrayList<RasterFilter>    filterStatus = null;
49
		private Transparency               transparency = null;
50
		
51
		/**
52
		 * Obtiene el estado de la lista de filtros
53
		 * @return Array con el estado de la lista de filtros
54
		 */
55
		public ArrayList<RasterFilter> getFilterStatus() {
56
			return filterStatus;
57
		}
58
		
59
		/**
60
		 * Asigna el estado de la lista de filtros
61
		 * @return Array con el estado de la lista de filtros
62
		 */
63
		public void setFilterStatus(ArrayList<RasterFilter> filterStatus) {
64
			this.filterStatus = filterStatus;
65
		}
66
		
67
		/**
68
		 * Obtiene el estado de la transparencia
69
		 * @return Transparency
70
		 */
71
		public Transparency getTransparency() {
72
			return transparency;
73
		}
74
		
75
		/**
76
		 * Asigna el estado de la transparencia
77
		 * @param Transparency
78
		 */
79
		public void setTransparency(Transparency transparency) {
80
			this.transparency = transparency;
81
		}
82
	}
83
	
84
	/**
85
	 * Limpia la pila de elementos
86
	 */
87
	public void clear() {
88
		list.clear();
89
	}
90
	
91
	/**
92
	 * Salva un estado al final de la lista
93
	 * @param status 
94
	 */
95
	public void add(LayerVisualStatus status) {
96
		list.add(status);
97
	}
98
	
99
	/**
100
	 * Recupera el ?ltimo estado introducido en la lista
101
	 * @return StatusLayer
102
	 */
103
	public LayerVisualStatus getLast() {
104
		return (LayerVisualStatus)list.get(list.size() - 1);
105
	}
106
	
107
	/**
108
	 * Recupera el estado de la posici?n i
109
	 * @return StatusLayer
110
	 */
111
	public LayerVisualStatus get(int i) {
112
		return (LayerVisualStatus)list.get(i);
113
	}
114
		
115
	
116
	/**
117
	 * Saca de la lista el ?ltimo estado y lo asigna a la capa indicada.
118
	 * @param lyr Capa raster
119
	 */
120
	public void restoreVisualStatus(FLyrRaster lyr) {
121
		Render rendering = lyr.getRender();
122
		LayerVisualStatus status = getLast();
123
		if(status != null) {
124
			if(rendering.getFilterList() != null)
125
				rendering.getFilterList().setStatus(status.filterStatus);
126
			lyr.getRender().setLastTransparency(status.transparency);
127
			if(((IRasterLayerActions)lyr).isActionEnabled(IRasterLayerActions.REMOTE_ACTIONS))
128
				lyr.getRender().getFilterList().setStatus(status.filterStatus);
129
		}
130
	}
131
	
132
	/**
133
	 * Obtiene de la capa su estado de visualizaci?n y lo salva en la lista
134
	 * @param lyr Capa raster
135
	 */
136
	public void getVisualStatus(FLyrRaster lyr) {
137
		LayerVisualStatus status = new LayerVisualStatus();
138
		status.transparency = lyr.getRender().getLastTransparency();
139
		status.filterStatus = lyr.getRender().getFilterList().getStatusCloned();
140
		add(status);
141
	}
142
}
0 143

  
org.gvsig.raster/tags/buildNumber_29/org.gvsig.raster/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
}
0 38

  
org.gvsig.raster/tags/buildNumber_29/org.gvsig.raster/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/buildNumber_29/org.gvsig.raster/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 extensions = new ArrayList();
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 getExtensions(){
193
		return extensions;
194
	}
195
}
0 196

  
org.gvsig.raster/tags/buildNumber_29/org.gvsig.raster/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/buildNumber_29/org.gvsig.raster/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/buildNumber_29/org.gvsig.raster/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;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff