Revision 1145

View differences:

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/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

  
33
	/*
34
	 * (non-Javadoc)
35
	 * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
36
	 */
37
	public void execute(String actionCommand) {
38
		System.gc();
39
	}
40

  
41
	/*
42
	 * (non-Javadoc)
43
	 * @see com.iver.andami.plugins.IExtension#initialize()
44
	 */
45
	public void initialize() {
46

  
47
	}
48

  
49
	/*
50
	 * (non-Javadoc)
51
	 * @see com.iver.andami.plugins.IExtension#isEnabled()
52
	 */
53
	public boolean isEnabled() {
54
		return true;
55
	}
56

  
57
	public boolean isVisible() {
58
		return true;
59
	}
60

  
61
}
0 62

  
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
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
import org.gvsig.raster.tools.app.basic.tool.multiresolution.ResolutionLevelListener;
23

  
24
public class InfoByRasterPointExtension extends Extension {
25
	
26
	public InfoByRasterPointExtension() {
27
		
28
	}
29
	
30
	/*
31
	 * (non-Javadoc)
32
	 * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
33
	 */
34
	public void execute(String actionCommand) {
35
		if(actionCommand.compareTo("INFO_BY_PIXEL") == 0) {
36
			MainInfoByPointDialog dialog = new MainInfoByPointDialog();
37
			InfoByPointDataModel model = dialog.getInfoByPointDataModel();
38
			
39
			IWindow theView = PluginServices.getMDIManager().getActiveWindow();
40
			if(!(theView instanceof AbstractViewPanel)) {
41
				JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this.getClass(), "window_not_valid"));
42
				return;
43
			}
44
			MapControl mapCtrl = ((AbstractViewPanel)theView).getMapControl();
45
			StatusBarListener sbl = new StatusBarListener(mapCtrl);
46
			InfoByPixelPointListener ibpl = new InfoByPixelPointListener(mapCtrl, model);
47
			mapCtrl.addBehavior("infoByRasterPoint", new Behavior[]{new PointBehavior(ibpl),
48
						new MouseMovementBehavior(sbl)});
49
			mapCtrl.setTool("infoByRasterPoint");
50
			
51
			model.setARGB(0, 255, 125, 110);
52
			model.setCMYK(54, 254, 121, 190);
53
			model.setHSL(234.3, 125.5, 110.3);
54
			model.setBandValues(new double[]{4.53, 2.24, 67.7, 67.87});
55
			model.setNumberOfBands(4);
56
			model.setPixelPoint(100, 105);
57
			model.setViewPoint(305, 405);
58
			model.setWorldPoint(20554523.32, 19362125.23);
59
			model.setLayerList(new String[]{
60
					"Esta_es_la_capa_numero_uno_de_la_lista_de_capas.jpg",
61
					"Esta_es_la_capa_segunda_de_la_lista_de_capas_del_info_by_point.jpg"});
62
			dialog.updateDataModel();
63
			PluginServices.getMDIManager().addWindow(dialog);
64
		}
65
	}
66
	
67
	/*
68
	 * (non-Javadoc)
69
	 * @see org.gvsig.andami.plugins.IExtension#isEnabled()
70
	 */
71
	@SuppressWarnings("deprecation")
72
	public boolean isEnabled() {
73
		org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
74
		if (f == null)
75
			return false;
76
		if (f instanceof AbstractViewPanel) {
77
			AbstractViewPanel vista = (AbstractViewPanel) f;
78
			ViewDocument model = vista.getModel();
79
			MapContext mapa = model.getMapContext();
80
			FLayers layers = mapa.getLayers();
81
			for (int i = 0; i < layers.getLayersCount(); i++)
82
				if (layers.getLayer(i) instanceof FLyrRaster)
83
					return true;
84
		}
85
		return false;
86
	}
87
	
88
	/*
89
	 * (non-Javadoc)
90
	 * @see org.gvsig.andami.plugins.IExtension#isVisible()
91
	 */
92
	public boolean isVisible() {
93
		return isEnabled();
94
	}
95

  
96
	/*
97
	 * (non-Javadoc)
98
	 * @see org.gvsig.andami.plugins.IExtension#initialize()
99
	 */
100
	public void initialize() {
101
		registerIcons();
102
	}
103
	
