Revision 4551

View differences:

trunk/extensions/extCAD/config/config.xml
14 14
			active="true">
15 15
			<menu text="Vista/new_theme/new_shp" action-command="SHP"/>
16 16
			<menu text="Vista/new_theme/new_dxf" action-command="DXF"/>
17
			<menu text="Vista/new_theme/new_postgis" action-command="POSTGIS"/>			
17
			<menu text="Vista/new_theme/new_postgis" action-command="POSTGIS"/>
18 18
		</extension>
19 19

  
20 20
		<extension class-name="com.iver.cit.gvsig.StopEditing"
......
73 73
			description="Extensi?n encargada de gestionar los eventos realizados sobre las geometr?as."
74 74
			active="true">
75 75
			<menu text="geometria/seleccionar" action-command="SELCAD" icon="images/SelCAD.png"/>
76
			<menu text="geometria/insertar/punto" action-command="POINT" icon="images/Point.png"/>
77
			<menu text="geometria/insertar/linea" action-command="LINE" icon="images/Rect.png"/>
78
			<menu text="geometria/insertar/polilinea" action-command="POLYLINE" icon="images/Line.png"/>
79
			<menu text="geometria/insertar/poligono" action-command="POLYGON" icon="images/Poligon.png"/>
80
			<menu text="geometria/insertar/rectangulo" action-command="RECTANGLE" icon="images/Rectangle.png"/>
81
			<menu text="geometria/insertar/circulo" action-command="CIRCLE" icon="images/Circle.png"/>
82
			<menu text="geometria/insertar/elipse" action-command="ELLIPSE" icon="images/Ellipse.png"/>
83
			<menu text="geometria/insertar/arc" action-command="ARC" icon="images/Arc.png"/>
76
			<!--menu text="geometria/insertar/punto" action-command="POINT" icon="images/Point.png"/-->
77
			<!--menu text="geometria/insertar/linea" action-command="LINE" icon="images/Rect.png"/-->
78
			<!--menu text="geometria/insertar/polilinea" action-command="POLYLINE" icon="images/Line.png"/-->
79
			<!--menu text="geometria/insertar/poligono" action-command="POLYGON" icon="images/Poligon.png"/-->
80
			<!--menu text="geometria/insertar/rectangulo" action-command="RECTANGLE" icon="images/Rectangle.png"/-->
81
			<!--menu text="geometria/insertar/circulo" action-command="CIRCLE" icon="images/Circle.png"/-->
82
			<!--menu text="geometria/insertar/elipse" action-command="ELLIPSE" icon="images/Ellipse.png"/-->
83
			<!--menu text="geometria/insertar/arc" action-command="ARC" icon="images/Arc.png"/-->
84 84
			<!--menu text="geometria/insertar/curva" action-command="SPLINE" icon="images/Spline.png"/-->
85 85
			<menu text="geometria/insertar/copia" action-command="COPY" icon="images/Copy.png"/>
86 86
			<menu text="geometria/insertar/desplazar" action-command="MOVE" icon="images/Move.png"/>
......
99 99

  
100 100
			<tool-bar name="insertar">
101 101
				<selectable-tool icon="images/SelCAD.png" action-command="SELCAD" tooltip="seleccion" group="vista"/>
102
				<selectable-tool icon="images/Point.png" action-command="POINT" tooltip="punto" group="vista"/>
103
				<selectable-tool icon="images/Rect.png" action-command="LINE" tooltip="linea" group="vista"/>
104
				<selectable-tool icon="images/Line.png" action-command="POLYLINE" tooltip="polilinea" group="vista"/>
105
				<selectable-tool icon="images/Poligon.png" action-command="POLYGON" tooltip="poligono" group="vista"/>
106
				<selectable-tool icon="images/Rectangle.png" action-command="RECTANGLE" tooltip="rectangulo" group="vista"/>
107
				<selectable-tool icon="images/Circle.png" action-command="CIRCLE" tooltip="circulo" group="vista"/>
108
				<selectable-tool icon="images/Ellipse.png" action-command="ELLIPSE" tooltip="elipse" group="vista"/>
