public abstract class IlvMapDataSource extends Object implements IlvPersistentObject
IlvMapDataSource
wraps the map rendering process code into
a single class. The data source produces an IlvMapLayer
usable
with IlvMapLayerTree
. This class is the base class for all
data sources. Specialized data sources are available for all JViews Maps
cartographic formats as well as for terrain analysis and measuring tools. A
data source uses an IlvMapReusableFeatureIterator
to produce
map features and can therefore be restarted. A typical data source is:
IlvManager manager = ...; IlvMapDataSource reader = new IlvShapeDataSource(shapeFileName, true); reader.setManager(manager); reader.start();
Modifier and Type | Field and Description |
---|---|
protected IlvFeatureRenderer |
renderer
The renderer used to produce
IlvGraphics . |
protected boolean |
usingGeodeticComputation
This flag indicates if this data source should use geodetic computation,
that is, data line wrapping.
|
Constructor and Description |
---|
IlvMapDataSource()
Constructs an empty data source.
|
IlvMapDataSource(IlvInputStream stream)
Reads an
IlvMapDataSource from an
IlvInputStream . |
Modifier and Type | Method and Description |
---|---|
void |
addDataSourceListener(DataSourceListener listener)
Adds a data source listener.
|
protected void |
callListeners(DataSourceEvent event)
Calls the listener registered for this data source.
|
protected IlvMapLayer |
createInsertionLayer()
Creates the insertion layer.
|
IlvGraphicLayerDataSource[] |
getBackupDataSources()
Returns the backup data sources that are used if the original data
source is absent, or if use of a backup data source is forced.
|
IlvCoordinateSystem |
getCoordinateSystem()
Retrieves the coordinate system of this data source.
|
String |
getDescription()
Returns a description of the data source.
|
abstract IlvMapReusableFeatureIterator |
getFeatureIterator()
Retrieves the feature iterator used by this data source.
|
IlvFeatureRenderer |
getFeatureRenderer()
Retrieves the renderer used by this data source to render the
IlvGraphic . |
IlvMapLayer |
getInsertionLayer()
Retrieves the insertion layer.
|
IlvManager |
getManager()
Retrieves the manager attached to this data source.
|
protected IlvMapLayer |
getMapLayer(IlvMapFeature feature)
Returns the
mapLayer containing the specified
IlvMapFeature . |
String |
getName()
Retrieves the name of this data source.
|
IlvMapDataSourceNode |
getNode()
Retrieves the
TreeNode for which this data source is the
user object. |
String[] |
getValidExtentions()
Retrieves the valid file name extensions of the files that this data source
can read.
|
boolean |
hasInsertionLayer()
Returns
true , if the IlvMapLayer insertion
layer and the associated IlvManagerLayer have been created. |
void |
initBackupDataSource()
Creates and initializes the internal backup data source that is used when
the original source data is not available.
|
protected void |
initInsertionLayer(IlvMapLayer layer)
Initializes the insertion
IlvMapLayer of this data source
and inserts a new IlvManagerLayer in the specified
IlvMapLayer . |
boolean |
isAttachingAttributes()
Indicates if the data source is attaching attributes.
|
boolean |
isGrapherMode()
Returns
true if the objects are created in grapher mode. |
boolean |
isSaveBackupDataSources()
Returns whether backup data sources (if any) should be saved along with the
map.
|
protected boolean |
isSourceDataAvailable()
Checks whether the source data this
IlvMapDataSource is
based on is available (file, database connection, url...). |
protected boolean |
isUsingBackupDataSource()
Indicates whether this data source is using backup data, meaning
the original data is not available, or that this use is being forced
by a
setForceUsingBackupDataSource(boolean) call. |
boolean |
isUsingGeodeticComputation()
Returns the
usingGeodeticComputation . |
void |
mapIntersects(Rectangle2D region,
IlvMapApplyObject applyObject)
Applies a function to all map features of the data source that intersect
the specified rectangle.
|
void |
removeDataSourceListener(DataSourceListener listener)
Removes a data source listener.
|
void |
reset()
Resets the data source and prepares it for reloading.
|
void |
setAttachingAttributes(boolean attach)
Indicates to the data source if it should attach attributes to the
IlvGraphic produced. |
void |
setCoordinateSystem(IlvCoordinateSystem cs)
Sets the coordinate system of this data source.
|
void |
setDescription(String descr)
Sets the description of the data source.
|
void |
setFeatureRenderer(IlvFeatureRenderer rdr)
Sets the
IlvFeatureRenderer used by the data source. |
void |
setForceUsingBackupDataSource(boolean forceBackupUse)
Indicates if this
IlvMapDataSource object should enforce
being based on the the data embedded in the map. |
void |
setGrapherMode(boolean value)
Sets the grapher mode value.
|
void |
setInsertionLayer(IlvMapLayer layer)
Sets the layer that the
IlvGraphic is to be inserted into. |
void |
setManager(IlvManager m)
Sets the manager of this data source.
|
void |
setName(String n)
Sets the name of this data source.
|
void |
setSaveBackupDataSources(boolean saveBackupDataSources)
Sets whether backup data sources (if any) should be saved along with the
map.
|
void |
setValidExtentions(String[] extentions)
Sets the valid file name extentions of the files that this data source can
read.
|
void |
start()
Starts this data source and initiates the rendering process.
|
String |
toString()
Returns the name of the data source.
|
void |
write(IlvOutputStream stream)
Writes an
IlvMapDataSource to an
IlvOutputStream . |
protected IlvFeatureRenderer renderer
IlvGraphics
.protected boolean usingGeodeticComputation
public IlvMapDataSource()
public IlvMapDataSource(IlvInputStream stream) throws IlvReadFileException
IlvMapDataSource
from an
IlvInputStream
.stream
- The stream to read from.IlvReadFileException
public void write(IlvOutputStream stream) throws IOException
IlvMapDataSource
to an
IlvOutputStream
.write
in interface IlvPersistentObject
stream
- The stream to write to.IOException
public void reset()
protected boolean isSourceDataAvailable()
IlvMapDataSource
is
based on is available (file, database connection, url...). A
.ivl,
JViews Maps file keeps references to the original
sources the map was built from. It can happen that these sources are not available when
opening the map, for example, when the map is transferred to another machine. This method
checks that availability. In the case where these sources are not available, all operations
that need them are performed from the data embedded in the map, but there is a risk of loosing
information (when reprojecting for example).
This method should be overridden by subclasses.true
, if the original source data is available.public void setForceUsingBackupDataSource(boolean forceBackupUse)
IlvMapDataSource
object should enforce
being based on the the data embedded in the map.
This will prevent reloading the original data source (file, database,
or .ivl).
Note: there is a risk of loosing information. For example, when reprojecting.
forceBackupUse
- Indicates whether the embedded data should be
used even if the original data source is available.Note: If the map data is saved "theme only", backup data source information is obviously lost.
public IlvGraphicLayerDataSource[] getBackupDataSources()
protected boolean isUsingBackupDataSource()
setForceUsingBackupDataSource(boolean)
call.true
, a backup data source is being used.public void initBackupDataSource()
IlvMapDataSource
present in the .ivl
map when
it is opened.public abstract IlvMapReusableFeatureIterator getFeatureIterator()
protected IlvMapLayer getMapLayer(IlvMapFeature feature)
mapLayer
containing the specified
IlvMapFeature
. Note: The feature passed is ignored in the
default implementation, but may be used in subclasses.feature
- The specified IlvMapFeature
.public void mapIntersects(Rectangle2D region, IlvMapApplyObject applyObject)
region
- The specified region.applyObject
- The IlvMapApplyObject
function to apply to the map
features.public IlvFeatureRenderer getFeatureRenderer() throws Exception
IlvGraphic
.IlvFeatureRenderer
.Exception
public void setFeatureRenderer(IlvFeatureRenderer rdr)
IlvFeatureRenderer
used by the data source.rdr
- The IlvFeatureRenderer
used by the data source.public void setAttachingAttributes(boolean attach)
IlvGraphic
produced.attach
- Set to true
, if the data source should attach
attributes, otherwise false
.public boolean isAttachingAttributes()
true
, if the data source is attaching
attributes, otherwise false
.public void setInsertionLayer(IlvMapLayer layer)
IlvGraphic
is to be inserted into.
The old insertion layer, if any, is disposed of.layer
- The insertion layer.public boolean hasInsertionLayer()
true
, if the IlvMapLayer
insertion
layer and the associated IlvManagerLayer
have been created.true
, if the IlvMapLayer
insertion layer and the IlvManagerLayer
have been
created.public IlvMapLayer getInsertionLayer()
protected IlvMapLayer createInsertionLayer()
protected void initInsertionLayer(IlvMapLayer layer)
IlvMapLayer
of this data source
and inserts a new IlvManagerLayer
in the specified
IlvMapLayer
.layer
- The IlvMapLayer
to initialize.public void setCoordinateSystem(IlvCoordinateSystem cs)
cs
- The coordinate system of this data source.public IlvCoordinateSystem getCoordinateSystem()
public void setName(String n)
n
- The name of this data source.public String getName()
public String toString()
public String getDescription()
public void setDescription(String descr)
descr
- The description of the data source.public void start() throws Exception
Exception
public boolean isGrapherMode()
true
if the objects are created in grapher mode.true
if the interactors are in grapher mode.
The default is false
.setGrapherMode(boolean)
public void setGrapherMode(boolean value)
true
, created objects will be added
to the grapher of the attached view with the IlvGrapher.addNode(IlvGraphic, boolean)
method.
If false
, they will be added with the IlvManager.addObject(IlvGraphic, boolean)
.value
- The value to be set.isGrapherMode()
public IlvManager getManager()
public void setManager(IlvManager m)
m
- The manager.public IlvMapDataSourceNode getNode()
TreeNode
for which this data source is the
user object.IlvMapDataSourceNode
.public String[] getValidExtentions()
public void setValidExtentions(String[] extentions)
extentions
- The valid file name extentions.public boolean isUsingGeodeticComputation()
usingGeodeticComputation
.usingGeodeticComputation
.public void addDataSourceListener(DataSourceListener listener)
listener
- The listener to add.public void removeDataSourceListener(DataSourceListener listener)
listener
- The listener to remove.protected final void callListeners(DataSourceEvent event)
event
- The event passed to the called listeners.public boolean isSaveBackupDataSources()
true
, if the backup data sources are to be
saved.public void setSaveBackupDataSources(boolean saveBackupDataSources)
saveBackupDataSources
- Set to true
, if the backup data sources are to be
saved.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.