Revision 17535

View differences:

tags/tmp_build/examples/exaExampleCenterViewToPoint/theme/andami-theme.xml
1
<AndamiProperties>
2
	<ApplicationImages>
3
		<SplashImages>
4
			<Splash path="gvSIG/extensiones/com.iver.gvsig.centerviewpoint/theme/logo_es.png" timer="1000"/>
5
			<Splash path="gvSIG/extensiones/com.iver.gvsig.centerviewpoint/theme/logo_personalizado.png" timer="100000"/>
6
		</SplashImages>
7
		<BackgroundImage path="gvSIG/extensiones/com.iver.gvsig.centerviewpoint/theme/logo_fondo_personalizado.png"/>
8
		<WallpaperType value="CENTERED"/>
9
		<Icon path="gvSIG/extensiones/com.iver.gvsig.centerviewpoint/theme/logoGVA.gif"/>
10
	</ApplicationImages>
11
	<ApplicationName value="gvSIG 1.0.2. Example center View to point"/>
12
</AndamiProperties>
0 13

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>exaExampleCenterViewToPoint</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>de.loskutov.FileSync.FSBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
	</buildSpec>
19
	<natures>
20
		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
21
		<nature>org.eclipse.jdt.core.javanature</nature>
22
		<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
23
	</natures>
24
</projectDescription>
0 25

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/about.htm
1
<html>
2
  <head>
3
    <title>Extesi&oacute;n de ejemplo.</title>
4
    <meta content="">
5
    <style></style>
6
  </head>
7
  <body>
8
<table width="60%" border="0">
9
  <tr>
10
    <td width="64%"><img src="images/logo_horiz_bicolor_gva.png" width="329" height="50"></td>
11
    <td width="36%"><div align="right"><img src="images/logoIver.png" width="87" height="50"></div></td>
12
  </tr>
13
  <tr>
14
    <td colspan="2"><font face="Arial, Helvetica, sans-serif">&copy; Copyright
15
      Generalitat Valenciana, IVER T.I. 2007.</font></td>
16
  </tr>
17
</table>
18
  <h3>Extensi&oacute;n de ejemplo:</h3>
19
   <p> - Opciones men&uacute;</p>
20
   <p> - Informaci&oacute;n ToolBar</p>
21
   <p> - Modificar preferencias</p>
22
   <p> - Opci&oacute;n en el men&uacute; contextual</p>
23
   <p> - Posibilidad de visualizar las extensiones elegidas</p>
24
   <p> - Personalizaci&oacute;n del Splash</p>
25
   <p> - InfoTool personalizado para nuestra capa</p>
26
   <p> - Ventana de About</p>
27
   <p> - Crear extensi&oacute;n sin los fuentes de gvSIG</p>
28

  
29
  <p><br><br><b> Build Number: #build.number#</b></p>
30
  </body>
31
</html>
0 32

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/text_en.properties
1
#Translations for language [en]
2
#Mon Feb 26 16:06:24 CET 2007
3
Centrar_la_Vista_sobre_un_punto=Center view to point
4
color_point=Color point
5
debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion=Select the layers you want to get information from
6
example_extension=Example extension
7
formato_de_numero_incorrecto=Incorrect number format
8
no_hay_ninguna_capa_seleccionada=No layer has been selected
9
this_is_a_window_example=This is a window example
10
Vista=View
0 11

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/text_gl.properties
1
#Translations for language [gl]
2
#Mon Feb 26 16:06:24 CET 2007
3
Centrar_la_Vista_sobre_un_punto=Centrar a vista sobre un punto
4
debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion=Debe seleccionar as capas das que desexe obter informaci\u00f3n
5
formato_de_numero_incorrecto=Formato de n\u00famero incorrecto.
6
no_hay_ninguna_capa_seleccionada=Non hai ningunha capa seleccionada
7
Vista=Vista
0 8

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<depends plugin-name="com.iver.cit.gvsig" />
4
	<libraries library-dir="lib"/>
5
    <resourceBundle name="text"/>
6
	<extensions>
7
		<extension class-name="org.gvsig.examples.example1.ExampleExtension"
8
			description="Extensi?n de ejemplo."
9
			active="true"
10
			priority="1">
11
		</extension>
12
		<extension class-name="org.gvsig.examples.example1.extension.CenterViewToPointExtension"
13
			description="Extensi?n que permite hacer zooms en funci?n de un par de coordenadas introducidas por el usuario."
14
			active="true"
15
			priority="2">
16
			<menu text="Vista/Centrar_la_Vista_sobre_un_punto" tooltip="Centrar_la_Vista_sobre_un_punto"
17
				action-command="CENTERVIEWTOPOINT"