109
				<selectable-tool icon="images/Arc.png" action-command="ARC" tooltip="arco" group="vista"/>
102
				<!--selectable-tool icon="images/Point.png" action-command="POINT" tooltip="punto" group="vista"/-->
103
				<!--selectable-tool icon="images/Rect.png" action-command="LINE" tooltip="linea" group="vista"/-->
104
				<!--selectable-tool icon="images/Line.png" action-command="POLYLINE" tooltip="polilinea" group="vista"/-->
105
				<!--selectable-tool icon="images/Poligon.png" action-command="POLYGON" tooltip="poligono" group="vista"/-->
106
				<!--selectable-tool icon="images/Rectangle.png" action-command="RECTANGLE" tooltip="rectangulo" group="vista"/-->
107
				<!--selectable-tool icon="images/Circle.png" action-command="CIRCLE" tooltip="circulo" group="vista"/-->
108
				<!--selectable-tool icon="images/Ellipse.png" action-command="ELLIPSE" tooltip="elipse" group="vista"/-->
109
				<!--selectable-tool icon="images/Arc.png" action-command="ARC" tooltip="arco" group="vista"/-->
110 110
				<!--selectable-tool icon="images/Spline.png" action-command="SPLINE" tooltip="curva" group="vista"/-->
111 111
			</tool-bar>
112 112
			<tool-bar name="modificar">
......
129 129

  
130 130
			</tool-bar>
131 131
		</extension>
132

  
133
		<extension class-name="com.iver.cit.gvsig.InsertPointExtension"
134
			description="Extensi?n encargada de insertar puntos en un tema en edici?n."
135
			active="true">
136
			<menu text="geometria/insertar/punto" action-command="POINT" icon="images/Point.png"/>
137
			<tool-bar name="insertar">
138
				<selectable-tool icon="images/Point.png" action-command="POINT" tooltip="punto" group="vista"/>
139
			</tool-bar>
140
		</extension>
141
		<extension class-name="com.iver.cit.gvsig.InsertLineExtension"
142
			description="Extensi?n encargada de insertar l?neas en un tema en edici?n."
143
			active="true">
144
			<menu text="geometria/insertar/linea" action-command="LINE" icon="images/Rect.png"/>
145
			<menu text="geometria/insertar/arc" action-command="ARC" icon="images/Arc.png"/>
146

  
147
			<tool-bar name="insertar">
148
				<selectable-tool icon="images/Rect.png" action-command="LINE" tooltip="linea" group="vista"/>
149
				<selectable-tool icon="images/Arc.png" action-command="ARC" tooltip="arco" group="vista"/>
150
			</tool-bar>
151
		</extension>
152
		<extension class-name="com.iver.cit.gvsig.InsertPolyLineExtension"
153
			description="Extensi?n encargada de insertar polil?neas en un tema en edici?n."
154
			active="true">
155
			<menu text="geometria/insertar/polilinea" action-command="POLYLINE" icon="images/Line.png"/>
156
			<tool-bar name="insertar">
157
				<selectable-tool icon="images/Line.png" action-command="POLYLINE" tooltip="polilinea" group="vista"/>
158
			</tool-bar>
159
		</extension>
160
		<extension class-name="com.iver.cit.gvsig.InsertPolygonExtension"
161
			description="Extensi?n encargada de insertar poligonos en un tema en edici?n."
162
			active="true">
163
			<menu text="geometria/insertar/poligono" action-command="POLYGON" icon="images/Poligon.png"/>
164
			<menu text="geometria/insertar/rectangulo" action-command="RECTANGLE" icon="images/Rectangle.png"/>
165
			<menu text="geometria/insertar/circulo" action-command="CIRCLE" icon="images/Circle.png"/>
166
			<menu text="geometria/insertar/elipse" action-command="ELLIPSE" icon="images/Ellipse.png"/>
167
			<tool-bar name="insertar">
168
				<selectable-tool icon="images/Poligon.png" action-command="POLYGON" tooltip="poligono" group="vista"/>
