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