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

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

Added lots of stuff

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