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

Print this page




   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 sun.java2d;
  27 

  28 import java.awt.Color;
  29 import java.awt.Font;
  30 import java.awt.Graphics2D;
  31 import java.awt.GraphicsConfiguration;
  32 import java.awt.GraphicsDevice;
  33 import java.awt.GraphicsEnvironment;
  34 import java.awt.Insets;
  35 import java.awt.Rectangle;
  36 import java.awt.Toolkit;
  37 import java.awt.font.TextAttribute;
  38 import java.awt.image.BufferedImage;
  39 import java.awt.peer.ComponentPeer;
  40 import java.io.BufferedReader;
  41 import java.io.File;
  42 import java.io.FileInputStream;
  43 import java.io.FilenameFilter;
  44 import java.io.InputStreamReader;
  45 import java.io.IOException;
  46 import java.text.AttributedCharacterIterator;
  47 import java.util.ArrayList;


 117                     } catch (Exception e) {
 118                     }
 119 
 120                 /* Establish the default font to be used by SG2D etc */
 121                 defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
 122 
 123                 return null;
 124             }
 125         });
 126     }
 127 
 128     protected GraphicsDevice[] screens;
 129 
 130     /**
 131      * Returns an array of all of the screen devices.
 132      */
 133     public synchronized GraphicsDevice[] getScreenDevices() {
 134         GraphicsDevice[] ret = screens;
 135         if (ret == null) {
 136             int num = getNumScreens();



 137             ret = new GraphicsDevice[num];
 138             for (int i = 0; i < num; i++) {
 139                 ret[i] = makeScreenDevice(i);
 140             }
 141             screens = ret;
 142         }
 143         return ret;
 144     }
 145 
 146     /**
 147      * Returns the number of screen devices of this graphics environment.
 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()}.




   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 sun.java2d;
  27 
  28 import java.awt.AWTError;
  29 import java.awt.Color;
  30 import java.awt.Font;
  31 import java.awt.Graphics2D;
  32 import java.awt.GraphicsConfiguration;
  33 import java.awt.GraphicsDevice;
  34 import java.awt.GraphicsEnvironment;
  35 import java.awt.Insets;
  36 import java.awt.Rectangle;
  37 import java.awt.Toolkit;
  38 import java.awt.font.TextAttribute;
  39 import java.awt.image.BufferedImage;
  40 import java.awt.peer.ComponentPeer;
  41 import java.io.BufferedReader;
  42 import java.io.File;
  43 import java.io.FileInputStream;
  44 import java.io.FilenameFilter;
  45 import java.io.InputStreamReader;
  46 import java.io.IOException;
  47 import java.text.AttributedCharacterIterator;
  48 import java.util.ArrayList;


 118                     } catch (Exception e) {
 119                     }
 120 
 121                 /* Establish the default font to be used by SG2D etc */
 122                 defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
 123 
 124                 return null;
 125             }
 126         });
 127     }
 128 
 129     protected GraphicsDevice[] screens;
 130 
 131     /**
 132      * Returns an array of all of the screen devices.
 133      */
 134     public synchronized GraphicsDevice[] getScreenDevices() {
 135         GraphicsDevice[] ret = screens;
 136         if (ret == null) {
 137             int num = getNumScreens();
 138             if (num == 0) {
 139                 throw new AWTError("no screen devices");
 140             }
 141             ret = new GraphicsDevice[num];
 142             for (int i = 0; i < num; i++) {
 143                 ret[i] = makeScreenDevice(i);
 144             }
 145             screens = ret;
 146         }
 147         return ret;
 148     }
 149 
 150     /**
 151      * Returns the number of screen devices of this graphics environment.
 152      *
 153      * @return the number of screen devices of this graphics environment
 154      */
 155     protected abstract int getNumScreens();
 156 
 157     /**
 158      * Create and return the screen device with the specified number. The
 159      * device with number <code>0</code> will be the default device (returned
 160      * by {@link #getDefaultScreenDevice()}.