Revision 18871

View differences:

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/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/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/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/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()
145
     */
146
    public void setChangesApplied() {
147
        setChanged(false);
148
    }
149
}
0 150

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

  
46
import java.awt.Color;
47
import java.awt.Component;
48
import java.awt.event.ActionEvent;
49
import java.awt.event.ActionListener;
50
import java.awt.event.MouseEvent;
51
import java.awt.geom.Point2D;
52
import java.awt.geom.Rectangle2D;
53

  
54
import javax.swing.JDialog;
55
import javax.swing.JLabel;
56
import javax.swing.JOptionPane;
57
import javax.swing.JPanel;
58
import javax.swing.JTextField;
59

  
60
import org.cresques.cts.IProjection;
61
import org.gvsig.examples.example1.extension.CenterViewToPointExtension;
62
import org.gvsig.gui.beans.AcceptCancelPanel;
63

  
64
import com.iver.andami.PluginServices;
65
import com.iver.andami.ui.mdiManager.IWindow;
66
import com.iver.andami.ui.mdiManager.WindowInfo;
67
import com.iver.cit.gvsig.fmap.MapContext;
68
import com.iver.cit.gvsig.fmap.MapControl;
69
import com.iver.cit.gvsig.fmap.core.IGeometry;
70
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
71
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
72
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
73
import com.iver.cit.gvsig.fmap.layers.GraphicLayer;
74
import com.iver.cit.gvsig.fmap.rendering.FGraphic;
75
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
76
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
77
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
78
import com.iver.cit.gvsig.project.documents.view.gui.View;
79
import com.iver.cit.gvsig.project.documents.view.toolListeners.InfoListener;
80
import javax.swing.JButton;
81

  
82

  
83
/**
84
 * The InputCoordinatesPanel class creates a JPanel where the
85
 * user can input the coordinates of the point of reference
86
 * for center the View.
87
 *
88
 * @author jmorell
89
 */
