Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / FPoint2D.java @ 1005

History | View | Annotate | Download (3.28 KB)

1
/* Generated by Together */
2
package com.iver.cit.gvsig.fmap.core;
3

    
4
import org.cresques.cts.ICoordTrans;
5

    
6
import java.awt.Rectangle;
7
import java.awt.geom.AffineTransform;
8
import java.awt.geom.PathIterator;
9
import java.awt.geom.Point2D;
10
import java.awt.geom.Rectangle2D;
11

    
12

    
13
/**
14
 * Punto 2D.
15
 *
16
 * @author Vicente Caballero Navarro
17
 */
18
public class FPoint2D implements FShape {
19
        protected Point2D p;
20

    
21
        /**
22
         * Crea un nuevo Point2D.
23
         *
24
         * @param x Coordenada x del punto.
25
         * @param y Coordenada y del punto.
26
         */
27
        public FPoint2D(double x, double y) {
28
                p = new Point2D.Double(x, y);
29
        }
30

    
31
        /**
32
         * Aplica la transformaci?n de la matriz de transformaci?n que se pasa como
33
         * par?metro.
34
         *
35
         * @param at Matriz de transformaci?n.
36
         */
37
        public void transform(AffineTransform at) {
38
                at.transform(p, p);
39
        }
40

    
41
        /* (non-Javadoc)
42
         * @see java.awt.Shape#contains(double, double)
43
         */
44
        public boolean contains(double x, double y) {
45
                if ((x == p.getX()) || (y == p.getY())) {
46
                        return true;
47
                } else {
48
                        return false;
49
                }
50
        }
51

    
52
        /* (non-Javadoc)
53
         * @see java.awt.Shape#contains(double, double, double, double)
54
         */
55
        public boolean contains(double x, double y, double w, double h) {
56
                return false;
57
        }
58

    
59
        /* (non-Javadoc)
60
         * @see java.awt.Shape#intersects(double, double, double, double)
61
         */
62
        public boolean intersects(double x, double y, double w, double h) {
63
                Rectangle2D.Double rAux = new Rectangle2D.Double(x, y, w, h);
64

    
65
                return rAux.contains(p.getX(), p.getY());
66
        }
67

    
68
        /* (non-Javadoc)
69
         * @see java.awt.Shape#getBounds()
70
         */
71
        public Rectangle getBounds() {
72
                return new Rectangle((int) p.getX(), (int) p.getY(), 0, 0);
73
        }
74

    
75
        /**
76
         * Devuelve la coordenada x del punto.
77
         *
78
         * @return Coordenada x.
79
         */
80
        public double getX() {
81
                return p.getX();
82
        }
83

    
84
        /**
85
         * Devuelve la coordenada y del punto.
86
         *
87
         * @return Coordenada y.
88
         */
89
        public double getY() {
90
                return p.getY();
91
        }
92

    
93
        /* (non-Javadoc)
94
         * @see java.awt.Shape#contains(java.awt.geom.Point2D)
95
         */
96
        public boolean contains(Point2D p) {
97
                return false;
98
        }
99

    
100
        /* (non-Javadoc)
101
         * @see java.awt.Shape#getBounds2D()
102
         */
103
        public Rectangle2D getBounds2D() {
104
                return new Rectangle2D.Double(p.getX(), p.getY(), 0, 0);
105
        }
106

    
107
        /* (non-Javadoc)
108
         * @see java.awt.Shape#contains(java.awt.geom.Rectangle2D)
109
         */
110
        public boolean contains(Rectangle2D r) {
111
                return false;
112
        }
113

    
114
        /* (non-Javadoc)
115
         * @see java.awt.Shape#intersects(java.awt.geom.Rectangle2D)
116
         */
117
        public boolean intersects(Rectangle2D r) {
118
                return r.contains(this.p);
119
        }
120

    
121
        /* (non-Javadoc)
122
         * @see java.awt.Shape#getPathIterator(java.awt.geom.AffineTransform)
123
         */
124
        public PathIterator getPathIterator(AffineTransform at) {
125
                return new FPointIterator(p, at);
126
        }
127

    
128
        /* (non-Javadoc)
129
         * @see java.awt.Shape#getPathIterator(java.awt.geom.AffineTransform, double)
130
         */
131
        public PathIterator getPathIterator(AffineTransform at, double flatness) {
132
                return new FPointIterator(p, at);
133
        }
134

    
135
        /**
136
         * @see com.iver.cit.gvsig.fmap.core.FShape#getShapeType()
137
         */
138
        public int getShapeType() {
139
                return FShape.POINT;
140
        }
141

    
142
        /* (non-Javadoc)
143
         * @see com.iver.cit.gvsig.fmap.core.FShape#cloneFShape()
144
         */
145
        public FShape cloneFShape() {
146
                return new FPoint2D(p.getX(), p.getY());
147
        }
148

    
149
        /* (non-Javadoc)
150
         * @see com.iver.cit.gvsig.fmap.core.FShape#reProject(org.cresques.cts.ICoordTrans)
151
         */
152
        public void reProject(ICoordTrans ct) {
153
                p = ct.convert(p, p);
154
        }
155
}