root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / FMultiPoint2D.java @ 2976
History | View | Annotate | Download (6.23 KB)
1 | 1100 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 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 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | 262 | fjp | package com.iver.cit.gvsig.fmap.core; |
42 | |||
43 | import com.iver.cit.gvsig.fmap.ViewPort; |
||
44 | 2193 | vcaballero | import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities; |
45 | 757 | fjp | import com.iver.cit.gvsig.fmap.core.v02.FLabel; |
46 | 458 | fjp | import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
47 | 324 | fernando | import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D; |
48 | 1005 | vcaballero | |
49 | 703 | fjp | import com.vividsolutions.jts.geom.Geometry; |
50 | 262 | fjp | |
51 | 1005 | vcaballero | import org.cresques.cts.ICoordTrans; |
52 | 262 | fjp | |
53 | 1005 | vcaballero | import java.awt.Color; |
54 | import java.awt.Graphics2D; |
||
55 | import java.awt.geom.Rectangle2D; |
||
56 | 2183 | fernando | import java.io.IOException; |
57 | 1005 | vcaballero | |
58 | |||
59 | 262 | fjp | /**
|
60 | * Multipunto 2D.
|
||
61 | *
|
||
62 | * @author Vicente Caballero Navarro
|
||
63 | */
|
||
64 | 305 | fjp | public class FMultiPoint2D implements IGeometry { |
65 | 1005 | vcaballero | double[] x = null; |
66 | double[] y = null; |
||
67 | 262 | fjp | |
68 | 1005 | vcaballero | /**
|
69 | * Crea un nuevo MultiPoint2D.
|
||
70 | *
|
||
71 | * @param x DOCUMENT ME!
|
||
72 | * @param y DOCUMENT ME!
|
||
73 | */
|
||
74 | public FMultiPoint2D(double[] x, double[] y) { |
||
75 | this.x = x;
|
||
76 | this.y = y;
|
||
77 | } |
||
78 | 1132 | vcaballero | public FMultiPoint2D(FPoint2D[] points) { |
79 | double[] auxX=new double[points.length]; |
||
80 | double[] auxY=new double[points.length]; |
||
81 | for (int i=0;i<points.length;i++){ |
||
82 | auxX[i]=points[i].getX(); |
||
83 | auxY[i]=points[i].getY(); |
||
84 | } |
||
85 | } |
||
86 | 1005 | vcaballero | /**
|
87 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#draw(java.awt.Graphics2D,
|
||
88 | * ViewPort, FStyle2D)
|
||
89 | */
|
||
90 | public void draw(Graphics2D g, ViewPort vp, FStyle2D symbol) { |
||
91 | int size = 2; |
||
92 | int hw = 4; |
||
93 | 262 | fjp | |
94 | 1005 | vcaballero | for (int i = 0; i < x.length; i++) { |
95 | java.awt.geom.Point2D.Double p = new java.awt.geom.Point2D.Double(x[i],
|
||
96 | y[i]); |
||
97 | vp.getAffineTransform().transform(p, p); |
||
98 | g.setColor(Color.red);
|
||
99 | g.fillOval((int) p.x - size, (int) p.y - size, (int) hw, (int) hw); |
||
100 | g.setColor(Color.black);
|
||
101 | g.drawOval((int) p.x - size, (int) p.y - size, (int) hw, (int) hw); |
||
102 | } |
||
103 | } |
||
104 | 262 | fjp | |
105 | 1005 | vcaballero | /**
|
106 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#toJTSGeometry()
|
||
107 | */
|
||
108 | public Geometry toJTSGeometry() {
|
||
109 | return null; |
||
110 | } |
||
111 | 267 | fjp | |
112 | 1005 | vcaballero | /**
|
113 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#createLabels(int, boolean)
|
||
114 | */
|
||
115 | public FLabel[] createLabels(int position, boolean duplicates) { |
||
116 | return null; |
||
117 | } |
||
118 | |||
119 | 267 | fjp | /* (non-Javadoc)
|
120 | 305 | fjp | * @see com.iver.cit.gvsig.fmap.core.IGeometry#intersects(java.awt.geom.Rectangle2D)
|
121 | 267 | fjp | */
|
122 | public boolean intersects(Rectangle2D r) { |
||
123 | 2193 | vcaballero | for (int i=0;i<getNumPoints();i++){ |
124 | if (r.contains(x[i],y[i]))return true; |
||
125 | } |
||
126 | 267 | fjp | return false; |
127 | } |
||
128 | |||
129 | /* (non-Javadoc)
|
||
130 | 305 | fjp | * @see com.iver.cit.gvsig.fmap.core.IGeometry#getBounds2D()
|
131 | 267 | fjp | */
|
132 | public Rectangle2D getBounds2D() { |
||
133 | 2193 | vcaballero | Rectangle2D r=null; |
134 | if (getNumPoints()>0){ |
||
135 | r=new Rectangle2D.Double(x[0],y[0],0.001,0.001); |
||
136 | } |
||
137 | for (int i=1;i<getNumPoints();i++){ |
||
138 | r.add(x[i],y[i]); |
||
139 | } |
||
140 | return r;
|
||
141 | 267 | fjp | } |
142 | 324 | fernando | |
143 | /**
|
||
144 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeometryType()
|
||
145 | */
|
||
146 | public int getGeometryType() { |
||
147 | 2193 | vcaballero | return FShape.MULTIPOINT;
|
148 | 324 | fernando | } |
149 | 458 | fjp | |
150 | /* (non-Javadoc)
|
||
151 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#draw(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.core.v02.FSymbol)
|
||
152 | */
|
||
153 | public void draw(Graphics2D g, ViewPort vp, FSymbol symbol) { |
||
154 | 1005 | vcaballero | int size = 2; |
155 | int hw = 4; |
||
156 | |||
157 | for (int i = 0; i < x.length; i++) { |
||
158 | java.awt.geom.Point2D.Double p = new java.awt.geom.Point2D.Double(x[i],
|
||
159 | y[i]); |
||
160 | vp.getAffineTransform().transform(p, p); |
||
161 | 2193 | vcaballero | FGraphicUtilities.DrawShape(g, vp.getAffineTransform(), new FPoint2D(p.getX(),p.getY()), symbol);
|
162 | |||
163 | /* java.awt.geom.Point2D.Double p = new java.awt.geom.Point2D.Double(x[i],
|
||
164 | y[i]);
|
||
165 | vp.getAffineTransform().transform(p, p);
|
||
166 | 1005 | vcaballero | g.setColor(Color.red);
|
167 | g.fillOval((int) p.x - size, (int) p.y - size, (int) hw, (int) hw);
|
||
168 | g.setColor(Color.black);
|
||
169 | g.drawOval((int) p.x - size, (int) p.y - size, (int) hw, (int) hw);
|
||
170 | 2193 | vcaballero | */
|
171 | 1005 | vcaballero | } |
172 | 458 | fjp | } |
173 | 703 | fjp | |
174 | /* (non-Javadoc)
|
||
175 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#cloneGeometry()
|
||
176 | */
|
||
177 | public IGeometry cloneGeometry() {
|
||
178 | 2193 | vcaballero | return new FMultiPoint2D((double[])x.clone(),(double[])y.clone()); |
179 | 703 | fjp | } |
180 | 885 | fjp | |
181 | /* (non-Javadoc)
|
||
182 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#reProject(org.cresques.cts.ICoordTrans)
|
||
183 | */
|
||
184 | public void reProject(ICoordTrans ct) { |
||
185 | // TODO Auto-generated method stub
|
||
186 | } |
||
187 | 1132 | vcaballero | public int getNumPoints(){ |
188 | return x.length;
|
||
189 | } |
||
190 | public FPoint2D getPoint(int i){ |
||
191 | return new FPoint2D(x[i],y[i]); |
||
192 | } |
||
193 | /**
|
||
194 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeneralPathXIterator()
|
||
195 | */
|
||
196 | public GeneralPathXIterator getGeneralPathXIterator() {
|
||
197 | 2193 | vcaballero | GeneralPathX gpx=new GeneralPathX();
|
198 | if (getNumPoints()>0){ |
||
199 | gpx.moveTo(x[0],y[0]); |
||
200 | } |
||
201 | for (int i=1;i<getNumPoints();i++){ |
||
202 | gpx.lineTo(x[i],y[i]); |
||
203 | } |
||
204 | return (GeneralPathXIterator)gpx.getPathIterator(null); |
||
205 | 1132 | vcaballero | } |
206 | 1298 | fjp | /* (non-Javadoc)
|
207 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#fastIntersects(double, double, double, double)
|
||
208 | */
|
||
209 | public boolean fastIntersects(double x, double y, double w, double h) { |
||
210 | // TODO Auto-generated method stub
|
||
211 | return false; |
||
212 | } |
||
213 | 2183 | fernando | /**
|
214 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#toWKB()
|
||
215 | */
|
||
216 | public byte[] toWKB() throws IOException { |
||
217 | // TODO Auto-generated method stub
|
||
218 | return null; |
||
219 | } |
||
220 | 2859 | fjp | /* (non-Javadoc)
|
221 | * @see com.iver.cit.gvsig.fmap.core.IGeometry#drawInts(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.core.v02.FSymbol)
|
||
222 | */
|
||
223 | public void drawInts(Graphics2D g, ViewPort vp, FSymbol symbol) { |
||
224 | draw(g,vp, symbol); |
||
225 | |||
226 | } |
||
227 | 262 | fjp | } |