Revision 356

View differences:

tags/org.gvsig.dwg-2.0.82/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/util/TextToUnicodeConverter.java
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 org.gvsig.dwg.lib.util;
36

  
37
import java.text.StringCharacterIterator;
38

  
39
/**
40
 * This class allows to convert an Autocad text in an Unicode text
41
 * 
42
 * @author jmorell
43
 */
44
public class TextToUnicodeConverter {
45
    
46
    /**
47
     * This method allows to convert an Autocad text in an Unicode text
48
     * 
49
     * @param s Autocad text
50
     * @return String Unicode text
51
     */
52
	public static String convertText(String s) {
53
        StringCharacterIterator stringcharacteriterator = new StringCharacterIterator(s);
54
        StringBuffer stringbuffer = new StringBuffer();
55
        int ai[] = new int[s.length()];
56
        int i = 0;
57
        int j = 0;
58
        for(char c = stringcharacteriterator.first(); c != '\uFFFF'; c = stringcharacteriterator.next())
59
            if(c == '%')
60
            {
61
                c = stringcharacteriterator.next();
62
                if(c != '%')
63
                {
64
                    stringbuffer.append('%');
65
                    c = stringcharacteriterator.previous();
66
                } else
67
                {
68
                    c = stringcharacteriterator.next();
69
                    switch(c)
70
                    {
71
                    case 37: // '%'
72
                        stringbuffer.append('%');
73
                        break;
74

  
75
                    case 80: // 'P'
76
                    case 112: // 'p'
77
                        stringbuffer.append('\361');
78
                        break;
79

  
80
                    case 67: // 'C'
81
                    case 99: // 'c'
82
                        stringbuffer.append('\355');
83
                        break;
84

  
85
                    case 68: // 'D'
86
                    case 100: // 'd'
87
                        stringbuffer.append('\u00b0');
88
                        break;
89

  
90
                    case 85: // 'U'
91
                    case 117: // 'u'
92
                        ai[stringbuffer.length()] ^= 1;
93
                        i++;
94
                        break;
95

  
96
                    case 79: // 'O'
97
                    case 111: // 'o'
98
                        ai[stringbuffer.length()] ^= 2;
99
                        j++;
100
                        break;
101

  
102
                    default:
103
                        if(c >= '0' && c <= '9')
104
                        {
105
                            int k = 3;
106
                            char c1 = (char)(c - 48);
107
                            for(c = stringcharacteriterator.next(); c >= '0' && c <= '9' && --k > 0; c = stringcharacteriterator.next())
108
                                c1 = (char)(10 * c1 + (c - 48));
109

  
110
                            stringbuffer.append(c1);
111
                        }
112
                        c = stringcharacteriterator.previous();
113
                        break;
114
                    }
115
                }
116
            } else
117
            if(c == '^')
118
            {
119
                c = stringcharacteriterator.next();
120
                if(c == ' ')
121
                    stringbuffer.append('^');
122
            } else
123
            {
124
                stringbuffer.append(c);
125
            }
126
        s = Unicode.char2DOS437(stringbuffer, 2, '?');
127

  
128
		String ss = s;
129
		return ss;
130
	}
131
}
tags/org.gvsig.dwg-2.0.82/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/util/Unicode.java
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 org.gvsig.dwg.lib.util;
36

  
37
/**
38
 * Class that contains the tables for Autocad to Unicode text conversions
39
 * 
40
 * @author jmorell
41
 */
