Revision 21460
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.232/org.gvsig.raster.tools.app.basic/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
|
|
26 |
<dependencySets> |
|
27 |
<dependencySet> |
|
28 |
<useProjectArtifact>false</useProjectArtifact> |
|
29 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
30 |
<outputDirectory>lib</outputDirectory> |
|
31 |
<includes> |
|
32 |
<include>org.gvsig:org.gvsig.raster.tools.app.basic:jar</include> |
|
33 |
<include>org.gvsig:org.gvsig.raster.tools.algorithm.layerdatatype:jar</include> |
|
34 |
<include>org.gvsig:org.gvsig.raster.tools.algorithm.saveraster:jar</include> |
|
35 |
<include>org.gvsig:org.gvsig.raster.tools.algorithm.swing.api:jar</include> |
|
36 |
<include>org.gvsig:org.gvsig.raster.tools.algorithm.swing.impl:jar</include> |
|
37 |
<include>org.gvsig:org.gvsig.raster.tools.toolbox.algorithm:jar</include> |
|
38 |
</includes> |
|
39 |
</dependencySet> |
|
40 |
</dependencySets> |
|
41 |
</assembly> |
|
0 | 42 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.232/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/SystemGCExtension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.tools.app.basic; |
|
23 |
|
|
24 |
import org.gvsig.andami.plugins.Extension; |
|
25 |
|
|
26 |
|
|
27 |
/** |
|
28 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
29 |
*/ |
|
30 |
public class SystemGCExtension extends Extension { |
|
31 |
|
|
32 |
public void execute(String actionCommand) { |
|
33 |
System.gc(); |
|
34 |
} |
|
35 |
|
|
36 |
public void initialize() { |
|
37 |
|
|
38 |
} |
|
39 |
|
|
40 |
public boolean isEnabled() { |
|
41 |
return true; |
|
42 |
} |
|
43 |
|
|
44 |
public boolean isVisible() { |
|
45 |
return true; |
|
46 |
} |
|
47 |
|
|
48 |
} |
|
0 | 49 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.232/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/MainWindow.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2011-2012 Prodevelop S.L |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
*/ |
|
21 |
package org.gvsig.raster.tools.app.basic; |
|
22 |
|
|
23 |
import java.awt.GridBagConstraints; |
|
24 |
import java.awt.GridBagLayout; |
|
25 |
import java.awt.event.ActionEvent; |
|
26 |
import java.awt.event.ActionListener; |
|
27 |
|
|
28 |
import javax.swing.JComponent; |
|
29 |
|
|
30 |
import org.gvsig.andami.PluginServices; |
|
31 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
32 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
33 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
34 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
|
35 |
|
|
36 |
|
|
37 |
/** |
|
38 |
* Basic frame for a gvSIG <code>IWindow</code> object. This frame adds buttons |
|
39 |
* of Cancel, Accept and others. |
|
40 |
* |
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
42 |
*/ |
|
43 |
public class MainWindow extends DefaultButtonsPanel implements IWindow, ActionListener { |
|
44 |
|
|
45 |
private static final long serialVersionUID = -4401123724140025094L; |
|
46 |
private ActionListener listener = null; |
|
47 |
private WindowInfo info = null; |
|
48 |
|
|
49 |
private Object profile = WindowInfo.EDITOR_PROFILE; |
|
50 |
|
|
51 |
public MainWindow(JComponent panel, JComponent preview, String title, int w, int h, ActionListener actionListener) { |
|
52 |
this.listener = actionListener; |
|
53 |
|
|
54 |
setLayout(new GridBagLayout()); |
|
55 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
56 |
gbc.fill = GridBagConstraints.BOTH; |
|
57 |
gbc.weightx = 1; |
|
58 |
gbc.weighty = 1; |
|
59 |
add(panel, gbc); |
|
60 |
|
|
61 |
if(preview != null) { |
|
62 |
gbc.anchor = GridBagConstraints.NORTH; |
|
63 |
gbc.fill = GridBagConstraints.NONE; |
|
64 |
gbc.weightx = 0; |
|
65 |
gbc.weighty = 0; |
|
66 |
gbc.gridx = 1; |
|
67 |
add(preview, gbc); |
|
68 |
} |
|
69 |
|
|
70 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(this); |
|
71 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).addActionListener(this); |
|
72 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(this); |
|
73 |
|
|
74 |
info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE); |
|
75 |
info.setTitle(title); |
|
76 |
info.setWidth(w); |
|
77 |
info.setHeight(h); |
|
78 |
} |
|
79 |
|
|
80 |
public WindowInfo getWindowInfo() { |
|
81 |
return info; |
|
82 |
} |
|
83 |
|
|
84 |
public Object getWindowProfile() { |
|
85 |
return profile; |
|
86 |
} |
|
87 |
|
|
88 |
public void actionPerformed(ActionEvent e) { |
|
89 |
if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT)) { |
|
90 |
listener.actionPerformed(e); |
|
91 |
PluginServices.getMDIManager().closeWindow(this); |
|
92 |
} |
|
93 |
|
|
94 |
if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY)) { |
|
95 |
listener.actionPerformed(e); |
|
96 |
} |
|
97 |
|
|
98 |
if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL)) { |
|
99 |
PluginServices.getMDIManager().closeWindow(this); |
|
100 |
} |
|
101 |
} |
|
102 |
} |
|
0 | 103 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.232/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/RasterExtension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.tools.app.basic; |
|
23 |
|
|
24 |
import java.util.ArrayList; |
|
25 |
import java.util.prefs.Preferences; |
|
26 |
|
|
27 |
import org.gvsig.andami.IconThemeHelper; |
|
28 |
import org.gvsig.andami.PluginServices; |
|
29 |
import org.gvsig.andami.plugins.Extension; |
|
30 |
import org.gvsig.andami.plugins.IExtensionQueryByAction; |
|
31 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
32 |
import org.gvsig.app.ApplicationLocator; |
|
33 |
import org.gvsig.app.ApplicationManager; |
|
34 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
35 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
36 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
|
37 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
|
38 |
import org.gvsig.fmap.dal.coverage.RasterLibrary; |
|
39 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
40 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
41 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
42 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
43 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
44 |
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary; |
|
45 |
import org.gvsig.raster.fmap.FmapRasterLibrary; |
|
46 |
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster; |
|
47 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
48 |
import org.gvsig.raster.mainplugin.config.Configuration; |
|
49 |
import org.gvsig.raster.mainplugin.config.ConfigurationEvent; |
|
50 |
import org.gvsig.raster.mainplugin.config.ConfigurationListener; |
|
51 |
import org.gvsig.raster.tools.app.basic.raster.gui.preference.RasterPreferences; |
|
52 |
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareDataStoreParametersRaw; |
|
53 |
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareDataStoreParametersVTR; |
|
54 |
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareLayerAskWritableDirectory; |
|
55 |
import org.gvsig.raster.tools.app.basic.raster.process.ClippingProcess; |
|
56 |
import org.gvsig.raster.tools.app.basic.tool.analysisview.ViewRasterAnalysisTocMenuEntry; |
|
57 |
import org.gvsig.raster.tools.app.basic.tool.clip.ClippingTocMenuEntry; |
|
58 |
import org.gvsig.raster.tools.app.basic.tool.colortable.ColorTableTocMenuEntry; |
|
59 |
import org.gvsig.raster.tools.app.basic.tool.colortable.ui.library.RasterColorTablesFactory; |
|
60 |
import org.gvsig.raster.tools.app.basic.tool.enhanced.EnhancedTocMenuEntry; |
|
61 |
import org.gvsig.raster.tools.app.basic.tool.filter.FilterTocMenuEntry; |
|
62 |
import org.gvsig.raster.tools.app.basic.tool.geolocation.GeoLocationTocMenuEntry; |
|
63 |
import org.gvsig.raster.tools.app.basic.tool.histogram.HistogramTocMenuEntry; |
|
64 |
import org.gvsig.raster.tools.app.basic.tool.infobypoint.InfoByRasterPointTocMenuEntry; |
|
65 |
import org.gvsig.raster.tools.app.basic.tool.layerdatatype.LayerDatatypeTocMenuEntry; |
|
66 |
import org.gvsig.raster.tools.app.basic.tool.multiresolution.ZoomResolutionLevelTocMenuEntry; |
|
67 |
import org.gvsig.raster.tools.app.basic.tool.overview.OverviewsTocMenuEntry; |
|
68 |
import org.gvsig.raster.tools.app.basic.tool.properties.panel.EnhancedPanel; |
|
69 |
import org.gvsig.raster.tools.app.basic.tool.properties.panel.GeneralPanel; |
|
70 |
import org.gvsig.raster.tools.app.basic.tool.properties.panel.InfoPanel; |
|
71 |
import org.gvsig.raster.tools.app.basic.tool.properties.panel.TransparencyPanel; |
|
72 |
import org.gvsig.raster.tools.app.basic.tool.rasterresolution.ZoomPixelCursorTocMenuEntry; |
|
73 |
import org.gvsig.raster.tools.app.basic.tool.roi.ROIManagerTocMenuEntry; |
|
74 |
import org.gvsig.raster.tools.app.basic.tool.saveas.SaveAsTocMenuEntry; |
|
75 |
import org.gvsig.raster.tools.app.basic.tool.saveviewtoraster.SaveViewToRasterTocMenuEntry; |
|
76 |
import org.gvsig.raster.tools.app.basic.tool.selectrasterlayer.SelectLayerTocMenuEntry; |
|
77 |
import org.gvsig.raster.tools.app.basic.tool.setviewprojection.SetViewProjectionTocMenuEntry; |
|
78 |
import org.gvsig.raster.tools.app.basic.tool.viewexport.SaveViewToImageTocMenuEntry; |
|
79 |
import org.gvsig.raster.tools.app.basic.toolbox.ToolboxRasterToolsLoader; |
|
80 |
import org.gvsig.tools.ToolsLocator; |
|
81 |
import org.gvsig.tools.extensionpoint.ExtensionBuilder; |
|
82 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
83 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
84 |
|
|
85 |
|
|
86 |
/** |
|
87 |
* Extensi?n que adapta a FMap y gvSIG la nueva implementaci?n de raster. Para |
|
88 |
* el cuadro de Propiedades de visualizaci?n de raster contiene el contenedor |
|
89 |
* base se registran la entrada del men? del TOC y los paneles en el cuadro. |
|
90 |
* Para la parte de FMap contiene una nueva capa raster y los drivers |
|
91 |
* necesarios. |
|
92 |
* |
|
93 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
94 |
*/ |
|
95 |
public class RasterExtension extends Extension implements ConfigurationListener, IExtensionQueryByAction { |
|
96 |
public static final String CLIPPING_PROCESS_LABEL = ClippingProcess.PROCESS_LABEL; |
|
97 |
|
|
98 |
/** |
|
99 |
* Indica si en el panel de preferencias se refresca automaticamente la vista |
|
100 |
* para mostrar los cambios |
|
101 |
*/ |
|
102 |
public static boolean autoRefreshView = true; |
|
103 |
|
|
104 |
private ExtensionPoint genericToolBarMenuExtensionPoint = null; |
|
105 |
|
|
106 |
public void execute(String actionCommand) { |
|
107 |
//Las entradas en GenericToolBarModule est?n registradas con la misma etiqueta que la del actionCommand |
|
108 |
//De esta forma pueden recuperarse los TocMenuEntry del punto de extensi?n y ejecutar la acci?n a |
|
109 |
//trav?s de este. |
|
110 |
ExtensionBuilder ext = getGenericToolBarMenuExtensionPoint().get(actionCommand).getBuilder(); |
|
111 |
if(ext != null && ext instanceof AbstractTocContextMenuAction) { |
|
112 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
|
113 |
if(w instanceof AbstractViewPanel) { |
|
114 |
FLayers lyrs = ((AbstractViewPanel)w).getMapControl().getMapContext().getLayers(); |
|
115 |
FLayer[] actives = lyrs.getActives(); |
|
116 |
((AbstractTocContextMenuAction)ext).execute(null, actives); |
|
117 |
} |
|
118 |
} |
|
119 |
} |
|
120 |
|
|
121 |
public void initialize() { |
|
122 |
// Asignamos la configuracion global a FlyrRasterSE |
|
123 |
DefaultFLyrRaster.setConfiguration(Configuration.getSingleton()); |
|
124 |
|
|
125 |
Configuration.addValueChangedListener(this); |
|
126 |
loadConfigurationValues(); |
|
127 |
|
|
128 |
registerIcons(); |
|
129 |
|
|
130 |
FmapRasterLibrary fmapRaster = new FmapRasterLibrary(); |
|
131 |
fmapRaster.initialize(); |
|
132 |
|
|
133 |
Preferences prefs = Preferences.userRoot().node("gvsig.foldering"); |
|
134 |
prefs.put("DataFolder", System.getProperty("user.home")); |
|
135 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
136 |
|
|
137 |
// Creaci?n del punto de extensi?n para registrar paneles en el cuadro de propiedades. |
|
138 |
if (!extensionPoints.has("RasterSEPropertiesDialog")) { |
|
139 |
ExtensionPoint point = extensionPoints.add("RasterSEPropertiesDialog"); |
|
140 |
point.setDescription("Raster Properties registrable panels (register instances of javax.swing.JPanel)"); |
|
141 |
} |
|
142 |
|
|
143 |
// A?adimos la configuracion de Raster a gvSIG |
|
144 |
|
|
145 |
ExtensionPoint point = extensionPoints.get("AplicationPreferences"); |
|
146 |
point.append("RasterPreferences", "", RasterPreferences.class); |
|
147 |
|
|
148 |
// A?adimos paneles al cuadro de propiedades. |
|
149 |
point = extensionPoints.get("RasterSEPropertiesDialog"); |
|
150 |
point.append("info", "", InfoPanel.class); |
|
151 |
point.append("general_panel", "", GeneralPanel.class); |
|
152 |
point.append("transparencia", "", TransparencyPanel.class); |
|
153 |
point.append("realce", "", EnhancedPanel.class); |
|
154 |
|
|
155 |
|
|
156 |
// A?adimos las entradas del men? del toc de raster |
|
157 |
point = extensionPoints.get("View_TocActions"); |
|
158 |
//point.append("RasterSEProperties", "Raster Properties", RasterPropertiesTocMenuEntry.getSingleton()); |
|
159 |
point.append("SaveAs", "Save as raster layer", SaveAsTocMenuEntry.getSingleton()); |
|
160 |
point.append("ZoomPixelCursor", "zoom to pixel resolution", ZoomPixelCursorTocMenuEntry.getSingleton()); |
|
161 |
point.append("ROI", "ROIs for a raster layer", ROIManagerTocMenuEntry.getSingleton()); |
|
162 |
point.append("Color table", "Color table for a raster layer", ColorTableTocMenuEntry.getSingleton()); |
|
163 |
point.append("Histogram", "Histogram of a raster layer", HistogramTocMenuEntry.getSingleton()); |
|
164 |
point.append("Overviews", "Build overviews", OverviewsTocMenuEntry.getSingleton()); |
|
165 |
|
|
166 |
ApplicationManager appGvSigMan = ApplicationLocator.getManager(); |
|
167 |
|
|
168 |
appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareLayerAskWritableDirectory()); |
|
169 |
appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareDataStoreParametersRaw()); |
|
170 |
appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareDataStoreParametersVTR()); |
|
171 |
|
|
172 |
appGvSigMan.registerColorTablesFactory(new RasterColorTablesFactory()); |
|
173 |
|
|
174 |
registerMenuElements(); |
|
175 |
registerProcesses(); |
|
176 |
} |
|
177 |
|
|
178 |
private void registerProcesses() { |
|
179 |
RasterBaseAlgorithmLibrary.register(CLIPPING_PROCESS_LABEL, ClippingProcess.class); |
|
180 |
ClippingProcess.registerParameters(); |
|
181 |
} |
|
182 |
|
|
183 |
/** |
|
184 |
* Registra los iconos a utilizar en andami. |
|
185 |
*/ |
|
186 |
private void registerIcons() { |
|
187 |
//Actions |
|
188 |
IconThemeHelper.registerIcon("action", "menu-layer-icon", this); |
|
189 |
IconThemeHelper.registerIcon("action", "menu-process-icon", this); |
|
190 |
IconThemeHelper.registerIcon("action", "menu-transgeo-icon", this); |
|
191 |
IconThemeHelper.registerIcon("action", "menu-raster-export", this); |
|
192 |
|
|
193 |
IconThemeHelper.registerIcon("action", "layer-modify-roi", this); |
|
194 |
IconThemeHelper.registerIcon("action", "layer-histogram", this); |
|
195 |
IconThemeHelper.registerIcon("action", "layer-color-table", this); |
|
196 |
IconThemeHelper.registerIcon("action", "layer-modify-overviews", this); |
|
197 |
IconThemeHelper.registerIcon("action", "layer-properties-raster", this); |
|
198 |
IconThemeHelper.registerIcon("action", "layer-filter-raster", this); |
|
199 |
IconThemeHelper.registerIcon("action", "layer-enhanced", this); |
|
200 |
IconThemeHelper.registerIcon("action", "view-raster-analysis", this); |
|
201 |
IconThemeHelper.registerIcon("action", "view-select-raster-layer", this); |
|
202 |
IconThemeHelper.registerIcon("action", "layer-geolocalization", this); |
|
203 |
IconThemeHelper.registerIcon("action", "tools-raster-reproject", this); |
|
204 |
IconThemeHelper.registerIcon("action", "view-export-georeferenced-raster", this); |
|
205 |
IconThemeHelper.registerIcon("action", "layer-saveas", this); |
|
206 |
IconThemeHelper.registerIcon("action", "layer-clip-raster", this); |
|
207 |
IconThemeHelper.registerIcon("action", "layer-zoom-res-level", this); |
|
208 |
IconThemeHelper.registerIcon("action", "layer-info-by-pixel", this); |
|
209 |
IconThemeHelper.registerIcon("action", "layer-vectorization", this); |
|
210 |
IconThemeHelper.registerIcon("action", "view-export-image", this); |
|
211 |
|
|
212 |
//Cursor |
|
213 |
IconThemeHelper.registerIcon("cursor", "zoom-pixel-cursor", this); |
|
214 |
IconThemeHelper.registerIcon("cursor", "hor-arrow-cursor", this); |
|
215 |
IconThemeHelper.registerIcon("cursor", "ver-arrow-cursor", this); |
|
216 |
IconThemeHelper.registerIcon("cursor", "inclder-arrow-cursor", this); |
|
217 |
IconThemeHelper.registerIcon("cursor", "inclizq-arrow-cursor", this); |
|
218 |
IconThemeHelper.registerIcon("cursor", "shear-y-cursor", this); |
|
219 |
IconThemeHelper.registerIcon("cursor", "shear-x-cursor", this); |
|
220 |
IconThemeHelper.registerIcon("cursor", "rotate-cursor", this); |
|
221 |
IconThemeHelper.registerIcon("cursor", "rot-inf-der-cursor", this); |
|
222 |
IconThemeHelper.registerIcon("cursor", "rot-inf-izq-cursor", this); |
|
223 |
IconThemeHelper.registerIcon("cursor", "rot-sup-der-cursor", this); |
|
224 |
IconThemeHelper.registerIcon("cursor", "rot-sup-izq-cursor", this); |
|
225 |
IconThemeHelper.registerIcon("cursor", "point-select-cursor", this); |
|
226 |
IconThemeHelper.registerIcon("cursor", "hand-cursor", this); |
|
227 |
IconThemeHelper.registerIcon("cursor", "rectangle-select-cursor", this); |
|
228 |
IconThemeHelper.registerIcon("cursor", "not-valid-cursor", this); |
|
229 |
IconThemeHelper.registerIcon("cursor", "line-cursor", this); |
|
230 |
IconThemeHelper.registerIcon("cursor", "polygon-cursor", this); |
|
231 |
IconThemeHelper.registerIcon("cursor", "point-cursor", this); |
|
232 |
|
|
233 |
//Other |
|
234 |
IconThemeHelper.registerIcon(null, "forward-icon", this); |
|
235 |
IconThemeHelper.registerIcon(null, "backward-icon", this); |
|
236 |
IconThemeHelper.registerIcon(null, "blank-icon", this); |
|
237 |
IconThemeHelper.registerIcon(null, "addlayer-icon", this); |
|
238 |
IconThemeHelper.registerIcon(null, "delall-icon", this); |
|
239 |
IconThemeHelper.registerIcon(null, "back-icon", this); |
|
240 |
IconThemeHelper.registerIcon(null, "next-icon", this); |
|
241 |
IconThemeHelper.registerIcon(null, "undo-icon", this); |
|
242 |
IconThemeHelper.registerIcon(null, "pixel-increase", this); |
|
243 |
IconThemeHelper.registerIcon(null, "pref-raster-icon", this); |
|
244 |
IconThemeHelper.registerIcon(null, "back-icon", this); |
|
245 |
IconThemeHelper.registerIcon(null, "next-icon", this); |
|
246 |
IconThemeHelper.registerIcon(null, "undo-icon", this); |
|
247 |
//IconThemeHelper.registerIcon(null, "save-raster", this); |
|
248 |
IconThemeHelper.registerIcon(null, "pixel-increase", this); |
|
249 |
//IconThemeHelper.registerIcon(null, "select-raster", this); |
|
250 |
IconThemeHelper.registerIcon(null, "pref-raster-icon", this); |
|
251 |
IconThemeHelper.registerIcon(null, "reset-icon", this); |
|
252 |
IconThemeHelper.registerIcon(null, "tfwload-icon", this); |
|
253 |
IconThemeHelper.registerIcon(null, "centerraster-icon", this); |
|
254 |
IconThemeHelper.registerIcon(null, "increase-icon", this); |
|
255 |
IconThemeHelper.registerIcon(null, "decrease-icon", this); |
|
256 |
IconThemeHelper.registerIcon(null, "selectzoomarea-icon", this); |
|
257 |
IconThemeHelper.registerIcon(null, "prevzoom-icon", this); |
|
258 |
IconThemeHelper.registerIcon(null, "fullview-icon", this); |
|
259 |
IconThemeHelper.registerIcon(null, "exporttoascii-icon", this); |
|
260 |
IconThemeHelper.registerIcon(null, "exporttocsv-icon", this); |
|
261 |
IconThemeHelper.registerIcon(null, "importfromcsv-icon", this); |
|
262 |
IconThemeHelper.registerIcon(null, "exit-icon", this); |
|
263 |
IconThemeHelper.registerIcon(null, "options-icon", this); |
|
264 |
IconThemeHelper.registerIcon(null, "add-icon", this); |
|
265 |
IconThemeHelper.registerIcon(null, "centerpoint-icon", this); |
|
266 |
IconThemeHelper.registerIcon(null, "selectrgb-icon", this); |
|
267 |
IconThemeHelper.registerIcon(null, "focus-icon", this); |
|
268 |
IconThemeHelper.registerIcon(null, "point-icon", this); |
|
269 |
IconThemeHelper.registerIcon(null, "line-icon", this); |
|
270 |
IconThemeHelper.registerIcon(null, "polygon-icon", this); |
|
271 |
IconThemeHelper.registerIcon(null, "import-icon", this); |
|
272 |
IconThemeHelper.registerIcon(null, "round-icon", this); |
|
273 |
//IconThemeHelper.registerIcon(null, "rois-icon", this); |
|
274 |
IconThemeHelper.registerIcon(null, "fullextent-icon", this); |
|
275 |
IconThemeHelper.registerIcon(null, "selecttool-icon", this); |
|
276 |
IconThemeHelper.registerIcon(null, "forward-icon", this); |
|
277 |
IconThemeHelper.registerIcon(null, "backward-icon", this); |
|
278 |
IconThemeHelper.registerIcon(null, "datatype-icon", this); |
|
279 |
IconThemeHelper.registerIcon(null, "setviewprojection-raster-icon", this); |
|
280 |
IconThemeHelper.registerIcon(null, "gvsig-icon", this); |
|
281 |
IconThemeHelper.registerIcon(null, "gvsig-icon16x16", this); |
|
282 |
} |
|
283 |
|
|
284 |
public void registerMenuElements() { |
|
285 |
// Creaci?n del punto de extensi?n para registrar paneles en el cuadro de propiedades. |
|
286 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
287 |
ExtensionPoint point = extensionPoints.get("GenericToolBarGroup"); |
|
288 |
point.setDescription("Punto de extension para los grupos de menus del GenericToolBarPanel"); |
|
289 |
|
|
290 |
point = extensionPoints.get("GenericToolBarMenu"); |
|
291 |
point.setDescription("Punto de extension para los submenus del GenericToolBarPanel"); |
|
292 |
//point.append("RasterProperties", "", RasterPropertiesTocMenuEntry.getSingleton()); |
|
293 |
point.append("SelectLayer", "", SelectLayerTocMenuEntry.getSingleton()); |
|
294 |
point.append("HistogramPanel", "", HistogramTocMenuEntry.getSingleton()); |
|
295 |
point.append("ViewColorTable", "",ColorTableTocMenuEntry.getSingleton()); |
|
296 |
if(RasterLocator.getManager().isOverviewBuilderSupported()) |
|
297 |
point.append("Overviews", "", OverviewsTocMenuEntry.getSingleton()); |
|
298 |
point.append("RoisManager", "", ROIManagerTocMenuEntry.getSingleton()); |
|
299 |
point.append("ViewRasterAnalysis", "", ViewRasterAnalysisTocMenuEntry.getSingleton()); |
|
300 |
point.append("ZoomResolutionLevel", "", ZoomResolutionLevelTocMenuEntry.getSingleton()); |
|
301 |
|
|
302 |
//point.append("SaveRaster", "", SaveViewToRasterTocMenuEntry.getSingleton()); |
|
303 |
point.append("SaveAs", "", SaveAsTocMenuEntry.getSingleton()); |
|
304 |
point.append("ClippingPanel", "", ClippingTocMenuEntry.getSingleton()); |
|
305 |
point.append("SaveViewToRaster", "", SaveViewToRasterTocMenuEntry.getSingleton()); |
|
306 |
point.append("SaveViewToImageRaster", "", SaveViewToImageTocMenuEntry.getSingleton()); |
|
307 |
|
|
308 |
point.append("FilterPanel", "", FilterTocMenuEntry.getSingleton()); |
|
309 |
point.append("EnhancedPanel", "", EnhancedTocMenuEntry.getSingleton()); |
|
310 |
point.append("InfoByPoint", "", InfoByRasterPointTocMenuEntry.getSingleton()); |
|
311 |
point.append("LayerDatatype", "", LayerDatatypeTocMenuEntry.getSingleton()); |
|
312 |
|
|
313 |
point.append("GeoLocation", "", GeoLocationTocMenuEntry.getSingleton()); |
|
314 |
point.append("SetProjection", "", SetViewProjectionTocMenuEntry.getSingleton()); |
|
315 |
|
|
316 |
} |
|
317 |
|
|
318 |
public boolean isEnabled() { |
|
319 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
320 |
if (f == null) |
|
321 |
return false; |
|
322 |
if (f instanceof AbstractViewPanel) { |
|
323 |
FLayers lyrs = ((AbstractViewPanel)f).getMapControl().getMapContext().getLayers(); |
|
324 |
for (int i = 0; i < lyrs.getLayersCount(); i++) |
|
325 |
if (lyrs.getLayer(i) instanceof FLyrRaster) |
|
326 |
return true; |
|
327 |
} |
|
328 |
return false; |
|
329 |
} |
|
330 |
|
|
331 |
/** |
|
332 |
* Mostramos el control si hay alguna capa cargada. |
|
333 |
*/ |
|
334 |
public boolean isVisible() { |
|
335 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
336 |
if (f == null) |
|
337 |
return false; |
|
338 |
|
|
339 |
if (f instanceof AbstractViewPanel) { |
|
340 |
FLayers lyrs = ((AbstractViewPanel)f).getMapControl().getMapContext().getLayers(); |
|
341 |
if (lyrs.getLayersCount() > 0) |
|
342 |
return true; |
|
343 |
} |
|
344 |
|
|
345 |
return false; |
|
346 |
} |
|
347 |
|
|
348 |
/** |
|
349 |
* Carga los valores de configuracion iniciales |
|
350 |
*/ |
|
351 |
private void loadConfigurationValues() { |
|
352 |
autoRefreshView = Configuration.getValue("general_auto_preview", Boolean.TRUE).booleanValue(); |
|
353 |
RasterLibrary.defaultNumberOfClasses = Configuration.getValue("general_defaultNumberOfClasses", Integer.valueOf(RasterLibrary.defaultNumberOfClasses)).intValue(); |
|
354 |
RasterLibrary.cacheSize = Configuration.getValue("cache_size", Long.valueOf(RasterLibrary.cacheSize)).longValue(); |
|
355 |
RasterLibrary.pageSize = Configuration.getValue("cache_pagesize", Double.valueOf(RasterLibrary.pageSize)).doubleValue(); |
|
356 |
RasterLibrary.pagsPerGroup = Configuration.getValue("cache_pagspergroup", Integer.valueOf(RasterLibrary.pagsPerGroup)).intValue(); |
|
357 |
RasterLibrary.blockHeight = Configuration.getValue("cache_blockheight", Integer.valueOf(RasterLibrary.blockHeight)).intValue(); |
|
358 |
//RasterLibrary.defaultNoDataValue = Configuration.getValue("nodata_value", Double.valueOf(RasterLibrary.defaultNoDataValue)).doubleValue(); |
|
359 |
} |
|
360 |
|
|
361 |
@SuppressWarnings("deprecation") |
|
362 |
public void actionConfigurationChanged(ConfigurationEvent e) { |
|
363 |
if (e.getKey().equals("nodata_transparency_enabled")) { |
|
364 |
boolean noDataTransparent = ((Boolean) e.getValue()).booleanValue(); |
|
365 |
IWindow[] f = PluginServices.getMDIManager().getAllWindows(); |
|
366 |
if (f == null) |
|
367 |
return; |
|
368 |
for (int i = 0; i < f.length; i++) |
|
369 |
if (f[i] instanceof AbstractViewPanel) { |
|
370 |
AbstractViewPanel vista = (AbstractViewPanel) f[i]; |
|
371 |
ViewDocument model = vista.getModel(); |
|
372 |
MapContext map = model.getMapContext(); |
|
373 |
FLayers lyrs = map.getLayers(); |
|
374 |
|
|
375 |
ArrayList<FLayer> list = RasterToolsUtil.getRasterLayerList(lyrs, null); |
|
376 |
for (int j = 0; j < list.size(); j++) |
|
377 |
if(list.get(j) instanceof FLyrRaster) |
|
378 |
((RasterDataStore)((FLyrRaster)list.get(j)).getDataStore()).getNoDataValue().setNoDataTransparent(noDataTransparent); |
|
379 |
} |
|
380 |
|
|
381 |
return; |
|
382 |
} |
|
383 |
|
|
384 |
if (e.getKey().equals("general_auto_preview")) { |
|
385 |
if(e.getValue() instanceof String) |
|
386 |
autoRefreshView = new Boolean((String) e.getValue()).booleanValue(); |
|
387 |
if(e.getValue() instanceof Boolean) |
|
388 |
autoRefreshView = ((Boolean) e.getValue()).booleanValue(); |
|
389 |
return; |
|
390 |
} |
|
391 |
|
|
392 |
if (e.getKey().equals("general_defaultNumberOfClasses")) { |
|
393 |
if(e.getValue() instanceof String) |
|
394 |
try { |
|
395 |
RasterLibrary.defaultNumberOfClasses = new Integer( |
|
396 |
(String) e.getValue()).intValue(); |
|
397 |
} catch (NumberFormatException exc) { |
|
398 |
//Valor por defecto en el n?mero de clases |
|
399 |
} |
|
400 |
|
|
401 |
if(e.getValue() instanceof Integer) |
|
402 |
RasterLibrary.defaultNumberOfClasses = ((Integer) e.getValue()).intValue(); |
|
403 |
return; |
|
404 |
} |
|
405 |
|
|
406 |
if (e.getKey().equals("cache_size")) { |
|
407 |
if(e.getValue() instanceof String) |
|
408 |
try { |
|
409 |
RasterLibrary.cacheSize = new Long((String) e.getValue()).longValue(); |
|
410 |
} catch (NumberFormatException exc) { |
|
411 |
//Valor por defecto en la cache |
|
412 |
} |
|
413 |
if(e.getValue() instanceof Long) |
|
414 |
RasterLibrary.cacheSize = ((Long) e.getValue()).longValue(); |
|
415 |
return; |
|
416 |
} |
|
417 |
|
|
418 |
if (e.getKey().equals("cache_pagesize")) { |
|
419 |
if(e.getValue() instanceof String) |
|
420 |
try { |
|
421 |
RasterLibrary.pageSize = new Double((String) e.getValue()) |
|
422 |
.doubleValue(); |
|
423 |
} catch (NumberFormatException exc) { |
|
424 |
//Valor por defecto en la cache |
|
425 |
} |
|
426 |
|
|
427 |
if(e.getValue() instanceof Double) |
|
428 |
RasterLibrary.pageSize = ((Double) e.getValue()).doubleValue(); |
|
429 |
return; |
|
430 |
} |
|
431 |
|
|
432 |
if (e.getKey().equals("cache_pagspergroup")) { |
|
433 |
if(e.getValue() instanceof String) |
|
434 |
try { |
|
435 |
RasterLibrary.pagsPerGroup = new Integer((String) e |
|
436 |
.getValue()).intValue(); |
|
437 |
} catch (NumberFormatException exc) { |
|
438 |
//Valor por defecto en la cache |
|
439 |
} |
|
440 |
|
|
441 |
if(e.getValue() instanceof Integer) |
|
442 |
RasterLibrary.pagsPerGroup = ((Integer) e.getValue()).intValue(); |
|
443 |
return; |
|
444 |
} |
|
445 |
|
|
446 |
if (e.getKey().equals("cache_blockheight")) { |
|
447 |
if(e.getValue() instanceof String) |
|
448 |
try { |
|
449 |
RasterLibrary.blockHeight = new Integer((String) e |
|
450 |
.getValue()).intValue(); |
|
451 |
} catch (NumberFormatException exc) { |
|
452 |
//Valor por defecto en la cache |
|
453 |
} |
|
454 |
if(e.getValue() instanceof Integer) |
|
455 |
RasterLibrary.blockHeight = ((Integer) e.getValue()).intValue(); |
|
456 |
return; |
|
457 |
} |
|
458 |
|
|
459 |
/*if (e.getKey().equals("nodata_value")) { |
|
460 |
if(e.getValue() instanceof String) |
|
461 |
try { |
|
462 |
RasterLibrary.defaultNoDataValue = new Double((String) e |
|
463 |
.getValue()).doubleValue(); |
|
464 |
} catch (NumberFormatException exc) { |
|
465 |
//Valor por defecto en valor nodata |
|
466 |
} |
|
467 |
|
|
468 |
if(e.getValue() instanceof Double) |
|
469 |
RasterLibrary.defaultNoDataValue = ((Double) e.getValue()).doubleValue(); |
|
470 |
return; |
|
471 |
}*/ |
|
472 |
|
|
473 |
} |
|
474 |
|
|
475 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
|
476 |
this.execute("SELECTIMAGE"); |
|
477 |
} |
|
478 |
|
|
479 |
public void postInitialize() { |
|
480 |
super.postInitialize(); |
|
481 |
new ToolboxRasterToolsLoader().registerTool(); |
|
482 |
} |
|
483 |
|
|
484 |
public boolean canQueryByAction() { |
|
485 |
return true; |
|
486 |
} |
|
487 |
|
|
488 |
public boolean isEnabled(String action) { |
|
489 |
//Las entradas en GenericToolBarModule est?n registradas con la misma etiqueta que el actionCommand |
|
490 |
//De esta forma pueden recuperarse los TocMenuEntry del punto de extensi?n y ejecutar isEnable a |
|
491 |
//trav?s de este. |
|
492 |
if(getGenericToolBarMenuExtensionPoint() != null && getGenericToolBarMenuExtensionPoint().get(action) != null) { |
|
493 |
ExtensionBuilder ext = getGenericToolBarMenuExtensionPoint().get(action).getBuilder(); |
|
494 |
if(ext != null && ext instanceof AbstractTocContextMenuAction) { |
|
495 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
|
496 |
if(w instanceof AbstractViewPanel) { |
|
497 |
FLayers lyrs = ((AbstractViewPanel)w).getMapControl().getMapContext().getLayers(); |
|
498 |
FLayer[] actives = lyrs.getActives(); |
|
499 |
return ((AbstractTocContextMenuAction)ext).isEnabled(null, actives); |
|
500 |
} |
|
501 |
} |
|
502 |
} |
|
503 |
return false; |
|
504 |
} |
|
505 |
|
|
506 |
public boolean isVisible(String action) { |
|
507 |
//Las entradas en GenericToolBarModule est?n registradas con la misma etiqueta que el actionCommand |
|
508 |
//De esta forma pueden recuperarse los TocMenuEntry del punto de extensi?n y ejecutar isVisible a |
|
509 |
//trav?s de este. |
|
510 |
if(getGenericToolBarMenuExtensionPoint() != null && getGenericToolBarMenuExtensionPoint().get(action) != null) { |
|
511 |
ExtensionBuilder ext = getGenericToolBarMenuExtensionPoint().get(action).getBuilder(); |
|
512 |
if(ext != null && ext instanceof AbstractTocContextMenuAction) { |
|
513 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
|
514 |
if(w instanceof AbstractViewPanel) { |
|
515 |
FLayers lyrs = ((AbstractViewPanel)w).getMapControl().getMapContext().getLayers(); |
|
516 |
FLayer[] actives = lyrs.getActives(); |
|
517 |
return ((AbstractTocContextMenuAction)ext).isVisible(null, actives); |
|
518 |
} |
|
519 |
} |
|
520 |
} |
|
521 |
return false; |
|
522 |
} |
|
523 |
|
|
524 |
public ExtensionPoint getGenericToolBarMenuExtensionPoint() { |
|
525 |
if(genericToolBarMenuExtensionPoint == null) { |
|
526 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
527 |
genericToolBarMenuExtensionPoint = extensionPoints.get("GenericToolBarMenu"); |
|
528 |
} |
|
529 |
return genericToolBarMenuExtensionPoint; |
|
530 |
} |
|
531 |
} |
|
0 | 532 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.232/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/infobypoint/InfoByRasterPointExtension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.tools.app.basic.tool.infobypoint; |
|
23 |
|
|
24 |
import java.awt.Component; |
|
25 |
import java.awt.Cursor; |
|
26 |
import java.util.Observable; |
|
27 |
import java.util.Observer; |
|
28 |
|
|
29 |
import javax.swing.JOptionPane; |
|
30 |
|
|
31 |
import org.gvsig.andami.PluginServices; |
|
32 |
import org.gvsig.andami.PluginsLocator; |
|
33 |
import org.gvsig.andami.actioninfo.ActionInfoManager; |
|
34 |
import org.gvsig.andami.plugins.Extension; |
|
35 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
36 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
37 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
38 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
|
39 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
40 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
41 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
42 |
import org.gvsig.fmap.mapcontrol.tools.CompoundBehavior; |
|
43 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
|
44 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
|
45 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
|
46 |
import org.gvsig.i18n.Messages; |
|
47 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
48 |
import org.gvsig.raster.swing.infobypoint.InfoByPointDataModel; |
|
49 |
import org.gvsig.raster.tools.app.basic.tool.infobypoint.viewtool.InfoByPixelPointViewTool; |
|
50 |
import org.gvsig.raster.tools.app.basic.tool.infobypoint.viewtool.PixelInspectorViewTool; |
|
51 |
|
|
52 |
/** |
|
53 |
* Plugin for the information by point of a raster layer |
|
54 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
55 |
*/ |
|
56 |
public class InfoByRasterPointExtension extends Extension { |
|
57 |
private InfoByPixelPointViewTool lastTool = null; |
|
58 |
public static Behavior oldBehavior = null; |
|
59 |
|
|
60 |
public void execute(String actionCommand) { |
|
61 |
if(actionCommand.compareTo("INFO_BY_PIXEL") == 0) { |
|
62 |
MapControl mapCtrl = getMapControl(); |
|
63 |
String oldTool = mapCtrl.getCurrentTool(); |
|
64 |
StatusBarListener sbl = new StatusBarListener(mapCtrl); |
|
65 |
|
|
66 |
IWindow[] wList = PluginServices.getMDIManager().getAllWindows(); |
|
67 |
for (int i = 0; i < wList.length; i++) { |
|
68 |
if(wList[i] instanceof MainInfoByPointDialog) { |
|
69 |
JOptionPane.showMessageDialog( |
|
70 |
(Component)wList[i], |
|
71 |
Messages.getText("open_window"), |
|
72 |
Messages.getText("Information"), |
|
73 |
JOptionPane.INFORMATION_MESSAGE); |
|
74 |
mapCtrl.addBehavior("infoByRasterPoint", |
|
75 |
new Behavior[]{new PointBehavior(lastTool), |
|
76 |
new MouseMovementBehavior(sbl)}); |
|
77 |
mapCtrl.setTool("infoByRasterPoint"); |
|
78 |
return; |
|
79 |
} |
|
80 |
} |
|
81 |
MainInfoByPointDialog dialog = new MainInfoByPointDialog(mapCtrl, oldTool); |
|
82 |
InfoByPointDataModel model = dialog.getInfoByPointDataModel(); |
|
83 |
((Observable)model).addObserver((Observer)dialog.getMainPanel()); |
|
84 |
|
|
85 |
lastTool = new InfoByPixelPointViewTool(mapCtrl, model); |
|
86 |
mapCtrl.addBehavior("infoByRasterPoint", |
|
87 |
new Behavior[]{new PointBehavior(lastTool), |
|
88 |
new MouseMovementBehavior(sbl)}); |
|
89 |
mapCtrl.setTool("infoByRasterPoint"); |
|
90 |
oldBehavior = CompoundBehavior.getAllControlsBehavior(); |
|
91 |
CompoundBehavior.setAllControlsBehavior(new PixelInspectorViewTool(mapCtrl, model, dialog.getPixelInspector())); |
|
92 |
|
|
93 |
model.notifyObservers(); |
|
94 |
PluginServices.getMDIManager().addWindow(dialog); |
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
private MapControl getMapControl() { |
|
99 |
IWindow theView = PluginServices.getMDIManager().getActiveWindow(); |
|
100 |
if(!(theView instanceof AbstractViewPanel)) { |
|
101 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this.getClass(), "window_not_valid")); |
|
102 |
return null; |
|
103 |
} |
|
104 |
return ((AbstractViewPanel)theView).getMapControl(); |
|
105 |
} |
|
106 |
|
|
107 |
@SuppressWarnings("deprecation") |
|
108 |
public boolean isEnabled() { |
|
109 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
110 |
if (f == null) |
|
111 |
return false; |
|
112 |
if (f instanceof AbstractViewPanel) { |
|
113 |
AbstractViewPanel vista = (AbstractViewPanel) f; |
|
114 |
ViewDocument model = vista.getModel(); |
|
115 |
MapContext mapa = model.getMapContext(); |
|
116 |
FLayers layers = mapa.getLayers(); |
|
117 |
for (int i = 0; i < layers.getLayersCount(); i++) |
|
118 |
if (layers.getLayer(i) instanceof FLyrRaster) { |
|
119 |
FLyrRaster lyr = (FLyrRaster)layers.getLayer(i); |
|
120 |
if(lyr.isActive()) |
|
121 |
return true; |
|
122 |
} |
|
123 |
} |
|
124 |
return false; |
|
125 |
} |
|
126 |
|
|
127 |
public boolean isVisible() { |
|
128 |
return isEnabled(); |
|
129 |
} |
|
130 |
|
|
131 |
public void initialize() { |
|
132 |
} |
|
133 |
|
|
134 |
@Override |
|
135 |
public void postInitialize() { |
|
136 |
super.postInitialize(); |
|
137 |
ActionInfoManager manager = PluginsLocator.getActionInfoManager(); |
|
138 |
manager.redirect("layer-info-by-point", "layer-info-by-raster-point"); |
|
139 |
} |
|
140 |
} |
|
0 | 141 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.232/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/infobypoint/InfoByRasterPointTocMenuEntry.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.tools.app.basic.tool.infobypoint; |
|
20 |
|
|
21 |
import javax.swing.Icon; |
|
22 |
|
|
23 |
import org.gvsig.andami.PluginServices; |
|
24 |
import org.gvsig.andami.plugins.Extension; |
|
25 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
26 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
27 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
|
28 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
|
29 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
30 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
31 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
32 |
import org.gvsig.i18n.Messages; |
|
33 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
34 |
import org.gvsig.raster.mainplugin.toolbar.IGenericToolBarMenuItem; |
|
35 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
|
36 |
|
|
37 |
/** |
|
38 |
* Entry point to the InfoByRasterPoint tool |
|
39 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
40 |
*/ |
|
41 |
public class InfoByRasterPointTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem { |
|
42 |
static private InfoByRasterPointTocMenuEntry singleton = null; |
|
43 |
private Extension extension = null; |
|
44 |
|
|
45 |
/** |
|
46 |
* Nadie puede crear una instancia a esta clase ?nica, hay que usar el |
|
47 |
* getSingleton() |
|
48 |
*/ |
|
49 |
private InfoByRasterPointTocMenuEntry() { |
|
50 |
extension = new InfoByRasterPointExtension(); |
|
51 |
extension.initialize(); |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* Assigns the extension to be executed |
|
56 |
* @param ext |
|
57 |
*/ |
|
58 |
public void setExtension(Extension ext) { |
|
59 |
this.extension = ext; |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* Devuelve un objeto unico a dicha clase |
|
64 |
* @return |
|
65 |
*/ |
|
66 |
static public InfoByRasterPointTocMenuEntry getSingleton() { |
|
67 |
if (singleton == null) |
|
68 |
singleton = new InfoByRasterPointTocMenuEntry(); |
|
69 |
return singleton; |
|
70 |
} |
|
71 |
|
|
72 |
public String getGroup() { |
|
73 |
return "RasterLayer"; |
|
74 |
} |
|
75 |
|
|
76 |
public int getGroupOrder() { |
|
77 |
return 10; |
|
78 |
} |
|
79 |
|
|
80 |
public int getOrder() { |
|
81 |
return 50; |
|
82 |
} |
|
83 |
|
|
84 |
public String getText() { |
|
85 |
return Messages.getText("infobypoint"); |
|
86 |
} |
|
87 |
|
|
88 |
@SuppressWarnings("deprecation") |
|
89 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
|
90 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
|
91 |
if (f == null) |
|
92 |
return false; |
|
93 |
if (f instanceof AbstractViewPanel) { |
|
94 |
AbstractViewPanel vista = (AbstractViewPanel) f; |
|
95 |
ViewDocument model = vista.getModel(); |
|
96 |
MapContext mapa = model.getMapContext(); |
|
97 |
FLayers layers = mapa.getLayers(); |
|
98 |
for (int i = 0; i < layers.getLayersCount(); i++) |
|
99 |
if (layers.getLayer(i) instanceof FLyrRaster && layers.getLayer(i).isActive()) |
|
100 |
return true; |
|
101 |
} |
|
102 |
return false; |
|
103 |
} |
|
104 |
|
|
105 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
|
106 |
return true; |
|
107 |
} |
|
108 |
|
|
109 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
|
110 |
extension.execute("INFO_BY_PIXEL"); |
|
111 |
} |
|
112 |
|
|
113 |
public Icon getIcon() { |
|
114 |
return RasterToolsUtil.getIcon("layer-info-by-pixel"); |
|
115 |
} |
|
116 |
|
|
117 |
} |
|
0 | 118 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.232/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/infobypoint/MainInfoByPointDialog.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.tools.app.basic.tool.infobypoint; |
|
23 |
|
|
24 |
import java.awt.BorderLayout; |
|
25 |
import java.awt.Component; |
|
26 |
import java.awt.Cursor; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.awt.event.ActionListener; |
|
29 |
import java.util.HashMap; |
|
30 |
|
|
31 |
import javax.swing.ImageIcon; |
|
32 |
import javax.swing.JPanel; |
|
33 |
|
|
34 |
import org.gvsig.andami.IconThemeHelper; |
|
35 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
36 |
import org.gvsig.andami.ui.mdiManager.IWindowListener; |
|
37 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
38 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
39 |
import org.gvsig.fmap.mapcontrol.tools.CompoundBehavior; |
|
40 |
import org.gvsig.i18n.Messages; |
|
41 |
import org.gvsig.raster.swing.RasterSwingLocator; |
|
42 |
import org.gvsig.raster.swing.infobypoint.InfoByPointDataModel; |
|
43 |
import org.gvsig.raster.swing.infobypoint.MainInfoByPointPanel; |
|
44 |
import org.gvsig.raster.swing.pixelinspector.PixelInspector; |
|
45 |
|
|
46 |
/** |
|
47 |
* Dialog for the information by point of a raster layer |
|
48 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
49 |
*/ |
|
50 |
public class MainInfoByPointDialog extends JPanel implements IWindow, ActionListener, IWindowListener { |
|
51 |
private static final long serialVersionUID = 1L; |
|
52 |
private MainInfoByPointPanel mainPanel = null; |
|
53 |
private String toolToRestore = null; |
|
54 |
private MapControl mapCtrl = null; |
|
55 |
|
|
56 |
public MainInfoByPointDialog(MapControl mapControl, String toolToRestore) { |
|
57 |
setLayout(new BorderLayout()); |
|
58 |
add((Component)getMainPanel(), BorderLayout.CENTER); |
|
59 |
this.toolToRestore = toolToRestore; |
|
60 |
this.mapCtrl = mapControl; |
|
61 |
} |
|
62 |
|
|
63 |
public MainInfoByPointPanel getMainPanel() { |
|
64 |
if(mainPanel == null) { |
|
65 |
HashMap<String, String> translations = new HashMap<String, String>(); |
|
66 |
translations.put("info", Messages.getText("info")); |
|
67 |
translations.put("view", Messages.getText("view")); |
|
68 |
translations.put("layer_list", Messages.getText("layer_list")); |
|
69 |
translations.put("band_values", Messages.getText("band_values")); |
|
70 |
translations.put("pixel_point", Messages.getText("pixel_point")); |
|
71 |
translations.put("view_point", Messages.getText("view_point")); |
|
72 |
translations.put("world_point", Messages.getText("world_point")); |
|
73 |
translations.put("bands", Messages.getText("bands")); |
|
74 |
translations.put("colors", Messages.getText("colors")); |
|
75 |
translations.put("coords", Messages.getText("coords")); |
|
76 |
translations.put("lat", Messages.getText("lat")); |
|
77 |
translations.put("long", Messages.getText("long")); |
|
78 |
translations.put("red", Messages.getText("red")); |
|
79 |
translations.put("green", Messages.getText("green")); |
|
80 |
translations.put("blue", Messages.getText("blue")); |
|
81 |
HashMap<String, ImageIcon> icons = new HashMap<String, ImageIcon>(); |
|
82 |
icons.put("forward-icon", IconThemeHelper.getImageIcon("forward-icon")); |
|
83 |
icons.put("backward-icon", IconThemeHelper.getImageIcon("backward-icon")); |
|
84 |
mainPanel = RasterSwingLocator.getSwingManager().createInfoByPointPanel( |
|
85 |
translations, icons, null); |
|
86 |
mainPanel.addListenerExtendedButton(this); |
|
87 |
} |
|
88 |
return mainPanel; |
|
89 |
} |
|
90 |
|
|
91 |
public WindowInfo getWindowInfo() { |
|
92 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG); |
|
93 |
m_viewinfo.setTitle(Messages.getText("InfoByPoint")); |
|
94 |
m_viewinfo.setHeight(380); |
|
95 |
m_viewinfo.setWidth(250); |
|
96 |
return m_viewinfo; |
|
97 |
} |
|
98 |
|
|
99 |
public void windowClosed() { |
|
100 |
CompoundBehavior.setAllControlsBehavior(InfoByRasterPointExtension.oldBehavior); |
|
101 |
mapCtrl.setTool(toolToRestore); |
|
102 |
} |
|
103 |
|
|
104 |
public Object getWindowProfile() { |
|
105 |
return WindowInfo.PROPERTIES_PROFILE; |
|
106 |
} |
|
107 |
|
|
108 |
public InfoByPointDataModel getInfoByPointDataModel() { |
|
109 |
return getMainPanel().getInfoByPointDataModel(); |
|
110 |
} |
|
111 |
|
|
112 |
public PixelInspector getPixelInspector() { |
|
113 |
return getMainPanel().getPixelInspectorPanel(); |
|
114 |
} |
|
115 |
|
|
116 |
public void actionPerformed(ActionEvent e) { |
|
117 |
} |
|
118 |
|
|
119 |
public void windowActivated() { |
|
120 |
|
|
121 |
} |
|
122 |
} |
|
0 | 123 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.232/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/infobypoint/viewtool/InfoByPixelPointViewTool.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.tools.app.basic.tool.infobypoint.viewtool; |
|
23 |
|
|
24 |
import java.awt.geom.Point2D; |
|
25 |
import java.awt.image.BufferedImage; |
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.List; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
30 |
import org.gvsig.fmap.dal.coverage.RasterManager; |
|
31 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
32 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
33 |
import org.gvsig.fmap.dal.coverage.util.ColorConversion; |
|
34 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
35 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
36 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
37 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
38 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
|
39 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
40 |
import org.gvsig.raster.swing.infobypoint.InfoByPointDataModel; |
|
41 |
import org.gvsig.raster.tools.app.basic.tool.selectrasterlayer.SelectImageListImpl; |
|
42 |
|
|
43 |
/** |
|
44 |
* This tool writes in InfoByPointDataModel the information about the selected point. |
|
45 |
* |
|
46 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
47 |
*/ |
|
48 |
public class InfoByPixelPointViewTool extends SelectImageListImpl { |
|
49 |
private RasterManager rManager = RasterLocator.getManager(); |
|
50 |
private InfoByPointDataModel model = null; |
|
51 |
private ColorConversion conv = null; |
|
52 |
private ViewPort viewPort = null; |
|
53 |
private FLayers layers = null; |
|
54 |
private List<String> list = null; |
|
55 |
|
|
56 |
/** |
|
57 |
* Contructor |
|
58 |
* @param mapCtrl |
|
59 |
*/ |
|
60 |
public InfoByPixelPointViewTool(MapControl mapCtrl, InfoByPointDataModel model) { |
|
61 |
super(mapCtrl); |
|
62 |
this.model = model; |
|
63 |
conv = rManager.getColorConversion(); |
|
64 |
viewPort = mapCtrl.getViewPort(); |
|
65 |
layers = mapCtrl.getMapContext().getLayers(); |
|
66 |
list = new ArrayList<String>(); |
|
67 |
} |
|
68 |
|
|
69 |
@SuppressWarnings("deprecation") |
|
70 |
public void point(PointEvent event) { |
|
71 |
super.point(event); |
|
72 |
|
|
73 |
Point2D point2D = event.getPoint(); |
|
74 |
|
|
75 |
BufferedImage image = mapCtrl.getImage(); |
|
76 |
int value = image.getRGB((int) point2D.getX(), (int) point2D.getY()); |
|
77 |
int r = (value >> 16) & 0xff; |
|
78 |
int g = (value >> 8) & 0xff; |
|
79 |
int b = value & 0xff; |
|
80 |
|
|
81 |
double[] cmyk = conv.RGBtoCMYK(r & 0xff, g & 0xff, b & 0xff, 1D); |
|
82 |
|
|
83 |
double[] hsl = conv.RGBtoHSL(r & 0xff, g & 0xff, b & 0xff); |
|
84 |
hsl[0] = (int)(255.0 * hsl[0] / 360.0 + 0.5); |
|
85 |
hsl[2] = (int) (hsl[2] * 255. + 0.5); |
|
86 |
hsl[1] = (int) (hsl[1] * 255. + 0.5); |
|
87 |
|
|
88 |
Point2D mapPoint = viewPort.toMapPoint(point2D); |
|
89 |
|
|
90 |
model.setARGB(r, g, b); |
|
91 |
model.setCMYK(cmyk); |
|
92 |
model.setHSL(hsl[0], hsl[1], hsl[2]); |
|
93 |
model.setViewPoint(point2D.getX(), point2D.getY()); |
|
94 |
model.setWorldPoint(mapPoint.getX(), mapPoint.getY()); |
|
95 |
|
|
96 |
//Raster dependent |
|
97 |
|
|
98 |
list.clear(); |
|
99 |
FLyrRaster selected = null; |
|
100 |
for (int i = layers.getLayersCount() - 1; i >= 0; i--) { |
|
101 |
FLayer lyr = layers.getLayer(i); |
|
102 |
if(lyr instanceof FLyrRaster) { |
|
103 |
FLyrRaster raster = (FLyrRaster)lyr; |
|
104 |
Point2D tmpPoint = mapPoint; |
|
105 |
|
|
106 |
if(raster.getCoordTrans() != null){ |
|
107 |
tmpPoint = raster.getCoordTrans().getInverted().convert(mapPoint, null); |
|
108 |
} |
|
109 |
|
|
110 |
if(raster.isInside(tmpPoint)) { |
|
111 |
list.add(raster.getName()); |
|
112 |
if(raster.isActive()) |
|
113 |
selected = raster; |
|
114 |
} |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
if(selected != null) { |
|
119 |
|
|
120 |
if(selected.getCoordTrans() != null){ |
|
121 |
mapPoint = selected.getCoordTrans().getInverted().convert(mapPoint, null); |
|
122 |
} |
|
123 |
|
|
124 |
Point2D rasterPoint = selected.getDataStore().worldToRaster(mapPoint); |
|
125 |
model.setNumberOfBands(selected.getDataStore().getBandCount()); |
|
126 |
model.setBandValues(getBandValues(selected.getDataStore(), rasterPoint)); |
|
127 |
model.setPixelPoint(rasterPoint.getX(), rasterPoint.getY()); |
|
128 |
} else { |
|
129 |
list.clear(); |
|
130 |
list.add("..."); |
|
131 |
model.setNumberOfBands(0); |
|
132 |
model.setBandValues(new double[]{Double.NaN}); |
|
133 |
model.setPixelPoint(-1, -1); |
|
134 |
} |
|
135 |
model.setLayerList(list); |
|
136 |
|
|
137 |
model.notifyObservers(); |
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* Loads the values of a pixel point |
|
142 |
* @param dataStore |
|
143 |
* @param pxPoint |
|
144 |
* @return |
|
145 |
*/ |
|
146 |
private double[] getBandValues(RasterDataStore dataStore, Point2D pxPoint) { |
|
147 |
double[] res = new double[dataStore.getBandCount()]; |
|
148 |
int pos = 0; |
|
149 |
try { |
|
150 |
if(dataStore.getDataType()[0] >= 0 && dataStore.getDataType()[0] <= 3) { |
|
151 |
for(int i = 0; i < dataStore.getBandCount(); i++) { |
|
152 |
int val = ((Integer)dataStore.getData((int)pxPoint.getX(), (int)pxPoint.getY(), i)).intValue(); |
|
153 |
if(dataStore.getDataType()[0] == Buffer.TYPE_BYTE) |
|
154 |
res[pos] = (val & 0x000000ff); |
|
155 |
else |
|
156 |
res[pos] = val; |
|
157 |
pos ++; |
|
158 |
} |
|
159 |
} |
|
160 |
|
|
161 |
if(dataStore.getDataType()[0] == 4) { |
|
162 |
for(int i = 0; i < dataStore.getBandCount(); i++) { |
|
163 |
res[pos] = ((Float)dataStore.getData((int)pxPoint.getX(), (int)pxPoint.getY(), i)).doubleValue() ; |
|
164 |
pos ++; |
|
165 |
} |
|
166 |
} |
|
167 |
if(dataStore.getDataType()[0] == 5) { |
|
168 |
for(int i = 0; i < dataStore.getBandCount(); i++) { |
|
169 |
res[pos] = ((Double)dataStore.getData((int)pxPoint.getX(), (int)pxPoint.getY(), i)).doubleValue(); |
|
170 |
pos ++; |
|
171 |
} |
|
172 |
} |
|
173 |
return res; |
|
174 |
} catch (Exception e) { |
|
175 |
for (int i = 0; i < dataStore.getBandCount(); i++) { |
|
176 |
res[i] = Double.NaN; |
|
177 |
} |
|
178 |
} |
|
179 |
return res; |
|
180 |
} |
|
181 |
} |
|
0 | 182 |
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.232/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/infobypoint/viewtool/PixelInspectorViewTool.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.tools.app.basic.tool.infobypoint.viewtool; |
|
23 |
|
|
24 |
import java.awt.event.MouseEvent; |
|
25 |
import java.awt.geom.Point2D; |
|
26 |
import java.awt.image.BufferedImage; |
|
27 |
|
|
28 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
29 |
import org.gvsig.fmap.dal.coverage.RasterManager; |
|
30 |
import org.gvsig.fmap.dal.coverage.util.ColorConversion; |
|
31 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
32 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
33 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
34 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
35 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
|
36 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener; |
|
37 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
38 |
import org.gvsig.raster.swing.infobypoint.InfoByPointDataModel; |
|
39 |
import org.gvsig.raster.swing.pixelinspector.PixelInspector; |
|
40 |
|
|
41 |
|
|
42 |
/** |
|
43 |
* Behavior to be added to the MapControl. With this behavior will be |
|
44 |
* possible to manage the mouse event on the view |
|
45 |
* |
|
46 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
47 |
*/ |
|
48 |
public class PixelInspectorViewTool extends Behavior { |
|
49 |
private RasterManager rManager = RasterLocator.getManager(); |
|
50 |
private InfoByPointDataModel model = null; |
|
51 |
private ColorConversion conv = null; |
|
52 |
private ViewPort viewPort = null; |
|
53 |
private MapControl mapCtrl = null; |
|
54 |
private PixelInspector observer = null; |
|
55 |
|
|
56 |
/** |
|
57 |
* Constructor. Asigna el dialogo |
|
58 |
* @param dialog |
|
59 |
*/ |
|
60 |
public PixelInspectorViewTool(MapControl mapCtrl, InfoByPointDataModel model, PixelInspector observer) { |
|
61 |
this.mapCtrl = mapCtrl; |
|
62 |
this.model = model; |
|
63 |
this.observer = observer; |
|
64 |
conv = rManager.getColorConversion(); |
|
65 |
viewPort = mapCtrl.getViewPort(); |
|
66 |
} |
|
67 |
|
|
68 |
public FLyrRaster getLayer(Point2D p) { |
|
69 |
FLyrRaster raster = null; |
|
70 |
for (int i = mapCtrl.getMapContext().getLayers().getLayersCount() - 1; i >= 0; i--) { |
|
71 |
FLayer lyr = mapCtrl.getMapContext().getLayers().getLayer(i); |
|
72 |
if(lyr instanceof FLyrRaster) { |
|
73 |
raster = (FLyrRaster)lyr; |
|
74 |
if(raster.isInside(p)) |
|
75 |
return raster; |
|
76 |
} |
|
77 |
} |
|
78 |
return null; |
|
79 |
} |
|
80 |
|
|
81 |
public ToolListener getListener() { |
|
82 |
return null; |
|
83 |
} |
|
84 |
|
Also available in: Unified diff