[570] | 1 | package org.expeditee.settings;
|
---|
[4] | 2 |
|
---|
[571] | 3 | import java.awt.Color;
|
---|
[4] | 4 | import java.io.File;
|
---|
| 5 | import java.util.LinkedList;
|
---|
| 6 | import java.util.List;
|
---|
| 7 |
|
---|
[571] | 8 | import org.expeditee.gui.Frame;
|
---|
[570] | 9 | import org.expeditee.gui.FrameIO;
|
---|
[571] | 10 | import org.expeditee.gui.FrameUtils;
|
---|
| 11 | import org.expeditee.items.Item;
|
---|
[4] | 12 | import org.expeditee.items.Text;
|
---|
| 13 |
|
---|
| 14 | /**
|
---|
| 15 | * Central class to contain all values that can be set by the user on their
|
---|
| 16 | * profile frame. These values should be updated only by
|
---|
| 17 | * FrameUtils.ParseProfile.
|
---|
| 18 | */
|
---|
| 19 | public abstract class UserSettings {
|
---|
[348] | 20 |
|
---|
| 21 | public final static String DEFAULT_PROFILE_NAME = "default";
|
---|
[4] | 22 |
|
---|
[309] | 23 | public static List<Text> Style = new LinkedList<Text>();;
|
---|
[289] | 24 |
|
---|
[4] | 25 | public static int Gravity = 3;
|
---|
[289] | 26 |
|
---|
| 27 | public static float ScaleFactor = 1F;
|
---|
[4] | 28 |
|
---|
| 29 | public static int LineStraightenThreshold = 15;
|
---|
| 30 |
|
---|
| 31 | public static int NoOpThreshold = 60;
|
---|
[74] | 32 |
|
---|
| 33 | public static int TitlePosition = 150;
|
---|
[4] | 34 |
|
---|
| 35 | public static int InitialWidth = 1024;
|
---|
| 36 |
|
---|
| 37 | public static int InitialHeight = 768;
|
---|
| 38 |
|
---|
[348] | 39 | public static String ProfileName;
|
---|
| 40 |
|
---|
| 41 | public static String UserName;
|
---|
| 42 |
|
---|
[4] | 43 | public static String DefaultFrame = null;
|
---|
[427] | 44 |
|
---|
| 45 | public static String StatisticsFrameset = null;
|
---|
[4] | 46 |
|
---|
| 47 | public static String MenuFrame = null;
|
---|
| 48 |
|
---|
[309] | 49 | public static String HomeFrame = null;
|
---|
[571] | 50 | public static void setHomeFrame(Text t) {
|
---|
| 51 | String first = FrameUtils.getLink(t, UserSettings.HomeFrame);
|
---|
| 52 | // do not use non-existant frames as the first frame
|
---|
| 53 | if (FrameIO.isValidFrameName(first)) {
|
---|
| 54 | UserSettings.HomeFrame = first;
|
---|
| 55 | }
|
---|
| 56 | // warn the user
|
---|
| 57 | else {
|
---|
| 58 | // MessageBay.warningMessage("Home frame: " + first
|
---|
| 59 | // + " is not a valid frame.");
|
---|
| 60 | UserSettings.HomeFrame = FrameIO.LoadProfile(UserSettings.ProfileName).getName();
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
[4] | 63 |
|
---|
| 64 | public static List<String> FrameDirs = new LinkedList<String>();
|
---|
| 65 |
|
---|
| 66 | public static List<String> ImageDirs = new LinkedList<String>();
|
---|
| 67 |
|
---|
| 68 | public static boolean AntiAlias = false;
|
---|
| 69 |
|
---|
| 70 | public static boolean LineHighlight = false;
|
---|
| 71 |
|
---|
| 72 | public static boolean Logging = false;
|
---|
| 73 |
|
---|
| 74 | public static boolean LogStats = true;
|
---|
| 75 |
|
---|
| 76 | public static boolean Threading = true;
|
---|
| 77 |
|
---|
[108] | 78 | public static Text ItemTemplate = new Text("@ItemTemplate");
|
---|
[70] | 79 |
|
---|
[247] | 80 | public static Text DotTemplate = new Text("@DotTemplate");
|
---|
[4] | 81 |
|
---|
| 82 | public static Text AnnotationTemplate = null;
|
---|
| 83 |
|
---|
| 84 | public static Text CodeCommentTemplate = null;
|
---|
| 85 |
|
---|
| 86 | public static Text TitleTemplate = null;
|
---|
| 87 |
|
---|
[72] | 88 | public static Text StatTemplate = null;
|
---|
[544] | 89 |
|
---|
[571] | 90 | public static void setColorWheel(Text t) {
|
---|
| 91 | Item.COLOR_WHEEL = FrameUtils.getColorWheel(t);
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | public static void setFillColorWheel(Text t) {
|
---|
| 95 | Item.FILL_COLOR_WHEEL = FrameUtils.getColorWheel(t);
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | public static void setBackgroundColorWheel(Text t) {
|
---|
| 99 | Frame.COLOR_WHEEL = FrameUtils.getColorWheel(t);
|
---|
| 100 | }
|
---|
| 101 |
|
---|
[4] | 102 | // add default values
|
---|
[355] | 103 | static {
|
---|
[490] | 104 | String expeditee_home = System.getProperty("expeditee.home");
|
---|
| 105 | if (expeditee_home != null) {
|
---|
[504] | 106 | FrameIO.changeParentFolder(expeditee_home + File.separator);
|
---|
| 107 | } else {
|
---|
| 108 | FrameIO.changeParentFolder(getSaveLocation());
|
---|
| 109 | }
|
---|
| 110 |
|
---|
[4] | 111 | UserSettings.FrameDirs.add(FrameIO.FRAME_PATH);
|
---|
[286] | 112 | UserSettings.FrameDirs.add(FrameIO.PUBLIC_PATH);
|
---|
[4] | 113 | UserSettings.FrameDirs.add(FrameIO.PROFILE_PATH);
|
---|
| 114 | UserSettings.FrameDirs.add(FrameIO.HELP_PATH);
|
---|
| 115 | UserSettings.ImageDirs.add(FrameIO.IMAGES_PATH);
|
---|
[298] | 116 | UserSettings.FrameDirs.add(FrameIO.MESSAGES_PATH);
|
---|
[4] | 117 | }
|
---|
| 118 |
|
---|
| 119 | /**
|
---|
[504] | 120 | * Find the appropriate directory to store application settings in for
|
---|
| 121 | * the current OS.
|
---|
| 122 | * This has only been tested on Linux so far, so if it doesn't work it
|
---|
| 123 | * may need to be modified or reverted. Should return:
|
---|
| 124 | * Linux: ~/.expeditee
|
---|
| 125 | * Windows: %appdata%\.expeditee
|
---|
| 126 | * Mac: ~/Library/Application\ Support/.expeditee
|
---|
| 127 | * @return the path to store expeditee's settings
|
---|
[4] | 128 | */
|
---|
[504] | 129 | public static String getSaveLocation() {
|
---|
| 130 | String OS=System.getProperty("os.name").toLowerCase();
|
---|
| 131 | if(OS.indexOf("win")>0) { //windoze
|
---|
| 132 | return System.getenv("APPDATA")+File.separator+".expeditee"+File.separator;
|
---|
| 133 | } else if(OS.indexOf("mac")>0) { //mac
|
---|
| 134 | return System.getProperty("user.home")+File.separator+"Library"+File.separator+"Application Support"+File.separator+".expeditee"+File.separator;
|
---|
| 135 | } else { //linux or other
|
---|
| 136 | return System.getProperty("user.home")+File.separator+".expeditee"+File.separator;
|
---|
[4] | 137 | }
|
---|
| 138 | }
|
---|
| 139 | }
|
---|