svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / test / java / org / gvsig / gui / beans / imagenavigator / TestImageNavigator.java @ 40561
History | View | Annotate | Download (3.16 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.gui.beans.imagenavigator; |
25 |
|
26 |
import java.awt.Color; |
27 |
import java.awt.Dimension; |
28 |
import java.awt.Graphics2D; |
29 |
|
30 |
import org.gvsig.gui.beans.TestUI; |
31 |
/**
|
32 |
* Test del ImageNavigator
|
33 |
*
|
34 |
* @version 08/05/2007
|
35 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
36 |
*/
|
37 |
public class TestImageNavigator implements IClientImageNavigator { |
38 |
private TestUI jFrame = null; |
39 |
private ImageNavigator imageNavigator = null; |
40 |
|
41 |
public TestImageNavigator() {
|
42 |
initialize(); |
43 |
} |
44 |
|
45 |
private void initialize() { |
46 |
jFrame = new TestUI("TestImageNavigator"); |
47 |
jFrame.setSize(new Dimension(200, 200)); |
48 |
jFrame.setContentPane(getImageNavigator()); |
49 |
getImageNavigator().setViewDimensions(0.0, 0.0, 200.0, 100.0); |
50 |
getImageNavigator().updateBuffer(); |
51 |
getImageNavigator().setEnabled(true);
|
52 |
jFrame.setVisible(true);
|
53 |
} |
54 |
|
55 |
private ImageNavigator getImageNavigator() {
|
56 |
if (imageNavigator == null) { |
57 |
imageNavigator = new ImageNavigator(this); |
58 |
} |
59 |
return imageNavigator;
|
60 |
} |
61 |
|
62 |
/**
|
63 |
* @param args
|
64 |
*/
|
65 |
public static void main(String[] args) { |
66 |
new TestImageNavigator();
|
67 |
} |
68 |
|
69 |
/*
|
70 |
* (non-Javadoc)
|
71 |
* @see org.gvsig.gui.beans.imagenavigator.IClientImageNavigator#drawImage(java.awt.Graphics2D, double, double, double, double, double, int, int)
|
72 |
*/
|
73 |
public void drawImage(Graphics2D g, double x1, double y1, double x2, double y2, double zoom, int width, int height) throws ImageUnavailableException { |
74 |
if (true) { |
75 |
throw new ImageUnavailableException("No es posible la visualizaci?n de la capa."); |
76 |
} |
77 |
double usex1 = (((0 - x1) * width) / (width/zoom)); |
78 |
double usey1 = (((0 - y1) * height) / (height/zoom)); |
79 |
double usex2 = (usex1 + (200.0 * zoom)); |
80 |
double usey2 = (usey1 + (100.0 * zoom)); |
81 |
|
82 |
g.setColor(Color.black);
|
83 |
g.fillRect((int) usex1, (int) usey1, (int) (usex2 - usex1), (int) (usey2 - usey1)); |
84 |
g.setColor(Color.RED);
|
85 |
g.drawLine((int) usex1, (int) usey1, (int) usex2, (int) usey2); |
86 |
g.drawLine((int) usex1, (int) usey2, (int) usex2, (int) usey1); |
87 |
g.drawRect((int) usex1, (int) usey1, (int) (usex2 - usex1), (int) (usey2 - usey1)); |
88 |
|
89 |
g.drawString("X1:" + (int) x1, 1, 20); |
90 |
g.drawString("Y1:" + (int) y1, 1, 40); |
91 |
g.drawString("X2:" + (int) x2, 1, 60); |
92 |
g.drawString("Y2:" + (int) y2, 1, 80); |
93 |
g.drawString(width + ":" + height, 1, 120); |
94 |
} |
95 |
} |