90
public class InputCoordinatesPanel extends JPanel implements IWindow {
91
    private static final long serialVersionUID = 1L;
92
    private JLabel labelX = null;
93
    private JTextField textX = null;
94
    private JLabel labelY = null;
95
    private JTextField textY = null;
96
    private MapControl mapControl;
97
    private WindowInfo viewInfo = null;
98
    private String firstCoordinate;
99
    private String secondCoordinate;
100
    private Point2D center;
101
    private GraphicLayer lyr;
102
    private ColorChooserPanel colorPanel;
103
	private AcceptCancelPanel okCancelPanel = null;
104
	private JButton bRemovePoint = null;
105
	private View view=null;
106
	/**
107
     * This is the default constructor
108
     */
109
    public InputCoordinatesPanel(View view) {
110
        super();
111
        this.view=view;
112
        this.mapControl = view.getMapControl();
113
        lyr=mapControl.getMapContext().getGraphicsLayer();
114
        initializeCoordinates();
115
        initialize();
116
    }
117

  
118
    private void initializeCoordinates() {
119
        IProjection proj = mapControl.getProjection();
120
        String projName = proj.getAbrev();
121
        if (projName.equals("EPSG:23030") || projName.equals("EPSG:27492") || projName.equals("EPSG:42101") || projName.equals("EPSG:42304")) {
122
            firstCoordinate = "X";
123
            secondCoordinate = "Y";
124
        } else if (projName.equals("EPSG:4230") || projName.equals("EPSG:4326")) {
125
            firstCoordinate = "Lon";
126
            secondCoordinate = "Lat";
127
        } else {
128
            System.out.println("Proyecci?n: " + projName);
129
            System.out.println("Proyecci?n no soportada.");
130
        }
131
    }
132

  
133
    private void zoomToCoordinates() throws Exception {
134
       try{
135
    	Rectangle2D oldExtent = mapControl.getViewPort().getAdjustedExtent();
136
        double oldCenterX = oldExtent.getCenterX();
137
        double oldCenterY = oldExtent.getCenterY();
138
        double centerX = (new Double((String)textX.getText())).doubleValue();
139
        double centerY = (new Double((String)textY.getText())).doubleValue();
140
        center=new Point2D.Double(centerX,centerY);
141
        double movX = centerX-oldCenterX;
142
        double movY = centerY-oldCenterY;
143
        double upperLeftCornerX = oldExtent.getMinX()+movX;
144
        double upperLeftCornerY = oldExtent.getMinY()+movY;
145
        double width = oldExtent.getWidth();
146
        double height = oldExtent.getHeight();
147
        Rectangle2D extent = new Rectangle2D.Double(upperLeftCornerX, upperLeftCornerY, width, height);
148
        mapControl.getViewPort().setExtent(extent);
149
       }catch (NumberFormatException e) {
150
    	   throw new Exception();
151
       }
152

  
153
    }
154

  
155
    /**
156
     * This method initializes this
157
     *
158
     * @return void
159
     */
160
    private void initialize() {
161
        labelY = new JLabel();
162
        labelY.setBounds(10, 35, 28, 20);
163
        labelY.setText(secondCoordinate + ":");
164
        labelX = new JLabel();
165
        labelX.setBounds(10, 10, 28, 20);
166
        labelX.setText(firstCoordinate + ":");
167
        this.setLayout(null);
168
        this.setSize(307, 111);
169
        this.add(labelX, null);
170
        this.add(getTextX(), null);
171
        this.add(labelY, null);
172
        this.add(getTextY(), null);
173
        this.add(getColorPanel());
174
        this.add(getOkCancelPanel(), null);
175
        this.add(getBRemovePoint(), null);
176
    }
177

  
178
    /**
179
     * This method initializes textX
180
     *
181
     * @return javax.swing.JTextField
182
     */
183
    private JTextField getTextX() {
184
    	if (textX == null) {
185
    		textX = new JTextField();
186
    		textX.setBounds(40, 10, 260, 20);
187
    		textX.addActionListener(new java.awt.event.ActionListener() {
188
    			public void actionPerformed(java.awt.event.ActionEvent e) {
189
    				textX.transferFocus();
190
    			}
191
    		});
192
    	}
193
    	return textX;
194
    }
195

  
196
    /**
197
     * This method initializes textY
198
     *
199
     * @return javax.swing.JTextField
200
     */
201
    private JTextField getTextY() {
202
    	if (textY == null) {
203
    		textY = new JTextField();
204
    		textY.setBounds(40, 35, 260, 20);
205
    		textY.addActionListener(new java.awt.event.ActionListener() {
206
    			public void actionPerformed(java.awt.event.ActionEvent e) {
207
    				textY.transferFocus();
208
    			}
209
    		});
210
    	}
211
    	return textY;
212
    }
213

  
214
    /* (non-Javadoc)
215
     * @see com.iver.andami.ui.mdiManager.View#getViewInfo()
216
     */
217
    public WindowInfo getWindowInfo() {
218
        if (viewInfo == null) {
219
            viewInfo=new WindowInfo(WindowInfo.MODALDIALOG);
220
            viewInfo.setTitle(PluginServices.getText(this,"Centrar_la_Vista_sobre_un_punto"));
221
            viewInfo.setWidth(this.getWidth()+8);
222
            viewInfo.setHeight(this.getHeight());
223
        }
224
        return viewInfo;
225
    }
226
    private void openInfo(){
227
    	InfoListener infoListener=new InfoListener(mapControl);
228
    	MouseEvent e=new MouseEvent((Component)view,MouseEvent.BUTTON1,MouseEvent.ACTION_EVENT_MASK,MouseEvent.MOUSE_CLICKED,500,400,1,true);
229
    	Point2D centerPixels=mapControl.getViewPort().fromMapPoint(center.getX(),center.getY());
230
    	PointEvent pe=new PointEvent(centerPixels,e);
231
    	try {
232
			infoListener.point(pe);
233
		} catch (BehaviorException e1) {
234
			e1.printStackTrace();
235
		}
236
		if (mapControl.getMapContext().getLayers().getActives().length==0){
237
			JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"no_hay_ninguna_capa_seleccionada")+" \n"+
238
					PluginServices.getText(this,"debe_seleccionar_las_capas_de_las_que_quiera_obtener_informacion"));
239
		}
240
    }
