Revision 1166

View differences:

org.gvsig.raster.netcdf/tags/buildNumber_14/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.app/distribution/distribution.xml
1
<assembly>
2
</assembly>
0 3

  
org.gvsig.raster.netcdf/tags/buildNumber_14/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.app/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Mon Jun 25 09:22:38 CEST 2012
3
buildNumber=40
0 4

  
org.gvsig.raster.netcdf/tags/buildNumber_14/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.app/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.gvsig.raster.netcdf.app</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.m2e.core.maven2Builder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.m2e.core.maven2Nature</nature>
16
	</natures>
17
</projectDescription>
org.gvsig.raster.netcdf/tags/buildNumber_14/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.app/org.gvsig.raster.netcdf.app.netcdfclient/src/test/java/org/gvsig/raster/netcdf/app/netcdfclient/gui/panel/TestVarSelectionPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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.netcdf.app.netcdfclient.gui.panel;
20

  
21
import javax.swing.JFrame;
22

  
23
public class TestVarSelectionPanel {
24
	private int                          w        = 510;
25
	private int                          h        = 610;
26
	private JFrame                       frame    = new JFrame();
27
	private VariableSelectionPanel       desc     = null;
28

  
29
	public TestVarSelectionPanel() {
30
		desc = new VariableSelectionPanel();
31
		frame.getContentPane().add(desc);
32
		frame.setSize(w, h);
33
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
34
		frame.setVisible(true);
35
	}
36

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

  
org.gvsig.raster.netcdf/tags/buildNumber_14/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.app/org.gvsig.raster.netcdf.app.netcdfclient/src/main/java/org/gvsig/raster/netcdf/app/netcdfclient/NetCDFMenuEntry.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.netcdf.app.netcdfclient;
23
import javax.swing.Icon;
24

  
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction;
27
import org.gvsig.app.project.documents.view.toc.ITocItem;
28
import org.gvsig.fmap.mapcontext.layers.FLayer;
29
import org.gvsig.raster.fmap.layers.FLyrRaster;
30
import org.gvsig.raster.fmap.layers.ILayerState;
31
import org.gvsig.raster.netcdf.app.netcdfclient.gui.panel.NetCDFPanel;
32
import org.gvsig.raster.netcdf.io.NetCDFDataParameters;
33

  
34

  
35
/**
36
 * <p>
37
 * TOC menu entry for NetCDF files
38
 * <p>
39
 * @author Nacho Brodin (nachobrodin@gmail.com)
40
 *
41
 */
42
public class NetCDFMenuEntry extends AbstractTocContextMenuAction {
43
	static private NetCDFMenuEntry    singleton     = null;
44

  
45
	/**
46
	 * Nadie puede crear una instancia a esta clase ?nica, hay que usar el
47
	 * getSingleton()
48
	 */
49
	private NetCDFMenuEntry() {}
50

  
51
	/**
52
	 * Devuelve un objeto unico a dicha clase
53
	 * @return
54
	 */
55
	static public NetCDFMenuEntry getSingleton() {
56
		if (singleton == null)
57
			singleton = new NetCDFMenuEntry();
58
		return singleton;
59

  
60
	}
61

  
62
	/*
63
	 * (non-Javadoc)
64
	 * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroup()
65
	 */
66
	public String getGroup() {
67
		return "Raster";
68
	}
69

  
70
	/*
71
	 * (non-Javadoc)
72
	 * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroupOrder()
73
	 */
74
	public int getGroupOrder() {
75
		return 50;
76
	}
77

  
78
	/*
79
	 * (non-Javadoc)
80
	 * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getOrder()
81
	 */
82
	public int getOrder() {
83
		return 1;
84
	}
85

  
86
	/*
87
	 * (non-Javadoc)
88
	 * @see com.iver.cit.gvsig.project.documents.IContextMenuAction#getText()
89
	 */
90
	public String getText() {
91
		return PluginServices.getText(this, "NetCDF_Variables");
92
	}
93

  
94
	/*
95
	 * (non-Javadoc)
96
	 * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
97
	 */
98
	public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
99
		if ((selectedItems == null) || (selectedItems.length != 1))
100
			return false;
101

  
102
		if (!(selectedItems[0] instanceof ILayerState))
103
			return false;
104

  
105
		if (!((ILayerState) selectedItems[0]).isOpen())
106
			return false;
107

  
108
		return true;
109
	}
110

  
111
	/*
112
	 * (non-Javadoc)
113
	 * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isVisible(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
114
	 */
115
	public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
116
		if ((selectedItems == null) || (selectedItems.length != 1))
117
			return false;
118

  
119
		if (!(selectedItems[0] instanceof FLyrRaster))
120
			return false;
121

  
122
		if(((FLyrRaster) selectedItems[0]).getDataStore() != null)
123
			return (((FLyrRaster) selectedItems[0]).getDataStore().getInternalParameters() instanceof NetCDFDataParameters);
124
		return false;
125
	}
126

  
127
	/*
128
	 * (non-Javadoc)
129
	 * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
130
	 */
131
	public void execute(ITocItem item, FLayer[] selectedItems) {
132
		FLayer lyr = null;
133

  
134
		if (selectedItems.length != 1)
135
			return;
136

  
137
		lyr = selectedItems[0];
138

  
139
		if (!(lyr instanceof FLyrRaster))
140
			return;
141
		
142
		FLyrRaster fLayer = (FLyrRaster)lyr;
143
		
144
		NetCDFPanel panel = new NetCDFPanel(fLayer);
145
		PluginServices.getMDIManager().addWindow(panel);
146
		//Esto es porque la llamada setHeight de getWindowInfo no funciona igual que esta. Asignan tama?os diferentes 
147
		PluginServices.getMDIManager().getWindowInfo(panel).setHeight(NetCDFPanel.HEIGHT);
148
	}
149

  
150
	/*
151
	 * (non-Javadoc)
152
	 * @see org.gvsig.rastertools.generictoolbar.IGenericToolBarMenuItem#getIcon()
153
	 */
154
	public Icon getIcon() {
155
		return PluginServices.getIconTheme().get("save-icon");
156
	}
