/* * 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.objects; import java.util.Vector; import org.jgrasstools.gears.io.dxfdwg.libs.dwg.DwgObject; import org.jgrasstools.gears.io.dxfdwg.libs.dwg.DwgUtil; /** * The DwgCircle class represents a DWG Circle * * @author jmorell */ public class DwgCircle extends DwgObject { private double[] center; private double radius; private double thickness; private double[] extrusion; /** * Read a Circle in the DWG format Version 15 * * @param data Array of unsigned bytes obtained from the DWG binary file * @param offset The current bit offset where the value begins * @throws Exception If an unexpected bit value is found in the DWG file. Occurs * when we are looking for LwPolylines. */ public void readDwgCircleV15(int[] data, int offset) throws Exception { int bitPos = offset; bitPos = readObjectHeaderV15(data, bitPos); Vector v = DwgUtil.getBitDouble(data, bitPos); bitPos = ((Integer)v.get(0)).intValue(); double x = ((Double)v.get(1)).doubleValue(); v = DwgUtil.getBitDouble(data, bitPos); bitPos = ((Integer)v.get(0)).intValue(); double y = ((Double)v.get(1)).doubleValue(); v = DwgUtil.getBitDouble(data, bitPos); bitPos = ((Integer)v.get(0)).intValue(); double z = ((Double)v.get(1)).doubleValue(); double[] coord = new double[]{x, y, z}; center = coord; v = DwgUtil.getBitDouble(data, bitPos); bitPos = ((Integer)v.get(0)).intValue(); double val = ((Double)v.get(1)).doubleValue(); radius = val; v = DwgUtil.testBit(data, bitPos); bitPos = ((Integer)v.get(0)).intValue(); boolean flag = ((Boolean)v.get(1)).booleanValue(); if (flag) { val=0.0; } else { v = DwgUtil.getBitDouble(data, bitPos); bitPos = ((Integer)v.get(0)).intValue(); val = ((Double)v.get(1)).doubleValue(); } thickness = val; v = DwgUtil.testBit(data, bitPos); bitPos = ((Integer)v.get(0)).intValue(); flag = ((Boolean)v.get(1)).booleanValue(); if (flag) { x = y = 0.0; z = 1.0; } else { v = DwgUtil.getBitDouble(data, bitPos); bitPos = ((Integer)v.get(0)).intValue(); x = ((Double)v.get(1)).doubleValue(); v = DwgUtil.getBitDouble(data, bitPos); bitPos = ((Integer)v.get(0)).intValue(); y = ((Double)v.get(1)).doubleValue(); v = DwgUtil.getBitDouble(data, bitPos); bitPos = ((Integer)v.get(0)).intValue(); z = ((Double)v.get(1)).doubleValue(); } coord = new double[]{x, y, z}; extrusion = coord; bitPos = readObjectTailV15(data, bitPos); } /** * @return Returns the center. */ public double[] getCenter() { return center; } /** * @param center The center to set. */ public void setCenter(double[] center) { this.center = center; } /** * @return Returns the radius. */ public double getRadius() { return radius; } /** * @param radius The radius to set. */ public void setRadius(double radius) { this.radius = radius; } /** * @return Returns the extrusion. */ public double[] getExtrusion() { return extrusion; } /* (non-Javadoc) * @see java.lang.Object#clone() */ public Object clone() { DwgCircle dwgCircle = new DwgCircle(); dwgCircle.setType(type); dwgCircle.setHandle(handle); dwgCircle.setVersion(version); dwgCircle.setMode(mode); dwgCircle.setLayerHandle(layerHandle); dwgCircle.setColor(color); dwgCircle.setNumReactors(numReactors); dwgCircle.setNoLinks(noLinks); dwgCircle.setLinetypeFlags(linetypeFlags); dwgCircle.setPlotstyleFlags(plotstyleFlags); dwgCircle.setSizeInBits(sizeInBits); dwgCircle.setExtendedData(extendedData); dwgCircle.setGraphicData(graphicData); //dwgCircle.setInsideBlock(insideBlock); dwgCircle.setCenter(center); dwgCircle.setRadius(radius); dwgCircle.setThickness(thickness); dwgCircle.setExtrusion(extrusion); return dwgCircle; } /** * @return Returns the thickness. */ public double getThickness() { return thickness; } /** * @param thickness The thickness to set. */ public void setThickness(double thickness) { this.thickness = thickness; } /** * @param extrusion The extrusion to set. */ public void setExtrusion(double[] extrusion) { this.extrusion = extrusion; } }