Statistics
| Revision:

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

History | View | Annotate | Download (2.13 KB)

1
/*
2
 * Created on 04-may-2004
3
 *
4
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
5
 */
6
 
7
package org.cresques.px.dxf;
8

    
9
import java.awt.Color;
10
import java.awt.Graphics2D;
11
import java.awt.geom.GeneralPath;
12
import java.awt.geom.Point2D;
13

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

    
19
/**
20
 * Linea de autocad (.dxf, .dwg)
21
 * 
22
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
23
 */
24

    
25
public class DxfLine extends DxfEntity {
26
        final static Color baseColor = new Color(255, 106, 121);
27
        Point2D [] pts;
28
        GeneralPath gp = null;
29
        
30
        public DxfLine(IProjection proj, DxfLayer layer, Point2D p1, Point2D p2) {
31
                super(proj, layer);
32
                extent = new Extent(p1, p2);
33
                pts = new Point2D[2];
34
                pts[0] = p1; pts[1] = p2;
35
        }
36

    
37
        private Color color = baseColor; //Color(255,214,132,255);
38
        
39
        public Color c() {return color;}
40
        public Color c(Color color) {this.color = color; return color;}
41
        
42
        public void reProject(ICoordTrans rp) {
43
                Point2D [] savePts = pts;
44

    
45
                pts = new Point2D[2];
46
                extent = new Extent();
47
                Point2D ptDest = null;
48
                for (int i=0; i<savePts.length; i++) {
49
                        ptDest = rp.getPDest().createPoint(0.0,0.0);
50
                        ptDest = rp.convert((Point2D) savePts[i], ptDest);
51
                        pts[i] = ptDest;
52
                        extent.add(ptDest);
53
                }
54
                setProjection(rp.getPDest());
55
        }
56

    
57
        public void draw(Graphics2D g, ViewPortData vp) {
58
                if (dxfColor == AcadColor.BYLAYER)
59
                        g.setColor(layer.getColor());
60
                else
61
                        g.setColor(AcadColor.getColor(dxfColor));
62
                newGP(vp);
63
                g.draw(gp);
64
        }
65
        
66
        private void newGP(ViewPortData vp) {
67
                //if (gp != null) return;
68
                Point2D.Double pt0 = new Point2D.Double(0.0, 0.0);
69
                Point2D.Double pt1 = new Point2D.Double(0.0, 0.0);
70
                vp.mat.transform((Point2D) pts[0], pt0);
71
                vp.mat.transform((Point2D) pts[1], pt1);
72
                gp = new GeneralPath();
73
                gp.moveTo((float)pt0.getX(), (float)pt0.getY());
74
                gp.lineTo((float)pt1.getX(), (float)pt1.getY());
75
        }
76
        /* (non-Javadoc)
77
         * @see org.cresques.px.dxf.DxfEntity#toDxfFileString()
78
         */
79
        public String toDxfString() {
80
                // TODO Auto-generated method stub
81
                return "";
82
        }
83
        /**
84
         * @return
85
         */
86
        public Point2D[] getPts() {
87
                return pts;
88
        }
89
}