svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfSolid.java @ 81
History | View | Annotate | Download (2.9 KB)
1 | 43 | jmorell | /*
|
---|---|---|---|
2 | * Created on 09-may-2004
|
||
3 | *
|
||
4 | * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
||
5 | */
|
||
6 | package org.cresques.px.dxf; |
||
7 | |||
8 | 81 | jmorell | import java.awt.Color; |
9 | 43 | jmorell | import java.awt.Graphics2D; |
10 | 81 | jmorell | import java.awt.geom.GeneralPath; |
11 | 43 | jmorell | import java.awt.geom.Point2D; |
12 | 81 | jmorell | import java.util.Iterator; |
13 | import java.util.Vector; |
||
14 | 43 | jmorell | |
15 | import org.cresques.geo.Projection; |
||
16 | import org.cresques.geo.ReProjection; |
||
17 | import org.cresques.geo.ViewPort; |
||
18 | 81 | jmorell | import org.cresques.io.DxfGroup; |
19 | 43 | jmorell | import org.cresques.px.Extent; |
20 | |||
21 | /**
|
||
22 | 81 | jmorell | * Entidad SOLID de AutoCAD
|
23 | 43 | jmorell | *
|
24 | * @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
|
||
25 | */
|
||
26 | public class DxfSolid extends DxfEntity { |
||
27 | 81 | jmorell | final static Color baseColor = new Color(69, 106, 121); |
28 | //Vector points = null;
|
||
29 | Point2D[] pts; |
||
30 | GeneralPath gp = null; |
||
31 | boolean closed = true; |
||
32 | 43 | jmorell | |
33 | 81 | jmorell | public DxfSolid(Projection proj, DxfLayer layer, Point2D[] pts) { |
34 | 43 | jmorell | super(proj, layer);
|
35 | 81 | jmorell | Point2D aux = pts[2]; |
36 | pts[2] = pts[3]; |
||
37 | pts[3] = aux;
|
||
38 | this.pts = pts;
|
||
39 | 43 | jmorell | extent = new Extent();
|
40 | 81 | jmorell | for (int i=0; i<pts.length; i++) { |
41 | extent.add(pts[i]); |
||
42 | } |
||
43 | 43 | jmorell | } |
44 | |||
45 | 81 | jmorell | private Color color = baseColor; //Color(255,214,132,255); |
46 | 43 | jmorell | |
47 | 81 | jmorell | public Color c() {return color;} |
48 | public Color c(Color color) {this.color = color; return color;} |
||
49 | |||
50 | 43 | jmorell | public void reProject(ReProjection rp) { |
51 | 81 | jmorell | Point2D [] savePts = pts; |
52 | 43 | jmorell | |
53 | 81 | jmorell | pts = new Point2D[savePts.length]; |
54 | 43 | jmorell | extent = new Extent();
|
55 | Point2D ptDest = null; |
||
56 | 81 | jmorell | for (int i=0; i<savePts.length; i++) { |
57 | 43 | jmorell | ptDest = rp.getPDest().createPoint(0.0,0.0); |
58 | 81 | jmorell | rp.convert((Point2D) savePts[i], ptDest);
|
59 | this.pts[i] = ptDest;
|
||
60 | extent.add(ptDest); |
||
61 | } |
||
62 | 43 | jmorell | setProjection(rp.getPDest()); |
63 | } |
||
64 | |||
65 | public void draw(Graphics2D g, ViewPort vp) { |
||
66 | 81 | jmorell | System.out.println("Va a pintar un solid"); |
67 | Color color = null; |
||
68 | 43 | jmorell | if (dxfColor == AcadColor.BYLAYER)
|
69 | 81 | jmorell | //g.setColor(layer.getColor());
|
70 | color = layer.getColor(); |
||
71 | 43 | jmorell | else
|
72 | 81 | jmorell | //g.setColor(AcadColor.getColor(dxfColor));
|
73 | color = AcadColor.getColor(dxfColor); |
||
74 | newGP(vp); |
||
75 | if (closed) {
|
||
76 | g.setColor(new Color(color.getRed(), color.getBlue(), color.getGreen(), 0x80)); |
||
77 | g.fill(gp); |
||
78 | } |
||
79 | g.setColor(color); |
||
80 | g.draw(gp); |
||
81 | 43 | jmorell | } |
82 | 81 | jmorell | |
83 | private void newGP(ViewPort vp) { |
||
84 | //if (gp != null) return;
|
||
85 | gp = new GeneralPath(); |
||
86 | Point2D pt0 = null, pt=null, pt1=null; |
||
87 | Point2D.Double ptTmp = new Point2D.Double(0.0, 0.0); |
||
88 | System.out.println("pts.length = " + pts.length); |
||
89 | for (int i=0; i<pts.length; i++) { |
||
90 | pt1 = (Point2D)pts[i];
|
||
91 | vp.mat.transform(pt1, ptTmp); |
||
92 | if (pt0 == null) { |
||
93 | pt0 = ptTmp; |
||
94 | gp.moveTo((float)ptTmp.getX(), (float)ptTmp.getY()); |
||
95 | } else {
|
||
96 | gp.lineTo((float)ptTmp.getX(), (float)ptTmp.getY()); |
||
97 | } |
||
98 | } |
||
99 | if (closed) {
|
||
100 | gp.closePath(); |
||
101 | } |
||
102 | } |
||
103 | 43 | jmorell | /* (non-Javadoc)
|
104 | * @see org.cresques.px.dxf.DxfEntity#toDxfFileString()
|
||
105 | */
|
||
106 | public String toDxfString() { |
||
107 | // TODO Auto-generated method stub
|
||
108 | return ""; |
||
109 | } |
||
110 | 81 | jmorell | /**
|
111 | * @return
|
||
112 | */
|
||
113 | public Point2D[] getPts() { |
||
114 | return pts;
|
||
115 | } |
||
116 | |||
117 | /**
|
||
118 | * @return
|
||
119 | */
|
||
120 | /*public GeneralPath getGeneralPath(ViewPort vp) {
|
||
121 | newGP(vp);
|
||
122 | return (GeneralPath) gp.clone();
|
||
123 | }*/
|
||
124 | |||
125 | 43 | jmorell | } |