root / trunk / extensions / extRasterTools-SE / src-test-ui / org / gvsig / rastertools / georeferencing / TestPixelZoomControlDialog.java @ 17838
History | View | Annotate | Download (3.57 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 java.awt.Dimension; |
22 |
import java.awt.Graphics2D; |
23 |
import java.awt.geom.Point2D; |
24 |
import java.awt.geom.Rectangle2D; |
25 |
import java.awt.image.BufferedImage; |
26 |
|
27 |
import javax.swing.JFrame; |
28 |
import javax.swing.UIManager; |
29 |
|
30 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
31 |
import org.gvsig.rastertools.georeferencing.ui.zoom.CenterPointGraphicLayer; |
32 |
import org.gvsig.rastertools.georeferencing.ui.zoom.GPGraphic; |
33 |
import org.gvsig.rastertools.georeferencing.ui.zoom.ZoomControl; |
34 |
|
35 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
36 |
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException; |
37 |
import com.iver.cit.gvsig.fmap.ViewPort; |
38 |
import com.iver.utiles.swing.threads.Cancellable; |
39 |
/**
|
40 |
* Test para el panel de geolocalizaci?n
|
41 |
*
|
42 |
* @version 30/07/2007
|
43 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
44 |
*/
|
45 |
public class TestPixelZoomControlDialog { |
46 |
private JFrame frame = new JFrame(); |
47 |
private String path = "/home/nacho/images/03AUG23153350-M2AS-000000122423_01_P001-BROWSE-1.jpg"; |
48 |
|
49 |
public TestPixelZoomControlDialog() {
|
50 |
super();
|
51 |
initialize(); |
52 |
} |
53 |
|
54 |
public static void main(String[] args) { |
55 |
try {
|
56 |
UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel"); |
57 |
} catch( Exception e ) { |
58 |
System.err.println( "No se puede cambiar al LookAndFeel"); |
59 |
} |
60 |
new TestPixelZoomControlDialog();
|
61 |
} |
62 |
|
63 |
private void initialize() { |
64 |
ZoomControl glp = new ZoomControl(ZoomControl.RIGHT_CONTROL);
|
65 |
|
66 |
CenterPointGraphicLayer cp = new CenterPointGraphicLayer(GPGraphic.PIXEL, glp);
|
67 |
cp.setShowNumber(true);
|
68 |
cp.setNumber(3);
|
69 |
|
70 |
glp.setGraphicLayer(cp); |
71 |
|
72 |
try {
|
73 |
FLyrRasterSE lyr = FLyrRasterSE.createLayer("mylyr", path, null); |
74 |
BufferedImage img = new BufferedImage((int)lyr.getPxWidth(), (int)lyr.getPxHeight(), BufferedImage.TYPE_INT_RGB); |
75 |
Rectangle2D r = lyr.getFullExtent();
|
76 |
//Rectangle2D r = new Rectangle2D.Double(0, 0, 870, 870);
|
77 |
|
78 |
ViewPort vp = new ViewPort(null); |
79 |
vp.setExtent(r); |
80 |
vp.setImageSize(new Dimension(870, 870)); |
81 |
|
82 |
try {
|
83 |
lyr.draw(img, (Graphics2D)img.getGraphics(), vp, new CancellableClass(), -1); |
84 |
} catch (ReadDriverException e) {
|
85 |
e.printStackTrace(); |
86 |
} |
87 |
|
88 |
glp.setDrawParams(img, r, 1, new Point2D.Double(435, 435)); |
89 |
|
90 |
} catch (LoadLayerException e) {
|
91 |
e.printStackTrace(); |
92 |
} |
93 |
frame.setContentPane(glp); |
94 |
|
95 |
frame.setSize(new java.awt.Dimension(220, 230)); |
96 |
frame.setResizable(true);
|
97 |
frame.setTitle("zoom");
|
98 |
frame.setVisible(true);
|
99 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
100 |
} |
101 |
|
102 |
class CancellableClass implements Cancellable{ |
103 |
private boolean cancel = false; |
104 |
public void setCanceled(boolean canceled) { |
105 |
this.cancel = canceled;
|
106 |
} |
107 |
|
108 |
public boolean isCanceled() { |
109 |
return this.cancel; |
110 |
} |
111 |
} |
112 |
} |