| | |
| | | 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; |
| | | |
| | |
| | | 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; |
| | |
| | | public int getLevelIndex() |
| | | { |
| | | return (raw[0] & 0x003f); |
| | | } |
| | | |
| | | public void setLevelIndex(int value) |
| | | { |
| | | raw[0] = (short) ((raw[0] & 0xffc0) | (value & 0x003f)); |
| | | } |
| | | |
| | | public int getWeight() |
| | |
| | | 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; |
| | |
| | | return ((Element) element).raw.length; |
| | | } |
| | | |
| | | public int getBufferLength(Object element) |
| | | { |
| | | return ((Element) element).rawBuffer.limit(); |
| | | } |
| | | |
| | | protected Element createElement(byte[] raw) |
| | | { |
| | | return new Element(raw); |