org.jgrasstools.gears.io.dxfdwg.libs.dwg.DwgObject Maven / Gradle / Ivy
/*
* JGrass - Free Open Source Java GIS http://www.jgrass.org
* (C) HydroloGIS - www.hydrologis.com
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Library General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
* details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; if not, write to the Free Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jgrasstools.gears.io.dxfdwg.libs.dwg;
import java.util.Vector;
/**
* The DwgObject class represents a DWG object
*
* @author jmorell
*/
public class DwgObject {
protected int type;
protected int handle;
protected int layerHandleCode;
protected String version;
protected int mode;
protected int layerHandle;
protected int color;
protected int numReactors;
protected boolean noLinks;
protected int linetypeFlags;
protected int plotstyleFlags;
protected int sizeInBits;
protected Vector extendedData;
protected int graphicData;
protected int subEntityHandle;
protected int xDicObjHandle;
protected boolean graphicsFlag;
/**
* Reads the header of an object in a DWG file Version 15
*
* @param data Array of unsigned bytes obtained from the DWG binary file
* @param offset The current bit offset where the value begins
* @return int New offset
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs
* when we are looking for LwPolylines.
*/
public int readObjectHeaderV15(int[] data, int offset) throws Exception {
int bitPos = offset;
Integer mode = (Integer)DwgUtil.getBits(data, 2, bitPos);
bitPos = bitPos + 2;
setMode(mode.intValue());
Vector v = DwgUtil.getBitLong(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int rnum = ((Integer)v.get(1)).intValue();
setNumReactors(rnum);
v = DwgUtil.testBit(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
boolean nolinks = ((Boolean)v.get(1)).booleanValue();
setNoLinks(nolinks);
v = DwgUtil.getBitShort(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int color = ((Integer)v.get(1)).intValue();
setColor(color);
v = DwgUtil.getBitDouble(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
float ltscale = ((Double)v.get(1)).floatValue();
Integer ltflag = (Integer)DwgUtil.getBits(data, 2, bitPos);
bitPos = bitPos + 2;
Integer psflag = (Integer)DwgUtil.getBits(data, 2, bitPos);
bitPos = bitPos + 2;
v = DwgUtil.getBitShort(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int invis = ((Integer)v.get(1)).intValue();
v = DwgUtil.getRawChar(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int weight = ((Integer)v.get(1)).intValue();
return bitPos;
}
/**
* Reads the tail of an object in a DWG file Version 15
*
* @param data Array of bytes obtained from the DWG binary file
* @param offset Offset for this array of bytes
* @return int New offset
* @throws Exception If an unexpected bit value is found in the DWG file. Occurs
* when we are looking for LwPolylines.
*/
public int readObjectTailV15(int[] data, int offset) throws Exception {
int bitPos = offset;
Vector v = null;
if (getMode()==0x0) {
v = DwgUtil.getHandle(data, bitPos);
bitPos = ((Integer)v.get(0)).intValue();
int[] sh = new int[v.size()-1];
for (int i=1;i