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