Class JTreeLocation

java.lang.Object
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.
  • Constructor Details

    • JTreeLocation

      public JTreeLocation()
  • Method Details

    • 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 executed in the event dispatch thread (EDT.) Clients are responsible for invoking this method in 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 executed in the event dispatch thread (EDT.) Clients are responsible for invoking this method in 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.
      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 executed in the event dispatch thread (EDT.) Clients are responsible for invoking this method in 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
    • pointAt

      private Point pointAt(Rectangle cellBounds)