org.fest.swing.driver
Class JTreeLocation

java.lang.Object
  extended by org.fest.swing.driver.JTreeLocation

public final class JTreeLocation
extends Object

Understands a visible location on a JTree. A row index or a Stringified TreePath (i.e. each TreePath component is a String) or a TreePath of Object may be used to indicate the location. Note that if a TreePath is used, the entire path leading up to the designated node must be viewable at the time the location is used.

Author:
Alex Ruiz

Constructor Summary
JTreeLocation()
           
 
Method Summary
 Pair<Rectangle,Point> pathBoundsAndCoordinates(JTree tree, TreePath path)
          Returns the bounds and visible coordinates of the given path.
 TreePath pathFor(JTree tree, int row)
          Returns the path for the given row.
 Pair<Rectangle,Point> rowBoundsAndCoordinates(JTree tree, int row)
          Returns the bounds and visible coordinates of the given row.
 int validIndex(JTree tree, int row)
          Validates that the given row index is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JTreeLocation

public JTreeLocation()
Method Detail

rowBoundsAndCoordinates

@RunsInCurrentThread
public Pair<Rectangle,Point> rowBoundsAndCoordinates(JTree tree,
                                                                         int row)
Returns the bounds and visible coordinates of the given row.

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

Parameters:
tree - the target JTree.
row - the given row.
Returns:
the the bounds and visible coordinates of the given row.
Throws:
IndexOutOfBoundsException - if the given row is less than zero or equal than or greater than the number of visible rows in the JTree.
LocationUnavailableException - if a tree path for the given row cannot be found.
Since:
1.2

pathFor

@RunsInCurrentThread
public TreePath pathFor(JTree tree,
                                            int row)
Returns the path for the given row.

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

Parameters:
tree - the target JTree.
row - the given row.
Returns:
the path for the given row.
Throws:
IndexOutOfBoundsException - if the given row is less than zero or equal than or greater than the number of visible rows in the JTree.
LocationUnavailableException - if a tree path for the given row cannot be found.

validIndex

@RunsInCurrentThread
public int validIndex(JTree tree,
                                          int row)
Validates that the given row index is valid.

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

Parameters:
tree - the target JTree.
row - the row index to validate.
Returns:
the validated row index.
Throws:
IndexOutOfBoundsException - if the given row is less than zero or equal than or greater than the number of visible rows in the JTree.

pathBoundsAndCoordinates

@RunsInCurrentThread
public Pair<Rectangle,Point> pathBoundsAndCoordinates(JTree tree,
                                                                          TreePath path)
Returns the bounds and visible coordinates of the given path.

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

Parameters:
tree - the target JTree.
path - the given path.
Returns:
the bounds and visible coordinates of the given path.
Throws:
LocationUnavailableException - if any part of the path is not visible.
Since:
1.2


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.