157
}
0 158

  
org.gvsig.raster.netcdf/tags/buildNumber_14/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.app/org.gvsig.raster.netcdf.app.netcdfclient/src/main/java/org/gvsig/raster/netcdf/app/netcdfclient/NetCDFClientExtension.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.netcdf.app.netcdfclient;
23

  
24
import org.gvsig.about.AboutManager;
25
import org.gvsig.about.AboutParticipant;
26
import org.gvsig.andami.PluginServices;
27
import org.gvsig.andami.plugins.Extension;
28
import org.gvsig.app.ApplicationLocator;
29
import org.gvsig.app.ApplicationManager;
30
import org.gvsig.tools.ToolsLocator;
31
import org.gvsig.tools.extensionpoint.ExtensionPoint;
32
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
33

  
34
/**
35
 * Extension for adding grid netcdf support to gvSIG.
36
 * @author Nacho Brodin (nachobrodin@gmail.com)
37
 */
38
public class NetCDFClientExtension extends Extension {
39

  
40
	public void initialize() {
41
		registerIcons();
42
    	
43
    	ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
44
    	ExtensionPoint point = extensionPoints.add("View_TocActions");
45
    	point.append("NetCDF_TocActions", "NetCDF", NetCDFMenuEntry.getSingleton());
46
	}
47
	
48
	/**
49
	 * @see com.iver.andami.plugins.IExtension#postInitialize()
50
	 */
51
	@Override
52
	public void postInitialize() {
53
		super.postInitialize();
54
	    addAboutInfo();
55
	}
56
	
57
	private void addAboutInfo() {
58
        ApplicationManager application = ApplicationLocator.getManager();
59
        
60
        AboutManager about = application.getAbout();
61
        about.addDeveloper("PRODEVELOP", getClass().getClassLoader()
62
            .getResource("about/netcdf-about.html"), 2);
63

  
64
        AboutParticipant participant = about.getDeveloper("PRODEVELOP");
65
        participant.addContribution(
66
            "NetCDF Raster",
67
            "Soporte para NetCDF raster ", 
68
            2011,7,1, 
69
            2011,7,30
70
        );      
71
    }
72

  
73
	public void execute(String actionCommand) {
74
	}
75

  
76
	public boolean isEnabled() {
77
		return true;
78
	}
79

  
80
	public boolean isVisible() {
81
		return false;
82
	}
83
	
84
	/**
85
	 * Registra los iconos a utilizar en la botonera.
86
	 */
87
	private void registerIcons() {
88
		PluginServices.getIconTheme().register(
89
				"nextarrow-icon",
90
				this.getClass().getClassLoader().getResource("images/ico16_arrow_next.png")
91
			);
92
		PluginServices.getIconTheme().register(
93
				"prevarrow-icon",
94
				this.getClass().getClassLoader().getResource("images/ico16_arrow_prev.png")
95
			);
96
		PluginServices.getIconTheme().register(
97
				"inspect-icon",
98
				this.getClass().getClassLoader().getResource("images/ico_show.gif")
99
			);
100
	}
101
}
0 102

  
org.gvsig.raster.netcdf/tags/buildNumber_14/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.app/org.gvsig.raster.netcdf.app.netcdfclient/src/main/java/org/gvsig/raster/netcdf/app/netcdfclient/gui/panel/VariableSelectionPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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.netcdf.app.netcdfclient.gui.panel;
20

  
21
import java.awt.BorderLayout;
22
import java.awt.Color;
23
import java.awt.GridBagConstraints;
24
import java.awt.GridBagLayout;
25

  
26
import javax.swing.BorderFactory;
27
import javax.swing.JButton;
28
import javax.swing.JComboBox;
29
import javax.swing.JLabel;
30
import javax.swing.JPanel;
31
import javax.swing.JTextArea;
32
import javax.swing.JTextField;
33

  
34
import org.gvsig.andami.PluginServices;
35

  
36
/**
37
 * Panel for selecting grid variables and dimensions
38
 * @author Nacho Brodin (nachobrodin@gmail.com)
39
 */
