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