42
class Unicode {
43
    private static final char UCNONE = 65535;
44
    private static final char unicode[][] = {
45
        {
46
            '\0', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', 
47
            '\n', '\013', '\f', '\r', '\016', '\017', '\020', '\021', '\022', '\023', 
48
            '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', 
49
            '\036', '\037', ' ', '!', '"', '#', '$', '%', '&', '\'', 
50
            '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', 
51
            '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 
52
            '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 
53
            'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
54
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 
55
            'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 
56
            'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
57
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
58
            'x', 'y', 'z', '{', '|', '}', '~', '\177', '\200', '\201', 
59
            '\202', '\203', '\204', '\205', '\206', '\207', '\210', '\211', '\212', '\213', 
60
            '\214', '\215', '\216', '\217', '\220', '\221', '\222', '\223', '\224', '\225', 
61
            '\226', '\227', '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', 
62
            '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', '\250', '\251', 
63
            '\252', '\253', '\254', '\255', '\256', '\257', '\260', '\261', '\262', '\263', 
64
            '\264', '\265', '\266', '\267', '\270', '\271', '\272', '\273', '\274', '\275', 
65
            '\276', '\277', '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', 
66
            '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', '\320', '\321', 
67
            '\322', '\323', '\324', '\325', '\326', '\327', '\330', '\331', '\332', '\333', 
68
            '\334', '\335', '\336', '\337', '\340', '\341', '\342', '\343', '\344', '\345', 
69
            '\346', '\347', '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', 
70
            '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', '\370', '\371', 
71
            '\372', '\373', '\374', '\375', '\376', '\377'
72
        }, {
73
            '\0', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', 
74
            '\n', '\013', '\f', '\r', '\016', '\017', '\020', '\021', '\022', '\023', 
75
            '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', 
76
            '\036', '\037', ' ', '!', '"', '#', '$', '%', '&', '\'', 
77
            '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', 
78
            '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 
79
            '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 
80
            'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
81
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 
82
            'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 
83
            'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
84
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
85
            'x', 'y', 'z', '{', '|', '}', '~', '\177', '\200', '\201', 
86
            '\202', '\203', '\204', '\205', '\206', '\207', '\210', '\211', '\212', '\213', 
87
            '\214', '\215', '\216', '\217', '\220', '\221', '\222', '\223', '\224', '\225', 
88
            '\226', '\227', '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', 
89
            '\240', '\u0104', '\u02D8', '\u0141', '\244', '\u013D', '\u015A', '\247', '\250', '\u0160', 
90
            '\u015E', '\u0164', '\u0179', '\255', '\u017D', '\u017B', '\260', '\u0105', '\u02DB', '\u0142', 
91
            '\264', '\u013E', '\u015B', '\u02C7', '\270', '\u0161', '\u015F', '\u0165', '\u017A', '\u02DD', 
92
            '\u017E', '\u017C', '\u0154', '\301', '\302', '\u0102', '\304', '\u0139', '\u0106', '\307', 
93
            '\u010C', '\311', '\u0118', '\313', '\u011A', '\315', '\316', '\u010E', '\u0110', '\u0143', 
94
            '\u0147', '\323', '\324', '\u0150', '\326', '\327', '\u0158', '\u016E', '\332', '\u0170', 
95
            '\334', '\335', '\u0162', '\337', '\u0155', '\341', '\342', '\u0103', '\344', '\u013A', 
96
            '\u0107', '\347', '\u010D', '\351', '\u0119', '\353', '\u011B', '\355', '\356', '\u010F', 
97
            '\u0111', '\u0144', '\u0148', '\363', '\364', '\u0151', '\366', '\367', '\u0159', '\u016F', 
98
            '\372', '\u0171', '\374', '\375', '\u0163', '\u02D9'
99
        }, {
100
            '\0', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', 
101
            '\n', '\013', '\f', '\r', '\016', '\017', '\020', '\021', '\022', '\023', 
102
            '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', 
103
            '\036', '\037', ' ', '!', '"', '#', '$', '%', '&', '\'', 
104
            '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', 
105
            '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 
106
            '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 
107
            'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
108
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 
109
            'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 
110
            'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
111
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
112
            'x', 'y', 'z', '{', '|', '}', '~', '\u2302', '\307', '\374', 
113
            '\351', '\342', '\344', '\340', '\345', '\347', '\352', '\353', '\350', '\357', 
114
            '\356', '\354', '\304', '\305', '\311', '\346', '\306', '\364', '\366', '\362', 
115
            '\373', '\371', '\377', '\326', '\334', '\242', '\243', '\245', '\u20A7', '\u0192', 
116
            '\341', '\355', '\363', '\372', '\361', '\321', '\252', '\272', '\277', '\u2310', 
117
            '\254', '\275', '\274', '\241', '\253', '\273', '\u2591', '\u2592', '\u2593', '\u2502', 
118
            '\u2524', '\u2561', '\u2562', '\u2556', '\u2555', '\u2563', '\u2551', '\u2557', '\u255D', '\u255C', 
119
            '\u255B', '\u2510', '\u2514', '\u2534', '\u252C', '\u251C', '\u2500', '\u253C', '\u255E', '\u255F', 
120
            '\u255A', '\u2554', '\u2569', '\u2566', '\u2560', '\u2550', '\u256C', '\u2567', '\u2568', '\u2564', 
121
            '\u2565', '\u2559', '\u2558', '\u2552', '\u2553', '\u256B', '\u256A', '\u2518', '\u250C', '\u2588', 
122
            '\u2584', '\u258C', '\u2590', '\u2580', '\u03B1', '\337', '\u0393', '\u03C0', '\u03A3', '\u03C3', 
123
            '\265', '\u03C4', '\u03A6', '\u0398', '\u03A9', '\u03B4', '\u221E', '\u03C6', '\u03B5', '\u2229', 
124
            '\u2261', '\261', '\u2265', '\u2264', '\u2320', '\u2321', '\367', '\u2248', '\260', '\u2219', 
125
            '\267', '\u221A', '\u207F', '\262', '\u25A0', '\240'
126
        }, {
127
            '\0', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', 
128
            '\n', '\013', '\f', '\r', '\016', '\017', '\020', '\021', '\022', '\023', 
129
            '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', 
130
            '\036', '\037', ' ', '!', '"', '#', '$', '%', '&', '\'', 
131
            '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', 
132
            '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 
133
            '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 
134
            'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
135
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 
136
            'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 
137
            'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
138
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
139
            'x', 'y', 'z', '{', '|', '}', '~', '\u2302', '\307', '\374', 
140
            '\351', '\342', '\344', '\340', '\345', '\347', '\352', '\353', '\350', '\357', 
141
            '\356', '\354', '\304', '\305', '\311', '\346', '\306', '\364', '\366', '\362', 
142
            '\373', '\371', '\377', '\326', '\334', '\370', '\243', '\330', '\327', '\u0192', 
143
            '\341', '\355', '\363', '\372', '\361', '\321', '\252', '\272', '\277', '\256', 
144
            '\254', '\275', '\274', '\241', '\253', '\273', '\u2591', '\u2592', '\u2593', '\u2502', 
145
            '\u2524', '\301', '\302', '\300', '\251', '\u2563', '\u2551', '\u2557', '\u255D', '\242', 
146
            '\245', '\u2510', '\u2514', '\u2534', '\u252C', '\u251C', '\u2500', '\u253C', '\343', '\303', 
147
            '\u255A', '\u2554', '\u2569', '\u2566', '\u2560', '\u2550', '\u256C', '\244', '\360', '\320', 
148
            '\312', '\313', '\310', '\u0131', '\315', '\316', '\317', '\u2518', '\u250C', '\u2588', 
149
            '\u2584', '\246', '\314', '\u2580', '\323', '\337', '\324', '\322', '\365', '\325', 
150
            '\265', '\376', '\336', '\332', '\333', '\331', '\375', '\335', '\257', '\264', 
151
            '\255', '\261', '\u2017', '\276', '\266', '\247', '\367', '\270', '\260', '\250', 
152
            '\267', '\271', '\263', '\262', '\u25A0', '\240'
153
        }, {
154
            '\0', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', 
155
            '\n', '\013', '\f', '\r', '\016', '\017', '\020', '\021', '\022', '\023', 
156
            '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', 
157
            '\036', '\037', ' ', '!', '"', '#', '$', '%', '&', '\'', 
158
            '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', 
159
            '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 
160
            '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 
161
            'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
162
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 
163
            'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 
164
            'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
165
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
166
            'x', 'y', 'z', '{', '|', '}', '~', '\u2302', '\307', '\374', 
167
            '\351', '\342', '\344', '\u016F', '\u0107', '\347', '\u0142', '\353', '\u0150', '\u0151', 
168
            '\356', '\u0179', '\304', '\u0106', '\311', '\u0139', '\u013A', '\364', '\366', '\u013D', 
169
            '\u013E', '\u015A', '\u015B', '\326', '\334', '\u0164', '\u0165', '\u0141', '\327', '\u010D', 
170
            '\341', '\355', '\363', '\372', '\u0104', '\u0105', '\u017D', '\u017E', '\u0118', '\u0119', 
171
            '\254', '\u017A', '\u010C', '\u015F', '\253', '\273', '\u2591', '\u2592', '\u2593', '\u2502', 
172
            '\u2524', '\301', '\302', '\u011A', '\u015E', '\u2563', '\u2551', '\u2557', '\u255D', '\u017B', 
173
            '\u017C', '\u2510', '\u2514', '\u2534', '\u252C', '\u251C', '\u2500', '\u253C', '\u0102', '\u0103', 
174
            '\u255A', '\u2554', '\u2569', '\u2566', '\u2560', '\u2550', '\u256C', '\244', '\u0111', '\u0110', 
175
            '\u010E', '\313', '\u010F', '\u0147', '\315', '\316', '\u011B', '\u2518', '\u250C', '\u2588', 
176
            '\u2584', '\u0162', '\u016E', '\u2580', '\323', '\337', '\324', '\u0143', '\u0144', '\u0148', 
177
            '\u0160', '\u0161', '\u0154', '\332', '\u0155', '\u0170', '\375', '\335', '\u0163', '\264', 
178
            '\255', '\u02DD', '\u02DB', '\u02C7', '\u02D8', '\247', '\367', '\270', '\260', '\250', 
179
            '\u02D9', '\u0171', '\u0158', '\u0159', '\u25A0', '\240'
180
        }, {
181
            '\0', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', 
182
            '\n', '\013', '\f', '\r', '\016', '\017', '\020', '\021', '\022', '\023', 
183
            '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', 
184
            '\036', '\037', ' ', '!', '"', '#', '$', '%', '&', '\'', 
185
            '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', 
186
            '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 
187
            '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 
188
            'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
189
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 
190
            'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 
191
            'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
192
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
193
            'x', 'y', 'z', '{', '|', '}', '~', '\u2302', '\u0452', '\u0402', 
194
            '\u0453', '\u0403', '\u0451', '\u0401', '\u0454', '\u0404', '\u0455', '\u0405', '\u0456', '\u0406', 
195
            '\u0457', '\u0407', '\u0456', '\u0408', '\u0459', '\u0409', '\u045A', '\u040A', '\u045B', '\u040B', 
196
            '\u045C', '\u040C', '\u045E', '\u040E', '\u045F', '\u040F', '\u044E', '\u042E', '\u044A', '\u042A', 
197
            '\u0430', '\u0410', '\u0431', '\u0411', '\u0446', '\u0426', '\u0434', '\u0414', '\u0435', '\u0415', 
198
            '\u0444', '\u0424', '\u0433', '\u0413', '\253', '\273', '\u2591', '\u2592', '\u2593', '\u2502', 
199
            '\u2524', '\u0445', '\u0425', '\u0438', '\u0418', '\u2563', '\u2551', '\u2557', '\u255D', '\u0439', 
200
            '\u0419', '\u2510', '\u2514', '\u2534', '\u252C', '\u251C', '\u2500', '\u253C', '\u043A', '\u041A', 
201
            '\u255A', '\u2554', '\u2569', '\u2566', '\u2560', '\u2550', '\u256C', '\244', '\u043B', '\u041B', 
202
            '\u043C', '\u041C', '\u043D', '\u041D', '\u043E', '\u041E', '\u043F', '\u2518', '\u250C', '\u2588', 
203
            '\u2584', '\u041F', '\u044F', '\u2580', '\u042F', '\u0440', '\u0420', '\u0441', '\u0421', '\u0442', 
204
            '\u0422', '\u0443', '\u0423', '\u0436', '\u0416', '\u0432', '\u0412', '\u044C', '\u042C', '\u2116', 
205
            '\255', '\u044B', '\u042B', '\u0437', '\u0417', '\u0448', '\u0428', '\u044D', '\u042D', '\u0449', 
206
            '\u0429', '\u0447', '\u0427', '\uFFFF', '\u25A0', '\240'
207
        }, {
208
            '\0', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', 
209
            '\n', '\013', '\f', '\r', '\016', '\017', '\020', '\021', '\022', '\023', 
210
            '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', 
211
            '\036', '\037', ' ', '!', '"', '#', '$', '%', '&', '\'', 
212
            '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', 
213
            '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 
214
            '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 
215
            'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
216
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 
217
            'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 
218
            'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
219
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
220
            'x', 'y', 'z', '{', '|', '}', '~', '\u2302', '\307', '\374', 
221
            '\351', '\342', '\344', '\340', '\345', '\347', '\352', '\353', '\350', '\357', 
222
            '\356', '\u0131', '\304', '\305', '\311', '\346', '\306', '\364', '\366', '\362', 
223
            '\373', '\371', '\u0130', '\326', '\334', '\370', '\243', '\330', '\u015E', '\u015F', 
224
            '\341', '\355', '\363', '\372', '\361', '\321', '\u011E', '\u011F', '\277', '\256', 
225
            '\254', '\275', '\274', '\241', '\253', '\273', '\u2591', '\u2592', '\u2593', '\u2502', 
226
            '\u2524', '\301', '\302', '\300', '\251', '\u2563', '\u2551', '\u2557', '\u255D', '\242', 
227
            '\245', '\u2510', '\u2514', '\u2534', '\u252C', '\u251C', '\u2500', '\u253C', '\343', '\303', 
228
            '\u255A', '\u2554', '\u2569', '\u2566', '\u2560', '\u2550', '\u256C', '\244', '\272', '\252', 
229
            '\312', '\313', '\310', '\uFFFF', '\315', '\316', '\317', '\u2518', '\u250C', '\u2588', 
230
            '\u2584', '\246', '\314', '\u2580', '\323', '\337', '\324', '\322', '\365', '\325', 
231
            '\265', '\uFFFF', '\327', '\332', '\333', '\331', '\354', '\377', '\257', '\264', 
232
            '\255', '\261', '\uFFFF', '\276', '\266', '\247', '\367', '\270', '\260', '\250', 
233
            '\267', '\271', '\263', '\262', '\u25A0', '\240'
234
        }, {
235
            '\0', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', 
236
            '\n', '\013', '\f', '\r', '\016', '\017', '\020', '\021', '\022', '\023', 
237
            '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', 
238
            '\036', '\037', ' ', '!', '"', '#', '$', '%', '&', '\'', 
239
            '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', 
240
            '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 
241
            '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 
242
            'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
243
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 
244
            'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 
245
            'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
246
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
247
            'x', 'y', 'z', '{', '|', '}', '~', '\u2302', '\307', '\374', 
248
            '\351', '\342', '\343', '\340', '\301', '\347', '\352', '\312', '\350', '\315', 
249
            '\324', '\354', '\303', '\302', '\311', '\300', '\310', '\364', '\365', '\362', 
250
            '\332', '\371', '\314', '\325', '\334', '\242', '\243', '\331', '\u20A7', '\323', 
251
            '\341', '\355', '\363', '\372', '\361', '\321', '\252', '\272', '\277', '\322', 
252
            '\254', '\275', '\274', '\241', '\253', '\273', '\u2591', '\u2592', '\u2593', '\u2502', 
253
            '\u2524', '\u2561', '\u2562', '\u2556', '\u2555', '\u2563', '\u2551', '\u2557', '\u255D', '\u255C', 
254
            '\u255B', '\u2510', '\u2514', '\u2534', '\u252C', '\u251C', '\u2500', '\u253C', '\u255E', '\u255F', 
255
            '\u255A', '\u2554', '\u2569', '\u2566', '\u2560', '\u2550', '\u256C', '\u2567', '\u2568', '\u2564', 
256
            '\u2565', '\u2559', '\u2558', '\u2552', '\u2553', '\u256B', '\u256A', '\u2518', '\u250C', '\u2588', 
257
            '\u2584', '\u258C', '\u2590', '\u2580', '\u03B1', '\337', '\u0393', '\u03C0', '\u03A3', '\u03C3', 
258
            '\265', '\u03C4', '\u03A6', '\u0398', '\u03A9', '\u03B4', '\u221E', '\u03C6', '\u03B5', '\u2229', 
259
            '\u2261', '\261', '\u2265', '\u2264', '\u2320', '\u2321', '\367', '\u2248', '\260', '\u2219', 
260
            '\267', '\u221A', '\u207F', '\262', '\u25A0', '\240'
261
        }, {
262
            '\0', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', 
263
            '\n', '\013', '\f', '\r', '\016', '\017', '\020', '\021', '\022', '\023', 
264
            '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', 
265
            '\036', '\037', ' ', '!', '"', '#', '$', '%', '&', '\'', 
266
            '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', 
267
            '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 
268
            '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 
269
            'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
270
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 
271
            'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 
272
            'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
273
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
274
            'x', 'y', 'z', '{', '|', '}', '~', '\u2302', '\307', '\374', 
275
            '\351', '\342', '\343', '\340', '\345', '\347', '\352', '\353', '\350', '\320', 
276
            '\360', '\336', '\304', '\305', '\311', '\346', '\306', '\364', '\366', '\376', 
277
            '\373', '\335', '\375', '\326', '\334', '\370', '\243', '\330', '\u20A7', '\u0192', 
278
            '\341', '\355', '\363', '\372', '\301', '\315', '\323', '\332', '\277', '\u2310', 
279
            '\254', '\275', '\274', '\241', '\253', '\273', '\u2591', '\u2592', '\u2593', '\u2502', 
280
            '\u2524', '\u2561', '\u2562', '\u2556', '\u2555', '\u2563', '\u2551', '\u2557', '\u255D', '\u255C', 
281
            '\u255B', '\u2510', '\u2514', '\u2534', '\u252C', '\u251C', '\u2500', '\u253C', '\u255E', '\u255F', 
282
            '\u255A', '\u2554', '\u2569', '\u2566', '\u2560', '\u2550', '\u256C', '\u2567', '\u2568', '\u2564', 
283
            '\u2565', '\u2559', '\u2558', '\u2552', '\u2553', '\u256B', '\u256A', '\u2518', '\u250C', '\u2588', 
284
            '\u2584', '\u258C', '\u2590', '\u2580', '\u03B1', '\337', '\u0393', '\u03C0', '\u03A3', '\u03C3', 
285
            '\265', '\u03C4', '\u03A6', '\u0398', '\u03A9', '\u03B4', '\u221E', '\u03C6', '\u03B5', '\u2229', 
286
            '\u2261', '\261', '\u2265', '\u2264', '\u2320', '\u2321', '\367', '\u2248', '\260', '\u2219', 
287
            '\267', '\u221A', '\u207F', '\262', '\u25A0', '\240'
288
        }, {
289
            '\0', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', 
290
            '\n', '\013', '\f', '\r', '\016', '\017', '\020', '\021', '\022', '\023', 
291
            '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', 
292
            '\036', '\037', ' ', '!', '"', '#', '$', '%', '&', '\'', 
293
            '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', 
294
            '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 
295
            '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 
296
            'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
297
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 
298
            'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 
299
            'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
300
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
301
            'x', 'y', 'z', '{', '|', '}', '~', '\u2302', '\307', '\374', 
302
            '\351', '\342', '\343', '\340', '\266', '\347', '\352', '\353', '\350', '\357', 
303
            '\356', '\u2017', '\300', '\247', '\311', '\310', '\312', '\364', '\313', '\317', 
304
            '\373', '\371', '\244', '\324', '\334', '\242', '\243', '\331', '\333', '\u0192', 
305
            '\246', '\264', '\363', '\372', '\250', '\270', '\263', '\257', '\316', '\u2310', 
306
            '\254', '\275', '\274', '\276', '\253', '\273', '\u2591', '\u2592', '\u2593', '\u2502', 
307
            '\u2524', '\u2561', '\u2562', '\u2556', '\u2555', '\u2563', '\u2551', '\u2557', '\u255D', '\u255C', 
308
            '\u255B', '\u2510', '\u2514', '\u2534', '\u252C', '\u251C', '\u2500', '\u253C', '\u255E', '\u255F', 
309
            '\u255A', '\u2554', '\u2569', '\u2566', '\u2560', '\u2550', '\u256C', '\u2567', '\u2568', '\u2564', 
310
            '\u2565', '\u2559', '\u2558', '\u2552', '\u2553', '\u256B', '\u256A', '\u2518', '\u250C', '\u2588', 
311
            '\u2584', '\u258C', '\u2590', '\u2580', '\u03B1', '\337', '\u0393', '\u03C0', '\u03A3', '\u03C3', 
312
            '\265', '\u03C4', '\u03A6', '\u0398', '\u03A9', '\u03B4', '\u221E', '\u03C6', '\u03B5', '\u2229', 
313
            '\u2261', '\261', '\u2265', '\u2264', '\u2320', '\u2321', '\367', '\u2248', '\260', '\u2219', 
314
            '\267', '\u221A', '\u207F', '\262', '\u25A0', '\240'
315
        }, {
316
            '\0', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', 
317
            '\n', '\013', '\f', '\r', '\016', '\017', '\020', '\021', '\022', '\023', 
318
            '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', 
319
            '\036', '\037', ' ', '!', '"', '#', '$', '%', '&', '\'', 
320
            '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', 
321
            '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 
322
            '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 
323
            'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
324
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 
325
            'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 
326
            'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
327
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
328
            'x', 'y', 'z', '{', '|', '}', '~', '\u2302', '\260', '\267', 
329
            '\u2219', '\u221A', '\u2592', '\u2500', '\u2502', '\u253C', '\u2524', '\u252C', '\u251C', '\u2534', 
330
            '\u2510', '\u250C', '\u2514', '\u2518', '\u03B2', '\u221E', '\u03C6', '\261', '\275', '\274', 
331
            '\u2248', '\253', '\273', '\uFEF7', '\uFEF8', '\uFFFF', '\uFFFF', '\uFEFB', '\uFEFC', '\uFFFF', 
332
            '\240', '\255', '\uFE82', '\243', '\244', '\uFE84', '\uFFFF', '\uFFFF', '\uFE8E', '\uFE8F', 
333
            '\uFE95', '\uFE99', '\u060C', '\uFE9D', '\uFEA1', '\uFEA5', '\u0660', '\u0661', '\u0662', '\u0663', 
334
            '\u0664', '\u0665', '\u0666', '\u0667', '\u0668', '\u0669', '\uFED1', '\u061B', '\uFEB1', '\uFEB5', 
335
            '\uFEB9', '\u061F', '\242', '\uFE80', '\uFE81', '\uFE83', '\uFE85', '\uFECC', '\uFE8A', '\uFE8D', 
336
            '\uFE90', '\uFE93', '\uFE96', '\uFE9A', '\uFE9E', '\uFEA2', '\uFEA6', '\uFEA9', '\uFEAB', '\uFEAD', 
337
            '\uFEAF', '\uFEB2', '\uFEB6', '\uFEBA', '\uFEBE', '\uFEC1', '\uFEC5', '\uFECA', '\uFECE', '\246', 
338
            '\254', '\367', '\327', '\uFEC9', '\u0640', '\uFED2', '\uFED6', '\uFEDA', '\uFEDE', '\uFEE2', 
339
            '\uFEE6', '\uFEEA', '\uFEED', '\uFEEF', '\uFEF2', '\uFEBD', '\uFECB', '\uFED0', '\uFECD', '\uFEE1', 
340
            '\uFE7D', '\u0651', '\uFEE5', '\uFEE9', '\uFEEB', '\uFEF0', '\uFEF4', '\uFECF', '\uFED5', '\uFEF5', 
341
            '\uFEF6', '\uFEDD', '\uFED9', '\uFEF1', '\u25A0', '\uFFFF'
342
        }, {
343
            '\0', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', 
344
            '\n', '\013', '\f', '\r', '\016', '\017', '\020', '\021', '\022', '\023', 
345
            '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', 
346
            '\036', '\037', ' ', '!', '"', '#', '$', '%', '&', '\'', 
347
            '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', 
348
            '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 
349
            '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 
350
            'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
351
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 
352
            'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 
353
            'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
354
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
355
            'x', 'y', 'z', '{', '|', '}', '~', '\u2302', '\307', '\374', 
356
            '\351', '\342', '\344', '\340', '\265', '\347', '\352', '\353', '\350', '\357', 
357
            '\356', '\354', '\304', '\305', '\311', '\346', '\306', '\364', '\366', '\362', 
358
            '\373', '\371', '\377', '\326', '\334', '\370', '\243', '\330', '\u20A7', '\u0192', 
359
            '\341', '\355', '\363', '\372', '\361', '\321', '\252', '\272', '\277', '\u2310', 
360
            '\254', '\275', '\274', '\241', '\253', '\244', '\u2591', '\u2592', '\u2593', '\u2502', 
361
            '\u2524', '\u2561', '\u2562', '\u2556', '\u2555', '\u2563', '\u2551', '\u2557', '\u255D', '\u255C', 
362
            '\u255B', '\u2510', '\u2514', '\u2534', '\u252C', '\u251C', '\u2500', '\u253C', '\u255E', '\u255F', 
363
            '\u255A', '\u2554', '\u2569', '\u2566', '\u2560', '\u2550', '\u256C', '\u2567', '\u2568', '\u2564', 
364
            '\u2565', '\u2559', '\u2558', '\u2552', '\u2553', '\u256B', '\u256A', '\u2518', '\u250C', '\u2588', 
365
            '\u2584', '\u258C', '\u2590', '\u2580', '\u03B1', '\337', '\u0393', '\u03C0', '\u03A3', '\u03C3', 
366
            '\265', '\u03C4', '\u03A6', '\u0398', '\u03A9', '\u03B4', '\u221E', '\u03C6', '\u03B5', '\u2229', 
367
            '\u2261', '\261', '\u2265', '\u2264', '\u2320', '\u2321', '\367', '\u2248', '\260', '\u2219', 
368
            '\267', '\u221A', '\u207F', '\262', '\u25A0', '\240'
369
        }, {
370
            '\0', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', 
371
            '\n', '\013', '\f', '\r', '\016', '\017', '\020', '\021', '\022', '\023', 
372
            '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', 
373
            '\036', '\037', ' ', '!', '"', '#', '$', '%', '&', '\'', 
374
            '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', 
375
            '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 
376
            '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 
377
            'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
378
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 
379
            'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 
380
            'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
381
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
382
            'x', 'y', 'z', '{', '|', '}', '~', '\u2302', '\uFFFF', '\uFFFF', 
383
            '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\u0386', '\uFFFF', '\267', '\254', '\246', '\u2018', 
384
            '\u2019', '\u0388', '\u2015', '\u0389', '\u038A', '\u03AA', '\u038C', '\uFFFF', '\uFFFF', '\u038E', 
385
            '\u03AB', '\251', '\u038F', '\262', '\263', '\u03AC', '\243', '\u03AD', '\u03AE', '\u03AF', 
386
            '\u03CA', '\u0390', '\u03CC', '\u03CD', '\u0391', '\u0392', '\u0393', '\u0394', '\u0395', '\u0396', 
387
            '\u0397', '\275', '\u0398', '\u0399', '\253', '\273', '\u2591', '\u2592', '\u2593', '\u2502', 
388
            '\u2524', '\u039A', '\u039B', '\u039C', '\u039D', '\u2563', '\u2551', '\u2557', '\u255D', '\u039E', 
389
            '\u039F', '\u2510', '\u2514', '\u2534', '\u252C', '\u251C', '\u2500', '\u253C', '\u03A0', '\u03A1', 
390
            '\u255A', '\u2554', '\u2569', '\u2566', '\u2560', '\u2550', '\u256C', '\u03A3', '\u03A4', '\u03A5', 
391
            '\u03A6', '\u03A7', '\u03A8', '\u03A9', '\u03B1', '\u03B2', '\u03B3', '\u2518', '\u250C', '\u2588', 
392
            '\u2584', '\u03B4', '\u03B5', '\u2580', '\u03B6', '\u03B7', '\u03B8', '\u03B9', '\u03BA', '\u03BB', 
393
            '\u03BC', '\u03BD', '\u03BE', '\u03BF', '\u03C0', '\u03C1', '\u03C3', '\u03C2', '\u03C4', '\264', 
394
            '\255', '\261', '\u03C5', '\u03C6', '\u03C7', '\247', '\u03C8', '\u03F4', '\260', '\250', 
395
            '\u03C9', '\u03CB', '\u03B0', '\u03CE', '\u25A0', '\240'
396
        }, {
397
            '\0', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', 
398
            '\n', '\013', '\f', '\r', '\016', '\017', '\020', '\021', '\022', '\023', 
399
            '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', 
400
            '\036', '\037', ' ', '!', '"', '#', '$', '%', '&', '\'', 
401
            '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', 
402
            '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', 
403
            '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 
404
            'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 
405
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 
406
            'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 
407
            'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 
408
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
409
            'x', 'y', 'z', '{', '|', '}', '~', '\177', '\304', '\305', 
410
            '\307', '\311', '\321', '\326', '\334', '\341', '\340', '\342', '\344', '\343', 
411
            '\345', '\347', '\351', '\350', '\352', '\353', '\355', '\354', '\356', '\357', 
412
            '\361', '\363', '\362', '\364', '\366', '\365', '\372', '\371', '\373', '\374', 
413
            '\u2020', '\260', '\242', '\243', '\247', '\u2022', '\266', '\337', '\256', '\251', 
414
            '\u2122', '\264', '\250', '\u2260', '\306', '\330', '\u221E', '\261', '\u2264', '\u2265', 
415
            '\245', '\265', '\u2202', '\u2211', '\u220F', '\u03C0', '\u222B', '\252', '\272', '\u2126', 
416
            '\346', '\370', '\277', '\241', '\254', '\u221A', '\u0192', '\u2248', '\u2206', '\253', 
417
            '\273', '\u2026', '\240', '\300', '\303', '\325', '\u0152', '\u0153', '\u2010', '\u2014', 
418
            '\u201C', '\u201D', '\u2018', '\u2019', '\367', '\u25CA', '\377', '\u0178', '\u2044', '\244', 
419
            '\u2039', '\u203A', 'f', 'f', '\u2021', '\267', '\u201A', '\u201E', '\u2030', '\302', 
420
            '\312', '\301', '\313', '\310', '\315', '\316', '\317', '\314', '\323', '\324', 
421
            '\uFDFF', '\322', '\332', '\333', '\331', '\u0131', '\u02C6', '\u02DC', '\257', '\u02D8', 
422
            '\u02D9', '\u02DA', '\270', '\u02DD', '\u02DB', '\u02C7'
423
        }
424
    };
425
    private static char unicode2DOS437[];
426
	
427
    /**
428
     * Char to DOS437 converter
429
     * 
430
     * @param stringbuffer
431
     * @param i
432
     * @param c
433
     * @return String 
434
     */
435
    public static String char2DOS437(StringBuffer stringbuffer, int i, char c)
436
    {
437
        if(unicode2DOS437 == null)
438
        {
439
            unicode2DOS437 = new char[0x10000];
440
            for(int j = 0; j < 256; j++)
441
            {
442
                char c1;
443
                if((c1 = unicode[2][j]) != '\uFFFF')
444
                    unicode2DOS437[c1] = (char)j;
445
            }
446

  
447
        }
448
        if(i != 2)
449
        {
450
            StringBuffer stringbuffer1 = new StringBuffer(stringbuffer.length());
451
            for(int k = 0; k < stringbuffer.length(); k++)
452
            {
453
                char c2 = unicode2DOS437[stringbuffer.charAt(k)];
454
                stringbuffer1.append(c2 == 0 ? c : c2);
455
            }
456

  
457
            return new String(stringbuffer1);
458
        } else
459
        {
460
            return new String(stringbuffer);
461
        }
462
    }
463
}
tags/org.gvsig.dwg-2.0.82/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/util/AcadColor.java
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 org.gvsig.dwg.lib.util;
36

  
37
import java.awt.Color;
38

  
39
/**
40
 * This class allows to convert Autocad colors in Java colors
41
 * 
42
 * @author jmorell
43
 */
