|
1
|
import org.gvsig.andami.PluginServices;
|
|
2
|
import org.gvsig.andami.plugins.Extension;
|
|
3
|
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
|
|
4
|
import org.gvsig.fmap.mapcontrol.MapControlLocator;
|
|
5
|
import org.gvsig.fmap.mapcontrol.MapControlManager;
|
|
6
|
import org.gvsig.fmap.mapcontrol.impl.DefaultMapControlManager;
|
|
7
|
import org.gvsig.utils.console.JConsole;
|
|
8
|
import es.udc.lbd.giseiel.editing.CADExtension;
|
|
9
|
import es.udc.lbd.giseiel.editing.EditionUtilities;
|
|
10
|
import es.udc.lbd.giseiel.editing.gui.cad.snapping.EIELFinalPointSnapper;
|
|
11
|
import es.udc.lbd.giseiel.editing.gui.cad.snapping.EIELNearestPointSnapper;
|
|
12
|
|
|
13
|
/**
|
|
14
|
* Extensi?n que gestiona la activaci?n y desactivaci?n de los snappers
|
|
15
|
*
|
|
16
|
* @author Jose Ignacio Lamas
|
|
17
|
* Leticia Riestra Ainsua
|
|
18
|
*/
|
|
19
|
public class SnappersExtension extends Extension {
|
|
20
|
|
|
21
|
private boolean activated;
|
|
22
|
|
|
23
|
/**
|
|
24
|
* @see com.iver.andami.plugins.IExtension#initialize()
|
|
25
|
*/
|
|
26
|
public void initialize() {
|
|
27
|
activated = true;
|
|
28
|
|
|
29
|
if (MapControlLocator.getMapControlManager() == null){
|
|
30
|
MapControlLocator.registerMapControlManager(DefaultMapControlManager.class);
|
|
31
|
}
|
|
32
|
MapControlManager mapControlManager = MapControlLocator.getMapControlManager();
|
|
33
|
|
|
34
|
//Borramos la lista de snapper para as? poder poner los nuestros arriba con la
|
|
35
|
//mayor prioridad
|
|
36
|
((DefaultMapControlManager)mapControlManager).clearSnappers();
|
|
37
|
|
|
38
|
//Le a?adimos los snapper que queremos
|
|
39
|
mapControlManager.registerSnapper("EIELFinalPointSnapper", EIELFinalPointSnapper.class);
|
|
40
|
mapControlManager.registerSnapper("EIELNearestPointSnapper", EIELNearestPointSnapper.class);
|
|
41
|
mapControlManager.registerSnapper("FinalPointSnapper", FinalPointSnapper.class);
|
|
42
|
mapControlManager.registerSnapper("NearestPointSnapper", NearestPointSnapper.class);
|
|
43
|
mapControlManager.registerSnapper("PixelSnapper", PixelSnapper.class);
|
|
44
|
mapControlManager.registerSnapper("CentralPointSnapper", CentralPointSnapper.class);
|
|
45
|
mapControlManager.registerSnapper("QuadrantPointSnapper", QuadrantPointSnapper.class);
|
|
46
|
//mapControlManager.registerSnapper("InsertPointSnapper", new InsertPointSnapper.class);
|
|
47
|
mapControlManager.registerSnapper("IntersectionPointSnapper", IntersectionPointSnapper.class);
|
|
48
|
mapControlManager.registerSnapper("MediumPointSnapper", MediumPointSnapper.class);
|
|
49
|
mapControlManager.registerSnapper("PerpendicularPointSnapper", PerpendicularPointSnapper.class);
|
|
50
|
mapControlManager.registerSnapper("TangentPointSnapper", TangentPointSnapper.class);
|
|
51
|
|
|
52
|
}
|
|
53
|
|
|
54
|
/**
|
|
55
|
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
|
56
|
*/
|
|
57
|
public void execute(String s) {
|
|
58
|
CADExtension.initFocus();
|
|
59
|
|
|
60
|
if (s.equals("_snappers")) {
|
|
61
|
|
|
62
|
if (MapControlLocator.getMapControlManager() == null){
|
|
63
|
MapControlLocator.registerMapControlManager(DefaultMapControlManager.class);
|
|
64
|
}
|
|
65
|
MapControlManager mapControlManager = MapControlLocator.getMapControlManager();
|
|
66
|
|
|
67
|
String message = new String();
|
|
68
|
|
|
69
|
if(activated){
|
|
70
|
//Borramos la lista de snapper
|
|
71
|
((DefaultMapControlManager)mapControlManager).clearSnappers();
|
|
72
|
|
|
73
|
activated = false;
|
|
74
|
message = PluginServices.getText(this, "snappers_desactivated");
|
|
75
|
}else{
|
|
76
|
//Borramos la lista de snapper para as? poder poner los nuestros arriba con la
|
|
77
|
//mayor prioridad
|
|
78
|
((DefaultMapControlManager)mapControlManager).clearSnappers();
|
|
79
|
|
|
80
|
//Le a?adimos los snapper que queremos
|
|
81
|
mapControlManager.registerSnapper("EIELFinalPointSnapper", EIELFinalPointSnapper.class);
|
|
82
|
mapControlManager.registerSnapper("EIELNearestPointSnapper", EIELNearestPointSnapper.class);
|
|
83
|
mapControlManager.registerSnapper("FinalPointSnapper", FinalPointSnapper.class);
|
|
84
|
mapControlManager.registerSnapper("NearestPointSnapper", NearestPointSnapper.class);
|
|
85
|
mapControlManager.registerSnapper("PixelSnapper", PixelSnapper.class);
|
|
86
|
mapControlManager.registerSnapper("CentralPointSnapper", CentralPointSnapper.class);
|
|
87
|
mapControlManager.registerSnapper("QuadrantPointSnapper", QuadrantPointSnapper.class);
|
|
88
|
//mapControlManager.registerSnapper("InsertPointSnapper", new InsertPointSnapper.class);
|
|
89
|
mapControlManager.registerSnapper("IntersectionPointSnapper", IntersectionPointSnapper.class);
|
|
90
|
mapControlManager.registerSnapper("MediumPointSnapper", MediumPointSnapper.class);
|
|
91
|
mapControlManager.registerSnapper("PerpendicularPointSnapper", PerpendicularPointSnapper.class);
|
|
92
|
mapControlManager.registerSnapper("TangentPointSnapper", TangentPointSnapper.class);
|
|
93
|
|
|
94
|
activated = true;
|
|
95
|
message = PluginServices.getText(this, "snappers_activated");
|
|
96
|
}
|
|
97
|
|
|
98
|
//Escribimos en la consola si esta activado el snapper
|
|
99
|
if (PluginServices.getMDIManager().getActiveWindow() instanceof DefaultViewPanel)
|
|
100
|
{
|
|
101
|
DefaultViewPanel vista = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow();
|
|
102
|
vista.getConsolePanel().addText("\n" +message, JConsole.INSERT);
|
|
103
|
}
|
|
104
|
}
|
|
105
|
|
|
106
|
}
|
|
107
|
|
|
108
|
/**
|
|
109
|
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
|
110
|
*/
|
|
111
|
public boolean isEnabled() {
|
|
112
|
|
|
113
|
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) {
|
|
114
|
if (CADExtension.getEditionManager().getActiveLayerEdited()==null){
|
|
115
|
return false;
|
|
116
|
}
|
|
117
|
return true;
|
|
118
|
}
|
|
119
|
|
|
120
|
return false;
|
|
121
|
}
|
|
122
|
|
|
123
|
/**
|
|
124
|
* @see com.iver.andami.plugins.IExtension#isVisible()
|
|
125
|
*/
|
|
126
|
public boolean isVisible() {
|
|
127
|
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE)
|
|
128
|
return true;
|
|
129
|
return false;
|
|
130
|
}
|
|
131
|
}
|