public class TLcdEarthTerrainRepositoryModelDecoder extends Object implements ILcdModelDecoder
TLcdEarthRepositoryModelDecoder
should be preferred over this model decoder. The difference is that the terrain repository model
decoder adds some painter specific tile set wrappers. These tile set wrappers are not necessary
in the model any more because the painters will also create these if necessary.
File | Required | Entry point | Description |
---|---|---|---|
tilerepository.cfg | x |
x | The root file of an Earth tile repository. |
tilerepository.ref | x |
The model reference of an Earth tile repository. | |
tilerepository_metadata.xml | The asset model of an Earth tile repository that describes its contents. |
java.io.File
.ILcd2DBoundsIndexedModel
.ILcdEarthAssetBasedModelDescriptor
.ILcdGridReference
or an
ILcdGeodeticReference
.TLcdModelReferenceDecoder
by default).ILcdEarthTileSet
.TLcdEarthAsynchronousTileSet
.
ILcdModelDecoder decoder = new TLcdEarthTerrainRepositoryModelDecoder();
ILcdModel model = decoder.decode("mydirectory/tilerepository.cfg");
Constructor and Description |
---|
TLcdEarthTerrainRepositoryModelDecoder()
Constructs a new
TLcdEarthTerrainRepositoryModelDecoder that uses the default
model reference decoder and tile data codecs and does not allow fallback to default geometry
or textures. |
Modifier and Type | Method and Description |
---|---|
void |
addAssetCodec(ILcdEarthAssetCodec aCodec)
Adds the specified asset codec.
|
void |
addTileDataCodec(ILcdEarthTileDataCodec aCodec)
Adds the specified tile data codec for its encoded format.
|
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
Collection<ILcdEarthAssetCodec> |
getAssetCodecs()
Returns the current collection of asset codecs.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
TLcdModelReferenceDecoder |
getModelReferenceDecoder()
Returns the model reference decoder used.
|
Collection<ILcdEarthTileDataCodec> |
getTileDataCodecs()
Returns the current collection of tile data codecs.
|
boolean |
isAllowFallbackToDefaultGeometry()
Returns whether a terrain may be created with default geometry if it cannot be derived
from data in the repository.
|
boolean |
isAllowFallbackToDefaultTexture()
Returns whether a terrain may be created with default textures if it cannot be derived from
data in the repository.
|
boolean |
removeAssetCodec(ILcdEarthAssetCodec aCodec)
Removes the specified asset codec.
|
boolean |
removeTileDataCodec(ILcdEarthTileDataCodec aCodec)
Removes the specified tile data codec for its encoded format.
|
void |
setAllowFallbackToDefaultGeometry(boolean aAllowFallbackToDefaultGeometry)
Sets whether a terrain may be created with default geometry.
|
void |
setAllowFallbackToDefaultTexture(boolean aAllowFallbackToDefaultTexture)
Sets whether a terrain may be created with default textures.
|
void |
setModelReferenceDecoder(TLcdModelReferenceDecoder aModelReferenceDecoder)
Sets the model reference decoder used.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public TLcdEarthTerrainRepositoryModelDecoder()
TLcdEarthTerrainRepositoryModelDecoder
that uses the default
model reference decoder and tile data codecs and does not allow fallback to default geometry
or textures.public void addTileDataCodec(ILcdEarthTileDataCodec aCodec)
aCodec
- the tile data codec that should be addedpublic boolean removeTileDataCodec(ILcdEarthTileDataCodec aCodec)
aCodec
- the tile data codec that should be removedpublic Collection<ILcdEarthTileDataCodec> getTileDataCodecs()
public void addAssetCodec(ILcdEarthAssetCodec aCodec)
aCodec
- the asset codec that should be addedpublic boolean removeAssetCodec(ILcdEarthAssetCodec aCodec)
aCodec
- the asset codec that should be removedpublic Collection<ILcdEarthAssetCodec> getAssetCodecs()
public TLcdModelReferenceDecoder getModelReferenceDecoder()
public void setModelReferenceDecoder(TLcdModelReferenceDecoder aModelReferenceDecoder)
aModelReferenceDecoder
- the new model reference decoder that should be used.public boolean isAllowFallbackToDefaultGeometry()
public void setAllowFallbackToDefaultGeometry(boolean aAllowFallbackToDefaultGeometry)
aAllowFallbackToDefaultGeometry
- true if fallback to default geometry is allowed, false otherwise.isAllowFallbackToDefaultGeometry()
public boolean isAllowFallbackToDefaultTexture()
public void setAllowFallbackToDefaultTexture(boolean aAllowFallbackToDefaultTexture)
aAllowFallbackToDefaultTexture
- true if fallback to default textures is allowed, false otherwise.isAllowFallbackToDefaultTexture()
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)