Package com.luciad.format.svg
Class TLcdSVGModelEncoder
java.lang.Object
com.luciad.format.svg.TLcdSVGModelEncoder
- All Implemented Interfaces:
ILcdOutputStreamFactoryCapable
,ILcdModelEncoder
,Serializable
@LcdService(service=ILcdModelEncoder.class,
priority=20000)
public class TLcdSVGModelEncoder
extends Object
implements ILcdModelEncoder, ILcdOutputStreamFactoryCapable
This
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:
- rectangle (
ILcdBounds
) - circle (
ILcdCircle
) - polygon (
ILcdPolygon
) - polyline (
ILcdPolyline
) - shapelist (
ILcdShapeList
) - ellipse (
ILcdEllipse
) - line (
ILcdPolyline
) - text (
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.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if there is at least one shape that can be exported.boolean
Checks on the destination and then checks if shapes can be exported.void
Exports theILcdModel
to the destination file and saves the model reference.protected String
Returns the default extension for files saved with this encoder.Gets the display name of this encoder.Returns theILcdModelReferenceEncoder
used to save the model reference.Get the usedILcdOutputStreamfactory
to this decoder.protected String
Returns the name of the root element.Gets theILcdSVGShapeWriter
that is used to write the shapes.static boolean
Deprecated.This method has been deprecated.boolean
Returns whether only objects that have an SVG counterpart shall be encoded.void
Saves theILcdModel
.static void
setClassTraceOn
(boolean aClassTraceOn) Deprecated.This method has been deprecated.void
setModelReferenceEncoder
(ILcdModelReferenceEncoder aModelReferenceEncoder) Sets theILcdModelReferenceEncoder
to use to encode the model reference.void
setOutputStreamFactory
(ILcdOutputStreamFactory aOutputStreamFactory) Sets aILcdOutputFactory
to this encoder.void
setSVGShapeWriter
(ILcdSVGShapeWriter aShapeWriter) Sets aILcdSVGShapeWriter
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.
-
Constructor Details
-
TLcdSVGModelEncoder
public TLcdSVGModelEncoder()
-
-
Method Details
-
getDisplayName
Gets the display name of this encoder.- Specified by:
getDisplayName
in interfaceILcdModelEncoder
- Returns:
- a
String
containing the display name of the encoder.
-
canSave
Checks on the destination and then checks if shapes can be exported.- Specified by:
canSave
in interfaceILcdModelEncoder
- Parameters:
aModel
- theILcdModel
to save.- Returns:
- true if the destination is set and is true.
- See Also:
-
getOutputStreamFactory
Get the usedILcdOutputStreamfactory
to this decoder.- Specified by:
getOutputStreamFactory
in interfaceILcdOutputStreamFactoryCapable
- Returns:
- the used
ILcdOutputStreamfactory
- See Also:
-
setOutputStreamFactory
Sets aILcdOutputFactory
to this encoder. A default implementation is set.- Specified by:
setOutputStreamFactory
in interfaceILcdOutputStreamFactoryCapable
- Parameters:
aOutputStreamFactory
- theILcdOytputStreamFactory
to use.- See Also:
-
getModelReferenceEncoder
Returns theILcdModelReferenceEncoder
used to save the model reference.- Returns:
- the
ILcdModelReferenceEncoder
used to save the model reference. - See Also:
-
setModelReferenceEncoder
Sets theILcdModelReferenceEncoder
to use to encode the model reference.- Parameters:
aModelReferenceEncoder
- theILcdModelReferenceEncoder
to use to encode the model reference.- See Also:
-
getSVGShapeWriter
Gets theILcdSVGShapeWriter
that is used to write the shapes. If noILcdSVGShapeWriter
is set, the default one will be returned.- Returns:
- the used
ILcdSVGShapeWriter
- See Also:
-
setSVGShapeWriter
Sets aILcdSVGShapeWriter
to this encoder. The defaultILcdSVGShapeWriter
is theTLcdSVGUnStyledShapeWriter
- Parameters:
aShapeWriter
- theILcdShapeWriter
to be used.- See Also:
-
save
Saves theILcdModel
.- Specified by:
save
in interfaceILcdModelEncoder
- Parameters:
aModel
- theILcdModel
to save.- Throws:
IOException
- when an I/O error occurs while saving the model.
-
canExport
Checks if there is at least one shape that can be exported.- Specified by:
canExport
in interfaceILcdModelEncoder
- Parameters:
aModel
- theILcdModel
containing the shapes.aSource
- the destination to export theILcdModel
to.- Returns:
- true if at least one
ILcdShape
of theILcdModel
can be exported. - See Also:
-
setTrueSVG
public void setTrueSVG(boolean aTrueSVG) Sets whether only objects that have an SVG counterpart shall be encoded. Default value is false, which implies that points and arcbands will be encoded.- Parameters:
aTrueSVG
- If true the encoder will not encodeILcd2DEditableArcBand
andILcdPoint
objects. These classes have no counterparts in SVG.
-
isTrueSVG
public boolean isTrueSVG()Returns whether only objects that have an SVG counterpart shall be encoded.- Returns:
- whether only objects that have an SVG counterpart shall be encoded.
-
export
Exports theILcdModel
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:- writing a header
writeHeader(java.io.Writer, com.luciad.model.ILcdModel)
- calling
ILcdSVGShapeWriter.writeElement(java.lang.Object, java.io.Writer)
for every element in the model - writing a footer
writeFooter(java.io.Writer)
.
- Specified by:
export
in interfaceILcdModelEncoder
- Parameters:
aModel
- theILcdModel
to export.aSource
- the destination to export to.- Throws:
IOException
- when an I/O error occurs while exporting the model.- See Also:
- writing a header
-
getRootElement
Returns the name of the root element.- Returns:
- the name of the root element.
- See Also:
-
getDefaultExtension
Returns the default extension for files saved with this encoder.- Returns:
- the default extension for files saved with this encoder.
-
writeHeader
Writes the header of the file. This should open the root element of the section in which all shape elements will be created. This implementation writes an xml version line and opens the root element.- Parameters:
aWriter
- the writer to write to.aModel
- the model that we are writing- Throws:
IOException
- when an I/O error occurred while writing the header.- See Also:
-
setClassTraceOn
public static void setClassTraceOn(boolean aClassTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for all instances of this class. If the argument istrue
then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.- Parameters:
aClassTraceOn
- if true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
-
isClassTraceOn
public static boolean isClassTraceOn()Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Returnstrue
if tracing is enabled for this class.- Returns:
- true if tracing is enabled for this class, false otherwise.
-