18
				icon="images/centerviewtopoint.png" />
19
			<tool-bar name="com.iver.cit.gvsig.Herramientas">
20
				<action-tool icon="images/centerviewtopoint.png"
21
					action-command="CENTERVIEWTOPOINT" tooltip="Centrar_la_Vista_sobre_un_punto"
22
					enable-text="deber?a de estar activada" last="true"/>
23
			</tool-bar>
24
		</extension>
25
		<extension class-name="org.gvsig.examples.example1.extension.InfoToolExampleExtension"
26
			description="Extensi?n encargada de gestionar la herramienta de info y centrar el extent al punto."
27
			active="true"
28
			priority="29">
29
			<menu text="Vista/consulta/informacion" action-command="INFO" icon="images/Identify.png"/>
30
			<tool-bar name="View_Tools_Query" position="5">
31
				<selectable-tool icon="images/Identify.png" action-command="INFO"  tooltip="informacion" position="1"/>
32
			</tool-bar>
33
		</extension>
34
		<extension class-name="org.gvsig.examples.example1.extension.OpenCSVToPointsExtension"
35
			description="Extensi?n encargada de abrir una vista con una cpa de puntos de una fichero CSV."
36
			active="true"
37
			priority="30">
38
		</extension>
39
	</extensions>
40
</plugin-config>
0 41

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/text_cs.properties
1
#Translations for language [cs]
2
#Mon Feb 26 16:06:24 CET 2007
3
Centrar_la_Vista_sobre_un_punto=Centruj pohled na st\u0159ed
4
debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion=Ozna\u010dte vrstvy, ze kter\u00fdch chcete z\u00edskat informace
5
formato_de_numero_incorrecto=Neplatn\u00e9 \u010d\u00edslo form\u00e1tu
6
no_hay_ninguna_capa_seleccionada=Nebyla vybr\u00e1na \u017e\u00e1dn\u00e1 vrstva
7
Vista=Pohled
0 8

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/text_fr.properties
1
#Translations for language [fr]
2
#Mon Feb 26 16:06:24 CET 2007
3
Centrar_la_Vista_sobre_un_punto=Centrer la vue sur un point
4
debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion=Vous devez s\u00e9lectionner les couches pour lesquelles vous souhaitez obtenir des informations.
5
formato_de_numero_incorrecto=Format incorrect
6
no_hay_ninguna_capa_seleccionada=
7
Vista=Vue
0 8

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/text_eu.properties
1
#Translations for language [eu]
2
#Mon Feb 26 16:06:24 CET 2007
3
Centrar_la_Vista_sobre_un_punto=Zentratu bista puntu batekiko
4
debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion=Geruzak hautatu behar dituzu horien gaineko informazioa jasotzeko.
5
formato_de_numero_incorrecto=Zenbakiaren formatua okerra da
6
no_hay_ninguna_capa_seleccionada=
7
Vista=Bista
0 8

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/text_nl.properties
1
#Translations for language [nl]
2
#Mon Feb 26 16:06:24 CET 2007
3
Centrar_la_Vista_sobre_un_punto=
4
debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion=
5
formato_de_numero_incorrecto=
6
no_hay_ninguna_capa_seleccionada=
7
Vista=Kaartbeeld
0 8

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/text_pl.properties
1
#Translations for language [po]
2
#Mon Mar 12 10:04:20 CET 2007
3
Centrar_la_Vista_sobre_un_punto=Wycentruj w punkcie
4
debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion=Wybierz warstwy, z kt\u00f3rych chcesz pobra\u0107 informacje
5
formato_de_numero_incorrecto=Niew\u0142a\u015bciwy format liczbowy
6
no_hay_ninguna_capa_seleccionada=Nie wybrano warstwy
7
Vista=Widok
0 8

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/text_it.properties
1
#Translations for language [it]
2
#Mon Feb 26 16:06:24 CET 2007
3
Centrar_la_Vista_sobre_un_punto=Centra la visuale su un punto
4
debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion=Selezionare i layers di cui si desiderano informazioni.
5
formato_de_numero_incorrecto=Formato del numero errato.
6
no_hay_ninguna_capa_seleccionada=Nessun layer selezionato
7
Vista=Vista
0 8

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/text.properties
1
#Translations for language [es]
2
#Mon Feb 26 16:06:24 CET 2007
3
Centrar_la_Vista_sobre_un_punto=Centrar la vista sobre un punto
4
color_point=Color del punto
5
debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion=Debe seleccionar las capas de las que quiera obtener informaci\u00f3n.
6
example_extension=Extensi?n ejemplo
7
formato_de_numero_incorrecto=Formato de n\u00famero incorrecto.
8
no_hay_ninguna_capa_seleccionada=No hay ninguna capa seleccionada
9
this_is_a_window_example=Esto es una ventana de ejemplo
10
Vista=Vista
0 11

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/text_ro.properties
1
#Translations for language [ro]
2
#Thu Mar 01 10:01:15 CET 2007
3
Centrar_la_Vista_sobre_un_punto=Centrar atentia a un punct
4
debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion=Trebuie selectionate crpetele de la care dorim obtine informati
5
formato_de_numero_incorrecto=
6
no_hay_ninguna_capa_seleccionada=nu ai ninguna capeta selectionata
7
Vista=Vedere
0 8

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/text_zh.properties
1
#Translations for language [zh]
2
#Mon Feb 26 16:06:24 CET 2007
3
Centrar_la_Vista_sobre_un_punto=\u5411\u4e00\u70b9\u96c6\u4e2d
4
debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion=\u60a8\u5fc5\u987b\u9009\u5b9a\u60a8\u8981\u8bfb\u53d6\u4fe1\u606f\u7684\u56fe\u5c42
5
formato_de_numero_incorrecto=\u6570\u5b57\u683c\u5f0f\u65e0\u6548
6
no_hay_ninguna_capa_seleccionada=\u672a\u9009\u5b9a\u56fe\u5c42
7
Vista=\u89c6\u56fe
0 8

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/text_ca.properties
1
#Translations for language [ca]
2
#Mon Feb 26 16:06:24 CET 2007
3
Centrar_la_Vista_sobre_un_punto=Centrar la Vista sobre un punt
4
debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion=Ha de seleccionar les capes de les quals vol obtindre informaci\u00f3
5
formato_de_numero_incorrecto=Format de n\u00famero incorrecte
6
no_hay_ninguna_capa_seleccionada=No hi ha cap capa seleccionada
7
Vista=Vista
0 8

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/text_pt.properties
1
#Translations for language [pt]
2
#Mon Feb 26 16:06:24 CET 2007
3
Centrar_la_Vista_sobre_un_punto=
4
debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion=
5
formato_de_numero_incorrecto=
6
no_hay_ninguna_capa_seleccionada=
7
Vista=Vista
0 8

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/config/text_de.properties
1
#Translations for language [de]
2
#Mon Feb 26 16:06:24 CET 2007
3
Centrar_la_Vista_sobre_un_punto=
4
debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion=
5
formato_de_numero_incorrecto=
6
no_hay_ninguna_capa_seleccionada=
7
Vista=Ansicht
0 8

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/build.number
1
#Build Number for ANT. Do not edit!
2
#Thu Apr 19 17:16:38 CEST 2007
3
build.number=910
0 4

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/src/org/gvsig/examples/example1/extension/OpenCSVToPointsExtension.java
1
package org.gvsig.examples.example1.extension;
2

  
3
import com.hardcode.driverManager.DriverLoadException;
4
import com.hardcode.driverManager.DriverManager;
5
import com.hardcode.gdbms.engine.data.DataSource;
6
import com.hardcode.gdbms.engine.data.DataSourceFactory;
7
import com.hardcode.gdbms.engine.data.NoSuchTableException;
8
import com.hardcode.gdbms.engine.data.driver.DriverException;
9
import com.iver.andami.PluginServices;
10
import com.iver.andami.plugins.Extension;
11
import com.iver.cit.gvsig.ProjectExtension;
12
import com.iver.cit.gvsig.fmap.MapContext;
13
import com.iver.cit.gvsig.fmap.layers.FLayerGenericVectorial;
14
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
15
import com.iver.cit.gvsig.project.Project;
16
import com.iver.cit.gvsig.project.ProjectFactory;
17
import com.iver.cit.gvsig.project.documents.view.ProjectView;
18
import com.iver.cit.gvsig.project.documents.view.gui.View;
19
import com.iver.gvsig.addeventtheme.AddEventThemeDriver;
20
import com.iver.utiles.extensionPoints.ExtensionPoint;
21
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
22

  
23
public class OpenCSVToPointsExtension extends Extension{
24

  
25
	public void initialize() {
26
		// TODO Auto-generated method stub
27

  
28
	}
29

  
30
	public void postInitialize() {
31
		try {
32
			addCSVPointLayer();
33
		} catch (DriverLoadException e) {
34
			// TODO Auto-generated catch block
35
			e.printStackTrace();
36
		} catch (NoSuchTableException e) {
37
			// TODO Auto-generated catch block
38
			e.printStackTrace();
39
		} catch (DriverException e) {
40
			// TODO Auto-generated catch block
41
			e.printStackTrace();
42
		} catch (InstantiationException e) {
43
			// TODO Auto-generated catch block
44
			e.printStackTrace();
45
		} catch (IllegalAccessException e) {
46
			// TODO Auto-generated catch block
47
			e.printStackTrace();
48
		}
49

  
50
	}
51

  
52
	public void execute(String actionCommand) {
53
		// TODO Auto-generated method stub
54

  
55
	}
56

  
57
	public boolean isEnabled() {
58
		// TODO Auto-generated method stub
59
		return false;
60
	}
61

  
62
	public boolean isVisible() {
63
		// TODO Auto-generated method stub
64
		return false;
65
	}
66

  
67

  
68

  
69
	private void addCSVPointLayer() throws DriverLoadException, NoSuchTableException, DriverException, InstantiationException, IllegalAccessException{
70
//		  Funcion encargada de crear y cargar en la vista la capa
71
//		  de trabajo a partir del fichero csv
72

  
73
		ProjectView pv=ProjectFactory.createView("Ejemplo CSV to Points");
74
		View view=(View)pv.createWindow();
75
		ProjectExtension pe=(ProjectExtension)PluginServices.getExtension(ProjectExtension.class);
76
		Project project=pe.getProject();
77
		project.addDocument(pv);
78
		PluginServices.getMDIManager().addWindow(view);
79

  
80
//		   csv
81
		  DataSourceFactory dataSourceFactory=LayerFactory.getDataSourceFactory();
82
		  String fileName="C:/prueba.csv";
83
		  dataSourceFactory.addFileDataSource("csv string", "prueba",fileName);
84
		  DataSource ds = dataSourceFactory.createRandomDataSource("prueba");
85
		  ds.start();
86

  
87
//		   Crearemos el driver que gestiona la capa de eventos y lo enlazaremos con
88
//		   la fuente de datos que acabamos de crear indicandole que columnas de esta
89
//		   representan los puntos de la geomretria
90
		  int xFieldIndex = ds.getFieldIndexByName("X");
91
		  int yFieldIndex = ds.getFieldIndexByName("Y");
92
//		  DriverManager dm=new DriverManager();
93
		  AddEventThemeDriver driver=new AddEventThemeDriver();//(AddEventThemeDriver)dm.getDriver("csv string");
94
		  driver.setData(ds, xFieldIndex, yFieldIndex);
95

  
96
		  MapContext mapContext=view.getMapControl().getMapContext();
97

  
98
//		   Crearemos ahora la nueva capa basada en este driver
99
		  FLayerGenericVectorial layer = (FLayerGenericVectorial)(((ExtensionPoint)ExtensionPointsSingleton.getInstance().get("Layers")).create("com.iver.cit.gvsig.fmap.layers.FLayerGenericVectorial"));
100
		  layer.setName("prueba");
101
		  layer.setDriver(driver);
102
		  layer.setProjection(mapContext.getProjection());
103
	      mapContext.getLayers().addLayer(layer);
104

  
105

  
106

  
107
//          capa = LayerFactory.createLayer("ademuz", driver, mapContext.getProjection());
108
//	      capa.addLayerListener(new AddEventThemListener());
109
//	      mapContext.getLayers().addLayer(layer);
110
//		   Una vez creada la capa se le a?ade una propiedad para reconocerla
111
//		   como nuestra capa de trabajo
112
		  layer.setProperty("CapaDePruebaCSV","propiedad para distinguir la capa de prueba");
113

  
114
//		   Indicamos al mapContext que se debe repintar
115
		  mapContext.invalidate();
116
		  mapContext.redraw();
117
	}
118
}
0 119

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/src/org/gvsig/examples/example1/extension/InfoToolExampleExtension.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41

  
42
package org.gvsig.examples.example1.extension;
43

  
44
import org.gvsig.examples.example1.tool.InfoToolListener;
45

  
46
import com.iver.andami.PluginServices;
47
import com.iver.andami.ui.mdiManager.IWindow;
48
import com.iver.cit.gvsig.fmap.MapContext;
49
import com.iver.cit.gvsig.fmap.MapControl;
50
import com.iver.cit.gvsig.fmap.layers.FLayer;
51
import com.iver.cit.gvsig.fmap.layers.FLayerGenericVectorial;
52
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior;
53
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior;
54
import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior;
55
import com.iver.cit.gvsig.project.documents.view.gui.View;
56
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener;
57

  
58

  
59
/**
60
 * Class that extends of the tool InfoToolExtension and
61
 * override the methods that interests us to change its behavior.
62
 *
63
 * @author Vicente Caballero Navarro
64
 */
