root / org.gvsig.dgn / trunk / org.gvsig.dgn / org.gvsig.dgn.provider / src / main / java / org / gvsig / fmap / dal / store / dgn / lib / DGNElemCore.java @ 108
History | View | Annotate | Download (4.66 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
*/
|
20 |
package org.gvsig.fmap.dal.store.dgn.lib; |
21 |
|
22 |
import java.util.Formatter; |
23 |
|
24 |
/**
|
25 |
* Clase utilizada para guardar un elemento de tipo Base del cual extienden los
|
26 |
* dem?s tipos.
|
27 |
*
|
28 |
* @author Vicente Caballero Navarro
|
29 |
*/
|
30 |
public class DGNElemCore { |
31 |
public int offset; |
32 |
public int size; |
33 |
public int element_id; /*!< Element number (zero based) */ |
34 |
public int stype; /*!< Structure type: (DGNST_*) */ |
35 |
public int level; /*!< Element Level: 0-63 */ |
36 |
public int type; /*!< Element type (DGNT_) */ |
37 |
public int complex; /*!< Is element complex? */ |
38 |
public int deleted; /*!< Is element deleted? */ |
39 |
public int graphic_group; /*!< Graphic group number */ |
40 |
public int properties; /*!< Properties: ORing of DGNPF_ flags */ |
41 |
public int color; /*!< Color index (0-255) */ |
42 |
public int weight; /*!< Line Weight (0-31) */ |
43 |
public int style; /*!< Line Style: One of DGNS_* values */ |
44 |
public int attr_bytes; /*!< Bytes of attribute data, usually zero. */ |
45 |
public byte[] attr_data; /*!< Raw attribute data */ |
46 |
public int raw_bytes; /*!< Bytes of raw data, usually zero. */ |
47 |
public byte[] raw_data; /*!< All raw element data including header. */ |
48 |
|
49 |
protected DGNReader dgnreader = null; |
50 |
|
51 |
public DGNElemCore(DGNReader dgnreader) {
|
52 |
this.dgnreader = dgnreader;
|
53 |
} |
54 |
|
55 |
public boolean isComplex() { |
56 |
return this.complex != 0; |
57 |
} |
58 |
|
59 |
public boolean isDeleted() { |
60 |
return this.deleted != 0; |
61 |
} |
62 |
|
63 |
public boolean isHole() { |
64 |
if( this.type != DGNFileHeader.DGNT_SHAPE ) { |
65 |
return false; |
66 |
} |
67 |
return (this.properties & DGNFileHeader.DGNPF_HOLE) != 0; |
68 |
} |
69 |
|
70 |
public boolean is3D() { |
71 |
return this.getDimensions()==3; |
72 |
} |
73 |
|
74 |
public boolean isComplexShapeHeader() { |
75 |
return type == DGNFileHeader.DGNT_COMPLEX_SHAPE_HEADER;
|
76 |
} |
77 |
|
78 |
public boolean isShape() { |
79 |
return this.type == DGNFileHeader.DGNT_SHAPE; |
80 |
} |
81 |
|
82 |
public boolean isEllipse() { |
83 |
return type == DGNFileHeader.DGNT_ELLIPSE;
|
84 |
} |
85 |
|
86 |
public boolean isCurve() { |
87 |
return type == DGNFileHeader.DGNT_CURVE;
|
88 |
} |
89 |
|
90 |
public int getShapeFillColor() { |
91 |
return this.dgnreader.DGNGetShapeFillInfo(this); |
92 |
} |
93 |
|
94 |
public String getLevelAsString() { |
95 |
return String.valueOf(this.level); |
96 |
} |
97 |
|
98 |
public int getLevel() { |
99 |
return this.level; |
100 |
} |
101 |
|
102 |
public int getStyle() { |
103 |
return this.style; |
104 |
} |
105 |
|
106 |
public int getWeight() { |
107 |
return this.weight; |
108 |
} |
109 |
|
110 |
public String getEntityName() { |
111 |
return this.dgnreader.DGNTypeToName(this.type); |
112 |
} |
113 |
|
114 |
public int getColor() { |
115 |
return this.color; |
116 |
} |
117 |
|
118 |
public int getID() { |
119 |
return this.element_id; |
120 |
} |
121 |
|
122 |
public int getGroup() { |
123 |
return this.graphic_group; |
124 |
} |
125 |
|
126 |
public double getElevation() { |
127 |
return 0; |
128 |
} |
129 |
|
130 |
public int getDimensions() { |
131 |
return this.dgnreader.getInfo().dimension; |
132 |
} |
133 |
|
134 |
public int getType() { |
135 |
return this.type; |
136 |
} |
137 |
|
138 |
public int getSType() { |
139 |
return this.stype; |
140 |
} |
141 |
|
142 |
|
143 |
public byte[] getData() { |
144 |
return this.raw_data; |
145 |
} |
146 |
|
147 |
public String getDataAsHexadecimal() { |
148 |
if( this.raw_data == null ) { |
149 |
return null; |
150 |
} |
151 |
Formatter out = new Formatter(); |
152 |
|
153 |
for (int i = 0; i < this.raw_data.length; i++) { |
154 |
int ch = this.raw_data[i] & 0xff; |
155 |
out.format("%02X", ch);
|
156 |
} |
157 |
return out.toString();
|
158 |
} |
159 |
} |