40
public class VariableSelectionPanel extends JPanel {
41
	private static final long       serialVersionUID         = 1L;
42
	private JLabel                  xdimLabel                = null;
43
	private JLabel                  ydimLabel                = null;
44
	private JLabel                  gridVariableLabel        = null;
45
	private JLabel                  gridVarDescriptionLabel  = null;
46
	private JLabel                  varDescriptionLabel      = null;
47
	private JLabel                  levelLabel               = null;
48
	private JLabel                  timeLabel                = null;
49
	private JTextArea               txtDescription           = null;
50
	private JTextField              xdimField                = null;
51
	private JTextField              ydimField                = null;
52
	private JComboBox               gridVariableCombo        = null;
53
	private JComboBox               levelCombo               = null;
54
	private JComboBox               timeCombo                = null;
55
	private JComboBox               variableCombo            = null;
56
	private UpDownPanel             varUpDown                = null;
57
	private UpDownPanel             timeUpDown               = null;
58
	private UpDownPanel             levelUpDown              = null;
59
	private JPanel                  varPanel                 = null;
60
	private JPanel                  gridVarPanel             = null;
61
	private JPanel                  timePanel                = null;
62
	private JPanel                  levelPanel               = null;
63
	private JPanel                  dimPanel                 = null;
64
	private JPanel                  northPanel               = null;
65
	private JPanel                  southPanel               = null;
66
	private JPanel                  centerPanel              = null;
67
	private JPanel                  auxPanel                 = new JPanel();
68
	private JButton                 varPropertiesButton      = null;
69
	private VariableTablePanel      tablePanel               = null;
70

  
71
	public VariableSelectionPanel() {
72
		xdimLabel = new JLabel(PluginServices.getText(this, "xdim"));
73
		ydimLabel = new JLabel(PluginServices.getText(this, "ydim"));
74
		gridVariableLabel = new JLabel(PluginServices.getText(this, "gridvar"));
75
		gridVarDescriptionLabel = new JLabel(PluginServices.getText(this, "gridvardescription"));
76
		varDescriptionLabel = new JLabel(PluginServices.getText(this, "vardescription"));
77
		levelLabel = new JLabel(PluginServices.getText(this, "level"));
78
		timeLabel = new JLabel(PluginServices.getText(this, "time"));
79
		init();
80
	}
81
	
82
	GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
83
	
84
	private void init() {
85
		setLayout(new GridBagLayout());
86
		gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
87
		gridBagConstraints1.weightx = 1.0;
88
		gridBagConstraints1.weighty = 0.0;
89
		gridBagConstraints1.anchor = GridBagConstraints.CENTER;
90
		gridBagConstraints1.insets = new java.awt.Insets(2, 2, 2, 2);
91
		
92
		add(getNorthPanel(), gridBagConstraints1);
93
		
94
		gridBagConstraints1.gridy = 1;
95
		add(getCenterPanel(), gridBagConstraints1);
96
		
97
		showTable(false);
98
	}
99
	
100
	/**
101
	 * Shows and hides the table of data
102
	 * @param show
103
	 */
104
	public void showTable(boolean show) {
105
		gridBagConstraints1.fill = GridBagConstraints.BOTH;
106
		gridBagConstraints1.weightx = 1.0;
107
		gridBagConstraints1.weighty = 1.0;
108
		gridBagConstraints1.gridy = 2;
109
		
110
		if(show) {
111
			remove(auxPanel);
112
			add(getSouthPanel(), gridBagConstraints1);
113
			getSouthPanel().setVisible(true);
114
		} else {
115
			remove(getSouthPanel());
116
			add(auxPanel, gridBagConstraints1);
117
			getSouthPanel().setVisible(false);
118
		}
119
	}
120
	
121
	/**
122
	 * Gets the south panel
123
	 * @return
124
	 */
125
	public JPanel getSouthPanel() {
126
		if(southPanel == null) {
127
			southPanel = new JPanel();
128
			southPanel.setLayout(new BorderLayout());
129
			southPanel.setBorder(BorderFactory.createLineBorder(Color.gray));
130
			southPanel.add(getTablePanel(), BorderLayout.CENTER);
131
		}
132
		return southPanel;
133
	}
134
	
135
	/**
136
	 * Gets the north panel
137
	 * @return
138
	 */
139
	private JPanel getNorthPanel() {
140
		if(northPanel == null) {
141
			northPanel = new JPanel();
142
			northPanel.setLayout(new GridBagLayout());
143
			northPanel.setBorder(BorderFactory.createLineBorder(Color.gray));
144
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
145
			gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
146
			gridBagConstraints1.anchor = GridBagConstraints.CENTER;
147
			gridBagConstraints1.weightx = 1.0;
148
			gridBagConstraints1.insets = new java.awt.Insets(2, 2, 2, 2);
149
			
150
			gridBagConstraints1.gridy = 0;
151
			northPanel.add(getDimPanel(), gridBagConstraints1);
152
			
153
			gridBagConstraints1.gridy = 1;
154
			northPanel.add(levelLabel, gridBagConstraints1);
155
			
156
			gridBagConstraints1.gridy = 2;
157
			northPanel.add(getLevelPanel(), gridBagConstraints1);
158
			
159
			gridBagConstraints1.gridy = 3;
160
			northPanel.add(timeLabel, gridBagConstraints1);
161
			
162
			gridBagConstraints1.gridy = 4;
163
			northPanel.add(getTimePanel(), gridBagConstraints1);
164
			
165
			gridBagConstraints1.gridy = 5;
166
			northPanel.add(gridVariableLabel, gridBagConstraints1);
167
			
168
			gridBagConstraints1.gridy = 6;
169
			northPanel.add(getGridVarPanel(), gridBagConstraints1);
170
			
171
			gridBagConstraints1.gridy = 7;
172
			northPanel.add(gridVarDescriptionLabel, gridBagConstraints1);
173
			
174
			gridBagConstraints1.gridy = 8;
175
			gridBagConstraints1.fill = GridBagConstraints.BOTH;
176
			gridBagConstraints1.weighty = 1.0;
177
			northPanel.add(getTxtDescription(), gridBagConstraints1);
178
			
179
			//gridBagConstraints1.gridy = 9;
180
			//gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
181
			//gridBagConstraints1.weighty = 0.0;
182
			//northPanel.add(varDescriptionLabel, gridBagConstraints1);
183
			
184
			//gridBagConstraints1.gridy = 10;
185
			//northPanel.add(getVarPanel(), gridBagConstraints1);
186
		}
187
		return northPanel;
188
	}
189
	
190
	/**
191
	 * Gets the center panel
192
	 * @return
193
	 */
194
	public JPanel getCenterPanel() {
195
		if(centerPanel == null) {
196
			centerPanel = new JPanel();
197
			centerPanel.setLayout(new GridBagLayout());
198
			centerPanel.setBorder(BorderFactory.createLineBorder(Color.gray));
199
			
200
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
201
			gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
202
			gridBagConstraints1.anchor = GridBagConstraints.CENTER;
203
			gridBagConstraints1.weightx = 1.0;
204
			gridBagConstraints1.weighty = 0.0;
205
			gridBagConstraints1.insets = new java.awt.Insets(2, 2, 2, 2);
206
			
207
			centerPanel.add(varDescriptionLabel, gridBagConstraints1);
208
			gridBagConstraints1.gridy = 1;
209
			centerPanel.add(getVarPanel(), gridBagConstraints1);
210
		}
211
		return centerPanel;
212
	}
213
	
214
	/**
215
	 * Gets the table panel 
216
	 * @return
217
	 */
218
	public VariableTablePanel getTablePanel() {
219
		if(tablePanel == null) {
220
			tablePanel = new VariableTablePanel();
221
		}
222
		return tablePanel;
223
	}
224
	
225
	/**
226
	 * Gets the panel of dimension variables
227
	 * @return
228
	 */
229
	private JPanel getDimPanel() {
230
		if(dimPanel == null) {
231
			dimPanel = new JPanel();
232
			dimPanel.setLayout(new GridBagLayout());
233
			
234
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
235
			gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
236
			gridBagConstraints1.anchor = GridBagConstraints.CENTER;
237
			gridBagConstraints1.weightx = 1.0;
238
			gridBagConstraints1.insets = new java.awt.Insets(2, 2, 2, 2);
239
			
240
			gridBagConstraints1.gridx = 0;
241
			gridBagConstraints1.gridy = 0;
242
			dimPanel.add(xdimLabel, gridBagConstraints1);
243
			
244
			gridBagConstraints1.gridx = 1;
245
			gridBagConstraints1.gridy = 0;
246
			dimPanel.add(ydimLabel, gridBagConstraints1);
247
			
248
			gridBagConstraints1.gridx = 0;
249
			gridBagConstraints1.gridy = 1;
250
			dimPanel.add(getXDimField(), gridBagConstraints1);
251
			
252
			gridBagConstraints1.gridx = 1;
253
			gridBagConstraints1.gridy = 1;
254
			dimPanel.add(getYDimField(), gridBagConstraints1);
255
		}
256
		return dimPanel;
257
	}
258
	
259
	public javax.swing.JTextArea getTxtDescription() {
260
		if (txtDescription == null) {
261
			txtDescription = new javax.swing.JTextArea();
262
			txtDescription.setWrapStyleWord(true);
263
			txtDescription.setColumns(30);
264
			txtDescription.setLineWrap(true);
265
			txtDescription.setEditable(false);
266
		}
267
		return txtDescription;
268
	}
269
	
270
	public JComboBox getTimeCombo() {
271
		if(timeCombo == null) {
272
			timeCombo = new JComboBox();
273
		}
274
		return timeCombo;
275
	}
276
	
277
	public JComboBox getLevelCombo() {
278
		if(levelCombo == null) {
279
			levelCombo = new JComboBox();
280
		}
281
		return levelCombo;
282
	}
283
	
284
	public JTextField getXDimField() {
285
		if(xdimField == null) {
286
			xdimField = new JTextField();
287
			xdimField.setEditable(false);
288
		}
289
		return xdimField;
290
	}
291
	
292
	public JTextField getYDimField() {
293
		if(ydimField == null) {
294
			ydimField = new JTextField();
295
			ydimField.setEditable(false);
296
		}
297
		return ydimField;
298
	}
299
	
300
	public JComboBox getGridVariableCombo() {
301
		if(gridVariableCombo == null) {
302
			gridVariableCombo = new JComboBox();
303
		}
304
		return gridVariableCombo;
305
	}
306
	
307
	public JComboBox getVariableCombo() {
308
		if(variableCombo == null) {
309
			variableCombo = new JComboBox();
310
		}
311
		return variableCombo;
312
	}
313
	
314
	public JButton getVarPropertiesButton() {
315
		if(varPropertiesButton == null) {
316
			varPropertiesButton = new JButton(PluginServices.getIconTheme().get("inspect-icon"));
317
		}
318
		return varPropertiesButton;
319
	}
320
	
321
	/**
322
	 * Gets the panel of variable controls
323
	 * @return
324
	 */
325
	private JPanel getVarPanel() {
326
		if(varPanel == null) {
327
			varPanel = new JPanel();
328
			varPanel.setLayout(new GridBagLayout());
329
			
330
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
331
			gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
332
			gridBagConstraints1.anchor = GridBagConstraints.CENTER;
333
			gridBagConstraints1.weightx = 1.0;
334
			gridBagConstraints1.insets = new java.awt.Insets(0, 2, 0, 0);
335
			
336
			gridBagConstraints1.gridx = 0;
337
			gridBagConstraints1.gridy = 0;
338
			varPanel.add(getVariableCombo(), gridBagConstraints1);
339
			
340
			gridBagConstraints1.fill = GridBagConstraints.NONE;
341
			gridBagConstraints1.weightx = 0.0;
342
			gridBagConstraints1.gridx = 1;
343
			gridBagConstraints1.gridy = 0;
344
			varPanel.add(getVarPropertiesButton(), gridBagConstraints1);
345
		}
346
		return varPanel;
347
	}
348
	
349
	/**
350
	 * Gets the panel of variable controls
351
	 * @return
352
	 */
353
	private JPanel getGridVarPanel() {
354
		if(gridVarPanel == null) {
355
			gridVarPanel = new JPanel();
356
			gridVarPanel.setLayout(new GridBagLayout());
357
			
358
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
359
			gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
360
			gridBagConstraints1.anchor = GridBagConstraints.CENTER;
361
			gridBagConstraints1.weightx = 1.0;
362
			gridBagConstraints1.insets = new java.awt.Insets(0, 2, 0, 0);
363
			
364
			gridBagConstraints1.gridx = 0;
365
			gridBagConstraints1.gridy = 0;
366
			gridVarPanel.add(getGridVariableCombo(), gridBagConstraints1);
367
			
368
			gridBagConstraints1.fill = GridBagConstraints.NONE;
369
			gridBagConstraints1.weightx = 0.0;
370
			gridBagConstraints1.gridx = 1;
371
			gridBagConstraints1.gridy = 0;
372
			gridVarPanel.add(getGridVarUpDownPanel(), gridBagConstraints1);
373
		}
374
		return gridVarPanel;
375
	}
376
	
377
	/**
378
	 * Gets the panel of time controls
379
	 * @return
380
	 */
381
	private JPanel getTimePanel() {
382
		if(timePanel == null) {
383
			timePanel = new JPanel();
384
			timePanel.setLayout(new GridBagLayout());
385
			
386
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
387
			gridBagConstraints1.fill = GridBagConstraints.BOTH;
388
			gridBagConstraints1.anchor = GridBagConstraints.CENTER;
389
			gridBagConstraints1.weightx = 1.0;
390
			gridBagConstraints1.weighty = 1.0;
391
			gridBagConstraints1.insets = new java.awt.Insets(0, 2, 0, 0);
392
			
393
			gridBagConstraints1.gridx = 0;
394
			gridBagConstraints1.gridy = 0;
395
			timePanel.add(getTimeCombo(), gridBagConstraints1);
396
			
397
			gridBagConstraints1.fill = GridBagConstraints.NONE;
398
			gridBagConstraints1.weightx = 0.0;
399
			gridBagConstraints1.weighty = 0.0;
400
			gridBagConstraints1.gridx = 1;
401
			gridBagConstraints1.gridy = 0;
402
			timePanel.add(getTimeUpDownPanel(), gridBagConstraints1);
403
		}
404
		return timePanel;
405
	}
406
	
407
	/**
408
	 * Gets the panel of level controls
409
	 * @return
410
	 */
411
	private JPanel getLevelPanel() {
412
		if(levelPanel == null) {
413
			levelPanel = new JPanel();
414
			levelPanel.setLayout(new GridBagLayout());
415
			
416
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
417
			gridBagConstraints1.fill = GridBagConstraints.BOTH;
418
			gridBagConstraints1.anchor = GridBagConstraints.CENTER;
419
			gridBagConstraints1.weightx = 1.0;
420
			gridBagConstraints1.weighty = 1.0;
421
			gridBagConstraints1.insets = new java.awt.Insets(0, 2, 0, 0);
422
			
423
			gridBagConstraints1.gridx = 0;
424
			gridBagConstraints1.gridy = 0;
425
			levelPanel.add(getLevelCombo(), gridBagConstraints1);
426
			
427
			gridBagConstraints1.fill = GridBagConstraints.NONE;
428
			gridBagConstraints1.weightx = 0.0;
429
			gridBagConstraints1.weighty = 0.0;
430
			gridBagConstraints1.gridx = 1;
431
			gridBagConstraints1.gridy = 0;
432
			levelPanel.add(getLevelUpDownPanel(), gridBagConstraints1);
433
		}
434
		return levelPanel;
435
	}
436
	
437
	public UpDownPanel getGridVarUpDownPanel() {
438
		if(varUpDown == null) {
439
			varUpDown = new UpDownPanel();
440
		}
441
		return varUpDown;
442
	}
443
	
444
	public UpDownPanel getTimeUpDownPanel() {
445
		if(timeUpDown == null) {
446
			timeUpDown = new UpDownPanel();
447
		}
448
		return timeUpDown;
449
	}
450
	
451
	public UpDownPanel getLevelUpDownPanel() {
452
		if(levelUpDown == null) {
453
			levelUpDown = new UpDownPanel();
454
		}
455
		return levelUpDown;
456
	}
457
}
0 458

  
org.gvsig.raster.netcdf/tags/buildNumber_14/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.app/org.gvsig.raster.netcdf.app.netcdfclient/src/main/java/org/gvsig/raster/netcdf/app/netcdfclient/gui/panel/UpDownPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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.netcdf.app.netcdfclient.gui.panel;
20

  
21
import java.awt.GridBagConstraints;
22
import java.awt.GridBagLayout;
23

  
24
import javax.swing.JButton;
25
import javax.swing.JPanel;
26

  
27
import org.gvsig.andami.PluginServices;
28

  
29
/**
30
 * Panel for up and down button
31
 * @author Nacho Brodin (nachobrodin@gmail.com)
32
 */