65
public class InfoToolExampleExtension
66
    extends com.iver.cit.gvsig.InfoToolExtension {
67

  
68
	/* (non-Javadoc)
69
	 * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
70
	 */
71
	public void execute(String s) {
72
        IWindow window = PluginServices.getMDIManager().getActiveWindow();
73

  
74
        if (window instanceof View) {
75
            MapControl mapCtrl = ((View) window).getMapControl();
76

  
77
            if (s.compareTo("INFO") == 0) {
78
                if (mapCtrl.getMapTool("centerviewtopoint") == null) {
79
                    StatusBarListener sbl = new StatusBarListener(mapCtrl);
80
                    InfoToolListener itl = new InfoToolListener(mapCtrl);
81
                    mapCtrl.addMapTool("centerviewtopoint",
82
                        new Behavior[] {
83
                            new PointBehavior(itl),
84
                            new MouseMovementBehavior(sbl)
85
                        });
86
                }
87
            }
88

  
89
//            FLayer[] layers=mapCtrl.getMapContext().getLayers().getActives();
90
//            if (layers[0] instanceof FLayerGenericVectorial){
91
//        		if (layers[0].getProperty("CapaDePruebaCSV")!=null)
92
        			if (s.compareTo("INFO") == 0) {
93
        				mapCtrl.setTool("centerviewtopoint");
94
        			}
95
//            } else {
96
//                super.execute(s);
97
//            }
98
        }
99
    }
100

  
101
    /* (non-Javadoc)
102
     * @see com.iver.andami.plugins.IExtension#initialize()
103
     */
104
    public void initialize() {
105
        super.initialize();
106
    }
107

  
108
    /* (non-Javadoc)
109
     * @see com.iver.andami.plugins.IExtension#isEnabled()
110
     */
111
    public boolean isEnabled() {
112
        return super.isEnabled();
113
    }
114

  
115
    /* (non-Javadoc)
116
     * @see com.iver.andami.plugins.IExtension#isVisible()
117
     */
118
    public boolean isVisible() {
119
        IWindow window = PluginServices.getMDIManager().getActiveWindow();
120

  
121
        if (window instanceof View) {
122
            MapContext mapContext = ((View) window).getMapControl()
123
                                     .getMapContext();
124
            FLayer[] layers=mapContext.getLayers().getActives();
125
            for (int i=0;i<layers.length;i++){
126
            	if (layers[i] instanceof FLayerGenericVectorial){
127
            		if (layers[i].getProperty("CapaDePruebaCSV")!=null)
128
            			return true;
129
            	}
130
            }
131
        }
132

  
133
        return super.isVisible();
134
    }
135
}
0 136

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/src/org/gvsig/examples/example1/extension/CenterViewToPointExtension.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41

  
42
package org.gvsig.examples.example1.extension;
43

  
44
import java.awt.Color;
45
import java.util.prefs.Preferences;
46

  
47
import org.gvsig.examples.example1.gui.InputCoordinatesPanel;
48

  
49
import com.iver.andami.PluginServices;
50
import com.iver.andami.plugins.Extension;
51
import com.iver.cit.gvsig.fmap.MapContext;
52
import com.iver.cit.gvsig.fmap.layers.FLayers;
53
import com.iver.cit.gvsig.project.documents.view.IProjectView;
54
import com.iver.cit.gvsig.project.documents.view.gui.View;
55
import com.iver.utiles.StringUtilities;
56

  
57
/**
58
 * The CenterViewToPointExtension class allows to center the View over a
59
 * concrete point given by its coordinates.
60
 *
61
 * @author Vicente Caballero Navarro
62
 */
