ilog.views.dxf
Class IlvDefaultDXFGraphicFactory

java.lang.Object
  extended by ilog.views.dxf.IlvDefaultDXFGraphicFactory
All Implemented Interfaces:
IlvDXFGraphicFactory

public class IlvDefaultDXFGraphicFactory
extends Object
implements IlvDXFGraphicFactory

The default implementation of the IlvDXFGraphicFactory.

Since:
JViews 8.0
See Also:
IlvDXFReader, IlvDXFReaderConfigurator.setGraphicFactory(ilog.views.dxf.IlvDXFGraphicFactory)

Constructor Summary
IlvDefaultDXFGraphicFactory()
          Creates a new default graphic factory for importing DXF files as ILOG JViews graphic objects.
 
Method Summary
 void addObject(IlvGraphic obj, IlvGraphicBag bag)
          Adds a graphic object to a given graphic bag.
 void addObject(IlvGraphic obj, IlvManager manager, int layerIndex)
          Adds a graphic object to a given layer of a manager.
 IlvGraphic create3DFace(IlvPoint[] points, Color color)
          Creates a graphic object for the DXF entity 3DFACE (rendered in 2D).
 IlvGraphic createArc(IlvPoint center, float radius, float startAngle, float angleRange, float thickness, Color color)
          Creates a graphic object for the DXF entity ARC.
 IlvGraphic createCircle(IlvPoint center, float radius, float thickness, Color color)
          Creates a graphic object for the DXF entity CIRCLE.
 IlvGraphic createDimension(String text, short type, IlvPoint p0, IlvPoint p1, IlvPoint p2, IlvPoint p3, IlvPoint p4, IlvPoint p5, IlvPoint p6)
          Creates a graphic object for the DXF entity DIMENSION.
 IlvGraphic createInsert(IlvGraphicVector children, String blockName, Color color)
          Creates a graphic object for the DXF entity INSERT, The default implementation creates an IlvGraphicSet containing the child objects, except if there is only one child object, in which case this object is returned.
 IlvGraphic createLine(IlvPoint from, IlvPoint to, float thickness, Color color)
          Creates a graphic object for the DXF entity LINE.
 IlvGraphic createPoint(IlvPoint point, float thickness, Color color)
          Creates a graphic object for the DXF entity POINT.
 IlvGraphic createPolyline(IlvPoint[] points, boolean closed, boolean filled, float thickness, Color color)
          Creates a graphic object for the DXF entities POLYLINE and LWPOLYLINE.
 IlvGraphic createSolid(IlvPoint[] points, float thickness, Color color)
          Creates a graphic object for the DXF entity SOLID.
 IlvGraphic createSpline(IlvPoint[] points, boolean closed, float thickness, Color color)
          Creates a graphic object for the DXF entity SPLINE.
 IlvGraphic createText(IlvPoint location, String text, boolean underlined, boolean antialiased, Font font, Color color)
          Creates a graphic object for the DXF entities TEXT and MTEXT.
 IlvGraphic createTrace(IlvPoint[] points, float thickness, Color color)
          Creates a graphic object for the DXF entity TRACE.
static String getBlockName(IlvGraphic blockGraphic)
          Returns the name of block represented by the provided graphic object.
 IlvManagerLayer prepareLayer(IlvManager manager, String layerName)
          Prepares a manager layer.
static void setBlockName(IlvGraphic blockGraphic, String blockName)
          Sets the name of the block represented by the provided graphic object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvDefaultDXFGraphicFactory

public IlvDefaultDXFGraphicFactory()
Creates a new default graphic factory for importing DXF files as ILOG JViews graphic objects.

Method Detail

addObject

public void addObject(IlvGraphic obj,
                      IlvManager manager,
                      int layerIndex)
Adds a graphic object to a given layer of a manager.

The DXF reader calls this method if the contents of the DXF file is read into an IlvManager or a subclass. Otherwise, if the read is done in another type of IlvGraphicBag, for instance in an IlvGraphicSet, the reader calls the method addObject(IlvGraphic, IlvGraphicBag) instead.

Specified by:
addObject in interface IlvDXFGraphicFactory
Parameters:
obj - The graphic object to be added to the manager.
manager - The manager into which the contents of the DXF file is read.
layerIndex - The index of the manager layer where the object must be added.

addObject

public void addObject(IlvGraphic obj,
                      IlvGraphicBag bag)
Adds a graphic object to a given graphic bag.

The DXF reader calls this method if the contents of the DXF file is read into a IlvGraphicBag which is not an IlvManager or a subclass, for instance an IlvGraphicSet. Otherwise, if the read is done in an IlvManager or a subclass, the reader calls the method addObject(IlvGraphic, IlvManager, int) instead.