241
    private void drawPoint(Color color){
242
    	CenterViewToPointExtension.COLOR=color;
243
    	lyr.clearAllGraphics();
244
    	FSymbol theSymbol = new FSymbol(FConstant.SYMBOL_TYPE_POINT,color);
245
        int idSymbol = lyr.addSymbol(theSymbol);
246
        IGeometry geom = ShapeFactory.createPoint2D(center.getX(),center.getY());
247
        FGraphic theGraphic = new FGraphic(geom, idSymbol);
248
        lyr.addGraphic(theGraphic);
249
        mapControl.drawGraphics();
250
	    mapControl.drawMap(false);
251

  
252
    }
253

  
254

  
255
	/**
256
	 * This method initializes jPanel
257
	 *
258
	 * @return javax.swing.JPanel
259
	 */
260
	private JPanel getColorPanel() {
261
		if (colorPanel==null){
262
		 	colorPanel=new ColorChooserPanel();
263
		 	colorPanel.setAlpha(250);
264
		 	colorPanel.setColor(CenterViewToPointExtension.COLOR);
265
		 	colorPanel.setBounds(new java.awt.Rectangle(40,59,123,24));
266
		}
267
		 	return colorPanel;
268
	}
269

  
270
	/**
271
	 * This method initializes okCancelPanel
272
	 *
273
	 * @return javax.swing.JPanel
274
	 */
275
	private AcceptCancelPanel getOkCancelPanel() {
276
		if (okCancelPanel == null) {
277
			ActionListener okAction, cancelAction;
278
			okAction = new java.awt.event.ActionListener() {
279
    			public void actionPerformed(java.awt.event.ActionEvent e) {
280
    				try{
281
    				zoomToCoordinates();
282
    				}catch (Exception e1) {
283
    					JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"formato_de_numero_incorrecto"));
284
    					return;
285
    				}
286
    				// y sale.
287
                    if (PluginServices.getMainFrame() == null)
288
                        ((JDialog) (getParent().getParent().getParent().getParent())).dispose();
289
                    else
290
                        PluginServices.getMDIManager().closeWindow(InputCoordinatesPanel.this);
291

  
292
                    openInfo();
293
                    drawPoint(((ColorChooserPanel)getColorPanel()).getColor());
294
    			}
295
    		};
296
    		cancelAction = new ActionListener() {
297
				public void actionPerformed(ActionEvent e) {
298
					closeThis();
299
				}
300
    		};
301
			okCancelPanel = new AcceptCancelPanel(okAction, cancelAction);
302
			okCancelPanel.setBounds(new java.awt.Rectangle(40, 88, 260, 30));
303
		}
304
		return okCancelPanel;
305
	}
306

  
307
	private void closeThis() {
308
		PluginServices.getMDIManager().closeWindow(this);
309

  
310
	}
311

  
312
	/**
313
	 * This method initializes bRemovePoint
314
	 *
315
	 * @return javax.swing.JButton
316
	 */
317
	private JButton getBRemovePoint() {
318
		if (bRemovePoint == null) {
319
			bRemovePoint = new JButton();
320
			bRemovePoint.setBounds(new java.awt.Rectangle(181,59,101,25));
321
			bRemovePoint.setText(PluginServices.getText(this,"remove"));
322
			bRemovePoint.addActionListener(new java.awt.event.ActionListener() {
323
				public void actionPerformed(java.awt.event.ActionEvent e) {
324
					lyr.clearAllGraphics();
325
					mapControl.drawMap(false);
326
				}
327
			});
328
		}
329
		return bRemovePoint;
330
	}
331

  
332

  
333
}  //  @jve:decl-index=0:visual-constraint="103,18"
0 334

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/src/org/gvsig/examples/example1/toc/PropertiesTocMenuEntry.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.toc;
44

  
45
import com.iver.andami.PluginServices;
46

  
47
import com.iver.cit.gvsig.fmap.layers.FLayer;
48
import com.iver.cit.gvsig.project.documents.view.gui.View;
49
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction;
50
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
51

  
52
import org.gvsig.examples.example1.gui.InputCoordinatesPanel;
53

  
54

  
55
/**
56
 * Properties toc menu entry center view to point.
57
 *
58
 * @author Vicente Caballero Navarro
59
 */
