root / trunk / libraries / libCq CMS for java.old / src / org / cresques / px / gml / LineString.java @ 95
History | View | Annotate | Download (2.09 KB)
1 |
package org.cresques.px.gml; |
---|---|
2 |
/*
|
3 |
* Created on 21-abr-2004
|
4 |
*/
|
5 |
|
6 |
import java.awt.Color; |
7 |
import java.awt.geom.Point2D; |
8 |
|
9 |
import java.awt.Graphics2D; |
10 |
import java.awt.geom.AffineTransform; |
11 |
|
12 |
import java.util.Iterator; |
13 |
import java.util.Vector; |
14 |
|
15 |
import java.awt.geom.Line2D; |
16 |
|
17 |
import org.cresques.cts.ICoordTrans; |
18 |
import org.cresques.cts.IProjection; |
19 |
import org.cresques.geo.ViewPortData; |
20 |
import org.cresques.px.Extent; |
21 |
|
22 |
/**
|
23 |
* Geometria de tipo Polygon
|
24 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
25 |
*/
|
26 |
|
27 |
public class LineString extends Geometry { |
28 |
public static int pointNr = 0; |
29 |
|
30 |
public LineString() {
|
31 |
super();
|
32 |
} |
33 |
|
34 |
public void add(Point2D pt) { |
35 |
pointNr++; |
36 |
super.add(pt);
|
37 |
} |
38 |
public void remove(int i) { |
39 |
getData().remove(i); |
40 |
} |
41 |
|
42 |
private Color fColor = null; //new Color(255,222,165,64); |
43 |
private Color color = new Color(255,0,0); //Color(255,214,132,255); |
44 |
|
45 |
public Color c() {return color;} |
46 |
public Color c(Color color) {this.color = color; return color;} |
47 |
|
48 |
public Color fillColor() {return fColor;} |
49 |
public Color fillColor(Color c) {fColor = c; return fColor;} |
50 |
|
51 |
public IProjection getProjection() { return proj; } |
52 |
public void setProjection(IProjection p) { proj = p; } |
53 |
public void reProject(ICoordTrans rp) { |
54 |
Vector saveLine = data;
|
55 |
|
56 |
data = new Vector(); |
57 |
extent = new Extent();
|
58 |
Point2D ptDest = null; |
59 |
for (int i=0; i<saveLine.size(); i++) { |
60 |
ptDest = rp.getPDest().createPoint(0.0,0.0); |
61 |
ptDest = rp.convert((Point2D) saveLine.get(i), ptDest);
|
62 |
data.add(ptDest); |
63 |
extent.add(ptDest); |
64 |
} |
65 |
setProjection(rp.getPDest()); |
66 |
} |
67 |
|
68 |
public void draw(Graphics2D g, ViewPortData vp) { |
69 |
AffineTransform msave=g.getTransform();
|
70 |
g.setTransform(vp.mat); |
71 |
// relleno el marco si es preciso
|
72 |
if (fillColor() != null) { |
73 |
g.setColor(fillColor()); |
74 |
// outPol.fill(g);
|
75 |
} |
76 |
// pinto el marco si es preciso
|
77 |
g.setColor(c()); |
78 |
drawLine2D(g, data); |
79 |
g.setTransform(msave); |
80 |
} |
81 |
|
82 |
void drawLine2D(Graphics2D g, Vector v) { |
83 |
Point2D pt=null, pt1=null; |
84 |
Iterator iter = v.iterator();
|
85 |
while (iter.hasNext()) {
|
86 |
pt1 = (Point2D) iter.next();
|
87 |
if (pt != null) |
88 |
g.draw(new Line2D.Double(pt,pt1)); |
89 |
pt = pt1; |
90 |
} |
91 |
} |
92 |
} |
93 |
|
94 |
|