| | |
| | | package com.ximple.io.dgn7; |
| | | |
| | | import java.awt.geom.AffineTransform; |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.ByteOrder; |
| | | import java.nio.CharBuffer; |
| | | import java.nio.charset.CharacterCodingException; |
| | | import java.nio.charset.Charset; |
| | | import java.nio.charset.CharsetDecoder; |
| | | |
| | | import org.apache.log4j.Logger; |
| | | |
| | |
| | | |
| | | val.append(temp[i]); |
| | | } |
| | | } else |
| | | { |
| | | byte[] strRaw = new byte[num * 2]; |
| | | for (int i = 0; i < num; i++) |
| | | { |
| | | short charValue = raw[i + 31]; |
| | | byte hi = (byte) (charValue >>> 8); |
| | | byte lo = (byte) charValue; |
| | | strRaw[i * 2] = hi; |
| | | strRaw[i * 2 + 1] = lo; |
| | | } |
| | | |
| | | try |
| | | { |
| | | Charset charsetBig5 = Charset.forName("Big5"); |
| | | CharsetDecoder decoder = charsetBig5.newDecoder(); |
| | | CharBuffer cb = decoder.decode(ByteBuffer.wrap(strRaw)); |
| | | val.append(cb); |
| | | } catch (CharacterCodingException e) |
| | | { |
| | | logger.warn(e.getMessage(), e); |
| | | return val.toString(); |
| | | } finally |
| | | { |
| | | // rawBuffer.position(pos); |
| | | // rawBuffer.order(order); |
| | | } |
| | | } |
| | | |
| | | return val.toString(); |
| | | } |
| | | |
| | | protected byte[] convertDBCSToUnicode(byte[] buffer) |
| | | { |
| | | byte[] charBuffer = new byte[4]; |
| | | charBuffer[0] = (byte) ((byte) ((buffer[1] & 0xc0) >>> 6) | 0xc0); |
| | | charBuffer[1] = (byte) (buffer[1] & 0x3f | 0x80); |
| | | charBuffer[2] = (byte) ((byte) ((buffer[0] & 0xc0) >>> 6) | 0xc0); |
| | | charBuffer[3] = (byte) (buffer[0] & 0x3f | 0x80); |
| | | return charBuffer; |
| | | } |
| | | |
| | | public Geometry toGeometry(GeometryFactory factory) |
| | |
| | | double[] srcPt = new double[2]; |
| | | double[] dstPt = new double[2]; |
| | | |
| | | srcPt[0] = p.x + width ; |
| | | srcPt[1] = p.y + height ; |
| | | srcPt[0] = p.x + width; |
| | | srcPt[1] = p.y + height; |
| | | |
| | | at.transform(srcPt, 0, dstPt, 0, 1); |
| | | |