de.cau.cs.kieler.kvid.datadistributor
Class DataDistributor

java.lang.Object
  extended by de.cau.cs.kieler.kvid.datadistributor.DataDistributor
All Implemented Interfaces:
IProviderListener, EventListener, ResourceSetListener

public final class DataDistributor
extends Object
implements IProviderListener, ResourceSetListener

This class organizes the distribution of the collected data to the objects that visualize it. This is the core class of the KViD Plugin. It collects the data provided by a data source and distributes it to all registered classes that might visualize it. This class is implemented as a singleton.

Rating red

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.emf.transaction.ResourceSetListener
ResourceSetListener.Internal
 
Method Summary
 HashMap<KvidUri,DataObject> getData()
          Getter for the data table.
 DataObject getDataObjectByURI(KvidUri uri)
          Getter for a DataObject by it's model element's URI.
 NotificationFilter getFilter()
          
static DataDistributor getInstance()
          Gives the single instance of the DataDistributor.
 List<List<Point>> getPathsByNode(KvidUri uri)
          Deprecated. Use KvidUtil#getPathsByElement(KvidUri, DiagramEditor, KNode) instead
 void initialize()
          Method which prepares a new visualization.
 boolean isAggregatePrecommitListener()
          
 boolean isPostcommitOnly()
          
 boolean isPrecommitOnly()
          
 void registerDataListener(IDataListener thelistener)
          Registers a new listener which will be notified when the data changes.
 void removeDataListener(IDataListener thelistener)
          Removes a listener from the listeners list.
 void resourceSetChanged(ResourceSetChangeEvent event)
          
 Command transactionAboutToCommit(ResourceSetChangeEvent event)
          
 void triggerInitialization()
          Will be triggered when the current IDataProvider starts giving data.
 void triggerWrapup()
          Will be triggered when the current IDataProvider stops giving data.
 void update(JSONObject data, boolean isHistoryStep)
          Call this every time the data to visualize has changed to trigger the visualization of the new data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DataDistributor getInstance()
Gives the single instance of the DataDistributor.

Returns:
The single instance of the DataDistributor

initialize

public void initialize()
Method which prepares a new visualization. Make sure this is called before any data is provided.


update

public void update(JSONObject data,
                   boolean isHistoryStep)
Call this every time the data to visualize has changed to trigger the visualization of the new data.

Specified by:
update in interface IProviderListener
Parameters:
data - The new data for the next visualization step in JSON
isHistoryStep - Does the data need special handling because it is history data?

getPathsByNode

public List<List<Point>> getPathsByNode(KvidUri uri)
Deprecated. Use KvidUtil#getPathsByElement(KvidUri, DiagramEditor, KNode) instead

Compute animation paths and location for a given model element (referred by URI).

Parameters:
uri - Referring URI, either in Ptolemy Notation or a Fragment URI
Returns:
A list of paths, represented by a list of Points

getDataObjectByURI

public DataObject getDataObjectByURI(KvidUri uri)
Getter for a DataObject by it's model element's URI.

Parameters:
uri - The URI of the model element
Returns:
The DataObject associated with the model element. Might be null if URI has no DataObject

getData

public HashMap<KvidUri,DataObject> getData()
Getter for the data table.

Returns:
The data table, holding the data referred by the model element's URI

triggerInitialization

public void triggerInitialization()
Will be triggered when the current IDataProvider starts giving data.

Specified by:
triggerInitialization in interface IProviderListener

triggerWrapup

public void triggerWrapup()
Will be triggered when the current IDataProvider stops giving data.

Specified by:
triggerWrapup in interface IProviderListener

registerDataListener

public void registerDataListener(IDataListener thelistener)
Registers a new listener which will be notified when the data changes.

Parameters:
thelistener - The IDataListener to add

removeDataListener

public void removeDataListener(IDataListener thelistener)
Removes a listener from the listeners list.

Parameters:
thelistener - The IDataListener to remove

getFilter

public NotificationFilter getFilter()

Specified by:
getFilter in interface ResourceSetListener

transactionAboutToCommit

public Command transactionAboutToCommit(ResourceSetChangeEvent event)
                                 throws RollbackException

Specified by:
transactionAboutToCommit in interface ResourceSetListener
Throws:
RollbackException

resourceSetChanged

public void resourceSetChanged(ResourceSetChangeEvent event)

Specified by:
resourceSetChanged in interface ResourceSetListener

isAggregatePrecommitListener

public boolean isAggregatePrecommitListener()

Specified by:
isAggregatePrecommitListener in interface ResourceSetListener

isPrecommitOnly

public boolean isPrecommitOnly()

Specified by:
isPrecommitOnly in interface ResourceSetListener

isPostcommitOnly

public boolean isPostcommitOnly()

Specified by:
isPostcommitOnly in interface ResourceSetListener