Revision 19729

View differences:

trunk/extensions/extRemoteSensing/src/org/gvsig/remotesensing/profiles/gui/ProfileDialog.java
53 53
import com.iver.andami.ui.mdiManager.IWindowListener;
54 54
import com.iver.andami.ui.mdiManager.WindowInfo;
55 55
import com.iver.cit.gvsig.fmap.MapControl;
56
import com.iver.cit.gvsig.fmap.layers.GraphicLayer;
56 57
import com.iver.cit.gvsig.project.documents.view.gui.View;
57 58

  
58 59
/**
......
66 67
public class ProfileDialog extends JPanel implements IWindow, IWindowListener, ButtonsPanelListener {
67 68
	
68 69
	private static final long serialVersionUID = 2847035927527203595L;
69
	private ProfilePanel zProfilePanel = null;
70
	private ProfilePanel profilePanel = null;
70 71
	private MapControl mapControl = null;
71 72
	private String previousTool = null;
72 73
	
......
79 80
		this.setSize(width, height);
80 81
		this.setLayout(new BorderLayout());
81 82
		mapControl = view.getMapControl();
82
		this.add(getZProfilePanel(), BorderLayout.CENTER);
83
		this.add(getProfilePanel(), BorderLayout.CENTER);
83 84
		previousTool = mapControl.getCurrentTool();
84 85
	}
85 86
	
......
118 119
	/** Recupera la herramienta previa seleccionada */
119 120
	public void setPreviousTool(){
120 121
		if (previousTool!=null)
121
			getZProfilePanel().getMapControl().setTool(previousTool);
122
			getProfilePanel().getMapControl().setTool(previousTool);
122 123
	}
123 124

  
124 125
	public void windowActivated() {
......
126 127
	}
127 128

  
128 129
	public void windowClosed() {
129
		getZProfilePanel().getMapControl().rePaintDirtyLayers();
130
		GraphicLayer graphicLayer = mapControl.getMapContext().getGraphicsLayer();
131
		graphicLayer.clearAllGraphics();
132
		graphicLayer.clearSymbolsGraphics();
133
		getProfilePanel().getMapControl().rePaintDirtyLayers();
130 134
		setPreviousTool();
131 135
	}
132 136

  
133 137
	
134 138
	/**
135
	 *  @return scatterplotpanel
139
	 *  @return ProfilePanel. Panel principal
136 140
	 * */
