bibliothek.gui.dock.station.split
Class SplitDockPathProperty

java.lang.Object
  extended by bibliothek.gui.dock.layout.AbstractDockableProperty
      extended by bibliothek.gui.dock.station.split.SplitDockPathProperty
All Implemented Interfaces:
DockableProperty, Iterable<SplitDockPathProperty.Node>

public class SplitDockPathProperty
extends AbstractDockableProperty
implements Iterable<SplitDockPathProperty.Node>

A DockableProperty used by the SplitDockStation to describe the location of a Dockable in the tree of all children of the station.

Author:
Benjamin Sigg

Nested Class Summary
static class SplitDockPathProperty.Location
          The direction which the path takes
static class SplitDockPathProperty.Node
          Describes one turn of the path.
 
Constructor Summary
SplitDockPathProperty()
          Creates a new, empty path
 
Method Summary
 void add(SplitDockPathProperty.Location location, double size, long id)
          Adds a new element to the end of the path.
 DockableProperty copy()
          Gets a copy of this property, the successor must be copied as well.
 boolean equals(Object obj)
           
 String getFactoryID()
          Gets the unique name of the DockablePropertyFactory which can create this type of DockableProperty.
 SplitDockPathProperty.Node getLastNode()
          Gets the last node of this path.
 long getLeafId()
          Gets the unique identifier of the leaf that was stored in this path.
 SplitDockPathProperty.Node getNode(int index)
          Gets the index'th node, where the node 0 is the node nearest to the root.
 int hashCode()
           
 void insert(SplitDockPathProperty.Location location, double size, int index, long id)
          Adds a new element to the path.
 Iterator<SplitDockPathProperty.Node> iterator()
           
 void load(DataInputStream in)
          Reads the contents of this DockableProperty from a stream.
 void load(XElement element)
          Reads the contents of this DockableProperty from an xml element.
 void setLeafId(long leafId)
          Sets the unique identifier of the leaf that was stored in this path.
 int size()
          Gets the number of nodes stores in this property.
 void store(DataOutputStream out)
          Stores the contents of this DockableProperty in a stream.
 void store(XElement element)
          Stores the contents of this property as xml element.
 SplitDockProperty toLocation()
          Calculates which bounds the element accessed through the given path would have.
 SplitDockProperty toLocation(SplitNode onPath)
          Calculates which bounds the element accessed through this path would have.
 String toString()
           
 
Methods inherited from class bibliothek.gui.dock.layout.AbstractDockableProperty
copy, equalsNoSuccessor, getSuccessor, setSuccessor
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SplitDockPathProperty

public SplitDockPathProperty()
Creates a new, empty path

Method Detail

copy

public DockableProperty copy()
Description copied from interface: DockableProperty
Gets a copy of this property, the successor must be copied as well.

Specified by:
copy in interface DockableProperty
Returns:
an independent copy of this

iterator

public Iterator<SplitDockPathProperty.Node> iterator()
Specified by:
iterator in interface Iterable<SplitDockPathProperty.Node>

size

public int size()
Gets the number of nodes stores in this property.

Returns:
the number of nodes

getNode

public SplitDockPathProperty.Node getNode(int index)
Gets the index'th node, where the node 0 is the node nearest to the root.

Parameters:
index - the index of the node
Returns:
the node

setLeafId

public void setLeafId(long leafId)
Sets the unique identifier of the leaf that was stored in this path.

Parameters:
leafId - the id or -1

getLeafId

public long getLeafId()
Gets the unique identifier of the leaf that was stored in this path.

Returns:
the id or -1

getLastNode

public SplitDockPathProperty.Node getLastNode()
Gets the last node of this path.

Returns:
the last node or null if this path is empty

toLocation

public SplitDockProperty toLocation()
Calculates which bounds the element accessed through the given path would have.

Returns:
the bounds

toLocation

public SplitDockProperty toLocation(SplitNode onPath)
Calculates which bounds the element accessed through this path would have. This method assumes that onPath is a node that is on this path and first searches for an item with the same unique identifier like onPath. If such an item is found, then the current boundaries of onPath are taken as start parameters.

Parameters:
onPath - some node which might be on this path
Returns:
the boundaries

add

public void add(SplitDockPathProperty.Location location,
                double size,
                long id)
Adds a new element to the end of the path. Every element describes which turn the path takes in a node.

Parameters:
location - the direction into which the path goes
size - the relative size of the path, a value in the range 0.0 to 1.0
id - the unique identifier of the node or -1

insert

public void insert(SplitDockPathProperty.Location location,
                   double size,
                   int index,
                   long id)
Adds a new element to the path. Every element describes which turn the path takes in a node.

Parameters:
location - the direction into which the path goes
size - the relative size of the path, a value in the range 0.0 to 1.0
index - where to add the new element
id - the unique identifier of the new node or -1

getFactoryID

public String getFactoryID()
Description copied from interface: DockableProperty
Gets the unique name of the DockablePropertyFactory which can create this type of DockableProperty.

Specified by:
getFactoryID in interface DockableProperty
Returns:
the id
See Also:
DockablePropertyFactory

store

public void store(DataOutputStream out)
           throws IOException
Description copied from interface: DockableProperty
Stores the contents of this DockableProperty in a stream. The successor (if there is one) must not be saved.

Specified by:
store in interface DockableProperty
Parameters:
out - the stream to write in
Throws:
IOException - if anything unexpected happens

store

public void store(XElement element)
Description copied from interface: DockableProperty
Stores the contents of this property as xml element.

Specified by:
store in interface DockableProperty
Parameters:
element - the element into which to write, the attributes of this element should not be changed

load

public void load(DataInputStream in)
          throws IOException
Description copied from interface: DockableProperty
Reads the contents of this DockableProperty from a stream. The property can assume that a property with the same type has written into the stream.

Specified by:
load in interface DockableProperty
Parameters:
in - the stream to read
Throws:
IOException - if anything unexpected happens

load

public void load(XElement element)
Description copied from interface: DockableProperty
Reads the contents of this DockableProperty from an xml element.

Specified by:
load in interface DockableProperty
Parameters:
element - the element that was written earlier by this property

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractDockableProperty

equals

public boolean equals(Object obj)
Overrides:
equals in class AbstractDockableProperty