169
				<selectable-tool icon="images/Rectangle.png" action-command="RECTANGLE" tooltip="rectangulo" group="vista"/>
170
				<selectable-tool icon="images/Circle.png" action-command="CIRCLE" tooltip="circulo" group="vista"/>
171
				<selectable-tool icon="images/Ellipse.png" action-command="ELLIPSE" tooltip="elipse" group="vista"/>
172
			</tool-bar>
173
		</extension>
132 174
	</extensions>
133 175
</plugin-config>
trunk/extensions/extCAD/src/com/iver/cit/gvsig/InsertPolygonExtension.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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
package com.iver.cit.gvsig;
42

  
43
import com.iver.andami.PluginServices;
44
import com.iver.andami.plugins.Extension;
45
import com.iver.cit.gvsig.fmap.DriverException;
46
import com.iver.cit.gvsig.fmap.MapControl;
47
import com.iver.cit.gvsig.fmap.core.FShape;
48
import com.iver.cit.gvsig.fmap.layers.FLayer;
49
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
50
import com.iver.cit.gvsig.gui.View;
51
import com.iver.cit.gvsig.gui.cad.tools.CircleCADTool;
52
import com.iver.cit.gvsig.gui.cad.tools.EllipseCADTool;
53
import com.iver.cit.gvsig.gui.cad.tools.PolygonCADTool;
54
import com.iver.cit.gvsig.gui.cad.tools.RectangleCADTool;
55

  
56
/**
57
 * Extensi?n que gestiona la inserci?n de poligonos en edici?n.
58
 *
59
 * @author Vicente Caballero Navarro
60
 */
61
public class InsertPolygonExtension implements Extension {
62
	private View view;
63

  
64
	private MapControl mapControl;
65

  
66
	/**
67
	 * @see com.iver.andami.plugins.Extension#inicializar()
68
	 */
69
	public void inicializar() {
70
		PolygonCADTool polygon = new PolygonCADTool();
71
		CircleCADTool circle=new CircleCADTool();
72
        RectangleCADTool rectangle=new RectangleCADTool();
73
        EllipseCADTool ellipse=new EllipseCADTool();
74
		CADExtension.addCADTool("polygon", polygon);
75
		CADExtension.addCADTool("circle",circle);
76
	    CADExtension.addCADTool("rectangle", rectangle);
77
	    CADExtension.addCADTool("ellipse", ellipse);
78
	}
79

  
80
	/**
81
	 * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
82
	 */
83
	public void execute(String s) {
84
		mapControl.addMapTool("cadtooladapter",CADExtension.getCADToolAdapter());
85
		mapControl.setTool("cadtooladapter");
86
		if (s.equals("POLYGON")) {
87
			CADExtension.setCADTool("polygon");
88
		}else if (s.equals("CIRCLE")) {
89
           CADExtension.setCADTool("circle");
90
        } else if (s.equals("ELLIPSE")) {
91
        	CADExtension.setCADTool("ellipse");
92
        }else if (s.equals("RECTANGLE")) {
93
        	CADExtension.setCADTool("rectangle");
94
        }
95
		CADExtension.getEditionManager().setMapControl(mapControl);
96
		CADExtension.getCADToolAdapter().configureMenu();
97
	}
98

  
99
	/**
100
	 * @see com.iver.andami.plugins.Extension#isEnabled()
101
	 */
102
	public boolean isEnabled() {
103

  
104
		try {
105
			if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) {
106
				view = (View) PluginServices.getMDIManager().getActiveView();
107
				mapControl = (MapControl) view.getMapControl();
108
				FLayer[] layers = mapControl.getMapContext().getLayers()
109
						.getActives();
110
				if (((FLyrVect) layers[0]).getShapeType() == FShape.POLYGON
111
						|| ((FLyrVect) layers[0]).getShapeType() == FShape.MULTI
112
						|| ((FLyrVect) layers[0]).getShapeType() == FShape.LINE) {
113
					return true;
114
				}
115
			}
116
		} catch (DriverException e) {
117
			e.printStackTrace();
118
		}
119
		return false;
120
	}