33
public class UpDownPanel extends JPanel {
34
	private static final long       serialVersionUID     = 1L;
35
	private JButton                 up                   = null;
36
	private JButton                 down                 = null;
37

  
38
	public UpDownPanel() {
39
		init();
40
	}
41
	
42
	private void init() {
43
		setLayout(new GridBagLayout());
44
		
45
		GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
46
		gridBagConstraints1.fill = GridBagConstraints.BOTH;
47
		gridBagConstraints1.anchor = GridBagConstraints.CENTER;
48
		gridBagConstraints1.weightx = 1.0;
49
		gridBagConstraints1.weighty = 1.0;
50
		
51
		add(getDownButton(), gridBagConstraints1);
52
				
53
		gridBagConstraints1.gridx = 1;
54
		add(getUpButton(), gridBagConstraints1);
55
	}
56

  
57
	public JButton getUpButton() {
58
		if(up == null) {
59
			up = new JButton(PluginServices.getIconTheme().get("nextarrow-icon"));
60
			//up.setPreferredSize(new Dimension(32, 12));
61
		}
62
		return up;
63
	}
64
	
65
	public JButton getDownButton() {
66
		if(down == null) {
67
			down = new JButton(PluginServices.getIconTheme().get("prevarrow-icon"));
68
			//down.setPreferredSize(new Dimension(32, 12));
69
		}
70
		return down;
71
	}
72
}
0 73

  
org.gvsig.raster.netcdf/tags/buildNumber_14/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.app/org.gvsig.raster.netcdf.app.netcdfclient/src/main/java/org/gvsig/raster/netcdf/app/netcdfclient/gui/panel/VariableTablePanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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.netcdf.app.netcdfclient.gui.panel;
20

  
21
import java.awt.BorderLayout;
22
import java.util.ArrayList;
23

  
24
import javax.swing.JPanel;
25

  
26
import org.gvsig.andami.PluginServices;
27
import org.gvsig.gui.beans.table.TableContainer;
28
import org.gvsig.gui.beans.table.exceptions.NotInitializeException;
29
import org.gvsig.raster.tools.app.basic.RasterToolsUtil;
30

  
31
/**
32
 * Panel for show variables
33
 * @author Nacho Brodin (nachobrodin@gmail.com)
34
 */