104
	private void registerIcons() {
105
		PluginServices.getIconTheme().registerDefault(
106
				"info-by-pixel",
107
				getClass().getClassLoader().getResource("images/infoByRasterPoint.png")
108
			);
109
	}
110
}
0 111

  
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/gui/MainInfoByPointPanel.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.gui;
23

  
24
import java.awt.BorderLayout;
25
import java.util.HashMap;
26

  
27
import javax.swing.JPanel;
28
import javax.swing.JTabbedPane;
29

  
30
public class MainInfoByPointPanel extends JPanel {
31
	private static final long       serialVersionUID    = 1L;
32
	private JTabbedPane             tabs                = null;
33
	private HashMap<String, String> tr                  = null;
34
	private PixelViewPanel          viewPanel           = null;
35
	private InfoByPointPanel        infoByPointPanel    = null;
36
	private ViewAndInfoPanel        viewAndInfoPanel    = null;
37
	private InfoByPointDataModel    dataModel           = null;
38
	
39
	public MainInfoByPointPanel(HashMap<String, String> translations) {
40
		tr = translations;
41
		if(tr == null) {
42
			tr = new HashMap<String, String>();
43
			tr.put("info", "info");
44
			tr.put("view", "view");
45
			tr.put("view_and_info", "view_and_info");
46
		}
47
		init();
48
	}
49
	
50
	private void init() {
51
		setLayout(new BorderLayout());
52
		add(getTabs(), BorderLayout.CENTER);
53
	}
54
	
55
	public JTabbedPane getTabs() {
56
		if(tabs == null) {
57
			tabs = new JTabbedPane();
58
			tabs.addTab(tr.get("info"), getInfoByPointPanel());
59
			tabs.addTab(tr.get("view"), getViewPanel());
60
			tabs.addTab(tr.get("view_and_info"), getViewAndInfoPanel());
61
		}
62
		return tabs;
63
	}
64
	
65
	private ViewAndInfoPanel getViewAndInfoPanel() {
66
		if(viewAndInfoPanel == null) {
67
			InfoByPointPanel infoByPointPanel = new InfoByPointPanel(tr, getInfoByPointDataModel());
68
			PixelViewPanel viewPanel = new PixelViewPanel(tr, getInfoByPointDataModel());
69
			viewAndInfoPanel = new ViewAndInfoPanel(viewPanel, infoByPointPanel);
70
		}
71
		return viewAndInfoPanel;
72
	}
73

  
74
	private PixelViewPanel getViewPanel() {
75
		if(viewPanel == null)
76
			viewPanel = new PixelViewPanel(tr, getInfoByPointDataModel());
77
		return viewPanel;
78
	}
79

  
80
	private InfoByPointPanel getInfoByPointPanel() {
81
		if(infoByPointPanel == null)
82
			infoByPointPanel = new InfoByPointPanel(tr, getInfoByPointDataModel());
83
		return infoByPointPanel;
84
	}
85
	
86
	public InfoByPointDataModel getInfoByPointDataModel() {
87
		if(dataModel == null)
88
			dataModel = new InfoByPointDataModel();
89
		return dataModel;
90
	}
91
	
92
	public void updateDataModel() {
93
		getInfoByPointPanel().updateDataModel();
94
		getViewPanel().updateDataModel();
95
		getViewAndInfoPanel().updateDataModel();
96
	}
97

  
98
}
0 99

  
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/gui/ViewAndInfoPanel.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.gui;
23

  
24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26

  
27
import javax.swing.JPanel;
28

  
29
public class ViewAndInfoPanel extends JPanel {
30
	private static final long   serialVersionUID   = 1L;
31
	private PixelViewPanel      pixelViewPanel     = null;
32
	private InfoByPointPanel    infoByPointPanel   = null;
33
	
34
	public ViewAndInfoPanel(PixelViewPanel pixelViewPanel, InfoByPointPanel infoByPointPanel) {
35
		this.pixelViewPanel = pixelViewPanel;
36
		this.infoByPointPanel = infoByPointPanel;
37
		init();
38
	}
39
	
40
	public void init() {
41
		setLayout(new GridBagLayout());
42
		GridBagConstraints gbc = new GridBagConstraints();
43
		gbc.gridx = 0;
44
		gbc.gridy = 0;
45
		gbc.anchor = GridBagConstraints.WEST;
46
		gbc.fill = GridBagConstraints.HORIZONTAL;
47
		gbc.weightx = 1;
48
		gbc.insets = new java.awt.Insets(1, 2, 1, 2);
49
		add(pixelViewPanel, gbc);
50
		
51
		gbc.gridy = 1;
52
		add(infoByPointPanel, gbc);
53
	}
54
	
55
	public void updateDataModel() {
56
		pixelViewPanel.updateDataModel();
57
		infoByPointPanel.updateDataModel();
58
	}
59
}
0 60

  
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/gui/InfoByPointDataModel.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.gui;
23

  
24
import java.awt.geom.Point2D;
25
import java.util.ArrayList;
26
import java.util.List;
27

  
28
public class InfoByPointDataModel {
29
	private static final int   LONG_STRING             = 22;
30
	public int                 bands                   = 0;
31
	public List<Double>        bandsValues             = new ArrayList<Double>();
32
	public Point2D             pixelPoint              = new Point2D.Double();
33
	public Point2D             worldPoint              = new Point2D.Double();
34
	public Point2D             viewPoint               = new Point2D.Double();
35
	public int[]               argb                    = new int[4];
36
	public int[]               cmyk                    = new int[4];
37
	public double[]            hsl                     = new double[3];
38
	public List<String>        layers                  = new ArrayList<String>();
39
	
40
	public void setBandValues(double[] list) {
41
		bandsValues.clear();
42
		for (int i = 0; i < list.length; i++) {
43
			bandsValues.add(list[i]);
44
		}
45
	}
46
	
47
	public void setNumberOfBands(int n) {
48
		this.bands = n;
49
	}
50
	
51
	public void setLayerList(String[] list) {
52
		layers.clear();
53
		for (int i = 0; i < list.length; i++) {
54
			layers.add(list[i]);
55
		}
56
	}
57
	
58
	public void setARGB(int a, int r, int g, int b) {
59
		argb[0] = a;
60
		argb[1] = r;
61
		argb[2] = g;
62
		argb[3] = b;
63
	}
64
	
65
	public void setCMYK(int c, int m, int i, int k) {
66
		cmyk[0] = c;
67
		cmyk[1] = m;
68
		cmyk[2] = i;
69
		cmyk[3] = k;
70
	}
71
	
72
	public void setHSL(double h, double s, double l) {
73
		hsl[0] = h;
74
		hsl[1] = s;
75
		hsl[2] = l;
76
	}
77
	
78
	public void setPixelPoint(double x, double y) {
79
		pixelPoint.setLocation(x, y);
80
	}
81
	
82
	public void setWorldPoint(double x, double y) {
83
		worldPoint.setLocation(x, y);
84
	}
85
	
86
	public void setViewPoint(double x, double y) {
87
		viewPoint.setLocation(x, y);
88
	}
89
	
90
	public String getFormatedLayerName(int i) {
91
		return "..." + layers.get(i).substring(layers.get(i).length() - LONG_STRING, layers.get(i).length());
92
	}
93
}
0 94

  
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/gui/PixelViewPanel.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.gui;
23

  
24
import java.util.HashMap;
25

  
26
import javax.swing.JPanel;
27

  
28
public class PixelViewPanel extends JPanel {
29
	private static final long           serialVersionUID        = 1L;
30
	private HashMap<String, String>     tr                      = null;
31
	private InfoByPointDataModel        dataModel               = null;
32
	
33
	public PixelViewPanel(HashMap<String, String> translations, InfoByPointDataModel dataModel) {
34
		tr = translations;
35
		if(tr == null || tr.get("layer_list") == null) {
36
			tr = new HashMap<String, String>();
37
			tr.put("layer_list", "layer_list");
38
			tr.put("band_values", "band_values");
39
			tr.put("pixel_point", "pixel_point");
40
			tr.put("view_point", "view_point");
41
			tr.put("world_point", "world_point");
42
			tr.put("bands", "bands");
43
			tr.put("colors", "colors");
44
			tr.put("coords", "coords");
45
			tr.put("lat", "lat");
46
			tr.put("long", "long");
47
		}
48
		this.dataModel = dataModel;
49
		init();
50
	}
51
	
52
	private void init() {
53
		
54
	}
55
	
56
	public void updateDataModel() {
57
		
58
	}
59
}
0 60

  
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/gui/InfoByPointPanel.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.gui;
23

  
24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.awt.event.ActionEvent;
27
import java.awt.event.ActionListener;
28
import java.text.DecimalFormat;
29
import java.util.HashMap;
30

  
31
import javax.swing.BorderFactory;
32
import javax.swing.DefaultListModel;
33
import javax.swing.JComboBox;
34
import javax.swing.JLabel;
35
import javax.swing.JList;
36
import javax.swing.JPanel;
37
import javax.swing.JScrollPane;
38
import javax.swing.JTextField;
39

  
40
public class InfoByPointPanel extends JPanel implements ActionListener {
41
	private static final long    serialVersionUID        = 1L;
42
	private HashMap<String, String>            
43
	                             tr                      = null;
44
	private JList                jListBandValues         = null;
45
	private JLabel               jLabelHSLPoint          = null;
46
	private JLabel               jLabelCMKYPoint         = null;
47
	private JLabel               jLabelRGBPoint          = null;
48
	private JLabel               jLabelPixelPoint        = null;
49
	private JLabel               jLabelViewPoint         = null;
50
	private JLabel               jLabelLatitudePoint     = null;
51
	private JLabel               jLabelLongitudPoint     = null;
52
	private JLabel               jLabelNumberOfBands     = null;
53
	private JTextField           jTextBoxLayerSelected   = null;
54
	private JComboBox            jComboListLayer         = null;
55
	
56
	private JPanel               jPanelLayerNames        = null;
57
	private JPanel               jPanelCoordinates       = null;
58
	private JPanel               jPanelColors            = null;
59
	private JPanel               jPanelBands             = null;
60
	private InfoByPointDataModel dataModel              = null;
61
	
62
	public InfoByPointPanel(HashMap<String, String> translations, InfoByPointDataModel dataModel) {
63
		tr = translations;
64
		if(tr == null || tr.get("layer_list") == null) {
65
			tr = new HashMap<String, String>();
66
			tr.put("layer_list", "layer_list");
67
			tr.put("band_values", "band_values");
68
			tr.put("pixel_point", "pixel_point");
69
			tr.put("view_point", "view_point");
70
			tr.put("world_point", "world_point");
71
			tr.put("bands", "bands");
72
			tr.put("colors", "colors");
73
			tr.put("coords", "coords");
74
			tr.put("lat", "lat");
75
			tr.put("long", "long");
76
		}
77
		this.dataModel = dataModel;
78
		init();
79
	}
80
	
81
	private void init() {
82
		setLayout(new GridBagLayout());
83
		GridBagConstraints gbc = new GridBagConstraints();
84
		gbc.gridx = 0;
85
		gbc.gridy = 0;
86
		gbc.anchor = GridBagConstraints.WEST;
87
		gbc.fill = GridBagConstraints.HORIZONTAL;
88
		gbc.weightx = 1;
89
		gbc.insets = new java.awt.Insets(1, 2, 1, 2);
90
		add(getJPanelLayerNames(), gbc);
91
		
92
		gbc.gridy = 3;
93
		add(getJPanelCoordinates(), gbc);
94
		
95
		gbc.gridy = 4;
96
		gbc.fill = GridBagConstraints.BOTH;
97
		gbc.weighty = 1;
98
		add(getJPanelBands(), gbc);
99
		
100
		gbc.gridy = 5;
101
		gbc.weighty = 0;
102
		gbc.fill = GridBagConstraints.HORIZONTAL;
103
		add(getJPanelColors(), gbc);
104
	}
105
	
106
	public JPanel getJPanelLayerNames() {
107
		if(jPanelLayerNames == null) {
108
			jPanelLayerNames = new JPanel();
109
			jPanelLayerNames.setBorder(BorderFactory.createTitledBorder(tr.get("layer_list")));
110
			jPanelLayerNames.setLayout(new GridBagLayout());
111
			GridBagConstraints gbc = new GridBagConstraints();
112
			gbc.gridx = 0;
113
			gbc.gridy = 0;
114
			gbc.anchor = GridBagConstraints.WEST;
115
			gbc.fill = GridBagConstraints.HORIZONTAL;
116
			gbc.weightx = 1;
117
			gbc.insets = new java.awt.Insets(1, 2, 2, 2);
118
			
119
			jPanelLayerNames.add(getJComboListLayer(), gbc);
120
			gbc.gridy = 1;
121
			jPanelLayerNames.add(getJTextBoxLayerSelected(), gbc);
122
		}
123
		return jPanelLayerNames;
124
	}
125
	
126
	public JPanel getJPanelBands() {
127
		if(jPanelBands == null) {
128
			jPanelBands = new JPanel();
129
			jPanelBands.setBorder(BorderFactory.createTitledBorder(tr.get("bands")));
130
			jPanelBands.setLayout(new GridBagLayout());
131
			GridBagConstraints gbc = new GridBagConstraints();
132
			gbc.gridx = 0;
133
			gbc.gridy = 0;
134
			gbc.anchor = GridBagConstraints.WEST;
135
			gbc.fill = GridBagConstraints.HORIZONTAL;
136
			gbc.weightx = 1;
137
			gbc.insets = new java.awt.Insets(1, 2, 1, 2);
138
			
139
			jPanelBands.add(getJLabelNumberOfBands(), gbc);
140
			gbc.gridy = 1;
141
			gbc.gridheight = 2;
142
			gbc.fill = GridBagConstraints.BOTH;
143
			gbc.weighty = 1;
144
			JScrollPane listScroller = new JScrollPane(getJListValues());
145
			jPanelBands.add(listScroller, gbc);
146
		}
147
		return jPanelBands;
148
	}
149

  
150
	public JPanel getJPanelColors() {
151
		if(jPanelColors == null) {
152
			jPanelColors = new JPanel();
153
			jPanelColors.setBorder(BorderFactory.createTitledBorder(tr.get("colors")));
154
			jPanelColors.setLayout(new GridBagLayout());
155
			GridBagConstraints gbc = new GridBagConstraints();
156
			gbc.gridx = 0;
157
			gbc.gridy = 0;
158
			gbc.anchor = GridBagConstraints.WEST;
159
			gbc.fill = GridBagConstraints.HORIZONTAL;
160
			gbc.weightx = 1;
161
			gbc.insets = new java.awt.Insets(1, 2, 2, 2);
162
			
163
			jPanelColors.add(getJLabelRGBPoint(), gbc);
164
			gbc.gridy = 1;
165
			jPanelColors.add(getJLabelCMKYPoint(), gbc);
166
			gbc.gridy = 2;
167
			jPanelColors.add(getJLabelHSLPoint(), gbc);
168
		}
169
		return jPanelColors;
170
	}
171

  
172
	public JPanel getJPanelCoordinates() {
173
		if(jPanelCoordinates == null) {
174
			jPanelCoordinates = new JPanel();
175
			jPanelCoordinates.setLayout(new GridBagLayout());
176
			jPanelCoordinates.setBorder(BorderFactory.createTitledBorder(tr.get("coords")));
177
			GridBagConstraints gbc = new GridBagConstraints();
178
			gbc.gridx = 0;
179
			gbc.gridy = 0;
180
			gbc.anchor = GridBagConstraints.WEST;
181
			gbc.fill = GridBagConstraints.HORIZONTAL;
182
			gbc.weightx = 1;
183
			gbc.insets = new java.awt.Insets(1, 2, 2, 2);
184
			
185
			gbc.gridy = 1;
186
			jPanelCoordinates.add(getJLabelLatitudePoint(), gbc);
187
			gbc.gridy = 2;
188
			jPanelCoordinates.add(getJLabelLongitudPoint(), gbc);
189
			gbc.gridy = 3;
190
			jPanelCoordinates.add(getJLabelViewPoint(), gbc);
191
			gbc.gridy = 4;
192
			jPanelCoordinates.add(getJLabelPixelPoint(), gbc);
193
		}
194
		return jPanelCoordinates;
195
	}
196

  
197
	private JList getJListValues() {
198
		if(jListBandValues == null) {
199
			jListBandValues = new JList();
200
		}
201
		return jListBandValues;
202
	}
203

  
204
	private JLabel getJLabelHSLPoint() {
205
		if(jLabelHSLPoint == null)
206
			jLabelHSLPoint = new JLabel("HSL: ");
207
		return jLabelHSLPoint;
208
	}
209

  
210
	private JLabel getJLabelCMKYPoint() {
211
		if(jLabelCMKYPoint == null)
212
			jLabelCMKYPoint = new JLabel("CMYK: ");
213
		return jLabelCMKYPoint;
214
	}
215

  
216
	private JLabel getJLabelRGBPoint() {
217
		if(jLabelRGBPoint == null)
218
			jLabelRGBPoint = new JLabel("RGB: " );
219
		return jLabelRGBPoint;
220
	}
221

  
222
	private JLabel getJLabelPixelPoint() {
223
		if(jLabelPixelPoint == null)
224
			jLabelPixelPoint = new JLabel();
225
		return jLabelPixelPoint;
226
	}
227

  
228
	private JLabel getJLabelViewPoint() {
229
		if(jLabelViewPoint == null)
230
			jLabelViewPoint = new JLabel();
231
		return jLabelViewPoint;
232
	}
233
	
234
	private JLabel getJLabelLatitudePoint() {
235
		if(jLabelLatitudePoint == null)
236
			jLabelLatitudePoint = new JLabel();
237
		return jLabelLatitudePoint;
238
	}
239
	
240
	private JLabel getJLabelLongitudPoint() {
241
		if(jLabelLongitudPoint == null)
242
			jLabelLongitudPoint = new JLabel();
243
		return jLabelLongitudPoint;
244
	}
245

  
246
	private JLabel getJLabelNumberOfBands() {
247
		if(jLabelNumberOfBands == null)
248
			jLabelNumberOfBands = new JLabel();
249
		return jLabelNumberOfBands;
250
	}
251

  
252
	private JTextField getJTextBoxLayerSelected() {
253
		if(jTextBoxLayerSelected == null)
254
			jTextBoxLayerSelected = new JTextField();
255
		return jTextBoxLayerSelected;
256
	}
257

  
258
	private JComboBox getJComboListLayer() {
259
		if(jComboListLayer == null) {
260
			jComboListLayer = new JComboBox();
261
			jComboListLayer.addActionListener(this);
262
		}
263
		return jComboListLayer;
264
	}
265
	
266
	public void updateDataModel() {
267
		DecimalFormat df = new DecimalFormat("#.##");
268
		getJLabelNumberOfBands().setText(tr.get("bands") + ": " + dataModel.bands);
269
		
270
		getJLabelLatitudePoint().setText(tr.get("lat") + ": " + 
271
				df.format(dataModel.worldPoint.getY()));
272
		
273
		getJLabelLongitudPoint().setText(tr.get("long") + ": " + 
274
				df.format(dataModel.worldPoint.getX()));
275
		
276
		getJLabelViewPoint().setText(tr.get("view_point") + ": (" + 
277
				df.format(dataModel.viewPoint.getX()) + ", " + 
278
				df.format(dataModel.viewPoint.getY() )+ ")");
279
		
280
		getJLabelPixelPoint().setText(tr.get("pixel_point") + ": (" + 
281
				df.format(dataModel.pixelPoint.getX()) + ", " + 
282
				df.format(dataModel.pixelPoint.getY() )+ ")");
283
		
284
		getJLabelRGBPoint().setText("ARGB: " + dataModel.argb[0] + ", " + 
285
											dataModel.argb[1] + ", " + 
286
											dataModel.argb[2] + ", " + 
287
											dataModel.argb[3]);
288
		getJLabelHSLPoint().setText("HSL: " + dataModel.hsl[0] + ", " + 
289
											dataModel.hsl[1] + ", " + 
290
											dataModel.hsl[2]);
291
		getJLabelCMKYPoint().setText("CMYK: " + dataModel.cmyk[0] + ", " + 
292
											dataModel.cmyk[1] + ", " + 
293
											dataModel.cmyk[2]);
294
		
295
		getJComboListLayer().removeAllItems();
296
		for (int i = 0; i < dataModel.layers.size(); i++) {
297
			getJComboListLayer().addItem(dataModel.getFormatedLayerName(i));	
298
		}
299
		
300
		if(dataModel.layers.size() > 0)
301
			getJTextBoxLayerSelected().setText(dataModel.layers.get(0));
302
		
303
		DefaultListModel listModel = null;
304
		if(getJListValues().getModel() == null || !(getJListValues().getModel() instanceof DefaultListModel))
305
			listModel = new DefaultListModel();
306
		else
307
			listModel = (DefaultListModel)getJListValues().getModel();
308
		listModel.clear();
309
		for (int i = 0; i < dataModel.bandsValues.size(); i++) {
310
			listModel.addElement("B" + i + ": " + dataModel.bandsValues.get(i));	
311
		}
312
		if(getJListValues().getModel() == null || !(getJListValues().getModel() instanceof DefaultListModel))
313
			getJListValues().setModel(listModel);
314
	}
315

  
316
	public void actionPerformed(ActionEvent e) {
317
		if(e.getSource() == getJComboListLayer()) {
318
			getJTextBoxLayerSelected().setText(dataModel.layers.get(getJComboListLayer().getSelectedIndex()));
319
		}
320
	}
321
	
322
}
0 323

  
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/MainInfoByPointDialog.java
1
package org.gvsig.raster.tools.app.basic.tool.infobypoint;
2

  
3
import java.awt.BorderLayout;
4
import java.util.HashMap;
5

  
6
import javax.swing.JPanel;
7
import javax.swing.event.ChangeEvent;
8
import javax.swing.event.ChangeListener;
9

  
10
import org.gvsig.andami.PluginServices;
11
import org.gvsig.andami.ui.mdiManager.IWindow;
12
import org.gvsig.andami.ui.mdiManager.WindowInfo;
13
import org.gvsig.raster.tools.app.basic.tool.infobypoint.gui.InfoByPointDataModel;
14
import org.gvsig.raster.tools.app.basic.tool.infobypoint.gui.MainInfoByPointPanel;
15

  
16
public class MainInfoByPointDialog extends JPanel implements IWindow, ChangeListener {
17
	private static final long               serialVersionUID   = 1L;
18
	private MainInfoByPointPanel            mainPanel          = null;
19
	
20
	public MainInfoByPointDialog() {
21
		setLayout(new BorderLayout());
22
		add(getMainPanel(), BorderLayout.CENTER);
23
		getMainPanel().getTabs().addChangeListener(this);
24
	}
25
	
26
	public MainInfoByPointPanel getMainPanel() {
27
		if(mainPanel == null) { 
28
			HashMap<String, String> translations = new HashMap<String, String>();
29
			translations.put("info", PluginServices.getText(this, "info"));
30
			translations.put("view", PluginServices.getText(this, "view"));
31
			translations.put("layer_list", PluginServices.getText(this, "layer_list"));
32
			translations.put("band_values", PluginServices.getText(this, "band_values"));
33
			translations.put("pixel_point", PluginServices.getText(this, "pixel_point"));
34
			translations.put("view_point", PluginServices.getText(this, "view_point"));
35
			translations.put("world_point", PluginServices.getText(this, "world_point"));
36
			translations.put("bands", PluginServices.getText(this, "bands"));
37
			translations.put("colors", PluginServices.getText(this, "colors"));
38
			translations.put("coords", PluginServices.getText(this, "coords"));
39
			translations.put("lat", PluginServices.getText(this, "lat"));
40
			translations.put("long", PluginServices.getText(this, "long"));
41
			translations.put("view_and_info", PluginServices.getText(this, "view_and_info"));
42
			mainPanel = new MainInfoByPointPanel(translations);
43
		}
44
		return mainPanel;
45
	}
46

  
47
	/*
48
	 * (non-Javadoc)
49
	 * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
50
	 */
51
	public WindowInfo getWindowInfo() {
52
		WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG);
53
		m_viewinfo.setTitle(PluginServices.getText(this, "InfoByPoint"));
54
		m_viewinfo.setHeight(350);
55
		m_viewinfo.setWidth(250);
56
		return m_viewinfo;
57
	}
