ilog.views.maps.datasource
Class IlvMapDataSource

java.lang.Object
  extended by ilog.views.maps.datasource.IlvMapDataSource
All Implemented Interfaces:
IlvPersistentObject
Direct Known Subclasses:
IlvDefaultMapDataSource, IlvGraphicLayerDataSource, IlvHierarchicalDataSource, IlvShapeDataSource, IlvTiledRasterDataSource

public abstract class IlvMapDataSource
extends Object
implements IlvPersistentObject

An 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(); 
 

Since:
JViews 7.5

Field Summary
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 Summary
IlvMapDataSource()
          Constructs an empty data source.
IlvMapDataSource(IlvInputStream stream)
          Reads an IlvMapDataSource from an IlvInputStream.
 
Method Summary
 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 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...).
 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

renderer

protected IlvFeatureRenderer renderer
The renderer used to produce IlvGraphics.


usingGeodeticComputation

protected boolean usingGeodeticComputation
This flag indicates if this data source should use geodetic computation, that is, data line wrapping. This is normally set when starting the data source by looking into the manager preferences.

Since:
JViews 8.1
Constructor Detail

IlvMapDataSource

public IlvMapDataSource()
Constructs an empty data source.


IlvMapDataSource

public IlvMapDataSource(IlvInputStream stream)
                 throws IlvReadFileException
Reads an IlvMapDataSource from an IlvInputStream.

Parameters:
stream - The stream to read from.
Throws:
IlvReadFileException
Method Detail

write

public void write(IlvOutputStream stream)
           throws IOException
Writes an IlvMapDataSource to an IlvOutputStream.

Specified by:
write in interface IlvPersistentObject
Parameters:
stream - The stream to write to.
Throws:
IOException

reset

public void reset()
Resets the data source and prepares it for reloading.


isSourceDataAvailable

protected boolean isSourceDataAvailable()
Checks whether the source data this 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.

Returns:
Returns true, if the original source data is available.
Since:
JViews 8.0

setForceUsingBackupDataSource

public void setForceUsingBackupDataSource(boolean forceBackupUse)
Indicates if this 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.

Parameters:
forceBackupUse - Indicates whether the embedded data should be used even if the original data source is available.
Since:
JViews 8.1
See Also:
Note: If the map data is saved "theme only", backup data source information is obviously lost.

getBackupDataSources

public 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.

Returns:
The array of backup data sources that contains the embedded map data.
Since:
JViews 8.1

initBackupDataSource

public void initBackupDataSource()
Creates and initializes the internal backup data source that is used when the original source data is not available. This method is called on every IlvMapDataSource present in the .ivl map when it is opened.

Since:
JViews 8.0

getFeatureIterator

public abstract IlvMapReusableFeatureIterator getFeatureIterator()
Retrieves the feature iterator used by this data source.

Returns:
The feature iterator.

getMapLayer

protected IlvMapLayer getMapLayer(IlvMapFeature feature)
Returns the mapLayer containing the specified IlvMapFeature. Note: The feature passed is ignored in the default implementation, but may be used in subclasses.

Parameters:
feature - The specified IlvMapFeature.
Returns:
The corresponding map layer.

mapIntersects

public void mapIntersects(Rectangle2D region,
                          IlvMapApplyObject applyObject)
Applies a function to all map features of the data source that intersect the specified rectangle.

Parameters:
region - The specified region.
applyObject - The IlvMapApplyObject function to apply to the map features.

getFeatureRenderer

public IlvFeatureRenderer getFeatureRenderer()
                                      throws Exception
Retrieves the renderer used by this data source to render the IlvGraphic.

Returns:
The IlvFeatureRenderer.
Throws:
Exception

setFeatureRenderer

public void setFeatureRenderer(IlvFeatureRenderer rdr)
Sets the IlvFeatureRenderer used by the data source.

Parameters:
rdr - The IlvFeatureRenderer used by the data source.

setAttachingAttributes

public void setAttachingAttributes(boolean attach)
Indicates to the data source if it should attach attributes to the IlvGraphic produced.

Parameters:
attach - Set to true, if the data source should attach attributes, otherwise false.