35
public class VariableTablePanel extends JPanel {
36
	private static final long serialVersionUID = 1L;
37
	private TableContainer    table            = null;
38
	private String[]          columnNames      = null;
39
	private int[]             columnWidths     = null;
40
	
41
	public VariableTablePanel() {
42
		init();
43
	}
44
	
45
	public TableContainer getTable() {
46
		if(table == null) {
47
			columnNames = new String[]{PluginServices.getText(this, "property"), PluginServices.getText(this, "value")};
48
			columnWidths = new int[]{(int)(NetCDFPanel.WIDTH * 0.3) , (int)(NetCDFPanel.WIDTH * 0.7)};
49
			table = new TableContainer(columnNames, columnWidths);
50
			table.initialize();
51
			table.setControlVisible(false);
52
		}
53
		return table;
54
	}
55

  
56
	private void init() {
57
		setLayout(new BorderLayout());
58
		add(getTable(), BorderLayout.CENTER);
59
	}
60
	
61
	public void setRows(ArrayList<String[]> varValue) {
62
		for (int i = 0; i < varValue.size(); i++) {
63
			try {
64
				table.addRow(varValue.get(i));
65
			} catch (NotInitializeException e) {
66
				RasterToolsUtil.messageBoxError("error_adding_rows", this, e);
67
			}
68
		}
69
	}
70

  
71
}
0 72

  
org.gvsig.raster.netcdf/tags/buildNumber_14/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.app/org.gvsig.raster.netcdf.app.netcdfclient/src/main/java/org/gvsig/raster/netcdf/app/netcdfclient/gui/panel/NetCDFPanel.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.netcdf.app.netcdfclient.gui.panel;
23

  
24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.awt.Insets;
27
import java.awt.event.ActionEvent;
28
import java.awt.event.ActionListener;
29
import java.io.IOException;
30
import java.util.ArrayList;
31
import java.util.Date;
32

  
33
import org.gvsig.andami.PluginServices;
34
import org.gvsig.andami.ui.mdiManager.IWindow;
35
import org.gvsig.andami.ui.mdiManager.WindowInfo;
36
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
37
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
38
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
39
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
40
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
41
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
42
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel;
43
import org.gvsig.gui.beans.table.exceptions.NotInitializeException;
44
import org.gvsig.raster.fmap.layers.FLyrRaster;
45
import org.gvsig.raster.netcdf.io.NetCDFDataParameters;
46
import org.gvsig.raster.tools.app.basic.RasterToolsUtil;
47

  
48
import ucar.nc2.Variable;
49

  
50
/**
51
 * Properties panel for NetCDF format.
52
 * @author Nacho Brodin (nachobrodin@gmail.com)
53
 */
