net.sourceforge.swtlayeredgraph
Class LayerContainer<LayerItem extends LayerDrawable>

java.lang.Object
  extended by net.sourceforge.swtlayeredgraph.LayerContainer<LayerItem>
All Implemented Interfaces:
java.io.Serializable

public class LayerContainer<LayerItem extends LayerDrawable>
extends java.lang.Object
implements java.io.Serializable

Author:
davija
See Also:
Serialized Form

Constructor Summary
LayerContainer()
          Default constructor.
LayerContainer(ChangeListener listener)
          Builds a new layer container with a change listener
 
Method Summary
 void addItem(LayerItem item)
          Adds an item to the list.
 void addItemsAfter(LayerItem item, java.util.List<LayerItem> addItems)
          Adds the specified items starting after the specified item.
 void addItemsAt(int index, java.util.List<LayerItem> addItems)
          Adds the specified items starting at the specified index.
 void addItemsBefore(LayerItem item, java.util.List<LayerItem> addItems)
          Adds the specified items starting before the specified item.
 void addItemsInBack(java.util.List<LayerItem> addItems)
          Adds the specified items starting at the back of the list.
 void addItemsInFront(java.util.List<LayerItem> addItems)
          Adds the specified items starting at the front of the list.
protected  java.util.List<GraphPoint> getExtentPoints()
          Gets the list of extent points.
 LayerItem getItem(java.lang.String name)
          Returns the requested item.
 java.lang.Integer getItemCount()
          Gets the number of items in this group.
 java.util.List<java.lang.String> getItemNames()
          Gets a list of the names of items.
 java.util.List<LayerItem> getItems()
           
 java.lang.Boolean isDirty()
          Checks if this object is dirty.
 void moveBackward(LayerItem item)
          Moves item backward by one.
 void moveBackward(java.lang.String name)
          Moves item backward by one.
 void moveForward(LayerItem item)
          Moves item forward by one.
 void moveForward(java.lang.String name)
          Moves item forward by one.
 void moveToBack(LayerItem item)
          Moves the specified item to the back of the list.
 void moveToBack(java.lang.String name)
          Moves the specified item to the back of the list.
 void moveToFront(LayerItem item)
          Moves the specified item to the front of the list.
 void moveToFront(java.lang.String name)
          Moves the specified item to the front of the list.
 void removeItem(LayerItem item)
          Removes the specified item from the list.
 void removeItem(java.lang.String itemName)
          Removes the specified item from the list.
 void setDirty(java.lang.Boolean isDirty)
          Sets the dirty flag.
 void setItems(java.util.List<LayerItem> setItems)
          Sets the list of items to the specified list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LayerContainer

public LayerContainer()
Default constructor. Builds a layer container.


LayerContainer

public LayerContainer(ChangeListener listener)
Builds a new layer container with a change listener

Parameters:
listener - Name change listener called when the extent point list changes.
Method Detail

addItem

public void addItem(LayerItem item)
             throws DuplicateItemException
Adds an item to the list. Verifies that no other item or group has at this level has the same name.

Parameters:
item - LayerItem item to add.
Throws:
java.lang.IllegalArgumentException - If item is null or empty.
DuplicateItemException - Thrown if the name of the item matches any other items or groups in this group.

removeItem

public void removeItem(LayerItem item)
Removes the specified item from the list. If the item doesn't exist, it is ignored.

Parameters:
item - The item to be removed.
Throws:
java.lang.IllegalArgumentException - If item is null.

removeItem

public void removeItem(java.lang.String itemName)
Removes the specified item from the list. If the item doesn't exist, it is ignored.

Parameters:
itemName - The name of the item to be removed.
Throws:
java.lang.IllegalArgumentException - If itemName is null or empty.

getItem

public LayerItem getItem(java.lang.String name)
Returns the requested item. If the item could not be found, null will be returned.

Parameters:
name - Name of item to get.
Returns:
Returns the item with the specified name. If it couldn't be found, null is returned.
Throws:
java.lang.IllegalArgumentException - If name is null or empty.

getItemCount

public java.lang.Integer getItemCount()
Gets the number of items in this group.

Returns:
Returns the number of items in the group.

getItems

public java.util.List<LayerItem> getItems()

setItems

public void setItems(java.util.List<LayerItem> setItems)
              throws DuplicateItemException
Sets the list of items to the specified list. If a duplicate is found the rest of the items will be added then an exception thrown. All previous items will be removed from the list.

Parameters:
setItems - List of items to add.
Throws:
java.lang.IllegalArgumentException - If items is null.
DuplicateItemException - If there was a duplicate in the list.

