svn-gvsig-desktop / branches / Mobile_Compatible_Hito_1 / libDXF / src / org / cresques / px / dxf / DxfInsert.java @ 21930
History | View | Annotate | Download (6.14 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 java.awt.Graphics2D; |
27 |
import java.awt.geom.Point2D; |
28 |
import java.util.Vector; |
29 |
|
30 |
import org.gvsig.projection.cts.ICoordTrans; |
31 |
import org.gvsig.projection.cts.IProjection; |
32 |
import org.gvsig.projection.geo.ViewPortData; |
33 |
import org.gvsig.projection.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 |
//System.out.println("encuentraBloque: ((DxfBlock)blkList.get(i)).getBlkName() = " + ((DxfBlock)blkList.get(i)).getBlkName());
|
110 |
//System.out.println("encuentraBloque: blockName = " + blockName);
|
111 |
if (((DxfBlock) blkList.get(i)).getBlkName().equals(blockName)) {
|
112 |
//System.out.println("encuentraBloque: Bloque " + i + " encontrado.");
|
113 |
block = (DxfBlock) blkList.get(i); |
114 |
blockFound = true;
|
115 |
} else {
|
116 |
//System.out.println("encuentraBloque: Bloque " + blockName + " no encontrado");
|
117 |
blockFound = false;
|
118 |
} |
119 |
|
120 |
i++; |
121 |
} |
122 |
|
123 |
return blockFound;
|
124 |
} |
125 |
|
126 |
/**
|
127 |
* Devuelve la capa en la que se encuentra el DxfInsert.
|
128 |
* @return DxfLayer, la capa.
|
129 |
*/
|
130 |
public DxfLayer getDxfLayer() {
|
131 |
return layer;
|
132 |
} |
133 |
|
134 |
/**
|
135 |
* Establece la lista de bloques.
|
136 |
* @param blkList, Vector con la lista de bloques.
|
137 |
*/
|
138 |
public void setBlkList(Vector blkList) { |
139 |
this.blkList = blkList;
|
140 |
} |
141 |
|
142 |
/**
|
143 |
* Devuelve el bloque al que hace referencia el punto de inserci?n.
|
144 |
* @return DxfBlock, el bloque.
|
145 |
*/
|
146 |
public DxfBlock getDxfBlock() {
|
147 |
return block;
|
148 |
} |
149 |
|
150 |
/**
|
151 |
* Establece el punto de inserci?n del DxfInsert.
|
152 |
* @param pt, punto de inserci?n.
|
153 |
*/
|
154 |
public void setPt(Point2D pt) { |
155 |
this.pt = pt;
|
156 |
extent.add(pt); |
157 |
} |
158 |
|
159 |
/**
|
160 |
* Establece el nombre del bloque.
|
161 |
* @param blockName, nombre del bloque.
|
162 |
*/
|
163 |
public void setBlockName(String blockName) { |
164 |
this.blockName = blockName;
|
165 |
} |
166 |
|
167 |
/**
|
168 |
* Devuelve el nombre del bloque al que hace referencia el punto de inserci?n.
|
169 |
* @return String, nombre del bloque.
|
170 |
*/
|
171 |
public String getBlockName() { |
172 |
return blockName;
|
173 |
} |
174 |
|
175 |
/**
|
176 |
* Establece el factor de escala para el bloque.
|
177 |
* @param scaleFactor, factor de escala en X, en Y y en Z.
|
178 |
*/
|
179 |
public void setScaleFactor(Point2D scaleFactor) { |
180 |
this.scaleFactor = scaleFactor;
|
181 |
} |
182 |
|
183 |
/**
|
184 |
* Establece el ?ngulo de rotaci?n para el bloque.
|
185 |
* @param rotAngle, ?ngulo de rotaci?n.
|
186 |
*/
|
187 |
public void setRotAngle(double rotAngle) { |
188 |
this.rotAngle = rotAngle;
|
189 |
} |
190 |
|
191 |
/* (non-Javadoc)
|
192 |
* @see org.cresques.px.dxf.DxfEntity#toDxfFileString()
|
193 |
*/
|
194 |
public String toDxfString() { |
195 |
// TODO Auto-generated method stub
|
196 |
return ""; |
197 |
} |
198 |
|
199 |
/* (non-Javadoc)
|
200 |
* @see org.cresques.px.dxf.DxfEntity#reProject(org.cresques.geo.ReProjection)
|
201 |
*/
|
202 |
public void reProject(ICoordTrans rp) { |
203 |
// TODO Auto-generated method stub
|
204 |
} |
205 |
|
206 |
/* (non-Javadoc)
|
207 |
* @see org.cresques.px.Drawable#draw(java.awt.Graphics2D, org.cresques.geo.ViewPort)
|
208 |
*/
|
209 |
public void draw(Graphics2D g, ViewPortData vp) { |
210 |
// TODO Auto-generated method stub
|
211 |
} |
212 |
} |