bibliothek.gui.dock.station.screen.magnet
Class StickMagnetGraph.DefaultNode

java.lang.Object
  extended by bibliothek.gui.dock.station.screen.magnet.StickMagnetGraph.DefaultNode
All Implemented Interfaces:
StickMagnetGraph.Node
Enclosing class:
StickMagnetGraph

protected class StickMagnetGraph.DefaultNode
extends Object
implements StickMagnetGraph.Node

The default implementation of StickMagnetGraph.Node

Author:
Benjamin Sigg

Constructor Summary
StickMagnetGraph.DefaultNode(int index, ScreenDockWindow window)
          Creates a new node.
 
Method Summary
 void add(MagnetRequest.Side side, StickMagnetGraph.DefaultNode depending)
          Creates a new edge between this and depending.
 void add(StickMagnetGraph.DefaultEdge edge)
           
 boolean contains(StickMagnetGraph.DefaultNode node)
          Checks whether there is an edge from this node to node.
 void doVisit(StickMagnetGraph.Visitor visitor)
          Visits this node and all its children, sets the mark flag.
 StickMagnetGraphConstraint getConstraints()
          Gets the constraints telling how this node has to be modified.
 StickMagnetGraph.DefaultEdge[] getEdges()
          Gets a list of all edges that either start or end at this node.
 int getIndex()
          Gets the location of this node in the array of all nodes.
 MagnetRequest.Side getNeighbor(ScreenDockWindow window)
          Tells whether window is a neighbor of this node and depends on this node, and if so tells on which side of this node window lies.
 int getRootDistance()
          Gets the distance of this node to the root node.
 ScreenDockWindow getWindow()
          Gest the window which is described by this node.
 boolean isMarked()
          Tells whether a flag was set by StickMagnetGraph.Node.mark().
 void mark()
          Marks this node with a flag.
 void unmark()
          Unmarks this node from the flag that was set by StickMagnetGraph.Node.mark().
 void visit(StickMagnetGraph.Visitor visitor)
          Visits this node and all its children.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StickMagnetGraph.DefaultNode

public StickMagnetGraph.DefaultNode(int index,
                                    ScreenDockWindow window)
Creates a new node.

Parameters:
index - the location of this node in the array of all nodes
window - the window represented by this node
Method Detail

visit

public void visit(StickMagnetGraph.Visitor visitor)
Description copied from interface: StickMagnetGraph.Node
Visits this node and all its children.

Specified by:
visit in interface StickMagnetGraph.Node
Parameters:
visitor - the visitor used to traverse the node

getConstraints

public StickMagnetGraphConstraint getConstraints()
Gets the constraints telling how this node has to be modified.

Specified by:
getConstraints in interface StickMagnetGraph.Node
Returns:
the constraints

getRootDistance

public int getRootDistance()
Gets the distance of this node to the root node.

Returns:
the distance, 0 for the root node itself

doVisit

public void doVisit(StickMagnetGraph.Visitor visitor)
Visits this node and all its children, sets the mark flag.

Parameters:
visitor - the visitor that is called

mark

public void mark()
Description copied from interface: StickMagnetGraph.Node
Marks this node with a flag.

Specified by:
mark in interface StickMagnetGraph.Node

isMarked

public boolean isMarked()
Description copied from interface: StickMagnetGraph.Node
Tells whether a flag was set by StickMagnetGraph.Node.mark().

Specified by:
isMarked in interface StickMagnetGraph.Node

unmark

public void unmark()
Description copied from interface: StickMagnetGraph.Node
Unmarks this node from the flag that was set by StickMagnetGraph.Node.mark().

Specified by:
unmark in interface StickMagnetGraph.Node

getWindow

public ScreenDockWindow getWindow()
Description copied from interface: StickMagnetGraph.Node
Gest the window which is described by this node.

Specified by:
getWindow in interface StickMagnetGraph.Node
Returns:
the window

getIndex

public int getIndex()
Gets the location of this node in the array of all nodes.

Returns:
the location

add

public void add(MagnetRequest.Side side,
                StickMagnetGraph.DefaultNode depending)
Creates a new edge between this and depending. If there is already an edge from either node to the other, then nothing happens.

Parameters:
side - the side at which depending lies
depending - the node to which a new edge may be created

add

public void add(StickMagnetGraph.DefaultEdge edge)

contains

public boolean contains(StickMagnetGraph.DefaultNode node)
Checks whether there is an edge from this node to node.

Parameters:
node - the node to search
Returns:
true if there is a directed edge

getNeighbor

public MagnetRequest.Side getNeighbor(ScreenDockWindow window)
Description copied from interface: StickMagnetGraph.Node
Tells whether window is a neighbor of this node and depends on this node, and if so tells on which side of this node window lies.

Specified by:
getNeighbor in interface StickMagnetGraph.Node
Parameters:
window - a window that might be a neighbor of this node
Returns:
the side at which window lies or null

getEdges

public StickMagnetGraph.DefaultEdge[] getEdges()
Description copied from interface: StickMagnetGraph.Node
Gets a list of all edges that either start or end at this node.

Specified by:
getEdges in interface StickMagnetGraph.Node
Returns:
the list of edges, may be empty