org.openflow.gui.drawables
Class Flow

java.lang.Object
  extended by org.pzgui.AbstractDrawable
      extended by org.openflow.gui.drawables.Flow
All Implemented Interfaces:
Drawable

public class Flow
extends AbstractDrawable

A flow of packets along some path through some set of node-port pairs.

Author:
David Underhill

Field Summary
static boolean ALLOW_FLOW_SELECTION
          whether flows may be selected or highlighted
static boolean ANIMATE
          whether flows should be animated
 
Constructor Summary
Flow(FlowType type, int flowID, FlowHop[] path)
          Creates a flow between two endpoints.
 
Method Summary
 boolean contains(int x, int y)
          returns true if the specified coordinates are in the area covered by this flow
 void drawObject(java.awt.Graphics2D gfx)
          Draw the flow
 java.awt.Color getColor()
          Gets the color of this flow
 int getID()
          Gets the ID of this flow
 FlowHop[] getPath()
          Gets the path of this flow
 int getPointSize()
          Gets the width of the line within which segments of the flow are drawn
 FlowType getType()
          Gets the type of this flow
 boolean hasSegment(Pair<FlowHop,FlowHop> s)
          whether this flow contains a particular segment
 void ignoreSegment(Pair<FlowHop,FlowHop> s)
          add a segment to ignore
 boolean isWithin(int x, int y, boolean select)
          Returns true if the specified coordinates are in the area covered by this flow.
 void setSelected(boolean selected)
          Sets whether this flow is selected - should only be directly used when deselecting the flow (otherwise use selectFlow()).
 void unignoreSegment(Pair<FlowHop,FlowHop> s)
          stop ignoring a particular segment
 
Methods inherited from class org.pzgui.AbstractDrawable
drag, drawBeforeObject, isDrawn, isHovered, isSelected, setHovered, unsetDrawn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALLOW_FLOW_SELECTION

public static boolean ALLOW_FLOW_SELECTION
whether flows may be selected or highlighted


ANIMATE

public static final boolean ANIMATE
whether flows should be animated

See Also:
Constant Field Values
Constructor Detail

Flow

public Flow(FlowType type,
            int flowID,
            FlowHop[] path)
Creates a flow between two endpoints.

Parameters:
path - the path being taken by this flow from src to dst
Method Detail

getType

public FlowType getType()
Gets the type of this flow


getID

public int getID()
Gets the ID of this flow


getPath

public FlowHop[] getPath()
Gets the path of this flow


hasSegment

public boolean hasSegment(Pair<FlowHop,FlowHop> s)
whether this flow contains a particular segment


ignoreSegment

public void ignoreSegment(Pair<FlowHop,FlowHop> s)
add a segment to ignore


unignoreSegment

public void unignoreSegment(Pair<FlowHop,FlowHop> s)
stop ignoring a particular segment


drawObject

public void drawObject(java.awt.Graphics2D gfx)
Draw the flow

Specified by:
drawObject in interface Drawable
Specified by:
drawObject in class AbstractDrawable

getPointSize

public int getPointSize()
Gets the width of the line within which segments of the flow are drawn


getColor

public java.awt.Color getColor()
Gets the color of this flow


contains

public boolean contains(int x,
                        int y)
returns true if the specified coordinates are in the area covered by this flow

Specified by:
contains in interface Drawable
Specified by:
contains in class AbstractDrawable

isWithin

public boolean isWithin(int x,
                        int y,
                        boolean select)
Returns true if the specified coordinates are in the area covered by this flow. If select is true, and this returns true, then the flow will be selected too.

Parameters:
x - the x coordinate
y - the y coordinate
select - whether to select the flow if x,y is within the flow
Returns:
true if x,y is in the area covered by the flow

setSelected

public void setSelected(boolean selected)
Sets whether this flow is selected - should only be directly used when deselecting the flow (otherwise use selectFlow()). If selected is false, then the current selection will slide back to its original position.

Specified by:
setSelected in interface Drawable
Overrides:
setSelected in class AbstractDrawable