Module org.jfree.chart
Package org.jfree.data.flow
Class DefaultFlowDataset<K extends Comparable<K>>
- java.lang.Object
-
- org.jfree.data.general.AbstractDataset
-
- org.jfree.data.flow.DefaultFlowDataset<K>
-
- Type Parameters:
K- the type for the keys used to identify sources and destinations (instances should be immutable,Stringis a good default choice).
- All Implemented Interfaces:
ObjectInputValidation,Serializable,Cloneable,PublicCloneable,FlowDataset<K>,Dataset
public class DefaultFlowDataset<K extends Comparable<K>> extends AbstractDataset implements FlowDataset<K>, PublicCloneable, Serializable
A dataset representing flows between source and destination nodes.- Since:
- 1.5.3
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultFlowDataset()Creates a new dataset that is initially empty.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()Returns a clone of the dataset.booleanequals(Object obj)Tests this dataset for equality with an arbitrary object.Set<FlowKey<K>>getAllFlows()Returns a set of keys for all the flows in the dataset.Set<NodeKey<K>>getAllNodes()Returns the set of keys for all the nodes in the dataset.List<K>getDestinations(int stage)Returns a list of the destination nodes for the specified stage.NumbergetFlow(int stage, K source, K destination)Returns the flow between a source node and a destination node at a specified stage.ObjectgetFlowProperty(FlowKey<K> flowKey, String propertyKey)Returns the value of a property, if specified, for the specified flow.List<FlowKey<K>>getInFlows(NodeKey nodeKey)Returns a list of flow keys for all the flows coming into this node.ObjectgetNodeProperty(NodeKey<K> nodeKey, String propertyKey)Returns the value of a property, if specified, for the specified node.List<FlowKey>getOutFlows(NodeKey nodeKey)Returns a list of flow keys for all the flows going out of this node.List<K>getSources(int stage)Returns a list of the source nodes for the specified stage.intgetStageCount()Returns the number of flow stages.inthashCode()voidsetFlow(int stage, K source, K destination, double flow)Sets the flow between a source node and a destination node at the specified stage.voidsetFlowProperty(FlowKey<K> flowKey, String propertyKey, Object value)Sets a property for the specified flow and notifies registered listeners that the dataset has changed.voidsetNodeProperty(NodeKey<K> nodeKey, String propertyKey, Object value)Sets a property for the specified node and notifies registered listeners that the dataset has changed.-
Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, fireDatasetChanged, getNotify, hasListener, notifyListeners, removeChangeListener, setNotify, validateObject
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jfree.data.general.Dataset
addChangeListener, removeChangeListener
-
-
-
-
Constructor Detail
-
DefaultFlowDataset
public DefaultFlowDataset()
Creates a new dataset that is initially empty.
-
-
Method Detail
-
getSources
public List<K> getSources(int stage)
Returns a list of the source nodes for the specified stage.- Specified by:
getSourcesin interfaceFlowDataset<K extends Comparable<K>>- Parameters:
stage- the stage (0 togetStageCount() - 1).- Returns:
- A list of source nodes (possibly empty but never
null).
-
getDestinations
public List<K> getDestinations(int stage)
Returns a list of the destination nodes for the specified stage.- Specified by:
getDestinationsin interfaceFlowDataset<K extends Comparable<K>>- Parameters:
stage- the stage (0 togetStageCount() - 1).- Returns:
- A list of destination nodes (possibly empty but never
null).
-
getAllNodes
public Set<NodeKey<K>> getAllNodes()
Returns the set of keys for all the nodes in the dataset.- Specified by:
getAllNodesin interfaceFlowDataset<K extends Comparable<K>>- Returns:
- The set of keys for all the nodes in the dataset (possibly empty
but never
null).
-
getNodeProperty
public Object getNodeProperty(NodeKey<K> nodeKey, String propertyKey)
Returns the value of a property, if specified, for the specified node.- Specified by:
getNodePropertyin interfaceFlowDataset<K extends Comparable<K>>- Parameters:
nodeKey- the node key (nullnot permitted).propertyKey- the node key (nullnot permitted).- Returns:
- The property value, or
null.
-
setNodeProperty
public void setNodeProperty(NodeKey<K> nodeKey, String propertyKey, Object value)
Sets a property for the specified node and notifies registered listeners that the dataset has changed.- Parameters:
nodeKey- the node key (nullnot permitted).propertyKey- the property key (nullnot permitted).value- the property value.
-
getFlow
public Number getFlow(int stage, K source, K destination)
Returns the flow between a source node and a destination node at a specified stage. This must be 0 or greater. The dataset can returnnullto represent an unknown value.- Specified by:
getFlowin interfaceFlowDataset<K extends Comparable<K>>- Parameters:
stage- the stage index (0 togetStageCount()- 1).source- the source (nullnot permitted).destination- the destination (nullnot permitted).- Returns:
- The flow (zero or greater, possibly
null).
-
setFlow
public void setFlow(int stage, K source, K destination, double flow)
Sets the flow between a source node and a destination node at the specified stage. A new stage will be added ifstageis equal togetStageCount().- Parameters:
stage- the stage (0 togetStageCount().source- the source (nullnot permitted).destination- the destination (nullnot permitted).flow- the flow (0 or greater).
-
getFlowProperty
public Object getFlowProperty(FlowKey<K> flowKey, String propertyKey)
Returns the value of a property, if specified, for the specified flow.- Specified by:
getFlowPropertyin interfaceFlowDataset<K extends Comparable<K>>- Parameters:
flowKey- flowKey (nullnot permitted).propertyKey- the property key (nullnot permitted).- Returns:
- The property value, or
null.
-
setFlowProperty
public void setFlowProperty(FlowKey<K> flowKey, String propertyKey, Object value)
Sets a property for the specified flow and notifies registered listeners that the dataset has changed.- Parameters:
flowKey- the node key (nullnot permitted).propertyKey- the property key (nullnot permitted).value- the property value.
-
getStageCount
public int getStageCount()
Returns the number of flow stages. A flow dataset always has one or more stages, so this method will return1even for an empty dataset (one with no sources, destinations or flows defined).- Specified by:
getStageCountin interfaceFlowDataset<K extends Comparable<K>>- Returns:
- The number of flow stages.
-
getAllFlows
public Set<FlowKey<K>> getAllFlows()
Returns a set of keys for all the flows in the dataset.- Specified by:
getAllFlowsin interfaceFlowDataset<K extends Comparable<K>>- Returns:
- A set.
-
getInFlows
public List<FlowKey<K>> getInFlows(NodeKey nodeKey)
Returns a list of flow keys for all the flows coming into this node.- Parameters:
nodeKey- the node key (nullnot permitted).- Returns:
- A list of flow keys (possibly empty but never
null).
-
getOutFlows
public List<FlowKey> getOutFlows(NodeKey nodeKey)
Returns a list of flow keys for all the flows going out of this node.- Parameters:
nodeKey- the node key (nullnot permitted).- Returns:
- A list of flow keys (possibly empty but never
null).
-
clone
public Object clone() throws CloneNotSupportedException
Returns a clone of the dataset.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classAbstractDataset- Returns:
- A clone of the dataset.
- Throws:
CloneNotSupportedException- if there is a problem with cloning.
-
equals
public boolean equals(Object obj)
Tests this dataset for equality with an arbitrary object. This method will returntrueif the object implements theFlowDatasetand defines the exact same set of nodes and flows as this dataset.
-
-