1. /*
  2. * @(#)GraphicsCallback.java 1.6 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt;
  8. import java.awt.peer.LightweightPeer;
  9. import sun.awt.SunGraphicsCallback;
  10. abstract class GraphicsCallback extends SunGraphicsCallback {
  11. static final class PaintCallback extends GraphicsCallback {
  12. private static PaintCallback instance = new PaintCallback();
  13. private PaintCallback() {}
  14. public void run(Component comp, Graphics cg) {
  15. comp.paint(cg);
  16. }
  17. static PaintCallback getInstance() {
  18. return instance;
  19. }
  20. }
  21. static final class PrintCallback extends GraphicsCallback {
  22. private static PrintCallback instance = new PrintCallback();
  23. private PrintCallback() {}
  24. public void run(Component comp, Graphics cg) {
  25. comp.print(cg);
  26. }
  27. static PrintCallback getInstance() {
  28. return instance;
  29. }
  30. }
  31. static final class PaintAllCallback extends GraphicsCallback {
  32. private static PaintAllCallback instance = new PaintAllCallback();
  33. private PaintAllCallback() {}
  34. public void run(Component comp, Graphics cg) {
  35. comp.paintAll(cg);
  36. }
  37. static PaintAllCallback getInstance() {
  38. return instance;
  39. }
  40. }
  41. static final class PrintAllCallback extends GraphicsCallback {
  42. private static PrintAllCallback instance = new PrintAllCallback();
  43. private PrintAllCallback() {}
  44. public void run(Component comp, Graphics cg) {
  45. comp.printAll(cg);
  46. }
  47. static PrintAllCallback getInstance() {
  48. return instance;
  49. }
  50. }
  51. static final class PeerPaintCallback extends GraphicsCallback {
  52. private static PeerPaintCallback instance = new PeerPaintCallback();
  53. private PeerPaintCallback() {}
  54. public void run(Component comp, Graphics cg) {
  55. comp.validate();
  56. if (comp.peer instanceof LightweightPeer) {
  57. comp.lightweightPaint(cg);
  58. } else {
  59. comp.peer.paint(cg);
  60. }
  61. }
  62. static PeerPaintCallback getInstance() {
  63. return instance;
  64. }
  65. }
  66. static final class PeerPrintCallback extends GraphicsCallback {
  67. private static PeerPrintCallback instance = new PeerPrintCallback();
  68. private PeerPrintCallback() {}
  69. public void run(Component comp, Graphics cg) {
  70. comp.validate();
  71. if (comp.peer instanceof LightweightPeer) {
  72. comp.lightweightPrint(cg);
  73. } else {
  74. comp.peer.print(cg);
  75. }
  76. }
  77. static PeerPrintCallback getInstance() {
  78. return instance;
  79. }
  80. }
  81. static final class PaintHeavyweightComponentsCallback
  82. extends GraphicsCallback
  83. {
  84. private static PaintHeavyweightComponentsCallback instance =
  85. new PaintHeavyweightComponentsCallback();
  86. private PaintHeavyweightComponentsCallback() {}
  87. public void run(Component comp, Graphics cg) {
  88. if (comp.peer instanceof LightweightPeer) {
  89. comp.paintHeavyweightComponents(cg);
  90. } else {
  91. comp.paintAll(cg);
  92. }
  93. }
  94. static PaintHeavyweightComponentsCallback getInstance() {
  95. return instance;
  96. }
  97. }
  98. static final class PrintHeavyweightComponentsCallback
  99. extends GraphicsCallback
  100. {
  101. private static PrintHeavyweightComponentsCallback instance =
  102. new PrintHeavyweightComponentsCallback();
  103. private PrintHeavyweightComponentsCallback() {}
  104. public void run(Component comp, Graphics cg) {
  105. if (comp.peer instanceof LightweightPeer) {
  106. comp.printHeavyweightComponents(cg);
  107. } else {
  108. comp.printAll(cg);
  109. }
  110. }
  111. static PrintHeavyweightComponentsCallback getInstance() {
  112. return instance;
  113. }
  114. }
  115. }