58
	
59
	public Object getWindowProfile() {
60
		return WindowInfo.PROPERTIES_PROFILE;
61
	}
62
	
63
	public void updateDataModel() {
64
		getMainPanel().updateDataModel();
65
	}
66

  
67
	public InfoByPointDataModel getInfoByPointDataModel() {
68
		return getMainPanel().getInfoByPointDataModel();
69
	}
70
	
71
	public void stateChanged(ChangeEvent e) {
72
		if(e.getSource() == getMainPanel().getTabs()) {
73
			if(getMainPanel().getTabs().getSelectedIndex() == 2) {
74
			} else {
75
			}
76
		}
77
	}
78

  
79
}
0 80

  
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/viewtool/InfoByPixelPointListener.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

  
27
import org.gvsig.andami.PluginServices;
28
import org.gvsig.fmap.mapcontrol.MapControl;
29
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
30
import org.gvsig.raster.tools.app.basic.tool.infobypoint.gui.InfoByPointDataModel;
31
import org.gvsig.raster.tools.app.basic.tool.selectrasterlayer.SelectImageListImpl;
32

  
33
/**
34
 * Extensi?n de la clase SelectImageListenerImple de FMap. Esta clase permite
35
 * capturar el evento de la selecci?n de un punto RGB sobre la vista
36
 * 
37
 * 22/02/2008
38
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
39
 */
