1. package org.jr.awt.icon;
  2. /**
  3. * Copyright: Copyright (c) 2002-2004
  4. * Company: JavaResearch(http://www.javaresearch.org)
  5. * 最后更新日期:2003年2月16日
  6. * @author Cherami
  7. */
  8. import java.awt.*;
  9. import javax.swing.*;
  10. import javax.swing.plaf.metal.*;
  11. /**
  12. * 被禁止的叶子节点(文件)图标。
  13. * @since 0.1
  14. */
  15. public class DisabledLeafIcon
  16. implements Icon {
  17. int width = 16;
  18. int height = 16;
  19. int additionalHeight = 4;
  20. /**
  21. * 绘制图标
  22. * @param c 绘制组件
  23. * @param g 图形设备
  24. * @param x 绘制的x坐标的起始点
  25. * @param y 绘制的y坐标的起始点
  26. * @since 0.1
  27. */
  28. public void paintIcon(Component c, Graphics g, int x, int y) {
  29. int right = width - 1;
  30. int bottom = height + 1;
  31. g.setColor(c.getBackground());
  32. g.fillRect(0, 0, width, getIconHeight());
  33. // Draw frame
  34. g.setColor(MetalLookAndFeel.getControlDisabled());
  35. g.drawLine(2, 2, 2, bottom); // left
  36. g.drawLine(2, 2, right - 4, 2); // top
  37. g.drawLine(2, bottom, right - 1, bottom); // bottom
  38. g.drawLine(right - 1, 8, right - 1, bottom); // right
  39. g.drawLine(right - 6, 4, right - 2, 8); // slant 1
  40. g.drawLine(right - 5, 3, right - 4, 3); // part of slant 2
  41. g.drawLine(right - 3, 4, right - 3, 5); // part of slant 2
  42. g.drawLine(right - 2, 6, right - 2, 7); // part of slant 2
  43. }
  44. /**
  45. * 图标宽度。
  46. * @return 图标宽度
  47. * @since 0.1
  48. */
  49. public int getIconWidth() {
  50. return width;
  51. }
  52. /**
  53. * 图标高度。
  54. * @return 图标高度
  55. * @since 0.1
  56. */
  57. public int getIconHeight() {
  58. return height + additionalHeight;
  59. }
  60. }