root / branches / v2_0_0_prep / extensions / extEditing / src / org / gvsig / editing / SplitGeometryCADToolExtension.java @ 38564
History | View | Annotate | Download (4.56 KB)
1 | 28070 | vcaballero | /*
|
---|---|---|---|
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 | 36668 | jpiera | *
|
46 | * $Id:
|
||
47 | * $Log:
|
||
48 | */
|
||
49 | 29616 | jpiera | package org.gvsig.editing; |
50 | 28070 | vcaballero | |
51 | 38564 | jjdelcerro | import org.gvsig.andami.IconThemeHelper; |
52 | 29616 | jpiera | import org.gvsig.andami.PluginServices; |
53 | import org.gvsig.andami.messages.NotificationManager; |
||
54 | import org.gvsig.andami.plugins.Extension; |
||
55 | 31496 | jjdelcerro | import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
56 | 29616 | jpiera | import org.gvsig.editing.gui.cad.tools.SplitGeometryCADTool; |
57 | 28070 | vcaballero | import org.gvsig.fmap.dal.exception.DataException; |
58 | import org.gvsig.fmap.geom.Geometry; |
||
59 | import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
||
60 | import org.gvsig.fmap.mapcontrol.MapControl; |
||
61 | |||
62 | |||
63 | /**
|
||
64 | * CAD extension to split geometries from a digitized linear geometry.
|
||
65 | *
|
||
66 | * @author Alvaro Zabala
|
||
67 | *
|
||
68 | */
|
||
69 | public class SplitGeometryCADToolExtension extends Extension { |
||
70 | |||
71 | 36668 | jpiera | private DefaultViewPanel view;
|
72 | private MapControl mapControl;
|
||
73 | private SplitGeometryCADTool cadTool;
|
||
74 | 28070 | vcaballero | |
75 | |||
76 | 36668 | jpiera | public void execute(String actionCommand) { |
77 | CADExtension.initFocus(); |
||
78 | 38564 | jjdelcerro | if (actionCommand.equals(SplitGeometryCADTool.SPLIT_GEOMETRY_ACTION_NAME)) {
|
79 | 36668 | jpiera | CADExtension.setCADTool(SplitGeometryCADTool.SPLIT_GEOMETRY_TOOL_NAME, true);
|
80 | 28070 | vcaballero | } |
81 | 36668 | jpiera | CADExtension.getEditionManager().setMapControl(mapControl); |
82 | CADExtension.getCADToolAdapter().configureMenu(); |
||
83 | } |
||
84 | 28070 | vcaballero | |
85 | 36668 | jpiera | public void initialize() { |
86 | cadTool = new SplitGeometryCADTool();
|
||
87 | CADExtension.addCADTool(SplitGeometryCADTool.SPLIT_GEOMETRY_TOOL_NAME, cadTool); |
||
88 | registerIcons(); |
||
89 | } |
||
90 | 28070 | vcaballero | |
91 | 36668 | jpiera | private void registerIcons(){ |
92 | 38564 | jjdelcerro | IconThemeHelper.registerIcon("action", "layer-modify-split", this); |
93 | 36668 | jpiera | } |
94 | 28070 | vcaballero | |
95 | 36668 | jpiera | /**
|
96 | * Returns if this Edit CAD tool is visible.
|
||
97 | * For this, there must be an active vectorial editing lyr in the TOC, which geometries'
|
||
98 | * dimension would must be linear or polygonal, and with at least one selected geometry.
|
||
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 = (DefaultViewPanel) 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 | 36669 | jpiera | if (isPoint(lv.getShapeType())){
|
114 | 36668 | jpiera | return false; |
115 | 36669 | jpiera | } |
116 | 28070 | vcaballero | |
117 | 36668 | jpiera | return !lv.getFeatureStore().getFeatureSelection().isEmpty();
|
118 | } |
||
119 | } catch (DataException e) {
|
||
120 | NotificationManager.addError(e.getMessage(),e); |
||
121 | return false; |
||
122 | } |
||
123 | return true; |
||
124 | } |
||
125 | 36669 | jpiera | |
126 | private boolean isPoint(int shapeType) { |
||
127 | switch (shapeType) {
|
||
128 | 36668 | jpiera | case Geometry.TYPES.MULTIPOINT:
|
129 | 36669 | jpiera | case Geometry.TYPES.POINT:
|
130 | return true; |
||
131 | 36668 | jpiera | default:
|
132 | 36669 | jpiera | return false; |
133 | 36668 | jpiera | } |
134 | } |
||
135 | 28070 | vcaballero | |
136 | 36668 | jpiera | public boolean isVisible() { |
137 | if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE)
|
||
138 | return true; |
||
139 | return false; |
||
140 | } |
||
141 | 28070 | vcaballero | } |