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