home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / awt / GraphicsEnvironment.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  3.4 KB  |  119 lines

  1. /*
  2.  * @(#)GraphicsEnvironment.java    1.19 98/03/18
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15.  
  16. package java.awt;
  17.  
  18. import java.awt.font.TextAttributeSet;
  19. import java.awt.image.BufferedImage;
  20. import java.awt.image.ImagingLib;
  21. import java.awt.print.PrinterJob;
  22. import java.util.Hashtable;
  23.  
  24. /**
  25.  *
  26.  * This class specifies the graphics environment.  The resources in
  27.  * this environment
  28.  * might be local or on a remote machine.  The graphics environment
  29.  * consists of a number of GraphicsDevice objects and Font objects.
  30.  * GraphicsDevice objects are typically screens or printers and are
  31.  * the destination of Graphics2D drawing methods.  Each GraphicsDevice
  32.  * has a number of GraphicsConfiguration objects associated with it.
  33.  * These specify the different configurations in which the GraphicsDevice
  34.  * can be used.  
  35.  *
  36.  * @see GraphicsDevice
  37.  * @see GraphicsConfiguration
  38.  * @version 10 Feb 1997
  39.  */
  40.  
  41. public abstract class GraphicsEnvironment {
  42.     private static GraphicsEnvironment localEnv;
  43.  
  44.     protected GraphicsEnvironment() {
  45.     }
  46.  
  47.     /**
  48.      * Returns the local graphics environment.
  49.      */
  50.     public static GraphicsEnvironment getLocalGraphicsEnvironment() {
  51.     if (localEnv == null) {
  52.         String nm = System.getProperty("java.awt.graphicsenv", null);
  53.  
  54.         try {
  55.         localEnv =
  56.             (GraphicsEnvironment) Class.forName(nm).newInstance();
  57.         } catch (ClassNotFoundException e) {
  58.                 throw new Error("Could not find class: "+nm);
  59.             } catch (InstantiationException e) {
  60.                 throw new Error("Could not instantiate Graphics Environment: "
  61.                 + nm);
  62.             } catch (IllegalAccessException e) {
  63.                 throw new Error ("Could not access Graphics Environment: "
  64.                  + nm);
  65.             }
  66.         }
  67.  
  68.     return localEnv;
  69.     }
  70.  
  71.     /**
  72.      * Returns an array of all of the screen devices.
  73.      */
  74.     public abstract GraphicsDevice[] getScreenDevices();
  75.  
  76.     /**
  77.      * Returns the default screen graphics device.
  78.      */
  79.     public abstract GraphicsDevice getDefaultScreenDevice();
  80.  
  81.     /**
  82.      * Returns a Graphics2D object for rendering into the
  83.      * given BufferedImage.
  84.      */
  85.     public abstract Graphics2D createGraphics(BufferedImage img);
  86.  
  87.     /**
  88.      * Returns a ImagingLib object that can used to process
  89.      * some/all of the imaging ops.  Can be null.
  90.      */
  91.     public abstract ImagingLib getImagingLib();
  92.  
  93.     /**
  94.      * Returns all fonts available in this environment.
  95.      */
  96.     public abstract Font[] getAllFonts();
  97.  
  98.     /**
  99.      * Returns all Fonts available in this environment that match
  100.      * the specified AttributeSet.
  101.      */
  102.      public abstract Font[] getFonts (TextAttributeSet attributes);
  103.  
  104.     /* this is in place of the above function and will eventually merge 
  105.      * using FontFeatureSet mechanism 
  106.      */
  107.     public abstract Font getFont(String fontFaceName);
  108.  
  109.     /**
  110.      * Gets a <code>PrinterJob</code> object suitable for the
  111.      * the current platform.
  112.      * @return    a <code>PrinterJob</code> object.
  113.      * @see       java.awt.PrinterJob
  114.      * @since     JDK1.2
  115.      */
  116.     public abstract PrinterJob getPrinterJob();
  117. }
  118.  
  119.