121

  
122
	/**
123
	 * @see com.iver.andami.plugins.Extension#isVisible()
124
	 */
125
	public boolean isVisible() {
126
		com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
127
				.getActiveView();
128

  
129
		if (f == null) {
130
			return false;
131
		}
132

  
133
		if (f.getClass() == View.class) {
134
			return true;
135
		} else {
136
			return false;
137
		}
138
	}
139
}
0 140

  
trunk/extensions/extCAD/src/com/iver/cit/gvsig/InsertLineExtension.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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
package com.iver.cit.gvsig;
42

  
43
import com.iver.andami.PluginServices;
44
import com.iver.andami.plugins.Extension;
45
import com.iver.cit.gvsig.fmap.DriverException;
46
import com.iver.cit.gvsig.fmap.MapControl;
47
import com.iver.cit.gvsig.fmap.core.FShape;
48
import com.iver.cit.gvsig.fmap.layers.FLayer;
49
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
50
import com.iver.cit.gvsig.gui.View;
51
import com.iver.cit.gvsig.gui.cad.tools.ArcCADTool;
52
import com.iver.cit.gvsig.gui.cad.tools.LineCADTool;
53

  
54
/**
55
 * Extensi?n que gestiona la inserci?n de l?neas en edici?n.
56
 *
57
 * @author Vicente Caballero Navarro
58
 */
59
public class InsertLineExtension implements Extension {
60
	private View view;
61

  
62
	private MapControl mapControl;
63

  
64
	/**
65
	 * @see com.iver.andami.plugins.Extension#inicializar()
66
	 */
67
	public void inicializar() {
68
		LineCADTool line = new LineCADTool();
69
		CADExtension.addCADTool("line", line);
70
		ArcCADTool arc=new ArcCADTool();
71
		CADExtension.addCADTool("arc", arc);
72
	}
73

  
74
	/**
75
	 * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
76
	 */
77
	public void execute(String s) {
78
		mapControl.addMapTool("cadtooladapter",CADExtension.getCADToolAdapter());
79
		mapControl.setTool("cadtooladapter");
80
		if (s.equals("LINE")) {
81
			CADExtension.setCADTool("line");
82
			CADExtension.getEditionManager().setMapControl(mapControl);
83
		} else if (s.equals("ARC")) {
84
        	CADExtension.setCADTool("arc");
85
        	CADExtension.getEditionManager().setMapControl(mapControl);
86
        }
87
		CADExtension.getCADToolAdapter().configureMenu();
88
	}
89

  
90
	/**
91
	 * @see com.iver.andami.plugins.Extension#isEnabled()
92
	 */
93
	public boolean isEnabled() {
94

  
95
		try {
96
			if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) {
97
				view = (View) PluginServices.getMDIManager().getActiveView();
98
				mapControl = (MapControl) view.getMapControl();
99
				FLayer[] layers = mapControl.getMapContext().getLayers()
100
						.getActives();
101
				if (((FLyrVect) layers[0]).getShapeType() == FShape.LINE
102
						|| ((FLyrVect) layers[0]).getShapeType() == FShape.MULTI) {
103
					return true;
104
				}
105
			}
106
		} catch (DriverException e) {
107
			e.printStackTrace();
108
		}
109
		return false;
110
	}
111

  
112
	/**
113
	 * @see com.iver.andami.plugins.Extension#isVisible()
114
	 */
115
	public boolean isVisible() {
116
		com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
117
				.getActiveView();
118

  
119
		if (f == null) {
120
			return false;
121
		}
122

  
123
		if (f.getClass() == View.class) {
124
			return true;
125
		} else {
126
			return false;
127
		}
128
	}