137
	public ProfilePanel getZProfilePanel() {
138
		if (zProfilePanel == null){
139
			zProfilePanel = new ProfilePanel(this);
140
			zProfilePanel.addButtonPressedListener(this);
141
	public ProfilePanel getProfilePanel() {
142
		if (profilePanel == null){
143
			profilePanel = new ProfilePanel(this);
144
			profilePanel.addButtonPressedListener(this);
141 145
		}
142
		return zProfilePanel;
146
		return profilePanel;
143 147
	}
144 148

  
145 149

  
trunk/extensions/extRemoteSensing/src/org/gvsig/remotesensing/profiles/gui/ProfilePanel.java
42 42

  
43 43
import java.awt.BorderLayout;
44 44
import java.awt.Dimension;
45
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionListener;
47
import java.util.Iterator;
48 45

  
49 46
import javax.swing.JPanel;
50 47
import javax.swing.JTabbedPane;
51 48
import javax.swing.event.ChangeEvent;
52 49
import javax.swing.event.ChangeListener;
53 50

  
54
import org.gvsig.fmap.raster.grid.roi.VectorialROI;
55 51
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
56 52
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel;
57 53
import org.gvsig.gui.beans.graphic.GraphicChartPanel;
58
import org.jfree.chart.axis.NumberAxis;
59
import org.jfree.chart.axis.NumberTickUnit;
60
import org.jfree.chart.plot.XYPlot;
61 54

  
62 55
import com.iver.andami.PluginServices;
63 56
import com.iver.cit.gvsig.fmap.MapControl;
57
import com.iver.cit.gvsig.fmap.layers.GraphicLayer;
64 58

  
65 59
/**
66
 * Clase que define el panel donde aparece el grafico de del perfil espectral de los puntos que seleccione el 
60
 * Clase que define el panel donde aparece el grafico  del perfil espectral de los puntos que seleccione el 
67 61
 * usuario.
68 62
 * 
69 63
 * @author aMu?oz (alejandro.munoz@uclm.es)  
......
72 66

  
73 67
public class ProfilePanel  extends DefaultButtonsPanel implements ChangeListener{
74 68
	
75
	private static final long 		serialVersionUID = 1L;
76
	private GraphicChartPanel		jPanelChart = null;
77
	private MapControl mapControl = null;;
78
	private JPanel southPanel = null;
79
	private ZProfileOptionsPanel  pointOptionsPanel= null;
80
	private LineProfileOptionsPanel  lineOptionsPanel= null;
81
	private JTabbedPane tabbedPane  = null;
69
	private static final long 			serialVersionUID = 1L;
70
	private GraphicChartPanel			jPanelChart = null;
71
	private MapControl 					mapControl = null;;
72
	private JPanel 						southPanel = null;
73
	private ZProfileOptionsPanel  		pointOptionsPanel= null;
74
	private LineProfileOptionsPanel  	lineOptionsPanel= null;
75
	private JTabbedPane 				tabbedPane  = null;
76
	public static int 					PANELZPROFILE = 0;
77
	public static int 					PANELLINEPROFILE =1;
78
	private int 						nextActiveChart = 0; 
82 79
	
83 80
	/**  Constructor del panel.
84 81
	 *   @param flayer capa de la que se van a tomar los puntos 
......
109 106
			 jPanelChart.getChart().setDomainZoomable(false);
110 107
			 jPanelChart.getChart().setRangeZoomable(false);
111 108
			 jPanelChart.getChart().setDisplayToolTips(true);
112
			
113 109
		}
114 110
		return 	jPanelChart;
115 111
	}
116 112

  
117 113
	
118
	
119 114
	public MapControl getMapControl() {
120 115
		return mapControl ;
121 116
	}
122 117

  
123 118
	
124
	
119
	/**
120
	 * Panel con los tab. 
121
	 * */
125 122
	public JPanel getSouthPanel(){
126 123
		if(southPanel== null){
127 124
			southPanel= new JPanel();
......
129 126
			southPanel.setLayout(bd);
130 127
			southPanel.setPreferredSize(new Dimension(150,110));
131 128
		 	getTabbedPane().addTab(PluginServices.getText(this, "zProfile"), getPointOptionsPanel());
132
			getTabbedPane().addTab(PluginServices.getText(this, "opciones"), getLineOptionsPanel());
133
			//southPanel.add(getTabbedPane(), BorderLayout.SOUTH);
129
			getTabbedPane().addTab(PluginServices.getText(this, "lineProfile"), getLineOptionsPanel());
134 130
			southPanel.add(getTabbedPane(),BorderLayout.CENTER);
135 131
		}
136 132
		return southPanel;
137
		
138 133
	}
139 134
	
140 135
	
141
	
136
	/** @return panel con las opciones zProfiles */
142 137
	public ZProfileOptionsPanel getPointOptionsPanel(){
143 138
		if(pointOptionsPanel==null){
144
			pointOptionsPanel= new ZProfileOptionsPanel(mapControl);
145
			pointOptionsPanel.setMainPanel(this);
139
			pointOptionsPanel= new ZProfileOptionsPanel(this);
146 140
			pointOptionsPanel.setJPanelChart(getChart());
147 141
		}
148 142
		return pointOptionsPanel;
149 143
	}
150 144
	
151
	
145
	/** @return panel con las opciones lineProfiles */
152 146
	public LineProfileOptionsPanel getLineOptionsPanel(){
153 147
		if(lineOptionsPanel==null){
154
			lineOptionsPanel= new LineProfileOptionsPanel(mapControl);
155
			lineOptionsPanel.setMainPanel(this);
148
			lineOptionsPanel= new LineProfileOptionsPanel(this);
156 149
			lineOptionsPanel.setJPanelChart(getChart());
157 150
		}
158 151
		return lineOptionsPanel;
159 152
	}
160 153
	
161
	/**
162
	 * 	Actualiza los colores las graficas en funcion de los colores de las rois de la tabla
163
	 * */
164
	public void UpdateColorsChart(){
165
		XYPlot plot = jPanelChart.getChart().getChart().getXYPlot();
166
		int index=-1; 
167
		for (Iterator iter = getPointOptionsPanel().getROIs().iterator(); iter.hasNext();){
168
			VectorialROI roi = (VectorialROI)iter.next();
169
			index=index+1;
170
			plot.getRenderer().setSeriesPaint(index, roi.getColor());
171
		}	
172
	}
173

  
174

  
154
	
175 155
	public  JTabbedPane getTabbedPane(){
176 156
		if(tabbedPane==null){
177 157
			tabbedPane= new JTabbedPane();
......
181 161
	}
182 162
	
183 163
	public void stateChanged(ChangeEvent e) {
184
		// TODO Auto-generated method stub
185 164
		if(e.getSource().equals(getTabbedPane())){
186
			System.out.print("Cambiando pesta?a");
165
	
166
			if(nextActiveChart==PANELZPROFILE){
167
				// Cambia las propiedades del grafico
168
				getPointOptionsPanel().getJPanelChart();
169
				GraphicLayer graphicLayer = mapControl.getMapContext().getGraphicsLayer();
170
				graphicLayer.clearAllGraphics();
171
				graphicLayer.clearSymbolsGraphics();
172
				getPointOptionsPanel().selectDrawRoiTool();
173
				mapControl.rePaintDirtyLayers();
174
				nextActiveChart = PANELLINEPROFILE;
175
				
176
			}
177
			
178
			else if(nextActiveChart == PANELLINEPROFILE){
179
				getLineOptionsPanel().getJPanelChart();
180
				GraphicLayer graphicLayer = mapControl.getMapContext().getGraphicsLayer();
181
				graphicLayer.clearAllGraphics();
182
				getLineOptionsPanel().selectDrawRoiTool();
183
				graphicLayer.clearSymbolsGraphics();
184
				mapControl.rePaintDirtyLayers();
185
				nextActiveChart= PANELZPROFILE;
186
				
187
			}
187 188
		}
188 189
	}
189 190

  
190 191

  
192
	public int getActivePanel(){
193
		return nextActiveChart;
194
	}
191 195
	
192 196
}
trunk/extensions/extRemoteSensing/src/org/gvsig/remotesensing/profiles/gui/LineProfileOptionsPanel.java
9 9
import java.awt.Toolkit;
10 10
import java.util.ArrayList;
11 11
import java.util.HashMap;
12
import java.util.Iterator;
12 13
import java.util.LinkedHashMap;
13 14

  
14 15
import javax.swing.ComboBoxModel;
......
17 18
import javax.swing.JPanel;
18 19
import javax.swing.JToggleButton;
19 20

  
21
import org.gvsig.fmap.raster.grid.roi.VectorialROI;
20 22
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
21 23
import org.gvsig.gui.beans.graphic.GraphicChartPanel;
22 24
import org.gvsig.gui.beans.table.TableContainer;
......
59 61
	private ProfilePanel mainPanel= null;
60 62
	private JComboBox comboBands = null;
61 63
	
62
	public LineProfileOptionsPanel(MapControl mapControl) {
64
	public LineProfileOptionsPanel(ProfilePanel mainPanel) {
63 65
		super();
64
		this.mapControl = mapControl;
66
		this.mapControl = mainPanel.getMapControl();
67
		this.mainPanel = mainPanel;
65 68
		this.fLayer = mapControl.getMapContext().getLayers().getLayer(0);;
66 69
		BorderLayout bd= new BorderLayout();
67 70
		listener= new LineProfileOptionsListener(this);
......
97 100
		}
98 101
		StatusBarListener sbl = new StatusBarListener(mapControl);
99 102
		DrawMouseProfileListener drawMouseViewListener = new DrawMouseProfileListener(
100
				this);
103
				mainPanel);
101 104
		mapControl.addMapTool("drawLineROI", new Behavior[] {
102 105
				new PolylineBehavior(drawMouseViewListener),
103 106
				new MouseMovementBehavior(sbl) });
......
152 155
	public JToggleButton getDeleteButton() {
153 156
		if(deleteButton== null){
154 157
			deleteButton = new JToggleButton();
155
			ImageIcon icono = new ImageIcon(ZProfileOptionsPanel.class.getClassLoader().getResource("images/delete.png"));
158
			ImageIcon icono = new ImageIcon(LineProfileOptionsPanel.class.getClassLoader().getResource("images/delete.png"));
156 159
			deleteButton.setSize(30,30);
157 160
			deleteButton.setIcon(icono);
158 161
		}
......
163 166
	public JToggleButton getNewButton() {
164 167
		if(newButton== null){
165 168
			newButton = new JToggleButton();
166
			ImageIcon icono = new ImageIcon(ZProfileOptionsPanel.class.getClassLoader().getResource("images/Line.png"));
169
			ImageIcon icono = new ImageIcon(LineProfileOptionsPanel.class.getClassLoader().getResource("images/Line.png"));
167 170
			newButton.setIcon(icono);
168 171
			newButton.setSize(30,30);
169 172
		}
......
175 178
	public void selectDrawRoiTool() {
176 179
		if (mapControl != null){
177 180
			if (getNewButton().isSelected()) {
178
				Image img = new ImageIcon(ZProfileOptionsPanel.class.getClassLoader().getResource(
181
				Image img = new ImageIcon(LineProfileOptionsPanel.class.getClassLoader().getResource(
179 182
						"images/LineCursor.png")).getImage();
180 183
				cursor = Toolkit.getDefaultToolkit().createCustomCursor(img,
181 184
						new Point(16, 16), "");
......
244 247

  
245 248

  
246 249
	public GraphicChartPanel getJPanelChart() {
250
		 jPanelChart.cleanChart();
247 251
		 XYPlot plot = jPanelChart.getChart().getChart().getXYPlot();
248 252
		 NumberAxis domainAxis = new NumberAxis(PluginServices.getText(this,"pixeles"));
249 253
	     plot.setDomainAxis(domainAxis);
250
	     
251
		return jPanelChart;
254
	     return jPanelChart;
252 255
	}
253 256

  
254 257

  
......
268 271
	}
269 272
	
270 273
	
271
	public void setMainPanel(ProfilePanel mainPanel){
272
		this.mainPanel=mainPanel;  
273
		
274
	}
275
	
276 274
	public void UpdateChart(){
277
		mainPanel.UpdateColorsChart();
275
		XYPlot plot = jPanelChart.getChart().getChart().getXYPlot();
276
		int index=-1; 
277
		for (Iterator iter = getROIs().iterator(); iter.hasNext();){
278
			VectorialROI roi = (VectorialROI)iter.next();
279
			index=index+1;
280
			plot.getRenderer().setSeriesPaint(index, roi.getColor());
281
		}	
278 282
	}
279 283
	
280 284
	public ROI getROI(String roiName) {
281 285
		return (ROI) getRois().get(roiName);
282 286
	}
287

  
288
	public int getActive(){
289
		return mainPanel.getActivePanel();
290
	}
283 291
}
trunk/extensions/extRemoteSensing/src/org/gvsig/remotesensing/profiles/gui/ZProfileOptionsPanel.java
49 49
import java.awt.Toolkit;
50 50
import java.util.ArrayList;
51 51
import java.util.HashMap;
52
import java.util.Iterator;
52 53
import java.util.LinkedHashMap;
53 54

  
54 55
import javax.swing.ImageIcon;
55 56
import javax.swing.JPanel;
56 57
import javax.swing.JToggleButton;
57 58

  
59
import org.gvsig.fmap.raster.grid.roi.VectorialROI;
58 60
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
59 61
import org.gvsig.gui.beans.graphic.GraphicChartPanel;
60 62
import org.gvsig.gui.beans.table.TableContainer;
......
104 106
	private GraphicChartPanel		jPanelChart = null;
105 107
	private ProfilePanel mainPanel= null;
106 108
	
107
	public  ZProfileOptionsPanel(MapControl mapControl) {
109
	public  ZProfileOptionsPanel(ProfilePanel mainPanel) {
108 110
		super();
109
		this.mapControl = mapControl;
111
		this.mapControl = mainPanel.getMapControl();
112
		this.mainPanel= mainPanel;
110 113
		this.fLayer = mapControl.getMapContext().getLayers().getLayer(0);;
111 114
		BorderLayout bd= new BorderLayout();
112 115
		listener= new ZProfileOptionsListener(this);
......
142 145
		}
143 146
		StatusBarListener sbl = new StatusBarListener(mapControl);
144 147
		DrawMouseProfileListener drawMouseViewListener = new DrawMouseProfileListener(
145
				this);
148
				mainPanel);
146 149
		mapControl.addMapTool("drawPointROI", new Behavior[] {
147 150
				new PointBehavior(drawMouseViewListener),
148 151
				new MouseMovementBehavior(sbl) });
......
272 275

  
273 276

  
274 277
	public GraphicChartPanel getJPanelChart() {
275
		 XYPlot plot = jPanelChart.getChart().getChart().getXYPlot();
276
		 NumberAxis domainAxis = new NumberAxis(PluginServices.getText(this,"bandas"));
277
		 domainAxis.setRange(1,getGrid().getBandCount() );
278
		 domainAxis.setTickUnit(new NumberTickUnit(1.0));
279
	     plot.setDomainAxis(domainAxis);
278
		jPanelChart.cleanChart(); 
279
		XYPlot plot = jPanelChart.getChart().getChart().getXYPlot();
280
		NumberAxis domainAxis = new NumberAxis(PluginServices.getText(this,"bandas"));
281
		domainAxis.setRange(1,getGrid().getBandCount() );
282
		domainAxis.setTickUnit(new NumberTickUnit(1.0));
283
		plot.setDomainAxis(domainAxis);
280 284
		return jPanelChart;
281 285
	}
282 286

  
......
297 301
	}
298 302
	
299 303
	
300
	public void setMainPanel(ProfilePanel mainPanel){
301
		this.mainPanel=mainPanel;  
302
		
303
	}
304 304
	
305 305
	public void UpdateChart(){
306
		mainPanel.UpdateColorsChart();
306
		XYPlot plot = jPanelChart.getChart().getChart().getXYPlot();
307
		int index=-1; 
308
		for (Iterator iter = getROIs().iterator(); iter.hasNext();){
309
			VectorialROI roi = (VectorialROI)iter.next();
310
			index=index+1;
311
			plot.getRenderer().setSeriesPaint(index, roi.getColor());
312
		}	
307 313
	}
308 314
	
309 315
	public ROI getROI(String roiName) {
310 316
		return (ROI) getRois().get(roiName);
311 317
	}
312 318

  
319
	public int getNextActive(){
320
		return mainPanel.getActivePanel();
321
	}
313 322
}

Also available in: Unified diff