60
public class PropertiesTocMenuEntry extends AbstractTocContextMenuAction {
61
    /* (non-Javadoc)
62
     * @see com.iver.cit.gvsig.project.documents.IContextMenuAction#getGroup()
63
     */
64
    public String getGroup() {
65
        return "examplegroup";
66
    }
67

  
68
    /* (non-Javadoc)
69
     * @see com.iver.cit.gvsig.project.documents.IContextMenuAction#getGroupOrder()
70
     */
71
    public int getGroupOrder() {
72
        return 1;
73
    }
74

  
75
    /* (non-Javadoc)
76
     * @see com.iver.cit.gvsig.project.documents.IContextMenuAction#getOrder()
77
     */
78
    public int getOrder() {
79
        return 1;
80
    }
81

  
82
    /* (non-Javadoc)
83
     * @see com.iver.cit.gvsig.project.documents.IContextMenuAction#getText()
84
     */
85
    public String getText() {
86
        return PluginServices.getText(this, "Centrar_la_Vista_sobre_un_punto");
87
    }
88

  
89
    /* (non-Javadoc)
90
     * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
91
     */
92
    public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
93
        return true;
94
    }
95

  
96
    /* (non-Javadoc)
97
     * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isVisible(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
98
     */
99
    public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
100
        return (isTocItemBranch(item));
101
    }
102

  
103
    /* (non-Javadoc)
104
     * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
105
     */
106
    public void execute(ITocItem item, FLayer[] selectedItems) {
107
        View vista = (View) PluginServices.getMDIManager().getActiveWindow();
108
        InputCoordinatesPanel dataSelectionPanel = new InputCoordinatesPanel(vista);
109
        PluginServices.getMDIManager().addWindow(dataSelectionPanel);
110
    }
111
}
0 112

  
tags/tmp_build/examples/exaExampleCenterViewToPoint/src/org/gvsig/examples/example1/ExampleExtension.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
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
44
 *
45
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
46
 *
47
 * This program is free software; you can redistribute it and/or
48
 * modify it under the terms of the GNU General Public License
49
 * as published by the Free Software Foundation; either version 2
50
 * of the License, or (at your option) any later version.
51
 *
52
 * This program is distributed in the hope that it will be useful,
53
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
54
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
55
 * GNU General Public License for more details.
56
 *
57
 * You should have received a copy of the GNU General Public License
58
 * along with this program; if not, write to the Free Software
59
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
60
 *
61
 * For more information, contact:
62
 *
63
 *  Generalitat Valenciana
64
 *   Conselleria d'Infraestructures i Transport
65
 *   Av. Blasco Ib??ez, 50
66
 *   46010 VALENCIA
67
 *   SPAIN
68
 *
69
 *      +34 963862235
70
 *   gvsig@gva.es
71
 *      www.gvsig.gva.es
72
 *
73
 *    or
74
 *
75
 *   IVER T.I. S.A
76
 *   Salamanca 50
77
 *   46005 Valencia
78
 *   Spain
79
 *
80
 *   +34 963163400
81
 *   dac@iver.es
82
 */
83
package org.gvsig.examples.example1;
84

  
85
import com.iver.andami.PluginServices;
86
import com.iver.andami.plugins.Extension;
87
import com.iver.andami.plugins.ExtensionDecorator;
88
import com.iver.andami.preferences.IPreference;
89
import com.iver.andami.preferences.IPreferenceExtension;
90

  
91
import com.iver.cit.gvsig.About;
92
import com.iver.cit.gvsig.gui.panels.FPanelAbout;
93

  
94
import com.iver.utiles.extensionPoints.ExtensionPoints;
95
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
96

  
97
import org.gvsig.examples.example1.preferences.CenterViewToPointPage;
98
import org.gvsig.examples.example1.toc.PropertiesTocMenuEntry;
99

  
100
import java.util.ArrayList;
101

  
102

  
103
/**
104
 * Example of extension with a dialog of preferences, option in a context menu,
105
 * Exclusive extensions and about page.
106
 *
107
 * @author Vicente Caballero Navarro
108
 */
