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