@LcdService(service=ILcdModelEncoder.class, priority=20000) public class TLcdMIFModelEncoder extends Object implements ILcdModelEncoder, ILcdOutputStreamFactoryCapable
ILcdModelEncoder
creates MIF (MapInfo Interchange Format) files from
an ILcdModel
containing any of the shapes displayed in the list below.
The TLcdMIFModelEncoder
encodes
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.TLcdMIFModelReferenceParser
,
Serialized FormConstructor and Description |
---|
TLcdMIFModelEncoder() |
Modifier and Type | Method and Description |
---|---|
boolean |
canExport(ILcdModel aModel,
String aDestination)
Returns whether this encoder can export the specified model to the specified destination.
|
boolean |
canSave(ILcdModel aModel)
Returns whether this model encoder can save the specified model to the location it originally came from.
|
protected 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 |
export(ILcdModel aModel,
String aDestination)
Exports the specified model to the specified destination.
|
String |
getDisplayName()
Returns a short, displayable name for the format this
ILcdModelEncoder encodes to. |
ILcdOutputStreamFactory |
getOutputStreamFactory()
Returns the factory to create output streams which are used in the methods
createBufferedWriter(String) and createMIDBufferedWriter(String) . |
void |
save(ILcdModel aModel)
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 methods
createBufferedWriter(String) and createMIDBufferedWriter(String) . |
protected void |
write2DArc(ILcdArc aArc,
BufferedWriter aBufferedWriter)
Writes the given
ILcdArc as an ellipse (Ellipse). |
protected void |
write2DEllipse(ILcdCircle aCircle,
BufferedWriter aBufferedWriter)
Writes the given
ILcdCircle as an ellipse (Ellipse). |
protected void |
write2DEllipse(ILcdEllipse aEllipse,
BufferedWriter aBufferedWriter)
Writes the given
ILcdEllipse as an ellipse (Ellipse). |
protected void |
write2DPLine(ILcdPointList aPointList,
BufferedWriter aBufferedWriter,
boolean aWritePenClause)
Writes the given
ILcdPointList 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 given
ILcdPoint as a point (Point) and adds a symbol clause. |
protected void |
write2DRectangle(ILcdBounds aBounds,
BufferedWriter aBufferedWriter)
Writes the given
ILcdBounds as a 2D rectangle (Rect). |
protected void |
write2DRegion(ILcdComplexPolygon aComplexPolygon,
BufferedWriter aBufferedWriter)
Writes the given
ILcdComplexPolygon as a 2D region (Region). |
protected void |
write2DRegion(ILcdPolygon aPolygon,
BufferedWriter aBufferedWriter)
Writes the given
ILcdPolygon 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 given
ILcdText as a TEXT. |
protected void |
writeBrushClause(Object aObject,
BufferedWriter aBufferedWriter)
Encodes fill style for
TLcdMIFRegion 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 given
ILcdShapeList to
the given buffered writer. |
protected void |
writePenClause(Object aObject,
BufferedWriter aBufferedWriter)
Encodes the line style for
TLcdMIFRegion or TLcdMIFPLine objects as a
pen clause (Pen). |
protected void |
writeSymbolClause(Object aObject,
BufferedWriter aBufferedWriter)
Writes the symbol clause corresponding to a given object.
|
public String getDisplayName()
ILcdModelEncoder
ILcdModelEncoder
encodes to.getDisplayName
in interface ILcdModelEncoder
ILcdModelEncoder
.public boolean canExport(ILcdModel aModel, String aDestination)
ILcdModelEncoder
canExport
in interface ILcdModelEncoder
aModel
- the model to be verified.aDestination
- the location where the model should be exported to.true
if this encoder can export the specified model to the
specified location, false
otherwise.ILcdModelEncoder.export(com.luciad.model.ILcdModel, java.lang.String)
public void export(ILcdModel aModel, String aDestination) throws IllegalArgumentException, IOException
ILcdModelEncoder
export
in interface ILcdModelEncoder
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.IllegalArgumentException
- if the model cannot be saved by this encoder (!canExport(aModel, aDestinationName)
).IOException
- if an I/O error occurs during encoding.public boolean canSave(ILcdModel aModel)
ILcdModelEncoder
canSave
in interface ILcdModelEncoder
aModel
- the model to be verified.true
if this encoder can save the model in the location where it originally came from,
false
otherwise.ILcdModelEncoder.save(com.luciad.model.ILcdModel)
public void save(ILcdModel aModel) throws IllegalArgumentException, IOException
ILcdModelEncoder
save
in interface ILcdModelEncoder
aModel
- the model to be saved.IllegalArgumentException
- if the model cannot be saved by this encoder (!canSave(aModel)
).IOException
- if an I/O error occurs during encoding.protected BufferedWriter createBufferedWriter(String aFileName) throws IllegalArgumentException
aFileName
- the file name to write to.IllegalArgumentException
- if aFileName is the file name
of an existing read-only file.protected BufferedWriter createMIDBufferedWriter(String aMIFFileName) throws IllegalArgumentException
aMIFFileName
- the file name of the mif file the mid file is accompanying.IllegalArgumentException
- if the accompanying mid the mif file name is an existing
read only filepublic ILcdOutputStreamFactory getOutputStreamFactory()
createBufferedWriter(String)
and createMIDBufferedWriter(String)
.getOutputStreamFactory
in interface ILcdOutputStreamFactoryCapable
public void setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
createBufferedWriter(String)
and createMIDBufferedWriter(String)
.setOutputStreamFactory
in interface ILcdOutputStreamFactoryCapable
aOutputStreamFactory
- the factory to create output streams.protected void writeCoordSysClause(ILcdModel aModel, BufferedWriter aBufferedWriter) throws IOException
aModel
- the model whose reference is translated in a coordinate system clause.aBufferedWriter
- sink for output.IOException
- when writing to the buffered writer fails.protected void writeColumnClause(ILcdModel aModel, BufferedWriter aBufferedWriter) throws IOException
aModel
- whose model descriptors features are written as a columns clause.aBufferedWriter
- sink for output.IOException
- when writing to the buffered writer fails.protected int writeElements(ILcdShapeList aShapeList, BufferedWriter aMIFBufferedWriter) throws IOException
ILcdShapeList
to
the given buffered writer.aShapeList
- the elements to be encoded.aMIFBufferedWriter
- the writer for MIF data.IOException
- when writing to one of the buffered writers fails.protected void write2DRegion(ILcdShapeList aShapeList, BufferedWriter aBufferedWriter) throws IOException
ILcdShapeList
containing
ILcdPointList
objects as a 2D region (Region).aShapeList
- the shape list to encode.aBufferedWriter
- sink for output.IOException
- when writing to the buffered writer fails.protected void write2DRegion(ILcdComplexPolygon aComplexPolygon, BufferedWriter aBufferedWriter) throws IOException
ILcdComplexPolygon
as a 2D region (Region).aComplexPolygon
- the complex polygon to encode.aBufferedWriter
- sink for output.IOException
- when writing to the buffered writer fails.protected void write2DRegion(ILcdPolygon aPolygon, BufferedWriter aBufferedWriter) throws IOException
ILcdPolygon
as a 2D region (Region 1).aPolygon
- the polygon to encode.aBufferedWriter
- sink for output.IOException
- when writing to the buffered writer fails.protected void write2DPLine(ILcdShapeList aShapeList, BufferedWriter aBufferedWriter) throws IOException
ILcdShapeList
containing 1 point list as 2D polyline
(PLine), 1 pen clause per shape list.aShapeList
- the shape list to encode.aBufferedWriter
- sink for output.IOException
- when writing to the buffered writer fails.protected void write2DPLine(ILcdPointList aPointList, BufferedWriter aBufferedWriter, boolean aWritePenClause) throws IOException
ILcdPointList
as a 2D polyline (PLine) with 1 pen
clause if aWritePenClause is true.aPointList
- the point list to encode.aBufferedWriter
- sink for output.aWritePenClause
- whether to write a pen clause or not.IOException
- when writing to the buffered writer fails.protected void write2DPoint(ILcdPoint aPoint, BufferedWriter aBufferedWriter) throws IOException
ILcdPoint
as a point (Point) and adds a symbol clause.aPoint
- the point to encode.aBufferedWriter
- sink for output.IOException
- when writing to the buffered writer fails.protected void write2DEllipse(ILcdCircle aCircle, BufferedWriter aBufferedWriter) throws IOException
ILcdCircle
as an ellipse (Ellipse).aCircle
- the circle to encode.aBufferedWriter
- sink for output.IOException
- when writing to the buffered writer fails.protected void write2DEllipse(ILcdEllipse aEllipse, BufferedWriter aBufferedWriter) throws IOException
ILcdEllipse
as an ellipse (Ellipse).aEllipse
- the ellipse to encode.aBufferedWriter
- sink for output.IOException
- when writing to the buffered writer fails.protected void write2DArc(ILcdArc aArc, BufferedWriter aBufferedWriter) throws IOException
ILcdArc
as an ellipse (Ellipse).aArc
- the arc to encode.aBufferedWriter
- sink for output.IOException
- when writing to the buffered writer fails.protected void write2DRectangle(ILcdBounds aBounds, BufferedWriter aBufferedWriter) throws IOException
ILcdBounds
as a 2D rectangle (Rect).aBounds
- the bounds to encode.aBufferedWriter
- sink for output.IOException
- when writing to the buffered writer fails.protected void write2DText(ILcdText aText, BufferedWriter aBufferedWriter) throws IOException
ILcdText
as a TEXT.aText
- The text to write to the given Writer
. Never
null
.aBufferedWriter
- The Writer
to which the text must be written. Never
null
.IOException
- when writing the text to the Writer
fails.protected void writeSymbolClause(Object aObject, BufferedWriter aBufferedWriter) throws IOException
aObject
- the object whose symbol is written.aBufferedWriter
- the output sink.IOException
- when writing to the buffered writer fails.protected void writePenClause(Object aObject, BufferedWriter aBufferedWriter) throws IOException
TLcdMIFRegion
or TLcdMIFPLine
objects as a
pen clause (Pen). For other objects a default pen clause is written.aObject
- the object to encode the line style for.aBufferedWriter
- the sink for output.IOException
- when writing to the buffered writer fails.protected void writeBrushClause(Object aObject, BufferedWriter aBufferedWriter) throws IOException
TLcdMIFRegion
objects as a brush clause (Brush).aObject
- the object to encode the fill style for (currently only TLcdMIFRegion
).aBufferedWriter
- the sink for output.IOException
- when writing to the buffered writer fails.protected void writeCenterClause(Object aObject, BufferedWriter aBufferedWriter) throws IOException
aObject
- the object whose center is encoded.aBufferedWriter
- output sink.IOException
- when writing to the buffered writer fails.protected final String colorToString(Color aColor)
((aColor.getRed() * 65536) + (aColor.getGreen() * 256) + aColor.getBlue())
.aColor
- The color for which to get the MIF representation. Must not be null.