1 | package org.expeditee.settings;
|
---|
2 |
|
---|
3 | import java.awt.Color;
|
---|
4 | import java.io.File;
|
---|
5 | import java.util.LinkedList;
|
---|
6 | import java.util.List;
|
---|
7 |
|
---|
8 | import org.expeditee.gui.Frame;
|
---|
9 | import org.expeditee.gui.FrameIO;
|
---|
10 | import org.expeditee.gui.FrameUtils;
|
---|
11 | import org.expeditee.items.Item;
|
---|
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 {
|
---|
20 |
|
---|
21 | public final static String DEFAULT_PROFILE_NAME = "default";
|
---|
22 |
|
---|
23 | public static List<Text> Style = new LinkedList<Text>();;
|
---|
24 |
|
---|
25 | public static int Gravity = 3;
|
---|
26 |
|
---|
27 | public static float ScaleFactor = 1F;
|
---|
28 |
|
---|
29 | public static int LineStraightenThreshold = 15;
|
---|
30 |
|
---|
31 | public static int NoOpThreshold = 60;
|
---|
32 |
|
---|
33 | public static int TitlePosition = 150;
|
---|
34 |
|
---|
35 | public static int InitialWidth = 1024;
|
---|
36 |
|
---|
37 | public static int InitialHeight = 768;
|
---|
38 |
|
---|
39 | public static String ProfileName;
|
---|
40 |
|
---|
41 | public static String UserName;
|
---|
42 |
|
---|
43 | public static String DefaultFrame = null;
|
---|
44 |
|
---|
45 | public static String StatisticsFrameset = null;
|
---|
46 |
|
---|
47 | public static String MenuFrame = null;
|
---|
48 |
|
---|
49 | public static String HomeFrame = null;
|
---|
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 | }
|
---|
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 |
|
---|
78 | public static Text ItemTemplate = new Text("@ItemTemplate");
|
---|
79 |
|
---|
80 | public static Text DotTemplate = new Text("@DotTemplate");
|
---|
81 |
|
---|
82 | public static Text AnnotationTemplate = null;
|
---|
83 |
|
---|
84 | public static Text CodeCommentTemplate = null;
|
---|
85 |
|
---|
86 | public static Text TitleTemplate = null;
|
---|
87 |
|
---|
88 | public static Text StatTemplate = null;
|
---|
89 |
|
---|
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 |
|
---|
102 | // add default values
|
---|
103 | static {
|
---|
104 | String expeditee_home = System.getProperty("expeditee.home");
|
---|
105 | if (expeditee_home != null) {
|
---|
106 | FrameIO.changeParentFolder(expeditee_home + File.separator);
|
---|
107 | } else {
|
---|
108 | FrameIO.changeParentFolder(getSaveLocation());
|
---|
109 | }
|
---|
110 |
|
---|
111 | UserSettings.FrameDirs.add(FrameIO.FRAME_PATH);
|
---|
112 | UserSettings.FrameDirs.add(FrameIO.PUBLIC_PATH);
|
---|
113 | UserSettings.FrameDirs.add(FrameIO.PROFILE_PATH);
|
---|
114 | UserSettings.FrameDirs.add(FrameIO.HELP_PATH);
|
---|
115 | UserSettings.ImageDirs.add(FrameIO.IMAGES_PATH);
|
---|
116 | UserSettings.FrameDirs.add(FrameIO.MESSAGES_PATH);
|
---|
117 | }
|
---|
118 |
|
---|
119 | /**
|
---|
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
|
---|
128 | */
|
---|
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;
|
---|
137 | }
|
---|
138 | }
|
---|
139 | }
|
---|