129
}
0 130

  
trunk/extensions/extCAD/src/com/iver/cit/gvsig/InsertPointExtension.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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
package com.iver.cit.gvsig;
42

  
43
import com.iver.andami.PluginServices;
44
import com.iver.andami.plugins.Extension;
45
import com.iver.cit.gvsig.fmap.DriverException;
46
import com.iver.cit.gvsig.fmap.MapControl;
47
import com.iver.cit.gvsig.fmap.core.FShape;
48
import com.iver.cit.gvsig.fmap.layers.FLayer;
49
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
50
import com.iver.cit.gvsig.gui.View;
51
import com.iver.cit.gvsig.gui.cad.tools.PointCADTool;
52
/**
53
 * Extensi?n que gestiona la inserci?n de puntos en edici?n.
54
 *
55
 * @author Vicente Caballero Navarro
56
 */
57
public class InsertPointExtension implements Extension {
58
   private View view;
59
   private MapControl mapControl;
60

  
61
   /**
62
     * @see com.iver.andami.plugins.Extension#inicializar()
63
     */
64
    public void inicializar() {
65
        PointCADTool point = new PointCADTool();
66
        CADExtension.addCADTool("point", point);
67
    }
68

  
69
    /**
70
     * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
71
     */
72
    public void execute(String s) {
73
    	mapControl.addMapTool("cadtooladapter",CADExtension.getCADToolAdapter());
74
        mapControl.setTool("cadtooladapter");
75

  
76
        if (s.equals("POINT")) {
77
        	CADExtension.setCADTool("point");
78
        	CADExtension.getEditionManager().setMapControl(mapControl);
79
        }
80
        CADExtension.getCADToolAdapter().configureMenu();
81
    }
82
    /**
83
     * @see com.iver.andami.plugins.Extension#isEnabled()
84
     */
85
    public boolean isEnabled() {
86

  
87
      	try {
88
			if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE){
89
				view = (View) PluginServices.getMDIManager().getActiveView();
90
		        mapControl = (MapControl) view.getMapControl();
91
				FLayer[] layers = mapControl.getMapContext().getLayers()
92
						.getActives();
93
				if (((FLyrVect) layers[0]).getShapeType() == FShape.POINT
94
						|| ((FLyrVect) layers[0]).getShapeType() == FShape.MULTI
95
						|| ((FLyrVect) layers[0]).getShapeType() == FShape.MULTIPOINT) {
96
					return true;
97
				}
98
			}
99
		} catch (DriverException e) {
100
			e.printStackTrace();
101
		}
102
		return false;
103
    }
104

  
105
    /**
106
     * @see com.iver.andami.plugins.Extension#isVisible()
107
     */
108
    public boolean isVisible() {
109
        com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
110
                                                             .getActiveView();
111

  
112
        if (f == null) {
113
            return false;
114
        }
115

  
116
        if (f.getClass() == View.class) {
117
            return true;
118
        } else {
119
            return false;
120
        }
121
    }
122
	}
0 123

  
trunk/extensions/extCAD/src/com/iver/cit/gvsig/InsertPolyLineExtension.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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
package com.iver.cit.gvsig;
42

  
43
import com.iver.andami.PluginServices;
44
import com.iver.andami.plugins.Extension;
45
import com.iver.cit.gvsig.fmap.DriverException;
46
import com.iver.cit.gvsig.fmap.MapControl;
47
import com.iver.cit.gvsig.fmap.core.FShape;
48
import com.iver.cit.gvsig.fmap.layers.FLayer;
49
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
50
import com.iver.cit.gvsig.gui.View;
51
import com.iver.cit.gvsig.gui.cad.tools.PolylineCADTool;
52

  
53
/**
54
 * Extensi?n que gestiona la inserci?n de polil?neas en edici?n.
55
 *
56
 * @author Vicente Caballero Navarro
57
 */
