Statistics
| Revision:

root / trunk / libraries / libCq_CMS_praster / src / org / cresques / px / dxf / DxfInsert.java @ 8026

History | View | Annotate | Download (5.91 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.dxf;
25

    
26
import org.cresques.cts.ICoordTrans;
27
import org.cresques.cts.IProjection;
28

    
29
import org.cresques.geo.ViewPortData;
30

    
31
import org.cresques.px.Extent;
32

    
33
import java.awt.Graphics2D;
34
import java.awt.geom.Point2D;
35

    
36
import java.util.Vector;
37

    
38

    
39
/**
40
 * Entidad INSERT de un fichero DXF.
41
 * @author jmorell
42
 */
43
public class DxfInsert extends DxfEntity {
44
    Point2D pt;
45
    String blockName;
46
    Point2D scaleFactor;
47
    double rotAngle;
48
    DxfBlock block = new DxfBlock(proj);
49
    Vector blkList;
50
    boolean blockFound = false;
51

    
52
    /**
53
     * Constructor de DxfInsert.
54
     * @param proj, proyecci?n cartogr?fica en la que se encuentra el DxfInsert.
55
     * @param layer, capa del DXF en la que se encuentra el DxfInsert.
56
     */
57
    public DxfInsert(IProjection proj, DxfLayer layer) {
58
        super(proj, layer);
59
        extent = new Extent();
60
    }
61

    
62
    /**
63
     * @return Returns the pt.
64
     */
65
    public Point2D getPt() {
66
        return pt;
67
    }
68

    
69
    /**
70
     * Devuelve el ?ngulo de rotaci?n que se aplica al bloque.
71
     * @return double. ?ngulo de rotaci?n.
72
     */
73
    public double getRotAngle() {
74
        return rotAngle;
75
    }
76

    
77
    /**
78
     * Devuelve el factor de escala que se aplica al bloque.
79
     * @return Point3D. Contiene el factor de escala en X, en Y y en Z.
80
     */
81
    public Point2D getScaleFactor() {
82
        return scaleFactor;
83
    }
84

    
85
    /**
86
     * Informa sobre si el bloque ya ha sido encontrado.
87
     * @return boolean, true si el bloque ya ha sido encontrado.
88
     */
89
    public boolean getBlockFound() {
90
        return blockFound;
91
    }
92

    
93
    /**
94
     * Establece si el bloque ya ha sido encontrado.
95
     * @param found, true si el bloque ya ha sido encontrado.
96
     */
97
    public void setBlockFound(boolean found) {
98
        blockFound = found;
99
    }
100

    
101
    /**
102
     * M?todo para cargar el bloque al que hace referencia el punto de inserci?n, en el
103
     * propio DxfInsert.
104
     * @param blockName, nombre del bloque que estamos buscando.
105
     * @return boolean, true si hemos encontrado el bloque que buscabamos y ha sido
106
     * cargado.
107
     */
108
    public boolean encuentraBloque(String blockName) {
109
        int i = 0;
110

    
111
        while ((i < blkList.size()) && (blockFound == false)) {
112
            //System.out.println("encuentraBloque: ((DxfBlock)blkList.get(i)).getBlkName() = " + ((DxfBlock)blkList.get(i)).getBlkName());
113
            //System.out.println("encuentraBloque: blockName = " + blockName);
114
            if (((DxfBlock) blkList.get(i)).getBlkName().equals(blockName)) {
115
                //System.out.println("encuentraBloque: Bloque " + i + " encontrado.");
116
                block = (DxfBlock) blkList.get(i);
117
                blockFound = true;
118
            } else {
119
                //System.out.println("encuentraBloque: Bloque " + blockName + " no encontrado");
120
                blockFound = false;
121
            }
122

    
123
            i++;
124
        }
125

    
126
        return blockFound;
127
    }
128

    
129
    /**
130
     * Devuelve la capa en la que se encuentra el DxfInsert.
131
     * @return DxfLayer, la capa.
132
     */
133
    public DxfLayer getDxfLayer() {
134
        return layer;
135
    }
136

    
137
    /**
138
     * Establece la lista de bloques.
139
     * @param blkList, Vector con la lista de bloques.
140
     */
141
    public void setBlkList(Vector blkList) {
142
        this.blkList = blkList;
143
    }
144

    
145
    /**
146
     * Devuelve el bloque al que hace referencia el punto de inserci?n.
147
     * @return DxfBlock, el bloque.
148
     */
149
    public DxfBlock getDxfBlock() {
150
        return block;
151
    }
152

    
153
    /**
154
     * Establece el punto de inserci?n del DxfInsert.
155
     * @param pt, punto de inserci?n.
156
     */
157
    public void setPt(Point2D pt) {
158
        this.pt = pt;
159
        extent.add(pt);
160
    }
161

    
162
    /**
163
     * Establece el nombre del bloque.
164
     * @param blockName, nombre del bloque.
165
     */
166
    public void setBlockName(String blockName) {
167
        this.blockName = blockName;
168
    }
169

    
170
    /**
171
     * Devuelve el nombre del bloque al que hace referencia el punto de inserci?n.
172
     * @return String, nombre del bloque.
173
     */
174
    public String getBlockName() {
175
        return blockName;
176
    }
177

    
178
    /**
179
     * Establece el factor de escala para el bloque.
180
     * @param scaleFactor, factor de escala en X, en Y y en Z.
181
     */
182
    public void setScaleFactor(Point2D scaleFactor) {
183
        this.scaleFactor = scaleFactor;
184
    }
185

    
186
    /**
187
     * Establece el ?ngulo de rotaci?n para el bloque.
188
     * @param rotAngle, ?ngulo de rotaci?n.
189
     */
190
    public void setRotAngle(double rotAngle) {
191
        this.rotAngle = rotAngle;
192
    }
193

    
194
    /* (non-Javadoc)
195
     * @see org.cresques.px.dxf.DxfEntity#toDxfFileString()
196
     */
197
    public String toDxfString() {
198
        // TODO Auto-generated method stub
199
        return "";
200
    }
201

    
202
    /* (non-Javadoc)
203
     * @see org.cresques.px.dxf.DxfEntity#reProject(org.cresques.geo.ReProjection)
204
     */
205
    public void reProject(ICoordTrans rp) {
206
        // TODO Auto-generated method stub
207
    }
208

    
209
    /* (non-Javadoc)
210
     * @see org.cresques.px.Drawable#draw(java.awt.Graphics2D, org.cresques.geo.ViewPort)
211
     */
212
    public void draw(Graphics2D g, ViewPortData vp) {
213
        // TODO Auto-generated method stub
214
    }
215
}