Statistics
| Revision:

svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / px / gml / InsPoint.java @ 2312

History | View | Annotate | Download (3.86 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 * 
4
 * Copyright (C) 2004-5. 
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 * 
22
 * cresques@gmail.com
23
 */
24
package org.cresques.px.gml;
25

    
26
import java.awt.Color;
27
import java.awt.geom.Point2D;
28
import java.awt.Graphics2D;
29
import java.awt.geom.Line2D;
30
import java.util.Vector;
31

    
32
import org.cresques.cts.ICoordTrans;
33
import org.cresques.cts.IProjection;
34
import org.cresques.geo.ViewPortData;
35
import org.cresques.geo.Point3D;
36

    
37
public class InsPoint extends Geometry {
38
        public static int pointNr = 0;
39
        public String text = null;
40
        
41
        String blockName;
42
        Point3D scaleFactor;
43
        double rotAngle;
44
        private FeatureCollection block = new FeatureCollection(proj);
45
        Vector blkList;
46
        boolean blockFound = false;
47
        
48
        public InsPoint() {
49
                super();
50
        }
51
        
52
        public void add(Point2D pt) {
53
                pointNr++;
54
                super.add(pt);
55
        }
56
        
57
        public double getRotAngle() {
58
                return rotAngle;
59
        }
60
        
61
        public Point3D getScaleFactor() {
62
                return scaleFactor;
63
        }
64
        
65
        public Vector getBlkList() {
66
                return blkList;
67
        }
68
        
69
        public boolean getBlockFound() {
70
                return blockFound;
71
        }
72
        
73
        public void setBlock(FeatureCollection block) {
74
                this.block = block;
75
        }
76
        
77
        public void setBlockFound(boolean found) {
78
                blockFound = found;
79
        }
80
        
81
        public void setBlkList(Vector blkList) {
82
                this.blkList = blkList;
83
        }
84
        
85
        public FeatureCollection getBlock() {
86
                return block;
87
        }
88
        
89
        public void setBlockName(String blockName) {
90
                this.blockName = blockName;
91
        }
92
        
93
        public String getBlockName() {
94
                return blockName;
95
        }
96
        
97
        public void setScaleFactor(Point3D scaleFactor) {
98
                this.scaleFactor = scaleFactor;
99
        }
100
        
101
        public void setRotAngle(double rotAngle) {
102
                this.rotAngle = rotAngle;
103
        }
104
        
105
        public boolean encuentraBloque(String blockName) {
106
                int i = 0;
107
                while (i<blkList.size() && blockFound == false) {
108
                        //System.out.println("encuentraBloque: ((DxfBlock)blkList.get(i)).getBlkName() = " + ((FeatureCollection)blkList.get(i)).getProp("blockName"));
109
                        //System.out.println("encuentraBloque: blockName = " + blockName);
110
                        if (((FeatureCollection)blkList.get(i)).getProp("blockName").equals(blockName)) {
111
                                //System.out.println("encuentraBloque: Bloque " + i + " encontrado.");
112
                                block = (FeatureCollection)blkList.get(i);
113
                                blockFound = true;
114
                        } else {
115
                                //System.out.println("encuentraBloque: Bloque " + blockName + " no encontrado");
116
                                blockFound = false;
117
                        }
118
                        i++;
119
                }
120
                return blockFound;
121
        }
122
        
123
        private Color fColor = null; //new Color(255,222,165,64);
124
        private Color color = new Color(255,0,0); //Color(255,214,132,255);
125
        
126
        public Color c() {return color;}
127
        public Color c(Color color) {this.color = color; return color;}
128

    
129
        public Color fillColor() {return fColor;}
130
        public Color fillColor(Color c) {fColor = c; return fColor;}
131

    
132
        public IProjection getProjection() { return proj; }
133
        public void setProjection(IProjection p) { proj = p; }
134
        public void reProject(ICoordTrans rp) {
135
                // TODO metodo reProject pendiente de implementar
136
        }
137
        
138
        public void draw(Graphics2D g, ViewPortData vp) {
139
                g.setColor(c());
140
                Point2D pt = new Point2D.Double(0D, 0D);
141
                vp.mat.transform((Point2D) data.get(0), pt);
142
                g.draw(new Line2D.Double(pt, pt));
143
                if (text != null)
144
                        g.drawString(text, (int) pt.getX(), (int) pt.getY());
145
        }
146
        
147
}