Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfArc.java @ 83

History | View | Annotate | Download (2.84 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
import java.util.Iterator;
13
import java.util.Vector;
14

    
15
import org.cresques.geo.Projection;
16
import org.cresques.geo.ReProjection;
17
import org.cresques.geo.ViewPort;
18
import org.cresques.io.DxfGroup;
19
import org.cresques.px.Extent;
20

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

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

    
124
}