@Deprecated @LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdCGMModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
ILcdModelDecoder
decodes data in CGM format (Computer
Graphics Metafile), as defined by MIL-STD-2301
.
Typically CGM documents are not directly decoded as models but rather used as styled icons to decorate existing models.
For that use case, consider using TLcdCGMIcon
instead.
The following CGM elements are currently supported:
CGM element name | Decoded object |
---|---|
POLYLINE |
|
TEXT |
|
POLYGON |
|
RECTANGLE |
|
CIRCLE |
|
CIRCULAR ARC |
|
CIRCULAR ARC, CLOSED |
|
ELLIPSE |
|
ELLIPTICAL ARC |
|
ELLIPTICAL ARC, CLOSED |
|
ILcdModelReferenceDecoder
. The default reference decoder set on this
model decoder is based on all model reference decoders annotated with the LcdService
annotation, and can handle
<filename>.epsg
): see TLcdEPSGModelReferenceDecoder
for more info.<filename>.prj
): see TLcdWKTModelReferenceDecoder
for more info.<filename>.ref
): see TLcdModelReferenceDecoder
for more info.ILcdDataObject
. Their data types
can be found in TLcdCGMDataTypes
.
The decode method of this model decoder will make sure that the model descriptor of
the decoded model will have all the data types of elements of the model. This
can be queried at runtime using the TLcdCGMModelDescriptor.getModelElementTypes()
method.
If the model is updated after decoding to feature more model element data types, a new model
descriptor will have to be added with an updated list of model element data types.
Constructor and Description |
---|
TLcdCGMModelDecoder()
Deprecated.
Creates a new
TLcdCGMModelDecoder . |
TLcdCGMModelDecoder(ILcdModelReference aDefaultModelReference)
Deprecated.
Creates a new
TLcdCGMModelDecoder . |
TLcdCGMModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Deprecated.
Creates a new
TLcdCGMModelDecoder . |
TLcdCGMModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder,
ILcdModelReference aDefaultModelReference)
Deprecated.
Creates a new
TLcdCGMModelDecoder . |
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aSourceName)
Deprecated.
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(String aSourceName)
Deprecated.
Creates a new model from the given data source.
|
void |
decodeElements(DataInputStream aStream,
ILcdModel aModelSFCT)
Deprecated.
Decodes the CGM elements from the given stream and adds them to the
given model.
|
void |
decodeElements(String aSourceName,
int aOffset,
ILcdModel aModelSFCT)
Deprecated.
Decodes the CGM elements from the given source and adds them to the
given model.
|
String |
getDefaultExtension()
Deprecated.
|
ILcdModelReference |
getDefaultModelReference()
Deprecated.
|
String |
getDisplayName()
Deprecated.
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ILcdInputStreamFactory |
getInputStreamFactory()
Deprecated.
Returns the input stream factory that is used.
|
ILcdModelReferenceDecoder |
getModelReferenceDecoder()
Deprecated.
Returns the model reference decoder that is used for creating model
references for decoded models.
|
double |
getScaleX()
Deprecated.
|
double |
getScaleY()
Deprecated.
|
double |
getShiftX()
Deprecated.
|
double |
getShiftY()
Deprecated.
|
void |
setDefaultModelReference(ILcdModelReference aDefaultModelReference)
Deprecated.
Sets the default model reference for decoded models, in case the model
reference decoder doesn't provide one.
|
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Deprecated.
Sets the input stream factory that will be used for creating input streams
given source names.
|
void |
setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Deprecated.
Sets the model reference decoder that will be used for creating model
references for decoded models.
|
void |
setScaleX(double aScaleX)
Deprecated.
Sets the factor by which x ordinates are scaled.
|
void |
setScaleY(double aScaleY)
Deprecated.
Sets the factor by which y ordinates are scaled.
|
void |
setShiftX(double aShiftX)
Deprecated.
Sets the distance by which x ordinates are shifted, after having
been scaled.
|
void |
setShiftY(double aShiftY)
Deprecated.
Sets the distance by which y ordinates are shifted, after having
been scaled.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public TLcdCGMModelDecoder()
TLcdCGMModelDecoder
.public TLcdCGMModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
TLcdCGMModelDecoder
.aModelReferenceDecoder
- the model reference decoder that can assign
references to decoded models.public TLcdCGMModelDecoder(ILcdModelReference aDefaultModelReference)
TLcdCGMModelDecoder
.aDefaultModelReference
- the model reference that decoded models will
get if the model reference decoder can't
decode one.public TLcdCGMModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder, ILcdModelReference aDefaultModelReference)
TLcdCGMModelDecoder
.aModelReferenceDecoder
- the model reference decoder that can assign
references to decoded models.aDefaultModelReference
- the model reference that decoded models will
get if the model reference decoder can't
decode one.public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactoryCapable
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
public ILcdModelReferenceDecoder getModelReferenceDecoder()
setModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
public void setDefaultModelReference(ILcdModelReference aDefaultModelReference)
public ILcdModelReference getDefaultModelReference()
public void setShiftX(double aShiftX)
public double getShiftX()
public void setShiftY(double aShiftY)
public double getShiftY()
public void setScaleX(double aScaleX)
public double getScaleX()
public void setScaleY(double aScaleY)
public double getScaleY()
public String getDefaultExtension()
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String aSourceName)
ILcdModelDecoder
true
for a source name while decode
throws an exception for that same source name.
For performance reasons, we strongly recommend that this will only be a simple test. For example: check the file extension of a file, but not that the file exists or contains expected content.
canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the data source to be verified; typically a file name or a URL.true
if this decoder can likely decode the data specified by the source name, false
otherwise.ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public ILcdModel decode(String aSourceName) throws IOException
ILcdModelDecoder
decode
in interface ILcdModelDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.null
is allowed, implementors are advised to throw an error instead.IOException
- for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost
always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException,
IllegalArgumentException, ...) on unexpected places, implementations are advised to catch
RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated
in the code snippet below.
public ILcdModel decode( String aSourceName ) throws IOException {
try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) {
// Perform decoding ...
} catch (RuntimeException e) {
throw new IOException(e);
}
}
InterruptedIOException
- When the thread on which this method is called is interrupted: it is recommended to stop the decoding
and throw an InterruptedIOException
.
This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding
through the UI.ILcdModelDecoder.canDecodeSource(String)
public void decodeElements(String aSourceName, int aOffset, ILcdModel aModelSFCT) throws IOException
aSourceName
- the name of the source containing CGM data.aOffset
- the offset indicating the start of the CGM dataaModelSFCT
- the model to which the decoded elements are added.IOException
public void decodeElements(DataInputStream aStream, ILcdModel aModelSFCT) throws IOException
aStream
- the stream containing CGM data.aModelSFCT
- the model to which the decoded elements are added.IOException