svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / ViewControls.java @ 652
History | View | Annotate | Download (5.37 KB)
1 |
/*
|
---|---|
2 |
* Created on 20-feb-2004
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
package com.iver.cit.gvsig; |
8 |
|
9 |
import org.apache.log4j.Logger; |
10 |
|
11 |
import com.iver.andami.PluginServices; |
12 |
import com.iver.andami.messages.NotificationManager; |
13 |
import com.iver.andami.plugins.Extension; |
14 |
import com.iver.cit.gvsig.fmap.DriverException; |
15 |
import com.iver.cit.gvsig.fmap.FMap; |
16 |
import com.iver.cit.gvsig.fmap.NewMapControl; |
17 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
18 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
19 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
20 |
import com.iver.cit.gvsig.gui.DefaultSelectionByThemeDataSource; |
21 |
import com.iver.cit.gvsig.gui.Encuadrator; |
22 |
import com.iver.cit.gvsig.gui.ExtentListSelectorModel; |
23 |
import com.iver.cit.gvsig.gui.FPanelExtentSelector; |
24 |
import com.iver.cit.gvsig.gui.FPanelLocConfig; |
25 |
import com.iver.cit.gvsig.gui.MySelectionByThemeListener; |
26 |
import com.iver.cit.gvsig.gui.SelectionByTheme; |
27 |
import com.iver.cit.gvsig.gui.View; |
28 |
import com.iver.cit.gvsig.project.ViewProperties; |
29 |
import com.iver.cit.gvsig.project.castor.Project; |
30 |
import com.iver.cit.gvsig.project.castor.ProjectExtent; |
31 |
import com.iver.cit.gvsig.project.castor.ProjectView; |
32 |
//import com.iver.utiles.FPanelExtentSelector;
|
33 |
|
34 |
|
35 |
/**
|
36 |
* DOCUMENT ME!
|
37 |
*
|
38 |
* @author vcn
|
39 |
*/
|
40 |
public class ViewControls implements Extension { |
41 |
private static Logger logger = Logger.getLogger(ViewControls.class.getName()); |
42 |
|
43 |
/**
|
44 |
* DOCUMENT ME!
|
45 |
*
|
46 |
* @param s DOCUMENT ME!
|
47 |
*/
|
48 |
public void execute(String s) { |
49 |
View vista = (View) PluginServices.getMDIManager().getActiveView(); |
50 |
ProjectView model=vista.getModel(); |
51 |
FMap mapa = model.getMapContext(); |
52 |
NewMapControl mapCtrl = vista.getMapControl(); |
53 |
logger.debug("Comand : " + s);
|
54 |
|
55 |
if (s.compareTo("FULL") == 0) { |
56 |
try {
|
57 |
mapa.getViewPort().setExtent(mapa.getLayers().getFullExtent()); |
58 |
mapCtrl.drawMap(); |
59 |
} catch (DriverException e) {
|
60 |
NotificationManager.addError("Error obteniendo el full extent", e);
|
61 |
} |
62 |
} else if (s.compareTo("SELECTIONBYSHAPE") == 0) { |
63 |
SelectionByTheme dlg = new SelectionByTheme();
|
64 |
FLayer[] layers = mapa.getLayers().getActives();
|
65 |
int count = 0; |
66 |
dlg.setModel(layers); |
67 |
dlg.setDataSource(new DefaultSelectionByThemeDataSource(mapa.getLayers()));
|
68 |
dlg.addSelectionListener(new MySelectionByThemeListener(mapa.getLayers()));
|
69 |
PluginServices.getMDIManager().addView(dlg); |
70 |
|
71 |
} else if (s.compareTo("ENCUADRE") == 0) { |
72 |
FPanelExtentSelector l = new FPanelExtentSelector();
|
73 |
|
74 |
ProjectExtension p = (ProjectExtension) PluginServices.getExtension(com.iver.cit.gvsig.ProjectExtension.class); |
75 |
Project project = p.getProject(); |
76 |
ExtentListSelectorModel modelo = new ExtentListSelectorModel(project);
|
77 |
ProjectExtent[] extents = project.getExtents();
|
78 |
project.addPropertyChangeListener(modelo); |
79 |
l.setModel(modelo); |
80 |
l.addSelectionListener(new Encuadrator(project,
|
81 |
mapa, vista)); |
82 |
PluginServices.getMDIManager().addView(l); |
83 |
} else if (s.compareTo("INFO") == 0) { |
84 |
mapCtrl.setTool("info");
|
85 |
} else if (s.compareTo("CONFIG_LOCATOR") == 0) { |
86 |
//Set up the map overview
|
87 |
FPanelLocConfig m_panelLoc = new FPanelLocConfig(vista.getMapOverview());
|
88 |
PluginServices.getMDIManager().addView(m_panelLoc); |
89 |
m_panelLoc.setPreferredSize(m_panelLoc.getSize()); |
90 |
|
91 |
} else if (s.compareTo("PAN") == 0) { |
92 |
mapCtrl.setTool("pan");
|
93 |
// vista.m_MapControl.setTool(MapControl.PAN);
|
94 |
} else if (s.compareTo("ZOOM_IN") == 0) { |
95 |
mapCtrl.setTool("zoomIn");
|
96 |
} else if (s.compareTo("ZOOM_OUT") == 0) { |
97 |
mapCtrl.setTool("zoomOut");
|
98 |
// vista.m_MapControl.setTool(MapControl.ZOOM_MENOS);
|
99 |
} else if (s.compareTo("ZOOM_SELECT") == 0) { |
100 |
// vista.m_MapControl.setZoomSelect();
|
101 |
} else if (s.compareTo("MEDICION") == 0) { |
102 |
mapCtrl.setTool("medicion");
|
103 |
// vista.m_MapControl.setTool(MapControl.MEDICION);
|
104 |
} else if (s.compareTo("AREA") == 0) { |
105 |
mapCtrl.setTool("area");
|
106 |
// vista.m_MapControl.setTool(MapControl.AREA);
|
107 |
} else if (s.compareTo("SELRECT") == 0) { |
108 |
mapCtrl.setTool("rectSelection");
|
109 |
} else if (s.compareTo("SELPOINT") == 0) { |
110 |
mapCtrl.setTool("pointSelection");
|
111 |
} else if (s.compareTo("PROPERTIES") == 0) { |
112 |
ViewProperties viewProperties = new ViewProperties(model);
|
113 |
PluginServices.getMDIManager().addView(viewProperties); |
114 |
} |
115 |
} |
116 |
|
117 |
/**
|
118 |
* @see com.iver.mdiApp.plugins.Extension#isVisible()
|
119 |
*/
|
120 |
public boolean isVisible() { |
121 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager().getActiveView(); |
122 |
|
123 |
if (f == null) { |
124 |
return false; |
125 |
} |
126 |
|
127 |
if (f.getClass() == View.class) { |
128 |
View vista = (View) f; |
129 |
ProjectView model=vista.getModel(); |
130 |
FMap mapa = model.getMapContext(); |
131 |
|
132 |
View v = (View) f; |
133 |
|
134 |
return mapa.getLayers().getLayersCount() > 0; |
135 |
} else {
|
136 |
return false; |
137 |
} |
138 |
} |
139 |
|
140 |
/**
|
141 |
* @see com.iver.andami.plugins.Extension#inicializar()
|
142 |
*/
|
143 |
public void inicializar() { |
144 |
} |
145 |
|
146 |
/**
|
147 |
* @see com.iver.andami.plugins.Extension#isEnabled()
|
148 |
*/
|
149 |
public boolean isEnabled() { |
150 |
return true; |
151 |
} |
152 |
} |