package org.expeditee.settings; import java.awt.Color; import java.io.File; import java.util.LinkedList; import java.util.List; import org.expeditee.gui.Frame; import org.expeditee.gui.FrameIO; import org.expeditee.gui.FrameUtils; import org.expeditee.items.Item; import org.expeditee.items.Text; /** * Central class to contain all values that can be set by the user on their * profile frame. These values should be updated only by * FrameUtils.ParseProfile. */ public abstract class UserSettings { public final static String DEFAULT_PROFILE_NAME = "default"; public static List Style = new LinkedList();; public static int Gravity = 3; public static float ScaleFactor = 1F; public static int LineStraightenThreshold = 15; public static int NoOpThreshold = 60; public static int TitlePosition = 150; public static int InitialWidth = 1024; public static int InitialHeight = 768; public static String ProfileName; public static String UserName; public static String DefaultFrame = null; public static String StatisticsFrameset = null; public static String MenuFrame = null; public static String HomeFrame = null; public static void setHomeFrame(Text t) { String first = FrameUtils.getLink(t, UserSettings.HomeFrame); // do not use non-existant frames as the first frame if (FrameIO.isValidFrameName(first)) { UserSettings.HomeFrame = first; } // warn the user else { // MessageBay.warningMessage("Home frame: " + first // + " is not a valid frame."); UserSettings.HomeFrame = FrameIO.LoadProfile(UserSettings.ProfileName).getName(); } } public static List FrameDirs = new LinkedList(); public static List ImageDirs = new LinkedList(); public static boolean AntiAlias = false; public static boolean LineHighlight = false; public static boolean Logging = false; public static boolean LogStats = true; public static boolean Threading = true; public static Text ItemTemplate = new Text("@ItemTemplate"); public static Text DotTemplate = new Text("@DotTemplate"); public static Text AnnotationTemplate = null; public static Text CodeCommentTemplate = null; public static Text TitleTemplate = null; public static Text StatTemplate = null; public static void setColorWheel(Text t) { Item.COLOR_WHEEL = FrameUtils.getColorWheel(t); } public static void setFillColorWheel(Text t) { Item.FILL_COLOR_WHEEL = FrameUtils.getColorWheel(t); } public static void setBackgroundColorWheel(Text t) { Frame.COLOR_WHEEL = FrameUtils.getColorWheel(t); } // add default values static { String expeditee_home = System.getProperty("expeditee.home"); if (expeditee_home != null) { FrameIO.changeParentFolder(expeditee_home + File.separator); } else { FrameIO.changeParentFolder(getSaveLocation()); } UserSettings.FrameDirs.add(FrameIO.FRAME_PATH); UserSettings.FrameDirs.add(FrameIO.PUBLIC_PATH); UserSettings.FrameDirs.add(FrameIO.PROFILE_PATH); UserSettings.FrameDirs.add(FrameIO.HELP_PATH); UserSettings.ImageDirs.add(FrameIO.IMAGES_PATH); UserSettings.FrameDirs.add(FrameIO.MESSAGES_PATH); } /** * Find the appropriate directory to store application settings in for * the current OS. * This has only been tested on Linux so far, so if it doesn't work it * may need to be modified or reverted. Should return: * Linux: ~/.expeditee * Windows: %appdata%\.expeditee * Mac: ~/Library/Application\ Support/.expeditee * @return the path to store expeditee's settings */ public static String getSaveLocation() { String OS=System.getProperty("os.name").toLowerCase(); if(OS.indexOf("win")>0) { //windoze return System.getenv("APPDATA")+File.separator+".expeditee"+File.separator; } else if(OS.indexOf("mac")>0) { //mac return System.getProperty("user.home")+File.separator+"Library"+File.separator+"Application Support"+File.separator+".expeditee"+File.separator; } else { //linux or other return System.getProperty("user.home")+File.separator+".expeditee"+File.separator; } } }