@Deprecated public class TLcdMultilevelTiledModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
ILcdModelDecoder
decodes multi-level, non-regularly tiled
models.
The tiles may be of different sizes and may overlap. The number of tiles is
not required to be the same for each level. Each tile is encoded separately
in one file, and the tiles may be of different types.
The model consists of one master file with the extension ".mtm" and several
data files, one for each tile at a level of detail. The master file is a Java
properties file that must contain the following keys.
Each of the keys must be preceded by "TLcdMultilevelTiledModel.
".
General model properties:
noLevels
: The number of levels.
defaultLevel
: The default level to use for
ILcdIntegerIndexedModel
interface methods and for returning the
enumeration of model elements (see ILcdModel.elements()
). If not
specified, the default is the most detailed level.
cumulative
(default=false); Boolean value saying if the model
at a particular level includes the lower-detail levels
(see TLcdMultilevel2DBoundsIndexedModel.isCumulative()
)
directoryPath
: The default path to the tiles.
This value must end with a separator character (forward slash).
If not specified, the default path is the directory of the master file.
ILcdModelDecoder.class (default=none)
: The default tile decoder.
charSet
(optional): The name of the character set to be used
by the tile decoders. It affects only the tile decoders that implement
ILcdCharsetSettable
.
Information related to a particular level:
range.l
: The start of the scale range interval from which
level l should be used. This value should be expressed in the units
of the ILcdModelReference of the ILcdModel.
The levels are expected to be sorted from lowest to highest detail
(= from high to low value of the range coefficient).
See TLcdMultilevel2DBoundsIndexedModel.setRange(double[])
.
The range corresponding to level l is [scale.l .. scale.(l+1)).
If not specified otherwise, range(noLevels+1) is automatically set to 0.
directoryPath.l
: The subdirectory containing tiles for level l.
This value is relative to the defaultDirectoryPath
. It must end
with a file separator character.
noFiles.l
: The number of files (=number of tiles) at level l.
ILcdModelDecoder.class.l
: The default decoder to use for
level l tiles. If not specified, the default ILcdModelDecoder.class
is used.
Information related to a particular tile:
fileName.l.t
: The name of the file corresponding to
tile t from level l.
bounds.x.l.t
: The x-ordinate of the bottom-left point
of tile t from level l.
bounds.y.l.t
: The y-ordinate of the bottom-left point
of tile t from level l.
bounds.width.l.t
: The width of tile t from level l.
bounds.height.l.t
: The height of tile t from level l.
ILcdModelDecoder.class.l.t
: Specific decoder for
tile t from level l. If not specified, the
ILcdModelDecoder.class.l
of this level is used.
Each individual tile is kept in a TLcdSoft2DBoundsIndexedModel
,
that performs lazy loading and soft caching. The final model is a
TLcdMultilevel2DBoundsIndexedModel
.
The decoded model itself is thread-safe for read-only access. However, please
note that decoding of the submodels is delegated to other decoders at
unpredictable moments. To insure thread-safety, both the sub-model
decoders and the decoded sub-models must be thread-safe.
TLcdSoft2DBoundsIndexedModel
,
TLcdMultilevel2DBoundsIndexedModel
Constructor and Description |
---|
TLcdMultilevelTiledModelDecoder()
Deprecated.
|
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.
|
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.
|
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Deprecated.
Sets the factory that will create the input streams from which property
files can be decoded.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public static final String TYPE_NAME
public TLcdMultilevelTiledModelDecoder()
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 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)