Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libDwg / src / org / gvsig / dwg / lib / readers / v1314 / DwgDictionaryReader1314.java @ 28969

History | View | Annotate | Download (3.46 KB)

1
/*
2
 * Created on 05-feb-2007
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. 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
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id: DwgDictionaryReader1314.java 28969 2009-05-25 13:23:12Z jmvivo $
47
* $Log$
48
* Revision 1.2.2.2  2007-03-21 19:49:16  azabala
49
* implementation of dwg 12, 13, 14.
50
*
51
* Revision 1.2  2007/02/06 20:17:29  azabala
52
* *** empty log message ***
53
*
54
* Revision 1.1  2007/02/05 19:44:00  azabala
55
* *** empty log message ***
56
*
57
*
58
*/
59
package org.gvsig.dwg.lib.readers.v1314;
60

    
61
import java.util.List;
62

    
63
import org.gvsig.dwg.lib.CorruptedDwgEntityException;
64
import org.gvsig.dwg.lib.DwgHandleReference;
65
import org.gvsig.dwg.lib.DwgObject;
66
import org.gvsig.dwg.lib.DwgUtil;
67
import org.gvsig.dwg.lib.objects.DwgDictionary;
68

    
69

    
70
public class DwgDictionaryReader1314 extends AbstractDwg1314Reader {
71

    
72
        public void readSpecificObj(int[] data, int offset, DwgObject dwgObj)
73
                        throws RuntimeException, CorruptedDwgEntityException {
74
                
75
                if(! (dwgObj instanceof DwgDictionary))
76
                        throw new RuntimeException("ArcReader 15 solo puede leer DwgDictionary");
77
                DwgDictionary dic = (DwgDictionary) dwgObj;
78
                
79
                int bitPos = offset;
80
                List val = DwgUtil.getBitShort(data, bitPos);
81
                bitPos = ((Integer) val.get(0)).intValue();
82
                int nr = ((Integer) val.get(1)).intValue();
83
                
84
                val = DwgUtil.getBitLong(data, bitPos);
85
                bitPos = ((Integer) val.get(0)).intValue();
86
                int ni = ((Integer) val.get(1)).intValue();
87
                int u = 0;
88
                //TODO Revisar que valores puede tomar el campo version
89
                if(dic.getVersion() == "Autocad R14"){
90
                        val = DwgUtil.getRawChar(data, bitPos);
91
                        bitPos = ((Integer) val.get(0)).intValue();
92
                        u = ((Integer) val.get(1)).intValue();
93
                }
94
                String[] texts = null;
95
                if(ni > 0){
96
                        texts = new String[ni];
97
                        for(int i = 0; i < ni; i++){
98
                                val = DwgUtil.getTextString(data, bitPos);
99
                                bitPos = ((Integer) val.get(0)).intValue();
100
                                texts[i] = (String) val.get(1);
101
                        }//for
102
                }
103
                
104
                DwgHandleReference handle = new DwgHandleReference();
105
                bitPos = handle.read(data, bitPos);
106
                dic.setParentHandle(handle);
107
                
108
                for (int i = 0; i < nr; i++){
109
                        handle = new DwgHandleReference();
110
                        bitPos = handle.read(data, bitPos);
111
                        dic.addReactorHandle(handle);
112
                }
113
                
114
                handle = new DwgHandleReference();
115
                bitPos = handle.read(data, bitPos);
116
                dic.setXDicObjHandle(handle);
117
                
118
                if(ni > 0){
119
                        for(int i = 0; i < ni; i++){
120
                                handle = new DwgHandleReference();
121
                                bitPos = handle.read(data, bitPos);
122
                                
123
                                dic.put(texts[i], handle);
124
                        }
125
                }
126
        }
127

    
128

    
129
}
130