| | |
| | | package com.ximple.io.dgn7; |
| | | |
| | | import java.nio.ByteOrder; |
| | | |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | import com.vividsolutions.jts.geom.Geometry; |
| | | import com.vividsolutions.jts.geom.GeometryFactory; |
| | | |
| | | public class EllipseElement extends Element implements GeometryConverter |
| | | { |
| | | public EllipseElement(short[] raw) |
| | | public EllipseElement(byte[] raw) |
| | | { |
| | | super(raw); |
| | | } |
| | |
| | | |
| | | public double getPrimary() |
| | | { |
| | | short[] primary = new short[4]; |
| | | |
| | | System.arraycopy(raw, 18, primary, 0, 4); |
| | | |
| | | rawBuffer.position(18 * 2); |
| | | ByteOrder bo = rawBuffer.order(); |
| | | rawBuffer.order(ByteOrder.BIG_ENDIAN); |
| | | byte[] primary = new byte[8]; |
| | | rawBuffer.get(primary); |
| | | rawBuffer.order(bo); |
| | | return Utility.convertDGNToIEEEDouble(primary) / 1000.0; |
| | | } |
| | | |
| | |
| | | |
| | | public double getSecondary() |
| | | { |
| | | short[] secondary = new short[4]; |
| | | |
| | | System.arraycopy(raw, 22, secondary, 0, 4); |
| | | |
| | | rawBuffer.position(22 * 2); |
| | | ByteOrder bo = rawBuffer.order(); |
| | | rawBuffer.order(ByteOrder.BIG_ENDIAN); |
| | | byte[] secondary = new byte[8]; |
| | | rawBuffer.get(secondary); |
| | | rawBuffer.order(bo); |
| | | return Utility.convertDGNToIEEEDouble(secondary) / 1000.0; |
| | | } |
| | | |
| | |
| | | public double getRotationAngle() |
| | | { |
| | | int rotation = (raw[26] << 16 & 0xffff0000); |
| | | |
| | | rotation |= raw[27] & 0x0000ffff; |
| | | |
| | | return Utility.converIntToRotation(rotation); |
| | |
| | | |
| | | public Coordinate getOrigin() |
| | | { |
| | | short[] x = new short[4]; |
| | | rawBuffer.position(28 * 2); |
| | | ByteOrder bo = rawBuffer.order(); |
| | | rawBuffer.order(ByteOrder.BIG_ENDIAN); |
| | | byte[] rawValue = new byte[8]; |
| | | |
| | | System.arraycopy(raw, 28, x, 0, 4); |
| | | rawBuffer.get(rawValue); // x |
| | | double dx = Utility.converUnitToCoord(Utility.convertDGNToIEEEDouble(rawValue)); |
| | | |
| | | double dx = Utility.converUnitToCoord((int) Utility.convertDGNToIEEEDouble(x)); |
| | | short[] y = new short[4]; |
| | | rawBuffer.get(rawValue); // y |
| | | double dy = Utility.converUnitToCoord(Utility.convertDGNToIEEEDouble(rawValue)); |
| | | |
| | | System.arraycopy(raw, 32, y, 0, 4); |
| | | |
| | | double dy = Utility.converUnitToCoord((int) Utility.convertDGNToIEEEDouble(y)); |
| | | rawBuffer.order(bo); |
| | | |
| | | return new Coordinate(dx, dy); |
| | | } |
| | |
| | | return instance; |
| | | } |
| | | |
| | | protected Element createElement(short[] raw) |
| | | protected Element createElement(byte[] raw) |
| | | { |
| | | return new EllipseElement(raw); |
| | | } |