public class IlvDXFReader extends Object
An example of code reading the contents of a DXF file into an
IlvManager
:
IlvManager manager = new IlvManager(0); // with no layer IlvDXFReader reader = new IlvDXFReader(); try { reader.read("myDXFFile.dxf", manager); } catch (IOException e) { e.printStackTrace(); }
You can also read the DXF file using directly the "read" method of the manager. For that, you should first create the manager you will work on and the stream factory:
IlvManager manager = new IlvManager(0); // with no layer IlvDXFStreamFactory factory = new IlvDXFStreamFactory(); manager.setStreamFactory(factory);Now that the stream factory has been set, calling
IlvManager.read
will load a DXF file instead of a regular Rogue Wave JViews IVL file. For example:
try { manager.read("myDXFFile.dxf"); } catch (IOException ex) { ex.printStackTrace(); }The contents of the DXF file can be read not only into
IlvManager
but into any implementation of the interface IlvGraphicBag
,
for instance IlvGraphicSet
. However, the layer information
of the DXF file is ignored when not reading into an IlvManager
.
The IlvDXFReader reads the DXF file and adds the graphic objects defined in the DXF file to the manager. If an error occurs during this process, an exception of the type IOException can be thrown and must be caught.
Configuration options can be set on the
IlvDXFReaderConfigurator
. A default configurator is created when using
the constructor IlvDXFReader()
. You can also pass your own
instance of configurator to IlvDXFReader(IlvDXFReaderConfigurator)
.
You can retrieve the current instance of configurator using getConfigurator()
.
The reader delegates the conversion of the DXF entities into Rogue Wave JViews graphic
objects to a factory: IlvDXFGraphicFactory
. A default implementation is
provided: IlvDefaultDXFGraphicFactory
. If needed, you
can provide your own implementation or specialize the default implementation.
To set a new factory, use the method
IlvDXFReaderConfigurator.setGraphicFactory(IlvDXFGraphicFactory)
.
The DXF format (Drawing eXchange Format) is the exchange format of AutoCAD. This format supports vector graphics (polygons, arcs, lines, points...) and layers. The specifications of the various versions of the DXF format can be found at the following URL: http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=5129239
Constructor and Description |
---|
IlvDXFReader()
Creates a new
IlvDXFReader with a default configurator. |
IlvDXFReader(IlvDXFReaderConfigurator configurator)
Creates a new
IlvDXFReader with the given configurator. |
Modifier and Type | Method and Description |
---|---|
IlvDXFReaderConfigurator |
getConfigurator()
Returns the configurator.
|
void |
read(InputStream dxfStream,
IlvGraphicBag bag)
Reads the DXF file from the input stream and fills the provided bag.
|
void |
read(String dxfFileName,
IlvGraphicBag bag)
Reads the DXF file and fills the provided bag.
|
void |
read(URL url,
IlvGraphicBag bag)
Reads a DXF file from the provided URL and fills the provided
graphic bag.
|
public IlvDXFReader()
IlvDXFReader
with a default configurator.public IlvDXFReader(IlvDXFReaderConfigurator configurator)
IlvDXFReader
with the given configurator.public final IlvDXFReaderConfigurator getConfigurator()
public void read(URL url, IlvGraphicBag bag) throws IOException
IOException
public void read(String dxfFileName, IlvGraphicBag bag) throws IOException
IOException
public void read(InputStream dxfStream, IlvGraphicBag bag) throws IOException
IOException
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.