Statistics
| Revision:

root / org.gvsig.dxf / trunk / org.gvsig.dxf / org.gvsig.dxf.lib / src / main / java / org / gvsig / dxf / px / dxf / DxfInsert.java @ 6

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

    
26
import java.awt.Graphics2D;
27
import java.awt.geom.Point2D;
28
import java.util.Vector;
29

    
30
import org.cresques.cts.ICoordTrans;
31
import org.cresques.cts.IProjection;
32
import org.cresques.geo.ViewPortData;
33
import org.cresques.px.Extent;
34

    
35

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

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

    
59
    /**
60
     * @return Returns the pt.
61
     */
62
    public Point2D getPt() {
63
        return pt;
64
    }
65

    
66
    /**
67
     * Devuelve el �ngulo de rotaci�n que se aplica al bloque.
68
     * @return double. �ngulo de rotaci�n.
69
     */
70
    public double getRotAngle() {
71
        return rotAngle;
72
    }
73

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

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

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

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

    
108
        while ((i < blkList.size()) && (blockFound == false)) {
109
            if (((DxfBlock) blkList.get(i)).getBlkName().equals(blockName)) {
110
                block = (DxfBlock) blkList.get(i);
111
                blockFound = true;
112
            } else {
113
                blockFound = false;
114
            }
115

    
116
            i++;
117
        }
118

    
119
        return blockFound;
120
    }
121

    
122
    /**
123
     * Devuelve la capa en la que se encuentra el DxfInsert.
124
     * @return DxfLayer, la capa.
125
     */
126
    public DxfLayer getDxfLayer() {
127
        return layer;
128
    }
129

    
130
    /**
131
     * Establece la lista de bloques.
132
     * @param blkList, Vector con la lista de bloques.
133
     */
134
    public void setBlkList(Vector blkList) {
135
        this.blkList = blkList;
136
    }
137

    
138
    /**
139
     * Devuelve el bloque al que hace referencia el punto de inserci�n.
140
     * @return DxfBlock, el bloque.
141
     */
142
    public DxfBlock getDxfBlock() {
143
        return block;
144
    }
145

    
146
    /**
147
     * Establece el punto de inserci�n del DxfInsert.
148
     * @param pt, punto de inserci�n.
149
     */
150
    public void setPt(Point2D pt) {
151
        this.pt = pt;
152
        extent.add(pt);
153
    }
154

    
155
    /**
156
     * Establece el nombre del bloque.
157
     * @param blockName, nombre del bloque.
158
     */
159
    public void setBlockName(String blockName) {
160
        this.blockName = blockName;
161
    }
162

    
163
    /**
164
     * Devuelve el nombre del bloque al que hace referencia el punto de inserci�n.
165
     * @return String, nombre del bloque.
166
     */
167
    public String getBlockName() {
168
        return blockName;
169
    }
170

    
171
    /**
172
     * Establece el factor de escala para el bloque.
173
     * @param scaleFactor, factor de escala en X, en Y y en Z.
174
     */
175
    public void setScaleFactor(Point2D scaleFactor) {
176
        this.scaleFactor = scaleFactor;
177
    }
178

    
179
    /**
180
     * Establece el �ngulo de rotaci�n para el bloque.
181
     * @param rotAngle, �ngulo de rotaci�n.
182
     */
183
    public void setRotAngle(double rotAngle) {
184
        this.rotAngle = rotAngle;
185
    }
186

    
187
    /* (non-Javadoc)
188
     * @see org.cresques.px.dxf.DxfEntity#toDxfFileString()
189
     */
190
    public String toDxfString() {
191
        // TODO Auto-generated method stub
192
        return "";
193
    }
194

    
195
    /* (non-Javadoc)
196
     * @see org.cresques.px.dxf.DxfEntity#reProject(org.cresques.geo.ReProjection)
197
     */
198
    public void reProject(ICoordTrans rp) {
199
        // TODO Auto-generated method stub
200
    }
201

    
202
    /* (non-Javadoc)
203
     * @see org.cresques.px.Drawable#draw(java.awt.Graphics2D, org.cresques.geo.ViewPort)
204
     */
205
    public void draw(Graphics2D g, ViewPortData vp) {
206
        // TODO Auto-generated method stub
207
    }
208
}