ilog.views.maps.datasource
Class IlvHierarchicalDataSource

java.lang.Object
  extended by ilog.views.maps.datasource.IlvMapDataSource
      extended by ilog.views.maps.datasource.IlvHierarchicalDataSource
All Implemented Interfaces:
IlvPersistentObject
Direct Known Subclasses:
IlvDefaultTilableDataSource, IlvMIDMIFDataSource, IlvSplitDataSource, IlvTilableDataSource

public class IlvHierarchicalDataSource
extends IlvMapDataSource

A data source that sorts graphic objects into layers according to their attributes. It relies on the underlying feature iterator to get a list of objects, and then applies a list a filters on each object to determine what layer it should be added to. This way, objects added via this data source can be grouped in hierarchical fashion. For instance a road object will be added in the road layer within the transportation layer.

Since:
JViews 7.5

Nested Class Summary
static class IlvHierarchicalDataSource.CriterionFilter
          A value extractor for map features.
static class IlvHierarchicalDataSource.SingleAttributeFilter
          A specialized criterion filter that returns the value of an attribute of a map feature.
 
Field Summary
protected  IlvMapReusableFeatureIterator featureIterator
          The IlvMapReusableFeatureIterator of this data source
protected  String filename
          the file this data source is based upon
protected  HashMap nameMap
          Hashmap containing explicit names for attributes values (usually codes).
protected  HashMap styleMap
          The (internal) table used to map a feature kep to a style.
 
Fields inherited from class ilog.views.maps.datasource.IlvMapDataSource
renderer, usingGeodeticComputation
 
Constructor Summary
IlvHierarchicalDataSource(IlvInputStream stream)
          Constructs a IlvHierarchicalDataSource from the specified input stream.
IlvHierarchicalDataSource(String filename)
          Constructs a IlvHierarchicalDataSource from a specified file.
 
Method Summary
 void addCriterionFilter(IlvHierarchicalDataSource.CriterionFilter filter)
          Adds a criterion filter at the end of the list of filters.
protected  void addLayer(IlvMapLayer parent, IlvMapLayer layer)
          Adds a specified IlvMapLayer in the specified parent layer.
protected  IlvFeatureRenderer createFeatureRenderer()
          Returns a renderer created for this datasource.
protected  IlvMapLayer createInsertionLayer()
          Creates the insertion layer.
 Iterator getCriterionFilters()
          Returns an iterator over the list of CriterionFilter of this data source
 IlvMapReusableFeatureIterator getFeatureIterator()
          Retrieves the feature iterator used by this data source.
 IlvFeatureRenderer getFeatureRenderer()
          Overrides the parent method to always create a renderer that creates IlvMapGraphic objects.
 IlvFeatureRenderer getFeatureRenderer(IlvMapFeature feature)
          Gets the appropriate feature renderer for the specified IlvMapFeature.
protected  Object getKey(IlvMapFeature feature)
          Associates a key to a map feature.
protected  IlvMapLayer getMapLayer(IlvMapFeature feature)
          Return the mapLayer containing the specified IlvMapFeature
protected  IlvMapStyle getStyle(IlvMapFeature feature)
          Returns a map style for the specified feature.
 boolean isAcceptNullValues()
          Returns whether this data source should discard map features which does not have a value for specified criteria (in the filter list).
 void readInfo(String info)
          Creates the table of attributes values from a text file description.
 void removeAllCriterionFilters()
          Removes all the filters from this IlvHierarchicalDataSource
 void removeCriterionFilter(IlvHierarchicalDataSource.CriterionFilter filter)
          Removes a criterion filter from the list of filters.
 void reset()
          Resets the data source and prepares it for reloading.
 void setAcceptNullValues(boolean acceptNullValues)
          Sets whether this data source should discard map features which does not have a value for specified criteria (in the filter list).
protected  void setupLayer(IlvMapLayer layer, IlvMapFeature feature)
          Sets up the layer to receive features.
 void start()
          Starts this data source.
 void write(IlvOutputStream stream)
          Writes this IlvHierarchicalDataSource to an IlvOutputStream.
 
Methods inherited from class ilog.views.maps.datasource.IlvMapDataSource
addDataSourceListener, callListeners, getBackupDataSources, getCoordinateSystem, getDescription, getInsertionLayer, getManager, getName, getNode, getValidExtentions, hasInsertionLayer, initBackupDataSource, initInsertionLayer, isAttachingAttributes, isSaveBackupDataSources, isSourceDataAvailable, isUsingGeodeticComputation, mapIntersects, removeDataSourceListener, setAttachingAttributes, setCoordinateSystem, setDescription, setFeatureRenderer, setForceUsingBackupDataSource, setInsertionLayer, setManager, setName, setSaveBackupDataSources, setValidExtentions, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

featureIterator

protected IlvMapReusableFeatureIterator featureIterator
The IlvMapReusableFeatureIterator of this data source


filename

protected String filename
the file this data source is based upon


styleMap

protected HashMap styleMap
The (internal) table used to map a feature kep to a style.

Since:
JViews 8.1
Internal method or field: do not use!

nameMap

protected HashMap nameMap
Hashmap containing explicit names for attributes values (usually codes).

Constructor Detail

IlvHierarchicalDataSource

public IlvHierarchicalDataSource(IlvInputStream stream)
                          throws IlvReadFileException
Constructs a IlvHierarchicalDataSource from the specified input stream.

Parameters:
stream - the IlvInputStream to constructs the data source from.
Throws:
IlvReadFileException - exception thrown if an error was encountered when deserializing this object.

IlvHierarchicalDataSource

public IlvHierarchicalDataSource(String filename)
                          throws MalformedURLException
Constructs a IlvHierarchicalDataSource from a specified file.

Parameters:
filename - the file containing map data.
Throws:
MalformedURLException - If the path cannot be parsed as a URL
Method Detail

getFeatureIterator

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

Specified by:
getFeatureIterator in class IlvMapDataSource
Returns:
null.

write

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

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

addCriterionFilter

public void addCriterionFilter(IlvHierarchicalDataSource.CriterionFilter filter)
Adds a criterion filter at the end of the list of filters. This will add sub layers to the parent layer.

Parameters:
filter - the CriterionFilter to add

getCriterionFilters

public Iterator getCriterionFilters()
Returns an iterator over the list of CriterionFilter of this data source

Returns:
the iterator.

removeCriterionFilter

public void removeCriterionFilter(IlvHierarchicalDataSource.CriterionFilter filter)
Removes a criterion filter from the list of filters.

Parameters:
filter - the CriterionFilter to remove

removeAllCriterionFilters

public void removeAllCriterionFilters()
Removes all the filters from this IlvHierarchicalDataSource


readInfo

public void readInfo(String info)
Creates the table of attributes values from a text file description.

Parameters:
info - the description file.

createFeatureRenderer

protected IlvFeatureRenderer createFeatureRenderer()
                                            throws Exception
Returns a renderer created for this datasource. This renderer is used in the getFeatureRenderer() and getFeatureRenderer(IlvMapFeature) methods calls. The default implementation creates a renderer through IlvDataSourceStylingFactory.createDefaultRenderer(boolean, boolean)

Returns:
Returns a renderer created for this datasource.
Throws:
Exception
Since:
JViews 8.0

getFeatureRenderer

public IlvFeatureRenderer getFeatureRenderer(IlvMapFeature feature)
                                      throws Exception
Gets the appropriate feature renderer for the specified IlvMapFeature.

Parameters:
feature - the feature to render.
Returns:
the IlvFeatureRenderer.
Throws:
Exception - if a feature renderer does not exist for the specified IlvMapFeature.

getFeatureRenderer

public IlvFeatureRenderer getFeatureRenderer()
                                      throws Exception
Overrides the parent method to always create a renderer that creates IlvMapGraphic objects.

Overrides:
getFeatureRenderer in class IlvMapDataSource
Returns:
The IlvFeatureRenderer.
Throws:
Exception
See Also:
IlvMapDataSource.getFeatureRenderer()

getKey

protected final Object getKey(IlvMapFeature feature)
Associates a key to a map feature. Basically a list of the values given by the criterion filters for this map feature

Parameters:
feature - the map feature whose key is needed.
Returns:
a key Object.

getStyle

protected IlvMapStyle getStyle(IlvMapFeature feature)
                        throws Exception
Returns a map style for the specified feature.

Parameters:
feature - the IlvMapFeature.
Returns:
a IlvMapStyle for the feature
Throws:
Exception - if an appropriate style could not be found for the specified feature.

setAcceptNullValues

public void setAcceptNullValues(boolean acceptNullValues)
Sets whether this data source should discard map features which does not have a value for specified criteria (in the filter list).

Parameters:
acceptNullValues - if true, such features will be added to the parent layer. If false, they will not be added to the map.

reset

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

Overrides:
reset in class IlvMapDataSource
See Also:
IlvMapDataSource.reset()

isAcceptNullValues

public boolean isAcceptNullValues()
Returns whether this data source should discard map features which does not have a value for specified criteria (in the filter list).

Returns:
true if such features are added to the parent layer. False if they are added to the map.

getMapLayer

protected IlvMapLayer getMapLayer(IlvMapFeature feature)
Return the mapLayer containing the specified IlvMapFeature

Overrides:
getMapLayer in class IlvMapDataSource
Parameters:
feature - The specified map feature
Returns:
The corresponding map layer.

setupLayer

protected void setupLayer(IlvMapLayer layer,
                          IlvMapFeature feature)
Sets up the layer to receive features. By default, this method sets the layer style to be compatible with the feature.

Parameters:
layer - The layer
feature - The feature for which the layer was created
Since:
JViews 8.1
See Also:
getStyle(IlvMapFeature)

addLayer

protected void addLayer(IlvMapLayer parent,
                        IlvMapLayer layer)
Adds a specified IlvMapLayer in the specified parent layer.

Parameters:
parent - the parent layer.
layer - the IlvMapLayer to add

start

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

Overrides:
start in class IlvMapDataSource
Throws:
Exception

createInsertionLayer

protected IlvMapLayer createInsertionLayer()
Creates the insertion layer.

Overrides:
createInsertionLayer in class IlvMapDataSource
Returns:
The layer that is to become the insertion layer.
See Also:
IlvMapDataSource.createInsertionLayer()


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