ice.pilots.html4
Class DRange

java.lang.Object
  extended byice.pilots.html4.DRange

public class DRange
extends Object


Constructor Summary
protected DRange()
           
 
Method Summary
 DElement duplicateSelectedDomHierarchy()
          Retrieve the topmost Element of the selected DOM hierarchy.
 void empty()
           
 DNode getEndContainer()
           
 int getEndOffset()
           
 DNode getStartContainer()
           
 int getStartOffset()
           
 boolean isInside(DNode n)
          Check to see if a given node is in the selection path.
 boolean isInside(DNode node, int chrIndex)
          More complex isInside.
 String toString()
          Retrieve a string representation of the selection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DRange

protected DRange()
Method Detail

empty

public void empty()

toString

public String toString()
Retrieve a string representation of the selection.

Returns:

duplicateSelectedDomHierarchy

public final DElement duplicateSelectedDomHierarchy()
Retrieve the topmost Element of the selected DOM hierarchy. This method duplicates the DOM hierarchy from the common parent up to the top (HTML) node, then duplicates the leafiest nodes between the startContainer and endContainer

Returns:
the parent

isInside

public boolean isInside(DNode n)
Check to see if a given node is in the selection path.

Given a possible node hierarchy as follows:

          common node
            /     \
     n1 - n2      n3 - n4 - n5
    /      /        \    \     \
   n6     n7        n8    n9    n10

 
Given a startpath of n9 - n4 and and endPath of n6-n1, this code does a test for inclusion and exclusion based upon how siblings of a given node intersect with the start and end Paths. For example, n5 would be excluded since it's outside the dome of selection. Think of the Dome of silence in Maxwell Smart. You're either sitting in the Dome, or you're sitting outside the dome. n8 and n7 would be inside the dome, since sibling navigation always runs into the start or end path from the correct direction.

By ascending up the hierarchy, any node must either be entirely included or excluded from the selected area.

Parameters:
n - The Node to test
Returns:
True if the Node n is contained in the selection hierarchy

isInside

public boolean isInside(DNode node,
                        int chrIndex)
More complex isInside. Used to determine if a given character offset within the text box is within the currently selected text region. If the node is completely within the selection region (eg. is not one of the endpoints) the logic is no different. The only case that is interesting is if the node is one of the endpoints.

Parameters:
node - The node to test
chrIndex - The equivalent char index of the point within the node.
Returns:
True if the point is within the selected range

getStartContainer

public DNode getStartContainer()

getEndContainer

public DNode getEndContainer()

getStartOffset

public int getStartOffset()

getEndOffset

public int getEndOffset()