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