Revision 83 trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfPolyline.java
DxfPolyline.java | ||
---|---|---|
30 | 30 |
public class DxfPolyline extends DxfEntity { |
31 | 31 |
final static Color baseColor = new Color(69, 106, 121); |
32 | 32 |
Vector pts = null; |
33 |
Vector faces = null; |
|
33 | 34 |
GeneralPath gp = null; |
34 | 35 |
int flags = 0; |
35 | 36 |
boolean closed = false; |
37 |
boolean hasFaces = false; |
|
36 | 38 |
|
37 | 39 |
public DxfPolyline(Projection proj, DxfLayer layer) { |
38 | 40 |
super(proj, layer); |
... | ... | |
45 | 47 |
extent.add(pt); |
46 | 48 |
} |
47 | 49 |
|
50 |
public void addFace(int [] face) { |
|
51 |
hasFaces = true; |
|
52 |
if (faces == null) |
|
53 |
faces = new Vector(); |
|
54 |
faces.add(face); |
|
55 |
} |
|
56 |
|
|
48 | 57 |
private Color color = baseColor; //Color(255,214,132,255); |
49 | 58 |
|
50 | 59 |
public Color c() {return color;} |
... | ... | |
76 | 85 |
color = AcadColor.getColor(dxfColor); |
77 | 86 |
newGP(vp); |
78 | 87 |
if (closed) { |
79 |
g.setColor(new Color(color.getRed(), color.getBlue(), color.getGreen(), 0x80));
|
|
88 |
g.setColor(new Color(color.getRed(), color.getBlue(), color.getGreen(), 0x20));
|
|
80 | 89 |
g.fill(gp); |
81 | 90 |
} |
82 | 91 |
g.setColor(color); |
... | ... | |
89 | 98 |
gp = new GeneralPath(); |
90 | 99 |
Point2D pt0 = null, pt=null, pt1=null; |
91 | 100 |
Point2D.Double ptTmp = new Point2D.Double(0.0, 0.0); |
92 |
Iterator iter = pts.iterator(); |
|
93 |
while (iter.hasNext()) { |
|
94 |
pt1 = (Point2D) iter.next(); |
|
95 |
vp.mat.transform(pt1, ptTmp); |
|
96 |
if (pt0 == null) { |
|
97 |
pt0 = ptTmp; |
|
98 |
gp.moveTo((float)ptTmp.getX(), (float)ptTmp.getY()); |
|
99 |
} else { |
|
100 |
gp.lineTo((float)ptTmp.getX(), (float)ptTmp.getY()); |
|
101 |
if (! hasFaces) { |
|
102 |
Iterator iter = pts.iterator(); |
|
103 |
while (iter.hasNext()) { |
|
104 |
pt1 = (Point2D) iter.next(); |
|
105 |
vp.mat.transform(pt1, ptTmp); |
|
106 |
if (pt0 == null) { |
|
107 |
pt0 = ptTmp; |
|
108 |
gp.moveTo((float)ptTmp.getX(), (float)ptTmp.getY()); |
|
109 |
} else { |
|
110 |
gp.lineTo((float)ptTmp.getX(), (float)ptTmp.getY()); |
|
111 |
} |
|
101 | 112 |
} |
113 |
if (closed) { |
|
114 |
gp.closePath(); |
|
115 |
} |
|
116 |
} else { |
|
117 |
System.out.println("POLYLINE: caras=" +faces.size()+", puntos="+ pts.size()); |
|
118 |
int [] face; |
|
119 |
int i0, i1; |
|
120 |
Iterator iter = faces.iterator(); |
|
121 |
while (iter.hasNext()) { |
|
122 |
face = (int []) iter.next(); |
|
123 |
|
|
124 |
i0 = face[3]; |
|
125 |
for (int i=0; i<4; i++) { |
|
126 |
i1 = face[i]; |
|
127 |
if (i0 > 0) { |
|
128 |
pt0 = (Point2D) pts.get(i0-1); |
|
129 |
vp.mat.transform(pt0, ptTmp); |
|
130 |
gp.moveTo((float)ptTmp.getX(), (float)ptTmp.getY()); |
|
131 |
pt1 = (Point2D) pts.get(Math.abs(i1)-1); |
|
132 |
vp.mat.transform(pt1, ptTmp); |
|
133 |
gp.lineTo((float)ptTmp.getX(), (float)ptTmp.getY()); |
|
134 |
} |
|
135 |
i0 = i1; |
|
136 |
} |
|
137 |
} |
|
102 | 138 |
} |
103 |
if (closed) { |
|
104 |
gp.closePath(); |
|
105 |
} |
|
106 | 139 |
} |
107 | 140 |
|
108 | 141 |
/** |
Also available in: Unified diff