63
public class CenterViewToPointExtension extends Extension{
64

  
65
	private View vista;
66
	public static Color COLOR=Color.red;
67
	private static Preferences prefs = Preferences.userRoot().node( "centerviewtopoint" );
68

  
69
    /* (non-Javadoc)
70
     * @see com.iver.andami.plugins.Extension#inicializar()
71
     */
72
    public void initialize() {
73
    	String colorString=prefs.get("colorcenterviewtopoint",StringUtilities.color2String(CenterViewToPointExtension.COLOR));
74
		Color color=StringUtilities.string2Color(colorString);
75
		CenterViewToPointExtension.COLOR=color;
76

  
77
    }
78

  
79
    /* (non-Javadoc)
80
     * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
81
     */
82
    public void execute(String actionCommand) {
83
		if ("CENTERVIEWTOPOINT".equals(actionCommand)){
84
			vista = (View)PluginServices.getMDIManager().getActiveWindow();
85
			InputCoordinatesPanel dataSelectionPanel = new InputCoordinatesPanel(vista);
86
			PluginServices.getMDIManager().addWindow(dataSelectionPanel);
87
		}
88
    }
89

  
90
    public View getView(){
91
    	return vista;
92
    }
93
    /* (non-Javadoc)
94
     * @see com.iver.andami.plugins.Extension#isEnabled()
95
     */
96
    public boolean isEnabled() {
97
		com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
98
		 .getActiveWindow();
99
		if (f == null) {
100
		    return false;
101
		}
102
		if (f.getClass() == View.class) {
103
		    View vista = (View) f;
104
		    IProjectView model = vista.getModel();
105
		    MapContext mapa = model.getMapContext();
106
		    FLayers layers = mapa.getLayers();
107
		    for (int i=0;i < layers.getLayersCount();i++) {
108
               if (layers.getLayer(i).isAvailable()) return true;
109
		    }
110
		}
111
		return false;
112

  
113
    }
114

  
115
    /* (non-Javadoc)
116
     * @see com.iver.andami.plugins.Extension#isVisible()
117
     */
118
    public boolean isVisible() {
119
		com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
120
		 .getActiveWindow();
121
		if (f == null) {
122
		    return false;
123
		}
124
		if (f.getClass() == View.class) {
125
		    View vista = (View) f;
126
		    IProjectView model = vista.getModel();
127
		    MapContext mapa = model.getMapContext();
128
            if (mapa.getLayers().getLayersCount() > 0) {
129
                return true;
130
            }
131
            return false;
132
        }
133
		return false;
134
	}
135

  
136
}
0 137

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/src/org/gvsig/examples/example1/tool/InfoToolListener.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42

  
43
package org.gvsig.examples.example1.tool;
44

  
45
import com.iver.andami.PluginServices;
46

  
47
import com.iver.cit.gvsig.fmap.MapControl;
48
import com.iver.cit.gvsig.fmap.layers.FLayer;
49
import com.iver.cit.gvsig.fmap.layers.FLayerGenericVectorial;
50
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
51
import com.iver.cit.gvsig.project.documents.view.toolListeners.InfoListener;
52

  
53

  
54
/**
55
 * Class that extends of the tool InfoToolListenerImpl and
56
 * override the methods that interests us to change its behavior.
57
 *
58
 * @author Vicente Caballero Navarro
59
 */
