root / branches / v2_0_0_prep / libraries / libDXF / src / org / gvsig / dxf / px / gml / LineString.java @ 29630
History | View | Annotate | Download (3.38 KB)
1 | 13047 | caballero | /*
|
---|---|---|---|
2 | * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
||
3 | *
|
||
4 | * Copyright (C) 2004-5.
|
||
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 2
|
||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
19 | *
|
||
20 | * For more information, contact:
|
||
21 | *
|
||
22 | * cresques@gmail.com
|
||
23 | */
|
||
24 | 29630 | jpiera | package org.gvsig.dxf.px.gml; |
25 | 13047 | caballero | |
26 | import java.awt.Color; |
||
27 | import java.awt.Graphics2D; |
||
28 | import java.awt.geom.AffineTransform; |
||
29 | import java.awt.geom.Line2D; |
||
30 | import java.awt.geom.Point2D; |
||
31 | import java.util.Iterator; |
||
32 | import java.util.Vector; |
||
33 | |||
34 | 13454 | jaume | import org.cresques.cts.ICoordTrans; |
35 | import org.cresques.cts.IProjection; |
||
36 | import org.cresques.geo.ViewPortData; |
||
37 | import org.cresques.px.Extent; |
||
38 | 13047 | caballero | |
39 | 13454 | jaume | |
40 | 13047 | caballero | /**
|
41 | * Geometria de tipo Polygon
|
||
42 | * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
||
43 | */
|
||
44 | public class LineString extends Geometry { |
||
45 | public static int pointNr = 0; |
||
46 | private Color fColor = null; //new Color(255,222,165,64); |
||
47 | private Color color = new Color(255, 0, 0); //Color(255,214,132,255); |
||
48 | |||
49 | public LineString() {
|
||
50 | super();
|
||
51 | } |
||
52 | |||
53 | public void add(Point2D pt) { |
||
54 | pointNr++; |
||
55 | super.add(pt);
|
||
56 | } |
||
57 | |||
58 | public void remove(int i) { |
||
59 | getData().remove(i); |
||
60 | } |
||
61 | |||
62 | public Color c() { |
||
63 | return color;
|
||
64 | } |
||
65 | |||
66 | public Color c(Color color) { |
||
67 | this.color = color;
|
||
68 | |||
69 | return color;
|
||
70 | } |
||
71 | |||
72 | public Color fillColor() { |
||
73 | return fColor;
|
||
74 | } |
||
75 | |||
76 | public Color fillColor(Color c) { |
||
77 | fColor = c; |
||
78 | |||
79 | return fColor;
|
||
80 | } |
||
81 | |||
82 | public IProjection getProjection() {
|
||
83 | return proj;
|
||
84 | } |
||
85 | |||
86 | public void setProjection(IProjection p) { |
||
87 | proj = p; |
||
88 | } |
||
89 | |||
90 | public void reProject(ICoordTrans rp) { |
||
91 | Vector saveLine = data;
|
||
92 | |||
93 | data = new Vector(); |
||
94 | extent = new Extent();
|
||
95 | |||
96 | Point2D ptDest = null; |
||
97 | |||
98 | for (int i = 0; i < saveLine.size(); i++) { |
||
99 | ptDest = rp.getPDest().createPoint(0.0, 0.0); |
||
100 | ptDest = rp.convert((Point2D) saveLine.get(i), ptDest);
|
||
101 | data.add(ptDest); |
||
102 | extent.add(ptDest); |
||
103 | } |
||
104 | |||
105 | setProjection(rp.getPDest()); |
||
106 | } |
||
107 | |||
108 | public void draw(Graphics2D g, ViewPortData vp) { |
||
109 | AffineTransform msave = g.getTransform();
|
||
110 | g.setTransform(vp.mat); |
||
111 | |||
112 | // relleno el marco si es preciso
|
||
113 | if (fillColor() != null) { |
||
114 | g.setColor(fillColor()); |
||
115 | |||
116 | // outPol.fill(g);
|
||
117 | } |
||
118 | |||
119 | // pinto el marco si es preciso
|
||
120 | g.setColor(c()); |
||
121 | drawLine2D(g, data); |
||
122 | g.setTransform(msave); |
||
123 | } |
||
124 | |||
125 | void drawLine2D(Graphics2D g, Vector v) { |
||
126 | Point2D pt = null; |
||
127 | Point2D pt1 = null; |
||
128 | Iterator iter = v.iterator();
|
||
129 | |||
130 | while (iter.hasNext()) {
|
||
131 | pt1 = (Point2D) iter.next();
|
||
132 | |||
133 | if (pt != null) { |
||
134 | g.draw(new Line2D.Double(pt, pt1)); |
||
135 | } |
||
136 | |||
137 | pt = pt1; |
||
138 | } |
||
139 | } |
||
140 | } |