54
public class NetCDFPanel extends DefaultButtonsPanel implements IWindow, ActionListener, ButtonsPanelListener {
55
	private static final long             serialVersionUID  = 1L;
56
	private static String                 NOVALUE           = "---";
57
	private VariableSelectionPanel        panel             = null;
58
	private FLyrRaster                    lyr               = null;
59
	private static boolean                blockRefreshEvent = false;
60
	private ArrayList<Variable>           listVars          = null;
61
	public static int                     HEIGHT            = 360;
62
	public static int                     WIDTH             = 340;
63
	
64
	/**
65
	 * This method initializes
66
	 */
67
	public NetCDFPanel(FLyrRaster lyr) {
68
		super(ButtonsPanel.BUTTONS_APPLYCLOSE);
69
		addButtonPressedListener(this);
70
		this.lyr = lyr;
71
		initialize();
72
		
73
		try {
74
			loadVariablesFromParameters();
75
		} catch (IOException e) {
76
			panel.getGridVariableCombo().setSelectedIndex(0);
77
		} finally {
78
		}
79
		
80
		setStatus();
81
	}
82
	
83
	/**
84
	 * Initializes graphic components
85
	 */
86
	protected void initialize() {
87
		GridBagConstraints gbc = new GridBagConstraints();
88
		setLayout(new GridBagLayout());
89
		
90
		gbc.insets = new Insets(0, 0, 0, 0);
91
		gbc.fill = GridBagConstraints.BOTH;
92
		gbc.anchor = GridBagConstraints.CENTER;
93
		gbc.weightx = 1.0;
94
		gbc.weighty = 1.0;
95
		
96
		add(getVariableSelectionPanel(), gbc);
97
		panel.getLevelCombo().addActionListener(this);
98
		panel.getTimeCombo().addActionListener(this);
99
		panel.getGridVariableCombo().addActionListener(this);
100
		panel.getGridVarUpDownPanel().getUpButton().addActionListener(this);
101
		panel.getGridVarUpDownPanel().getDownButton().addActionListener(this);
102
		panel.getTimeUpDownPanel().getUpButton().addActionListener(this);
103
		panel.getTimeUpDownPanel().getDownButton().addActionListener(this);
104
		panel.getLevelUpDownPanel().getUpButton().addActionListener(this);
105
		panel.getLevelUpDownPanel().getDownButton().addActionListener(this);
106
		panel.getVarPropertiesButton().addActionListener(this);
107
		panel.getVariableCombo().addActionListener(this);
108
	}
109
	
110
	/**
111
	 * Sets the variable status
112
	 * @param params
113
	 */
114
	private void setStatus() {
115
		NetCDFDataParameters params = (NetCDFDataParameters)lyr.getDataStore().getInternalParameters();
116
		Integer time = params.getFieldTime();
117
		Integer level = params.getFieldLevel();
118
		String fieldVar = params.getStringVariable();
119
		
120
		blockRefreshEvent = true;
121
		for (int i = 0; i < panel.getGridVariableCombo().getItemCount(); i++) {
122
			if(fieldVar.compareTo((String)panel.getGridVariableCombo().getItemAt(i)) == 0) {
123
				panel.getGridVariableCombo().setSelectedIndex(i);
124
				break;
125
			}
126
		}
127
		panel.getTimeCombo().setSelectedIndex(time.intValue());
128
		panel.getLevelCombo().setSelectedIndex(level.intValue());
129
		blockRefreshEvent = false;
130
	}
131
	
132
	/**
133
	 * Loads the main window of data
134
	 * @throws IOException
135
	 */
136
	private void loadVariablesFromParameters() throws IOException {
137
		NetCDFDataParameters params = ((NetCDFDataParameters)lyr.getDataStore().getInternalParameters());
138
		
139
		panel.getXDimField().setText(params.getXDimVariable());
140
		panel.getYDimField().setText(params.getYDimVariable());
141
		
142
		blockRefreshEvent = true;
143
		ArrayList<String[]> listGridVars = params.getGridVariables();
144
		panel.getGridVariableCombo().removeAllItems();
145
		for (int i = 0; i < listGridVars.size(); i++) {
146
			panel.getGridVariableCombo().addItem(listGridVars.get(i)[0]);
147
		}
148
		
149
		listVars = params.getVariables();
150
		panel.getVariableCombo().removeAllItems();
151
		if(listVars != null) {
152
			for (int i = 0; i < listVars.size(); i++) {
153
				panel.getVariableCombo().addItem(listVars.get(i).getName());
154
			}
155
		} else {
156
			panel.getLevelCombo().addItem(NOVALUE);
157
		}
158

  
159
		Date[] dateList = params.getTimeList(params.getStringVariable());
160
		panel.getTimeCombo().removeAllItems();
161
		if(dateList != null) {
162
			for (int i = 0; i < dateList.length; i++) {
163
				panel.getTimeCombo().addItem(dateList[i]);
164
			}
165
		} else
166
			panel.getTimeCombo().addItem(NOVALUE);
167
		
168
		panel.getLevelCombo().removeAllItems();
169
		double[] levels = params.getLevelList(params.getStringVariable());
170
		if(levels != null) {
171
			for (int i = 0; i < levels.length; i++) {
172
				panel.getLevelCombo().addItem(levels[i]);
173
			}
174
		} else
175
			panel.getLevelCombo().addItem(NOVALUE);
176
		
177
		blockRefreshEvent = false;
178
	}
179
	
180
	/**
181
	 * Loads the description of the selected variable
182
	 * @param selectedVariable
183
	 * @throws IOException
184
	 */
185
	private void loadDescription(String selectedVariable) throws IOException {
186
		NetCDFDataParameters params = ((NetCDFDataParameters)lyr.getDataStore().getInternalParameters());
187
		ArrayList<String[]> list = params.getGridVariables();
188
		for (int i = 0; i < list.size(); i++) {
189
			String[] values = list.get(i);
190
			if(values[0].compareTo(selectedVariable) == 0)
191
				panel.getTxtDescription().setText(values[1]);
192
		}
193
	}
194
	
195
	/**
196
	 * Loads the list of levels of the selected variable
197
	 */
198
	private void loadLevel() {
199
		NetCDFDataParameters params = ((NetCDFDataParameters)lyr.getDataStore().getInternalParameters());
200
		double[] levels = params.getLevelList((String)panel.getGridVariableCombo().getSelectedItem());
201
		blockRefreshEvent = true;
202
		panel.getLevelCombo().removeAllItems();
203
		if(levels != null) {
204
			for (int i = 0; i < levels.length; i++) {
205
				panel.getLevelCombo().addItem(levels[i]);
206
			}
207
		} else
208
			panel.getLevelCombo().addItem(NOVALUE);
209
		blockRefreshEvent = false;
210
	}
211
	
212
	/**
213
	 * Loads the list of dates of the selected variable.
214
	 */
215
	private void loadDates() {
216
		NetCDFDataParameters params = ((NetCDFDataParameters)lyr.getDataStore().getInternalParameters());
217
		Date[] dateList = params.getTimeList((String)panel.getGridVariableCombo().getSelectedItem());
218
		blockRefreshEvent = true;
219
		panel.getTimeCombo().removeAllItems();
220
		if(dateList != null) {
221
			for (int i = 0; i < dateList.length; i++) {
222
				panel.getTimeCombo().addItem(dateList[i]);
223
			}
224
		} else
225
			panel.getTimeCombo().addItem(NOVALUE);
226
		blockRefreshEvent = false;
227
	}
228
	
229
	/**
230
	 * Gets the main panel
231
	 * @return
232
	 */
233
	private VariableSelectionPanel getVariableSelectionPanel() {
234
		if(panel == null) {
235
			panel = new VariableSelectionPanel();
236
			panel.getGridVariableCombo().addActionListener(this);
237
		}
238
		return panel;
239
	}
240
	
241
	/*
242
	 * (non-Javadoc)
243
	 * @see org.gvsig.andami.ui.mdiManager.IWindow#getWindowInfo()
244
	 */
245
	public WindowInfo getWindowInfo() {
246
		WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG);
247
		m_viewinfo.setTitle(PluginServices.getText(this, "NetCDF_Variables"));
248
		m_viewinfo.setHeight(HEIGHT);
249
		m_viewinfo.setWidth(WIDTH);
250
		return m_viewinfo;
251
	}
