1. /*
  2. * @(#)WindowsTreeUI.java 1.16 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 com.sun.java.swing.plaf.windows;
  11. import java.awt.*;
  12. import java.awt.event.*;
  13. import java.io.*;
  14. import java.util.*;
  15. import javax.swing.plaf.basic.*;
  16. import javax.swing.*;
  17. import javax.swing.plaf.*;
  18. /**
  19. * A Windows tree.
  20. * <p>
  21. * <strong>Warning:</strong>
  22. * Serialized objects of this class will not be compatible with
  23. * future Swing releases. The current serialization support is appropriate
  24. * for short term storage or RMI between applications running the same
  25. * version of Swing. A future release of Swing will provide support for
  26. * long term persistence.
  27. *
  28. * @version 1.16 02/02/00
  29. * @author Scott Violet
  30. */
  31. public class WindowsTreeUI extends BasicTreeUI {
  32. public static ComponentUI createUI( JComponent c )
  33. {
  34. return new WindowsTreeUI();
  35. }
  36. protected void paintVerticalLine( Graphics g, JComponent c, int x, int top, int bottom )
  37. {
  38. drawDashedVerticalLine( g, x, top, bottom );
  39. }
  40. protected void paintHorizontalLine( Graphics g, JComponent c, int y, int left, int right )
  41. {
  42. drawDashedHorizontalLine( g, y, left, right );
  43. }
  44. static protected final int HALF_SIZE = 4;
  45. static protected final int SIZE = 9;
  46. /**
  47. * The minus sign button icon
  48. * <p>
  49. * <strong>Warning:</strong>
  50. * Serialized objects of this class will not be compatible with
  51. * future Swing releases. The current serialization support is appropriate
  52. * for short term storage or RMI between applications running the same
  53. * version of Swing. A future release of Swing will provide support for
  54. * long term persistence.
  55. */
  56. public static class ExpandedIcon implements Icon, Serializable {
  57. static public Icon createExpandedIcon() {
  58. return new ExpandedIcon();
  59. }
  60. public void paintIcon(Component c, Graphics g, int x, int y) {
  61. Color backgroundColor = c.getBackground();
  62. if(backgroundColor != null)
  63. g.setColor(backgroundColor);
  64. else
  65. g.setColor(Color.white);
  66. g.fillRect(x, y, SIZE-1, SIZE-1);
  67. g.setColor(Color.gray);
  68. g.drawRect(x, y, SIZE-1, SIZE-1);
  69. g.setColor(Color.black);
  70. g.drawLine(x + 2, y + HALF_SIZE, x + (SIZE - 3), y + HALF_SIZE);
  71. }
  72. public int getIconWidth() { return SIZE; }
  73. public int getIconHeight() { return SIZE; }
  74. }
  75. /**
  76. * The plus sign button icon
  77. * <p>
  78. * <strong>Warning:</strong>
  79. * Serialized objects of this class will not be compatible with
  80. * future Swing releases. The current serialization support is appropriate
  81. * for short term storage or RMI between applications running the same
  82. * version of Swing. A future release of Swing will provide support for
  83. * long term persistence.
  84. */
  85. public static class CollapsedIcon extends ExpandedIcon {
  86. static public Icon createCollapsedIcon() {
  87. return new CollapsedIcon();
  88. }
  89. public void paintIcon(Component c, Graphics g, int x, int y) {
  90. super.paintIcon(c, g, x, y);
  91. g.drawLine(x + HALF_SIZE, y + 2, x + HALF_SIZE, y + (SIZE - 3));
  92. }
  93. }
  94. }