44
public class AcadColor {
45
    /**
46
     * When Autocad color is 256, then the color of the object is the color of it
47
     * layer
48
     */
49
	public final static int BYLAYER = 256;
50
    /**
51
     * When Autocad color is 0, then the color of the object is the color of the
52
     * block where it is placed
53
     */
54
	public final static int BYBLOCK = 0;
55
	private static AcadColor[] colors = initTable();
56
	private int code;
57
	private float r0, g0, b0;
58
	private int r, g, b;
59
	private Color color = null;
60
	
61
	/**
62
	 * This method is used to build the Autocad color table
63
	 * 
64
	 * @param code Code is the Autocad color number
65
	 * @param r0 r0 is the red component (0-1)
66
	 * @param g0 g0 is the green component (0-1)
67
	 * @param b0 b0 is the blue component (0-1)
68
	 * @param r r0 is the red component (0-255)
69
	 * @param g g0 is the green component (0-255)
70
	 * @param b b0 is the blue component (0-255)
71
	 */
72
	public AcadColor(int code, double r0, double g0, double b0, double r, double g, double b) {
73
		this.code = code;
74
		this.r0 = (float) r0; this.g0 = (float) g0; this.b0 = (float) b0;
75
		this.r = (int) r; this.g = (int) g; this.b = (int) b;
76
		this.color = new Color(this.r, this.g, this.b);
77
		colors[code] = this;
78
	}
79
	
80
	/**
81
	 * This method uses Autocad color table for convert a color in the Autocad color
82
	 * code in a java Color
83
	 * 
84
	 * @param code This int is the Autocad color number
85
	 * @return Color Java Color corresponding to the Autocad color number argument
86
	 */
87
	public static Color getColor(int code) {
88
		return colors[code].color;
89
	}
90
	
91
	/**
92
	 * Initialize an Autocad color table
93
	 * 
94
	 * @return AcadColor[] Object of this class that represents Acad color to Java color
95
	 * 		   conversion
96
	 */
97
	public static AcadColor[] initTable() {
98
		colors = new AcadColor[256];
99

  
100
		new AcadColor(0, 0, 0, 0, 0, 0, 0);
101
		
102
		new AcadColor(1, 1, 0, 0, 255, 0, 0);
103
		new AcadColor(2, 1, 1, 0, 255, 255, 0);
104
		new AcadColor(3, 0, 1, 0, 0, 255, 0);
105
		new AcadColor(4, 0, 1, 1, 0, 255, 255);
106
		new AcadColor(5, 0, 0, 1, 0, 0, 255);
107
		new AcadColor(6, 1, 0, 1, 255, 0, 255);
108
		new AcadColor(7, 0, 0, 0, 0, 0, 0);
109
		new AcadColor(8, 0, 0, 0, 0, 0, 0);
110
		new AcadColor(9, 0, 0, 0, 0, 0, 0);
111
		new AcadColor(10, 1, 0, 0, 255, 0, 0);
112
		new AcadColor(11, 1.0, 0.5, 0.5, 255.0, 127.5, 127.5);
113
		new AcadColor(12, 0.65, 0, 0, 165.75, 0, 0);
114
		new AcadColor(13, 0.65, 0.325, 0.325, 165.75, 82.875, 82.875);
115
		new AcadColor(14, 0.5, 0, 0, 127.5, 0, 0);
116
		new AcadColor(15, 0.5, 0.25, 0.25, 127.5, 63.75, 63.75);
117
		new AcadColor(16, 0.3, 0, 0, 76.5, 0, 0);
118
		new AcadColor(17, 0.3, 0.15, 0.15, 76.5, 38.25, 38.25);
119
		new AcadColor(18, 0.15, 0, 0, 38.25, 0, 0);
120
		new AcadColor(19, 0.15, 0.075, 0.075, 38.25, 19.125, 19.125);
121
		new AcadColor(20, 1, 0.25, 0, 255, 63.75, 0);
122
		new AcadColor(21, 1, 0.625, 0.5, 255, 159.375, 127.5);
123
		new AcadColor(22, 0.65, 0.1625, 0, 165.75, 41.4375, 0);
124
		new AcadColor(23, 0.65, 0.4063, 0.325, 165.75, 103.6065, 82.875);
125
		new AcadColor(24, 0.5, 0.125, 0, 127.5, 31.875, 0);
126
		new AcadColor(25, 0.5, 0.3125, 0.25, 127.5, 79.6875, 63.75);
127
		new AcadColor(26, 0.3, 0.075, 0, 76.5, 19.125, 0);
128
		new AcadColor(27, 0.3, 0.1875, 0.15, 76.5, 47.8125, 38.25);
129
		new AcadColor(28, 0.15, 0.0375, 0, 38.25, 9.5625, 0);
130
		new AcadColor(29, 0.15, 0.0938, 0.075, 38.25, 23.919, 19.125);
131
		new AcadColor(30, 1, 0.5, 0, 255, 127.5, 0);
132
		new AcadColor(31, 1, 0.75, 0.5, 255, 191.25, 127.5);
133
		new AcadColor(32, 0.65, 0.325, 0, 165.75, 82.875, 0);
134
		new AcadColor(33, 0.65, 0.4875, 0.325, 165.75, 124.3125, 82.875);
135
		new AcadColor(34, 0.5, 0.25, 0, 127.5, 63.75, 0);
136
		new AcadColor(35, 0.5, 0.375, 0.25, 127.5, 95.625, 63.75);
137
		new AcadColor(36, 0.3, 0.15, 0, 76.5, 38.25, 0);
138
		new AcadColor(37, 0.3, 0.225, 0.15, 76.5, 57.375, 38.25);
139
		new AcadColor(38, 0.15, 0.075, 0, 38.25, 19.125, 0);
140
		new AcadColor(39, 0.15, 0.1125, 0.075, 38.25, 28.6875, 19.125);
141
		new AcadColor(40, 1, 0.75, 0, 255, 191.25, 0);
142
		new AcadColor(41, 1, 0.875, 0.5, 255, 223.125, 127.5);
143
		new AcadColor(42, 0.65, 0.4875, 0, 165.75, 124.3125, 0);
144
		new AcadColor(43, 0.65, 0.5688, 0.325, 165.75, 145.044, 82.875);
145
		new AcadColor(44, 0.5, 0.375, 0, 127.5, 95.625, 0);
146
		new AcadColor(45, 0.5, 0.4375, 0.25, 127.5, 111.5625, 63.75);
147
		new AcadColor(46, 0.3, 0.225, 0, 76.5, 57.375, 0);
148
		new AcadColor(47, 0.3, 0.2625, 0.15, 76.5, 66.9375, 38.25);
149
		new AcadColor(48, 0.15, 0.1125, 0, 38.25, 28.6875, 0);
150
		new AcadColor(49, 0.15, 0.1313, 0.075, 38.25, 33.4815, 19.125);
151
		new AcadColor(50, 1, 1, 0, 255, 255, 0);
152
		new AcadColor(51, 1, 1, 0.5, 255, 255, 127.5);
153
		new AcadColor(52, 0.65, 0.65, 0, 165.75, 165.75, 0);
154
		new AcadColor(53, 0.65, 0.65, 0.325, 165.75, 165.75, 82.875);
155
		new AcadColor(54, 0.5, 0.5, 0, 127.5, 127.5, 0);
156
		new AcadColor(55, 0.5, 0.5, 0.25, 127.5, 127.5, 63.75);
157
		new AcadColor(56, 0.3, 0.3, 0, 76.5, 76.5, 0);
158
		new AcadColor(57, 0.3, 0.3, 0.15, 76.5, 76.5, 38.25);
159
		new AcadColor(58, 0.15, 0.15, 0, 38.25, 38.25, 0);
160
		new AcadColor(59, 0.15, 0.15, 0.075, 38.25, 38.25, 19.125);
161
		new AcadColor(60, 0.75, 1, 0, 191.25, 255, 0);
162
		new AcadColor(61, 0.875, 1, 0.5, 223.125, 255, 127.5);
163
		new AcadColor(62, 0.4875, 0.65, 0, 124.3125, 165.75, 0);
164
		new AcadColor(63, 0.5688, 0.65, 0.325, 145.044, 165.75, 82.875);
165
		new AcadColor(64, 0.375, 0.5, 0, 95.625, 127.5, 0);
166
		new AcadColor(65, 0.4375, 0.5, 0.25, 111.5625, 127.5, 63.75);
167
		new AcadColor(66, 0.225, 0.3, 0, 57.375, 76.5, 0);
168
		new AcadColor(67, 0.2625, 0.3, 0.15, 66.9375, 76.5, 38.25);
169
		new AcadColor(68, 0.1125, 0.15, 0, 28.6875, 38.25, 0);
170
		new AcadColor(69, 0.1313, 0.15, 0.075, 33.4815, 38.25, 19.125);
171
		new AcadColor(70, 0.5, 1, 0, 127.5, 255, 0);
172
		new AcadColor(71, 0.75, 1, 0.5, 191.25, 255, 127.5);
173
		new AcadColor(72, 0.325, 0.65, 0, 82.875, 165.75, 0);
174
		new AcadColor(73, 0.4875, 0.65, 0.325, 124.3125, 165.75, 82.875);
175
		new AcadColor(74, 0.25, 0.5, 0, 63.75, 127.5, 0);
176
		new AcadColor(75, 0.375, 0.5, 0.25, 95.625, 127.5, 63.75);
177
		new AcadColor(76, 0.15, 0.3, 0, 38.25, 76.5, 0);
178
		new AcadColor(77, 0.225, 0.3, 0.15, 57.375, 76.5, 38.25);
179
		new AcadColor(78, 0.075, 0.15, 0, 19.125, 38.25, 0);
180
		new AcadColor(79, 0.1125, 0.15, 0.075, 28.6875, 38.25, 19.125);
181
		new AcadColor(80, 0.25, 1, 0, 63.75, 255, 0);
182
		new AcadColor(81, 0.625, 1, 0.5, 159.375, 255, 127.5);
183
		new AcadColor(82, 0.1625, 0.65, 0, 41.4375, 165.75, 0);
184
		new AcadColor(83, 0.4063, 0.65, 0.325, 103.6065, 165.75, 82.875);
185
		new AcadColor(84, 0.125, 0.5, 0, 31.875, 127.5, 0);
186
		new AcadColor(85, 0.3125, 0.5, 0.25, 79.6875, 127.5, 63.75);
187
		new AcadColor(86, 0.075, 0.3, 0, 19.125, 76.5, 0);
188
		new AcadColor(87, 0.1875, 0.3, 0.15, 47.8125, 76.5, 38.25);
189
		new AcadColor(88, 0.0375, 0.15, 0, 9.5625, 38.25, 0);
190
		new AcadColor(89, 0.0938, 0.15, 0.075, 23.919, 38.25, 19.125);
191
		new AcadColor(90, 0, 1, 0, 0, 255, 0);
192
		new AcadColor(91, 0.5, 1, 0.5, 127.5, 255, 127.5);
193
		new AcadColor(92, 0, 0.65, 0, 0, 165.75, 0);
194
		new AcadColor(93, 0.325, 0.65, 0.325, 82.875, 165.75, 82.875);
195
		new AcadColor(94, 0, 0.5, 0, 0, 127.5, 0);
196
		new AcadColor(95, 0.25, 0.5, 0.25, 63.75, 127.5, 63.75);
197
		new AcadColor(96, 0, 0.3, 0, 0, 76.5, 0);
198
		new AcadColor(97, 0.15, 0.3, 0.15, 38.25, 76.5, 38.25);
199
		new AcadColor(98, 0, 0.15, 0, 0, 38.25, 0);
200
		new AcadColor(99, 0.075, 0.15, 0.075, 19.125, 38.25, 19.125);
201
		new AcadColor(100, 0, 1, 0.25, 0, 255, 63.75);
202
		new AcadColor(101, 0.5, 1, 0.625, 127.5, 255, 159.375);
203
		new AcadColor(102, 0, 0.65, 0.1625, 0, 165.75, 41.4375);
204
		new AcadColor(103, 0.325, 0.65, 0.4063, 82.875, 165.75, 103.6065);
205
		new AcadColor(104, 0, 0.5, 0.125, 0, 127.5, 31.875);
206
		new AcadColor(105, 0.25, 0.5, 0.3125, 63.75, 127.5, 79.6875);
207
		new AcadColor(106, 0, 0.3, 0.075, 0, 76.5, 19.125);
208
		new AcadColor(107, 0.15, 0.3, 0.1875, 38.25, 76.5, 47.8125);
209
		new AcadColor(108, 0, 0.15, 0.0375, 0, 38.25, 9.5625);
210
		new AcadColor(109, 0.075, 0.15, 0.0938, 19.125, 38.25, 23.919);
211
		new AcadColor(110, 0, 1, 0.5, 0, 255, 127.5);
212
		new AcadColor(111, 0.5, 1, 0.75, 127.5, 255, 191.25);
213
		new AcadColor(112, 0, 0.65, 0.325, 0, 165.75, 82.875);
214
		new AcadColor(113, 0.325, 0.65, 0.4875, 82.875, 165.75, 124.3125);
215
		new AcadColor(114, 0, 0.5, 0.25, 0, 127.5, 63.75);
216
		new AcadColor(115, 0.25, 0.5, 0.375, 63.75, 127.5, 95.625);
217
		new AcadColor(116, 0, 0.3, 0.15, 0, 76.5, 38.25);
218
		new AcadColor(117, 0.15, 0.3, 0.225, 38.25, 76.5, 57.375);
219
		new AcadColor(118, 0, 0.15, 0.075, 0, 38.25, 19.125);
220
		new AcadColor(119, 0.075, 0.15, 0.1125, 19.125, 38.25, 28.6875);
221
		new AcadColor(120, 0, 1, 0.75, 0, 255, 191.25);
222
		new AcadColor(121, 0.5, 1, 0.875, 127.5, 255, 223.125);
223
		new AcadColor(122, 0, 0.65, 0.4875, 0, 165.75, 124.3125);
224
		new AcadColor(123, 0.325, 0.65, 0.5688, 82.875, 165.75, 145.044);
225
		new AcadColor(124, 0, 0.5, 0.375, 0, 127.5, 95.625);
226
		new AcadColor(125, 0.25, 0.5, 0.4375, 63.75, 127.5, 111.5625);
227
		new AcadColor(126, 0, 0.3, 0.225, 0, 76.5, 57.375);
228
		new AcadColor(127, 0.15, 0.3, 0.2625, 38.25, 76.5, 66.9375);
229
		new AcadColor(128, 0, 0.15, 0.1125, 0, 38.25, 28.6875);
230
		new AcadColor(129, 0.075, 0.15, 0.1313, 19.125, 38.25, 33.4815);
231
		new AcadColor(130, 0, 1, 1, 0, 255, 255);
232
		new AcadColor(131, 0.5, 1, 1, 127.5, 255, 255);
233
		new AcadColor(132, 0, 0.65, 0.65, 0, 165.75, 165.75);
234
		new AcadColor(133, 0.325, 0.65, 0.65, 82.875, 165.75, 165.75);
235
		new AcadColor(134, 0, 0.5, 0.5, 0, 127.5, 127.5);
236
		new AcadColor(135, 0.25, 0.5, 0.5, 63.75, 127.5, 127.5);
237
		new AcadColor(136, 0, 0.3, 0.3, 0, 76.5, 76.5);
238
		new AcadColor(137, 0.15, 0.3, 0.3, 38.25, 76.5, 76.5);
239
		new AcadColor(138, 0, 0.15, 0.15, 0, 38.25, 38.25);
240
		new AcadColor(139, 0.075, 0.15, 0.15, 19.125, 38.25, 38.25);
241
		new AcadColor(140, 0, 0.75, 1, 0, 191.25, 255);
242
		new AcadColor(141, 0.5, 0.875, 1, 127.5, 223.125, 255);
243
		new AcadColor(142, 0, 0.4875, 0.65, 0, 124.3125, 165.75);
244
		new AcadColor(143, 0.325, 0.5688, 0.65, 82.875, 145.044, 165.75);
245
		new AcadColor(144, 0, 0.375, 0.5, 0, 95.625, 127.5);
246
		new AcadColor(145, 0.25, 0.4375, 0.5, 63.75, 111.5625, 127.5);
247
		new AcadColor(146, 0, 0.225, 0.3, 0, 57.375, 76.5);
248
		new AcadColor(147, 0.15, 0.2625, 0.3, 38.25, 66.9375, 76.5);
249
		new AcadColor(148, 0, 0.1125, 0.15, 0, 28.6875, 38.25);
250
		new AcadColor(149, 0.075, 0.1313, 0.15, 19.125, 33.4815, 38.25);
251
		new AcadColor(150, 0, 0.5, 1, 0, 127.5, 255);
252
		new AcadColor(151, 0.5, 0.75, 1, 127.5, 191.25, 255);
253
		new AcadColor(152, 0, 0.325, 0.65, 0, 82.875, 165.75);
254
		new AcadColor(153, 0.325, 0.4875, 0.65, 82.875, 124.3125, 165.75);
255
		new AcadColor(154, 0, 0.25, 0.5, 0, 63.75, 127.5);
256
		new AcadColor(155, 0.25, 0.375, 0.5, 63.75, 95.625, 127.5);
257
		new AcadColor(156, 0, 0.15, 0.3, 0, 38.25, 76.5);
258
		new AcadColor(157, 0.15, 0.225, 0.3, 38.25, 57.375, 76.5);
259
		new AcadColor(158, 0, 0.075, 0.15, 0, 19.125, 38.25);
260
		new AcadColor(159, 0.075, 0.1125, 0.15, 19.125, 28.6875, 38.25);
261
		new AcadColor(160, 0, 0.25, 1, 0, 63.75, 255);
262
		new AcadColor(161, 0.5, 0.625, 1, 127.5, 159.375, 255);
263
		new AcadColor(162, 0, 0.1625, 0.65, 0, 41.4375, 165.75);
264
		new AcadColor(163, 0.325, 0.4063, 0.65, 82.875, 103.6065, 165.75);
265
		new AcadColor(164, 0, 0.125, 0.5, 0, 31.875, 127.5);
266
		new AcadColor(165, 0.25, 0.3125, 0.5, 63.75, 79.6875, 127.5);
267
		new AcadColor(166, 0, 0.075, 0.3, 0, 19.125, 76.5);
268
		new AcadColor(167, 0.15, 0.1875, 0.3, 38.25, 47.8125, 76.5);
269
		new AcadColor(168, 0, 0.0375, 0.15, 0, 9.5625, 38.25);
270
		new AcadColor(169, 0.075, 0.0938, 0.15, 19.125, 23.919, 38.25);
271
		new AcadColor(170, 0, 0, 1, 0, 0, 255);
272
		new AcadColor(171, 0.5, 0.5, 1, 127.5, 127.5, 255);
273
		new AcadColor(172, 0, 0, 0.65, 0, 0, 165.75);
274
		new AcadColor(173, 0.325, 0.325, 0.65, 82.875, 82.875, 165.75);
275
		new AcadColor(174, 0, 0, 0.5, 0, 0, 127.5);
276
		new AcadColor(175, 0.25, 0.25, 0.5, 63.75, 63.75, 127.5);
277
		new AcadColor(176, 0, 0, 0.3, 0, 0, 76.5);
278
		new AcadColor(177, 0.15, 0.15, 0.3, 38.25, 38.25, 76.5);
279
		new AcadColor(178, 0, 0, 0.15, 0, 0, 38.25);
280
		new AcadColor(179, 0.075, 0.075, 0.15, 19.125, 19.125, 38.25);
281
		new AcadColor(180, 0.25, 0, 1, 63.75, 0, 255);
282
		new AcadColor(181, 0.625, 0.5, 1, 159.375, 127.5, 255);
283
		new AcadColor(182, 0.1625, 0, 0.65, 41.4375, 0, 165.75);
284
		new AcadColor(183, 0.4063, 0.325, 0.65, 103.6065, 82.875, 165.75);
285
		new AcadColor(184, 0.125, 0, 0.5, 31.875, 0, 127.5);
286
		new AcadColor(185, 0.3125, 0.25, 0.5, 79.6875, 63.75, 127.5);
287
		new AcadColor(186, 0.075, 0, 0.3, 19.125, 0, 76.5);
288
		new AcadColor(187, 0.1875, 0.15, 0.3, 47.8125, 38.25, 76.5);
289
		new AcadColor(188, 0.0375, 0, 0.15, 9.5625, 0, 38.25);
290
		new AcadColor(189, 0.0938, 0.075, 0.15, 23.919, 19.125, 38.25);
291
		new AcadColor(190, 0.5, 0, 1, 127.5, 0, 255);
292
		new AcadColor(191, 0.75, 0.5, 1, 191.25, 127.5, 255);
293
		new AcadColor(192, 0.325, 0, 0.65, 82.875, 0, 165.75);
294
		new AcadColor(193, 0.4875, 0.325, 0.65, 124.3125, 82.875, 165.75);
295
		new AcadColor(194, 0.25, 0, 0.5, 63.75, 0, 127.5);
296
		new AcadColor(195, 0.375, 0.25, 0.5, 95.625, 63.75, 127.5);
297
		new AcadColor(196, 0.15, 0, 0.3, 38.25, 0, 76.5);
298
		new AcadColor(197, 0.225, 0.15, 0.3, 57.375, 38.25, 76.5);
299
		new AcadColor(198, 0.075, 0, 0.15, 19.125, 0, 38.25);
300
		new AcadColor(199, 0.1125, 0.075, 0.15, 28.6875, 19.125, 38.25);
301
		new AcadColor(200, 0.75, 0, 1, 191.25, 0, 255);
302
		new AcadColor(201, 0.875, 0.5, 1, 223.125, 127.5, 255);
303
		new AcadColor(202, 0.4875, 0, 0.65, 124.3125, 0, 165.75);
304
		new AcadColor(203, 0.5688, 0.325, 0.65, 145.044, 82.875, 165.75);
305
		new AcadColor(204, 0.375, 0, 0.5, 95.625, 0, 127.5);
306
		new AcadColor(205, 0.4375, 0.25, 0.5, 111.5625, 63.75, 127.5);
307
		new AcadColor(206, 0.225, 0, 0.3, 57.375, 0, 76.5);
308
		new AcadColor(207, 0.2625, 0.15, 0.3, 66.9375, 38.25, 76.5);
309
		new AcadColor(208, 0.1125, 0, 0.15, 28.6875, 0, 38.25);
310
		new AcadColor(209, 0.1313, 0.075, 0.15, 33.4815, 19.125, 38.25);
311
		new AcadColor(210, 1, 0, 1, 255, 0, 255);
312
		new AcadColor(211, 1, 0.5, 1, 255, 127.5, 255);
313
		new AcadColor(212, 0.65, 0, 0.65, 165.75, 0, 165.75);
314
		new AcadColor(213, 0.65, 0.325, 0.65, 165.75, 82.875, 165.75);
315
		new AcadColor(214, 0.5, 0, 0.5, 127.5, 0, 127.5);
316
		new AcadColor(215, 0.5, 0.25, 0.5, 127.5, 63.75, 127.5);
317
		new AcadColor(216, 0.3, 0, 0.3, 76.5, 0, 76.5);
318
		new AcadColor(217, 0.3, 0.15, 0.3, 76.5, 38.25, 76.5);
319
		new AcadColor(218, 0.15, 0, 0.15, 38.25, 0, 38.25);
320
		new AcadColor(219, 0.15, 0.075, 0.15, 38.25, 19.125, 38.25);
321
		new AcadColor(220, 1, 0, 0.75, 255, 0, 191.25);
322
		new AcadColor(221, 1, 0.5, 0.875, 255, 127.5, 223.125);
323
		new AcadColor(222, 0.65, 0, 0.4875, 165.75, 0, 124.3125);
324
		new AcadColor(223, 0.65, 0.325, 0.5688, 165.75, 82.875, 145.044);
325
		new AcadColor(224, 0.5, 0, 0.375, 127.5, 0, 95.625);
326
		new AcadColor(225, 0.5, 0.25, 0.4375, 127.5, 63.75, 111.5625);
327
		new AcadColor(226, 0.3, 0, 0.225, 76.5, 0, 57.375);
328
		new AcadColor(227, 0.3, 0.15, 0.2625, 76.5, 38.25, 66.9375);
329
		new AcadColor(228, 0.15, 0, 0.1125, 38.25, 0, 28.6875);
330
		new AcadColor(229, 0.15, 0.075, 0.1313, 38.25, 19.125, 33.4815);
331
		new AcadColor(230, 1, 0, 0.5, 255, 0, 127.5);
332
		new AcadColor(231, 1, 0.5, 0.75, 255, 127.5, 191.25);
333
		new AcadColor(232, 0.65, 0, 0.325, 165.75, 0, 82.875);
334
		new AcadColor(233, 0.65, 0.325, 0.4875, 165.75, 82.875, 124.3125);
335
		new AcadColor(234, 0.5, 0, 0.25, 127.5, 0, 63.75);
336
		new AcadColor(235, 0.5, 0.25, 0.375, 127.5, 63.75, 95.625);
337
		new AcadColor(236, 0.3, 0, 0.15, 76.5, 0, 38.25);
338
		new AcadColor(237, 0.3, 0.15, 0.225, 76.5, 38.25, 57.375);
339
		new AcadColor(238, 0.15, 0, 0.075, 38.25, 0, 19.125);
340
		new AcadColor(239, 0.15, 0.075, 0.1125, 38.25, 19.125, 28.6875);
341
		new AcadColor(240, 1, 0, 0.25, 255, 0, 63.75);
342
		new AcadColor(241, 1, 0.5, 0.625, 255, 127.5, 159.375);
343
		new AcadColor(242, 0.65, 0, 0.1625, 165.75, 0, 41.4375);
344
		new AcadColor(243, 0.65, 0.325, 0.4063, 165.75, 82.875, 103.6065);
345
		new AcadColor(244, 0.5, 0, 0.125, 127.5, 0, 31.875);
346
		new AcadColor(245, 0.5, 0.25, 0.3125, 127.5, 63.75, 79.6875);
347
		new AcadColor(246, 0.3, 0, 0.075, 76.5, 0, 19.125);
348
		new AcadColor(247, 0.3, 0.15, 0.1875, 76.5, 38.25, 47.8125);
349
		new AcadColor(248, 0.15, 0, 0.0375, 38.25, 0, 9.5625);
350
		new AcadColor(249, 0.15, 0.075, 0.0938, 38.25, 19.125, 23.919);
351
		new AcadColor(250, 0.33, 0.33, 0.33, 84.15, 84.15, 84.15);
352
		new AcadColor(251, 0.464, 0.464, 0.464, 118.32, 118.32, 118.32);
353
		new AcadColor(252, 0.598, 0.598, 0.598, 152.49, 152.49, 152.49);
354
		new AcadColor(253, 0.732, 0.732, 0.732, 186.66, 186.66, 186.66);
355
		new AcadColor(254, 0.866, 0.866, 0.866, 220.83, 220.83, 220.83);
356
		new AcadColor(255, 1.0, 1.0, 1.0, 255.0, 255.0, 255.0);
357
		return AcadColor.colors;
358
	}
359
}
tags/org.gvsig.dwg-2.0.82/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/util/Vector3D.java
1

  
2
package org.gvsig.dwg.lib.util;
3

  
4
/**
5
 *  3dim double vector. A vector is transformed different than a point.
6
 *  The class is now declared final to allow a more aggresive optimization.
7
 *
8
 *  @see       dxfviewer.math.Point3D;
9
 *
10
 *  @version   1.10,?01/13/99
11
 */
