1 /* 2 Part of the Processing project - http://processing.org 3 4 Copyright (c) 2004-09 Ben Fry and Casey Reas 5 Copyright (c) 2001-04 Massachusetts Institute of Technology 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software Foundation, 19 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 */ 21 22 package processing.app; 23 24 import processing.app.helpers.PreferencesMap; 25 26 27 /** 28 * Storage class for user preferences and environment settings. 29 * <p/> 30 * This class no longer uses the Properties class, since 31 * properties files are iso8859-1, which is highly likely to 32 * be a problem when trying to save sketch folders and locations. 33 * <p/> 34 * The GUI portion in here is really ugly, as it uses exact layout. This was 35 * done in frustration one evening (and pre-Swing), but that's long since past, 36 * and it should all be moved to a proper swing layout like BoxLayout. 37 * <p/> 38 * This is very poorly put together, that the preferences panel and the actual 39 * preferences i/o is part of the same code. But there hasn't yet been a 40 * compelling reason to bother with the separation aside from concern about 41 * being lectured by strangers who feel that it doesn't look like what they 42 * learned in CS class. 43 * <p/> 44 * Would also be possible to change this to use the Java Preferences API. 45 * Some useful articles 46 * <a href="http://www.onjava.com/pub/a/onjava/synd/2001/10/17/j2se.html">here</a> and 47 * <a href="http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chapter10/Preferences.html">here</a>. 48 * However, haven't implemented this yet for lack of time, but more 49 * importantly, because it would entail writing to the registry (on Windows), 50 * or an obscure file location (on Mac OS X) and make it far more difficult to 51 * find the preferences to tweak them by hand (no! stay out of regedit!) 52 * or to reset the preferences by simply deleting the preferences.txt file. 53 */ 54 public class Preferences { 55 56 57 /** 58 * Standardized width for buttons. Mac OS X 10.3 wants 70 as its default, 59 * Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper. 60 */ 61 static public int BUTTON_WIDTH = 80; 62 63 /** 64 * Standardized button height. Mac OS X 10.3 (Java 1.4) wants 29, 65 * presumably because it now includes the blue border, where it didn't 66 * in Java 1.3. Windows XP only wants 23 (not sure what default Linux 67 * would be). Because of the disparity, on Mac OS X, it will be set 68 * inside a static block. 69 */ 70 static public int BUTTON_HEIGHT = 24; 71 72 // indents and spacing standards. these probably need to be modified 73 // per platform as well, since macosx is so huge, windows is smaller, 74 // and linux is all over the map 75 76 static final int GUI_SMALL = 6; 77 78 @Deprecated save()79 protected static void save() { 80 PreferencesData.save(); 81 } 82 83 @Deprecated get(String attribute)84 public static String get(String attribute) { 85 return PreferencesData.get(attribute); 86 } 87 88 @Deprecated get(String attribute, String defaultValue)89 public static String get(String attribute, String defaultValue) { 90 return PreferencesData.get(attribute, defaultValue); 91 } 92 93 @Deprecated has(String key)94 public static boolean has(String key) { 95 return PreferencesData.has(key); 96 } 97 98 @Deprecated remove(String key)99 public static void remove(String key) { 100 PreferencesData.remove(key); 101 } 102 103 @Deprecated set(String attribute, String value)104 public static void set(String attribute, String value) { 105 PreferencesData.set(attribute, value); 106 } 107 108 @Deprecated getBoolean(String attribute)109 public static boolean getBoolean(String attribute) { 110 return PreferencesData.getBoolean(attribute); 111 } 112 113 @Deprecated setBoolean(String attribute, boolean value)114 public static void setBoolean(String attribute, boolean value) { 115 PreferencesData.setBoolean(attribute, value); 116 } 117 118 @Deprecated getInteger(String attribute)119 public static int getInteger(String attribute) { 120 return PreferencesData.getInteger(attribute); 121 } 122 123 @Deprecated getInteger(String attribute, int defaultValue)124 public static int getInteger(String attribute, int defaultValue) { 125 return PreferencesData.getInteger(attribute, defaultValue); 126 } 127 128 @Deprecated setInteger(String key, int value)129 public static void setInteger(String key, int value) { 130 PreferencesData.setInteger(key, value); 131 } 132 133 @Deprecated getMap()134 public static PreferencesMap getMap() { 135 return PreferencesData.getMap(); 136 } 137 138 @Deprecated setDoSave(boolean value)139 public static void setDoSave(boolean value) { 140 PreferencesData.setDoSave(value); 141 } 142 143 } 144