gishur.graph.gui
Class FlowAdapter

java.lang.Object
  |
  +--gishur.gui2.SourcePropertyAdapter
        |
        +--gishur.graph.gui.FlowAdapter

public class FlowAdapter
extends SourcePropertyAdapter

An adapter based on SourcePropertyAdapter, that reads a flow datas.

Version:
1.0
Author:
Thomas Wolf

Field Summary
static byte FLOW_VALUE
          Signals, that the flow value should be read.
static byte LOWER_CAPACITY
          Signals, that the lower capacity should be read.
static byte UPPER_CAPACITY
          Signals, that the upper capacity should be read.
 
Constructor Summary
FlowAdapter(java.lang.String propertyname)
          Constructor.
FlowAdapter(java.lang.String propertyname, double shift, double scale)
          Constructs a FlowDataAdapter, which reads the given flow and shifts its values by the given number and then scales this value by the given factor.
 
Method Summary
protected  java.awt.Color convertFlowDataColors(byte i, Flow flow)
          Reads flow-value specified by i from the given flow and returns the - adapted - color value.
protected  int convertFlowDataWidth(byte i, Flow flow)
          Reads flow-value specified by i from the given flow and returns the - adapted - value.
 java.lang.Object getProperty(java.lang.String key, java.lang.Object source, PropertyStatusReader prop)
          Returns a property value with a given key using the source-object (and perhaps the given PropertyStatusReader).
 double scale()
          Returns the scale-factor.
 double shift()
          Returns the shift-parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UPPER_CAPACITY

public static final byte UPPER_CAPACITY
Signals, that the upper capacity should be read.

FLOW_VALUE

public static final byte FLOW_VALUE
Signals, that the flow value should be read.

LOWER_CAPACITY

public static final byte LOWER_CAPACITY
Signals, that the lower capacity should be read.
Constructor Detail

FlowAdapter

public FlowAdapter(java.lang.String propertyname)
Constructor.
Parameters:
propertyname - the name of the connected property at the GraphElement.

FlowAdapter

public FlowAdapter(java.lang.String propertyname,
                   double shift,
                   double scale)
Constructs a FlowDataAdapter, which reads the given flow and shifts its values by the given number and then scales this value by the given factor.
Parameters:
propertyname - the name of the connected property at the GraphElement.
shift - shift parameter
scale - scale factor
Method Detail

shift

public double shift()
Returns the shift-parameter.
Returns:
the shift-parameter.

scale

public double scale()
Returns the scale-factor.
Returns:
the scale-factor.

getProperty

public java.lang.Object getProperty(java.lang.String key,
                                    java.lang.Object source,
                                    PropertyStatusReader prop)
Returns a property value with a given key using the source-object (and perhaps the given PropertyStatusReader).
Overrides:
getProperty in class SourcePropertyAdapter
Parameters:
key - the property name
source - the source object to use
prop - the PropertyStatusReader
Returns:
property value

convertFlowDataWidth

protected int convertFlowDataWidth(byte i,
                                   Flow flow)
Reads flow-value specified by i from the given flow and returns the - adapted - value. Overwrite this method to convert the values otherwise. The default implementation shifts the values and scales them by the parameters specified at the constructor.
Parameters:
i - specifies which value to be read (one of { UPPER_CAPACITY,LOWER_CAPACITY,FLOW_VALUE }
flow - the GraphElement.FlowData-object where to read from.
Returns:
the with according to the flow value. If the appropriate part of th flow edge should be invisible, return -1.

convertFlowDataColors

protected java.awt.Color convertFlowDataColors(byte i,
                                               Flow flow)
Reads flow-value specified by i from the given flow and returns the - adapted - color value. Overwrite this method to convert the values otherwise. The default implementation returns null.
Parameters:
i - specifies which value to be read (one of { UPPER_CAPACITY,LOWER_CAPACITY,FLOW_VALUE }
flow - the GraphElement.FlowData-object where to read from.
Returns:
the color according to the flow value.