MCPcopy Create free account
hub / github.com/GateNLP/gate-core / applyUserPreferences

Method applyUserPreferences

src/main/java/gate/Main.java:259–327  ·  view source on GitHub ↗

Reads the user config data and applies the required settings. This must be called after Gate#init() but before any GUI components are created.

()

Source from the content-addressed store, hash-verified

257 * any GUI components are created.
258 */
259 public static void applyUserPreferences(){
260 //look and feel
261 String lnfClassName;
262 if(System.getProperty("swing.defaultlaf") != null) {
263 lnfClassName = System.getProperty("swing.defaultlaf");
264 } else {
265 lnfClassName = Gate.getUserConfig().
266 getString(GateConstants.LOOK_AND_FEEL);
267 }
268 if(lnfClassName == null){
269 //if running on Linux, default to Metal rather than GTK because GTK LnF
270 //doesn't play nicely with most Gnome themes
271 if(System.getProperty("os.name").toLowerCase().indexOf("linux") != -1){
272 //running on Linux
273 lnfClassName = UIManager.getCrossPlatformLookAndFeelClassName();
274 }else{
275 lnfClassName = UIManager.getSystemLookAndFeelClassName();
276 }
277 }
278 try {
279 UIManager.setLookAndFeel(lnfClassName);
280 } catch(Exception e) {
281 System.err.print("Could not set your preferred Look and Feel. The error was:\n" +
282 e.toString() + "\nReverting to using Java Look and Feel");
283 try {
284 UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
285 }catch(Exception e1) {
286 //we just can't catch a break here. Let's forget about look and feel.
287 System.err.print(
288 "Could not set the cross-platform Look and Feel either. The error was:\n" +
289 e1.toString() + "\nGiving up on Look and Feel.");
290 }
291 }
292 Gate.getUserConfig().put(GateConstants.LOOK_AND_FEEL, lnfClassName);
293
294 //read the user config data
295 OptionsMap userConfig = Gate.getUserConfig();
296
297 //text font
298 Font font = userConfig.getFont(GateConstants.TEXT_COMPONENTS_FONT);
299 if(font == null){
300 font = UIManager.getFont("TextPane.font");
301 }
302
303 if(font != null){
304 OptionsDialog.setTextComponentsFont(font);
305 }
306
307 //menus font
308 font = userConfig.getFont(GateConstants.MENUS_FONT);
309 if(font == null){
310 font = UIManager.getFont("Menu.font");
311 }
312
313 if(font != null){
314 OptionsDialog.setMenuComponentsFont(font);
315 }
316

Callers 1

runMethod · 0.95

Calls 11

getUserConfigMethod · 0.95
getFontMethod · 0.95
setTextComponentsFontMethod · 0.95
setMenuComponentsFontMethod · 0.95
setComponentsFontMethod · 0.95
getPropertyMethod · 0.65
indexOfMethod · 0.65
toStringMethod · 0.65
getStringMethod · 0.45
printMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected