Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / test / java / org / gvsig / gui / beans / imagenavigator / TestImageNavigatorInverted.java @ 40561

History | View | Annotate | Download (3.06 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 para coordenadas totalmente invertidas.
33
 *
34
 * @version 08/05/2007
35
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
36
 */
37
public class TestImageNavigatorInverted implements IClientImageNavigator {
38
        private TestUI         jFrame         = null;
39
        private ImageNavigator imageNavigator = null;
40

    
41
        public TestImageNavigatorInverted() {
42
                initialize();
43
        }
44

    
45
        private void initialize() {
46
                jFrame = new TestUI("TestImageNavigatorInverted");
47
                jFrame.setSize(new Dimension(598, 167));
48
                jFrame.setContentPane(getImageNavigator());
49
                getImageNavigator().setViewDimensions(200.0, 100.0, 0.0, 0.0);
50
                getImageNavigator().updateBuffer();
51
                jFrame.setVisible(true);
52
        }
53

    
54
        private ImageNavigator getImageNavigator() {
55
                if (imageNavigator == null) {
56
                        imageNavigator = new ImageNavigator(this);
57
                }
58
                return imageNavigator;
59
        }
60

    
61
        /**
62
         * @param args
63
         */
64
        public static void main(String[] args) {
65
                new TestImageNavigatorInverted();
66
        }
67

    
68
        /*
69
         * (non-Javadoc)
70
         * @see org.gvsig.gui.beans.imagenavigator.IClientImageNavigator#drawImage(java.awt.Graphics2D, double, double, double, int, int)
71
         */
72
        public void drawImage(Graphics2D g, double x1, double y1, double x2, double y2, double zoom, int width, int height) {
73
                double usex1 = (((0 + x1) * width) / (width/zoom));
74
                double usey1 = (((0 + y1) * height) / (height/zoom));
75
                double usex2 = (usex1 - (200.0 * zoom));
76
                double usey2 = (usey1 - (100.0 * zoom));
77

    
78
                g.setColor(Color.GREEN);
79
                g.fillRect((int) usex2, (int) usey2, (int) (usex1 - usex2), (int) (usey1 - usey2));
80
                g.setColor(Color.BLACK);
81
                g.drawLine((int) usex2, (int) usey1, (int) usex1, (int) usey2);
82
                g.drawLine((int) usex2, (int) usey2, (int) usex1, (int) usey1);
83
                g.drawRect((int) usex2, (int) usey2, (int) (usex1 - usex2), (int) (usey1 - usey2));
84

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