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
TLcdDataTypes. 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether this encoder can export the specified model to the specified destination.booleanReturns whether this model encoder can save the specified model to the location it originally came from.protected final StringcolorToString(Color aColor) Gets the MIF color representation for aColor.protected BufferedWritercreateBufferedWriter(String aFileName) Called by the save and export methods to redirect output to the mif and mid files using a buffered writer.protected BufferedWritercreateMIDBufferedWriter(String aMIFFileName) Called by the save and export methods to redirect output to the mid files using a buffered writer.voidExports the specified model to the specified destination.Returns a short, displayable name for the format thisILcdModelEncoderencodes to.Returns the factory to create output streams which are used in the methodscreateBufferedWriter(String)andcreateMIDBufferedWriter(String).voidSaves the model to the location where it originally came from.voidsetOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory) Sets the factory to create output streams which are used in the methodscreateBufferedWriter(String)andcreateMIDBufferedWriter(String).protected voidwrite2DArc(ILcdArc aArc, BufferedWriter aBufferedWriter) Writes the givenILcdArcas an ellipse (Ellipse).protected voidwrite2DEllipse(ILcdCircle aCircle, BufferedWriter aBufferedWriter) Writes the givenILcdCircleas an ellipse (Ellipse).protected voidwrite2DEllipse(ILcdEllipse aEllipse, BufferedWriter aBufferedWriter) Writes the givenILcdEllipseas an ellipse (Ellipse).protected voidwrite2DPLine(ILcdPointList aPointList, BufferedWriter aBufferedWriter, boolean aWritePenClause) Writes the givenILcdPointListas a 2D polyline (PLine) with 1 pen clause if aWritePenClause is true.protected voidwrite2DPLine(ILcdShapeList aShapeList, BufferedWriter aBufferedWriter) Deprecated.Use #writeElements(ILcdShapeList, BufferedWriter)protected voidwrite2DPoint(ILcdPoint aPoint, BufferedWriter aBufferedWriter) Writes the givenILcdPointas a point (Point) and adds a symbol clause.protected voidwrite2DRectangle(ILcdBounds aBounds, BufferedWriter aBufferedWriter) Writes the givenILcdBoundsas a 2D rectangle (Rect).protected voidwrite2DRegion(ILcdComplexPolygon aComplexPolygon, BufferedWriter aBufferedWriter) Writes the givenILcdComplexPolygonas a 2D region (Region).protected voidwrite2DRegion(ILcdPolygon aPolygon, BufferedWriter aBufferedWriter) Writes the givenILcdPolygonas a 2D region (Region 1).protected voidwrite2DRegion(ILcdShapeList aShapeList, BufferedWriter aBufferedWriter) Deprecated.Use #writeElements(ILcdShapeList, BufferedWriter)protected voidwrite2DText(ILcdText aText, BufferedWriter aBufferedWriter) Writes the givenILcdTextas a TEXT.protected voidwriteBrushClause(Object aObject, BufferedWriter aBufferedWriter) Encodes fill style forTLcdMIFRegionobjects as a brush clause (Brush).protected voidwriteCenterClause(Object aObject, BufferedWriter aBufferedWriter) Encodes the focus point of an object.protected voidwriteColumnClause(ILcdModel aModel, BufferedWriter aBufferedWriter) Writes the columns clause to the given buffered writer.protected voidwriteCoordSysClause(ILcdModel aModel, BufferedWriter aBufferedWriter) Writes the coordinate system clause to the given buffered writer.protected intwriteElements(ILcdShapeList aShapeList, BufferedWriter aMIFBufferedWriter) Writes the elements of the givenILcdShapeListto the given buffered writer.protected voidwritePenClause(Object aObject, BufferedWriter aBufferedWriter) Encodes the line style forTLcdMIFRegionorTLcdMIFPLineobjects as a pen clause (Pen).protected voidwriteSymbolClause(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:ILcdModelEncoderReturns a short, displayable name for the format thisILcdModelEncoderencodes to.- Specified by:
getDisplayNamein interfaceILcdModelEncoder- Returns:
- the displayable name of this
ILcdModelEncoder.
-
canExport
Description copied from interface:ILcdModelEncoderReturns 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:
canExportin interfaceILcdModelEncoder- Parameters:
aModel- the model to be verified.aDestination- the location where the model should be exported to.- Returns:
trueif this encoder can export the specified model to the specified location,falseotherwise.- See Also:
-
export
public void export(ILcdModel aModel, String aDestination) throws IllegalArgumentException, IOException Description copied from interface:ILcdModelEncoderExports the specified model to the specified destination.- Specified by:
exportin 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:ILcdModelEncoderReturns 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:
canSavein interfaceILcdModelEncoder- Parameters:
aModel- the model to be verified.- Returns:
trueif this encoder can save the model in the location where it originally came from,falseotherwise.- See Also:
-
save
Description copied from interface:ILcdModelEncoderSaves the model to the location where it originally came from.- Specified by:
savein 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:
getOutputStreamFactoryin 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:
setOutputStreamFactoryin 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 givenILcdShapeListto 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 givenILcdShapeListcontainingILcdPointListobjects 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 givenILcdComplexPolygonas 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 givenILcdPolygonas 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 givenILcdShapeListcontaining 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 givenILcdPointListas 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 givenILcdPointas 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 givenILcdCircleas 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 givenILcdEllipseas 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 givenILcdArcas 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 givenILcdBoundsas 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 givenILcdTextas a TEXT.- Parameters:
aText- The text to write to the givenWriter. Nevernull.aBufferedWriter- TheWriterto which the text must be written. Nevernull.- Throws:
IOException- when writing the text to theWriterfails.
-
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 forTLcdMIFRegionorTLcdMIFPLineobjects 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 forTLcdMIFRegionobjects 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.
-