109
public class ExampleExtension extends Extension implements IPreferenceExtension {
110
    private CenterViewToPointPage centerViewPage = new CenterViewToPointPage();
111

  
112
    /* (non-Javadoc)
113
     * @see com.iver.andami.plugins.IExtension#initialize()
114
     */
115
    public void initialize() {
116
    }
117

  
118
    /* (non-Javadoc)
119
     * @see com.iver.andami.plugins.IExtension#postInitialize()
120
     */
121
    public void postInitialize() {
122
        super.postInitialize();
123

  
124
        ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
125
        extensionPoints.add("View_TocActions", "CenterViewToPoint",
126
            new PropertiesTocMenuEntry());
127

  
128
        About about = (About) PluginServices.getExtension(About.class);
129
        FPanelAbout panelAbout = about.getAboutPanel();
130
        java.net.URL aboutURL = this.getClass().getResource("/about.htm");
131
        panelAbout.addAboutUrl(PluginServices.getText(this, "example_extension"),
132
            aboutURL);
133

  
134
        exclusiveExtensions();
135
    }
136

  
137
    /**
138
     *
139
     */
140
    private void exclusiveExtensions() {
141
        ArrayList goodExtensions = new ArrayList();
142
        String[] ss = new String[] {
143
                "com.iver.core.Consola", "com.iver.core.StatusBar",
144
                "com.iver.cit.gvsig.ViewControls", "com.iver.cit.gvsig.AddLayer",
145
                "com.iver.cit.gvsig.ProjectExtension",
146
                "com.iver.cit.gvsig.About", "com.iver.cit.gvsig.LayoutControls",
147
                "com.iver.cit.gvsig.ViewPropertiesExtension",
148
                "com.iver.cit.gvsig.ZoomPrev",
149
                "com.iver.cit.gvsig.ViewProjectWindow",
150
                "com.iver.cit.gvsig.Print", "com.iver.cit.gvsig.PrintProperties",
151
                "com.iver.cit.gvsig.LayoutEditableControls",
152
                "com.iver.cit.gvsig.LayoutUndoExtension",
153
                "com.iver.cit.gvsig.LayoutRedoExtension",
154
                "com.iver.cit.gvsig.LayoutInsertToolsExtension",
155
                "com.iver.cit.gvsig.LayoutGraphicControls",
156
                "com.iver.cit.gvsig.LayoutEditVertexExtension",
157
                "com.iver.cit.gvsig.ViewSelectionControls",
158
                "org.gvsig.examples.example1.extension.CenterViewToPointExtension",
159
                "org.gvsig.examples.example1.extension.InfoToolExampleExtension",
160
                "org.gvsig.examples.example1.extension.OpenCSVToPointsExtension",
161
                "org.gvsig.examples.example1.ExampleExtension"
162
            };
163

  
164
        for (int i = 0; i < ss.length; i++) {
165
            goodExtensions.add(ss[i]);
166
        }
167

  
168
        ExtensionDecorator[] exts = PluginServices.getDecoratedExtensions();
169

  
170
        for (int i = 0; i < exts.length; i++) {
171
            if (!goodExtensions.contains(exts[i].getExtension().getClass()
172
                                                    .getName())) {
173
                exts[i].setVisibility(ExtensionDecorator.ALWAYS_INVISIBLE);
174
                System.out.println(exts[i].getExtension().getClass().getName());
175
            } else {
176
                exts[i].setVisibility(ExtensionDecorator.INACTIVE);
177
                System.err.println(exts[i].getExtension().getClass().getName());
178
            }
179
        }
180
    }
181

  
182
    /* (non-Javadoc)
183
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
184
     */
185
    public void execute(String arg0) {
186
    }
187

  
188
    /* (non-Javadoc)
189
     * @see com.iver.andami.plugins.IExtension#isEnabled()
190
     */
191
    public boolean isEnabled() {
192
        return false;
193
    }
194

  
195
    /* (non-Javadoc)
196
     * @see com.iver.andami.plugins.IExtension#isVisible()
197
     */
198
    public boolean isVisible() {
199
        return false;
200
    }
201

  
202
    /* (non-Javadoc)
203
     * @see com.iver.andami.preferences.IPreferenceExtension#getPreferencesPage()
204
     */
205
    public IPreference getPreferencesPage() {
206
        return centerViewPage;
207
    }
208
}
0 209

  
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
 *
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff