1. /*
  2. * @(#)MotifTreeCellRenderer.java 1.11 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 com.sun.java.swing.plaf.motif;
  8. import javax.swing.*;
  9. import javax.swing.plaf.*;
  10. import javax.swing.tree.*;
  11. import java.awt.*;
  12. import java.awt.event.*;
  13. import java.beans.*;
  14. import java.io.*;
  15. import java.util.*;
  16. /**
  17. * Motif rendered to display a tree cell.
  18. * <p>
  19. * <strong>Warning:</strong>
  20. * Serialized objects of this class will not be compatible with
  21. * future Swing releases. The current serialization support is appropriate
  22. * for short term storage or RMI between applications running the same
  23. * version of Swing. A future release of Swing will provide support for
  24. * long term persistence.
  25. *
  26. * @version 1.11 11/29/01
  27. * @author Jeff Dinkins
  28. */
  29. public class MotifTreeCellRenderer extends DefaultTreeCellRenderer
  30. {
  31. static final int LEAF_SIZE = 13;
  32. static final Icon LEAF_ICON = new IconUIResource(new TreeLeafIcon());
  33. public MotifTreeCellRenderer() {
  34. super();
  35. }
  36. public static Icon loadLeafIcon() {
  37. return LEAF_ICON;
  38. }
  39. /**
  40. * Icon for a node with no children.
  41. * <p>
  42. * <strong>Warning:</strong>
  43. * Serialized objects of this class will not be compatible with
  44. * future Swing releases. The current serialization support is appropriate
  45. * for short term storage or RMI between applications running the same
  46. * version of Swing. A future release of Swing will provide support for
  47. * long term persistence.
  48. */
  49. public static class TreeLeafIcon implements Icon, Serializable {
  50. Color bg;
  51. Color shadow;
  52. Color highlight;
  53. public TreeLeafIcon() {
  54. bg = UIManager.getColor("Tree.iconBackground");
  55. shadow = UIManager.getColor("Tree.iconShadow");
  56. highlight = UIManager.getColor("Tree.iconHighlight");
  57. }
  58. public void paintIcon(Component c, Graphics g, int x, int y) {
  59. g.setColor(bg);
  60. g.fillRect(4, 7, 5, 5);
  61. g.drawLine(6, 6, 6, 6);
  62. g.drawLine(3, 9, 3, 9);
  63. g.drawLine(6, 12, 6, 12);
  64. g.drawLine(9, 9, 9, 9);
  65. g.setColor(highlight);
  66. g.drawLine(2, 9, 5, 6);
  67. g.drawLine(3, 10, 5, 12);
  68. g.setColor(shadow);
  69. g.drawLine(6, 13, 10, 9);
  70. g.drawLine(9, 8, 7, 6);
  71. }
  72. public int getIconWidth() {
  73. return LEAF_SIZE;
  74. }
  75. public int getIconHeight() {
  76. return LEAF_SIZE;
  77. }
  78. }
  79. }