Revision 42501 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.snapping.app/org.gvsig.snapping.app.mainplugin/src/main/java/org/gvsig/app/extension/SnappingExtension.java
SnappingExtension.java | ||
---|---|---|
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2007-2013 gvSIG Association. |
5 | 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.
|
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
|
9 |
* version. |
|
10 | 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.
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14 |
* details. |
|
15 | 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. |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
20 | 19 |
* |
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
23 | 22 |
*/ |
24 | 23 |
package org.gvsig.app.extension; |
25 | 24 |
|
... | ... | |
47 | 46 |
|
48 | 47 |
/** |
49 | 48 |
* Extension for config the snapping |
49 |
* |
|
50 | 50 |
* @author fdiaz |
51 | 51 |
* |
52 | 52 |
*/ |
53 |
public class SnappingExtension extends Extension{ |
|
53 |
public class SnappingExtension extends Extension {
|
|
54 | 54 |
|
55 | 55 |
private static MapControlManager mapControlManager = MapControlLocator.getMapControlManager(); |
56 | 56 |
|
... | ... | |
61 | 61 |
|
62 | 62 |
for (int n = 0; n < mapControlManager.getSnapperCount(); n++) { |
63 | 63 |
ISnapper snp = (ISnapper) mapControlManager.getSnapperAt(n); |
64 |
String nameClass=snp.getClass().getName();
|
|
65 |
nameClass=nameClass.substring(nameClass.lastIndexOf('.')+1);
|
|
66 |
snp.setEnabled((Boolean)getPlugin().getPluginProperties().getDynValue("snapperActivated"+nameClass));
|
|
67 |
snp.setPriority((Integer)getPlugin().getPluginProperties().getDynValue("snapperPriority"+nameClass));
|
|
64 |
String nameClass = snp.getClass().getName();
|
|
65 |
nameClass = nameClass.substring(nameClass.lastIndexOf('.') + 1);
|
|
66 |
snp.setEnabled((Boolean) getPlugin().getPluginProperties().getDynValue("snapperActivated" + nameClass));
|
|
67 |
snp.setPriority((Integer) getPlugin().getPluginProperties().getDynValue("snapperPriority" + nameClass));
|
|
68 | 68 |
} |
69 | 69 |
|
70 |
Integer snapTolerance =
|
|
71 |
(Integer) getPlugin().getPluginProperties().getDynValue("snapTolerance"); |
|
70 |
Integer snapTolerance |
|
71 |
= (Integer) getPlugin().getPluginProperties().getDynValue("snapTolerance");
|
|
72 | 72 |
mapControlManager.setTolerance(snapTolerance.intValue()); |
73 | 73 |
|
74 |
Boolean applySnappers =
|
|
75 |
(Boolean) getPlugin().getPluginProperties().getDynValue("applySnappers"); |
|
74 |
Boolean applySnappers |
|
75 |
= (Boolean) getPlugin().getPluginProperties().getDynValue("applySnappers");
|
|
76 | 76 |
//TODO: si se a?ade al MapControlManager para habilitar/deshabilitar de manera global los snappers activos, invocarlo aqu? |
77 | 77 |
// mapControlManager.applySnappers(applySnappers); |
78 | 78 |
|
... | ... | |
81 | 81 |
|
82 | 82 |
} |
83 | 83 |
|
84 |
@Override
|
|
85 |
public void postInitialize() {
|
|
86 |
ExtensionPointManager extensionPoints =
|
|
87 |
ToolsLocator.getExtensionPointManager(); |
|
84 |
@Override
|
|
85 |
public void postInitialize() {
|
|
86 |
ExtensionPointManager extensionPoints |
|
87 |
= ToolsLocator.getExtensionPointManager();
|
|
88 | 88 |
ExtensionPoint ep = extensionPoints.add("AplicationPreferences", ""); |
89 | 89 |
ep.append("Snapping", "", new SnapConfigPage()); |
90 | 90 |
ep.append("Grid", "", new GridPage()); |
91 | 91 |
} |
92 | 92 |
|
93 |
private void registerIcons(){
|
|
94 |
IconThemeHelper.registerIcon("preferences", "preferences-snapper", this);
|
|
93 |
private void registerIcons() {
|
|
94 |
IconThemeHelper.registerIcon("preferences", "preferences-snapper", this);
|
|
95 | 95 |
IconThemeHelper.registerIcon("preferences", "grid-preferences", this); |
96 | 96 |
IconThemeHelper.registerIcon("actions", "enable-snapping", this); |
97 | 97 |
IconThemeHelper.registerIcon("actions", "disable-snapping", this); |
98 |
}
|
|
98 |
}
|
|
99 | 99 |
|
100 |
public void execute(String actionCommand) {
|
|
101 |
}
|
|
100 |
public void execute(String actionCommand) {
|
|
101 |
}
|
|
102 | 102 |
|
103 |
public boolean isEnabled() {
|
|
104 |
return true;
|
|
105 |
}
|
|
103 |
public boolean isEnabled() {
|
|
104 |
return true;
|
|
105 |
}
|
|
106 | 106 |
|
107 | 107 |
public boolean isVisible() { |
108 | 108 |
|
109 |
org.gvsig.andami.ui.mdiManager.IWindow f =
|
|
110 |
PluginServices.getMDIManager().getActiveWindow(); |
|
109 |
org.gvsig.andami.ui.mdiManager.IWindow f |
|
110 |
= PluginServices.getMDIManager().getActiveWindow();
|
|
111 | 111 |
|
112 | 112 |
if (f != null && f instanceof DefaultViewPanel) { |
113 | 113 |
DefaultViewPanel vista = (DefaultViewPanel) f; |
... | ... | |
125 | 125 |
while (iter.hasNext()) { |
126 | 126 |
capa = iter.nextLayer(); |
127 | 127 |
if (capa instanceof FLyrVect && capa.isActive() |
128 |
&& capa.isAvailable()) { |
|
128 |
&& capa.isAvailable()) {
|
|
129 | 129 |
numActiveVectorial++; |
130 |
if (capa.isEditing()) |
|
130 |
if (capa.isEditing()) {
|
|
131 | 131 |
numActiveVectorialEditable++; |
132 |
} |
|
132 | 133 |
} |
133 | 134 |
|
134 | 135 |
} |
... | ... | |
140 | 141 |
return false; |
141 | 142 |
} |
142 | 143 |
|
143 |
} |
|
144 |
} |
Also available in: Unified diff