From 1939acb5eeca2792e93a0e236ed2f4a60b4d4008 Mon Sep 17 00:00:00 2001 From: ?? ? <ulysseskao@ximple.com.tw> Date: Wed, 25 Jun 2008 19:24:44 +0800 Subject: [PATCH] update for EOFM-127 --- xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Element.java | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 46 insertions(+), 1 deletions(-) diff --git a/xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Element.java b/xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Element.java index f1788ac..030b950 100644 --- a/xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Element.java +++ b/xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/Element.java @@ -5,9 +5,9 @@ import java.nio.BufferUnderflowException; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.nio.ShortBuffer; import java.util.ArrayList; import java.util.List; -import java.util.Arrays; import com.vividsolutions.jts.geom.Envelope; @@ -71,6 +71,29 @@ DgnUtility.converUnitToCoord(lowCoorY), DgnUtility.converUnitToCoord(highCoorY)); } + public void setRange(Envelope bbox) + { + int lowCoordX = DgnUtility.converCoordToUnit(bbox.getMinX()); + int temp = DgnUtility.converToDGN(lowCoordX); + raw[3] = (short) (temp >> 16 & 0x0000ffff); + raw[2] = (short) (temp & 0x0000ffff); + + int lowCoordY = DgnUtility.converCoordToUnit(bbox.getMinY()); + temp = DgnUtility.converToDGN(lowCoordY); + raw[5] = (short) (temp >> 16 & 0x0000ffff); + raw[4] = (short) (temp & 0x0000ffff); + + int highCoorX = DgnUtility.converCoordToUnit(bbox.getMaxX()); + temp = DgnUtility.converToDGN(highCoorX); + raw[9] = (short) (temp >> 16 & 0x0000ffff); + raw[8] = (short) (temp & 0x0000ffff); + + int highCoorY = DgnUtility.converCoordToUnit(bbox.getMaxY()); + temp = DgnUtility.converToDGN(highCoorY); + raw[11] = (short) (temp >> 16 & 0x0000ffff); + raw[10] = (short) (temp & 0x0000ffff); + } + public boolean isComponentElement() { return (short) ((raw[0] >>> 7) & 0x0001) == 1; @@ -109,6 +132,11 @@ public int getLevelIndex() { return (raw[0] & 0x003f); + } + + public void setLevelIndex(int value) + { + raw[0] = (short) ((raw[0] & 0xffc0) | (value & 0x003f)); } public int getWeight() @@ -227,6 +255,18 @@ return offset * 2; } + public void resyncBuffer() + { + byte[] tempRaw = new byte[this.raw.length * 2]; + ByteBuffer tempBuffer = ByteBuffer.wrap(tempRaw); + tempBuffer.order(ByteOrder.LITTLE_ENDIAN); + tempBuffer.asShortBuffer().put(this.raw); + + int pos = rawBuffer.position(); + rawBuffer = tempBuffer; + rawBuffer.position(pos); + } + public static class ElementHandler implements IElementHandler { ElementType elementType; @@ -281,6 +321,11 @@ return ((Element) element).raw.length; } + public int getBufferLength(Object element) + { + return ((Element) element).rawBuffer.limit(); + } + protected Element createElement(byte[] raw) { return new Element(raw); -- Gitblit v0.0.0-SNAPSHOT