ilog.views.dxf
Class IlvDXFReader

java.lang.Object
  extended by ilog.views.dxf.IlvDXFReader

public class IlvDXFReader
extends Object

Class for reading DXF files and for translating the DXF entities into ILOG JViews graphic objects.

Using the DXF Reader

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 ILOG 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.

Customizing the DXF Reader

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 ILOG 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).

About the DXF Format

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 of the DXF format can be found at the following URL: http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=5129239

Limitations

Since:
JViews 8.0

Constructor Summary
IlvDXFReader()
          Creates a new IlvDXFReader with a default configurator.
IlvDXFReader(IlvDXFReaderConfigurator configurator)
          Creates a new IlvDXFReader with the given configurator.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvDXFReader

public IlvDXFReader()
Creates a new IlvDXFReader with a default configurator.


IlvDXFReader

public IlvDXFReader(IlvDXFReaderConfigurator configurator)
Creates a new IlvDXFReader with the given configurator.

Method Detail

getConfigurator

public final IlvDXFReaderConfigurator getConfigurator()
Returns the configurator.


read

public void read(URL url,
                 IlvGraphicBag bag)
          throws IOException
Reads a DXF file from the provided URL and fills the provided graphic bag.

Throws:
IOException

read

public void read(String dxfFileName,
                 IlvGraphicBag bag)
          throws IOException
Reads the DXF file and fills the provided bag.

Throws:
IOException

read

public void read(InputStream dxfStream,
                 IlvGraphicBag bag)
          throws IOException
Reads the DXF file from the input stream and fills the provided bag.

Throws:
IOException


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.