svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.editing.app / org.gvsig.editing.app.mainplugin / src / main / java / org / gvsig / editing / InsertPolyLineExtension.java @ 40557
History | View | Annotate | Download (3.61 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.editing; |
25 |
|
26 |
import org.gvsig.andami.IconThemeHelper; |
27 |
import org.gvsig.andami.PluginServices; |
28 |
import org.gvsig.andami.messages.NotificationManager; |
29 |
import org.gvsig.andami.plugins.Extension; |
30 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
31 |
import org.gvsig.editing.gui.cad.tools.PolylineCADTool; |
32 |
import org.gvsig.editing.gui.cad.tools.SplineCADTool; |
33 |
import org.gvsig.fmap.dal.exception.ReadException; |
34 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
35 |
import org.gvsig.fmap.mapcontrol.MapControl; |
36 |
|
37 |
|
38 |
/**
|
39 |
* Extensi?n que gestiona la inserci?n de polil?neas en edici?n.
|
40 |
*
|
41 |
* @author Vicente Caballero Navarro
|
42 |
*/
|
43 |
public class InsertPolyLineExtension extends Extension { |
44 |
private DefaultViewPanel view;
|
45 |
|
46 |
private MapControl mapControl;
|
47 |
private PolylineCADTool polyline;
|
48 |
private SplineCADTool spline;
|
49 |
|
50 |
/**
|
51 |
* @see org.gvsig.andami.plugins.IExtension#initialize()
|
52 |
*/
|
53 |
public void initialize() { |
54 |
polyline = new PolylineCADTool();
|
55 |
spline = new SplineCADTool();
|
56 |
CADExtension.addCADTool("_polyline", polyline);
|
57 |
CADExtension.addCADTool("_spline", spline);
|
58 |
|
59 |
registerIcons(); |
60 |
} |
61 |
|
62 |
private void registerIcons(){ |
63 |
IconThemeHelper.registerIcon("action", "layer-insert-polyline", this); |
64 |
IconThemeHelper.registerIcon("action", "layer-insert-spline", this); |
65 |
} |
66 |
/**
|
67 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
68 |
*/
|
69 |
public void execute(String s) { |
70 |
CADExtension.initFocus(); |
71 |
if ("layer-insert-polyline".equalsIgnoreCase(s)) { |
72 |
CADExtension.setCADTool("_polyline",true); |
73 |
}else if ("layer-insert-spline".equalsIgnoreCase(s) ) { |
74 |
CADExtension.setCADTool("_spline",true); |
75 |
} |
76 |
CADExtension.getEditionManager().setMapControl(mapControl); |
77 |
CADExtension.getCADToolAdapter().configureMenu(); |
78 |
} |
79 |
|
80 |
/**
|
81 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled()
|
82 |
*/
|
83 |
public boolean isEnabled() { |
84 |
|
85 |
try {
|
86 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) {
|
87 |
view = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
88 |
mapControl = view.getMapControl(); |
89 |
if (CADExtension.getEditionManager().getActiveLayerEdited()==null) |
90 |
return false; |
91 |
FLyrVect lv=(FLyrVect)CADExtension.getEditionManager().getActiveLayerEdited().getLayer(); |
92 |
if (polyline.isApplicable(lv.getShapeType())){
|
93 |
return true; |
94 |
} |
95 |
} |
96 |
} catch (ReadException e) {
|
97 |
NotificationManager.addError(e.getMessage(),e); |
98 |
} |
99 |
return false; |
100 |
} |
101 |
|
102 |
/**
|
103 |
* @see org.gvsig.andami.plugins.IExtension#isVisible()
|
104 |
*/
|
105 |
public boolean isVisible() { |
106 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE)
|
107 |
return true; |
108 |
return false; |
109 |
} |
110 |
} |