svn-gvsig-desktop / trunk / libraries / libDwg / src / com / iver / cit / jdwglib / dwg / objects / DwgBlockControl.java @ 2896
History | View | Annotate | Download (4.05 KB)
1 |
/* jdwglib. Java Library for reading Dwg files.
|
---|---|
2 |
*
|
3 |
* Author: Jose Morell Rama (jose.morell@gmail.com).
|
4 |
* Port from the Pythoncad Dwg library by Art Haas.
|
5 |
*
|
6 |
* Copyright (C) 2005 Jose Morell, IVER TI S.A. and Generalitat Valenciana
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Jose Morell (jose.morell@gmail.com)
|
25 |
*
|
26 |
* or
|
27 |
*
|
28 |
* IVER TI S.A.
|
29 |
* C/Salamanca, 50
|
30 |
* 46005 Valencia
|
31 |
* Spain
|
32 |
* +34 963163400
|
33 |
* dac@iver.es
|
34 |
*/
|
35 |
package com.iver.cit.jdwglib.dwg.objects; |
36 |
|
37 |
import java.util.Vector; |
38 |
|
39 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
40 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
41 |
|
42 |
/**
|
43 |
* The DwgBlockControl class represents a DWG Block control
|
44 |
*
|
45 |
* @author jmorell
|
46 |
*/
|
47 |
public class DwgBlockControl extends DwgObject { |
48 |
private int nullHandle; |
49 |
private Vector code2Handles; |
50 |
private int modelSpaceHandle; |
51 |
private int paperSpaceHandle; |
52 |
|
53 |
/**
|
54 |
* Read a Block control in the DWG format Version 15
|
55 |
*
|
56 |
* @param data Array of unsigned bytes obtained from the DWG binary file
|
57 |
* @param offset The current bit offset where the value begins
|
58 |
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs
|
59 |
* when we are looking for LwPolylines.
|
60 |
*/
|
61 |
public void readDwgBlockControlV15(int[] data, int offset) throws Exception { |
62 |
//System.out.println("readDwgBlockControl() executed ...");
|
63 |
int bitPos = offset;
|
64 |
Vector v = DwgUtil.getBitLong(data, bitPos);
|
65 |
bitPos = ((Integer)v.get(0)).intValue(); |
66 |
int numReactors = ((Integer)v.get(1)).intValue(); |
67 |
setNumReactors(numReactors); |
68 |
v = DwgUtil.getBitShort(data, bitPos); |
69 |
bitPos = ((Integer)v.get(0)).intValue(); |
70 |
int enum = ((Integer)v.get(1)).intValue(); |
71 |
v = DwgUtil.getHandle(data, bitPos); |
72 |
bitPos = ((Integer)v.get(0)).intValue(); |
73 |
int[] handle = new int[v.size()-1]; |
74 |
for (int i=1;i<v.size();i++) { |
75 |
handle[i-1] = ((Integer)v.get(i)).intValue(); |
76 |
} |
77 |
Vector handleVect = new Vector(); |
78 |
for (int i=0;i<handle.length;i++) { |
79 |
handleVect.add(new Integer(handle[i])); |
80 |
} |
81 |
nullHandle = DwgUtil.handleBinToHandleInt(handleVect); |
82 |
v = DwgUtil.getHandle(data, bitPos); |
83 |
bitPos = ((Integer)v.get(0)).intValue(); |
84 |
handle = new int[v.size()-1]; |
85 |
for (int i=1;i<v.size();i++) { |
86 |
handle[i-1] = ((Integer)v.get(i)).intValue(); |
87 |
} |
88 |
if (enum>0) { |
89 |
Vector handles = new Vector(); |
90 |
for (int i=0;i<enum;i++) { |
91 |
v = DwgUtil.getHandle(data, bitPos); |
92 |
bitPos = ((Integer)v.get(0)).intValue(); |
93 |
handle = new int[v.size()-1]; |
94 |
for (int j=1;j<v.size();j++) { |
95 |
handle[j-1] = ((Integer)v.get(j)).intValue(); |
96 |
} |
97 |
handles.add(handle); |
98 |
} |
99 |
code2Handles = handles; |
100 |
} |
101 |
v = DwgUtil.getHandle(data, bitPos); |
102 |
bitPos = ((Integer)v.get(0)).intValue(); |
103 |
handle = new int[v.size()-1]; |
104 |
for (int j=1;j<v.size();j++) { |
105 |
handle[j-1] = ((Integer)v.get(j)).intValue(); |
106 |
} |
107 |
handleVect = new Vector(); |
108 |
for (int i=0;i<handle.length;i++) { |
109 |
handleVect.add(new Integer(handle[i])); |
110 |
} |
111 |
modelSpaceHandle = DwgUtil.handleBinToHandleInt(handleVect); |
112 |
v = DwgUtil.getHandle(data, bitPos); |
113 |
bitPos = ((Integer)v.get(0)).intValue(); |
114 |
handle = new int[v.size()-1]; |
115 |
for (int j=1;j<v.size();j++) { |
116 |
handle[j-1] = ((Integer)v.get(j)).intValue(); |
117 |
} |
118 |
handleVect = new Vector(); |
119 |
for (int i=0;i<handle.length;i++) { |
120 |
handleVect.add(new Integer(handle[i])); |
121 |
} |
122 |
paperSpaceHandle = DwgUtil.handleBinToHandleInt(handleVect); |
123 |
} |
124 |
} |