gvsig-vectorediting / org.gvsig.vectorediting / trunk / org.gvsig.vectorediting / org.gvsig.vectorediting.app / org.gvsig.vectorediting.app.mainplugin / src / main / java / org / gvsig / vectorediting / app / mainplugin / extensions / SymmetryExtension.java @ 63
History | View | Annotate | Download (2.25 KB)
1 |
/*
|
---|---|
2 |
* Copyright 2014 DiSiD Technologies S.L.L. All rights reserved.
|
3 |
*
|
4 |
* Project : DiSiD org.gvsig.vectorediting.app.mainplugin
|
5 |
* SVN Id : $Id$
|
6 |
*/
|
7 |
package org.gvsig.vectorediting.app.mainplugin.extensions; |
8 |
|
9 |
import org.gvsig.andami.IconThemeHelper; |
10 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
11 |
import org.gvsig.fmap.dal.exception.ReadException; |
12 |
import org.gvsig.fmap.geom.type.GeometryType; |
13 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
14 |
import org.gvsig.tools.service.ServiceException; |
15 |
import org.gvsig.vectorediting.app.mainplugin.BaseEditingServiceExtension; |
16 |
import org.gvsig.vectorediting.lib.api.EditingServiceInfo; |
17 |
import org.gvsig.vectorediting.lib.prov.circlecr.CircleCREditingProviderFactory; |
18 |
import org.gvsig.vectorediting.lib.prov.symmetry.SymmetryEditingProviderFactory; |
19 |
|
20 |
public class SymmetryExtension extends BaseEditingServiceExtension { |
21 |
|
22 |
public void initialize() { |
23 |
// TODO Auto-generated method stub
|
24 |
|
25 |
} |
26 |
|
27 |
public void execute(String arg0) { |
28 |
|
29 |
DefaultViewPanel view = getActiveView(); |
30 |
swingManager.activateTool(SymmetryEditingProviderFactory.PROVIDER_NAME, view.getMapControl()); |
31 |
|
32 |
registerIcons(); |
33 |
} |
34 |
|
35 |
private void registerIcons() { |
36 |
IconThemeHelper.registerIcon("action", "symmetry", this); |
37 |
} |
38 |
|
39 |
public boolean isEnabled() { |
40 |
EditingServiceInfo SymmetryInfo; |
41 |
try {
|
42 |
SymmetryInfo = manager.getServiceInfo(SymmetryEditingProviderFactory.PROVIDER_NAME); |
43 |
DefaultViewPanel view = getActiveView(); |
44 |
FLyrVect layer = getActiveLayer(view); |
45 |
|
46 |
int[] supportedTypes = SymmetryInfo.getSupportedPrimitiveGeometryTypes(); |
47 |
GeometryType[] supportedGeoTypes = loadGeometryTypes(supportedTypes);
|
48 |
|
49 |
if (isApplicable(supportedGeoTypes, layer.getShapeType())) {
|
50 |
return true; |
51 |
} |
52 |
|
53 |
return false; |
54 |
|
55 |
} |
56 |
catch (ServiceException e1) {
|
57 |
// TODO Auto-generated catch block
|
58 |
e1.printStackTrace(); |
59 |
} |
60 |
catch (ReadException e) {
|
61 |
// TODO Auto-generated catch block
|
62 |
e.printStackTrace(); |
63 |
} |
64 |
return false; |
65 |
} |
66 |
|
67 |
public boolean isVisible() { |
68 |
DefaultViewPanel view = getActiveView(); |
69 |
if (view != null) { |
70 |
FLyrVect layer = getActiveLayer(view); |
71 |
if (layer != null && layer.isEditing()) { |
72 |
return true; |
73 |
} |
74 |
} |
75 |
return false; |
76 |
} |
77 |
|
78 |
} |