Beispiel #1
0
 /**
  * create an identifier for a descendant area.
  * as a BinContainerArea can only have one direct child area,
  * the only valie identifiers are ones that are at the end of
  * thier path, indicating that it identifies this this node,
  * or an identifier with its' current element being zero, indicating
  * that the current leg of its's path identifies the zero'th and
  * only child node.
  */
 public override Area GetArea(AreaIdentifier id)
 {
     if (id.End)
     {
         return(this);
     }
     else if (id.Current == 0)
     {
         id.MoveNext();
         return(child.GetArea(id));
     }
     else
     {
         throw new InvalidIdentifier();
     }
 }
Beispiel #2
0
 /**
  * get the right side value.
  * the identier is only valid if it is for the child
  * node, or one of the child node's descendants. a
  * bin container can not have a right side value.
  */
 public override Scaled RightSide(AreaIdentifier id)
 {
     if (id.End)
     {
         throw new InvalidOperation();
     }
     else if (id.Current == 0)
     {
         id.MoveNext();
         return(child.RightSide(id));
     }
     else
     {
         throw new InvalidIdentifier();
     }
 }
Beispiel #3
0
 /**
  * get a child area that has a path to this node
  * if the identifier is at its's last item, this final step
  * in the path, so return this node, otherwise, if the current step
  * is valid (less than the size of the child node list, the child
  * area at the current position will get the path moved to the next
  * position. If the id is not at it's end, and the current item is
  * out of range, an invalid id exception is thrown.
  */
 public override Area GetArea(AreaIdentifier id)
 {
     if (id.End)
     {
         return(this);
     }
     else if (id.Current < content.Length)
     {
         Area current = content[id.Current];
         id.MoveNext();
         return(current.GetArea(id));
     }
     else
     {
         throw new InvalidIdentifier();
     }
 }
Beispiel #4
0
 /**
  * TODO write this up
  */
 public override Scaled Origin(AreaIdentifier id)
 {
     if (id.End)
     {
         // get the origin for this node.
         return(0);
     }
     else if (id.Current == 0)
     {
         // get the origin for the child node
         id.MoveNext();
         return(child.Origin(id));
     }
     else
     {
         // bad monkey
         throw new InvalidIdentifier();
     }
 }