root / trunk / extensions / extTopology / src / com / iver / cit / gvsig / cad / TopologicalEditVertexExtension.java @ 19998
History | View | Annotate | Download (4 KB)
1 | 19998 | azabala | /*
|
---|---|---|---|
2 | * Created on 10-abr-2006
|
||
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 | /* CVS MESSAGES:
|
||
45 | *
|
||
46 | * $Id:
|
||
47 | * $Log:
|
||
48 | */
|
||
49 | package com.iver.cit.gvsig.cad; |
||
50 | |||
51 | import org.gvsig.topology.Topology; |
||
52 | |||
53 | import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
||
54 | import com.iver.andami.PluginServices; |
||
55 | import com.iver.andami.messages.NotificationManager; |
||
56 | import com.iver.andami.plugins.Extension; |
||
57 | import com.iver.cit.gvsig.CADExtension; |
||
58 | import com.iver.cit.gvsig.EditionUtilities; |
||
59 | import com.iver.cit.gvsig.fmap.MapControl; |
||
60 | import com.iver.cit.gvsig.fmap.layers.FLayers; |
||
61 | import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
||
62 | import com.iver.cit.gvsig.project.documents.view.gui.View; |
||
63 | |||
64 | /**
|
||
65 | * CAD Extension that edits a vertex, moving the same vertex in all the
|
||
66 | * layers of a topology that shares it.
|
||
67 | *
|
||
68 | * @author Alvaro Zabala
|
||
69 | *
|
||
70 | */
|
||
71 | public class TopologicalEditVertexExtension extends Extension { |
||
72 | |||
73 | private View view; |
||
74 | private MapControl mapControl;
|
||
75 | private TopologicalEditVertexCADTool cadTool;
|
||
76 | |||
77 | |||
78 | public void execute(String actionCommand) { |
||
79 | CADExtension.initFocus(); |
||
80 | if (actionCommand.equals(TopologicalEditVertexCADTool.COMMAND_STRING)) {
|
||
81 | CADExtension.setCADTool(TopologicalEditVertexCADTool.COMMAND_STRING, true);
|
||
82 | } |
||
83 | CADExtension.getEditionManager().setMapControl(mapControl); |
||
84 | CADExtension.getCADToolAdapter().configureMenu(); |
||
85 | } |
||
86 | |||
87 | public void initialize() { |
||
88 | cadTool = new TopologicalEditVertexCADTool();
|
||
89 | CADExtension.addCADTool(TopologicalEditVertexCADTool.COMMAND_STRING, cadTool); |
||
90 | registerIcons(); |
||
91 | } |
||
92 | |||
93 | private void registerIcons(){ |
||
94 | PluginServices.getIconTheme().registerDefault("topological-edit-vertex",
|
||
95 | this.getClass().
|
||
96 | getClassLoader(). |
||
97 | getResource("images/topology_edit.png")
|
||
98 | ); |
||
99 | } |
||
100 | |||
101 | public boolean isEnabled() { |
||
102 | try {
|
||
103 | if (EditionUtilities.getEditionStatus() ==
|
||
104 | EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) { |
||
105 | this.view = (View) PluginServices.getMDIManager().getActiveWindow(); |
||
106 | mapControl = view.getMapControl(); |
||
107 | if (CADExtension.getEditionManager().getActiveLayerEdited() == null) |
||
108 | return false; |
||
109 | FLyrVect lv = (FLyrVect) CADExtension. |
||
110 | getEditionManager(). |
||
111 | getActiveLayerEdited(). |
||
112 | getLayer(); |
||
113 | if (! cadTool.isApplicable(lv.getShapeType())){
|
||
114 | return false; |
||
115 | } |
||
116 | |||
117 | // FLayers parentLyr = lv.getParentLayer();
|
||
118 | // if(!(parentLyr instanceof Topology))
|
||
119 | // return false;
|
||
120 | } |
||
121 | } catch (ReadDriverException e) {
|
||
122 | NotificationManager.addError(e.getMessage(),e); |
||
123 | return false; |
||
124 | } |
||
125 | return true; |
||
126 | } |
||
127 | |||
128 | public boolean isVisible() { |
||
129 | if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE)
|
||
130 | return true; |
||
131 | return false; |
||
132 | } |
||
133 | } |