Specified by:
addObject in interface IlvDXFGraphicFactory
Parameters:
obj - The graphic object to be added to the bag.
bag - The bag where the graphic object must be added.

prepareLayer

public IlvManagerLayer prepareLayer(IlvManager manager,
                                    String layerName)
Prepares a manager layer.

The default implementation adds a new layer on top of the existing layers (if any), and sets the name of this layer (see IlvManager.setLayerName(int, String)).

Notice the following:

Specified by:
prepareLayer in interface IlvDXFGraphicFactory
Parameters:
manager - The manager into which the contents of the DXF file is read.
layerName - The name of the layer as read in the DXF file.
Returns:
The layer of the manager where the entities of the DXF file that belong to the layer named layerName must be added.

createPoint

public IlvGraphic createPoint(IlvPoint point,
                              float thickness,
                              Color color)
Creates a graphic object for the DXF entity POINT. The default implementation creates an IlvMarker of type IlvMarker.IlvMarkerPlus.

Specified by:
createPoint in interface IlvDXFGraphicFactory
Parameters:
point - The location of the graphic object.
thickness - The thickness parameter.
color - The color.
Returns:
The created graphic object.

createLine

public IlvGraphic createLine(IlvPoint from,
                             IlvPoint to,
                             float thickness,
                             Color color)
Creates a graphic object for the DXF entity LINE. The default implementation creates an IlvLine.

Specified by:
createLine in interface IlvDXFGraphicFactory
Parameters:
from - The starting point of the line.
to - The ending point of the line.
thickness - The thickness of the line.
color - The color of the line.
Returns:
The created graphic object.

createArc

public IlvGraphic createArc(IlvPoint center,
                            float radius,
                            float startAngle,
                            float angleRange,
                            float thickness,
                            Color color)
Creates a graphic object for the DXF entity ARC. The default implementation creates an IlvArc.

Specified by:
createArc in interface IlvDXFGraphicFactory
Parameters:
center - The center of the arc.
radius - The radius of the arc.
startAngle - The start angle of the arc in degrees.
angleRange - The angle range of the arc in degrees.
thickness - The thickness of the arc.
color - The color of the arc.
Returns:
The created graphic object.

createCircle

public IlvGraphic createCircle(IlvPoint center,
                               float radius,
                               float thickness,
                               Color color)
Creates a graphic object for the DXF entity CIRCLE. The default implementation creates an IlvEllipse with circular shape.

Specified by:
createCircle in interface IlvDXFGraphicFactory
Parameters:
center - The center of the circle.
radius - The radius of the circle.
thickness - The thickness of the circle.
color - The color of the circle.
Returns:
The created graphic object.

createPolyline

public IlvGraphic createPolyline(IlvPoint[] points,
                                 boolean closed,
                                 boolean filled,
                                 float thickness,
                                 Color color)
Creates a graphic object for the DXF entities POLYLINE and LWPOLYLINE. The default implementation creates an IlvPolygon if closed and filled are both true, otherwise it creates an IlvPolyline.

Specified by:
createPolyline in interface IlvDXFGraphicFactory
Parameters:
points - The array of points defining the polyline.
closed - Indicates whether the polyline is closed (in this case, the first and last points in the array of points have equal coordinates).
filled - Indicates whether the interior of the polyline is filled.
thickness - The thickness of the polyline.
color - The color of the polyline.
Returns:
The created graphic object.

createSpline

public IlvGraphic createSpline(IlvPoint[] points,
                               boolean closed,
                               float thickness,
                               Color color)
Creates a graphic object for the DXF entity SPLINE. The default implementation creates an IlvSpline.

Specified by:
createSpline in interface IlvDXFGraphicFactory
Parameters:
points - The array of points defining the control points of the spline.
closed - Indicates whether the spline is closed.
thickness - The thickness of the spline.
color - The color of the spline.
Returns:
The created graphic object.

createTrace

public IlvGraphic createTrace(IlvPoint[] points,
                              float thickness,
                              Color color)
Creates a graphic object for the DXF entity TRACE. The default implementation creates an IlvPolyline.

Specified by:
createTrace in interface IlvDXFGraphicFactory
Parameters:
points - The array of points defining the trace.
thickness - The thickness of the trace.
color - The color of the trace.
Returns:
The created graphic object.

createSolid

public IlvGraphic createSolid(IlvPoint[] points,
                              float thickness,
                              Color color)
Creates a graphic object for the DXF entity SOLID. The default implementation creates an IlvPolyline.

Specified by:
createSolid in interface IlvDXFGraphicFactory
Parameters:
points - The array of points defining the solid.
thickness - The thickness of the solid.
color - The color of the solid.
Returns:
The created graphic object.

create3DFace

public IlvGraphic create3DFace(IlvPoint[] points,
                               Color color)
Creates a graphic object for the DXF entity 3DFACE (rendered in 2D). The default implementation creates an IlvPolyline.

Specified by:
create3DFace in interface IlvDXFGraphicFactory
Parameters:
points - The array of points defining the 3D face.
color - The color of the 3D face.
Returns:
The created graphic object.

createText

public IlvGraphic createText(IlvPoint location,
                             String text,
                             boolean underlined,
                             boolean antialiased,
                             Font font,
                             Color color)
Creates a graphic object for the DXF entities TEXT and MTEXT. The default implementation creates an IlvText.

Specified by:
createText in interface IlvDXFGraphicFactory
Parameters:
location - The location of the text.
text - The text to be shown.
underlined - Tells whether the text must be underlined.
antialiased - Tells whether the text must be antialiased.
font - The font of the text.
color - The color of the text.
Returns:
The created graphic object.

createDimension

public IlvGraphic createDimension(String text,
                                  short type,
                                  IlvPoint p0,
                                  IlvPoint p1,
                                  IlvPoint p2,
                                  IlvPoint p3,
                                  IlvPoint p4,
                                  IlvPoint p5,
                                  IlvPoint p6)
Creates a graphic object for the DXF entity DIMENSION. The default implementation creates an IlvGraphicSet containing the various graphic objects needed for rendering the dimension entity.

Specified by:
createDimension in interface IlvDXFGraphicFactory
Parameters:
text - The text of the dimension.
type - The dimension type. See the Autodesk documentation of the DXF format: Values 0-6 are integer values that represent the dimension type. Values 32, 64, and 128 are bit values, which are added to the integer values (value 32 is always set in R13 and later releases).
0 = Rotated, horizontal, or vertical; 1 = Aligned
2 = Angular; 3 = Diameter; 4 = Radius
5 = Angular 3 point; 6 = Ordinate
32 = Indicates that the block reference (group code 2) is referenced by this dimension only
64 = Ordinate type. This is a bit value (bit 7) used only with integer value 6. If set, ordinate is X-type; if not set, ordinate is Y-type
128 = This is a bit value (bit 8) added to the other group 70 values if the dimension text has been positioned at a user-defined location rather than at the default location
p0 - Definition point.
p1 - Middle point.
p2 - Insertion point.
p3 - Definition point for linear and angular dimensions.
p4 - Definition point for linear and angular dimensions.
p5 - Definition point for diameter, radius, and angular dimensions.
p6 - Point defining dimension arc for angular dimensions.
Returns:
The created graphic object.

createInsert

public IlvGraphic createInsert(IlvGraphicVector children,
                               String blockName,
                               Color color)
Creates a graphic object for the DXF entity INSERT,

The default implementation creates an IlvGraphicSet containing the child objects, except if there is only one child object, in which case this object is returned.

The name of the block is stored by calling the method setBlockName(IlvGraphic, String). To retrieve this name, use the method getBlockName(IlvGraphic).

Specified by:
createInsert in interface IlvDXFGraphicFactory
Parameters:
children - The graphic objects contained in the instance of the block.
blockName - The name of the DXF BLOCK, as read in the DXF file.
color - The color of the instance of the block.
Returns:
The created graphic object.
See Also:
getBlockName(IlvGraphic), setBlockName(IlvGraphic, String)

setBlockName

public static void setBlockName(IlvGraphic blockGraphic,
                                String blockName)
Sets the name of the block represented by the provided graphic object. The method Does nothing if the name is null or an empty string.

The name of the block is stored in a named property of the returned graphic object. To retrieve this name after the DXF file has been read, use the method getBlockName(IlvGraphic).

You do not need to call this method, but you can use it if if you override createInsert(IlvGraphicVector, String, Color).

Parameters:
blockGraphic - The graphic object corresponding to the instance of DXF block.
blockName - The name of the DXF block.
See Also:
createInsert(IlvGraphicVector, String, Color), getBlockName(IlvGraphic)

getBlockName

public static String getBlockName(IlvGraphic blockGraphic)
Returns the name of block represented by the provided graphic object. Returns null if the object does not belong to a block. It can also return null if the method createInsert(IlvGraphicVector, String, Color) is overridden and does not store the name.

Parameters:
blockGraphic - The graphic object corresponding to the instance of DXF block.
Returns:
The name of the DXF block.
See Also:
createInsert(IlvGraphicVector, String, Color), setBlockName(IlvGraphic, String)


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