isAttachingAttributes

public boolean isAttachingAttributes()
Indicates if the data source is attaching attributes.

Returns:
Returns true, if the data source is attaching attributes, otherwise false.

setInsertionLayer

public void setInsertionLayer(IlvMapLayer layer)
Sets the layer that the IlvGraphic is to be inserted into. The old insertion layer, if any, is disposed of.

Parameters:
layer - The insertion layer.

hasInsertionLayer

public boolean hasInsertionLayer()
Returns true, if the IlvMapLayer insertion layer and the associated IlvManagerLayer have been created.

Returns:
Returns true, if the IlvMapLayer insertion layer and the IlvManagerLayer have been created.

getInsertionLayer

public IlvMapLayer getInsertionLayer()
Retrieves the insertion layer.

Returns:
The insertion layer.

createInsertionLayer

protected IlvMapLayer createInsertionLayer()
Creates the insertion layer.

Returns:
The layer that is to become the insertion layer.

initInsertionLayer

protected void initInsertionLayer(IlvMapLayer layer)
Initializes the insertion IlvMapLayer of this data source and inserts a new IlvManagerLayer in the specified IlvMapLayer.

Parameters:
layer - The IlvMapLayer to initialize.

setCoordinateSystem

public void setCoordinateSystem(IlvCoordinateSystem cs)
Sets the coordinate system of this data source.

Parameters:
cs - The coordinate system of this data source.

getCoordinateSystem

public IlvCoordinateSystem getCoordinateSystem()
Retrieves the coordinate system of this data source.

Returns:
The coordinate system of this data source.

setName

public void setName(String n)
Sets the name of this data source.

Parameters:
n - The name of this data source.

getName

public String getName()
Retrieves the name of this data source.

Returns:
The name of the data source.

toString

public String toString()
Returns the name of the data source.

Overrides:
toString in class Object
Returns:
The name of the data source.

getDescription

public String getDescription()
Returns a description of the data source.

Returns:
The description of the data source.

setDescription

public void setDescription(String descr)
Sets the description of the data source.

Parameters:
descr - The description of the data source.

start

public void start()
           throws Exception
Starts this data source and initiates the rendering process. The map features are read from the reader and the graphic objects are rendered and inserted into the manager.

Throws:
Exception

getManager

public IlvManager getManager()
Retrieves the manager attached to this data source.

Returns:
The manager attached to this data source.

setManager

public void setManager(IlvManager m)
Sets the manager of this data source.

Parameters:
m - The manager.

getNode

public IlvMapDataSourceNode getNode()
Retrieves the TreeNode for which this data source is the user object.

Returns:
The IlvMapDataSourceNode.

getValidExtentions

public String[] getValidExtentions()
Retrieves the valid file name extensions of the files that this data source can read.

Returns:
The valid file name extentions.

setValidExtentions

public void setValidExtentions(String[] extentions)
Sets the valid file name extentions of the files that this data source can read.

Parameters:
extentions - The valid file name extentions.

isUsingGeodeticComputation

public boolean isUsingGeodeticComputation()
Returns the usingGeodeticComputation.

Returns:
Returns the usingGeodeticComputation.

addDataSourceListener

public void addDataSourceListener(DataSourceListener listener)
Adds a data source listener. The listener is called when the data source is fully loaded.

Parameters:
listener - The listener to add.

removeDataSourceListener

public void removeDataSourceListener(DataSourceListener listener)
Removes a data source listener.

Parameters:
listener - The listener to remove.

callListeners

protected final void callListeners(DataSourceEvent event)
Calls the listener registered for this data source.

Parameters:
event - The event passed to the called listeners.

isSaveBackupDataSources

public boolean isSaveBackupDataSources()
Returns whether backup data sources (if any) should be saved along with the map.

Returns:
Returns true, if the backup data sources are to be saved.
Since:
JViews 8.0

setSaveBackupDataSources

public void setSaveBackupDataSources(boolean saveBackupDataSources)
Sets whether backup data sources (if any) should be saved along with the map.

Parameters:
saveBackupDataSources - Set to true, if the backup data sources are to be saved.
Since:
JViews 8.0


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.