93 String sortedKeys[] = new String[keys.length]; 94 95 for ( int nkey = 0; nkey < keys.length; nkey++ ) { 96 sortedKeys[nkey] = keys[nkey].toString(); 97 } 98 Arrays.sort(sortedKeys); 99 return sortedKeys; 100 } 101 102 /* 103 * Reads Win32 configuration information and 104 * updates hashmap values 105 */ 106 private native void getWindowsParameters(); 107 108 /* 109 * Called from native code to set a boolean property 110 */ 111 private synchronized void setBooleanProperty(String key, boolean value) { 112 assert( key != null ); 113 if (log.isLoggable(PlatformLogger.FINE)) { 114 log.fine(key + "=" + String.valueOf(value)); 115 } 116 map.put(key, Boolean.valueOf(value)); 117 } 118 119 /* 120 * Called from native code to set an integer property 121 */ 122 private synchronized void setIntegerProperty(String key, int value) { 123 assert( key != null ); 124 if (log.isLoggable(PlatformLogger.FINE)) { 125 log.fine(key + "=" + String.valueOf(value)); 126 } 127 map.put(key, Integer.valueOf(value)); 128 } 129 130 /* 131 * Called from native code to set a string property 132 */ 133 private synchronized void setStringProperty(String key, String value) { 134 assert( key != null ); 135 if (log.isLoggable(PlatformLogger.FINE)) { 136 log.fine(key + "=" + value); 137 } 138 map.put(key, value); 139 } 140 141 /* 142 * Called from native code to set a color property 143 */ 144 private synchronized void setColorProperty(String key, int r, int g, int b) { 145 assert( key != null && r <= 255 && g <=255 && b <= 255 ); 146 Color color = new Color(r, g, b); 147 if (log.isLoggable(PlatformLogger.FINE)) { 148 log.fine(key + "=" + color); 149 } 150 map.put(key, color); 151 } 152 153 /* Map of known windows font aliases to the preferred JDK name */ 154 static HashMap<String,String> fontNameMap; 155 static { 156 fontNameMap = new HashMap<String,String>(); 157 fontNameMap.put("Courier", Font.MONOSPACED); 158 fontNameMap.put("MS Serif", "Microsoft Serif"); 159 fontNameMap.put("MS Sans Serif", "Microsoft Sans Serif"); 160 fontNameMap.put("Terminal", Font.DIALOG); 161 fontNameMap.put("FixedSys", Font.MONOSPACED); 162 fontNameMap.put("System", Font.DIALOG); 163 } 164 /* 165 * Called from native code to set a font property 166 */ 167 private synchronized void setFontProperty(String key, String name, int style, int size) { 168 assert( key != null && style <= (Font.BOLD|Font.ITALIC) && size >= 0 ); 169 170 String mappedName = fontNameMap.get(name); 171 if (mappedName != null) { 172 name = mappedName; 173 } 174 Font font = new Font(name, style, size); 175 if (log.isLoggable(PlatformLogger.FINE)) { 176 log.fine(key + "=" + font); 177 } 178 map.put(key, font); 179 180 String sizeKey = key + ".height"; 181 Integer iSize = Integer.valueOf(size); 182 if (log.isLoggable(PlatformLogger.FINE)) { 183 log.fine(sizeKey + "=" + iSize); 184 } 185 map.put(sizeKey, iSize); 186 } 187 188 /* 189 * Called from native code to set a sound event property 190 */ 191 private synchronized void setSoundProperty(String key, String winEventName) { 192 assert( key != null && winEventName != null ); 193 194 Runnable soundRunnable = new WinPlaySound(winEventName); 195 if (log.isLoggable(PlatformLogger.FINE)) { 196 log.fine(key + "=" + soundRunnable); 197 } 198 map.put(key, soundRunnable); 199 } 200 201 /* 202 * Plays Windows sound event 203 */ 204 private native void playWindowsSound(String winEventName); 205 206 class WinPlaySound implements Runnable { 207 String winEventName; 208 209 WinPlaySound(String winEventName) { 210 this.winEventName = winEventName; 211 } 212 213 public void run() { 214 WDesktopProperties.this.playWindowsSound(winEventName); 215 } | 93 String sortedKeys[] = new String[keys.length]; 94 95 for ( int nkey = 0; nkey < keys.length; nkey++ ) { 96 sortedKeys[nkey] = keys[nkey].toString(); 97 } 98 Arrays.sort(sortedKeys); 99 return sortedKeys; 100 } 101 102 /* 103 * Reads Win32 configuration information and 104 * updates hashmap values 105 */ 106 private native void getWindowsParameters(); 107 108 /* 109 * Called from native code to set a boolean property 110 */ 111 private synchronized void setBooleanProperty(String key, boolean value) { 112 assert( key != null ); 113 if (log.isLoggable(PlatformLogger.Level.FINE)) { 114 log.fine(key + "=" + String.valueOf(value)); 115 } 116 map.put(key, Boolean.valueOf(value)); 117 } 118 119 /* 120 * Called from native code to set an integer property 121 */ 122 private synchronized void setIntegerProperty(String key, int value) { 123 assert( key != null ); 124 if (log.isLoggable(PlatformLogger.Level.FINE)) { 125 log.fine(key + "=" + String.valueOf(value)); 126 } 127 map.put(key, Integer.valueOf(value)); 128 } 129 130 /* 131 * Called from native code to set a string property 132 */ 133 private synchronized void setStringProperty(String key, String value) { 134 assert( key != null ); 135 if (log.isLoggable(PlatformLogger.Level.FINE)) { 136 log.fine(key + "=" + value); 137 } 138 map.put(key, value); 139 } 140 141 /* 142 * Called from native code to set a color property 143 */ 144 private synchronized void setColorProperty(String key, int r, int g, int b) { 145 assert( key != null && r <= 255 && g <=255 && b <= 255 ); 146 Color color = new Color(r, g, b); 147 if (log.isLoggable(PlatformLogger.Level.FINE)) { 148 log.fine(key + "=" + color); 149 } 150 map.put(key, color); 151 } 152 153 /* Map of known windows font aliases to the preferred JDK name */ 154 static HashMap<String,String> fontNameMap; 155 static { 156 fontNameMap = new HashMap<String,String>(); 157 fontNameMap.put("Courier", Font.MONOSPACED); 158 fontNameMap.put("MS Serif", "Microsoft Serif"); 159 fontNameMap.put("MS Sans Serif", "Microsoft Sans Serif"); 160 fontNameMap.put("Terminal", Font.DIALOG); 161 fontNameMap.put("FixedSys", Font.MONOSPACED); 162 fontNameMap.put("System", Font.DIALOG); 163 } 164 /* 165 * Called from native code to set a font property 166 */ 167 private synchronized void setFontProperty(String key, String name, int style, int size) { 168 assert( key != null && style <= (Font.BOLD|Font.ITALIC) && size >= 0 ); 169 170 String mappedName = fontNameMap.get(name); 171 if (mappedName != null) { 172 name = mappedName; 173 } 174 Font font = new Font(name, style, size); 175 if (log.isLoggable(PlatformLogger.Level.FINE)) { 176 log.fine(key + "=" + font); 177 } 178 map.put(key, font); 179 180 String sizeKey = key + ".height"; 181 Integer iSize = Integer.valueOf(size); 182 if (log.isLoggable(PlatformLogger.Level.FINE)) { 183 log.fine(sizeKey + "=" + iSize); 184 } 185 map.put(sizeKey, iSize); 186 } 187 188 /* 189 * Called from native code to set a sound event property 190 */ 191 private synchronized void setSoundProperty(String key, String winEventName) { 192 assert( key != null && winEventName != null ); 193 194 Runnable soundRunnable = new WinPlaySound(winEventName); 195 if (log.isLoggable(PlatformLogger.Level.FINE)) { 196 log.fine(key + "=" + soundRunnable); 197 } 198 map.put(key, soundRunnable); 199 } 200 201 /* 202 * Plays Windows sound event 203 */ 204 private native void playWindowsSound(String winEventName); 205 206 class WinPlaySound implements Runnable { 207 String winEventName; 208 209 WinPlaySound(String winEventName) { 210 this.winEventName = winEventName; 211 } 212 213 public void run() { 214 WDesktopProperties.this.playWindowsSound(winEventName); 215 } |