root / trunk / extensions / extRasterTools-SE / src-test-ui / org / gvsig / rastertools / georeferencing / TestViewDialog.java @ 18251
History | View | Annotate | Download (3.67 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 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.rastertools.georeferencing; |
20 |
|
21 |
import javax.swing.JFrame; |
22 |
import javax.swing.UIManager; |
23 |
|
24 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
25 |
import org.gvsig.rastertools.georeferencing.ui.zoom.InvalidRequestException; |
26 |
import org.gvsig.rastertools.georeferencing.ui.zoom.ViewRasterRequestManager; |
27 |
import org.gvsig.rastertools.georeferencing.ui.zoom.tools.ToolEvent; |
28 |
import org.gvsig.rastertools.georeferencing.ui.zoom.tools.ToolListener; |
29 |
import org.gvsig.rastertools.georeferencing.view.ViewDialog; |
30 |
|
31 |
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException; |
32 |
import com.iver.utiles.swing.threads.Cancellable; |
33 |
/**
|
34 |
* Test para la vista de georreferenciaci?n con peticiones a la capa.
|
35 |
*
|
36 |
* @version 30/07/2007
|
37 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
38 |
*/
|
39 |
public class TestViewDialog implements ToolListener { |
40 |
private JFrame frame = new JFrame(); |
41 |
private String path = "/home/nacho/images/500k_2.ecw"; |
42 |
//private String path = "/home/nacho/images/orto5mv30f290126cor03.sid";
|
43 |
//private String path = "/home/nacho/images/wcs16bits.tif";
|
44 |
//private String path = "/home/nacho/images/03AUG23153350-M2AS-000000122423_01_P001-BROWSE.jpg";
|
45 |
private int w = 500, h = 500; |
46 |
|
47 |
public TestViewDialog() {
|
48 |
super();
|
49 |
initialize(); |
50 |
} |
51 |
|
52 |
public static void main(String[] args) { |
53 |
try {
|
54 |
UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel"); |
55 |
} catch( Exception e ) { |
56 |
System.err.println( "No se puede cambiar al LookAndFeel"); |
57 |
} |
58 |
new TestViewDialog();
|
59 |
} |
60 |
|
61 |
private void initialize() { |
62 |
FLyrRasterSE layer = null;
|
63 |
try {
|
64 |
layer = FLyrRasterSE.createLayer("mylyr", path, null); |
65 |
} catch (LoadLayerException e) {
|
66 |
e.printStackTrace(); |
67 |
} |
68 |
|
69 |
//Creamos el componente
|
70 |
ViewDialog view = new ViewDialog(0, 0, w, h, this); |
71 |
view.setShowInfo(true);
|
72 |
//Gestor de peticiones a la capa (IExtensionRequest)
|
73 |
ViewRasterRequestManager viewRequestManager = new ViewRasterRequestManager(view, layer);
|
74 |
//Asignamos al componente cual ser? su gestor de peticiones. Cada vez que se pulse un zoom el componente har?
|
75 |
//una llamada request a su gestor de peticiones
|
76 |
view.setExtensionRequest(viewRequestManager); |
77 |
view.setZoomCursorSize(w / 2, h / 2); |
78 |
|
79 |
frame.setContentPane(view); |
80 |
|
81 |
frame.setSize(new java.awt.Dimension(w, h));
|
82 |
frame.setResizable(true);
|
83 |
frame.setTitle("zoom");
|
84 |
frame.setVisible(true);
|
85 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
86 |
|
87 |
try {
|
88 |
viewRequestManager.initRequest(layer.getFullExtent()); |
89 |
} catch (InvalidRequestException e1) {
|
90 |
System.out.println("Error asignando la vista"); |
91 |
} |
92 |
} |
93 |
|
94 |
class CancellableClass implements Cancellable{ |
95 |
private boolean cancel = false; |
96 |
public void setCanceled(boolean canceled) { |
97 |
this.cancel = canceled;
|
98 |
} |
99 |
|
100 |
public boolean isCanceled() { |
101 |
return this.cancel; |
102 |
} |
103 |
} |
104 |
|
105 |
public void endAction(ToolEvent ev) { |
106 |
} |
107 |
|
108 |
} |