Statistics
| Revision:

root / trunk / libraries / libUIComponent / src-test-ui / org / gvsig / gui / beans / imagenavigator / TestImageNavigator.java @ 12898

History | View | Annotate | Download (2.92 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 javax.swing.JFrame;
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 JFrame jFrame = null;
34
        private ImageNavigator imageNavigator = null;
35

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

    
40
        private void initialize() {
41
                jFrame = new JFrame();
42
                jFrame.setSize(new Dimension(598, 167));
43
                jFrame.setContentPane(getImageNavigator());
44
                getImageNavigator().setViewDimensions(0.0, 0.0, 200.0, 100.0);
45
                getImageNavigator().updateBuffer();
46
                jFrame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
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, int, int)
67
         */
68
        public void drawImage(Graphics2D g, double x1, double y1, double x2, double y2, double zoom, int width, int height) {
69
                double usex1 = (((0 - x1) * width) / (width/zoom));
70
                double usey1 = (((0 - y1) * height) / (height/zoom));
71
                double usex2 = (usex1 + (200.0 * zoom));
72
                double usey2 = (usey1 + (100.0 * zoom));
73

    
74
                g.setColor(Color.black);
75
                g.fillRect((int) usex1, (int) usey1, (int) (usex2 - usex1), (int) (usey2 - usey1));
76
                g.setColor(Color.RED);
77
                g.drawLine((int) usex1, (int) usey1, (int) usex2, (int) usey2);
78
                g.drawLine((int) usex1, (int) usey2, (int) usex2, (int) usey1);
79
                g.drawRect((int) usex1, (int) usey1, (int) (usex2 - usex1), (int) (usey2 - usey1));
80

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