moveToFront

public void moveToFront(LayerItem item)
Moves the specified item to the front of the list.

Parameters:
item - The item to move to the front.
Throws:
java.lang.IllegalArgumentException - If item is null.

moveToFront

public void moveToFront(java.lang.String name)
Moves the specified item to the front of the list.

Parameters:
name - Name of the item to move to the front of the list.
Throws:
java.lang.IllegalArgumentException - If name is null or empty.

moveToBack

public void moveToBack(LayerItem item)
Moves the specified item to the back of the list.

Parameters:
item - Item to move to the back of the list.
Throws:
java.lang.IllegalArgumentException - If item is null.

moveToBack

public void moveToBack(java.lang.String name)
Moves the specified item to the back of the list.

Parameters:
name - Name of the item to move to the back of the list.
Throws:
java.lang.IllegalArgumentException - If name is null or empty.

moveForward

public void moveForward(LayerItem item)
Moves item forward by one.

Parameters:
item - Item to move forward
Throws:
java.lang.IllegalArgumentException - If item is null.

moveForward

public void moveForward(java.lang.String name)
Moves item forward by one.

Parameters:
name - Name of item to move.
Throws:
java.lang.IllegalArgumentException - If name is null or empty.

moveBackward

public void moveBackward(LayerItem item)
Moves item backward by one.

Parameters:
item - Item to move backward
Throws:
java.lang.IllegalArgumentException - If item is null.

moveBackward

public void moveBackward(java.lang.String name)
Moves item backward by one.

Parameters:
item - Item to move backward
Throws:
java.lang.IllegalArgumentException - If item is null.

addItemsAt

public void addItemsAt(int index,
                       java.util.List<LayerItem> addItems)
Adds the specified items starting at the specified index. If a duplicate item is in the list, it is noted and the rest of the items are added. If there was a duplicate, an exception is thrown at the end.

Parameters:
index - The index to add items to.
addItems - Items to add.
Throws:
java.lang.IllegalArgumentException - If items is null, or index is negative.
DuplicateItemException - If items contains duplicates or has an item that is already in the list.

addItemsAfter

public void addItemsAfter(LayerItem item,
                          java.util.List<LayerItem> addItems)
Adds the specified items starting after the specified item. If the item does not exist, then items are added at the end. If a duplicate item is in the list, it is noted and the rest of the items are added. If there was a duplicate, an exception is thrown at the end.

Parameters:
addItem - The item to add after.
items - Items to add.
Throws:
java.lang.IllegalArgumentException - If items or item is null.
DuplicateItemException - If items contains duplicates or has an item that is already in the list.

addItemsBefore

public void addItemsBefore(LayerItem item,
                           java.util.List<LayerItem> addItems)
Adds the specified items starting before the specified item. If the item does not exist, then items are added at the front. If a duplicate item is in the list, it is noted and the rest of the items are added. If there was a duplicate, an exception is thrown at the end.

Parameters:
addItem - The item to add before.
items - Items to add.
Throws:
java.lang.IllegalArgumentException - If items or item is null.
DuplicateItemException - If items contains duplicates or has an item that is already in the list.

addItemsInFront

public void addItemsInFront(java.util.List<LayerItem> addItems)
Adds the specified items starting at the front of the list. If there was a duplicate it is noted and the rest of the list is processed, then an exception will be thrown.

Parameters:
addItems - Items to add to the front of the list.
Throws:
java.lang.IllegalArgumentException - If items is null.
DuplicateItemException - If there was a duplicate item in the list.

addItemsInBack

public void addItemsInBack(java.util.List<LayerItem> addItems)
Adds the specified items starting at the back of the list. If there was a duplicate it is noted and the rest of the list is processed, then an exception will be thrown.

Parameters:
addItems - Items to add to the back of the list.
Throws:
java.lang.IllegalArgumentException - If items is null.
DuplicateItemException - If there was a duplicate item in the list.

getItemNames

public java.util.List<java.lang.String> getItemNames()
Gets a list of the names of items. This list is not sorted.

Returns:
Returns an unsorted list with names of all items.

getExtentPoints

protected java.util.List<GraphPoint> getExtentPoints()
Gets the list of extent points.

Returns:
Returns the list of extent points.

setDirty

public void setDirty(java.lang.Boolean isDirty)
Sets the dirty flag.

Parameters:
isDirty - Flag used to indicate if this object is dirty.

isDirty

public java.lang.Boolean isDirty()
Checks if this object is dirty.

Returns:
Returns true if dirty, false otherwise.


Copyright © 2009. All Rights Reserved.