12
public final class Vector3D {
13
  public double x, y, z;       // coordinates, allowing direct access
14

  
15
  /**
16
   *
17
   */
18
  public Vector3D() {
19
  }
20

  
21
  /**
22
   *  Copy constructor.
23
   *  @param  v    vector to copy
24
   */
25
  public Vector3D(Vector3D v) {
26
    x = v.x;
27
    y = v.y;
28
    z = v.z;
29
  }
30

  
31
  /**
32
   *  Copy from a point.
33
   *  @param  p   point to copy
34
   */
35
  public Vector3D(Point3D p) {
36
    x = p.x;
37
    y = p.y;
38
    z = p.z;
39
  }
40

  
41
  /**
42
   *  @param   xx    x coord
43
   *  @param   yy    y coord
44
   *  @param   zz    z coord
45
   */
46
  public Vector3D(double xx, double yy, double zz) {
47
    x = xx;
48
    y = yy;
49
    z = zz;
50
  }
51

  
52
  /**
53
   *  Calculate the length.
54
   *  @return  length of vector
55
   */
56
  public double length() {
57
    return (double)Math.sqrt(x*x+y*y+z*z);
58
  }
59

  
60
  /**
61
   *  Scale.
62
   *  @param   f     scaling factor
63
   */
64
  public void scale(double f) {
65
    if (f != 1f) {
66
      x *= f;
67
      y *= f;
68
      z *= f;
69
    }
70
  }
71

  
72
  /**
73
   *  Normalize. Scale vector so it has length 1.
74
   */
75
  public void normalize() {
76
    scale(1.0f/length());
77
  }
78

  
79
  /**
80
   *  Add a vector.
81
   *  @param  v      vector to add
82
   */
83
  public void add(Vector3D v) {
84
    x += v.x;
85
    y += v.y;
86
    z += v.z;
87
  }
88

  
89
  /**
90
   *  Get sum of vectors.
91
   *  @param  v     vector to add
92
   *  @return this+v
93
   */
94
  public Vector3D plus(Vector3D v) {
95
    Vector3D ret = new Vector3D(this);
96
    ret.add(v);
97
    return ret;
98
  }
99
  /**
100
   *  Get sum of this vector and point.
101
   *  @param  p     point to add
102
   *  @return this+p
103
   */
104
  public Point3D plus(Point3D p) {
105
    Point3D ret = new Point3D(p);
106
    ret.add(this);
107
    return ret;
108
  }
109

  
110
  /**
111
   *  Substract a vector from this.
112
   *  @param  v     vector to substract
113
   */
114
  public void sub(Vector3D v) {
115
    x -= v.x;
116
    y -= v.y;
117
    z -= v.z;
118
  }
119

  
120
  /**
121
   *  Get difference with point.
122
   *  @param  p     point to substract
123
   *  @return this-p = -(p-this)
124
   */
125
  public Point3D minus(Point3D p) {
126
    Point3D ret = new Point3D(p);
127
    ret.sub(this);
128
    ret.scale(-1f);
129
    return ret;
130
  }
131

  
132
  /**
133
   *  Get difference with vector.
134
   *  @param  v     vector to substract
135
   *  @return this-v
136
   */
137
  public Vector3D minus(Vector3D v) {
138
    Vector3D ret = new Vector3D(this);
139
    ret.sub(v);
140
    return ret;
141
  }
142

  
143
  /**
144
   *  Scalar product.
145
   *  @param  v     vector to multiply
146
   *  @return this*v
147
   */
148
  public double mult(Vector3D v) {
149
    return x*v.x+y*v.y+z*v.z;
150
  }
151

  
152
  /**
153
   *  Cross product.
154
   *  @param  v     vector to multiply
155
   *  @return this x v
156
   */
157
  public Vector3D cross(Vector3D v) {
158
    return new Vector3D(y*v.z - z*v.y,
159
			z*v.x - x*v.z,
160
			x*v.y - y*v.x);
161
  }
162

  
163
  /**
164
   *  Output.
165
   *  @return  string representation
166
   */
167
  public String toString() {
168
    return new String(new StringBuffer().append("<").append(x).append(",").append(y).append(",").append(z).append(">"));
169
  }
170
}
171

  
tags/org.gvsig.dwg-2.0.82/org.gvsig.dwg.lib/src/main/java/org/gvsig/dwg/lib/util/Matrix4D.java
1

  
2
package org.gvsig.dwg.lib.util;
3

  
4

  
5
/**
6
 *  4x4dim double matrix used for perspective transformations.
7
 *  The class is now declared final to allow a more aggresive optimization.
8
 *
9
 */
