forked from geodmms/xdgnjobs

?? ?
2008-05-14 fe4bda7d456c106e1061afaa29d452e5553e9d96
xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Element.java
@@ -33,12 +33,17 @@
    public static final int PRIMARY_CLASS           = 0;
    public static final int PRIMARY_RULE_CLASS      = 0;
    protected short[]   raw;
    protected byte      attrOffset = 0;
    protected short[]       raw;
    protected byte          attrOffset = 0;
    protected ByteBuffer    rawBuffer;
    public Element(short[] raw)
    public Element(byte[] raw)
    {
        this.raw = raw;
        // this.raw = raw;
        this.raw = new short[raw.length / 2];
        rawBuffer = ByteBuffer.wrap(raw);
        rawBuffer.order(ByteOrder.LITTLE_ENDIAN);
        rawBuffer.asShortBuffer().get(this.raw);
    }
    public int getLineStyle()
@@ -217,6 +222,10 @@
        }
    }
    protected static int getOffsetPosition(int offset)
    {
        return offset * 2;
    }
    public static class ElementHandler implements IElementHandler
    {
@@ -234,23 +243,30 @@
        public Object read(ByteBuffer buffer, short signature, int length)
        {
            byte[] dst = new byte[length - 4];
            byte[] dst = new byte[length];
            try
            {
                buffer.get(dst, 0, dst.length);
                buffer.get(dst, 4, dst.length - 4);
            } catch (BufferUnderflowException exception)
            {
                throw exception;   
            }
            ByteBuffer tmpBuffer = ByteBuffer.wrap(dst);
            tmpBuffer.order(ByteOrder.LITTLE_ENDIAN);
            tmpBuffer.position(0);
            tmpBuffer.putShort(signature);
            tmpBuffer.putShort((short) ((length / 2) - 2));
            /*
            ShortBuffer sbuffer = tmpBuffer.asShortBuffer();
            short[] rawMem = new short[(length / 2)];
            sbuffer.get(rawMem, 2, rawMem.length - 2);
            rawMem[0] = signature;
            rawMem[1] = (short) ((length / 2) - 2);
            Element elm = createElement(rawMem);
            */
            Element elm = createElement(dst);
            return elm;
        }
@@ -264,7 +280,7 @@
            return ((Element) element).raw.length;
        }
        protected Element createElement(short[] raw)
        protected Element createElement(byte[] raw)
        {
            return new Element(raw);
        }