Statistics
| Revision:

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

History | View | Annotate | Download (2.68 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
                extent = new Extent();
36
                this.pts = pts;
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(ReProjection 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
                        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, ViewPort vp) {
60
                System.out.println("Va a pintar un arc");
61
                if (dxfColor == AcadColor.BYLAYER)
62
                        g.setColor(layer.getColor());
63
                else
64
                        g.setColor(AcadColor.getColor(dxfColor));
65
                newGP(vp);
66
                if (closed) {
67
                        g.setColor(new Color(color.getRed(), color.getBlue(), color.getGreen(), 0x80));
68
                        g.fill(gp);
69
                } 
70
                g.setColor(color);
71
                g.draw(gp);
72
        }
73
        
74
        private void newGP(ViewPort vp) {
75
                //if (gp != null) return;
76
                gp = new GeneralPath();
77
                Point2D pt0 = null, pt=null, pt1=null;
78
                Point2D.Double ptTmp = new Point2D.Double(0.0, 0.0);
79
                System.out.println("pts.length = " + pts.length);
80
                for (int i=0; i<pts.length; i++) {
81
                        pt1 = (Point2D)pts[i];
82
                        vp.mat.transform(pt1, ptTmp);
83
                        if (pt0 == null) { 
84
                                pt0 = ptTmp;
85
                                gp.moveTo((float)ptTmp.getX(), (float)ptTmp.getY());
86
                        } else {
87
                                gp.lineTo((float)ptTmp.getX(), (float)ptTmp.getY());
88
                        }                        
89
                }
90
                if (closed) {
91
                        gp.closePath();                        
92
                }
93
        }
94
        /* (non-Javadoc)
95
         * @see org.cresques.px.dxf.DxfEntity#toDxfFileString()
96
         */
97
        public String toDxfString() {
98
                // TODO Auto-generated method stub
99
                return "";
100
        }
101
        /**
102
         * @return
103
         */
104
        public Point2D[] getPts() {
105
                return pts;
106
        }
107
        
108
        /**
109
         * @return
110
         */
111
        /*public GeneralPath getGeneralPath(ViewPort vp) {
112
                newGP(vp);
113
                return (GeneralPath) gp.clone();
114
        }*/
115

    
116
}