Statistics
| Revision:

root / trunk / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfArc.java @ 95

History | View | Annotate | Download (2.78 KB)

1
/*
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
import java.awt.Color;
9
import java.awt.Graphics2D;
10
import java.awt.geom.GeneralPath;
11
import java.awt.geom.Point2D;
12

    
13
import org.cresques.cts.ICoordTrans;
14
import org.cresques.cts.IProjection;
15
import org.cresques.geo.ViewPortData;
16
import org.cresques.px.Extent;
17

    
18
/**
19
 * Entidad TEXT de AutoCAD
20
 * 
21
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
22
 */
23
public class DxfArc extends DxfEntity {
24
        final static Color baseColor = new Color(69, 106, 121);
25
        //Vector points = null;
26
        Point2D [] pts;
27
        GeneralPath gp = null;
28
        boolean closed = false;
29
        
30
        public DxfArc(IProjection proj, DxfLayer layer, Point2D[] pts) {
31
                super(proj, layer);
32
                this.pts = pts;
33
                extent = new Extent();
34
                for (int i=0; i<pts.length; i++) {
35
                        extent.add(pts[i]);
36
                }
37
        }
38
        
39
        private Color color = baseColor; //Color(255,214,132,255);
40
        
41
        public Color c() {return color;}
42
        public Color c(Color color) {this.color = color; return color;}
43
        
44
        public void reProject(ICoordTrans rp) {
45
                Point2D [] savePts = pts;
46

    
47
                pts = new Point2D[savePts.length];
48
                extent = new Extent();
49
                Point2D ptDest = null;
50
                for (int i=0; i<savePts.length; i++) {
51
                        ptDest = rp.getPDest().createPoint(0.0,0.0);
52
                        ptDest = rp.convert((Point2D) savePts[i], ptDest);
53
                        this.pts[i] = ptDest;
54
                        extent.add(ptDest);
55
                }
56
                setProjection(rp.getPDest());
57
        }
58
        
59
        public void draw(Graphics2D g, ViewPortData vp) {
60
                //System.out.println("Va a pintar un arc");
61
                
62
                Color color = null;
63
                
64
                if (dxfColor == AcadColor.BYLAYER)
65
                        //g.setColor(layer.getColor());
66
                        color = layer.getColor();
67
                else
68
                        color = AcadColor.getColor(dxfColor);
69
                        //g.setColor(AcadColor.getColor(dxfColor));
70
                newGP(vp);
71
                if (closed) {
72
                        g.setColor(new Color(color.getRed(), color.getBlue(), color.getGreen(), 0x80));
73
                        g.fill(gp);
74
                } 
75
                g.setColor(color);
76
                g.draw(gp);
77
        }
78
        
79
        private void newGP(ViewPortData vp) {
80
                //if (gp != null) return;
81
                gp = new GeneralPath();
82
                Point2D pt0 = null, pt=null, pt1=null;
83
                Point2D.Double ptTmp = new Point2D.Double(0.0, 0.0);
84
                System.out.println("pts.length = " + pts.length);
85
                for (int i=0; i<pts.length; i++) {
86
                        pt1 = (Point2D)pts[i];
87
                        vp.mat.transform(pt1, ptTmp);
88
                        if (pt0 == null) { 
89
                                pt0 = ptTmp;
90
                                gp.moveTo((float)ptTmp.getX(), (float)ptTmp.getY());
91
                        } else {
92
                                gp.lineTo((float)ptTmp.getX(), (float)ptTmp.getY());
93
                        }                        
94
                }
95
                if (closed) {
96
                        gp.closePath();                        
97
                }
98
        }
99
        /* (non-Javadoc)
100
         * @see org.cresques.px.dxf.DxfEntity#toDxfFileString()
101
         */
102
        public String toDxfString() {
103
                // TODO Auto-generated method stub
104
                return "";
105
        }
106
        /**
107
         * @return
108
         */
109
        public Point2D[] getPts() {
110
                return pts;
111
        }
112
        
113
        /**
114
         * @return
115
         */
116
        /*public GeneralPath getGeneralPath(ViewPort vp) {
117
                newGP(vp);
118
                return (GeneralPath) gp.clone();
119
        }*/
120

    
121
}