gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / infobypoint / InfoByRasterPointExtension.java @ 1148
History | View | Annotate | Download (3.72 KB)
1 |
package org.gvsig.raster.tools.app.basic.tool.infobypoint; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
|
5 |
import javax.swing.JOptionPane; |
6 |
|
7 |
import org.gvsig.andami.PluginServices; |
8 |
import org.gvsig.andami.plugins.Extension; |
9 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
10 |
import org.gvsig.app.project.documents.view.ViewDocument; |
11 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
12 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
13 |
import org.gvsig.fmap.mapcontext.MapContext; |
14 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
15 |
import org.gvsig.fmap.mapcontrol.MapControl; |
16 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
17 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
18 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
19 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
20 |
import org.gvsig.raster.tools.app.basic.tool.infobypoint.gui.InfoByPointDataModel; |
21 |
import org.gvsig.raster.tools.app.basic.tool.infobypoint.viewtool.InfoByPixelPointListener; |
22 |
|
23 |
public class InfoByRasterPointExtension extends Extension { |
24 |
|
25 |
public InfoByRasterPointExtension() {
|
26 |
|
27 |
} |
28 |
|
29 |
/*
|
30 |
* (non-Javadoc)
|
31 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
32 |
*/
|
33 |
public void execute(String actionCommand) { |
34 |
if(actionCommand.compareTo("INFO_BY_PIXEL") == 0) { |
35 |
MainInfoByPointDialog dialog = new MainInfoByPointDialog();
|
36 |
InfoByPointDataModel model = dialog.getInfoByPointDataModel(); |
37 |
|
38 |
IWindow theView = PluginServices.getMDIManager().getActiveWindow(); |
39 |
if(!(theView instanceof AbstractViewPanel)) { |
40 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this.getClass(), "window_not_valid")); |
41 |
return;
|
42 |
} |
43 |
MapControl mapCtrl = ((AbstractViewPanel)theView).getMapControl(); |
44 |
StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
45 |
InfoByPixelPointListener ibpl = new InfoByPixelPointListener(mapCtrl, model);
|
46 |
mapCtrl.addBehavior("infoByRasterPoint", new Behavior[]{new PointBehavior(ibpl), |
47 |
new MouseMovementBehavior(sbl)});
|
48 |
mapCtrl.setTool("infoByRasterPoint");
|
49 |
|
50 |
model.setARGB(0, 255, 125, 110); |
51 |
model.setCMYK(new double[]{54, 254, 121, 190}); |
52 |
model.setHSL(234.3, 125.5, 110.3); |
53 |
model.setBandValues(new double[]{4.53, 2.24, 67.7, 67.87}); |
54 |
model.setNumberOfBands(4);
|
55 |
model.setPixelPoint(100, 105); |
56 |
model.setViewPoint(305, 405); |
57 |
model.setWorldPoint(20554523.32, 19362125.23); |
58 |
model.setLayerList(new String[]{ |
59 |
"Esta_es_la_capa_numero_uno_de_la_lista_de_capas.jpg",
|
60 |
"Esta_es_la_capa_segunda_de_la_lista_de_capas_del_info_by_point.jpg"});
|
61 |
dialog.updateDataModel(); |
62 |
PluginServices.getMDIManager().addWindow(dialog); |
63 |
} |
64 |
} |
65 |
|
66 |
/*
|
67 |
* (non-Javadoc)
|
68 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled()
|
69 |
*/
|
70 |
@SuppressWarnings("deprecation") |
71 |
public boolean isEnabled() { |
72 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
73 |
if (f == null) |
74 |
return false; |
75 |
if (f instanceof AbstractViewPanel) { |
76 |
AbstractViewPanel vista = (AbstractViewPanel) f; |
77 |
ViewDocument model = vista.getModel(); |
78 |
MapContext mapa = model.getMapContext(); |
79 |
FLayers layers = mapa.getLayers(); |
80 |
for (int i = 0; i < layers.getLayersCount(); i++) |
81 |
if (layers.getLayer(i) instanceof FLyrRaster) |
82 |
return true; |
83 |
} |
84 |
return false; |
85 |
} |
86 |
|
87 |
/*
|
88 |
* (non-Javadoc)
|
89 |
* @see org.gvsig.andami.plugins.IExtension#isVisible()
|
90 |
*/
|
91 |
public boolean isVisible() { |
92 |
return isEnabled();
|
93 |
} |
94 |
|
95 |
/*
|
96 |
* (non-Javadoc)
|
97 |
* @see org.gvsig.andami.plugins.IExtension#initialize()
|
98 |
*/
|
99 |
public void initialize() { |
100 |
registerIcons(); |
101 |
} |
102 |
|
103 |
private void registerIcons() { |
104 |
PluginServices.getIconTheme().registerDefault( |
105 |
"info-by-pixel",
|
106 |
getClass().getClassLoader().getResource("images/infoByRasterPoint.png")
|
107 |
); |
108 |
} |
109 |
} |