40
public class InfoByPixelPointListener extends SelectImageListImpl {
41
	private InfoByPointDataModel model = null;
42
	
43
	/**
44
	 * Contructor
45
	 * @param mapCtrl
46
	 */
47
	public InfoByPixelPointListener(MapControl mapCtrl, InfoByPointDataModel model) {
48
		super(mapCtrl);
49
		this.model = model;
50
	}
51

  
52
	/* (non-Javadoc)
53
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
54
	 */
55
	public void point(PointEvent event) {
56
		super.point(event);
57

  
58
		Point2D point2D = event.getPoint();
59

  
60
		if (PluginServices.getMainFrame() != null)
61
			PluginServices.getMainFrame().enableControls();
62

  
63
		BufferedImage image = mapCtrl.getImage();
64
		int value = image.getRGB((int) point2D.getX(), (int) point2D.getY());
65
		int r = (value >> 16) & 0xff;
66
		int g = (value >> 8) & 0xff;
67
		int b = value & 0xff;
68
		int a = image.getTransparency();
69
		
70
		model.setARGB(a, r, g, b);
71
	}
72
}
0 73

  
org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app/org.gvsig.raster.tools.app.basic/src/test/java/org/gvsig/raster/app/extension/TestInfoByPointPanel.java
1
package org.gvsig.raster.app.extension;
2

  
3
import javax.swing.JFrame;
4
import javax.swing.event.ChangeEvent;
5
import javax.swing.event.ChangeListener;
6

  
7
import org.gvsig.raster.tools.app.basic.tool.infobypoint.gui.InfoByPointDataModel;
8
import org.gvsig.raster.tools.app.basic.tool.infobypoint.gui.MainInfoByPointPanel;
9

  
10
public class TestInfoByPointPanel implements ChangeListener {
11
		private int                          w        = 280;
12
		private int                          h        = 410;
13
		private JFrame                       frame    = new JFrame();
14
		private MainInfoByPointPanel         desc     = null;
15

  
16
		public TestInfoByPointPanel() {
17
			desc = new MainInfoByPointPanel(null);
18
			desc.getTabs().addChangeListener(this);
19
			InfoByPointDataModel model = desc.getInfoByPointDataModel();
20
			model.setARGB(0, 255, 125, 110);
21
			model.setCMYK(54, 254, 121, 190);
22
			model.setHSL(234.3, 125.5, 110.3);
23
			model.setBandValues(new double[]{4.53, 2.24, 67.7, 67.87});
24
			model.setNumberOfBands(4);
25
			model.setPixelPoint(100, 105);
26
			model.setViewPoint(305, 405);
27
			model.setWorldPoint(20554523.32, 19362125.23);
28
			model.setLayerList(new String[]{
29
					"Esta_es_la_capa_numero_uno_de_la_lista_de_capas.jpg",
30
					"Esta_es_la_capa_segunda_de_la_lista_de_capas_del_info_by_point.jpg"});
31
			desc.updateDataModel();
32
			frame.getContentPane().add(desc);
33
			frame.setSize(w, h);
34
			frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
35
			frame.setVisible(true);
36
		}
37

  
38
		public static void main(String[] args) {
39
			new TestInfoByPointPanel();
40
		}
41

  
42
		public void stateChanged(ChangeEvent e) {
43
			if(e.getSource() == desc.getTabs()) {
44
				if(desc.getTabs().getSelectedIndex() == 2) {
45
					frame.setSize(w, 600);
46
				} else {
47
					frame.setSize(w, h);
48
				}
49
			}
50
		}
51
	}
0 52

  

Also available in: Unified diff