Package com.luciad.format.mif
Class TLcdMIFModelEncoder
java.lang.Object
com.luciad.format.mif.TLcdMIFModelEncoder
- All Implemented Interfaces:
ILcdOutputStreamFactoryCapable
,ILcdModelEncoder
,Serializable
@LcdService(service=ILcdModelEncoder.class,
priority=20000)
public class TLcdMIFModelEncoder
extends Object
implements ILcdModelEncoder, ILcdOutputStreamFactoryCapable
This
ILcdModelEncoder
creates MIF (MapInfo Interchange Format) files from
an ILcdModel
containing any of the shapes displayed in the list below.
The TLcdMIFModelEncoder
encodes
- ILcdPoint as Point
- ILcdPolygon as Region
- ILcdPolyline as Line
- ILcdCircle as Ellipse
- ILcdEllipse as Ellipse
- ILcdArc as Arc
- ILcdBounds as Rect
- ILcdShapeList as an expanded list of its composing shapes.
ILcdDataObject
, this model encoder will
encode each of the properties of the TLcdDataType
of the shape. Note
that this exporter cannot export non-primitive properties with complex
TLcdDataType
s. It will skip these properties. Also note that the exporter
can only export properties for models that have an ILcdDataModelDescriptor
with only a single model element data type
.
Only a subset of the coordinate systems available in the MIF format is supported.
Rotated ellipses are not supported.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether this encoder can export the specified model to the specified destination.boolean
Returns whether this model encoder can save the specified model to the location it originally came from.protected final String
colorToString
(Color aColor) Gets the MIF color representation for aColor.protected BufferedWriter
createBufferedWriter
(String aFileName) Called by the save and export methods to redirect output to the mif and mid files using a buffered writer.protected BufferedWriter
createMIDBufferedWriter
(String aMIFFileName) Called by the save and export methods to redirect output to the mid files using a buffered writer.void
Exports the specified model to the specified destination.Returns a short, displayable name for the format thisILcdModelEncoder
encodes to.Returns the factory to create output streams which are used in the methodscreateBufferedWriter(String)
andcreateMIDBufferedWriter(String)
.void
Saves the model to the location where it originally came from.void
setOutputStreamFactory
(ILcdOutputStreamFactory aOutputStreamFactory) Sets the factory to create output streams which are used in the methodscreateBufferedWriter(String)
andcreateMIDBufferedWriter(String)
.protected void
write2DArc
(ILcdArc aArc, BufferedWriter aBufferedWriter) Writes the givenILcdArc
as an ellipse (Ellipse).protected void
write2DEllipse
(ILcdCircle aCircle, BufferedWriter aBufferedWriter) Writes the givenILcdCircle
as an ellipse (Ellipse).protected void
write2DEllipse
(ILcdEllipse aEllipse, BufferedWriter aBufferedWriter) Writes the givenILcdEllipse
as an ellipse (Ellipse).protected void
write2DPLine
(ILcdPointList aPointList, BufferedWriter aBufferedWriter, boolean aWritePenClause) Writes the givenILcdPointList
as a 2D polyline (PLine) with 1 pen clause if aWritePenClause is true.protected void
write2DPLine
(ILcdShapeList aShapeList, BufferedWriter aBufferedWriter) Deprecated.Use #writeElements(ILcdShapeList, BufferedWriter)protected void
write2DPoint
(ILcdPoint aPoint, BufferedWriter aBufferedWriter) Writes the givenILcdPoint
as a point (Point) and adds a symbol clause.protected void
write2DRectangle
(ILcdBounds aBounds, BufferedWriter aBufferedWriter) Writes the givenILcdBounds
as a 2D rectangle (Rect).protected void
write2DRegion
(ILcdComplexPolygon aComplexPolygon, BufferedWriter aBufferedWriter) Writes the givenILcdComplexPolygon
as a 2D region (Region).protected void
write2DRegion
(ILcdPolygon aPolygon, BufferedWriter aBufferedWriter) Writes the givenILcdPolygon
as a 2D region (Region 1).protected void
write2DRegion
(ILcdShapeList aShapeList, BufferedWriter aBufferedWriter) Deprecated.Use #writeElements(ILcdShapeList, BufferedWriter)protected void
write2DText
(ILcdText aText, BufferedWriter aBufferedWriter) Writes the givenILcdText
as a TEXT.protected void
writeBrushClause
(Object aObject, BufferedWriter aBufferedWriter) Encodes fill style forTLcdMIFRegion
objects as a brush clause (Brush).protected void
writeCenterClause
(Object aObject, BufferedWriter aBufferedWriter) Encodes the focus point of an object.protected void
writeColumnClause
(ILcdModel aModel, BufferedWriter aBufferedWriter) Writes the columns clause to the given buffered writer.protected void
writeCoordSysClause
(ILcdModel aModel, BufferedWriter aBufferedWriter) Writes the coordinate system clause to the given buffered writer.protected int
writeElements
(ILcdShapeList aShapeList, BufferedWriter aMIFBufferedWriter) Writes the elements of the givenILcdShapeList
to the given buffered writer.protected void
writePenClause
(Object aObject, BufferedWriter aBufferedWriter) Encodes the line style forTLcdMIFRegion
orTLcdMIFPLine
objects as a pen clause (Pen).protected void
writeSymbolClause
(Object aObject, BufferedWriter aBufferedWriter) Writes the symbol clause corresponding to a given object.
-
Constructor Details
-
TLcdMIFModelEncoder
public TLcdMIFModelEncoder()
-
-
Method Details
-
getDisplayName
Description copied from interface:ILcdModelEncoder
Returns a short, displayable name for the format thisILcdModelEncoder
encodes to.- Specified by:
getDisplayName
in interfaceILcdModelEncoder
- Returns:
- the displayable name of this
ILcdModelEncoder
.
-
canExport
Description copied from interface:ILcdModelEncoder
Returns whether this encoder can export the specified model to the specified destination. This method will typically check whether the contents of the specified model are compatible with the format this encoder is written for.- Specified by:
canExport
in interfaceILcdModelEncoder
- Parameters:
aModel
- the model to be verified.aDestination
- the location where the model should be exported to.- Returns:
true
if this encoder can export the specified model to the specified location,false
otherwise.- See Also:
-
export
public void export(ILcdModel aModel, String aDestination) throws IllegalArgumentException, IOException Description copied from interface:ILcdModelEncoder
Exports the specified model to the specified destination.- Specified by:
export
in interfaceILcdModelEncoder
- Parameters:
aModel
- the model to be exported.aDestination
- the location where the model should be saved. Typically, this is a name for the output file, but it can also point to a file containing the required properties to create a set of data files.- Throws:
IllegalArgumentException
- if the model cannot be saved by this encoder (!canExport(aModel, aDestinationName)
).IOException
- if an I/O error occurs during encoding.
-
canSave
Description copied from interface:ILcdModelEncoder
Returns whether this model encoder can save the specified model to the location it originally came from. Often this will only be a simple test, for example checking the type of the model's model descriptor.- Specified by:
canSave
in interfaceILcdModelEncoder
- Parameters:
aModel
- the model to be verified.- Returns:
true
if this encoder can save the model in the location where it originally came from,false
otherwise.- See Also:
-
save
Description copied from interface:ILcdModelEncoder
Saves the model to the location where it originally came from.- Specified by:
save
in interfaceILcdModelEncoder
- Parameters:
aModel
- the model to be saved.- Throws:
IllegalArgumentException
- if the model cannot be saved by this encoder (!canSave(aModel)
).IOException
- if an I/O error occurs during encoding.
-
createBufferedWriter
Called by the save and export methods to redirect output to the mif and mid files using a buffered writer.- Parameters:
aFileName
- the file name to write to.- Returns:
- a buffered writer to allow output to aDestination.
- Throws:
IllegalArgumentException
- if aFileName is the file name of an existing read-only file.
-
createMIDBufferedWriter
protected BufferedWriter createMIDBufferedWriter(String aMIFFileName) throws IllegalArgumentException Called by the save and export methods to redirect output to the mid files using a buffered writer.- Parameters:
aMIFFileName
- the file name of the mif file the mid file is accompanying.- Returns:
- a buffered writer to allow output to the mid file accompanying aMIFFileName.
- Throws:
IllegalArgumentException
- if the accompanying mid the mif file name is an existing read only file
-
getOutputStreamFactory
Returns the factory to create output streams which are used in the methodscreateBufferedWriter(String)
andcreateMIDBufferedWriter(String)
.- Specified by:
getOutputStreamFactory
in interfaceILcdOutputStreamFactoryCapable
- Returns:
- the factory to create output streams.
-
setOutputStreamFactory
Sets the factory to create output streams which are used in the methodscreateBufferedWriter(String)
andcreateMIDBufferedWriter(String)
.- Specified by:
setOutputStreamFactory
in interfaceILcdOutputStreamFactoryCapable
- Parameters:
aOutputStreamFactory
- the factory to create output streams.
-
writeCoordSysClause
protected void writeCoordSysClause(ILcdModel aModel, BufferedWriter aBufferedWriter) throws IOException Writes the coordinate system clause to the given buffered writer.- Parameters:
aModel
- the model whose reference is translated in a coordinate system clause.aBufferedWriter
- sink for output.- Throws:
IOException
- when writing to the buffered writer fails.
-
writeColumnClause
protected void writeColumnClause(ILcdModel aModel, BufferedWriter aBufferedWriter) throws IOException Writes the columns clause to the given buffered writer.- Parameters:
aModel
- whose model descriptors features are written as a columns clause.aBufferedWriter
- sink for output.- Throws:
IOException
- when writing to the buffered writer fails.
-
writeElements
protected int writeElements(ILcdShapeList aShapeList, BufferedWriter aMIFBufferedWriter) throws IOException Writes the elements of the givenILcdShapeList
to the given buffered writer.- Parameters:
aShapeList
- the elements to be encoded.aMIFBufferedWriter
- the writer for MIF data.- Returns:
- the number of elements that were written.
- Throws:
IOException
- when writing to one of the buffered writers fails.
-
write2DRegion
protected void write2DRegion(ILcdShapeList aShapeList, BufferedWriter aBufferedWriter) throws IOException Deprecated.Use #writeElements(ILcdShapeList, BufferedWriter)Writes the givenILcdShapeList
containingILcdPointList
objects as a 2D region (Region).- Parameters:
aShapeList
- the shape list to encode.aBufferedWriter
- sink for output.- Throws:
IOException
- when writing to the buffered writer fails.
-
write2DRegion
protected void write2DRegion(ILcdComplexPolygon aComplexPolygon, BufferedWriter aBufferedWriter) throws IOException Writes the givenILcdComplexPolygon
as a 2D region (Region).- Parameters:
aComplexPolygon
- the complex polygon to encode.aBufferedWriter
- sink for output.- Throws:
IOException
- when writing to the buffered writer fails.
-
write2DRegion
protected void write2DRegion(ILcdPolygon aPolygon, BufferedWriter aBufferedWriter) throws IOException Writes the givenILcdPolygon
as a 2D region (Region 1).- Parameters:
aPolygon
- the polygon to encode.aBufferedWriter
- sink for output.- Throws:
IOException
- when writing to the buffered writer fails.
-
write2DPLine
protected void write2DPLine(ILcdShapeList aShapeList, BufferedWriter aBufferedWriter) throws IOException Deprecated.Use #writeElements(ILcdShapeList, BufferedWriter)Writes the givenILcdShapeList
containing 1 point list as 2D polyline (PLine), 1 pen clause per shape list.- Parameters:
aShapeList
- the shape list to encode.aBufferedWriter
- sink for output.- Throws:
IOException
- when writing to the buffered writer fails.
-
write2DPLine
protected void write2DPLine(ILcdPointList aPointList, BufferedWriter aBufferedWriter, boolean aWritePenClause) throws IOException Writes the givenILcdPointList
as a 2D polyline (PLine) with 1 pen clause if aWritePenClause is true.- Parameters:
aPointList
- the point list to encode.aBufferedWriter
- sink for output.aWritePenClause
- whether to write a pen clause or not.- Throws:
IOException
- when writing to the buffered writer fails.
-
write2DPoint
Writes the givenILcdPoint
as a point (Point) and adds a symbol clause.- Parameters:
aPoint
- the point to encode.aBufferedWriter
- sink for output.- Throws:
IOException
- when writing to the buffered writer fails.
-
write2DEllipse
protected void write2DEllipse(ILcdCircle aCircle, BufferedWriter aBufferedWriter) throws IOException Writes the givenILcdCircle
as an ellipse (Ellipse).- Parameters:
aCircle
- the circle to encode.aBufferedWriter
- sink for output.- Throws:
IOException
- when writing to the buffered writer fails.
-
write2DEllipse
protected void write2DEllipse(ILcdEllipse aEllipse, BufferedWriter aBufferedWriter) throws IOException Writes the givenILcdEllipse
as an ellipse (Ellipse).- Parameters:
aEllipse
- the ellipse to encode.aBufferedWriter
- sink for output.- Throws:
IOException
- when writing to the buffered writer fails.
-
write2DArc
Writes the givenILcdArc
as an ellipse (Ellipse).- Parameters:
aArc
- the arc to encode.aBufferedWriter
- sink for output.- Throws:
IOException
- when writing to the buffered writer fails.
-
write2DRectangle
protected void write2DRectangle(ILcdBounds aBounds, BufferedWriter aBufferedWriter) throws IOException Writes the givenILcdBounds
as a 2D rectangle (Rect).- Parameters:
aBounds
- the bounds to encode.aBufferedWriter
- sink for output.- Throws:
IOException
- when writing to the buffered writer fails.
-
write2DText
Writes the givenILcdText
as a TEXT.- Parameters:
aText
- The text to write to the givenWriter
. Nevernull
.aBufferedWriter
- TheWriter
to which the text must be written. Nevernull
.- Throws:
IOException
- when writing the text to theWriter
fails.
-
writeSymbolClause
Writes the symbol clause corresponding to a given object.- Parameters:
aObject
- the object whose symbol is written.aBufferedWriter
- the output sink.- Throws:
IOException
- when writing to the buffered writer fails.
-
writePenClause
Encodes the line style forTLcdMIFRegion
orTLcdMIFPLine
objects as a pen clause (Pen). For other objects a default pen clause is written.- Parameters:
aObject
- the object to encode the line style for.aBufferedWriter
- the sink for output.- Throws:
IOException
- when writing to the buffered writer fails.
-
writeBrushClause
Encodes fill style forTLcdMIFRegion
objects as a brush clause (Brush).- Parameters:
aObject
- the object to encode the fill style for (currently onlyTLcdMIFRegion
).aBufferedWriter
- the sink for output.- Throws:
IOException
- when writing to the buffered writer fails.
-
writeCenterClause
Encodes the focus point of an object.- Parameters:
aObject
- the object whose center is encoded.aBufferedWriter
- output sink.- Throws:
IOException
- when writing to the buffered writer fails.
-
colorToString
Gets the MIF color representation for aColor. The following formula is used:((aColor.getRed() * 65536) + (aColor.getGreen() * 256) + aColor.getBlue())
.- Parameters:
aColor
- The color for which to get the MIF representation. Must not be null.- Returns:
- The color representation as a string.
-