1. /*
  2. * @(#)TreeUI.java 1.21 00/02/02
  3. *
  4. * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.swing.plaf;
  11. import java.awt.Rectangle;
  12. import javax.swing.JTree;
  13. import javax.swing.tree.TreePath;
  14. /**
  15. * Pluggable look and feel interface for JTree.
  16. *
  17. * @version 1.21 02/02/00
  18. * @author Rob Davis
  19. * @author Scott Violet
  20. */
  21. public abstract class TreeUI extends ComponentUI
  22. {
  23. /**
  24. * Returns the Rectangle enclosing the label portion that the
  25. * last item in path will be drawn into. Will return null if
  26. * any component in path is currently valid.
  27. */
  28. public abstract Rectangle getPathBounds(JTree tree, TreePath path);
  29. /**
  30. * Returns the path for passed in row. If row is not visible
  31. * null is returned.
  32. */
  33. public abstract TreePath getPathForRow(JTree tree, int row);
  34. /**
  35. * Returns the row that the last item identified in path is visible
  36. * at. Will return -1 if any of the elements in path are not
  37. * currently visible.
  38. */
  39. public abstract int getRowForPath(JTree tree, TreePath path);
  40. /**
  41. * Returns the number of rows that are being displayed.
  42. */
  43. public abstract int getRowCount(JTree tree);
  44. /**
  45. * Returns the path to the node that is closest to x,y. If
  46. * there is nothing currently visible this will return null, otherwise
  47. * it'll always return a valid path. If you need to test if the
  48. * returned object is exactly at x, y you should get the bounds for
  49. * the returned path and test x, y against that.
  50. */
  51. public abstract TreePath getClosestPathForLocation(JTree tree, int x,
  52. int y);
  53. /**
  54. * Returns true if the tree is being edited. The item that is being
  55. * edited can be returned by getEditingPath().
  56. */
  57. public abstract boolean isEditing(JTree tree);
  58. /**
  59. * Stops the current editing session. This has no effect if the
  60. * tree isn't being edited. Returns true if the editor allows the
  61. * editing session to stop.
  62. */
  63. public abstract boolean stopEditing(JTree tree);
  64. /**
  65. * Cancels the current editing session. This has no effect if the
  66. * tree isn't being edited. Returns true if the editor allows the
  67. * editing session to stop.
  68. */
  69. public abstract void cancelEditing(JTree tree);
  70. /**
  71. * Selects the last item in path and tries to edit it. Editing will
  72. * fail if the CellEditor won't allow it for the selected item.
  73. */
  74. public abstract void startEditingAtPath(JTree tree, TreePath path);
  75. /**
  76. * Returns the path to the element that is being edited.
  77. */
  78. public abstract TreePath getEditingPath(JTree tree);
  79. }