252

  
253
	/*
254
	 * (non-Javadoc)
255
	 * @see org.gvsig.andami.ui.mdiManager.IWindow#getWindowProfile()
256
	 */
257
	public Object getWindowProfile() {
258
		return WindowInfo.PROPERTIES_PROFILE;
259
	}
260

  
261
	/*
262
	 * (non-Javadoc)
263
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
264
	 */
265
	public void actionPerformed(ActionEvent e) {
266
		if(blockRefreshEvent)
267
			return;
268
		
269
		if(e.getSource() == panel.getGridVariableCombo()) {
270
			try {
271
				loadDescription((String)panel.getGridVariableCombo().getSelectedItem());
272
				loadLevel();
273
				loadDates();
274
			} catch (IOException e1) {
275
				panel.getTxtDescription().setText("?");
276
			}
277
		}
278
		
279
		if(e.getSource() == panel.getGridVarUpDownPanel().getDownButton()) {
280
			panel.getGridVariableCombo().setSelectedIndex(
281
					Math.min(panel.getGridVariableCombo().getSelectedIndex() + 1,
282
					panel.getGridVariableCombo().getItemCount() - 1));
283
		}
284
		
285
		if(e.getSource() == panel.getGridVarUpDownPanel().getUpButton()) {
286
			panel.getGridVariableCombo().setSelectedIndex(
287
					Math.max(panel.getGridVariableCombo().getSelectedIndex() - 1,
288
					0));
289
		}
290
		
291
		if(e.getSource() == panel.getTimeUpDownPanel().getDownButton()) {
292
			panel.getTimeCombo().setSelectedIndex(
293
					Math.min(panel.getTimeCombo().getSelectedIndex() + 1,
294
					panel.getTimeCombo().getItemCount() - 1));
295
		}
296
		
297
		if(e.getSource() == panel.getTimeUpDownPanel().getUpButton()) {
298
			panel.getTimeCombo().setSelectedIndex(
299
					Math.max(panel.getTimeCombo().getSelectedIndex() - 1,
300
					0));
301
		}
302
		
303
		if(e.getSource() == panel.getLevelUpDownPanel().getDownButton()) {
304
			panel.getLevelCombo().setSelectedIndex(
305
					Math.min(panel.getLevelCombo().getSelectedIndex() + 1,
306
					panel.getLevelCombo().getItemCount() - 1));
307
		}
308
		
309
		if(e.getSource() == panel.getLevelUpDownPanel().getUpButton()) {
310
			panel.getLevelCombo().setSelectedIndex(
311
					Math.max(panel.getLevelCombo().getSelectedIndex() - 1,
312
					0));
313
		}
314
		
315
		if(e.getSource() == panel.getVarPropertiesButton()) {
316
			showVariableProperties((String)panel.getVariableCombo().getSelectedItem());
317
			openVariableTable();
318
		}
319
		
320
		if(e.getSource() == panel.getVariableCombo()) {
321
			showVariableProperties((String)panel.getVariableCombo().getSelectedItem());
322
		}
323
		
324
		//Apply when a selection changes
325
		if((e.getSource() == panel.getGridVariableCombo() || 
326
			e.getSource() == panel.getTimeCombo() || 
327
			e.getSource() == panel.getLevelCombo())) 
328
			actionButtonPressed(null);
329
	}
330
	
331
	/**
332
	 * Shows the dialog for properties variable
333
	 * @param var
334
	 */
