Home » openjdk-7 » java » awt » [javadoc | source]

    1   /*
    2    * Copyright (c) 1999, 2000, Oracle and/or its affiliates. All rights reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Oracle designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Oracle in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22    * or visit www.oracle.com if you need additional information or have any
   23    * questions.
   24    */
   25   
   26   package java.awt;
   27   
   28   import java.awt.peer.LightweightPeer;
   29   import sun.awt.SunGraphicsCallback;
   30   
   31   
   32   abstract class GraphicsCallback extends SunGraphicsCallback {
   33   
   34       static final class PaintCallback extends GraphicsCallback {
   35           private static PaintCallback instance = new PaintCallback();
   36   
   37           private PaintCallback() {}
   38           public void run(Component comp, Graphics cg) {
   39               comp.paint(cg);
   40           }
   41           static PaintCallback getInstance() {
   42               return instance;
   43           }
   44       }
   45       static final class PrintCallback extends GraphicsCallback {
   46           private static PrintCallback instance = new PrintCallback();
   47   
   48           private PrintCallback() {}
   49           public void run(Component comp, Graphics cg) {
   50               comp.print(cg);
   51           }
   52           static PrintCallback getInstance() {
   53               return instance;
   54           }
   55       }
   56       static final class PaintAllCallback extends GraphicsCallback {
   57           private static PaintAllCallback instance = new PaintAllCallback();
   58   
   59           private PaintAllCallback() {}
   60           public void run(Component comp, Graphics cg) {
   61               comp.paintAll(cg);
   62           }
   63           static PaintAllCallback getInstance() {
   64               return instance;
   65           }
   66       }
   67       static final class PrintAllCallback extends GraphicsCallback {
   68           private static PrintAllCallback instance = new PrintAllCallback();
   69   
   70           private PrintAllCallback() {}
   71           public void run(Component comp, Graphics cg) {
   72               comp.printAll(cg);
   73           }
   74           static PrintAllCallback getInstance() {
   75               return instance;
   76           }
   77       }
   78       static final class PeerPaintCallback extends GraphicsCallback {
   79           private static PeerPaintCallback instance = new PeerPaintCallback();
   80   
   81           private PeerPaintCallback() {}
   82           public void run(Component comp, Graphics cg) {
   83               comp.validate();
   84               if (comp.peer instanceof LightweightPeer) {
   85                   comp.lightweightPaint(cg);
   86               } else {
   87                   comp.peer.paint(cg);
   88               }
   89           }
   90           static PeerPaintCallback getInstance() {
   91               return instance;
   92           }
   93       }
   94       static final class PeerPrintCallback extends GraphicsCallback {
   95           private static PeerPrintCallback instance = new PeerPrintCallback();
   96   
   97           private PeerPrintCallback() {}
   98           public void run(Component comp, Graphics cg) {
   99               comp.validate();
  100               if (comp.peer instanceof LightweightPeer) {
  101                   comp.lightweightPrint(cg);
  102               } else {
  103                   comp.peer.print(cg);
  104               }
  105           }
  106           static PeerPrintCallback getInstance() {
  107               return instance;
  108           }
  109       }
  110       static final class PaintHeavyweightComponentsCallback
  111           extends GraphicsCallback
  112       {
  113           private static PaintHeavyweightComponentsCallback instance =
  114               new PaintHeavyweightComponentsCallback();
  115   
  116           private PaintHeavyweightComponentsCallback() {}
  117           public void run(Component comp, Graphics cg) {
  118               if (comp.peer instanceof LightweightPeer) {
  119                   comp.paintHeavyweightComponents(cg);
  120               } else {
  121                   comp.paintAll(cg);
  122               }
  123           }
  124           static PaintHeavyweightComponentsCallback getInstance() {
  125               return instance;
  126           }
  127       }
  128       static final class PrintHeavyweightComponentsCallback
  129           extends GraphicsCallback
  130       {
  131           private static PrintHeavyweightComponentsCallback instance =
  132               new PrintHeavyweightComponentsCallback();
  133   
  134           private PrintHeavyweightComponentsCallback() {}
  135           public void run(Component comp, Graphics cg) {
  136               if (comp.peer instanceof LightweightPeer) {
  137                   comp.printHeavyweightComponents(cg);
  138               } else {
  139                   comp.printAll(cg);
  140               }
  141           }
  142           static PrintHeavyweightComponentsCallback getInstance() {
  143               return instance;
  144           }
  145       }
  146   }

Home » openjdk-7 » java » awt » [javadoc | source]