gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.swing / org.gvsig.raster.swing.impl / src / main / java / org / gvsig / raster / swing / impl / sumaryprocess / SummaryProcessPanel.java @ 2127
History | View | Annotate | Download (9.98 KB)
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.swing.impl.sumaryprocess; |
23 |
|
24 |
import java.awt.BorderLayout; |
25 |
import java.awt.CardLayout; |
26 |
import java.awt.Color; |
27 |
import java.awt.Dimension; |
28 |
import java.awt.FlowLayout; |
29 |
import java.awt.GridBagConstraints; |
30 |
import java.awt.GridBagLayout; |
31 |
import java.awt.Insets; |
32 |
import java.awt.event.ActionEvent; |
33 |
import java.awt.event.ActionListener; |
34 |
import java.io.File; |
35 |
|
36 |
import javax.swing.BorderFactory; |
37 |
import javax.swing.JLabel; |
38 |
import javax.swing.JPanel; |
39 |
import javax.swing.JTextField; |
40 |
import javax.swing.border.TitledBorder; |
41 |
|
42 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
43 |
import org.gvsig.i18n.Messages; |
44 |
import org.gvsig.raster.swing.basepanel.AbstractButtonsPanel; |
45 |
import org.gvsig.raster.swing.basepanel.IButtonsPanel; |
46 |
import org.gvsig.utils.swing.JComboBox; |
47 |
|
48 |
/**
|
49 |
* Panel principal del dialogo de finalizaci?n del salvado a raster. En el se
|
50 |
* muestra la informaci?n de nombre de fichero, tama?o de este, tiempo de la
|
51 |
* operaci?n, etc...
|
52 |
*
|
53 |
* @version 18/04/2007
|
54 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
55 |
*/
|
56 |
public class SummaryProcessPanel extends AbstractButtonsPanel implements ActionListener { |
57 |
private static final long serialVersionUID = -2280318605043767336L; |
58 |
private JPanel contentPane = null; |
59 |
private JComboBox comboBox = null; |
60 |
|
61 |
private String labelFilename = "File:"; |
62 |
private String labelPath = "Path:"; |
63 |
private String labelTime = "Time:"; |
64 |
private String labelSize = "Size:"; |
65 |
private String labelCompression = "Compression:"; |
66 |
|
67 |
/**
|
68 |
* This is the default constructor
|
69 |
*/
|
70 |
protected SummaryProcessPanel() {
|
71 |
super(IButtonsPanel.BUTTONS_ACCEPT);
|
72 |
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
73 |
initialize(); |
74 |
setTranslation(); |
75 |
} |
76 |
|
77 |
/**
|
78 |
* Asigna los textos a los paneles en el idioma seleccionado
|
79 |
*/
|
80 |
private void setTranslation() { |
81 |
setLabelFilename(Messages.getText("file") + ":"); |
82 |
setLabelPath(Messages.getText("path") + ":"); |
83 |
setLabelSize(Messages.getText("size") + ":"); |
84 |
setLabelTime(Messages.getText("time") + ":"); |
85 |
setLabelCompression(Messages.getText("compress") + ":"); |
86 |
} |
87 |
|
88 |
protected void addFile(String fileName, long time) { |
89 |
File f = new File(fileName); |
90 |
String size = RasterLocator.getManager().getFileUtils().formatFileSize(f.length());
|
91 |
|
92 |
String compression;
|
93 |
if (fileName.endsWith("ecw") || fileName.endsWith("jp2") || |
94 |
fileName.endsWith("jpg") || fileName.endsWith("jpeg")) { |
95 |
compression = "Yes";
|
96 |
} else {
|
97 |
compression = "No";
|
98 |
} |
99 |
|
100 |
JPanel pContent = new JPanel(); |
101 |
pContent.setLayout(new GridBagLayout()); |
102 |
|
103 |
GridBagConstraints gridBagConstraints;
|
104 |
gridBagConstraints = new GridBagConstraints(); |
105 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
106 |
gridBagConstraints.insets = new Insets(5, 5, 2, 5); |
107 |
pContent.add(newPanelFile(fileName), gridBagConstraints); |
108 |
|
109 |
gridBagConstraints = new GridBagConstraints(); |
110 |
gridBagConstraints.gridx = 0;
|
111 |
gridBagConstraints.gridy = 1;
|
112 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
113 |
gridBagConstraints.insets = new Insets(2, 5, 2, 5); |
114 |
pContent.add(newPanelTimeSize(RasterLocator.getManager().getRasterUtils().formatTime(time), size), gridBagConstraints); |
115 |
|
116 |
gridBagConstraints = new GridBagConstraints(); |
117 |
gridBagConstraints.gridx = 0;
|
118 |
gridBagConstraints.gridy = 2;
|
119 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
120 |
gridBagConstraints.insets = new Insets(2, 5, 5, 5); |
121 |
pContent.add(newPanelCompression(compression), gridBagConstraints); |
122 |
|
123 |
gridBagConstraints = new GridBagConstraints(); |
124 |
gridBagConstraints.gridx = 0;
|
125 |
gridBagConstraints.gridy = 4;
|
126 |
gridBagConstraints.weightx = 1.0;
|
127 |
gridBagConstraints.weighty = 1.0;
|
128 |
JPanel emptyPanel = new JPanel(); |
129 |
emptyPanel.setPreferredSize(new Dimension(0, 0)); |
130 |
pContent.add(emptyPanel, gridBagConstraints); |
131 |
|
132 |
pContent.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.gray, 1), "Estadisticas", |
133 |
TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
134 |
|
135 |
File file = new File(fileName); |
136 |
|
137 |
contentPane.add(pContent, file.getName()); |
138 |
if (comboBox.getItemCount() == 0) |
139 |
comboBox.setVisible(false);
|
140 |
else
|
141 |
comboBox.setVisible(true);
|
142 |
comboBox.addItem(file.getName()); |
143 |
} |
144 |
|
145 |
/**
|
146 |
* This method initializes this
|
147 |
* @return void
|
148 |
*/
|
149 |
private void initialize() { |
150 |
setLayout(new BorderLayout(5, 5)); |
151 |
|
152 |
contentPane = new JPanel(); |
153 |
contentPane.setLayout(new CardLayout()); |
154 |
|
155 |
comboBox = new JComboBox(); |
156 |
comboBox.setVisible(false);
|
157 |
comboBox.addActionListener(this);
|
158 |
|
159 |
this.add(contentPane, BorderLayout.CENTER); |
160 |
this.add(comboBox, BorderLayout.SOUTH); |
161 |
} |
162 |
|
163 |
/**
|
164 |
* This method initializes jPanel
|
165 |
*
|
166 |
* @return javax.swing.JPanel
|
167 |
*/
|
168 |
private JPanel newPanelFile(String file) { |
169 |
JPanel pFile = new JPanel(); |
170 |
|
171 |
JLabel lFileNameTag = new JLabel(labelFilename); |
172 |
JLabel lPathTag = new JLabel(labelPath); |
173 |
|
174 |
File fileorig = new File(file); |
175 |
|
176 |
JTextField tFile = new JTextField(fileorig.getName()); |
177 |
tFile.setBackground(pFile.getBackground()); |
178 |
tFile.setEditable(false);
|
179 |
tFile.setHorizontalAlignment(JTextField.LEFT);
|
180 |
tFile.setBorder(null);
|
181 |
|
182 |
JTextField pathFile = new JTextField(fileorig.getParent() + File.separator); |
183 |
pathFile.setBackground(pFile.getBackground()); |
184 |
pathFile.setEditable(false);
|
185 |
pathFile.setHorizontalAlignment(JTextField.LEFT);
|
186 |
pathFile.setBorder(null);
|
187 |
|
188 |
pFile.setLayout(new GridBagLayout()); |
189 |
|
190 |
GridBagConstraints gridBagConstraints;
|
191 |
gridBagConstraints = new GridBagConstraints(); |
192 |
gridBagConstraints.gridx = 0;
|
193 |
gridBagConstraints.gridy = 0;
|
194 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
195 |
gridBagConstraints.insets = new Insets(5, 5, 5, 5); |
196 |
pFile.add(lFileNameTag, gridBagConstraints); |
197 |
|
198 |
gridBagConstraints = new GridBagConstraints(); |
199 |
gridBagConstraints.gridx = 1;
|
200 |
gridBagConstraints.gridy = 0;
|
201 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
202 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
203 |
gridBagConstraints.weightx = 1.0;
|
204 |
gridBagConstraints.insets = new Insets(5, 5, 5, 5); |
205 |
pFile.add(tFile, gridBagConstraints); |
206 |
|
207 |
gridBagConstraints = new GridBagConstraints(); |
208 |
gridBagConstraints.gridx = 0;
|
209 |
gridBagConstraints.gridy = 1;
|
210 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
211 |
gridBagConstraints.insets = new Insets(5, 5, 5, 5); |
212 |
pFile.add(lPathTag, gridBagConstraints); |
213 |
|
214 |
gridBagConstraints = new GridBagConstraints(); |
215 |
gridBagConstraints.gridx = 1;
|
216 |
gridBagConstraints.gridy = 1;
|
217 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
218 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
219 |
gridBagConstraints.weightx = 1.0;
|
220 |
gridBagConstraints.insets = new Insets(5, 5, 5, 5); |
221 |
pFile.add(pathFile, gridBagConstraints); |
222 |
|
223 |
|
224 |
return pFile;
|
225 |
} |
226 |
|
227 |
/**
|
228 |
* This method initializes jPanel1
|
229 |
*
|
230 |
* @return javax.swing.JPanel
|
231 |
*/
|
232 |
private JPanel newPanelTimeSize(String time, String size) { |
233 |
JPanel pTime = new JPanel(); |
234 |
pTime.setLayout(new GridBagLayout()); |
235 |
|
236 |
JLabel lTimeTag = new JLabel(labelTime); |
237 |
GridBagConstraints gridBagConstraints;
|
238 |
gridBagConstraints = new GridBagConstraints(); |
239 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
240 |
gridBagConstraints.insets = new Insets(2, 5, 2, 2); |
241 |
pTime.add(lTimeTag, gridBagConstraints); |
242 |
|
243 |
JLabel lTime = new JLabel(time); |
244 |
gridBagConstraints = new GridBagConstraints(); |
245 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
246 |
gridBagConstraints.weightx = 1.0;
|
247 |
gridBagConstraints.insets = new Insets(2, 2, 2, 11); |
248 |
pTime.add(lTime, gridBagConstraints); |
249 |
|
250 |
JLabel lSizeTag = new JLabel(labelSize); |
251 |
gridBagConstraints = new GridBagConstraints(); |
252 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
253 |
gridBagConstraints.insets = new Insets(2, 2, 2, 11); |
254 |
pTime.add(lSizeTag, gridBagConstraints); |
255 |
|
256 |
JLabel lSize = new JLabel(size); |
257 |
gridBagConstraints = new GridBagConstraints(); |
258 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
259 |
gridBagConstraints.weightx = 1.0;
|
260 |
gridBagConstraints.insets = new Insets(2, 2, 2, 5); |
261 |
pTime.add(lSize, gridBagConstraints); |
262 |
|
263 |
return pTime;
|
264 |
} |
265 |
|
266 |
/**
|
267 |
* This method initializes jPanel
|
268 |
*
|
269 |
* @return javax.swing.JPanel
|
270 |
*/
|
271 |
private JPanel newPanelCompression(String compression) { |
272 |
JPanel pCompression = new JPanel(); |
273 |
|
274 |
JLabel lCompressTag = new JLabel(labelCompression); |
275 |
JLabel lCompress = new JLabel(compression); |
276 |
|
277 |
pCompression.setLayout(new FlowLayout(FlowLayout.LEFT)); |
278 |
pCompression.add(lCompressTag); |
279 |
pCompression.add(lCompress); |
280 |
|
281 |
return pCompression;
|
282 |
} |
283 |
|
284 |
/**
|
285 |
* @param labelFilename the labelFilename to set
|
286 |
*/
|
287 |
private void setLabelFilename(String labelFilename) { |
288 |
this.labelFilename = labelFilename;
|
289 |
} |
290 |
|
291 |
/**
|
292 |
* @param labelFilename the labelFilename to set
|
293 |
*/
|
294 |
private void setLabelPath(String labelPath) { |
295 |
this.labelPath = labelPath;
|
296 |
} |
297 |
|
298 |
/**
|
299 |
* @param labelTime the labelTime to set
|
300 |
*/
|
301 |
private void setLabelTime(String labelTime) { |
302 |
this.labelTime = labelTime;
|
303 |
} |
304 |
|
305 |
/**
|
306 |
* @param labelSize the labelSize to set
|
307 |
*/
|
308 |
private void setLabelSize(String labelSize) { |
309 |
this.labelSize = labelSize;
|
310 |
} |
311 |
|
312 |
/**
|
313 |
* @param labelCompression the labelCompression to set
|
314 |
*/
|
315 |
private void setLabelCompression(String labelCompression) { |
316 |
this.labelCompression = labelCompression;
|
317 |
} |
318 |
|
319 |
public void actionPerformed(ActionEvent e) { |
320 |
if (e.getSource() == comboBox)
|
321 |
((CardLayout) contentPane.getLayout()).show(contentPane, (String) comboBox.getSelectedItem()); |
322 |
} |
323 |
} |