335
	private void showVariableProperties(String var) {
336
		if(listVars != null) {
337
			ArrayList<String[]> varValue = new ArrayList<String[]>();
338
			for (int i = 0; i < listVars.size(); i++) {
339
				Variable v = listVars.get(i);
340
				String name = v.getName();
341
				if(name.compareTo(var) == 0) {
342
					varValue.add(new String[] {PluginServices.getText(this, "description"), v.getDescription()});
343
					varValue.add(new String[] {PluginServices.getText(this, "dimensions"), v.getDimensionsString()});
344
					int[] shape = v.getShape();
345
					String shapeString = "";
346
					for (int j = 0; j < shape.length; j++) {
347
						shapeString += shape[j] + ", ";
348
					}
349
					varValue.add(new String[] {PluginServices.getText(this, "shape"), shapeString});
350
					varValue.add(new String[] {PluginServices.getText(this, "units"), v.getUnitsString()});
351
					varValue.add(new String[] {PluginServices.getText(this, "dataType"), v.getDataType().toString()});
352
				}
353
			}
354
			try {
355
				panel.getTablePanel().getTable().removeAllRows();
356
			} catch (NotInitializeException e) {
357
				RasterToolsUtil.messageBoxError("error_removing_rows", this, e);
358
			}
359
			panel.getTablePanel().setRows(varValue);
360
		}
361
	}
362
	
363
	/**
364
	 * Opens variable table
365
	 */
366
	private void openVariableTable() {
367
		//Shows and hides the table of data
368
		if(panel.getSouthPanel().isVisible()) {
369
			panel.showTable(false);
370
			PluginServices.getMDIManager().getWindowInfo(this).setHeight(HEIGHT);
371
		} else {
372
			panel.showTable(true);
373
			PluginServices.getMDIManager().getWindowInfo(this).setHeight(500);
374
		}
375
	}
376

  
377
	/*
378
	 * (non-Javadoc)
379
	 * @see org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener#actionButtonPressed(org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent)
380
	 */
381
	public void actionButtonPressed(ButtonsPanelEvent e) {
382
		if(blockRefreshEvent)
383
			return;
384
			
385
		// Bot?n de Aplicar
386
		if (e == null || e.getButton() == ButtonsPanel.BUTTON_APPLY) {
387
			//DataManager datamanager = DALLocator.getDataManager();
388
			//FilesystemServerExplorerParameters explorerParams = (FilesystemServerExplorerParameters) datamanager.createServerExplorerParameters(FilesystemServerExplorer.NAME);
389
			//DataServerExplorer explorer = datamanager.openServerExplorer(FilesystemServerExplorer.NAME, explorerParams);
390
			//NewDataStoreParameters newParams = explorer.getAddParameters(NetCDFProvider.NAME);
391
			NetCDFDataParameters newParams = (NetCDFDataParameters)lyr.getDataStore().getInternalParameters();
392
			newParams.setDynValue(NetCDFDataParameters.FIELD_VARIABLE, panel.getGridVariableCombo().getSelectedItem());
393
			String value = (String)panel.getTimeCombo().getSelectedItem().toString();
394
			newParams.setDynValue(NetCDFDataParameters.FIELD_TIME, value.compareTo(NOVALUE) == 0 ? 0 : panel.getTimeCombo().getSelectedIndex());
395
			value = (String)panel.getLevelCombo().getSelectedItem().toString();
396
			newParams.setDynValue(NetCDFDataParameters.FIELD_LEVEL, value.compareTo(NOVALUE) == 0 ? new Integer(0) : new Integer(panel.getLevelCombo().getSelectedIndex()));
397

  
398
			//The statistics have to be recalculated for each subdataset
399
			try {
400
				lyr.getDataStore().getStatistics().forceToRecalc();
401
				lyr.getDataStore().getStatistics().calculate(1);
402
			} catch (FileNotOpenException e1) {
403
				RasterToolsUtil.messageBoxError("error_stats", this, e1);
404
			} catch (RasterDriverException e1) {
405
				RasterToolsUtil.messageBoxError("error_stats", this, e1);
406
			} catch (ProcessInterruptedException e1) {
407
			}
408

  
409
			//If there is a color table this will have to be adapted to subdataset range
410
			if(lyr.getRender().getColorTable() != null)
411
				lyr.getRender().getColorTable().createColorTableInRange(lyr.getDataStore().getStatistics().getMinimun(), lyr.getDataStore().getStatistics().getMaximun(), false);
412
			lyr.getMapContext().invalidate();
413
		}
414
		
415
		// Bot?n de Cerrar
416
		if (e != null && e.getButton() == ButtonsPanel.BUTTON_CLOSE)
417
			PluginServices.getMDIManager().closeWindow(this);
418
	}
419
}
0 420

  
org.gvsig.raster.netcdf/tags/buildNumber_14/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.app/org.gvsig.raster.netcdf.app.netcdfclient/src/main/resources/text.properties
1
level=Nivel
2
gridvar=Variable Grid
3
NetCDF_Properties=Propiedades de NetCDF
4
NetCDF_Variables=Variables de NetCDF
5
error_stats=Error calculando las estad?sticas
6
coordSys=Sistema de coordenadas
7
dataType=Tipo de dato
8
description=Descripci?n
9
dimensions=Dimensiones
10
group=Grupo
11
name=Nombre
12
shape=Shape
13
units=Unidades
14
property=Propiedad
15
variable_info=Informaci?n de variable
16
vardescription=Descripci?n de variable
17
gridvardescription=Descripci?n de variable grid
18
error_adding_rows=Error a?adiendo filas a la tabla
0 19

  
org.gvsig.raster.netcdf/tags/buildNumber_14/org.gvsig.raster.netcdf/org.gvsig.raster.netcdf.app/org.gvsig.raster.netcdf.app.netcdfclient/src/main/resources/text_en.properties
1
level=Level
2
gridvar=Grid Variable
3
NetCDF_Properties=NetCDF properties
4
NetCDF_Variables=NetCDF variables
5
error_stats=Error while calculatin statistics
6
coordSys=Coordinate system
7
dataType=Type of data
8
description=Description
9
dimensions=Dimensions
10
group=Group
11
name=Name
12
shape=Shape
13
units=Units
14
property=Property
15
variable_info=Variable information
16
vardescription=Variable description
17
gridvardescription=Grid variable description
18
error_adding_rows=Error while adding rows to the table
0 19

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff