source: trunk/src/org/expeditee/gui/UserSettings.java@ 78

Last change on this file since 78 was 78, checked in by ra33, 16 years ago

Added @b and @v...
Also changed @f... so that images can be displayed with transparent backgrounds.
Did a bunch of refactoring in the process to remove duplicated code and simplify managing @i, @f and @b.

File size: 3.1 KB
Line 
1package org.expeditee.gui;
2
3import java.io.File;
4import java.net.URL;
5import java.util.LinkedList;
6import java.util.List;
7
8import org.expeditee.items.Item;
9import org.expeditee.items.Text;
10
11/**
12 * Central class to contain all values that can be set by the user on their
13 * profile frame. These values should be updated only by
14 * FrameUtils.ParseProfile.
15 */
16public abstract class UserSettings {
17
18 public static int Gravity = 3;
19
20 public static int LineStraightenThreshold = 15;
21
22 public static int NoOpThreshold = 60;
23
24 public static int TitlePosition = 150;
25
26 public static int InitialWidth = 1024;
27
28 public static int InitialHeight = 768;
29
30 public static String Username;
31
32 public static String DefaultFrame = null;
33
34 public static String MenuFrame = null;
35
36 public static String FirstFrame = null;
37
38 public static List<String> FrameDirs = new LinkedList<String>();
39
40 public static List<String> ImageDirs = new LinkedList<String>();
41
42 public static boolean AntiAlias = false;
43
44 public static boolean LineHighlight = false;
45
46 public static boolean Logging = false;
47
48 public static boolean LogStats = true;
49
50 public static boolean Threading = true;
51
52 public static Text ItemTemplate = new Text(-1, "@ItemTemplate");
53
54 public static Text LineTemplate = new Text(-1, "@LineTemplate");
55
56 public static Text AnnotationTemplate = null;
57
58 public static Text CodeCommentTemplate = null;
59
60 public static Text TitleTemplate = null;
61
62 public static Text StatTemplate = null;
63
64 // add default values
65 public static void Init() {
66 String jarPath = getJarLocation();
67 if (jarPath != null)
68 FrameIO.changeParentFolder(jarPath);
69 else
70 FrameIO.changeParentFolder("." + File.separator + "expeditee"
71 + File.separator);
72
73 UserSettings.FrameDirs.add(FrameIO.FRAME_PATH);
74 UserSettings.FrameDirs.add(FrameIO.PROFILE_PATH);
75 UserSettings.FrameDirs.add(FrameIO.HELP_PATH);
76 UserSettings.ImageDirs.add(FrameIO.IMAGES_PATH);
77 }
78
79 /**
80 * Find where abouts the Jar is located that is running expeditee. The
81 * reason for this was so that the framesets could be stored in the same
82 * location as the jar file for now. Using the current directory fails to
83 * achieve this as the current directory not the same as the directory the
84 * jar is stored in if the user double clicks on the jar file in Linux or
85 * runs the jar from the command line from another directory.
86 *
87 * @return
88 */
89 public static String getJarLocation() {
90 // Get a File object for the package
91 File directory = null;
92
93 ClassLoader cld = Thread.currentThread().getContextClassLoader();
94 URL resource = cld.getResource("org");
95 directory = new File(resource.getFile());
96
97 int splitPoint = directory.getPath().indexOf('!');
98 if (splitPoint > 0) {
99 String jarName = directory.getPath().substring("file:".length(),
100 splitPoint);
101 // Windows HACK
102 if (jarName.indexOf(":") >= 0)
103 jarName = jarName.substring(1);
104
105 if (jarName.indexOf("%20") > 0) {
106 jarName = jarName.replace("%20", " ");
107 }
108
109 int lastFileSeparator = jarName.lastIndexOf(File.separator);
110 return jarName.substring(0, lastFileSeparator + 1);
111 }
112 return null;
113 }
114}
Note: See TracBrowser for help on using the repository browser.