abbot.tester
Class JTreeLocation

java.lang.Object
  extended byabbot.tester.ComponentLocation
      extended byabbot.tester.JTreeLocation

public class JTreeLocation
extends ComponentLocation

Provides encapsulation of a visible location on a JTree. A row may be indicated with [row] or a tree path [root, parent, child].


Constructor Summary
JTreeLocation()
          Create an uninitialized JTreeLocation.
JTreeLocation(int row)
          Create a JTreeLocation corresponding to the given row, by index.
JTreeLocation(int row, boolean inExpansion)
          Create a JTreeLocation corresponding to the given row, by index.
JTreeLocation(Point p)
           
JTreeLocation(TreePath treePath)
          Create a JTreeLocation corresponding to the given TreePath.
JTreeLocation(TreePath treePath, boolean inExpansion)
          Create a JTreeLocation corresponding to the given TreePath.
 
Method Summary
protected  String badFormat(String encoded)
           
 boolean equals(Object o)
           
static TreePath findMatchingPath(JTree tree, TreePath path)
          Given a TreePath of Strings, return the equivalent TreePath for the given JTree constructed from objects from the tree's model.
 Rectangle getBounds(Component c)
          Convert the abstract location into a concrete area.
(package private)  TreePath getPath(JTree tree)
          Return the path represented by this JTree location.
 Point getPoint(Component c)
          Return a concrete point for the abstract location.
(package private)  int getRow(JTree tree)
          Return the row represented by this JTree location.
 boolean isInExpansion()
           
 ComponentLocation parse(String encoded)
          Convert the given encoding into the proper location.
protected  Point pathToPoint(JTree tree, TreePath path)
          Convert the given path to an x, y coordinate.
protected  Point rowToPoint(JTree tree, int row)
          Convert the given row to an x, y coordinate.
 void setInExpansion(boolean in)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JTreeLocation

public JTreeLocation()
Create an uninitialized JTreeLocation. If queried for its Point will return the default location.


JTreeLocation

public JTreeLocation(int row)
Create a JTreeLocation corresponding to the given row, by index.


JTreeLocation

public JTreeLocation(int row,
                     boolean inExpansion)
Create a JTreeLocation corresponding to the given row, by index.


JTreeLocation

public JTreeLocation(TreePath treePath)
Create a JTreeLocation corresponding to the given TreePath. The TreePath must consist of usable String representations that can be used in later comparisons. The default @ returned by Object.toString() is not usable; if that is all that is available, refer to the row number instead.


JTreeLocation

public JTreeLocation(TreePath treePath,
                     boolean inExpansion)
Create a JTreeLocation corresponding to the given TreePath. The TreePath must consist of usable String representations that can be used in later comparisons. The default @ returned by Object.toString() is not usable; if that is all that is available, refer to the row number instead.


JTreeLocation

public JTreeLocation(Point p)
Method Detail

setInExpansion

public void setInExpansion(boolean in)

isInExpansion

public boolean isInExpansion()

rowToPoint

protected Point rowToPoint(JTree tree,
                           int row)
Convert the given row to an x, y coordinate.

Throws:
LocationUnavailableException - if the row is not visible.

pathToPoint

protected Point pathToPoint(JTree tree,
                            TreePath path)
Convert the given path to an x, y coordinate.

Throws:
LocationUnavailableException - if any part of the path is hidden.

getPath

TreePath getPath(JTree tree)
Return the path represented by this JTree location.

Returns:
null if the path can not be found.

getRow

int getRow(JTree tree)
Return the row represented by this JTree location.

Returns:
-1 if the row is not found.

getPoint

public Point getPoint(Component c)
Return a concrete point for the abstract location.

Overrides:
getPoint in class ComponentLocation

getBounds

public Rectangle getBounds(Component c)
Description copied from class: ComponentLocation
Convert the abstract location into a concrete area. If a point has been specified, returns a 1x1 rectangle, otherwise returns the a rectangle at (0, 0) of the Component's size.

Overrides:
getBounds in class ComponentLocation

equals

public boolean equals(Object o)
Overrides:
equals in class ComponentLocation

toString

public String toString()
Overrides:
toString in class ComponentLocation

parse

public ComponentLocation parse(String encoded)
Description copied from class: ComponentLocation
Convert the given encoding into the proper location. Allowed formats: (x, y)

Overrides:
parse in class ComponentLocation

badFormat

protected String badFormat(String encoded)
Overrides:
badFormat in class ComponentLocation

findMatchingPath

public static TreePath findMatchingPath(JTree tree,
                                        TreePath path)
Given a TreePath of Strings, return the equivalent TreePath for the given JTree constructed from objects from the tree's model. If necessary, expands nodes in the tree until the requested path is fully visible.

Throws:
LocationUnavailableException - if no matching path is found.


Copyright © 2002-2004 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge