67 import sun.font.FontManagerForSGE;
68 import sun.font.NativeFont;
69
70 /**
71 * This is an implementation of a GraphicsEnvironment object for the
72 * default local GraphicsEnvironment.
73 *
74 * @see GraphicsDevice
75 * @see GraphicsConfiguration
76 */
77 public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
78 implements DisplayChangedListener {
79
80 public static boolean isOpenSolaris;
81 private static Font defaultFont;
82
83 public SunGraphicsEnvironment() {
84 java.security.AccessController.doPrivileged(
85 new java.security.PrivilegedAction<Object>() {
86 public Object run() {
87 String version = System.getProperty("os.version", "0.0");
88 try {
89 float ver = Float.parseFloat(version);
90 if (ver > 5.10f) {
91 File f = new File("/etc/release");
92 FileInputStream fis = new FileInputStream(f);
93 InputStreamReader isr
94 = new InputStreamReader(fis, "ISO-8859-1");
95 BufferedReader br = new BufferedReader(isr);
96 String line = br.readLine();
97 if (line.indexOf("OpenSolaris") >= 0) {
98 isOpenSolaris = true;
99 } else {
100 /* We are using isOpenSolaris as meaning
101 * we know the Solaris commercial fonts aren't
102 * present. "Solaris Next" (03/10) did not
103 * include these even though its was not
104 * OpenSolaris. Need to revisit how this is
105 * handled but for now as in 6ux, we'll use
106 * the test for a standard font resource as
107 * being an indicator as to whether we need
108 * to treat this as OpenSolaris from a font
109 * config perspective.
110 */
111 String courierNew =
112 "/usr/openwin/lib/X11/fonts/TrueType/CourierNew.ttf";
113 File courierFile = new File(courierNew);
114 isOpenSolaris = !courierFile.exists();
115 }
116 fis.close();
117 }
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 ret = new GraphicsDevice[num];
139 for (int i = 0; i < num; i++) {
140 ret[i] = makeScreenDevice(i);
|
67 import sun.font.FontManagerForSGE;
68 import sun.font.NativeFont;
69
70 /**
71 * This is an implementation of a GraphicsEnvironment object for the
72 * default local GraphicsEnvironment.
73 *
74 * @see GraphicsDevice
75 * @see GraphicsConfiguration
76 */
77 public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
78 implements DisplayChangedListener {
79
80 public static boolean isOpenSolaris;
81 private static Font defaultFont;
82
83 public SunGraphicsEnvironment() {
84 java.security.AccessController.doPrivileged(
85 new java.security.PrivilegedAction<Object>() {
86 public Object run() {
87 String osName = System.getProperty("os.name");
88 if ("SunOS".equals(osName)) {
89 String version = System.getProperty("os.version", "0.0");
90 try {
91 float ver = Float.parseFloat(version);
92 if (ver > 5.10f) {
93 File f = new File("/etc/release");
94 FileInputStream fis = new FileInputStream(f);
95 InputStreamReader isr
96 = new InputStreamReader(fis, "ISO-8859-1");
97 BufferedReader br = new BufferedReader(isr);
98 String line = br.readLine();
99 if (line.indexOf("OpenSolaris") >= 0) {
100 isOpenSolaris = true;
101 } else {
102 /* We are using isOpenSolaris as meaning
103 * we know the Solaris commercial fonts aren't
104 * present. "Solaris Next" (03/10) did not
105 * include these even though its was not
106 * OpenSolaris. Need to revisit how this is
107 * handled but for now as in 6ux, we'll use
108 * the test for a standard font resource as
109 * being an indicator as to whether we need
110 * to treat this as OpenSolaris from a font
111 * config perspective.
112 */
113 String courierNew =
114 "/usr/openwin/lib/X11/fonts/TrueType/CourierNew.ttf";
115 File courierFile = new File(courierNew);
116 isOpenSolaris = !courierFile.exists();
117 }
118 fis.close();
119 }
120 } catch (Exception e) {
121 }
122 }
123 /* Establish the default font to be used by SG2D etc */
124 defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
125
126 return null;
127 }
128 });
129 }
130
131 protected GraphicsDevice[] screens;
132
133 /**
134 * Returns an array of all of the screen devices.
135 */
136 public synchronized GraphicsDevice[] getScreenDevices() {
137 GraphicsDevice[] ret = screens;
138 if (ret == null) {
139 int num = getNumScreens();
140 ret = new GraphicsDevice[num];
141 for (int i = 0; i < num; i++) {
142 ret[i] = makeScreenDevice(i);
|