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)
ILcdPointILcdArcBand
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if there is at least one shape that can be exported.booleanChecks on the destination and then checks if shapes can be exported.voidExports theILcdModelto the destination file and saves the model reference.protected StringReturns the default extension for files saved with this encoder.Gets the display name of this encoder.Returns theILcdModelReferenceEncoderused to save the model reference.Get the usedILcdOutputStreamfactoryto this decoder.protected StringReturns the name of the root element.Gets theILcdSVGShapeWriterthat is used to write the shapes.static booleanDeprecated.This method has been deprecated.booleanReturns whether only objects that have an SVG counterpart shall be encoded.voidSaves theILcdModel.static voidsetClassTraceOn(boolean aClassTraceOn) Deprecated.This method has been deprecated.voidsetModelReferenceEncoder(ILcdModelReferenceEncoder aModelReferenceEncoder) Sets theILcdModelReferenceEncoderto use to encode the model reference.voidsetOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory) Sets aILcdOutputFactoryto this encoder.voidsetSVGShapeWriter(ILcdSVGShapeWriter aShapeWriter) Sets aILcdSVGShapeWriterto this encoder.voidsetTrueSVG(boolean aTrueSVG) Sets whether only objects that have an SVG counterpart shall be encoded.protected voidwriteFooter(Writer aWriter) Writes the footer of the file.protected voidwriteHeader(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:
getDisplayNamein interfaceILcdModelEncoder- Returns:
- a
Stringcontaining the display name of the encoder.
-
canSave
Checks on the destination and then checks if shapes can be exported.- Specified by:
canSavein interfaceILcdModelEncoder- Parameters:
aModel- theILcdModelto save.- Returns:
- true if the destination is set and is true.
- See Also:
-
getOutputStreamFactory
Get the usedILcdOutputStreamfactoryto this decoder.- Specified by:
getOutputStreamFactoryin interfaceILcdOutputStreamFactoryCapable- Returns:
- the used
ILcdOutputStreamfactory - See Also:
-
setOutputStreamFactory
Sets aILcdOutputFactoryto this encoder. A default implementation is set.- Specified by:
setOutputStreamFactoryin interfaceILcdOutputStreamFactoryCapable- Parameters:
aOutputStreamFactory- theILcdOytputStreamFactoryto use.- See Also:
-
getModelReferenceEncoder
Returns theILcdModelReferenceEncoderused to save the model reference.- Returns:
- the
ILcdModelReferenceEncoderused to save the model reference. - See Also:
-
setModelReferenceEncoder
Sets theILcdModelReferenceEncoderto use to encode the model reference.- Parameters:
aModelReferenceEncoder- theILcdModelReferenceEncoderto use to encode the model reference.- See Also:
-
getSVGShapeWriter
Gets theILcdSVGShapeWriterthat is used to write the shapes. If noILcdSVGShapeWriteris set, the default one will be returned.- Returns:
- the used
ILcdSVGShapeWriter - See Also:
-
setSVGShapeWriter
Sets aILcdSVGShapeWriterto this encoder. The defaultILcdSVGShapeWriteris theTLcdSVGUnStyledShapeWriter- Parameters:
aShapeWriter- theILcdShapeWriterto be used.- See Also:
-
save
Saves theILcdModel.- Specified by:
savein interfaceILcdModelEncoder- Parameters:
aModel- theILcdModelto 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:
canExportin interfaceILcdModelEncoder- Parameters:
aModel- theILcdModelcontaining the shapes.aSource- the destination to export theILcdModelto.- Returns:
- true if at least one
ILcdShapeof theILcdModelcan 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 encodeILcd2DEditableArcBandandILcdPointobjects. 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 theILcdModelto 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:
exportin interfaceILcdModelEncoder- Parameters:
aModel- theILcdModelto 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 istruethen 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.Returnstrueif tracing is enabled for this class.- Returns:
- true if tracing is enabled for this class, false otherwise.
-