Revision 19843
org.gvsig.raster/tags/org.gvsig.raster-2.2.234/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/FileNameManagementImpl.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.swing.impl; |
|
23 |
|
|
24 |
import java.util.ArrayList; |
|
25 |
import java.util.List; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
28 |
import org.gvsig.fmap.dal.coverage.util.FileUtils; |
|
29 |
import org.gvsig.raster.swing.newlayer.FileNameManagement; |
|
30 |
|
|
31 |
/** |
|
32 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
33 |
*/ |
|
34 |
public class FileNameManagementImpl implements FileNameManagement { |
|
35 |
private FileUtils fileUtils = RasterLocator.getManager().getFileUtils(); |
|
36 |
|
|
37 |
public String getDefaultFilePath() { |
|
38 |
return System.getProperty("java.io.tmpdir");//System.getProperty("user.home"); |
|
39 |
} |
|
40 |
|
|
41 |
public List<String> getPrefixSupported() { |
|
42 |
List<String> list = new ArrayList<String>(); |
|
43 |
list.add("tif"); |
|
44 |
return list; |
|
45 |
} |
|
46 |
|
|
47 |
public String getUniqueLayerName() { |
|
48 |
return fileUtils.getOnlyLayerName(); |
|
49 |
} |
|
50 |
|
|
51 |
public void usesUniqueLayerName() { |
|
52 |
fileUtils.usesOnlyLayerName(); |
|
53 |
} |
|
54 |
|
|
55 |
} |
|
0 | 56 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.234/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/sumaryprocess/SummaryProcessDialog.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.swing.impl.sumaryprocess; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
|
|
26 |
import javax.swing.JFrame; |
|
27 |
|
|
28 |
import org.gvsig.i18n.Messages; |
|
29 |
import org.gvsig.raster.swing.basepanel.ButtonsPanelEvent; |
|
30 |
import org.gvsig.raster.swing.basepanel.ButtonsPanelListener; |
|
31 |
import org.gvsig.raster.swing.impl.basepanel.ButtonsPanel; |
|
32 |
|
|
33 |
/** |
|
34 |
* Panel principal del dialogo de finalizaci?n del salvado a raster. En el se |
|
35 |
* muestra la informaci?n de nombre de fichero, tama?o de este, tiempo de la |
|
36 |
* operaci?n, etc... |
|
37 |
* |
|
38 |
* Para mostrar un fichero solo hay que usar el metodo estatico show. |
|
39 |
* |
|
40 |
* @version 19/06/2008 |
|
41 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
42 |
*/ |
|
43 |
public class SummaryProcessDialog implements ButtonsPanelListener { |
|
44 |
private JFrame frame = null; |
|
45 |
private SummaryProcessPanel infoPanel = null; |
|
46 |
static private SummaryProcessDialog endInfoDialog = null; |
|
47 |
|
|
48 |
/** |
|
49 |
* Obtiene el panel con la informaci?n de finalizaci?n |
|
50 |
* @return EndInfoPanel |
|
51 |
*/ |
|
52 |
private SummaryProcessPanel getInfoPanel() { |
|
53 |
if (infoPanel == null) { |
|
54 |
infoPanel = new SummaryProcessPanel(); |
|
55 |
getFrame().add(infoPanel); |
|
56 |
infoPanel.addButtonPressedListener(this); |
|
57 |
} |
|
58 |
return infoPanel; |
|
59 |
} |
|
60 |
|
|
61 |
private JFrame getFrame() { |
|
62 |
if (frame == null) { |
|
63 |
frame = new JFrame(Messages.getText("stats")); |
|
64 |
frame.setResizable(false); |
|
65 |
frame.setAlwaysOnTop(true); |
|
66 |
} |
|
67 |
return frame; |
|
68 |
} |
|
69 |
|
|
70 |
static public void show(String fileName, long time) { |
|
71 |
if (fileName == null || !new File(fileName).exists()) |
|
72 |
return; |
|
73 |
|
|
74 |
if ((endInfoDialog == null) || (!endInfoDialog.getFrame().isVisible())) |
|
75 |
endInfoDialog = new SummaryProcessDialog(); |
|
76 |
endInfoDialog.getInfoPanel().addFile(fileName, time); |
|
77 |
endInfoDialog.getFrame().setContentPane(endInfoDialog.getInfoPanel()); |
|
78 |
endInfoDialog.getFrame().pack(); |
|
79 |
endInfoDialog.getFrame().setVisible(true); |
|
80 |
} |
|
81 |
|
|
82 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
|
83 |
if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) { |
|
84 |
getFrame().setVisible(false); |
|
85 |
endInfoDialog = null; |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
0 | 89 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.234/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/sumaryprocess/SummaryProcessPanel.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.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 |
} |
|
0 | 324 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.234/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/preview/SinglePreviewPanel.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.swing.impl.preview; |
|
23 |
|
|
24 |
import java.awt.BorderLayout; |
|
25 |
import java.awt.Color; |
|
26 |
import java.awt.Dimension; |
|
27 |
import java.awt.geom.Rectangle2D; |
|
28 |
|
|
29 |
import javax.swing.BorderFactory; |
|
30 |
import javax.swing.JPanel; |
|
31 |
import javax.swing.JTabbedPane; |
|
32 |
import javax.swing.border.TitledBorder; |
|
33 |
|
|
34 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
35 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
|
36 |
import org.gvsig.gui.beans.imagenavigator.IClientImageNavigator; |
|
37 |
import org.gvsig.gui.beans.imagenavigator.ImageNavigator; |
|
38 |
import org.gvsig.i18n.Messages; |
|
39 |
import org.gvsig.raster.swing.preview.DataSourcePreview; |
|
40 |
import org.gvsig.raster.swing.preview.PreviewPanel; |
|
41 |
import org.gvsig.raster.swing.preview.PreviewRenderProcess; |
|
42 |
/** |
|
43 |
* Single preview with fixed size to insert in a major panel. |
|
44 |
* |
|
45 |
* 19/02/2008 |
|
46 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
47 |
*/ |
|
48 |
public class SinglePreviewPanel extends JPanel implements PreviewPanel { |
|
49 |
private static final long serialVersionUID = 6028780107787443656L; |
|
50 |
private ImageNavigator imageNavigator = null; |
|
51 |
private DataSourcePreview fLayer = null; |
|
52 |
private PreviewRenderProcess renderProcess = null; |
|
53 |
private JPanel jPanelPreview = null; |
|
54 |
private PreviewRequestManager previewRequestManager = null; |
|
55 |
|
|
56 |
/** |
|
57 |
* Construir un nuevo PreviewBasePanel |
|
58 |
* @param renderProcess. Clase para procesar el raster antes del dibujado |
|
59 |
* @param lyr. Capa raster a mostrar en la previsualizaci?n |
|
60 |
*/ |
|
61 |
public SinglePreviewPanel( |
|
62 |
PreviewRenderProcess renderProcess, |
|
63 |
DataSourcePreview lyr) { |
|
64 |
this.renderProcess = renderProcess; |
|
65 |
setLayer(lyr); |
|
66 |
initialize(); |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* Construir un nuevo PreviewBasePanel |
|
71 |
* @param renderProcess. Clase para procesar el raster antes del dibujado |
|
72 |
* @param lyr. Capa raster a mostrar en la previsualizaci?n |
|
73 |
*/ |
|
74 |
public SinglePreviewPanel( |
|
75 |
PreviewRenderProcess renderProcess) { |
|
76 |
this.renderProcess = renderProcess; |
|
77 |
initialize(); |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* Inicializa los componentes gr?ficos |
|
82 |
*/ |
|
83 |
private void initialize() { |
|
84 |
setLayout(new BorderLayout(8, 8)); |
|
85 |
add(getPanelPreview(), BorderLayout.CENTER); |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* Cierra la capa abierta para previsualizaci?n |
|
90 |
*/ |
|
91 |
public void closePreviewLayer() { |
|
92 |
previewRequestManager.closePreviewLayer(); |
|
93 |
} |
|
94 |
|
|
95 |
/** |
|
96 |
* Obtiene el objeto IClientImageNavigator |
|
97 |
* @return |
|
98 |
*/ |
|
99 |
public IClientImageNavigator getPreviewManager() { |
|
100 |
return previewRequestManager; |
|
101 |
} |
|
102 |
|
|
103 |
/* |
|
104 |
* (non-Javadoc) |
|
105 |
* @see org.gvsig.raster.swing.preview.PreviewPanel#getImageNavigator() |
|
106 |
*/ |
|
107 |
public ImageNavigator getImageNavigator() { |
|
108 |
if (imageNavigator == null) { |
|
109 |
imageNavigator = new ImageNavigator(getPreviewManager()); |
|
110 |
imageNavigator.setFocusable(true); |
|
111 |
imageNavigator.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
|
112 |
} |
|
113 |
return imageNavigator; |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* Obtiene el panel con el componente con la vista previa |
|
118 |
* @return JPanel |
|
119 |
*/ |
|
120 |
public JPanel getPanelPreview() { |
|
121 |
if (jPanelPreview == null) { |
|
122 |
jPanelPreview = new JPanel(); |
|
123 |
JPanel jsubpanel2 = new JPanel(); |
|
124 |
jPanelPreview.setBorder(BorderFactory.createTitledBorder(null, Messages.getText("vista_previa"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
|
125 |
jPanelPreview.setLayout(new BorderLayout()); |
|
126 |
jsubpanel2.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); |
|
127 |
jsubpanel2.setLayout(new BorderLayout()); |
|
128 |
|
|
129 |
jsubpanel2.add(getImageNavigator(), BorderLayout.CENTER); |
|
130 |
jPanelPreview.add(jsubpanel2, BorderLayout.CENTER); |
|
131 |
|
|
132 |
jPanelPreview.setPreferredSize(new Dimension(237, 237)); |
|
133 |
jPanelPreview.setMinimumSize(new Dimension(237, 237)); |
|
134 |
jPanelPreview.setMaximumSize(new Dimension(237, 237)); |
|
135 |
} |
|
136 |
return jPanelPreview; |
|
137 |
} |
|
138 |
|
|
139 |
|
|
140 |
/** |
|
141 |
* Especificar la capa para la previsualizaci?n |
|
142 |
* @param layer |
|
143 |
*/ |
|
144 |
public void setLayer(DataSourcePreview fLayer) { |
|
145 |
this.fLayer = fLayer; |
|
146 |
previewRequestManager = new PreviewRequestManager(renderProcess, fLayer); |
|
147 |
|
|
148 |
previewInitializeSizes(); |
|
149 |
} |
|
150 |
|
|
151 |
public void previewInitializeSizes() { |
|
152 |
// Util para ejecutar el test sin una capa de prueba |
|
153 |
if (fLayer == null) |
|
154 |
return; |
|
155 |
|
|
156 |
// Especificar las dimensiones de la capa en la vista previa |
|
157 |
Rectangle2D extent2 = fLayer.getBBoxRectangle(); |
|
158 |
getImageNavigator().setViewDimensions(extent2.getMinX(), extent2.getMaxY(), extent2.getMaxX(), extent2.getMinY()); |
|
159 |
getImageNavigator().setZoom(1.0/ fLayer.getCellSize()); |
|
160 |
getImageNavigator().setAutoAdjusted(); |
|
161 |
} |
|
162 |
|
|
163 |
/** |
|
164 |
* Especificar el layer para el recorte |
|
165 |
* @param layer |
|
166 |
*/ |
|
167 |
public DataSourcePreview getLayer() { |
|
168 |
return fLayer; |
|
169 |
} |
|
170 |
|
|
171 |
/* |
|
172 |
* (non-Javadoc) |
|
173 |
* @see org.gvsig.raster.swing.preview.PreviewPanel#setPreviewSize(java.awt.Dimension) |
|
174 |
*/ |
|
175 |
public void setPreviewSize(Dimension dimension) { |
|
176 |
getPanelPreview().setPreferredSize(dimension); |
|
177 |
getPanelPreview().setMinimumSize(dimension); |
|
178 |
getPanelPreview().setMaximumSize(dimension); |
|
179 |
} |
|
180 |
|
|
181 |
/* |
|
182 |
* (non-Javadoc) |
|
183 |
* @see org.gvsig.raster.swing.preview.PreviewPanel#refreshPreview() |
|
184 |
*/ |
|
185 |
public void refreshPreview() { |
|
186 |
if (fLayer == null) |
|
187 |
return; |
|
188 |
getImageNavigator().updateBuffer(); |
|
189 |
} |
|
190 |
|
|
191 |
/* |
|
192 |
* (non-Javadoc) |
|
193 |
* @see org.gvsig.raster.swing.preview.PreviewPanel#getDataSourcePreview() |
|
194 |
*/ |
|
195 |
public DataSourcePreview getDataSourcePreview() { |
|
196 |
return fLayer; |
|
197 |
} |
|
198 |
|
|
199 |
public void addButtonPressedListener(ButtonsPanelListener listener) { |
|
200 |
// TODO Auto-generated method stub |
|
201 |
|
|
202 |
} |
|
203 |
|
|
204 |
public ButtonsPanel getButtonsPanel() { |
|
205 |
// TODO Auto-generated method stub |
|
206 |
return null; |
|
207 |
} |
|
208 |
|
|
209 |
public JTabbedPane getTabbedPane() { |
|
210 |
// TODO Auto-generated method stub |
|
211 |
return null; |
|
212 |
} |
|
213 |
} |
|
0 | 214 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.234/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/preview/PreviewRequestManager.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.swing.impl.preview; |
|
23 |
|
|
24 |
import java.awt.Component; |
|
25 |
import java.awt.Graphics2D; |
|
26 |
|
|
27 |
import javax.swing.JOptionPane; |
|
28 |
|
|
29 |
import org.gvsig.gui.beans.imagenavigator.IClientImageNavigator; |
|
30 |
import org.gvsig.gui.beans.imagenavigator.ImageUnavailableException; |
|
31 |
import org.gvsig.i18n.Messages; |
|
32 |
import org.gvsig.raster.swing.preview.DataSourcePreview; |
|
33 |
import org.gvsig.raster.swing.preview.PreviewRenderProcess; |
|
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
36 |
|
|
37 |
/** |
|
38 |
* Gestor de visualizaci?n de preview. Se encarga del repintado de la imagen |
|
39 |
* de la previsualizaci?n |
|
40 |
* |
|
41 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
42 |
*/ |
|
43 |
public class PreviewRequestManager implements IClientImageNavigator { |
|
44 |
private static final Logger logger = LoggerFactory.getLogger(PreviewRequestManager.class); |
|
45 |
private DataSourcePreview previewLayer = null; |
|
46 |
private PreviewRenderProcess renderProcess = null; |
|
47 |
|
|
48 |
/** |
|
49 |
* Construye un ColorTableListener |
|
50 |
* @param |
|
51 |
*/ |
|
52 |
public PreviewRequestManager( PreviewRenderProcess renderProcess, |
|
53 |
DataSourcePreview layer) { |
|
54 |
this.renderProcess = renderProcess; |
|
55 |
setLayer(layer); |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* Asigna la capa raster de la vista |
|
60 |
* @param fLayer |
|
61 |
*/ |
|
62 |
private void setLayer(DataSourcePreview fLayer) { |
|
63 |
//if (fLayer instanceof IRasterLayerActions) { |
|
64 |
//IRasterLayerActions ly = (IRasterLayerActions) fLayer; |
|
65 |
//try { |
|
66 |
//Este c?digo no va bien pq la preview siempre tiene el extent global y el ?ltimo fichero |
|
67 |
//puede ser de un zoom |
|
68 |
/*if(ly.isActionEnabled(IRasterLayerActions.REMOTE_ACTIONS)) |
|
69 |
previewLayer = (FLyrRaster)fLayer.getFileLayer(); |
|
70 |
else*/ |
|
71 |
previewLayer = fLayer.cloneDataSourcePreview(); |
|
72 |
//} catch (Exception e) { |
|
73 |
//messageBoxError("preview_not_available", previewBasePanel, e); |
|
74 |
//} |
|
75 |
//} |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* Cierra la capa abierta para previsualizaci?n |
|
80 |
*/ |
|
81 |
public void closePreviewLayer() { |
|
82 |
previewLayer.closePreviewLayer(); |
|
83 |
} |
|
84 |
|
|
85 |
public void drawImage(Graphics2D g, double x1, double y1, double x2, double y2, double zoom, int width, int height) |
|
86 |
throws ImageUnavailableException { |
|
87 |
if (previewLayer == null) |
|
88 |
throw new ImageUnavailableException(Messages.getText("error_dont_exists_layer")); |
|
89 |
|
|
90 |
previewLayer.pushStatus(); |
|
91 |
try { |
|
92 |
if(renderProcess != null) |
|
93 |
renderProcess.process(previewLayer); |
|
94 |
} catch (ImageUnavailableException e2) { |
|
95 |
throw new ImageUnavailableException(Messages.getText("error_adding_filters")); |
|
96 |
} catch (Exception e2) { |
|
97 |
logger.debug("error_adding_filters", this, e2); |
|
98 |
throw new ImageUnavailableException(Messages.getText("error_adding_filters")); |
|
99 |
} |
|
100 |
|
|
101 |
try { |
|
102 |
double[] coords = new double[]{x1, y1, x2, y2}; |
|
103 |
previewLayer.draw(null, g, coords, width, height, null, 1.0); |
|
104 |
} catch (ImageUnavailableException e) { |
|
105 |
logger.debug("error_preview_render", this, e); |
|
106 |
throw new ImageUnavailableException(Messages.getText("error_preview_render")); |
|
107 |
} catch (Exception e2) { |
|
108 |
logger.debug("error_preview_render", this, e2); |
|
109 |
throw new ImageUnavailableException(Messages.getText("error_preview_render")); |
|
110 |
} |
|
111 |
previewLayer.popStatus(); |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* Shows a error dialog with a text and a accept button |
|
116 |
* @param msg Message to show in the dialog |
|
117 |
* @param parentWindow Parent window |
|
118 |
*/ |
|
119 |
public void messageBoxError(String msg, Object parentWindow, Exception exception) { |
|
120 |
logger.debug(msg, parentWindow, exception); |
|
121 |
String string = Messages.getText("accept"); |
|
122 |
Object[] options = {string}; |
|
123 |
JOptionPane.showOptionDialog((Component)parentWindow, |
|
124 |
"<html>" + Messages.getText(msg).replaceAll("\n", "<br>") + "</html>", |
|
125 |
Messages.getText("confirmacion"), |
|
126 |
JOptionPane.OK_OPTION, |
|
127 |
JOptionPane.ERROR_MESSAGE, |
|
128 |
null, |
|
129 |
options, |
|
130 |
string); |
|
131 |
} |
|
132 |
} |
|
0 | 133 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.234/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/preview/PreviewBasePanel.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.swing.impl.preview; |
|
23 |
|
|
24 |
import java.awt.BorderLayout; |
|
25 |
import java.awt.Color; |
|
26 |
import java.awt.Dimension; |
|
27 |
import java.awt.geom.Rectangle2D; |
|
28 |
import java.util.ArrayList; |
|
29 |
|
|
30 |
import javax.swing.BorderFactory; |
|
31 |
import javax.swing.JPanel; |
|
32 |
import javax.swing.JSplitPane; |
|
33 |
import javax.swing.JTabbedPane; |
|
34 |
import javax.swing.border.Border; |
|
35 |
import javax.swing.border.TitledBorder; |
|
36 |
import javax.swing.plaf.basic.BasicSplitPaneDivider; |
|
37 |
import javax.swing.plaf.basic.BasicSplitPaneUI; |
|
38 |
|
|
39 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
40 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
|
41 |
import org.gvsig.gui.beans.imagenavigator.IClientImageNavigator; |
|
42 |
import org.gvsig.gui.beans.imagenavigator.ImageNavigator; |
|
43 |
import org.gvsig.i18n.Messages; |
|
44 |
import org.gvsig.raster.swing.preview.DataSourcePreview; |
|
45 |
import org.gvsig.raster.swing.preview.PreviewBasePanelTab; |
|
46 |
import org.gvsig.raster.swing.preview.PreviewPanel; |
|
47 |
import org.gvsig.raster.swing.preview.PreviewRenderProcess; |
|
48 |
/** |
|
49 |
* Panel base para componentes con previsualizaci?n. |
|
50 |
* |
|
51 |
* 19/02/2008 |
|
52 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
53 |
*/ |
|
54 |
public class PreviewBasePanel extends DefaultButtonsPanel implements PreviewPanel { |
|
55 |
private static final long serialVersionUID = 6028780107787443656L; |
|
56 |
|
|
57 |
private ImageNavigator imageNavigator = null; |
|
58 |
private DataSourcePreview fLayer = null; |
|
59 |
|
|
60 |
/** |
|
61 |
* Lista de paneles de usuario que son a?adidos a los tabs |
|
62 |
*/ |
|
63 |
private ArrayList<PreviewBasePanelTab> |
|
64 |
userPanel = new ArrayList<PreviewBasePanelTab>(); |
|
65 |
/** |
|
66 |
* Panel de la base del cuadro con opciones comunes para todos los tabs |
|
67 |
*/ |
|
68 |
private JPanel generalPanel = null; |
|
69 |
/** |
|
70 |
* Panel de debajo de la vista previa |
|
71 |
*/ |
|
72 |
private JPanel downPreviewPanel = null; |
|
73 |
private PreviewRenderProcess renderProcess = null; |
|
74 |
|
|
75 |
/** |
|
76 |
* Panel central para el caso de que sea m?s de uno (con pesta?as) |
|
77 |
*/ |
|
78 |
private JTabbedPane tabbedPane = null; |
|
79 |
/** |
|
80 |
* Panel central para el caso de que sea solo uno (sin pesta?as) |
|
81 |
*/ |
|
82 |
private JPanel mainPanel = null; |
|
83 |
|
|
84 |
private JSplitPane jPanelRight = null; |
|
85 |
private JPanel jPanelPreview = null; |
|
86 |
|
|
87 |
private PreviewRequestManager previewRequestManager = null; |
|
88 |
|
|
89 |
/** |
|
90 |
* Construir un nuevo PreviewBasePanel |
|
91 |
* @param userPanel. Lista de paneles de usuario para los tabs |
|
92 |
* @param generalPanel. Panel inferior global para todos los tabs |
|
93 |
* @param downPreviewPanel. Panel inferior al de la previsualizaci?n |
|
94 |
* @param renderProcess. Clase para procesar el raster antes del dibujado |
|
95 |
* @param lyr. Capa raster a mostrar en la previsualizaci?n |
|
96 |
*/ |
|
97 |
public PreviewBasePanel(ArrayList<PreviewBasePanelTab> userPanel, |
|
98 |
JPanel generalPanel, |
|
99 |
JPanel downPreviewPanel, |
|
100 |
PreviewRenderProcess renderProcess, |
|
101 |
DataSourcePreview lyr) { |
|
102 |
this(ButtonsPanel.BUTTONS_ACCEPTCANCELAPPLY, userPanel, generalPanel, downPreviewPanel, renderProcess, lyr); |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
106 |
* Construir un nuevo PreviewBasePanel |
|
107 |
* @param buttons |
|
108 |
* @param userPanel |
|
109 |
* @param generalPanel |
|
110 |
* @param downPreviewPanel |
|
111 |
* @param renderProcess |
|
112 |
* @param lyr |
|
113 |
*/ |
|
114 |
public PreviewBasePanel(int buttons, |
|
115 |
ArrayList<PreviewBasePanelTab> userPanel, |
|
116 |
JPanel generalPanel, |
|
117 |
JPanel downPreviewPanel, |
|
118 |
PreviewRenderProcess renderProcess, |
|
119 |
DataSourcePreview lyr) { |
|
120 |
super(buttons); |
|
121 |
this.userPanel = userPanel; |
|
122 |
this.generalPanel = generalPanel; |
|
123 |
this.downPreviewPanel = downPreviewPanel; |
|
124 |
this.renderProcess = renderProcess; |
|
125 |
setLayer(lyr); |
|
126 |
initialize(); |
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* Inicializa los componentes gr?ficos |
|
131 |
*/ |
|
132 |
private void initialize() { |
|
133 |
setLayout(new BorderLayout(8, 8)); |
|
134 |
|
|
135 |
JPanel panelLeft = new JPanel(); |
|
136 |
panelLeft.setPreferredSize(new Dimension(390, 0)); |
|
137 |
panelLeft.setLayout(new BorderLayout(8, 8)); |
|
138 |
if(userPanel != null) { |
|
139 |
if(userPanel.size() == 1) |
|
140 |
panelLeft.add(getPanelWithoutTabs(), BorderLayout.CENTER); |
|
141 |
else if(userPanel.size() > 1) |
|
142 |
panelLeft.add(getTabbedPane(), BorderLayout.CENTER); |
|
143 |
} |
|
144 |
if(generalPanel != null) |
|
145 |
panelLeft.add(getGeneralPanel(), BorderLayout.SOUTH); |
|
146 |
|
|
147 |
JSplitPane jSplitPane1 = new JSplitPane(); |
|
148 |
jSplitPane1.setLeftComponent(panelLeft); |
|
149 |
jSplitPane1.setRightComponent(getPanelRight()); |
|
150 |
jSplitPane1.setResizeWeight(1.0); |
|
151 |
jSplitPane1.setContinuousLayout(true); |
|
152 |
jSplitPane1.setUI(new BasicSplitPaneUI() { |
|
153 |
public BasicSplitPaneDivider createDefaultDivider() { |
|
154 |
return new BasicSplitPaneDivider(this) { |
|
155 |
private static final long serialVersionUID = 1L; |
|
156 |
|
|
157 |
public void setBorder(Border b) { |
|
158 |
} |
|
159 |
}; |
|
160 |
} |
|
161 |
}); |
|
162 |
jSplitPane1.setBorder(null); |
|
163 |
|
|
164 |
add(jSplitPane1, BorderLayout.CENTER); |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* Cierra la capa abierta para previsualizaci?n |
|
169 |
*/ |
|
170 |
public void closePreviewLayer() { |
|
171 |
previewRequestManager.closePreviewLayer(); |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* Asigna el panel de la posici?n 0 del array. Este panel es el que se utiliza |
|
176 |
* cuando no hay un JTabbedPane |
|
177 |
* @param panel |
|
178 |
*/ |
|
179 |
public void setUniquePanel(PreviewBasePanelTab panel) { |
|
180 |
userPanel.clear(); |
|
181 |
userPanel.add(panel); |
|
182 |
mainPanel = (JPanel)panel; |
|
183 |
((JSplitPane)getContent().getComponent(0)).setLeftComponent(mainPanel); |
|
184 |
getContent().updateUI(); |
|
185 |
} |
|
186 |
|
|
187 |
/* |
|
188 |
* (non-Javadoc) |
|
189 |
* @see org.gvsig.raster.swing.preview.PreviewPanel#getTabbedPane() |
|
190 |
*/ |
|
191 |
public JTabbedPane getTabbedPane() { |
|
192 |
if (tabbedPane == null) { |
|
193 |
tabbedPane = new JTabbedPane(); |
|
194 |
for (int i = 0; i < userPanel.size(); i++) |
|
195 |
tabbedPane.addTab(((PreviewBasePanelTab)userPanel.get(i)).getTitle(), ((PreviewBasePanelTab)userPanel.get(i)).getPanel()); |
|
196 |
} |
|
197 |
return tabbedPane; |
|
198 |
} |
|
199 |
|
|
200 |
/** |
|
201 |
* Obtiene el panel central sin tabs. Esto ocurre cuando el usuario solo quiere un |
|
202 |
* panel. En este caso no hacen falta pesta?as por lo que se incorpora solo un JPanel |
|
203 |
* @return JTabbedPane |
|
204 |
*/ |
|
205 |
public JPanel getPanelWithoutTabs() { |
|
206 |
if (mainPanel == null) { |
|
207 |
if(((PreviewBasePanelTab)userPanel.get(0)) instanceof JPanel) { |
|
208 |
mainPanel = ((PreviewBasePanelTab)userPanel.get(0)).getPanel(); |
|
209 |
} else |
|
210 |
mainPanel = new JPanel(); |
|
211 |
} |
|
212 |
return mainPanel; |
|
213 |
} |
|
214 |
|
|
215 |
/** |
|
216 |
* Obtiene el panel con opciones comunes a todas las pesta?as. |
|
217 |
* @return JPanel |
|
218 |
*/ |
|
219 |
public JPanel getGeneralPanel() { |
|
220 |
return generalPanel; |
|
221 |
} |
|
222 |
|
|
223 |
/** |
|
224 |
* Obtiene el panel de debajo de la vista previa |
|
225 |
* @return JPanel |
|
226 |
*/ |
|
227 |
public JPanel getDownPreviewPanel() { |
|
228 |
return downPreviewPanel; |
|
229 |
} |
|
230 |
|
|
231 |
/** |
|
232 |
* Obtiene la lista de paneles de usuario |
|
233 |
* @return ArrayList de IUserPanelInterface |
|
234 |
*/ |
|
235 |
public ArrayList<PreviewBasePanelTab> getUserPanels() { |
|
236 |
return userPanel; |
|
237 |
} |
|
238 |
|
|
239 |
/** |
|
240 |
* Obtiene el objeto IClientImageNavigator |
|
241 |
* @return |
|
242 |
*/ |
|
243 |
public IClientImageNavigator getPreviewManager() { |
|
244 |
return previewRequestManager; |
|
245 |
} |
|
246 |
|
|
247 |
/* |
|
248 |
* (non-Javadoc) |
|
249 |
* @see org.gvsig.raster.swing.preview.PreviewPanel#getImageNavigator() |
|
250 |
*/ |
|
251 |
public ImageNavigator getImageNavigator() { |
|
252 |
if (imageNavigator == null) { |
|
253 |
imageNavigator = new ImageNavigator(getPreviewManager()); |
|
254 |
imageNavigator.setFocusable(true); |
|
255 |
imageNavigator.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); |
|
256 |
} |
|
257 |
return imageNavigator; |
|
258 |
} |
|
259 |
|
|
260 |
/** |
|
261 |
* Obtiene el panel con el componente con la vista previa |
|
262 |
* @return JPanel |
|
263 |
*/ |
|
264 |
public JPanel getPanelPreview() { |
|
265 |
if (jPanelPreview == null) { |
|
266 |
jPanelPreview = new JPanel(); |
|
267 |
JPanel jsubpanel2 = new JPanel(); |
|
268 |
jPanelPreview.setBorder(BorderFactory.createTitledBorder(null, Messages.getText("vista_previa"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
|
269 |
jPanelPreview.setLayout(new BorderLayout()); |
|
270 |
jsubpanel2.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); |
|
271 |
jsubpanel2.setLayout(new BorderLayout()); |
|
272 |
|
|
273 |
jsubpanel2.add(getImageNavigator(), BorderLayout.CENTER); |
|
274 |
jPanelPreview.add(jsubpanel2, BorderLayout.CENTER); |
|
275 |
|
|
276 |
jPanelPreview.setPreferredSize(new Dimension(237, 237)); |
|
277 |
jPanelPreview.setMinimumSize(new Dimension(237, 237)); |
|
278 |
jPanelPreview.setMaximumSize(new Dimension(237, 237)); |
|
279 |
} |
|
280 |
return jPanelPreview; |
|
281 |
} |
|
282 |
|
|
283 |
/** |
|
284 |
* Devuelve el panel donde estar? el widget de preview |
|
285 |
* @return |
|
286 |
*/ |
|
287 |
private JSplitPane getPanelRight() { |
|
288 |
if (jPanelRight == null) { |
|
289 |
jPanelRight = new JSplitPane(); |
|
290 |
jPanelRight.setOrientation(JSplitPane.VERTICAL_SPLIT); |
|
291 |
jPanelRight.setContinuousLayout(true); |
|
292 |
jPanelRight.setResizeWeight(0.0); |
|
293 |
jPanelRight.setPreferredSize(new Dimension(220, 0)); |
|
294 |
jPanelRight.setMinimumSize(new Dimension(220, 0)); |
|
295 |
|
|
296 |
if(getPanelPreview() != null) |
|
297 |
jPanelRight.setTopComponent(getPanelPreview()); |
|
298 |
else |
|
299 |
jPanelRight.setTopComponent(new JPanel()); |
|
300 |
if(getDownPreviewPanel() != null) |
|
301 |
jPanelRight.setBottomComponent(getDownPreviewPanel()); |
|
302 |
else |
|
303 |
jPanelRight.setBottomComponent(new JPanel()); |
|
304 |
jPanelRight.setUI(new BasicSplitPaneUI() { |
|
305 |
public BasicSplitPaneDivider createDefaultDivider() { |
|
306 |
return new BasicSplitPaneDivider(this) { |
|
307 |
private static final long serialVersionUID = 1L; |
|
308 |
|
|
309 |
public void setBorder(Border b) { |
|
310 |
} |
|
311 |
}; |
|
312 |
} |
|
313 |
}); |
|
314 |
jPanelRight.setBorder(null); |
|
315 |
} |
|
316 |
return jPanelRight; |
|
317 |
} |
|
318 |
|
|
319 |
public void setLayer(DataSourcePreview fLayer) { |
|
320 |
this.fLayer = fLayer; |
|
321 |
previewRequestManager = new PreviewRequestManager(renderProcess, fLayer); |
|
322 |
|
|
323 |
previewInitializeSizes(); |
|
324 |
} |
|
325 |
|
|
326 |
public void previewInitializeSizes() { |
|
327 |
// Util para ejecutar el test sin una capa de prueba |
|
328 |
if (fLayer == null) |
|
329 |
return; |
|
330 |
|
|
331 |
// Especificar las dimensiones de la capa en la vista previa |
|
332 |
Rectangle2D extent2 = fLayer.getBBoxRectangle(); |
|
333 |
getImageNavigator().setViewDimensions(extent2.getMinX(), extent2.getMaxY(), extent2.getMaxX(), extent2.getMinY()); |
|
334 |
getImageNavigator().setZoom(1.0/ fLayer.getCellSize()); |
|
335 |
getImageNavigator().setAutoAdjusted(); |
|
336 |
} |
|
337 |
|
|
338 |
|
|
339 |
/** |
|
340 |
* Especificar el layer para el recorte |
|
341 |
* @param layer |
|
342 |
*/ |
|
343 |
public DataSourcePreview getLayer() { |
|
344 |
return fLayer; |
|
345 |
} |
|
346 |
|
|
347 |
/* |
|
348 |
* (non-Javadoc) |
|
349 |
* @see org.gvsig.raster.swing.preview.PreviewPanel#setPreviewSize(java.awt.Dimension) |
|
350 |
*/ |
|
351 |
public void setPreviewSize(Dimension dimension) { |
|
352 |
getPanelPreview().setPreferredSize(dimension); |
|
353 |
getPanelPreview().setMinimumSize(dimension); |
|
354 |
getPanelPreview().setMaximumSize(dimension); |
|
355 |
} |
|
356 |
|
|
357 |
/* |
|
358 |
* (non-Javadoc) |
|
359 |
* @see org.gvsig.raster.swing.preview.PreviewPanel#refreshPreview() |
|
360 |
*/ |
|
361 |
public void refreshPreview() { |
|
362 |
if (fLayer == null) |
|
363 |
return; |
|
364 |
getImageNavigator().updateBuffer(); |
|
365 |
} |
|
366 |
|
|
367 |
/* |
|
368 |
* (non-Javadoc) |
|
369 |
* @see org.gvsig.raster.swing.preview.PreviewPanel#getDataSourcePreview() |
|
370 |
*/ |
|
371 |
public DataSourcePreview getDataSourcePreview() { |
|
372 |
return fLayer; |
|
373 |
} |
|
374 |
} |
|
0 | 375 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.234/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/slider/ColorSliderTextContainer.java | ||
---|---|---|
1 |
package org.gvsig.raster.swing.impl.slider; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Color; |
|
5 |
import java.awt.Dimension; |
|
6 |
import java.awt.GridBagConstraints; |
|
7 |
import java.awt.GridBagLayout; |
|
8 |
import java.util.ArrayList; |
|
9 |
import java.util.Iterator; |
|
10 |
|
|
11 |
import javax.swing.JPanel; |
|
12 |
import javax.swing.JSpinner; |
|
13 |
import javax.swing.event.ChangeEvent; |
|
14 |
import javax.swing.event.ChangeListener; |
|
15 |
|
|
16 |
import org.gvsig.gui.beans.doubleslider.DoubleSlider; |
|
17 |
import org.gvsig.gui.beans.doubleslider.DoubleSliderEvent; |
|
18 |
import org.gvsig.gui.beans.doubleslider.DoubleSliderListener; |
|
19 |
/** |
|
20 |
* Barra de deslizamiento con una ventana de texto que tiene el valor de la |
|
21 |
* posici?n de la barra. En este control podr? controlarse mediante la entrada |
|
22 |
* de datos por la caja de texto la posibilidad de introducir valores decimales. |
|
23 |
* |
|
24 |
* @version 15/06/2007 |
|
25 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
26 |
*/ |
|
27 |
public class ColorSliderTextContainer extends JPanel implements ChangeListener, DoubleSliderListener { |
|
28 |
private static final long serialVersionUID = 1876415954410511634L; |
|
29 |
private ArrayList<DoubleSliderListener> actionCommandListeners = new ArrayList<DoubleSliderListener>(); |
|
30 |
|
|
31 |
private JPanel pText = null; |
|
32 |
private DoubleSlider slider = null; |
|
33 |
private JSpinner jSpinner = null; |
|
34 |
private int min = 0; |
|
35 |
private int max = 255; |
|
36 |
private int defaultPos = 0; |
|
37 |
|
|
38 |
/** |
|
39 |
* Contructor |
|
40 |
* @param min Valor m?nimo de la barra |
|
41 |
* @param max Valor m?ximo de la barra |
|
42 |
* @param defaultPos Posici?n por defecto |
|
43 |
*/ |
|
44 |
public ColorSliderTextContainer(int min, int max, int defaultPos) { |
|
45 |
super(); |
|
46 |
this.min = min; |
|
47 |
this.max = max; |
|
48 |
this.defaultPos = defaultPos; |
|
49 |
|
|
50 |
initialize(); |
|
51 |
slider.setTwoSliders(false); |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* Constructor vacio |
|
56 |
*/ |
|
57 |
public ColorSliderTextContainer() { |
|
58 |
this(0, 100, 0); |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* This method initializes this |
|
63 |
* |
|
64 |
*/ |
|
65 |
private void initialize() { |
|
66 |
this.setLayout(new BorderLayout(5, 5)); |
|
67 |
this.add(getSlider(), BorderLayout.CENTER); |
|
68 |
this.add(getPText(), BorderLayout.EAST); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* This method initializes jPanel1 |
|
73 |
* |
|
74 |
* @return javax.swing.JPanel |
|
75 |
*/ |
|
76 |
private JPanel getPText() { |
|
77 |
if (pText == null) { |
|
78 |
pText = new JPanel(); |
|
79 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
80 |
gridBagConstraints1.insets = new java.awt.Insets(0, 10, 8, 0); |
|
81 |
pText.setLayout(new GridBagLayout()); |
|
82 |
pText.add(getJSpinner(), gridBagConstraints1); |
|
83 |
} |
|
84 |
return pText; |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* This method initializes jSlider |
|
89 |
* |
|
90 |
* @return javax.swing.JSlider |
|
91 |
*/ |
|
92 |
public DoubleSlider getSlider() { |
|
93 |
if (slider == null) { |
|
94 |
slider = new DoubleSlider(); |
|
95 |
slider.setMinimum(min); |
|
96 |
slider.setMaximum(max); |
|
97 |
slider.setValue(defaultPos); |
|
98 |
slider.addValueChangedListener(this); |
|
99 |
} |
|
100 |
return slider; |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* This method initializes jTextField |
|
105 |
* |
|
106 |
* @return javax.swing.JTextField |
|
107 |
*/ |
|
108 |
public JSpinner getJSpinner() { |
|
109 |
if (jSpinner == null) { |
|
110 |
jSpinner = new JSpinner(); |
|
111 |
jSpinner.setValue(new Integer(defaultPos)); |
|
112 |
jSpinner.setPreferredSize(new Dimension(50, 26)); |
|
113 |
jSpinner.setMinimumSize(new Dimension(50, 26)); |
|
114 |
jSpinner.addChangeListener(this); |
|
115 |
} |
|
116 |
return jSpinner; |
|
117 |
} |
|
118 |
|
|
119 |
public void setComponentSize(int w, int h){ |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* Obtiene el valor del control. |
|
124 |
* @return Valor del control en formato double. |
|
125 |
*/ |
|
126 |
public int getValue() { |
|
127 |
return new Integer(getJSpinner().getValue() + "").intValue(); |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* Asigna el valor del control. |
|
132 |
* @return Valor del control en formato double. |
|
133 |
*/ |
|
134 |
public void setValue(int value) { |
|
135 |
getJSpinner().setValue(new Integer(value)); |
|
136 |
getSlider().setValue(value); |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* Activa o desactiva el control del panel |
|
141 |
* @param active |
|
142 |
*/ |
|
143 |
public void setControlEnabled(boolean active){ |
|
144 |
getSlider().setEnabled(active); |
|
145 |
getJSpinner().setEnabled(active); |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* Obtiene el valor m?ximo del slider |
|
150 |
* @return Entero con el valor m?ximo |
|
151 |
*/ |
|
152 |
public int getMax() { |
|
153 |
return max; |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* Asigna el valor m?ximo del slider |
|
158 |
* @param Entero con el valor m?ximo |
|
159 |
* @deprecated Usar setMaximum en su lugar |
|
160 |
*/ |
|
161 |
public void setMax(int max) { |
|
162 |
this.setMaximum(max); |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* Asigna el valor m?ximo del slider |
|
167 |
* @param Entero con el valor m?ximo |
|
168 |
*/ |
|
169 |
public void setMaximum(int max) { |
|
170 |
this.max = max; |
|
171 |
updateInterval(); |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* Obtiene el valor m?nimo del slider |
|
176 |
* @return Entero con el valor m?nimo |
|
177 |
*/ |
|
178 |
public int getMin() { |
|
179 |
return min; |
|
180 |
} |
|
181 |
|
|
182 |
/** |
|
183 |
* Asigna el valor m?nimo del slider |
|
184 |
* @param Entero con el valor m?nimo |
|
185 |
* @deprecated Usar setMinimum |
|
186 |
*/ |
|
187 |
public void setMin(int min) { |
|
188 |
this.setMinimum(min); |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* Asigna el valor m?nimo del slider |
|
193 |
* @param Entero con el valor m?nimo |
|
194 |
*/ |
|
195 |
public void setMinimum(int min) { |
|
196 |
this.min = min; |
|
197 |
updateInterval(); |
|
198 |
} |
|
199 |
|
|
200 |
private void updateInterval() { |
|
201 |
int aux = this.getValue(); |
|
202 |
getSlider().setMinimum(min); |
|
203 |
getSlider().setMaximum(max); |
|
204 |
setValue(aux); |
|
205 |
} |
|
206 |
|
|
207 |
/** |
|
208 |
* Especificar el color izquierdo del control |
|
209 |
* @param color |
|
210 |
*/ |
|
211 |
public void setColor1(Color color, boolean refresh) { |
|
212 |
slider.setColor1(color, refresh); |
|
213 |
} |
|
214 |
|
|
215 |
/** |
|
216 |
* Especificar el color derecho del control |
|
217 |
* @param color |
|
218 |
*/ |
|
219 |
public void setColor2(Color color, boolean refresh) { |
|
220 |
slider.setColor2(color, refresh); |
|
221 |
} |
|
222 |
|
|
223 |
/** |
|
224 |
* Controla cuando cambia el spinner |
|
225 |
*/ |
|
226 |
public void stateChanged(ChangeEvent e) { |
|
227 |
int value = new Integer(getJSpinner().getValue().toString()).intValue(); |
|
228 |
if (value != getSlider().getValue()) |
|
229 |
getSlider().setValue(value); |
|
230 |
if (new Integer(getJSpinner().getValue().toString()).intValue() != getSlider().getValue()) |
|
231 |
getJSpinner().setValue(new Integer(getSlider().getValue())); |
|
232 |
|
|
233 |
if (spinnerEvent) |
|
234 |
callChangeValue(); |
|
235 |
} |
|
236 |
|
|
237 |
/** |
|
238 |
* Dispara el evento del cambio del control |
|
239 |
*/ |
|
240 |
protected void callChangeValue() { |
Also available in: Unified diff