+ * Loads the configuration of the interface.
+ */
+ private void loadConfig() {
+ /* initialize default stuff. */
+ antialias = false;
+ /* now read config. */
+ File configFile = new File(configDirectory, "swing-interface.properties");
+ if (!configFile.exists() || !configFile.canRead() || !configFile.isFile()) {
+ System.err.println("could not find “" + configFile.getAbsolutePath() + "”!");
+ return;
+ }
+ Properties configProperties = new Properties();
+ FileInputStream configInputStream = null;
+ try {
+ configInputStream = new FileInputStream(configFile);
+ configProperties.load(configInputStream);
+ } catch (IOException ioe1) {
+ System.err.println("could not load config, " + ioe1.getMessage());
+ } finally {
+ Closer.close(configInputStream);
+ }
+ if (configProperties.containsKey("antialias")) {
+ antialias = Boolean.valueOf(configProperties.getProperty("antialias"));
+ }
+ if (configProperties.containsKey("controlFont")) {
+ controlFont = configProperties.getProperty("controlFont");
+ }
+ if (configProperties.containsKey("userFont")) {
+ userFont = configProperties.getProperty("userFont");
+ }
+ }
+
+ /**
+ * Saves the configuration.
+ */
+ private void saveConfig() {
+ File configDirectory = new File(this.configDirectory);
+ if (!configDirectory.exists()) {
+ if (!configDirectory.mkdirs()) {
+ System.err.println("could not create “" + this.configDirectory + "”!");
+ return;
+ }
+ }
+ if (!configDirectory.exists() || !configDirectory.isDirectory() || !configDirectory.canWrite()) {
+ System.err.println("can not access “" + this.configDirectory + "”!");
+ return;
+ }
+ File configFile = new File(configDirectory, "swing-interface.properties");
+ Properties configProperties = new Properties();
+ configProperties.setProperty("antialias", String.valueOf(antialias));
+ if (controlFont != null) {
+ configProperties.setProperty("controlFont", controlFont);
+ }
+ if (userFont != null) {
+ configProperties.setProperty("userFont", userFont);
+ }
+ FileOutputStream configOutputStream = null;
+ try {
+ configOutputStream = new FileOutputStream(configFile);
+ configProperties.store(configOutputStream, "configuration of swing interface");
+ } catch (IOException ioe1) {
+ System.err.println("could not save config, " + ioe1.getMessage());
+ } finally {
+ Closer.close(configOutputStream);
+ }
+ }
+
+ /**