10
public final class Matrix4D {
11
  static private final double DEG2RAD = Math.PI/180.0;  // conversion from degree to radians
12

  
13
  public double xx, xy, xz, xw,     // 1st row
14
			   yx, yy, yz, yw,     // 2nd row
15
			   zx, zy, zz, zw,     // 3rd row
16
			   wx, wy, wz, ww;     // 4th row
17

  
18
  /**
19
   *  Create identity matrix.
20
   */
21
  public Matrix4D() {
22
	// set to identity mat
23
	xx = yy = zz = ww = 1f;
24
  }
25

  
26
  /**
27
   *  Copy constructor.
28
   *  @param  m   matrix to copy
29
   */
30
  public Matrix4D(Matrix4D m) {
31
	xx = m.xx;
32
	xy = m.xy;
33
	xz = m.xz;
34
	xw = m.xw;
35
	yx = m.yx;
36
	yy = m.yy;
37
	yz = m.yz;
38
	yw = m.yw;
39
	zx = m.zx;
40
	zy = m.zy;
41
	zz = m.zz;
42
	zw = m.zw;
43
	wx = m.wx;
44
	wy = m.wy;
45
	wz = m.wz;
46
	ww = m.ww;
47
  }
48

  
49
  /**
50
   *  @param  mxx     1st elem in 1st row
51
   *  @param  mxy     2nd elem in 1st row
52
   *  @param  mxz     3rd elem in 1st row
53
   *  @param  mxw     4th elem in 1st row
54
   *  @param  myx     1st elem in 2nd row
55
   *  @param  myy     2nd elem in 2nd row
56
   *  @param  myz     3rd elem in 2nd row
57
   *  @param  myw     4th elem in 2nd row
58
   *  @param  mzx     1st elem in 3rd row
59
   *  @param  mzy     2nd elem in 3rd row
60
   *  @param  mzz     3rd elem in 3rd row
61
   *  @param  mzw     4th elem in 3rd row
62
   *  @param  mwx     1st elem in 4th row
63
   *  @param  mwy     2nd elem in 4th row
64
   *  @param  mwz     3rd elem in 4th row
65
   *  @param  mww     4th elem in 4th row
66
   */
67
  public Matrix4D(double mxx, double mxy, double mxz, double mxw,
68
		  double myx, double myy, double myz, double myw,
69
		  double mzx, double mzy, double mzz, double mzw,
70
		  double mwx, double mwy, double mwz, double mww) {
71
	xx = mxx;
72
	xy = mxy;
73
	xz = mxz;
74
	xw = mxw;
75
	yx = myx;
76
	yy = myy;
77
	yz = myz;
78
	yw = myw;
79
	zx = mzx;
80
	zy = mzy;
81
	zz = mzz;
82
	zw = mzw;
83
	wx = mwx;
84
	wy = mwy;
85
	wz = mwz;
86
	ww = mww;
87
  }
88

  
89
  /**
90
   *  Reset to identity
91
   */
92
  public void identity() {
93
	xx = yy = zz = ww = 1f;
94
	xy = xz = xw =
95
	  yx = yz = yw =
96
	  zx = zy = zw =
97
	  wx = wy = wz = 0f;
98
  }
99

  
100
  /**
101
   *  Transponize.
102
   */
103
  public void transponize() {
104
	// switch rows and columns
105
	double t;
106
	t = xy; xy = yx; yx = t;
107
	t = xz; xz = zx; zx = t;
108
	t = xw; xw = wx; wx = t;
109
	t = yz; yz = zy; zy = t;
110
	t = yw; yw = wy; wy = t;
111
	t = zw; zw = wz; wz = t;
112
  }
113

  
114
  /**
115
   *  Matrix multiplication of vector.
116
   *  @param  v   vector to transform
117
   *  @return transformed vector
118
   */
119
  public Vector3D mult(Vector3D v) {
120
	return new Vector3D(xx*v.x + xy*v.y + xz*v.z,
121
			yx*v.x + yy*v.y + yz*v.z,
122
			zx*v.x + zy*v.y + zz*v.z);
123
  }
124

  
125
  /**
126
   *  Transformation of 1 vector.
127
   *  @param  v   vector to transform
128
   */
129
  public void transform(Vector3D v) {
130
	double x = xx*v.x + xy*v.y + xz*v.z,
131
		  y = yx*v.x + yy*v.y + yz*v.z,
132
		  z = zx*v.x + zy*v.y + zz*v.z;
133

  
134
	v.x = x;
135
	v.y = y;
136
	v.z = z;
137
  }
138

  
139
  /**
140
   *  Matrix multiplication of point.
141
   *  @param  p    point to transform
142
   *  @return transformed point
143
   */
144
  public Point3D mult(Point3D p) {
145
	Point3D ret = new Point3D(xx*p.x + xy*p.y + xz*p.z + xw,
146
				  yx*p.x + yy*p.y + yz*p.z + yw,
147
				  zx*p.x + zy*p.y + zz*p.z + zw);
148
	ret.scale(1f/(wx*p.x + wy*p.y + wz*p.z + ww));
149
	return ret;
150
  }
151

  
152
  /**
153
   *  Transformation of 1 point.
154
   *  @param  p   point to transform
155
   */
156
  public void transform(Point3D p) {
157
	double  x = xx*p.x + xy*p.y + xz*p.z + xw,
158
		   y = yx*p.x + yy*p.y + yz*p.z + yw,
159
		   z = zx*p.x + zy*p.y + zz*p.z + zw,
160
		   w = wx*p.x + wy*p.y + wz*p.z + ww;
161

  
162
	p.x = x/w;
163
	p.y = y/w;
164
	p.z = z/w;
165
  }
166

  
167
  /**Transformacion de un punto considerando solo el plano horizontal
168
   */
169
   public void transformXY(Point3D p){
170
		double  x = xx*p.x + xy*p.y+ xw,
171
		y = yx*p.x + yy*p.y + yw,
172
		w = wx*p.x + wy*p.y + ww;
173
		p.x = x/w;
174
		p.y = y/w;
175
   }
176

  
177
  /**
178
   *  Matrix multiplication.
179
   *  @param  m   matrix to multiply with
180
   *  @return this * m
181
   */
182
  public Matrix4D mult(Matrix4D m) {
183
	if (m != null) {
184
	  return new Matrix4D(xx*m.xx + xy*m.yx + xz*m.zx + xw*m.wx,
185
			  xx*m.xy + xy*m.yy + xz*m.zy + xw*m.wy,
186
			  xx*m.xz + xy*m.yz + xz*m.zz + xw*m.wz,
187
			  xx*m.xw + xy*m.yw + xz*m.zw + xw*m.ww,
188
			  yx*m.xx + yy*m.yx + yz*m.zx + yw*m.wx,
189
			  yx*m.xy + yy*m.yy + yz*m.zy + yw*m.wy,
190
			  yx*m.xz + yy*m.yz + yz*m.zz + yw*m.wz,
191
			  yx*m.xw + yy*m.yw + yz*m.zw + yw*m.ww,
192
			  zx*m.xx + zy*m.yx + zz*m.zx + zw*m.wx,
193
			  zx*m.xy + zy*m.yy + zz*m.zy + zw*m.wy,
194
			  zx*m.xz + zy*m.yz + zz*m.zz + zw*m.wz,
195
			  zx*m.xw + zy*m.yw + zz*m.zw + zw*m.ww,
196
			  wx*m.xx + wy*m.yx + wz*m.zx + ww*m.wx,
197
			  wx*m.xy + wy*m.yy + wz*m.zy + ww*m.wy,
198
			  wx*m.xz + wy*m.yz + wz*m.zz + ww*m.wz,
199
			  wx*m.xw + wy*m.yw + wz*m.zw + ww*m.ww);
200
	}
201
	else {
202
	  return new Matrix4D(this);
203
	}
204
  }
205

  
206
  /**
207
   *  Matrix multiplication.
208
   *  @param  m  matrix to multply with
209
   */
210
  public void multBy(Matrix4D m) {
211
	double x = xx*m.xx + xy*m.yx + xz*m.zx + xw*m.wx,
212
		  y = xx*m.xy + xy*m.yy + xz*m.zy + xw*m.wy,
213
		  z = xx*m.xz + xy*m.yz + xz*m.zz + xw*m.wz,
214
		  w = xx*m.xw + xy*m.yw + xz*m.zw + xw*m.ww;
215
	xx = x;
216
	xy = y;
217
	xz = z;
218
	xw = w;
219

  
220
	x = yx*m.xx + yy*m.yx + yz*m.zx + yw*m.wx;
221
	y = yx*m.xy + yy*m.yy + yz*m.zy + yw*m.wy;
222
	z = yx*m.xz + yy*m.yz + yz*m.zz + yw*m.wz;
223
	w = yx*m.xw + yy*m.yw + yz*m.zw + yw*m.ww;
224
	yx = x;
225
	yy = y;
226
	yz = z;
227
	yw = w;
228

  
229
	x = zx*m.xx + zy*m.yx + zz*m.zx + zw*m.wx;
230
	y = zx*m.xy + zy*m.yy + zz*m.zy + zw*m.wy;
231
	z = zx*m.xz + zy*m.yz + zz*m.zz + zw*m.wz;
232
	w = zx*m.xw + zy*m.yw + zz*m.zw + zw*m.ww;
233
	zx = x;
234
	zy = y;
235
	zz = z;
236
	zw = w;
237

  
238
	x = wx*m.xx + wy*m.yx + wz*m.zx + ww*m.wx;
239
	y = wx*m.xy + wy*m.yy + wz*m.zy + ww*m.wy;
240
	z = wx*m.xz + wy*m.yz + wz*m.zz + ww*m.wz;
241
	w = wx*m.xw + wy*m.yw + wz*m.zw + ww*m.ww;
242
	wx = x;
243
	wy = y;
244
	wz = z;
245
	ww = w;
246
  }
247

  
248
  /**
249
   *  Matrix multiplication from left.
250
   *  @param  m  matrix to multiply with.
251
   */
252
  public void multLeftBy(Matrix4D m) {
253
	double x = m.xx*xx + m.xy*yx + m.xz*zx + m.xw*wx,
254
		  y = m.yx*xx + m.yy*yx + m.yz*zx + m.yw*wx,
255
		  z = m.zx*xx + m.zy*yx + m.zz*zx + m.zw*wx,
256
		  w = m.wx*xx + m.wy*yx + m.wz*zx + m.ww*wx;
257
	xx = x;
258
	yx = y;
259
	zx = z;
260
	wx = w;
261

  
262
	x = m.xx*xy + m.xy*yy + m.xz*zy + m.xw*wy;
263
	y = m.yx*xy + m.yy*yy + m.yz*zy + m.yw*wy;
264
	z = m.zx*xy + m.zy*yy + m.zz*zy + m.zw*wy;
265
	w = m.wx*xy + m.wy*yy + m.wz*zy + m.ww*wy;
266
	xy = x;
267
	yy = y;
268
	zy = z;
269
	wy = w;
270

  
271
	x = m.xx*xz + m.xy*yz + m.xz*zz + m.xw*wz;
272
	y = m.yx*xz + m.yy*yz + m.yz*zz + m.yw*wz;
273
	z = m.zx*xz + m.zy*yz + m.zz*zz + m.zw*wz;
274
	w = m.wx*xz + m.wy*yz + m.wz*zz + m.ww*wz;
275
	xz = x;
276
	yz = y;
277
	zz = z;
278
	wz = w;
279

  
280
	x = m.xx*xw + m.xy*yw + m.xz*zw + m.xw*ww;
281
	y = m.yx*xw + m.yy*yw + m.yz*zw + m.yw*ww;
282
	z = m.zx*xw + m.zy*yw + m.zz*zw + m.zw*ww;
283
	w = m.wx*xw + m.wy*yw + m.wz*zw + m.ww*ww;
284
	xw = x;
285
	yw = y;
286
	zw = z;
287
	ww = w;
288
  }
289

  
290
  /**
291
   *  Translate the origin.
292
   *  @param  x   translation in x
293
   *  @param  y   translation in y
294
   *  @param  z   translation in z
295
   */
296
  public void translate(double x, double y, double z) {
297
	xw += x*xx+y*xy+z*xz;
298
	yw += x*yx+y*yy+z*yz;
299
	zw += x*zx+y*zy+z*zz;
300
	ww += x*wx+y*wy+z*wz;
301
  }
302

  
303
  /**
304
   *  Translate the origin
305
   *  @param  v   translation vector
306
   */
307
  public void translate(Vector3D v) {
308
	translate(v.x, v.y, v.z);
309
  }
310

  
311
  /**
312
   *  Translate.
313
   *  @param  x   translation in x
314
   *  @param  y   translation in y
315
   *  @param  z   translation in z
316
   */
317
  public void translateLeft(double x, double y, double z) {
318
	if (x != 0f) {
319
	  xx += x*wx;  xy += x*wy;  xz += x*wz;  xw += x*ww;
320
	}
321
	if (y != 0f) {
322
	  yx += y*wx;  yy += y*wy;  yz += y*wz;  yw += y*ww;
323
	}
324
	if (z != 0f) {
325
	  zx += z*wx;  zy += z*wy;  zz += z*wz;  zw += z*ww;
326
	}
327
  }
328

  
329
  /**
330
   *  Translate the origin
331
   *  @param  v   tranbslation vector
332
   */
333
  public void translateLeft(Vector3D v) {
334
	translateLeft(v.x, v.y, v.z);
335
  }
336

  
337

  
338
  /**
339
   *  Move the stuff.
340
   *  @param  x   translation in x
341
   *  @param  y   translation in y
342
   *  @param  z   translation in z
343
   */
344
  public void moveBy(double x, double y, double z) {
345
	if (x != 0f) {
346
	  xx += x*xw;  yx += x*yw;  zx += x*zw;  wx += x*ww;
347
	}
348
	if (y != 0f) {
349
	  xy += y*xw;  yy += y*yw;  zy += y*zw;  wy += y*ww;
350
	}
351
	if (z != 0f) {
352
	  xz += z*xw;  yz += z*yw;  zz += z*zw;  wz += z*ww;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff