@LcdService(service=ILcdModelEncoder.class, priority=20000) public class TLcdSVGModelEncoder extends Object implements ILcdModelEncoder, ILcdOutputStreamFactoryCapable
ILcdModelEncoder
allows to encode models to SVG files.
It does not encode styling elements or ILcdDataObject
properties.
It supports the Scalable Vector Graphics (SVG) format as described in:
Scalable Vector Graphics (SVG) 1.0 Specification
W3C Candidate Recommendation 02 November 2000
http://www.w3.org/TR/2000/CR-SVG-20001102/
SVG supports the shapes:
ILcdBounds
)
ILcdCircle
)
ILcdPolygon
)
ILcdPolyline
)
ILcdShapeList
)
ILcdEllipse
)
ILcdPolyline
)
ILcdText
)
ILcdPoint
ILcdArcBand
ILcdOutputStreamFactory
( which provides a stream
for writing the encoded file to, by default a BufferedOutputStream ( FileOutputStream )
) and
a default ILcdSVGShapeWriter
( TLcdSVGUnStyledShapeWriter
) , to encodes a given shape
to a StringBuffer
. These 2 classes can be set.Constructor and Description |
---|
TLcdSVGModelEncoder() |
Modifier and Type | Method and Description |
---|---|
boolean |
canExport(ILcdModel aModel,
String aSource)
Checks if there is at least one shape that can be exported.
|
boolean |
canSave(ILcdModel aModel)
Checks on the destination and then checks if shapes can be
exported.
|
void |
export(ILcdModel aModel,
String aSource)
Exports the
ILcdModel to the destination file and saves the model reference. |
protected String |
getDefaultExtension()
Returns the default extension for files saved with this encoder.
|
String |
getDisplayName()
Gets the display name of this encoder.
|
ILcdModelReferenceEncoder |
getModelReferenceEncoder()
Returns the
ILcdModelReferenceEncoder used to save the model reference. |
ILcdOutputStreamFactory |
getOutputStreamFactory()
Get the used
ILcdOutputStreamfactory to this decoder. |
protected String |
getRootElement()
Returns the name of the root element.
|
ILcdSVGShapeWriter |
getSVGShapeWriter()
Gets the
ILcdSVGShapeWriter that is used to write the shapes. |
static boolean |
isClassTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
boolean |
isTrueSVG()
Returns whether only objects that have an SVG counterpart shall be encoded.
|
void |
save(ILcdModel aModel)
Saves the
ILcdModel . |
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setModelReferenceEncoder(ILcdModelReferenceEncoder aModelReferenceEncoder)
Sets the
ILcdModelReferenceEncoder to use to encode the
model reference. |
void |
setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
Sets a
ILcdOutputFactory to this encoder. |
void |
setSVGShapeWriter(ILcdSVGShapeWriter aShapeWriter)
Sets a
ILcdSVGShapeWriter to this encoder. |
void |
setTrueSVG(boolean aTrueSVG)
Sets whether only objects that have an SVG counterpart shall be encoded.
|
protected void |
writeFooter(Writer aWriter)
Writes the footer of the file.
|
protected void |
writeHeader(Writer aWriter,
ILcdModel aModel)
Writes the header of the file.
|
public String getDisplayName()
getDisplayName
in interface ILcdModelEncoder
String
containing the display name of the encoder.public boolean canSave(ILcdModel aModel)
canSave
in interface ILcdModelEncoder
aModel
- the ILcdModel
to save.ILcdModelEncoder.save(com.luciad.model.ILcdModel)
public ILcdOutputStreamFactory getOutputStreamFactory()
ILcdOutputStreamfactory
to this decoder.getOutputStreamFactory
in interface ILcdOutputStreamFactoryCapable
ILcdOutputStreamfactory
setOutputStreamFactory(com.luciad.io.ILcdOutputStreamFactory)
public void setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
ILcdOutputFactory
to this encoder. A default implementation is set.setOutputStreamFactory
in interface ILcdOutputStreamFactoryCapable
aOutputStreamFactory
- the ILcdOytputStreamFactory
to use.getOutputStreamFactory()
public ILcdModelReferenceEncoder getModelReferenceEncoder()
ILcdModelReferenceEncoder
used to save the model reference.ILcdModelReferenceEncoder
used to save the model reference.setModelReferenceEncoder(com.luciad.model.ILcdModelReferenceEncoder)
public void setModelReferenceEncoder(ILcdModelReferenceEncoder aModelReferenceEncoder)
ILcdModelReferenceEncoder
to use to encode the
model reference.aModelReferenceEncoder
- the ILcdModelReferenceEncoder
to use to encode the
model reference.getModelReferenceEncoder()
public ILcdSVGShapeWriter getSVGShapeWriter()
ILcdSVGShapeWriter
that is used to write the shapes. If no ILcdSVGShapeWriter
is set, the default one will be returned.ILcdSVGShapeWriter
setSVGShapeWriter(com.luciad.format.svg.ILcdSVGShapeWriter)
public void setSVGShapeWriter(ILcdSVGShapeWriter aShapeWriter)
ILcdSVGShapeWriter
to this encoder. The default ILcdSVGShapeWriter
is the
TLcdSVGUnStyledShapeWriter
aShapeWriter
- the ILcdShapeWriter
to be used.getSVGShapeWriter()
public void save(ILcdModel aModel) throws IOException
ILcdModel
.save
in interface ILcdModelEncoder
aModel
- the ILcdModel
to save.IOException
- when an I/O error occurs while saving the model.public boolean canExport(ILcdModel aModel, String aSource)
canExport
in interface ILcdModelEncoder
aModel
- the ILcdModel
containing the shapes.aSource
- the destination to export the ILcdModel
to.ILcdShape
of the
ILcdModel
can be exported.ILcdModelEncoder.export(com.luciad.model.ILcdModel, java.lang.String)
public void setTrueSVG(boolean aTrueSVG)
aTrueSVG
- If true the encoder will not encode ILcd2DEditableArcBand
and ILcdPoint
objects.
These classes have no counterparts in SVG.public boolean isTrueSVG()
public void export(ILcdModel aModel, String aSource) throws IOException
ILcdModel
to the destination file and saves the model reference.
If the ModelReferenceEncoder is unset, this method will write a aSource.ref file.
The exported file is created by:
writeHeader(java.io.Writer, com.luciad.model.ILcdModel)
ILcdSVGShapeWriter.writeElement(java.lang.Object, java.io.Writer)
for every element in the model
writeFooter(java.io.Writer)
.
export
in interface ILcdModelEncoder
aModel
- the ILcdModel
to export.aSource
- the destination to export to.IOException
- when an I/O error occurs while exporting the model.setModelReferenceEncoder(com.luciad.model.ILcdModelReferenceEncoder)
protected String getRootElement()
writeHeader(java.io.Writer, com.luciad.model.ILcdModel)
,
writeFooter(java.io.Writer)
protected String getDefaultExtension()
protected void writeHeader(Writer aWriter, ILcdModel aModel) throws IOException
aWriter
- the writer to write to.aModel
- the model that we are writingIOException
- when an I/O error occurred while writing the header.getRootElement()
protected void writeFooter(Writer aWriter) throws IOException
aWriter
- the writer to write to.IOException
- when an I/O error occurred while writing the footer.getRootElement()
public static void setClassTraceOn(boolean aClassTraceOn)
true
then all log messages are recorded, otherwise only
the informative, warning and error messages are recorded.aClassTraceOn
- if true then all log messages are recorded,
otherwise only the informative, warning and error messages are recorded.public static boolean isClassTraceOn()
true
if tracing is enabled for this class.