58
public class InsertPolyLineExtension implements Extension {
59
	private View view;
60

  
61
	private MapControl mapControl;
62

  
63
	/**
64
	 * @see com.iver.andami.plugins.Extension#inicializar()
65
	 */
66
	public void inicializar() {
67
		PolylineCADTool polyline = new PolylineCADTool();
68
		CADExtension.addCADTool("polyline", polyline);
69
	}
70

  
71
	/**
72
	 * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
73
	 */
74
	public void execute(String s) {
75
		mapControl.addMapTool("cadtooladapter",CADExtension.getCADToolAdapter());
76
		mapControl.setTool("cadtooladapter");
77
		if (s.equals("POLYLINE")) {
78
			CADExtension.setCADTool("polyline");
79
			CADExtension.getEditionManager().setMapControl(mapControl);
80
		}
81
		CADExtension.getCADToolAdapter().configureMenu();
82
	}
83

  
84
	/**
85
	 * @see com.iver.andami.plugins.Extension#isEnabled()
86
	 */
87
	public boolean isEnabled() {
88

  
89
		try {
90
			if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) {
91
				view = (View) PluginServices.getMDIManager().getActiveView();
92
				mapControl = (MapControl) view.getMapControl();
93
				FLayer[] layers = mapControl.getMapContext().getLayers()
94
						.getActives();
95
				if (((FLyrVect) layers[0]).getShapeType() == FShape.LINE
96
						|| ((FLyrVect) layers[0]).getShapeType() == FShape.POLYGON
97
						|| ((FLyrVect) layers[0]).getShapeType() == FShape.MULTI) {
98
					return true;
99
				}
100
			}
101
		} catch (DriverException e) {
102
			e.printStackTrace();
103
		}
104
		return false;
105
	}
106

  
107
	/**
108
	 * @see com.iver.andami.plugins.Extension#isVisible()
109
	 */
110
	public boolean isVisible() {
111
		com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
112
				.getActiveView();
113

  
114
		if (f == null) {
115
			return false;
116
		}
117

  
118
		if (f.getClass() == View.class) {
119
			return true;
120
		} else {
121
			return false;
122
		}
123
	}
124
}
0 125

  
trunk/extensions/extCAD/src/com/iver/cit/gvsig/CADExtension.java
49 49
import java.util.HashMap;
50 50

  
51 51
import javax.swing.AbstractAction;
52
import javax.swing.FocusManager;
53
import javax.swing.JComponent;
54 52
import javax.swing.JMenuItem;
55 53
import javax.swing.JPopupMenu;
56
import javax.swing.JTextArea;
57
import javax.swing.KeyStroke;
58 54

  
59 55
import com.iver.andami.PluginServices;
60 56
import com.iver.andami.plugins.Extension;
61 57
import com.iver.cit.gvsig.fmap.MapControl;
62
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
63
import com.iver.cit.gvsig.fmap.layers.FLayer;
64
import com.iver.cit.gvsig.fmap.layers.FLayers;
65
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
66
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior;
67 58
import com.iver.cit.gvsig.gui.View;
68 59
import com.iver.cit.gvsig.gui.cad.CADTool;
69 60
import com.iver.cit.gvsig.gui.cad.CADToolAdapter;
......
102 93
     */
