Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libUIComponent / src-test-ui / org / gvsig / gui / beans / imagenavigator / TestImageNavigator.java @ 21577

History | View | Annotate | Download (3.06 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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.gui.beans.imagenavigator;
20

    
21
import java.awt.Color;
22
import java.awt.Dimension;
23
import java.awt.Graphics2D;
24

    
25
import org.gvsig.gui.beans.TestUI;
26
/**
27
 * Test del ImageNavigator
28
 *
29
 * @version 08/05/2007
30
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
31
 */
32
public class TestImageNavigator implements IClientImageNavigator {
33
        private TestUI jFrame = null;
34
        private ImageNavigator imageNavigator = null;
35

    
36
        public TestImageNavigator() {
37
                initialize();
38
        }
39

    
40
        private void initialize() {
41
                jFrame = new TestUI("TestImageNavigator");
42
                jFrame.setSize(new Dimension(200, 200));
43
                jFrame.setContentPane(getImageNavigator());
44
                getImageNavigator().setViewDimensions(0.0, 0.0, 200.0, 100.0);
45
                getImageNavigator().updateBuffer();
46
                getImageNavigator().setEnabled(true);
47
                jFrame.setVisible(true);
48
        }
49

    
50
        private ImageNavigator getImageNavigator() {
51
                if (imageNavigator == null) {
52
                        imageNavigator = new ImageNavigator(this);
53
                }
54
                return imageNavigator;
55
        }
56

    
57
        /**
58
         * @param args
59
         */
60
        public static void main(String[] args) {
61
                new TestImageNavigator();
62
        }
63

    
64
        /*
65
         * (non-Javadoc)
66
         * @see org.gvsig.gui.beans.imagenavigator.IClientImageNavigator#drawImage(java.awt.Graphics2D, double, double, double, double, double, int, int)
67
         */
68
        public void drawImage(Graphics2D g, double x1, double y1, double x2, double y2, double zoom, int width, int height) throws ImageUnavailableException {
69
                if (true) {
70
                        throw new ImageUnavailableException("No es posible la visualizaci?n de la capa.");
71
                }
72
                double usex1 = (((0 - x1) * width) / (width/zoom));
73
                double usey1 = (((0 - y1) * height) / (height/zoom));
74
                double usex2 = (usex1 + (200.0 * zoom));
75
                double usey2 = (usey1 + (100.0 * zoom));
76

    
77
                g.setColor(Color.black);
78
                g.fillRect((int) usex1, (int) usey1, (int) (usex2 - usex1), (int) (usey2 - usey1));
79
                g.setColor(Color.RED);
80
                g.drawLine((int) usex1, (int) usey1, (int) usex2, (int) usey2);
81
                g.drawLine((int) usex1, (int) usey2, (int) usex2, (int) usey1);
82
                g.drawRect((int) usex1, (int) usey1, (int) (usex2 - usex1), (int) (usey2 - usey1));
83

    
84
                g.drawString("X1:" + (int) x1, 1, 20);
85
                g.drawString("Y1:" + (int) y1, 1, 40);
86
                g.drawString("X2:" + (int) x2, 1, 60);
87
                g.drawString("Y2:" + (int) y2, 1, 80);
88
                g.drawString(width + ":" + height, 1, 120);
89
        }
90
}