Statistics
| Revision:

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

History | View | Annotate | Download (3 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
import javax.swing.UIManager;
27

    
28
public class TestImageNavigatorInverted implements IClientImageNavigator {
29
        private JFrame jFrame = null;
30
        private ImageNavigator imageNavigator = null;
31

    
32
        public TestImageNavigatorInverted() {
33
                initialize();
34
        }
35
        
36
        private void initialize() {
37
                jFrame = new JFrame();
38
                jFrame.setSize(new Dimension(598, 167));
39
                jFrame.setContentPane(getImageNavigator());
40
                jFrame.show();
41
                getImageNavigator().setViewDimensions(200.0, 100.0, 0.0, 0.0);
42
                jFrame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
43
        }
44
        
45
        private ImageNavigator getImageNavigator() {
46
                if (imageNavigator == null) {
47
                        imageNavigator = new ImageNavigator(this, 0.0, 0.0, 1.0);
48
                }
49
                return imageNavigator;
50
        }
51
        
52
        /**
53
         * @param args
54
         */
55
        public static void main(String[] args) {
56
                try {
57
                        UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
58
                } catch (Exception e) {
59
                        System.err.println("No se puede cambiar al LookAndFeel");
60
                }
61
                new TestImageNavigatorInverted();
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.GREEN);
75
                g.fillRect((int) usex2, (int) usey2, (int) (usex1 - usex2), (int) (usey1 - usey2));
76
                g.setColor(Color.BLACK);
77
                g.drawLine((int) usex2, (int) usey1, (int) usex1, (int) usey2);
78
                g.drawLine((int) usex2, (int) usey2, (int) usex1, (int) usey1);
79
                g.drawRect((int) usex2, (int) usey2, (int) (usex1 - usex2), (int) (usey1 - usey2));
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
}