103 94
    public void inicializar() {
104 95
        SelectionCADTool selection=new SelectionCADTool();
105
    	LineCADTool line = new LineCADTool();
106
        PointCADTool point = new PointCADTool();
107
        CircleCADTool circle=new CircleCADTool();
108
        RectangleCADTool rectangle=new RectangleCADTool();
109
        PolylineCADTool polyline=new PolylineCADTool();
110
        EllipseCADTool ellipse=new EllipseCADTool();
111
        ArcCADTool arc=new ArcCADTool();
112
        PolygonCADTool polygon=new PolygonCADTool();
96
//    	LineCADTool line = new LineCADTool();
97
//        PointCADTool point = new PointCADTool();
98
//        CircleCADTool circle=new CircleCADTool();
99
//        RectangleCADTool rectangle=new RectangleCADTool();
100
//        PolylineCADTool polyline=new PolylineCADTool();
101
//        EllipseCADTool ellipse=new EllipseCADTool();
102
//        ArcCADTool arc=new ArcCADTool();
103
//        PolygonCADTool polygon=new PolygonCADTool();
113 104
        CopyCADTool copy=new CopyCADTool();
114 105
        MoveCADTool move=new MoveCADTool();
115 106
        RotateCADTool rotate=new RotateCADTool();
116 107
        ScaleCADTool scale=new ScaleCADTool();
117 108
        EditVertexCADTool editvertex=new EditVertexCADTool();
118 109
        addCADTool("selection", selection);
119
        addCADTool("line", line);
120
        addCADTool("point", point);
121
        addCADTool("circle",circle);
122
        addCADTool("rectangle", rectangle);
123
        addCADTool("polyline", polyline);
124
        addCADTool("ellipse", ellipse);
125
        addCADTool("arc", arc);
126
        addCADTool("polygon", polygon);
110
//        addCADTool("line", line);
111
//        addCADTool("point", point);
112
//        addCADTool("circle",circle);
113
//        addCADTool("rectangle", rectangle);
114
//        addCADTool("polyline", polyline);
115
//        addCADTool("ellipse", ellipse);
116
//        addCADTool("arc", arc);
117
//        addCADTool("polygon", polygon);
127 118
        addCADTool("copy",copy);
128 119
        addCADTool("move",move);
129 120
        addCADTool("rotate",rotate);
......
204 195
        	setCADTool("join");
205 196
        } else if (s.equals("SELCAD")) {
206 197
        	setCADTool("selection");
207
        } else if (s.equals("POINT")) {
208
        	setCADTool("point");
209
        } else if (s.equals("LINE")) {
210
        	setCADTool("line");
211
        } else if (s.equals("POLYLINE")) {
212
        	setCADTool("polyline");
213
        } else if (s.equals("CIRCLE")) {
214
           setCADTool("circle");
215
        } else if (s.equals("ARC")) {
216
        	setCADTool("arc");
217
        } else if (s.equals("ELLIPSE")) {
218
        	setCADTool("ellipse");
219
        } else if (s.equals("RECTANGLE")) {
220
        	setCADTool("rectangle");
221
        } else if (s.equals("POLYGON")) {
222
        	setCADTool("polygon");
198
//        } else if (s.equals("POINT")) {
199
//        	setCADTool("point");
200
//        } else if (s.equals("LINE")) {
201
//        	setCADTool("line");
202
//        } else if (s.equals("POLYLINE")) {
203
//        	setCADTool("polyline");
204
//        } else if (s.equals("CIRCLE")) {
205
//           setCADTool("circle");
206
//        } else if (s.equals("ARC")) {
207
//        	setCADTool("arc");
208
//        } else if (s.equals("ELLIPSE")) {
209
//        	setCADTool("ellipse");
210
//        } else if (s.equals("RECTANGLE")) {
211
//        	setCADTool("rectangle");
212
//        } else if (s.equals("POLYGON")) {
213
//        	setCADTool("polygon");
223 214
        } else if (s.equals("EDITVERTEX")) {
224 215
        	setCADTool("editvertex");
225 216
        }
226 217
        adapter.configureMenu();
227 218
        //ViewControls.CANCELED=false;
228 219
    }
229
    public void addCADTool(String name, CADTool c){
220
    public static void addCADTool(String name, CADTool c){
230 221
		namesCadTools.put(name, c);
231 222
	}
232 223
    public static void setCADTool(String text){
......
348 339
        	else
349 340
        	{
350 341
        		if (e.getComponent().getName() != null)
351
        		{        			
342
        		{
352 343
	        		System.out.println("Evento de teclado desde el componente " + e.getComponent().getName());
353 344
	        		if (!e.getComponent().getName().equals("CADConsole"))
354 345
	        		{
......
368 359

  
369 360
	}
370 361

  
371
	private void registerKeyStrokes(){
362
/*	private void registerKeyStrokes(){
372 363
		for (char key = '0'; key <= '9'; key++){
373 364
			Character keyChar = new Character(key);
374 365
			mapControl.getInputMap(MapControl.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(key), keyChar);
......
397 388

  
398 389

  
399 390
	}
400

  
391
*/
401 392
	private static JPopupMenu popup = new JPopupMenu();
402 393
	public static  void clearMenu(){
403 394
		popup.removeAll();

Also available in: Unified diff