60
public class InfoToolListener extends InfoToolListenerImpl {
61

  
62
	public InfoToolListener(MapControl mapCtrl) {
63
        super(mapCtrl);
64

  
65
    }
66

  
67
    /* (non-Javadoc)
68
     * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
69
     */
70
    public void point(PointEvent event) {
71
    	super.point(event);
72
        PluginServices.getMainFrame().enableControls();
73
    }
74
}
0 75

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/src/org/gvsig/examples/example1/tool/InfoToolListenerImpl.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42

  
43
package org.gvsig.examples.example1.tool;
44

  
45
import com.iver.andami.PluginServices;
46
import com.iver.cit.gvsig.fmap.MapControl;
47
import com.iver.cit.gvsig.fmap.core.IGeometry;
48
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
49
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
50
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
51
import com.iver.cit.gvsig.fmap.layers.FLayer;
52
import com.iver.cit.gvsig.fmap.layers.FLayerGenericVectorial;
53
import com.iver.cit.gvsig.fmap.layers.GraphicLayer;
54
import com.iver.cit.gvsig.fmap.rendering.FGraphic;
55
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
56
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
57
import com.iver.cit.gvsig.fmap.tools.Listeners.PointListener;
58
import com.iver.cit.gvsig.project.documents.view.toolListeners.InfoListener;
59

  
60
import org.gvsig.examples.example1.extension.CenterViewToPointExtension;
61
import org.gvsig.examples.example1.tool.gui.InfoWindowExample;
62

  
63
import java.awt.Cursor;
64
import java.awt.Image;
65
import java.awt.Point;
66
import java.awt.Toolkit;
67
import java.awt.geom.Point2D;
68
import java.awt.geom.Rectangle2D;
69

  
70
import javax.swing.ImageIcon;
71

  
72

  
73
/**
74
 * Implementation of the interface PointListener as tool
75
 * of information and center the extent to that point.
76
 *
77
 * @author Vicente Caballero Navarro
78
 */
79
public class InfoToolListenerImpl implements PointListener {
80
    private final Image icentertopoint = new ImageIcon(MapControl.class.getResource(
81
                "images/InfoCursor.gif")).getImage();
82
    private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(icentertopoint,
83
            new Point(16, 16), "");
84
    private MapControl mapControl;
85
    private InfoListener infoListener;
86
    /**
87
     * Create a new InfoToolListenerImpl.
88
     *
89
     * @param mapControl MapControl.
90
     */
91
    public InfoToolListenerImpl(MapControl mapControl) {
92
        this.mapControl = mapControl;
93
        infoListener=new InfoListener(mapControl);
94
    }
95

  
96
    /* (non-Javadoc)
97
     * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
98
     */
99
    public void point(PointEvent event) {
100
    	 FLayer[] layers=mapControl.getMapContext().getLayers().getActives();
101
         if (layers[0] instanceof FLayerGenericVectorial){
102
     		if (layers[0].getProperty("CapaDePruebaCSV")!=null){
103
     			Point2D centerPoint = mapControl.getViewPort().toMapPoint(event.getPoint());
104
     	        zoomToCoordinates(centerPoint);
105
     	        drawPoint(centerPoint);
106
     	        InfoWindowExample iwe=new InfoWindowExample();
107
     	        PluginServices.getMDIManager().addWindow(iwe);
108
     		}
109
     	 } else {
110
             try {
111
				infoListener.point(event);
112
			} catch (BehaviorException e) {
113
				e.printStackTrace();
114
			}
115
         }
116

  
117
    }
118

  
119
    private void drawPoint(Point2D center) {
120
        GraphicLayer lyr = mapControl.getMapContext().getGraphicsLayer();
121
        lyr.clearAllGraphics();
122

  
123
        FSymbol theSymbol = new FSymbol(FConstant.SYMBOL_TYPE_POINT,
124
                CenterViewToPointExtension.COLOR);
125
        int idSymbol = lyr.addSymbol(theSymbol);
126
        IGeometry geom = ShapeFactory.createPoint2D(center.getX(), center.getY());
127
        FGraphic theGraphic = new FGraphic(geom, idSymbol);
128
        lyr.addGraphic(theGraphic);
129
        mapControl.drawGraphics();
130
        mapControl.drawMap(false);
131
    }
132

  
133
    private void zoomToCoordinates(Point2D center) {
134
        Rectangle2D oldExtent = mapControl.getViewPort().getAdjustedExtent();
135
        double oldCenterX = oldExtent.getCenterX();
136
        double oldCenterY = oldExtent.getCenterY();
137
        double movX = center.getX() - oldCenterX;
138
        double movY = center.getY() - oldCenterY;
139
        double upperLeftCornerX = oldExtent.getMinX() + movX;
140
        double upperLeftCornerY = oldExtent.getMinY() + movY;
141
        double width = oldExtent.getWidth();
142
        double height = oldExtent.getHeight();
143
        Rectangle2D extent = new Rectangle2D.Double(upperLeftCornerX,
144
                upperLeftCornerY, width, height);
145
        mapControl.getViewPort().setExtent(extent);
146
        mapControl.getMapContext().clearAllCachingImageDrawnLayers();
147
    }
148

  
149
    /* (non-Javadoc)
150
     * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
151
     */
152
    public Cursor getCursor() {
153
        return cur;
154
    }
155

  
156
    /* (non-Javadoc)
157
     * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
158
     */
159
    public boolean cancelDrawing() {
160
        return true;
161
    }
162

  
163
    /* (non-Javadoc)
164
     * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#pointDoubleClick(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
165
     */
166
    public void pointDoubleClick(PointEvent event) {
167
    }
168
}
0 169

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/src/org/gvsig/examples/example1/tool/gui/InfoWindowExample.java
1
package org.gvsig.examples.example1.tool.gui;
2

  
3
import java.awt.event.ActionListener;
4

  
5
import javax.swing.JPanel;
6

  
7
import com.iver.andami.PluginServices;
8
import com.iver.andami.ui.mdiManager.IWindow;
9
import com.iver.andami.ui.mdiManager.WindowInfo;
10
import javax.swing.JLabel;
11

  
12
import org.gvsig.gui.beans.AcceptCancelPanel;
13

  
14
public class InfoWindowExample extends JPanel implements IWindow{
15

  
16
	private JLabel jLabel = null;
17
	private AcceptCancelPanel accept;
18

  
19
	/**
20
	 * This method initializes
21
	 *
22
	 */
23
	public InfoWindowExample() {
24
		super();
25
		initialize();
26
	}
27

  
28
	/**
29
	 * This method initializes this
30
	 *
31
	 */
32
	private void initialize() {
33
        jLabel = new JLabel();
34
        jLabel.setText(PluginServices.getText(this,"this_is_a_window_example"));
35
        this.setSize(new java.awt.Dimension(380,78));
36

  
37
        this.add(jLabel, null);
38
        this.add(getAcceptCancelPanel(), null);
39
	}
40

  
41
	public WindowInfo getWindowInfo() {
42
		WindowInfo wi=new WindowInfo(WindowInfo.MODALDIALOG);
43
		return wi;
44
	}
45
	private AcceptCancelPanel getAcceptCancelPanel() {
46
		if (accept == null) {
47
			ActionListener okAction, cancelAction;
48
			okAction = new java.awt.event.ActionListener() {
49
				public void actionPerformed(java.awt.event.ActionEvent e) {
50
					PluginServices.getMDIManager().closeWindow(
51
							InfoWindowExample.this);
52
				}
53
			};
54
			cancelAction = new java.awt.event.ActionListener() {
55
				public void actionPerformed(java.awt.event.ActionEvent e) {
56
					PluginServices.getMDIManager().closeWindow(
57
							InfoWindowExample.this);
58
				}
59
			};
60
			accept = new AcceptCancelPanel(okAction, cancelAction);
61
			accept.setPreferredSize(new java.awt.Dimension(300, 300));
62
			// accept.setBounds(new java.awt.Rectangle(243,387,160,28));
63
			accept.setEnabled(true);
64
			accept.setVisible(true);
65
		}
66
		return accept;
67
	}
68

  
69
}  //  @jve:decl-index=0:visual-constraint="10,10"
0 70

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/src/org/gvsig/examples/example1/preferences/CenterViewToPointPage.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41

  
42
package org.gvsig.examples.example1.preferences;
43

  
44
import com.iver.andami.PluginServices;
45
import com.iver.andami.preferences.AbstractPreferencePage;
46
import com.iver.andami.preferences.StoreException;
47

  
48
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
49

  
50
import com.iver.utiles.StringUtilities;
51

  
52
import org.gvsig.examples.example1.extension.CenterViewToPointExtension;
53

  
54
import java.awt.Color;
55

  
56
import java.util.prefs.Preferences;
57

  
58
import javax.swing.ImageIcon;
59
import javax.swing.JPanel;
60

  
61

  
62
/**
63
 * References page of center view to point options.
64
 *
65
 * @author Vicente Caballero Navarro
66
 */
67
public class CenterViewToPointPage extends AbstractPreferencePage {
68
    private static Preferences prefs = Preferences.userRoot().node("centerviewtopoint");
69
    private ColorChooserPanel colorPoint;
70
    private ImageIcon icon;
71

  
72
    public CenterViewToPointPage() {
73
        super();
74
        icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/CenterView.png"));
75
        addComponent(PluginServices.getText(this, "color_point") + ":",
76
            colorPoint = new ColorChooserPanel());
77
    }
78

  
79
    /* (non-Javadoc)
80
     * @see com.iver.andami.preferences.IPreference#initializeValues()
81
     */
82
    public void initializeValues() {
83
        String colorString = prefs.get("colorcenterviewtopoint",
84
                StringUtilities.color2String(CenterViewToPointExtension.COLOR));
85
        Color color = StringUtilities.string2Color(colorString);
86
        CenterViewToPointExtension.COLOR = color;
87
        colorPoint.setColor(color);
88
        colorPoint.setAlpha(255);
89
    }
90

  
91
    /* (non-Javadoc)
92
     * @see com.iver.andami.preferences.IPreference#getID()
93
     */
94
    public String getID() {
95
        return this.getClass().getName();
96
    }
97

  
98
    /* (non-Javadoc)
99
     * @see com.iver.andami.preferences.IPreference#getTitle()
100
     */
101
    public String getTitle() {
102
        return PluginServices.getText(this, "Centrar_la_Vista_sobre_un_punto");
103
    }
104

  
105
    /* (non-Javadoc)
106
     * @see com.iver.andami.preferences.IPreference#getPanel()
107
     */
108
    public JPanel getPanel() {
109
        return this;
110
    }
111

  
112
    /* (non-Javadoc)
113
     * @see com.iver.andami.preferences.AbstractPreferencePage#storeValues()
114
     */
115
    public void storeValues() throws StoreException {
116
        String colorString;
117
        colorString = StringUtilities.color2String(colorPoint.getColor());
118
        prefs.put("colorcenterviewtopoint", colorString);
119
        CenterViewToPointExtension.COLOR = colorPoint.getColor();
120
    }
121

  
122
    /* (non-Javadoc)
123
     * @see com.iver.andami.preferences.IPreference#initializeDefaults()
124
     */
125
    public void initializeDefaults() {
126
        colorPoint.setColor(CenterViewToPointExtension.COLOR);
127
    }
128

  
129
    /* (non-Javadoc)
130
     * @see com.iver.andami.preferences.IPreference#getIcon()
131
     */
132
    public ImageIcon getIcon() {
133
        return icon;
134
    }
135

  
136
    /* (non-Javadoc)
137
     * @see com.iver.andami.preferences.IPreference#isValueChanged()
138
     */
139
    public boolean isValueChanged() {
140
        return super.hasChanged();
141
    }
142

  
143
    /* (non-Javadoc)
144
     * @see com.iver.andami.preferences.AbstractPreferencePage#setChangesApplied()
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff