jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java

Print this page




 148      *
 149      * @return the number of screen devices of this graphics environment
 150      */
 151     protected abstract int getNumScreens();
 152 
 153     /**
 154      * Create and return the screen device with the specified number. The
 155      * device with number <code>0</code> will be the default device (returned
 156      * by {@link #getDefaultScreenDevice()}.
 157      *
 158      * @param screennum the number of the screen to create
 159      *
 160      * @return the created screen device
 161      */
 162     protected abstract GraphicsDevice makeScreenDevice(int screennum);
 163 
 164     /**
 165      * Returns the default screen graphics device.
 166      */
 167     public GraphicsDevice getDefaultScreenDevice() {
 168         return getScreenDevices()[0];

 169     }
 170 
 171     /**
 172      * Returns a Graphics2D object for rendering into the
 173      * given BufferedImage.
 174      * @throws NullPointerException if BufferedImage argument is null
 175      */
 176     public Graphics2D createGraphics(BufferedImage img) {
 177         if (img == null) {
 178             throw new NullPointerException("BufferedImage cannot be null");
 179         }
 180         SurfaceData sd = SurfaceData.getPrimarySurfaceData(img);
 181         return new SunGraphics2D(sd, Color.white, Color.black, defaultFont);
 182     }
 183 
 184     public static FontManagerForSGE getFontManagerForSGE() {
 185         FontManager fm = FontManagerFactory.getInstance();
 186         return (FontManagerForSGE) fm;
 187     }
 188 




 148      *
 149      * @return the number of screen devices of this graphics environment
 150      */
 151     protected abstract int getNumScreens();
 152 
 153     /**
 154      * Create and return the screen device with the specified number. The
 155      * device with number <code>0</code> will be the default device (returned
 156      * by {@link #getDefaultScreenDevice()}.
 157      *
 158      * @param screennum the number of the screen to create
 159      *
 160      * @return the created screen device
 161      */
 162     protected abstract GraphicsDevice makeScreenDevice(int screennum);
 163 
 164     /**
 165      * Returns the default screen graphics device.
 166      */
 167     public GraphicsDevice getDefaultScreenDevice() {
 168         GraphicsDevice[] screens = getScreenDevices();
 169         return screens.length == 0 ? null : screens[0];
 170     }
 171 
 172     /**
 173      * Returns a Graphics2D object for rendering into the
 174      * given BufferedImage.
 175      * @throws NullPointerException if BufferedImage argument is null
 176      */
 177     public Graphics2D createGraphics(BufferedImage img) {
 178         if (img == null) {
 179             throw new NullPointerException("BufferedImage cannot be null");
 180         }
 181         SurfaceData sd = SurfaceData.getPrimarySurfaceData(img);
 182         return new SunGraphics2D(sd, Color.white, Color.black, defaultFont);
 183     }
 184 
 185     public static FontManagerForSGE getFontManagerForSGE() {
 186         FontManager fm = FontManagerFactory.getInstance();
 187         return (FontManagerForSGE) fm;
 188     }
 189