>
+{
+
+ /**
+ *
+ */
+ public ClassRegistry()
+ {
+ super();
+
+ }
+
+ public U lookupInstance(String key)
+ {
+ return getInstance(this.get(key));
+ }
+
+ /**
+ * Get a DocumentType from a generic parameterized Class object.
+ *
+ * @param thatClass
+ * @return
+ */
+ public U getInstance(Class extends U> thatClass)
+ {
+ U result = null;
+ if (thatClass != null)
+ {
+ try
+ {
+ result = thatClass.newInstance();
+ } catch (InstantiationException e)
+ {
+ e.printStackTrace();
+ } catch (IllegalAccessException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return result;
+ }
+
+
+}
diff --git a/simplCore/src/ecologylab/appframework/Environment.java b/simplCore/src/ecologylab/appframework/Environment.java
index 2978c7c8..0e3a93b2 100644
--- a/simplCore/src/ecologylab/appframework/Environment.java
+++ b/simplCore/src/ecologylab/appframework/Environment.java
@@ -1,389 +1,389 @@
-/*
- * Copyright 1996-2002 by Andruid Kerne. All rights reserved. CONFIDENTIAL. Use is subject to
- * license terms.
- */
-package ecologylab.appframework;
-
-import ecologylab.appframework.types.prefs.Pref;
-import ecologylab.collections.Scope;
-import ecologylab.generic.ConsoleUtils;
-import ecologylab.generic.Debug;
-import ecologylab.generic.StringTools;
-import ecologylab.net.ParsedURL;
-
-/**
- * Provides a mechanism for passing parameters/preferences/properties from diverse runtime
- * environments, including applets (via the param tag), applications (via a properties file), and
- * sooner or later, servlets.
- *
- *
- * Cooperative programming: Any class that implements this interface needs to include the
- * following line of code at the top of its initialization, in order to make the services provided
- * by this Environment interface globally accessible.
- *
- *
- * Environment.the.set(this);
- *
- *
- *
- *
- * The nested class The serves to keep a global reference to the actual instance of the
- * singleton class that implements Environment. (Don't have more than 1 instance that does!)
- *
- * The raison d'etre of this interface is first to allow programs to utilize services in a
- * uniform way, whether they are applets or applications. The raison d'etre of the nested
- * class is to overcome the existence of a single java.applet.Applet instance in the
- * runtime environment which provides services that conceptually, one expects to get from a static,
- * like java.lang.System. This is a simple mechanism that actually does something quite
- * complex, and for complex reasons.
- *
- *
- * Services are then available globally through syntax such as:
- *
- *
- * Environment.the.get().parameter("bgcolor");
- *
- *
- *
- */
-public interface Environment
-{
- /**
- * Holds a reference to the singleton global instance of {@link Environment Environment}, and
- * simple methods for getting and setting this reference.
- */
- public class The extends Debug
- {
- Environment environment;
-
- /**
- * Holds preferences for use in servicing parameter(String) requests.
- */
- private final Scope preferencesRegistry = new Scope();
-
- float javaVersion = 1.1f; // minimum expected
-
- boolean javaIsBeta;
-
- boolean javaIsRC;
-
- boolean hasXML;
-
- boolean hasServlet;
-
- boolean checkedForServlet;
-
- boolean hasQuicktime;
-
- boolean checkedForQuicktime;
-
- boolean hasGL;
-
- boolean checkedForGL;
-
- boolean hasAgile2D;
-
- boolean checkedForAgile2D;
-
- boolean checkedForMultivalent;
-
- boolean hasMultivalent;
-
- boolean checkedForPDFBox;
-
- boolean hasPDFBox;
-
- boolean checkedForJTidy;
-
- boolean hasJTidy;
-
- String frame;
-
- public The()
- {
- String sysJavaVersion = System.getProperty("java.version");
- String floatableJavaVersion = StringTools.remove(sysJavaVersion, '_');
-
- int firstDot = floatableJavaVersion.indexOf('.');
- int lastDot = floatableJavaVersion.lastIndexOf('.');
- if (firstDot != lastDot)
- {
- String toFirstDot = floatableJavaVersion.substring(0, firstDot + 1);
- String afterFirstDot = floatableJavaVersion.substring(firstDot + 1);
- afterFirstDot = StringTools.remove(afterFirstDot, '.');
- floatableJavaVersion = toFirstDot + afterFirstDot;
- }
- int dashBeta = floatableJavaVersion.indexOf("-beta");
- int dashRC = floatableJavaVersion.indexOf("-rc");
-
- if (dashBeta != -1)
- {
- floatableJavaVersion = floatableJavaVersion.substring(0, dashBeta);
- javaIsBeta = true;
- }
- else if (dashRC != -1)
- {
- floatableJavaVersion = floatableJavaVersion.substring(0, dashRC);
- javaIsRC = true;
- }
- try
- {
- javaVersion = Float.parseFloat(floatableJavaVersion);
- }
- catch (NumberFormatException e)
- {
- debug("PROBLEM parsing javaVersion = " + floatableJavaVersion);
- e.printStackTrace();
- }
- // debug("javaVersion="+ sysJavaVersion+" -> "+ javaVersion);
-
- if (javaVersion >= 1.4f)
- hasXML = true;
- else
- hasXML = checkFor("org.w3c.dom.Node");
-
- // debug("javaVersion=" + javaVersion+" hasXML="+hasXML);
- }
-
- public The(Environment e)
- {
- set(e);
- }
-
- public void set(Environment e)
- {
- environment = e;
- }
-
- public Environment get()
- {
- return environment;
- }
-
- /**
- * @return The version of Java we're using.
- */
- public float javaVersion()
- {
- return javaVersion;
- }
-
- /**
- * Check to see if we're running on what we consider to be a decent, usable version of Java. For
- * 1.5, this means rel 4 or more; for 1.4, it means 1.42_04 or more.
- *
- * @return true if the Java we're running on is good; false if its crap.
- */
- public boolean hasGoodJava()
- {
- float javaVersion = javaVersion();
- // return (javaVersion >= 1.5004) || ((javaVersion < 1.5) && (javaVersion >= 1.4204));
- // accomodate the retarded scc
- return (javaVersion >= 1.5);
- }
-
- public boolean javaIsBeta()
- {
- return javaIsBeta;
- }
-
- public boolean javaIsReleaseCandidate()
- {
- return javaIsRC;
- }
-
- public boolean hasQuicktime()
- {
- if (!checkedForQuicktime)
- {
- checkedForQuicktime = true;
- hasQuicktime = checkFor("quicktime.std.movies.Movie");
- }
- return hasQuicktime;
- }
-
- public boolean hasAgile2D()
- {
- if (!checkedForAgile2D)
- {
- checkedForAgile2D = true;
- hasAgile2D = checkFor("agile2D.AgileJFrame");
- }
- return hasAgile2D;
- }
-
- public boolean hasMultivalent()
- {
- if (!checkedForMultivalent)
- {
- checkedForMultivalent = true;
- hasMultivalent = checkFor("multivalent.std.adaptor.pdf.PDFReader");
- debug("hasMultivalent() = " + hasMultivalent);
- if (hasMultivalent)
- ConsoleUtils.obtrusiveConsoleOutput("Multivalent Found");
- }
- return hasMultivalent;
- }
-
- public boolean hasPDFBox()
- {
- if (!checkedForPDFBox)
- {
- checkedForPDFBox = true;
- hasPDFBox = checkFor("org.pdfbox.pdmodel.PDDocument");
- debug("hasPDFBox() = " + hasPDFBox);
- if (hasPDFBox)
- ConsoleUtils.obtrusiveConsoleOutput("PDFBox Found");
- }
- return hasPDFBox;
- }
-
- public boolean hasJTidy()
- {
- if (!checkedForJTidy)
- {
- checkedForJTidy = true;
- hasJTidy = checkFor("org.w3c.tidy.TdNode");
- debug("hasJTidy() = " + hasJTidy);
- if (hasJTidy)
- ConsoleUtils.obtrusiveConsoleOutput("JTidy Found");
- }
- return hasJTidy;
- }
-
- public boolean hasGL()
- {
- if (!checkedForGL)
- {
- checkedForGL = true;
- hasGL = checkFor("gl4java.awt.GLCanvas");
- }
- return hasGL;
- }
-
- public boolean hasXML()
- {
- return hasXML;
- }
-
- public boolean hasServlet()
- {
- if (!checkedForServlet)
- {
- checkedForServlet = true;
- hasServlet = checkFor("javax.servlet.http.HttpServlet");
- }
- return hasServlet;
- }
-
- public static boolean checkFor(String className)
- {
- boolean result = false;
- try
- {
- Class.forName(className);
- result = true;
- }
- catch (ClassNotFoundException e)
- {
- println("Environment.checkFor(" + className + ") caught exception " + e);
- // e.printStackTrace();
- }
- catch (Error e)
- {
- println("Environment.checkFor(" + className + ") caught error");
- e.printStackTrace();
- }
- return result;
- }
-
- public String frame()
- {
- String result = frame;
- if (result == null)
- {
- result = Pref.lookupString("frame");
- frame = result;
- }
- return frame;
- }
-
- /**
- * The registry of Preferences for this Environment.
- *
- * @return registry of Preferences for this Environment.
- */
- public Scope preferencesRegistry()
- {
- return preferencesRegistry;
- }
-
- };
-
- /**
- * Each running entity (be it an applet or an application), should have one and only one instance
- * of an Environment. "the" is that singleton instance.
- */
- static final The the = new The();
-
- /**
- * Find out which java runtime we're operating in.
- */
- int runtimeEnv();
-
- /**
- * Find out which browser we're running in.
- */
- int browser();
-
- /**
- * Show msg in the browser's status bar.
- *
- * Short form, with for (@link java.cm.applet.Applet#showStatus). Also more robust: avoids
- * breaking when msg is null.
- */
- public void status(String msg);
-
- /**
- *
- * Change type from URL to ParsedURL.
- */
- ParsedURL codeBase();
-
- /**
- *
- * Change type from URL to ParsedURL.
- */
- ParsedURL docBase();
-
- /**
- * Called at the end of an invocation.
- *
- * @param code
- * -- 0 for normal. other values are application specific.
- */
- void exit(int code);
-
- public static final int APPLICATION = -1;
-
- public static final int IE = 0;
-
- public static final int NS = 1;
-
- public static final int PLUGIN = 2;
-
- /**
- * Open a document in a web browser.
- *
- * @param purl
- * The address of the web document.
- *
- * @param frame
- * Frame to open it in within the web page. This may or may not be used.
- */
- public void navigate(ParsedURL purl, String frame);
-
- public String getApplicationName();
-
- public boolean hasFirefox();
-}
+/*
+ * Copyright 1996-2002 by Andruid Kerne. All rights reserved. CONFIDENTIAL. Use is subject to
+ * license terms.
+ */
+package ecologylab.appframework;
+
+import ecologylab.appframework.types.prefs.Pref;
+import ecologylab.collections.Scope;
+import ecologylab.generic.ConsoleUtils;
+import ecologylab.generic.Debug;
+import ecologylab.generic.StringTools;
+import ecologylab.net.ParsedURL;
+
+/**
+ * Provides a mechanism for passing parameters/preferences/properties from diverse runtime
+ * environments, including applets (via the param tag), applications (via a properties file), and
+ * sooner or later, servlets.
+ *
+ *
+ * Cooperative programming: Any class that implements this interface needs to include the
+ * following line of code at the top of its initialization, in order to make the services provided
+ * by this Environment interface globally accessible.
+ *
+ *
+ * Environment.the.set(this);
+ *
+ *
+ *
+ *
+ * The nested class The serves to keep a global reference to the actual instance of the
+ * singleton class that implements Environment. (Don't have more than 1 instance that does!)
+ *
+ * The raison d'etre of this interface is first to allow programs to utilize services in a
+ * uniform way, whether they are applets or applications. The raison d'etre of the nested
+ * class is to overcome the existence of a single java.applet.Applet instance in the
+ * runtime environment which provides services that conceptually, one expects to get from a static,
+ * like java.lang.System. This is a simple mechanism that actually does something quite
+ * complex, and for complex reasons.
+ *
+ *
+ * Services are then available globally through syntax such as:
+ *
+ *
+ * Environment.the.get().parameter("bgcolor");
+ *
+ *
+ *
+ */
+public interface Environment
+{
+ /**
+ * Holds a reference to the singleton global instance of {@link Environment Environment}, and
+ * simple methods for getting and setting this reference.
+ */
+ public class The extends Debug
+ {
+ Environment environment;
+
+ /**
+ * Holds preferences for use in servicing parameter(String) requests.
+ */
+ private final Scope preferencesRegistry = new Scope();
+
+ float javaVersion = 1.1f; // minimum expected
+
+ boolean javaIsBeta;
+
+ boolean javaIsRC;
+
+ boolean hasXML;
+
+ boolean hasServlet;
+
+ boolean checkedForServlet;
+
+ boolean hasQuicktime;
+
+ boolean checkedForQuicktime;
+
+ boolean hasGL;
+
+ boolean checkedForGL;
+
+ boolean hasAgile2D;
+
+ boolean checkedForAgile2D;
+
+ boolean checkedForMultivalent;
+
+ boolean hasMultivalent;
+
+ boolean checkedForPDFBox;
+
+ boolean hasPDFBox;
+
+ boolean checkedForJTidy;
+
+ boolean hasJTidy;
+
+ String frame;
+
+ public The()
+ {
+ String sysJavaVersion = System.getProperty("java.version");
+ String floatableJavaVersion = StringTools.remove(sysJavaVersion, '_');
+
+ int firstDot = floatableJavaVersion.indexOf('.');
+ int lastDot = floatableJavaVersion.lastIndexOf('.');
+ if (firstDot != lastDot)
+ {
+ String toFirstDot = floatableJavaVersion.substring(0, firstDot + 1);
+ String afterFirstDot = floatableJavaVersion.substring(firstDot + 1);
+ afterFirstDot = StringTools.remove(afterFirstDot, '.');
+ floatableJavaVersion = toFirstDot + afterFirstDot;
+ }
+ int dashBeta = floatableJavaVersion.indexOf("-beta");
+ int dashRC = floatableJavaVersion.indexOf("-rc");
+
+ if (dashBeta != -1)
+ {
+ floatableJavaVersion = floatableJavaVersion.substring(0, dashBeta);
+ javaIsBeta = true;
+ }
+ else if (dashRC != -1)
+ {
+ floatableJavaVersion = floatableJavaVersion.substring(0, dashRC);
+ javaIsRC = true;
+ }
+ try
+ {
+ javaVersion = Float.parseFloat(floatableJavaVersion);
+ }
+ catch (NumberFormatException e)
+ {
+ debug("PROBLEM parsing javaVersion = " + floatableJavaVersion);
+ e.printStackTrace();
+ }
+ // debug("javaVersion="+ sysJavaVersion+" -> "+ javaVersion);
+
+ if (javaVersion >= 1.4f)
+ hasXML = true;
+ else
+ hasXML = checkFor("org.w3c.dom.Node");
+
+ // debug("javaVersion=" + javaVersion+" hasXML="+hasXML);
+ }
+
+ public The(Environment e)
+ {
+ set(e);
+ }
+
+ public void set(Environment e)
+ {
+ environment = e;
+ }
+
+ public Environment get()
+ {
+ return environment;
+ }
+
+ /**
+ * @return The version of Java we're using.
+ */
+ public float javaVersion()
+ {
+ return javaVersion;
+ }
+
+ /**
+ * Check to see if we're running on what we consider to be a decent, usable version of Java. For
+ * 1.5, this means rel 4 or more; for 1.4, it means 1.42_04 or more.
+ *
+ * @return true if the Java we're running on is good; false if its crap.
+ */
+ public boolean hasGoodJava()
+ {
+ float javaVersion = javaVersion();
+ // return (javaVersion >= 1.5004) || ((javaVersion < 1.5) && (javaVersion >= 1.4204));
+ // accomodate the retarded scc
+ return (javaVersion >= 1.5);
+ }
+
+ public boolean javaIsBeta()
+ {
+ return javaIsBeta;
+ }
+
+ public boolean javaIsReleaseCandidate()
+ {
+ return javaIsRC;
+ }
+
+ public boolean hasQuicktime()
+ {
+ if (!checkedForQuicktime)
+ {
+ checkedForQuicktime = true;
+ hasQuicktime = checkFor("quicktime.std.movies.Movie");
+ }
+ return hasQuicktime;
+ }
+
+ public boolean hasAgile2D()
+ {
+ if (!checkedForAgile2D)
+ {
+ checkedForAgile2D = true;
+ hasAgile2D = checkFor("agile2D.AgileJFrame");
+ }
+ return hasAgile2D;
+ }
+
+ public boolean hasMultivalent()
+ {
+ if (!checkedForMultivalent)
+ {
+ checkedForMultivalent = true;
+ hasMultivalent = checkFor("multivalent.std.adaptor.pdf.PDFReader");
+ debug("hasMultivalent() = " + hasMultivalent);
+ if (hasMultivalent)
+ ConsoleUtils.obtrusiveConsoleOutput("Multivalent Found");
+ }
+ return hasMultivalent;
+ }
+
+ public boolean hasPDFBox()
+ {
+ if (!checkedForPDFBox)
+ {
+ checkedForPDFBox = true;
+ hasPDFBox = checkFor("org.pdfbox.pdmodel.PDDocument");
+ debug("hasPDFBox() = " + hasPDFBox);
+ if (hasPDFBox)
+ ConsoleUtils.obtrusiveConsoleOutput("PDFBox Found");
+ }
+ return hasPDFBox;
+ }
+
+ public boolean hasJTidy()
+ {
+ if (!checkedForJTidy)
+ {
+ checkedForJTidy = true;
+ hasJTidy = checkFor("org.w3c.tidy.TdNode");
+ debug("hasJTidy() = " + hasJTidy);
+ if (hasJTidy)
+ ConsoleUtils.obtrusiveConsoleOutput("JTidy Found");
+ }
+ return hasJTidy;
+ }
+
+ public boolean hasGL()
+ {
+ if (!checkedForGL)
+ {
+ checkedForGL = true;
+ hasGL = checkFor("gl4java.awt.GLCanvas");
+ }
+ return hasGL;
+ }
+
+ public boolean hasXML()
+ {
+ return hasXML;
+ }
+
+ public boolean hasServlet()
+ {
+ if (!checkedForServlet)
+ {
+ checkedForServlet = true;
+ hasServlet = checkFor("javax.servlet.http.HttpServlet");
+ }
+ return hasServlet;
+ }
+
+ public static boolean checkFor(String className)
+ {
+ boolean result = false;
+ try
+ {
+ Class.forName(className);
+ result = true;
+ }
+ catch (ClassNotFoundException e)
+ {
+ println("Environment.checkFor(" + className + ") caught exception " + e);
+ // e.printStackTrace();
+ }
+ catch (Error e)
+ {
+ println("Environment.checkFor(" + className + ") caught error");
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ public String frame()
+ {
+ String result = frame;
+ if (result == null)
+ {
+ result = Pref.lookupString("frame");
+ frame = result;
+ }
+ return frame;
+ }
+
+ /**
+ * The registry of Preferences for this Environment.
+ *
+ * @return registry of Preferences for this Environment.
+ */
+ public Scope preferencesRegistry()
+ {
+ return preferencesRegistry;
+ }
+
+ };
+
+ /**
+ * Each running entity (be it an applet or an application), should have one and only one instance
+ * of an Environment. "the" is that singleton instance.
+ */
+ static final The the = new The();
+
+ /**
+ * Find out which java runtime we're operating in.
+ */
+ int runtimeEnv();
+
+ /**
+ * Find out which browser we're running in.
+ */
+ int browser();
+
+ /**
+ * Show msg in the browser's status bar.
+ *
+ * Short form, with for (@link java.cm.applet.Applet#showStatus). Also more robust: avoids
+ * breaking when msg is null.
+ */
+ public void status(String msg);
+
+ /**
+ *
+ * Change type from URL to ParsedURL.
+ */
+ ParsedURL codeBase();
+
+ /**
+ *
+ * Change type from URL to ParsedURL.
+ */
+ ParsedURL docBase();
+
+ /**
+ * Called at the end of an invocation.
+ *
+ * @param code
+ * -- 0 for normal. other values are application specific.
+ */
+ void exit(int code);
+
+ public static final int APPLICATION = -1;
+
+ public static final int IE = 0;
+
+ public static final int NS = 1;
+
+ public static final int PLUGIN = 2;
+
+ /**
+ * Open a document in a web browser.
+ *
+ * @param purl
+ * The address of the web document.
+ *
+ * @param frame
+ * Frame to open it in within the web page. This may or may not be used.
+ */
+ public void navigate(ParsedURL purl, String frame);
+
+ public String getApplicationName();
+
+ public boolean hasFirefox();
+}
diff --git a/simplCore/src/ecologylab/appframework/MacOSAppHandler.java b/simplCore/src/ecologylab/appframework/MacOSAppHandler.java
index 017229fe..71cc1bdc 100644
--- a/simplCore/src/ecologylab/appframework/MacOSAppHandler.java
+++ b/simplCore/src/ecologylab/appframework/MacOSAppHandler.java
@@ -1,27 +1,27 @@
-/**
- *
- */
-package ecologylab.appframework;
-
-/**
- * Interface for handling Mac OS X application specific events (those related to the application menu found only on Mac OS X).
- *
- * @author andrew
- *
- */
-public interface MacOSAppHandler
-{
- public void handleAbout();
-
- public void handleOpenApplication();
-
- public void handleOpenFile(String filename);
-
- public void handlePreferences();
-
- public void handlePrintFile(String filename);
-
- public void handleQuit();
-
- public void handleReOpenApplication();
-}
+/**
+ *
+ */
+package ecologylab.appframework;
+
+/**
+ * Interface for handling Mac OS X application specific events (those related to the application menu found only on Mac OS X).
+ *
+ * @author andrew
+ *
+ */
+public interface MacOSAppHandler
+{
+ public void handleAbout();
+
+ public void handleOpenApplication();
+
+ public void handleOpenFile(String filename);
+
+ public void handlePreferences();
+
+ public void handlePrintFile(String filename);
+
+ public void handleQuit();
+
+ public void handleReOpenApplication();
+}
diff --git a/simplCore/src/ecologylab/appframework/Memory.java b/simplCore/src/ecologylab/appframework/Memory.java
index 500902c1..02584aff 100644
--- a/simplCore/src/ecologylab/appframework/Memory.java
+++ b/simplCore/src/ecologylab/appframework/Memory.java
@@ -1,192 +1,192 @@
-/*
- * Copyright 1996-2002 by Andruid Kerne. All rights reserved. CONFIDENTIAL. Use is subject to
- * license terms.
- */
-package ecologylab.appframework;
-
-import ecologylab.generic.Debug;
-import ecologylab.generic.StringTools;
-
-/**
- * Utility routines related to memory management, used to watch the JVM's consumption of memory, and
- * to kick the garbage collector into action.
- */
-public class Memory
-{
- // private static final int KICK_GC_COUNT = 5;
- private static final int KICK_GC_COUNT = 3;
-
- /**
- * Less than this many bytes of memory free means danger, baby. Currently set at 32M for PC and 0M for ANDROID
- */
-
- public static final int DANGER_THRESHOLD = (PropertiesAndDirectories.os() == PropertiesAndDirectories.ANDROID) ? 0
- : 32 * 1024 * 1024;
-
- public static final int RECLAIM_THRESHOLD = 2 * DANGER_THRESHOLD;
-
- static final Runtime RUNTIME = Runtime.getRuntime();
-
- /**
- * Number of times we've called gc().
- */
- public static int gcCount;
-
- public static boolean isMicroshaftVM;
-
- static long gcTimeStamp;
-
- static StringBuffer buffy = new StringBuffer(256);
-
- static final int GC_MAX_DELTA_T = 30 * 1000; // 30 seconds
-
- /**
- * Prod the garbage collector, and print a message about memory status.
- */
- public static void reclaim()
- {
- reclaim("");
- }
-
- /**
- * Prod the garbage collector, and print a message about memory status.
- *
- * @param s
- * Part of the message to be printed, to identify call site.
- */
- public static synchronized void reclaim(String s)
- {
- try
- {
- StringTools.clear(buffy);
- buffy.append("\nMemory.reclaim(").append(Thread.currentThread().getName()).append(s)
- .append("):\n\t").append(getFreeMemoryInK());
- reclaimQuiet();
- buffy.append(" -> ").append(usage()).append("\t #").append(gcCount).append("\n");
- Debug.println(buffy);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- public static synchronized void reclaimQuiet()
- {
- gcTimeStamp = System.currentTimeMillis();
- System.gc();
- gcCount++;
- }
-
- private static final Object MEMORY_RECLAIM_LOCK = new Object();
-
- /**
- * Try to reclaim memory if it seems to be in low supply. Kicks the garbage collector, perhaps
- * repeatedly. Does this even though GC is supposed to be automatic.
- *
- * Also maintains the current time stamp to the one in which the garbage collector was last
- * kicked. To avoid maxing out the CPU calling GC repeatedly, will not kick GC again if the last
- * time was recent. (Currently, recent means within the last 30 seconds.)
- *
- * @return true if memory status is in danger and more agressive measures are called for. false if
- * everything is fine, and the caller can proceed to perform operations that use lots of
- * memory, as needed.
- *
- */
- public static boolean reclaimIfLow()
- {
- synchronized (MEMORY_RECLAIM_LOCK)
- {
- // this lock pushes memory check (and the expensive reclaim part) into one thread at a time.
-
- long now = System.currentTimeMillis();
- long deltaT = now - gcTimeStamp;
- if (deltaT >= GC_MAX_DELTA_T)
- {
- for (int i = 0; i != KICK_GC_COUNT; i++)
- {
- if (RUNTIME.freeMemory() < RECLAIM_THRESHOLD)
- reclaim();
- else
- break;
- }
- }
- }
- return RUNTIME.freeMemory() < DANGER_THRESHOLD;
- }
-
- public static void recover(Throwable throwable, String msg)
- {
- Memory.reclaimQuiet();
- Debug.println("Memory.recover()");
- if (msg != null)
- Memory.reclaim(msg);
- throwable.printStackTrace();
- // Thread.dumpStack();
- Debug.println(Memory.threads());
- Debug.println("");
- }
-
- public static String usage()
- {
- return getFreeMemoryInK() + " free of " + K(RUNTIME.totalMemory());
- }
-
- public static String K(long numBytes)
- {
- return (numBytes / 1024) + "K";
- }
-
- public static String threads()
- {
- Thread current = Thread.currentThread();
- int count = Thread.activeCount();
- Thread[] threads = new Thread[count];
- Thread.enumerate(threads);
- String result = count + " Threads ACTIVE\n";
- for (int i = 0; i != count; i++)
- {
- Thread t = threads[i];
- if (t != null)
- {
- // String alive = t.isAlive() ? "alive" : "dead";
- result += threads[i].getName() + "\n";
- }
- }
- return result;
- }
-
- static int outOfMemoryCount;
-
- static boolean processingOutOfMemory;
-
- static final int ENOUGH_OUT_OF_MEMORY_CALLS = 10;
-
- /**
- * @return true if its time to give up!
- */
- public static boolean outOfMemory(Throwable throwable)
- {
- if (outOfMemoryCount >= ENOUGH_OUT_OF_MEMORY_CALLS)
- return true;
-
- if (!processingOutOfMemory)
- { // dont bother locking, cause we're too desparate
- processingOutOfMemory = true;
- outOfMemoryCount++;
- Memory.recover(throwable, null);
- processingOutOfMemory = false;
- }
- return false;
- }
-
- public static long getFreeMemoryInBytes()
- {
- return RUNTIME.freeMemory();
- }
-
- public static String getFreeMemoryInK()
- {
- return K(getFreeMemoryInBytes());
- }
-}
+/*
+ * Copyright 1996-2002 by Andruid Kerne. All rights reserved. CONFIDENTIAL. Use is subject to
+ * license terms.
+ */
+package ecologylab.appframework;
+
+import ecologylab.generic.Debug;
+import ecologylab.generic.StringTools;
+
+/**
+ * Utility routines related to memory management, used to watch the JVM's consumption of memory, and
+ * to kick the garbage collector into action.
+ */
+public class Memory
+{
+ // private static final int KICK_GC_COUNT = 5;
+ private static final int KICK_GC_COUNT = 3;
+
+ /**
+ * Less than this many bytes of memory free means danger, baby. Currently set at 32M for PC and 0M for ANDROID
+ */
+
+ public static final int DANGER_THRESHOLD = (PropertiesAndDirectories.os() == PropertiesAndDirectories.ANDROID) ? 0
+ : 32 * 1024 * 1024;
+
+ public static final int RECLAIM_THRESHOLD = 2 * DANGER_THRESHOLD;
+
+ static final Runtime RUNTIME = Runtime.getRuntime();
+
+ /**
+ * Number of times we've called gc().
+ */
+ public static int gcCount;
+
+ public static boolean isMicroshaftVM;
+
+ static long gcTimeStamp;
+
+ static StringBuffer buffy = new StringBuffer(256);
+
+ static final int GC_MAX_DELTA_T = 30 * 1000; // 30 seconds
+
+ /**
+ * Prod the garbage collector, and print a message about memory status.
+ */
+ public static void reclaim()
+ {
+ reclaim("");
+ }
+
+ /**
+ * Prod the garbage collector, and print a message about memory status.
+ *
+ * @param s
+ * Part of the message to be printed, to identify call site.
+ */
+ public static synchronized void reclaim(String s)
+ {
+ try
+ {
+ StringTools.clear(buffy);
+ buffy.append("\nMemory.reclaim(").append(Thread.currentThread().getName()).append(s)
+ .append("):\n\t").append(getFreeMemoryInK());
+ reclaimQuiet();
+ buffy.append(" -> ").append(usage()).append("\t #").append(gcCount).append("\n");
+ Debug.println(buffy);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public static synchronized void reclaimQuiet()
+ {
+ gcTimeStamp = System.currentTimeMillis();
+ System.gc();
+ gcCount++;
+ }
+
+ private static final Object MEMORY_RECLAIM_LOCK = new Object();
+
+ /**
+ * Try to reclaim memory if it seems to be in low supply. Kicks the garbage collector, perhaps
+ * repeatedly. Does this even though GC is supposed to be automatic.
+ *
+ * Also maintains the current time stamp to the one in which the garbage collector was last
+ * kicked. To avoid maxing out the CPU calling GC repeatedly, will not kick GC again if the last
+ * time was recent. (Currently, recent means within the last 30 seconds.)
+ *
+ * @return true if memory status is in danger and more agressive measures are called for. false if
+ * everything is fine, and the caller can proceed to perform operations that use lots of
+ * memory, as needed.
+ *
+ */
+ public static boolean reclaimIfLow()
+ {
+ synchronized (MEMORY_RECLAIM_LOCK)
+ {
+ // this lock pushes memory check (and the expensive reclaim part) into one thread at a time.
+
+ long now = System.currentTimeMillis();
+ long deltaT = now - gcTimeStamp;
+ if (deltaT >= GC_MAX_DELTA_T)
+ {
+ for (int i = 0; i != KICK_GC_COUNT; i++)
+ {
+ if (RUNTIME.freeMemory() < RECLAIM_THRESHOLD)
+ reclaim();
+ else
+ break;
+ }
+ }
+ }
+ return RUNTIME.freeMemory() < DANGER_THRESHOLD;
+ }
+
+ public static void recover(Throwable throwable, String msg)
+ {
+ Memory.reclaimQuiet();
+ Debug.println("Memory.recover()");
+ if (msg != null)
+ Memory.reclaim(msg);
+ throwable.printStackTrace();
+ // Thread.dumpStack();
+ Debug.println(Memory.threads());
+ Debug.println("");
+ }
+
+ public static String usage()
+ {
+ return getFreeMemoryInK() + " free of " + K(RUNTIME.totalMemory());
+ }
+
+ public static String K(long numBytes)
+ {
+ return (numBytes / 1024) + "K";
+ }
+
+ public static String threads()
+ {
+ Thread current = Thread.currentThread();
+ int count = Thread.activeCount();
+ Thread[] threads = new Thread[count];
+ Thread.enumerate(threads);
+ String result = count + " Threads ACTIVE\n";
+ for (int i = 0; i != count; i++)
+ {
+ Thread t = threads[i];
+ if (t != null)
+ {
+ // String alive = t.isAlive() ? "alive" : "dead";
+ result += threads[i].getName() + "\n";
+ }
+ }
+ return result;
+ }
+
+ static int outOfMemoryCount;
+
+ static boolean processingOutOfMemory;
+
+ static final int ENOUGH_OUT_OF_MEMORY_CALLS = 10;
+
+ /**
+ * @return true if its time to give up!
+ */
+ public static boolean outOfMemory(Throwable throwable)
+ {
+ if (outOfMemoryCount >= ENOUGH_OUT_OF_MEMORY_CALLS)
+ return true;
+
+ if (!processingOutOfMemory)
+ { // dont bother locking, cause we're too desparate
+ processingOutOfMemory = true;
+ outOfMemoryCount++;
+ Memory.recover(throwable, null);
+ processingOutOfMemory = false;
+ }
+ return false;
+ }
+
+ public static long getFreeMemoryInBytes()
+ {
+ return RUNTIME.freeMemory();
+ }
+
+ public static String getFreeMemoryInK()
+ {
+ return K(getFreeMemoryInBytes());
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/OutOfMemoryErrorHandler.java b/simplCore/src/ecologylab/appframework/OutOfMemoryErrorHandler.java
index a4fd6022..42d5d38c 100644
--- a/simplCore/src/ecologylab/appframework/OutOfMemoryErrorHandler.java
+++ b/simplCore/src/ecologylab/appframework/OutOfMemoryErrorHandler.java
@@ -1,77 +1,77 @@
-package ecologylab.appframework;
-
-import java.util.ArrayList;
-
-import ecologylab.collections.Scope;
-import ecologylab.generic.ConsoleUtils;
-import ecologylab.generic.Debug;
-import ecologylab.generic.ExceptionHandler;
-
-
-/**
- * Handle running out of memory. Basically, inform the user, ask if they wish
- * to save, then exit combinformation.
- *
- */
-public class OutOfMemoryErrorHandler
-extends Debug
-{
- private static ArrayList handlers = new ArrayList();
- private static Scope objectRegistry;
-
- private static boolean previouslyRanOut = false;
-
- /**
- * The OutOfMemoryError memory threshold (in bytes) that means we should shut down
- */
- private static final long OUT_OF_MEMORY_THRESHOLD = 4000000;
-
- private OutOfMemoryErrorHandler() {}
-
- public static void registerObjectRegistry(Scope oRegistry)
- {
- objectRegistry = oRegistry;
- }
-
- /**
- * Register an ExceptionHandler for callback when an exception
- * is thrown
- * @param exceptionHandler The ExceptionHandler to add.
- */
- public static void registerHandler(ExceptionHandler exceptionHandler)
- {
- handlers.add(exceptionHandler);
- }
-
- /**
- * Call to register that an exception has ocurred. Results in all
- * registered handlers being notified.
- * @param e
- */
- public static void handleException(OutOfMemoryError e)
- {
- //in case we get here prematurely
- if (Memory.getFreeMemoryInBytes() > OUT_OF_MEMORY_THRESHOLD)
- {
- ConsoleUtils.obtrusiveConsoleOutput("OutOfMemoryErrorHandler BYPASSED PREMATURE MEMORY ERROR");
- e.printStackTrace();
- return;
- }
-
- //ConsoleUtils.obtrusiveConsoleOutput("Free Memory: " + currentFreeMemory + " bytes");
- //ConsoleUtils.obtrusiveConsoleOutput("Memory Threshold: " + OUT_OF_MEMORY_THRESHOLD + " bytes");
-
- //don't bother synchronizing because we're probably hosed and can't do it.
- if (previouslyRanOut) //we already handled it
- return;
- previouslyRanOut = true;
-
- Debug.println("Calling OUT OF MEMORY Handlers cause: ");
- e.printStackTrace();
- for (int i=0; i handlers = new ArrayList();
+ private static Scope objectRegistry;
+
+ private static boolean previouslyRanOut = false;
+
+ /**
+ * The OutOfMemoryError memory threshold (in bytes) that means we should shut down
+ */
+ private static final long OUT_OF_MEMORY_THRESHOLD = 4000000;
+
+ private OutOfMemoryErrorHandler() {}
+
+ public static void registerObjectRegistry(Scope oRegistry)
+ {
+ objectRegistry = oRegistry;
+ }
+
+ /**
+ * Register an ExceptionHandler for callback when an exception
+ * is thrown
+ * @param exceptionHandler The ExceptionHandler to add.
+ */
+ public static void registerHandler(ExceptionHandler exceptionHandler)
+ {
+ handlers.add(exceptionHandler);
+ }
+
+ /**
+ * Call to register that an exception has ocurred. Results in all
+ * registered handlers being notified.
+ * @param e
+ */
+ public static void handleException(OutOfMemoryError e)
+ {
+ //in case we get here prematurely
+ if (Memory.getFreeMemoryInBytes() > OUT_OF_MEMORY_THRESHOLD)
+ {
+ ConsoleUtils.obtrusiveConsoleOutput("OutOfMemoryErrorHandler BYPASSED PREMATURE MEMORY ERROR");
+ e.printStackTrace();
+ return;
+ }
+
+ //ConsoleUtils.obtrusiveConsoleOutput("Free Memory: " + currentFreeMemory + " bytes");
+ //ConsoleUtils.obtrusiveConsoleOutput("Memory Threshold: " + OUT_OF_MEMORY_THRESHOLD + " bytes");
+
+ //don't bother synchronizing because we're probably hosed and can't do it.
+ if (previouslyRanOut) //we already handled it
+ return;
+ previouslyRanOut = true;
+
+ Debug.println("Calling OUT OF MEMORY Handlers cause: ");
+ e.printStackTrace();
+ for (int i=0; i extends Debug
-implements DownloadProcessor
-{
- /**
- *
- */
- public SimpleDownloadProcessor()
- {
- super();
- }
-
- /*
- * A no-op to conform to the interface spec. We have no threads to stop :-)
- */
- @Override
- public void stop()
- {
- }
-
- /**
- * Download it now, in this thread.
- *
- * @param downloadable
- * The thing to download.
- * @param dispatchTarget
- * Ignored, since we are not asynchronous, there are no callbacks.
- */
- // TODO improve error handling here
- @Override
- public void download(T downloadable, Continuation continuation)
- {
- try
- {
- downloadable.performDownload();
- }
- catch (IOException e)
- {
- e.printStackTrace();
- downloadable.handleIoError(e);
- }
- finally
- {
- if (continuation != null)
- continuation.callback(downloadable);
- }
- }
-
- @Override
- public void requestStop()
- {
- // TODO Auto-generated method stub
-
- }
-
-}
+/**
+ *
+ */
+package ecologylab.appframework;
+
+import java.io.IOException;
+
+import ecologylab.concurrent.Downloadable;
+import ecologylab.generic.Continuation;
+import ecologylab.generic.Debug;
+import ecologylab.io.DownloadProcessor;
+
+/**
+ * A simple download processor: just download the Downloadable immediately.
+ *
+ * @author andruid
+ */
+public class SimpleDownloadProcessor extends Debug
+implements DownloadProcessor
+{
+ /**
+ *
+ */
+ public SimpleDownloadProcessor()
+ {
+ super();
+ }
+
+ /*
+ * A no-op to conform to the interface spec. We have no threads to stop :-)
+ */
+ @Override
+ public void stop()
+ {
+ }
+
+ /**
+ * Download it now, in this thread.
+ *
+ * @param downloadable
+ * The thing to download.
+ * @param dispatchTarget
+ * Ignored, since we are not asynchronous, there are no callbacks.
+ */
+ // TODO improve error handling here
+ @Override
+ public void download(T downloadable, Continuation continuation)
+ {
+ try
+ {
+ downloadable.performDownload();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ downloadable.handleIoError(e);
+ }
+ finally
+ {
+ if (continuation != null)
+ continuation.callback(downloadable);
+ }
+ }
+
+ @Override
+ public void requestStop()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/simplCore/src/ecologylab/appframework/SingletonApplicationEnvironment.java b/simplCore/src/ecologylab/appframework/SingletonApplicationEnvironment.java
index 0fcd6f59..2472775d 100644
--- a/simplCore/src/ecologylab/appframework/SingletonApplicationEnvironment.java
+++ b/simplCore/src/ecologylab/appframework/SingletonApplicationEnvironment.java
@@ -1,1234 +1,1234 @@
-package ecologylab.appframework;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLDecoder;
-import java.util.Stack;
-
-import ecologylab.appframework.types.prefs.MetaPrefSet;
-import ecologylab.appframework.types.prefs.MetaPrefsTranslationScope;
-import ecologylab.appframework.types.prefs.Pref;
-import ecologylab.appframework.types.prefs.PrefSet;
-import ecologylab.collections.Scope;
-import ecologylab.generic.Debug;
-import ecologylab.io.Assets;
-import ecologylab.io.AssetsRoot;
-import ecologylab.io.Files;
-import ecologylab.net.ParsedURL;
-import ecologylab.platformspecifics.FundamentalPlatformSpecifics;
-import ecologylab.serialization.ClassDescriptor;
-import ecologylab.serialization.SIMPLTranslationException;
-import ecologylab.serialization.SimplTypesScope;
-import ecologylab.serialization.XMLTranslationExceptionTypes;
-import ecologylab.serialization.formatenums.StringFormat;
-
-/**
- * An instance of Environment, which is an application, rather than an applet, or a servlet. The
- * Environment mechanism is used to enable the provision of contextual runtime configuration
- * parameter services in a way that is independent of the deployment structure.
- *
- * The SingletonApplicationEnvironment differs from ApplicationEnvironment in that it sets the
- * static Environment.the (among other static references). It CANNOT be used in a situation where
- * multiple ApplicationEnvironments will operate in the same JVM. It does, however, simplify the use
- * of Prefs and other statically accessed application components.
- *
- * @author Andruid
- * @author Zachary O. Toups (zach@ecologylab.net)
- */
-public class SingletonApplicationEnvironment extends ApplicationEnvironment implements Environment,
- XMLTranslationExceptionTypes, ApplicationPropertyNames
-{
- public static final String SCREEN_SIZE = "screen_size";
-
- private static final String METAPREFS_XML = "metaprefs.xml";
-
- private static boolean inUse = false;
-
- /** Set of MetaPrefs that describe preferences and provide default values. */
- MetaPrefSet metaPrefSet;
-
- // must initialize this before subsequent lookup by scope name.
- static final SimplTypesScope META_PREFS_TRANSLATION_SCOPE = MetaPrefsTranslationScope.get();
-
- public static enum WindowSize
- {
- PASS_PARAMS, QUARTER_SCREEN, ALMOST_HALF, NEAR_FULL, FULL_SCREEN
- }
-
- public static final String TOP_LEVEL_HEIGHT = "topheight";
- public static final String TOP_LEVEL_WIDTH = "topwidth";
-
- static boolean firefoxExists = false;
-
- /**
- * Create an ApplicationEnvironment. Create an empty properties object for application parameters.
- *
- * No command line argument is processed. Only default preferences are loaded, and processed with
- * the default TranslationSpace.
- *
- * @param args
- * The args array, which is treated as a stack with optional entries. They are: *) JNLP
- * -- if that is the launch method *) preferences file if you are running in eclipse.
- * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
- * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
- * @throws SIMPLTranslationException
- */
- public SingletonApplicationEnvironment(String applicationName) throws SIMPLTranslationException
- {
- this(null, applicationName, null);
- }
-
- /**
- * Create an ApplicationEnvironment. Load preferences from XML file founds in the
- * config/preferences directory. Default preferences will be loaded from preferences.xml. If there
- * is a 0th command line argument, that is the name of an additional preferences file.
- *
- * @param applicationName
- * @param translationScope
- * TranslationSpace used for translating preferences XML. If this is null,
- * {@link ecologylab.oodss.messages.DefaultServicesTranslations
- * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
- * @param args
- * The args array, which is treated as a stack with optional entries. They are: *) JNLP
- * -- if that is the launch method *) preferences file if you are running in eclipse.
- * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
- * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
- * @param prefsAssetVersion
- * TODO
- * @throws SIMPLTranslationException
- */
- public SingletonApplicationEnvironment( String applicationName,
- SimplTypesScope translationScope,
- String args[],
- float prefsAssetVersion) throws SIMPLTranslationException
- {
- this(applicationName, translationScope, (SimplTypesScope) null, args, prefsAssetVersion);
- }
-
- /**
- * Create an ApplicationEnvironment. Load preferences from XML file founds in the
- * config/preferences directory. Default preferences will be loaded from preferences.xml. If there
- * is a 0th command line argument, that is the name of an additional preferences file.
- *
- * @param applicationName
- * @param translationScope
- * TranslationSpace used for translating preferences XML. If this is null,
- * {@link ecologylab.oodss.messages.DefaultServicesTranslations
- * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
- * @param customPrefs
- * TODO
- * @param args
- * The args array, which is treated as a stack with optional entries. They are: *) JNLP
- * -- if that is the launch method *) preferences file if you are running in eclipse.
- * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
- * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
- * @param prefsAssetVersion
- * TODO
- * @throws SIMPLTranslationException
- */
- public SingletonApplicationEnvironment( String applicationName,
- SimplTypesScope translationScope,
- Class extends Pref>>[] customPrefs,
- String args[],
- float prefsAssetVersion) throws SIMPLTranslationException
- {
- this(applicationName, (Scope>) null, translationScope, customPrefs, args, prefsAssetVersion);
- }
-
- /**
- *
- * @param applicationName
- * @param translationScope
- * TranslationSpace used for translating preferences XML. If this is null,
- * {@link ecologylab.oodss.messages.DefaultServicesTranslations
- * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
- * @param sessionScope
- * @param customPrefs
- * @param args
- * The args array, which is treated as a stack with optional entries. They are: *) JNLP
- * -- if that is the launch method *) preferences file if you are running in eclipse.
- * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
- * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
- * @param prefsAssetVersion
- * @throws SIMPLTranslationException
- */
- public SingletonApplicationEnvironment( String applicationName,
- Scope> sessionScope,
- SimplTypesScope translationScope,
- Class extends Pref>>[] customPrefs,
- String args[],
- float prefsAssetVersion) throws SIMPLTranslationException
- {
- this( (Class>) null,
- applicationName,
- sessionScope,
- translationScope,
- prefsClassArrayToTranslationScope(customPrefs),
- args,
- prefsAssetVersion);
- }
-
- /**
- * Create an ApplicationEnvironment. Load preferences from XML file founds in the
- * config/preferences directory. Default preferences will be loaded from preferences.xml. If there
- * is a 0th command line argument, that is the name of an additional preferences file.
- *
- * @param applicationName
- * @param translationScope
- * TranslationSpace used for translating preferences XML. If this is null,
- * {@link ecologylab.oodss.messages.DefaultServicesTranslations
- * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
- * @param customPrefsTranslationScope
- * TODO
- * @param args
- * The args array, which is treated as a stack with optional entries. They are: *) JNLP
- * -- if that is the launch method *) preferences file if you are running in eclipse.
- * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
- * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
- * @param prefsAssetVersion
- * TODO
- * @throws SIMPLTranslationException
- */
- public SingletonApplicationEnvironment( String applicationName,
- SimplTypesScope translationScope,
- SimplTypesScope customPrefsTranslationScope,
- String args[],
- float prefsAssetVersion) throws SIMPLTranslationException
- {
- this( (Class>) null,
- applicationName,
- (Scope>) null,
- translationScope,
- customPrefsTranslationScope,
- args,
- prefsAssetVersion);
- }
-
- /**
- * Create an ApplicationEnvironment. Load preferences from XML files found in the
- * config/preferences directory. Default preferences will be loaded from preferences.xml. If there
- * is a 0th command line argument, that is the name of an additional preferences file.
- *
- * The default TranslationSpace, from
- * {@link ecologylab.oodss.messages.DefaultServicesTranslations
- * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
- *
- * @param applicationName
- * {@link ecologylab.oodss.messages.DefaultServicesTranslations
- * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
- * @param args
- * The args array, which is treated as a stack with optional entries. They are: *) JNLP
- * -- if that is the launch method *) preferences file if you are running in eclipse.
- * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
- * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
- * @throws SIMPLTranslationException
- */
- public SingletonApplicationEnvironment(String applicationName, String args[])
- throws SIMPLTranslationException
- {
- this(applicationName, (SimplTypesScope) null, (SimplTypesScope) null, args, 0);
- }
-
- /**
- * Create an ApplicationEnvironment. Get the base for finding the path to the "codeBase" by using
- * the package path of the baseClass passed in.
- *
- * Load preferences from XML file founds in the codeBase/config/preferences directory. Default
- * preferences will be loaded from preferences.xml. If there is a 0th command line argument, that
- * is the name of an additional preferences file.
- *
- * Also, sets the Assets cacheRoot to the applicationDir().
- *
- * The default TranslationSpace, from
- * {@link ecologylab.oodss.messages.DefaultServicesTranslations
- * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
- *
- * @param baseClass
- * Used for computing codeBase property.
- * @param applicationName
- * @param args
- * The args array, which is treated as a stack with optional entries. They are: *) JNLP
- * -- if that is the launch method *) preferences file if you are running in eclipse.
- * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
- * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full
- * @throws SIMPLTranslationException
- */
- public SingletonApplicationEnvironment(Class> baseClass, String applicationName, String args[])
- throws SIMPLTranslationException
- {
- this(baseClass, applicationName, null, null, null, args, 0);
- }
-
- /**
- * Additional constructor to hold the session scope for post processing loaded preferences.
- *
- * @param applicationName
- * @param sessionScope
- */
- public SingletonApplicationEnvironment( Class> baseClass,
- String applicationName,
- SimplTypesScope translationScope,
- String args[],
- float prefsAssetVersion) throws SIMPLTranslationException
- {
- this(baseClass, applicationName, null, translationScope, null, args, prefsAssetVersion);
- }
-
- /**
- * Create an ApplicationEnvironment.
- *
- * Treats the args array like a stack. If any args are missing (based on their format), they are
- * skipped.
- *
- * The first arg we seek is codeBase. This is a path that ends in slash. It may be a local
- * relative path, or a URL-based absolute path.
- *
- * The next possible arg is a preferences file. This ends with .xml.
- *
- * The next 2 possible args are integers, for graphicsDev and screenSize. graphics_device (screen
- * number) to display window. count from 0. screenSize used in TopLevel -- 1 - quarter; 2 - almost
- * half; 3; near full; 4 full
- *
- * Get the base for finding the path to the "codeBase" by using the package path of the baseClass
- * passed in.
- *
- * Load preferences from XML file founds in the codeBase/config/preferences directory. Default
- * preferences will be loaded from preferences.xml. If there is a 0th command line argument, that
- * is the name of an additional preferences file.
- *
- * Also, sets the Assets cacheRoot to the applicationDir().
- *
- * The default TranslationSpace, from
- * {@link ecologylab.oodss.messages.DefaultServicesTranslations
- * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
- *
- * @param baseClass
- * Used for computing codeBase property.
- * @param applicationName
- * Name of the application.
- * @param translationScope
- * TranslationSpace used for translating preferences XML. If this is null,
- * {@link ecologylab.oodss.messages.DefaultServicesTranslations
- * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
- * @param args
- * The args array, which is treated as a stack with optional entries. They are: *) JNLP
- * -- if that is the launch method *) preferences file if you are running in eclipse.
- * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
- * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
- * @param prefsAssetVersion
- * TODO
- * @throws SIMPLTranslationException
- */
- public SingletonApplicationEnvironment( Class> baseClass,
- String applicationName,
- Scope sessionScope,
- SimplTypesScope translationScope,
- String args[],
- float prefsAssetVersion) throws SIMPLTranslationException
- {
- this(baseClass, applicationName, sessionScope, translationScope, null, args, prefsAssetVersion);
- }
-
- /**
- * Create an ApplicationEnvironment.
- *
- * Treats the args array like a stack. If any args are missing (based on their format), they are
- * skipped.
- *
- * The first arg we seek is codeBase. This is a path that ends in slash. It may be a local
- * relative path, or a URL-based absolute path.
- *
- * The next possible arg is a preferences file. This ends with .xml.
- *
- * The next 2 possible args are integers, for graphicsDev and screenSize. graphics_device (screen
- * number) to display window. count from 0. screenSize used in TopLevel -- 1 - quarter; 2 - almost
- * half; 3; near full; 4 full
- *
- * Get the base for finding the path to the "codeBase" by using the package path of the baseClass
- * passed in.
- *
- * Load preferences from XML file founds in the codeBase/config/preferences directory. Default
- * preferences will be loaded from preferences.xml. If there is a 0th command line argument, that
- * is the name of an additional preferences file.
- *
- * Also, sets the Assets cacheRoot to the applicationDir().
- *
- * The default TranslationSpace, from
- * {@link ecologylab.oodss.messages.DefaultServicesTranslations
- * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
- *
- * @param baseClass
- * Used for computing codeBase property.
- * @param applicationName
- * Name of the application.
- * @param translationScope
- * TranslationSpace used for translating preferences XML. If this is null,
- * {@link ecologylab.oodss.messages.DefaultServicesTranslations
- * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
- * @param customPrefs
- * An array of Pref subclasses that are used for this specific application. These classes
- * will be automatically composed into a special translation scope used for translating
- * prefs for the application. Note that translationScope is NOT used for translating the
- * application prefs, but is still required for other translations in the application.
- * @param args
- * The args array, which is treated as a stack with optional entries. They are: *) JNLP
- * -- if that is the launch method *) preferences file if you are running in eclipse.
- * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
- * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
- * @param prefsAssetVersion
- * TODO
- * @throws SIMPLTranslationException
- */
- public SingletonApplicationEnvironment( Class> baseClass,
- String applicationName,
- Scope> sessionScope,
- SimplTypesScope translationScope,
- SimplTypesScope customPrefsTranslationScope,
- String args[],
- float prefsAssetVersion) throws SIMPLTranslationException
- {
- super(baseClass,
- applicationName,
- sessionScope,
- translationScope,
- customPrefsTranslationScope,
- args,
- prefsAssetVersion);
-
- inUse = true;
-
- // this is the one and only singleton Environment
- Environment.the.set(this);
-
- PropertiesAndDirectories.setApplicationName(applicationName);
- }
-
- /**
- * Sets the applicationName for PropertiesAndDirectories.
- *
- * @see ecologylab.appframework.ApplicationEnvironment#setApplicationName(java.lang.String)
- */
- @Override
- protected void setApplicationName(String applicationName)
- {
- super.setApplicationName(applicationName);
-
- PropertiesAndDirectories.setApplicationName(applicationName);
- }
-
- @Override
- protected void processArgsAndPrefs(Class> baseClass, SimplTypesScope translationScope,
- float prefsAssetVersion) throws SIMPLTranslationException
- {
- String arg;
- processPrefs(baseClass, translationScope, argStack, prefsAssetVersion);
-
- Debug.initialize();
-
- arg = pop(argStack);
- if (arg == null)
- return;
- try
- {
- int screenNum = Integer.parseInt(arg);
- Pref.useAndSetPrefInt("graphics_device", screenNum);
-
- }
- catch (NumberFormatException e)
- {
- argStack.push(arg);
- }
- try
- {
- arg = pop(argStack);
- if (arg == null)
- return;
- Pref.useAndSetPrefInt(SCREEN_SIZE, WindowSize.valueOf(arg.toUpperCase()).ordinal());
- }
- catch (IllegalArgumentException e)
- {
- argStack.push(arg);
- }
- if (Pref.lookupInt(SCREEN_SIZE) == 0)
- {
- try
- {
- arg = pop(argStack);
- if (arg == null)
- return;
- Pref.useAndSetPrefInt(TOP_LEVEL_WIDTH, Integer.parseInt(arg));
-
- arg = pop(argStack);
- if (arg == null)
- return;
- Pref.useAndSetPrefInt(TOP_LEVEL_HEIGHT, Integer.parseInt(arg));
- }
- catch (IllegalArgumentException e)
- {
- argStack.push(arg);
- }
- }
- }
-
- /**
- * request User's prefSet from the preferenceServlet and return the prefSetXML string.
- *
- * @author eunyee
- * @param prefServlet
- * @param translationScope
- * TODO
- * @param uid
- * @return
- */
- @Override
- protected PrefSet requestPrefFromServlet(String prefServlet, SimplTypesScope translationScope)
- {
- System.out.println("retrieving preferences set from servlet: " + prefServlet);
- /*
- * try { ParsedURL purl = new ParsedURL(new URL(prefServlet));
- *
- * PrefSet prefSet = (PrefSet) ElementState.translateFromXML(purl, PrefTranslations.get());
- * return prefSet; } catch (MalformedURLException e1) { // TODO Auto-generated catch block
- * e1.printStackTrace(); } catch (XmlTranslationException e) { // TODO Auto-generated catch
- * block e.printStackTrace(); } return null;
- */
- try
- {
- URL url = new URL(prefServlet);
- URLConnection connection = url.openConnection();
-
- // specify the content type that binary data is sent
- connection.setRequestProperty("Content-Type", "text/xml");
-
- // define a new BufferedReader on the input stream
- BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
-
- // receive data from the servlet
- String prefSetXML = in.readLine();
- PrefSet prfs = null;
- try
- {
- prfs = PrefSet.loadFromCharSequence(prefSetXML, translationScope);
- System.out.println("Prefs loaded From Servlet:: ");
- if (prfs != null)
- SimplTypesScope.serialize(prfs, System.out, StringFormat.XML);
-
- System.out.println(" --- End Prefs");
- }
- catch (SIMPLTranslationException e)
- {
- e.printStackTrace();
- }
- in.close();
-
- return prfs;
- }
- catch (IOException e)
- {
- warning("not a servlet URL: " + prefServlet);
- }
- return null;
- }
-
- /**
- * Load MetaPrefs and Prefs, if possible
- *
- * @param baseClass
- * @param translationScope
- * @param argStack
- * @param prefsAssetVersion
- * TODO
- * @throws SIMPLTranslationException
- */
- private void processPrefs(Class> baseClass, SimplTypesScope translationScope,
- Stack argStack, float prefsAssetVersion) throws SIMPLTranslationException
- {
- LaunchType launchType = LaunchType.ECLIPSE; // current default
-
- // look for launch method identifier in upper case
- String arg = pop(argStack);
-
- if (arg != null)
- {
- String uc = arg.toUpperCase();
- if ("JNLP".equals(uc))
- { // tells us how we were launched: e.g., JNLP, ECLIPSE, ...
- launchType = LaunchType.JNLP;
- }
- else if ("STUDIES".equals(uc))
- {
- launchType = LaunchType.STUDIES;
- }
- else
- {
- // TODO -- recognize JAR here !!!
- argStack.push(arg);
- }
- LAUNCH_TYPE_PREF.setValue(launchType);
- }
- println("LaunchType = " + launchType);
- this.launchType = launchType;
- // look for codeBase path
- arg = pop(argStack);
-
- // read perhaps meta-preferences and surely preferences from application data dir
- File applicationDir = PropertiesAndDirectories.thisApplicationDir();
-
- ParsedURL applicationDataPURL = new ParsedURL(applicationDir);
- prefsPURL = applicationDataPURL.getRelative("preferences/prefs.xml");
- debugA("prefsPURL= " + prefsPURL);
-
- System.out.println("arg: " + arg);
-
- switch (launchType)
- {
- case STUDIES:
- case JNLP:
- // next arg *should* be code base
- if ((arg != null) && arg.endsWith("/"))
- {
- // JNLP only! (as of now)
- // right now this only works for http://
- ParsedURL codeBase = ParsedURL.getAbsolute(arg, "Setting up codebase");
- this.setCodeBase(codeBase);
-
- // XXX is this right?
- final String host = codeBase.host();
- if ("localhost".equals(host) || "127.0.0.1".equals(host))
- {
- debug("launched from localhost. must be a developer.");
- LAUNCH_TYPE_PREF.setValue(LaunchType.LOCAL_JNLP);
- }
-
- SIMPLTranslationException metaPrefSetException = null;
- ParsedURL metaPrefsPURL = null;
- try
- {
- AssetsRoot prefAssetsRoot = new AssetsRoot(this, PREFERENCES, null);
- File metaPrefsFile = Assets.getAsset( prefAssetsRoot,
- METAPREFS_XML,
- "prefs",
- null,
- false,
- prefsAssetVersion);
- metaPrefsPURL = new ParsedURL(metaPrefsFile);
- metaPrefSet = MetaPrefSet.load(metaPrefsFile, translationScope);
- println("OK: loaded MetaPrefs from " + metaPrefsFile);
- }
- catch (SIMPLTranslationException e)
- {
- metaPrefSetException = e;
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- // from supplied URL instead of from here
- try
- {
- debugA("Considering prefSet=" + prefSet + "\tprefsPURL=" + prefsPURL);
- if (prefSet == null) // Normal Case
- {
- prefSet = PrefSet.load(prefsPURL, translationScope);
- if (prefSet != null)
- println("OK: Loaded Prefs from " + prefsPURL);
- else
- println("No Prefs to load from " + prefsPURL);
- }
- if (metaPrefSetException != null)
- {
- warning("Couldn't load MetaPrefs:");
- metaPrefSetException.printTraceOrMessage(this, "MetaPrefs", metaPrefsPURL);
- println("\tContinuing.");
- }
- }
- catch (SIMPLTranslationException e)
- {
- if (metaPrefSetException != null)
- {
- error("Can't load MetaPrefs or Prefs. Quitting.");
- metaPrefSetException.printTraceOrMessage(this, "MetaPrefs", metaPrefsPURL);
- e.printTraceOrMessage(this, "Prefs", prefsPURL);
- }
- else
- {
- // meta prefs o.k. we can continue
- warning("Couldn't load Prefs:");
- e.printTraceOrMessage(this, "Prefs", prefsPURL);
- println("\tContinuing.");
- }
- }
-
- debugA("argStack.size() = " + argStack.size());
- if (argStack.size() > 0)
- {
- String prefSpec = "";
- if (arg.startsWith("http://"))
- {
- // PreferencesServlet
- prefSpec = pop(argStack);
-
- if (prefSpec != null)
- {
- // load URLEncoded prefs XML straight from the argument
- PrefSet JNLPPrefSet = loadPrefsFromJNLP(prefSpec);
-
- if (JNLPPrefSet != null)
- {
- if (prefSet == null)
- prefSet = JNLPPrefSet;
- else
- prefSet.append(JNLPPrefSet);
- }
- else
- { // if we got args straight from jnlp, then continue
- if (JNLPPrefSet != null)
- prefSpec = pop(argStack);
-
- if (prefSpec != null)
- {
- PrefSet servletPrefSet = requestPrefFromServlet(prefSpec, translationScope);
- if (servletPrefSet == null)
- error("incorrect prefXML string returned from the servlet=" + prefSpec);
- else
- {
- if (prefSet == null)
- prefSet = servletPrefSet;
- else
- prefSet.append(servletPrefSet);
- }
- }
- }
- }
- }
- }
- }
- else
- {
- error("No code base argument :-( Can't load preferences.");
- }
- break;
- case ECLIPSE:
- case JAR:
- // NB: This gets executed even if arg was null!
- File localCodeBasePath = deriveLocalFileCodeBase(baseClass); // sets codeBase()!
- argStack.push(arg);
-
- // AssetsRoot prefAssetsRoot = new AssetsRoot(Assets.getAssetsRoot().getRelative(PREFERENCES),
- // Files.newFile(PropertiesAndDirectories.thisApplicationDir(), PREFERENCES));
- // Assets.downloadZip(prefAssetsRoot, "prefs", null, false, prefsAssetVersion);
-
- SIMPLTranslationException metaPrefSetException = null;
- File metaPrefsFile = new File(localCodeBasePath, ECLIPSE_PREFS_DIR + METAPREFS_XML);
- ParsedURL metaPrefsPURL = new ParsedURL(metaPrefsFile);
- try
- {
- metaPrefSet = MetaPrefSet.load(metaPrefsPURL, translationScope);
- println("OK: Loaded MetaPrefs from: " + metaPrefsFile);
- }
- catch (SIMPLTranslationException e)
- {
- metaPrefSetException = e;
- }
-
- // load the application dir prefs from this machine
- // (e.g., c:\Documents and Settings\andruid\Application
- // Data\combinFormation\preferences\prefs.xml
- // these are the ones that get edited interactively!
-
- prefSet = PrefSet.load(prefsPURL, translationScope);
- if (prefSet != null)
- println("Loaded Prefs from: " + prefsPURL);
- else
- println("No Prefs to load from: " + prefsPURL);
-
- // now seek the path to an application specific xml preferences file
- arg = pop(argStack);
- // if (arg == null)
- // return;
- if (arg != null)
- {
- // load preferences specific to this invocation
- if (arg.endsWith(".xml"))
- {
- File argPrefsFile = new File(localCodeBasePath, ECLIPSE_PREFS_DIR + arg);
- ParsedURL argPrefsPURL = new ParsedURL(argPrefsFile);
- try
- {
- PrefSet argPrefSet = PrefSet.load(argPrefsPURL, translationScope);
- if (metaPrefSetException != null)
- {
- warning("Couldn't load MetaPrefs:");
- metaPrefSetException.printTraceOrMessage(this, "MetaPrefs", metaPrefsPURL);
- println("\tContinuing.");
- }
- if (argPrefSet != null)
- {
- println("OK: Loaded Prefs from: " + argPrefsFile);
- if (prefSet != null)
- prefSet.addPrefSet(argPrefSet);
- else
- prefSet = argPrefSet;
- }
- else
- {
- println("");
- String doesntExist = argPrefsFile.exists() ? "" : "\n\tFile does not exist!!!\n\n";
- println("ERROR: Loading Prefs from: " + argPrefsFile + doesntExist);
- }
-
- }
- catch (SIMPLTranslationException e)
- {
- if (metaPrefSetException != null)
- {
- error("Can't load MetaPrefs or Prefs. Quitting.");
- metaPrefSetException.printTraceOrMessage(this, "MetaPrefs", metaPrefsPURL);
- e.printStackTrace();
- throw e;
- }
- // meta prefs o.k. we can continue without having loaded Prefs now
- e.printTraceOrMessage(this, "Couldn't load Prefs", argPrefsPURL);
- println("\tContinuing.");
- }
- }
- else
- argStack.push(arg);
- }
- else
- argStack.push(arg); // let the next code handle returning.
- break;
- }
- System.out.println("Printing Prefs:\n");
- try
- {
- if (prefSet != null)
- SimplTypesScope.serialize(prefSet, System.out, StringFormat.XML);
- }
- catch (SIMPLTranslationException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- System.out.println("\nPrefs Printed");
- if (prefSet != null)
- postProcessPrefs(prefSet);
- }
-
- /**
- * Look for pref Ops, if delayed: setup their timers, and also set scope for their ops.
- *
- * @param prefSet
- */
- private void postProcessPrefs(PrefSet prefSet)
- {
- if (sessionScope == null)
- return;
- for (Pref> pref : prefSet.values())
- if (pref != null)
- pref.postLoadHook(sessionScope);
- }
-
- private PrefSet loadPrefsFromJNLP(String prefSpec)
- {
- PrefSet prefSet = null;
-
- debugA("loadPrefsFromJNLP()");
- if (prefSpec.startsWith("%3Cpref_set"))
- {
- try
- {
- String decodedPrefsXML = URLDecoder.decode(prefSpec, "UTF-8");
- debugA("Loading prefs from JNLP: " + decodedPrefsXML);
-
- for (ClassDescriptor c : translationScope.getClassDescriptors())
- {
- debugA(c.toString());
- }
-
- prefSet = PrefSet.loadFromCharSequence(decodedPrefsXML, translationScope);
- }
- catch (UnsupportedEncodingException e)
- {
- e.printStackTrace();
- }
- catch (SIMPLTranslationException e)
- {
- e.printStackTrace();
- }
- }
- return prefSet;
- }
-
- /**
- * Get the user.dir property. Form a path from it, ending in slash. See if there is path within
- * that that includes the package of baseClass. If so, remove that component from the path.
- *
- * Form a File from this path, and a ParsedURL from the file. Set codeBase to this ParsedURL.
- *
- * @param baseClass
- * Class of the subclass of this that is the main program that was executed.
- *
- * @return File that corresponds to the path of the local codeBase.
- */
- @Override
- protected File deriveLocalFileCodeBase(Class> baseClass)
- {
- // setup codeBase
- if (baseClass == null)
- baseClass = this.getClass();
-
- Package basePackage = baseClass.getPackage();
- String packageName = basePackage.getName();
- String packageNameAsPath = packageName.replace('.', Files.sep);
-
- String pathName = System.getProperty("user.dir") + Files.sep;
- File path = new File(pathName);
- String pathString = path.getAbsolutePath();
-
- // println("looking for " + packageNameAsPath +" in " + pathString);
-
- int packageIndex = pathString.lastIndexOf(packageNameAsPath);
- if (packageIndex != -1)
- {
- pathString = pathString.substring(0, packageIndex);
- path = new File(pathString + Files.sep);
- }
-
- codeBase = new ParsedURL(path);
- println("codeBase=" + codeBase);
- return path;
- }
-
- /**
- * @see ecologylab.appframework.Environment#runtimeEnv()
- */
- @Override
- public int runtimeEnv()
- {
- return APPLICATION;
- }
-
- /**
- * @see ecologylab.appframework.Environment#status(String)
- */
- @Override
- public void showStatus(String s)
- {
- System.out.println(s);
- }
-
- /**
- * @see ecologylab.appframework.Environment#status(String)
- */
- @Override
- public void status(String msg)
- {
- if (msg != null)
- showStatus(msg);
- }
-
- /**
- * @see ecologylab.appframework.Environment#docBase() return the current working directory of the
- * application which is "c:\web\code\java\cm"
- */
- @Override
- public ParsedURL docBase()
- {
- ParsedURL purl = new ParsedURL(new File(System.getProperty("user.dir")));
- return purl;
- }
-
- @Override
- public ParsedURL preferencesDir()
- {
- ParsedURL codeBase = codeBase();
- ParsedURL purl = codeBase.getRelative(ECLIPSE_PREFS_DIR, "forming preferences dir");
- return purl;
- }
-
- static final String FIREFOX_PATH_WINDOWS = "C:\\Program Files\\Mozilla Firefox\\firefox.exe";
-
- static final String FIREFOX_PATH_WINDOWS_64 = "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe";
-
- static final String FIREFOX_PATH_VIRT = "C:\\Program Files (x86)\\Microsoft Application Virtualization Client\\sfttray.exe";
-
- // TODO -- use "open" on the mac!!!
- static final String FIREFOX_PATH_MAC = "/Applications/Firefox.app/Contents/MacOS/firefox";
-
- // static final String FIREFOX_PATH_MAC = null;
- static final String SAFARI_PATH_MAC = "/Applications/Safari.app/Contents/MacOS/Safari";
-
- static final String FIREFOX_PATH_LINUX = "/usr/bin/firefox";
-
- static final String IE_PATH_WINDOWS = "C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE";
-
- static String browserPath;
-
- /**
- * Get the operating system dependent path to a suitable web browser for navigating to a web page.
- * This is also dependent on what web browser(s) the user has installed. In particular, we use
- * Firefox if it is in its normal place!
- *
- * @return String that specifies the OS and browser-specific command.
- */
- static String getBrowserPath()
- {
- int os = PropertiesAndDirectories.os();
- String result = browserPath;
- if (result == null)
- {
- switch (os)
- {
- case PropertiesAndDirectories.XP:
- case PropertiesAndDirectories.VISTA_AND_7:
- if (!Pref.lookupBoolean("navigate_with_ie"))
- result = FIREFOX_PATH_WINDOWS;
- if (result != null)
- {
- File existentialTester = new File(result);
- if (!existentialTester.exists())
- {
- result = FIREFOX_PATH_WINDOWS_64;
- existentialTester = new File(result);
- if (!existentialTester.exists())
- {
- result = IE_PATH_WINDOWS;
- existentialTester = new File(result);
- if (!existentialTester.exists())
- result = null;
- }
- }
- }
- break;
- case PropertiesAndDirectories.MAC:
- result = "/usr/bin/open";
- break;
- default:
- error(PropertiesAndDirectories.getOsName(), "go(ParsedURL) not supported");
- break;
- }
- if (result != null)
- {
- browserPath = result;
- }
- }
- return result;
- }
-
- static String[] cachedNavigateArgs;
-
- /**
- * Get the operating system dependent path to a suitable web browser for navigating to a web page.
- * This is also dependent on what web browser(s) the user has installed. In particular, we use
- * Firefox if it is in its normal place!
- *
- * @return String that specifies the OS and browser-specific command.
- */
- static String[] getNavigateArgs()
- {
- int os = PropertiesAndDirectories.os();
- String[] result = cachedNavigateArgs;
- if (result == null)
- {
- switch (os)
- {
- case PropertiesAndDirectories.XP:
- case PropertiesAndDirectories.VISTA_AND_7:
- String path = null;
- if (!Pref.lookupBoolean("navigate_with_ie"))
- path = FIREFOX_PATH_WINDOWS;
- if (path != null)
- {
- File existentialTester = new File(path);
- firefoxExists = existentialTester.exists();
- if (!firefoxExists)
- {
- path = FIREFOX_PATH_WINDOWS_64;
- existentialTester = new File(path);
- firefoxExists = existentialTester.exists();
- }
- if (firefoxExists)
- { // cool! firefox
- result = new String[3];
- result[0] = path;
- result[1] = "-new-tab";
- } else {
- //Use the SCC Virtualization Path
- path = FIREFOX_PATH_VIRT;
- existentialTester = new File(path);
- firefoxExists = existentialTester.exists();
- if(firefoxExists)
- {
- result = new String[5];
- result[0] = path;
- result[1] = "/launch";
- result[2] = "\"Mozilla Firefox 11\"";
- result[3] = "-new-tab";
- }
- }
-
- }
- if (result == null)
- {
- path = IE_PATH_WINDOWS;
- File existentialTester = new File(path);
- if (existentialTester.exists())
- {
- result = new String[2];
- result[0] = path;
- }
- }
- break;
- case PropertiesAndDirectories.MAC:
- result = new String[4];
- result[0] = "/usr/bin/open";
- result[1] = "-a";
- result[2] = "firefox";
- firefoxExists = true;
- break;
- case PropertiesAndDirectories.LINUX:
- result = new String[2];
- result[0] = FIREFOX_PATH_LINUX;
- firefoxExists = true;
- break;
- default:
- error(PropertiesAndDirectories.getOsName(), "go(ParsedURL) not supported");
- break;
- }
- if (result != null)
- {
- cachedNavigateArgs = result;
- }
- }
- return result;
- }
-
-
- /**
- * Returns true if firefox was found on this system.
- * @return
- */
- @Override
- public boolean hasFirefox()
- {
- getNavigateArgs();//sets firefoxExists if true
- return firefoxExists;
- }
-
-
- /**
- * Navigate to the purl using the best browser we can find.
- *
- * @param purl
- * @param frame
- */
- @Override
- public void navigate(ParsedURL purl, String frame)
- {
- String[] navigateArgs = getNavigateArgs();
- if (navigateArgs != null && purl != null)
- {
- String purlString = purl.toString();
- int numArgs = navigateArgs.length;
- navigateArgs[numArgs - 1] = purlString;
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < numArgs; i++)
- sb.append(navigateArgs[i]).append(' ');
- Debug.println("navigate: " + sb);
- try
- {
- Process p = Runtime.getRuntime().exec(navigateArgs);
- }
- catch (IOException e)
- {
- error("navigate() - caught exception: ");
- e.printStackTrace();
- }
- }
- else
- error("navigate() - Can't find browser to navigate to.");
- }
-
- @Override
- public int browser()
- {
- return APPLICATION;
- }
-
- /**
- * Called at the end of an invocation. Calls System.exit(code).
- *
- * @param code
- * -- 0 for normal. other values are application specific.
- */
- @Override
- public void exit(int code)
- {
- System.exit(code);
- }
-
- public static boolean isInUse()
- {
- return inUse;
- }
-
- public static boolean runningInEclipse()
- {
- return LaunchType.ECLIPSE == LAUNCH_TYPE_PREF.value();
- }
-
- public static boolean runningLocalhost()
- {
- return LaunchType.LOCAL_JNLP == LAUNCH_TYPE_PREF.value();
- }
-
- /**
- * Create and show an editor for preferences, iff the MetaPrefSet and PrefSet are non-null. If the
- * PrefSet is null, a new empty one will be created for the editor to use.
- *
- * @return
- */
- public Object createPrefsEditor(final boolean createJFrame, final boolean isStandalone)
- {
- Object result = null;
- if (metaPrefSet != null)
- {
- if (prefSet == null)
- prefSet = new PrefSet();
- result = FundamentalPlatformSpecifics.get().getOrCreatePrefsEditor(metaPrefSet, prefSet, prefsPURL, createJFrame, isStandalone);
- }
- return result;
- }
-
- /**
- * Create and show an editor for preferences, iff the MetaPrefSet and PrefSet are non-null. If the
- * PrefSet is null, a new empty one will be created for the editor to use.
- *
- * @return
- */
- public Object createPrefsEditor()
- {
- return this.createPrefsEditor(true, false);
- }
-
- /**
- *
- * @return MetaPrefSet for this application, loaded from standard locations.
- */
- protected MetaPrefSet metaPrefSet()
- {
- return metaPrefSet;
- }
-
- @Override
- public String getApplicationName()
- {
- return PropertiesAndDirectories.applicationName;
- }
-}
+package ecologylab.appframework;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLDecoder;
+import java.util.Stack;
+
+import ecologylab.appframework.types.prefs.MetaPrefSet;
+import ecologylab.appframework.types.prefs.MetaPrefsTranslationScope;
+import ecologylab.appframework.types.prefs.Pref;
+import ecologylab.appframework.types.prefs.PrefSet;
+import ecologylab.collections.Scope;
+import ecologylab.generic.Debug;
+import ecologylab.io.Assets;
+import ecologylab.io.AssetsRoot;
+import ecologylab.io.Files;
+import ecologylab.net.ParsedURL;
+import ecologylab.platformspecifics.FundamentalPlatformSpecifics;
+import ecologylab.serialization.ClassDescriptor;
+import ecologylab.serialization.SIMPLTranslationException;
+import ecologylab.serialization.SimplTypesScope;
+import ecologylab.serialization.XMLTranslationExceptionTypes;
+import ecologylab.serialization.formatenums.StringFormat;
+
+/**
+ * An instance of Environment, which is an application, rather than an applet, or a servlet. The
+ * Environment mechanism is used to enable the provision of contextual runtime configuration
+ * parameter services in a way that is independent of the deployment structure.
+ *
+ * The SingletonApplicationEnvironment differs from ApplicationEnvironment in that it sets the
+ * static Environment.the (among other static references). It CANNOT be used in a situation where
+ * multiple ApplicationEnvironments will operate in the same JVM. It does, however, simplify the use
+ * of Prefs and other statically accessed application components.
+ *
+ * @author Andruid
+ * @author Zachary O. Toups (zach@ecologylab.net)
+ */
+public class SingletonApplicationEnvironment extends ApplicationEnvironment implements Environment,
+ XMLTranslationExceptionTypes, ApplicationPropertyNames
+{
+ public static final String SCREEN_SIZE = "screen_size";
+
+ private static final String METAPREFS_XML = "metaprefs.xml";
+
+ private static boolean inUse = false;
+
+ /** Set of MetaPrefs that describe preferences and provide default values. */
+ MetaPrefSet metaPrefSet;
+
+ // must initialize this before subsequent lookup by scope name.
+ static final SimplTypesScope META_PREFS_TRANSLATION_SCOPE = MetaPrefsTranslationScope.get();
+
+ public static enum WindowSize
+ {
+ PASS_PARAMS, QUARTER_SCREEN, ALMOST_HALF, NEAR_FULL, FULL_SCREEN
+ }
+
+ public static final String TOP_LEVEL_HEIGHT = "topheight";
+ public static final String TOP_LEVEL_WIDTH = "topwidth";
+
+ static boolean firefoxExists = false;
+
+ /**
+ * Create an ApplicationEnvironment. Create an empty properties object for application parameters.
+ *
+ * No command line argument is processed. Only default preferences are loaded, and processed with
+ * the default TranslationSpace.
+ *
+ * @param args
+ * The args array, which is treated as a stack with optional entries. They are: *) JNLP
+ * -- if that is the launch method *) preferences file if you are running in eclipse.
+ * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
+ * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
+ * @throws SIMPLTranslationException
+ */
+ public SingletonApplicationEnvironment(String applicationName) throws SIMPLTranslationException
+ {
+ this(null, applicationName, null);
+ }
+
+ /**
+ * Create an ApplicationEnvironment. Load preferences from XML file founds in the
+ * config/preferences directory. Default preferences will be loaded from preferences.xml. If there
+ * is a 0th command line argument, that is the name of an additional preferences file.
+ *
+ * @param applicationName
+ * @param translationScope
+ * TranslationSpace used for translating preferences XML. If this is null,
+ * {@link ecologylab.oodss.messages.DefaultServicesTranslations
+ * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
+ * @param args
+ * The args array, which is treated as a stack with optional entries. They are: *) JNLP
+ * -- if that is the launch method *) preferences file if you are running in eclipse.
+ * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
+ * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
+ * @param prefsAssetVersion
+ * TODO
+ * @throws SIMPLTranslationException
+ */
+ public SingletonApplicationEnvironment( String applicationName,
+ SimplTypesScope translationScope,
+ String args[],
+ float prefsAssetVersion) throws SIMPLTranslationException
+ {
+ this(applicationName, translationScope, (SimplTypesScope) null, args, prefsAssetVersion);
+ }
+
+ /**
+ * Create an ApplicationEnvironment. Load preferences from XML file founds in the
+ * config/preferences directory. Default preferences will be loaded from preferences.xml. If there
+ * is a 0th command line argument, that is the name of an additional preferences file.
+ *
+ * @param applicationName
+ * @param translationScope
+ * TranslationSpace used for translating preferences XML. If this is null,
+ * {@link ecologylab.oodss.messages.DefaultServicesTranslations
+ * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
+ * @param customPrefs
+ * TODO
+ * @param args
+ * The args array, which is treated as a stack with optional entries. They are: *) JNLP
+ * -- if that is the launch method *) preferences file if you are running in eclipse.
+ * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
+ * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
+ * @param prefsAssetVersion
+ * TODO
+ * @throws SIMPLTranslationException
+ */
+ public SingletonApplicationEnvironment( String applicationName,
+ SimplTypesScope translationScope,
+ Class extends Pref>>[] customPrefs,
+ String args[],
+ float prefsAssetVersion) throws SIMPLTranslationException
+ {
+ this(applicationName, (Scope>) null, translationScope, customPrefs, args, prefsAssetVersion);
+ }
+
+ /**
+ *
+ * @param applicationName
+ * @param translationScope
+ * TranslationSpace used for translating preferences XML. If this is null,
+ * {@link ecologylab.oodss.messages.DefaultServicesTranslations
+ * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
+ * @param sessionScope
+ * @param customPrefs
+ * @param args
+ * The args array, which is treated as a stack with optional entries. They are: *) JNLP
+ * -- if that is the launch method *) preferences file if you are running in eclipse.
+ * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
+ * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
+ * @param prefsAssetVersion
+ * @throws SIMPLTranslationException
+ */
+ public SingletonApplicationEnvironment( String applicationName,
+ Scope> sessionScope,
+ SimplTypesScope translationScope,
+ Class extends Pref>>[] customPrefs,
+ String args[],
+ float prefsAssetVersion) throws SIMPLTranslationException
+ {
+ this( (Class>) null,
+ applicationName,
+ sessionScope,
+ translationScope,
+ prefsClassArrayToTranslationScope(customPrefs),
+ args,
+ prefsAssetVersion);
+ }
+
+ /**
+ * Create an ApplicationEnvironment. Load preferences from XML file founds in the
+ * config/preferences directory. Default preferences will be loaded from preferences.xml. If there
+ * is a 0th command line argument, that is the name of an additional preferences file.
+ *
+ * @param applicationName
+ * @param translationScope
+ * TranslationSpace used for translating preferences XML. If this is null,
+ * {@link ecologylab.oodss.messages.DefaultServicesTranslations
+ * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
+ * @param customPrefsTranslationScope
+ * TODO
+ * @param args
+ * The args array, which is treated as a stack with optional entries. They are: *) JNLP
+ * -- if that is the launch method *) preferences file if you are running in eclipse.
+ * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
+ * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
+ * @param prefsAssetVersion
+ * TODO
+ * @throws SIMPLTranslationException
+ */
+ public SingletonApplicationEnvironment( String applicationName,
+ SimplTypesScope translationScope,
+ SimplTypesScope customPrefsTranslationScope,
+ String args[],
+ float prefsAssetVersion) throws SIMPLTranslationException
+ {
+ this( (Class>) null,
+ applicationName,
+ (Scope>) null,
+ translationScope,
+ customPrefsTranslationScope,
+ args,
+ prefsAssetVersion);
+ }
+
+ /**
+ * Create an ApplicationEnvironment. Load preferences from XML files found in the
+ * config/preferences directory. Default preferences will be loaded from preferences.xml. If there
+ * is a 0th command line argument, that is the name of an additional preferences file.
+ *
+ * The default TranslationSpace, from
+ * {@link ecologylab.oodss.messages.DefaultServicesTranslations
+ * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
+ *
+ * @param applicationName
+ * {@link ecologylab.oodss.messages.DefaultServicesTranslations
+ * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
+ * @param args
+ * The args array, which is treated as a stack with optional entries. They are: *) JNLP
+ * -- if that is the launch method *) preferences file if you are running in eclipse.
+ * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
+ * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
+ * @throws SIMPLTranslationException
+ */
+ public SingletonApplicationEnvironment(String applicationName, String args[])
+ throws SIMPLTranslationException
+ {
+ this(applicationName, (SimplTypesScope) null, (SimplTypesScope) null, args, 0);
+ }
+
+ /**
+ * Create an ApplicationEnvironment. Get the base for finding the path to the "codeBase" by using
+ * the package path of the baseClass passed in.
+ *
+ * Load preferences from XML file founds in the codeBase/config/preferences directory. Default
+ * preferences will be loaded from preferences.xml. If there is a 0th command line argument, that
+ * is the name of an additional preferences file.
+ *
+ * Also, sets the Assets cacheRoot to the applicationDir().
+ *
+ * The default TranslationSpace, from
+ * {@link ecologylab.oodss.messages.DefaultServicesTranslations
+ * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
+ *
+ * @param baseClass
+ * Used for computing codeBase property.
+ * @param applicationName
+ * @param args
+ * The args array, which is treated as a stack with optional entries. They are: *) JNLP
+ * -- if that is the launch method *) preferences file if you are running in eclipse.
+ * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
+ * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full
+ * @throws SIMPLTranslationException
+ */
+ public SingletonApplicationEnvironment(Class> baseClass, String applicationName, String args[])
+ throws SIMPLTranslationException
+ {
+ this(baseClass, applicationName, null, null, null, args, 0);
+ }
+
+ /**
+ * Additional constructor to hold the session scope for post processing loaded preferences.
+ *
+ * @param applicationName
+ * @param sessionScope
+ */
+ public SingletonApplicationEnvironment( Class> baseClass,
+ String applicationName,
+ SimplTypesScope translationScope,
+ String args[],
+ float prefsAssetVersion) throws SIMPLTranslationException
+ {
+ this(baseClass, applicationName, null, translationScope, null, args, prefsAssetVersion);
+ }
+
+ /**
+ * Create an ApplicationEnvironment.
+ *
+ * Treats the args array like a stack. If any args are missing (based on their format), they are
+ * skipped.
+ *
+ * The first arg we seek is codeBase. This is a path that ends in slash. It may be a local
+ * relative path, or a URL-based absolute path.
+ *
+ * The next possible arg is a preferences file. This ends with .xml.
+ *
+ * The next 2 possible args are integers, for graphicsDev and screenSize. graphics_device (screen
+ * number) to display window. count from 0. screenSize used in TopLevel -- 1 - quarter; 2 - almost
+ * half; 3; near full; 4 full
+ *
+ * Get the base for finding the path to the "codeBase" by using the package path of the baseClass
+ * passed in.
+ *
+ * Load preferences from XML file founds in the codeBase/config/preferences directory. Default
+ * preferences will be loaded from preferences.xml. If there is a 0th command line argument, that
+ * is the name of an additional preferences file.
+ *
+ * Also, sets the Assets cacheRoot to the applicationDir().
+ *
+ * The default TranslationSpace, from
+ * {@link ecologylab.oodss.messages.DefaultServicesTranslations
+ * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
+ *
+ * @param baseClass
+ * Used for computing codeBase property.
+ * @param applicationName
+ * Name of the application.
+ * @param translationScope
+ * TranslationSpace used for translating preferences XML. If this is null,
+ * {@link ecologylab.oodss.messages.DefaultServicesTranslations
+ * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
+ * @param args
+ * The args array, which is treated as a stack with optional entries. They are: *) JNLP
+ * -- if that is the launch method *) preferences file if you are running in eclipse.
+ * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
+ * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
+ * @param prefsAssetVersion
+ * TODO
+ * @throws SIMPLTranslationException
+ */
+ public SingletonApplicationEnvironment( Class> baseClass,
+ String applicationName,
+ Scope sessionScope,
+ SimplTypesScope translationScope,
+ String args[],
+ float prefsAssetVersion) throws SIMPLTranslationException
+ {
+ this(baseClass, applicationName, sessionScope, translationScope, null, args, prefsAssetVersion);
+ }
+
+ /**
+ * Create an ApplicationEnvironment.
+ *
+ * Treats the args array like a stack. If any args are missing (based on their format), they are
+ * skipped.
+ *
+ * The first arg we seek is codeBase. This is a path that ends in slash. It may be a local
+ * relative path, or a URL-based absolute path.
+ *
+ * The next possible arg is a preferences file. This ends with .xml.
+ *
+ * The next 2 possible args are integers, for graphicsDev and screenSize. graphics_device (screen
+ * number) to display window. count from 0. screenSize used in TopLevel -- 1 - quarter; 2 - almost
+ * half; 3; near full; 4 full
+ *
+ * Get the base for finding the path to the "codeBase" by using the package path of the baseClass
+ * passed in.
+ *
+ * Load preferences from XML file founds in the codeBase/config/preferences directory. Default
+ * preferences will be loaded from preferences.xml. If there is a 0th command line argument, that
+ * is the name of an additional preferences file.
+ *
+ * Also, sets the Assets cacheRoot to the applicationDir().
+ *
+ * The default TranslationSpace, from
+ * {@link ecologylab.oodss.messages.DefaultServicesTranslations
+ * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
+ *
+ * @param baseClass
+ * Used for computing codeBase property.
+ * @param applicationName
+ * Name of the application.
+ * @param translationScope
+ * TranslationSpace used for translating preferences XML. If this is null,
+ * {@link ecologylab.oodss.messages.DefaultServicesTranslations
+ * ecologylab.oodss.message.DefaultServicesTranslations} will be used.
+ * @param customPrefs
+ * An array of Pref subclasses that are used for this specific application. These classes
+ * will be automatically composed into a special translation scope used for translating
+ * prefs for the application. Note that translationScope is NOT used for translating the
+ * application prefs, but is still required for other translations in the application.
+ * @param args
+ * The args array, which is treated as a stack with optional entries. They are: *) JNLP
+ * -- if that is the launch method *) preferences file if you are running in eclipse.
+ * Relative to CODEBASE/config/preferences/ *) graphics_device (screen number) *)
+ * screen_size (used in TopLevel -- 1 - quarter; 2 - almost half; 3; near full; 4 full)
+ * @param prefsAssetVersion
+ * TODO
+ * @throws SIMPLTranslationException
+ */
+ public SingletonApplicationEnvironment( Class> baseClass,
+ String applicationName,
+ Scope> sessionScope,
+ SimplTypesScope translationScope,
+ SimplTypesScope customPrefsTranslationScope,
+ String args[],
+ float prefsAssetVersion) throws SIMPLTranslationException
+ {
+ super(baseClass,
+ applicationName,
+ sessionScope,
+ translationScope,
+ customPrefsTranslationScope,
+ args,
+ prefsAssetVersion);
+
+ inUse = true;
+
+ // this is the one and only singleton Environment
+ Environment.the.set(this);
+
+ PropertiesAndDirectories.setApplicationName(applicationName);
+ }
+
+ /**
+ * Sets the applicationName for PropertiesAndDirectories.
+ *
+ * @see ecologylab.appframework.ApplicationEnvironment#setApplicationName(java.lang.String)
+ */
+ @Override
+ protected void setApplicationName(String applicationName)
+ {
+ super.setApplicationName(applicationName);
+
+ PropertiesAndDirectories.setApplicationName(applicationName);
+ }
+
+ @Override
+ protected void processArgsAndPrefs(Class> baseClass, SimplTypesScope translationScope,
+ float prefsAssetVersion) throws SIMPLTranslationException
+ {
+ String arg;
+ processPrefs(baseClass, translationScope, argStack, prefsAssetVersion);
+
+ Debug.initialize();
+
+ arg = pop(argStack);
+ if (arg == null)
+ return;
+ try
+ {
+ int screenNum = Integer.parseInt(arg);
+ Pref.useAndSetPrefInt("graphics_device", screenNum);
+
+ }
+ catch (NumberFormatException e)
+ {
+ argStack.push(arg);
+ }
+ try
+ {
+ arg = pop(argStack);
+ if (arg == null)
+ return;
+ Pref.useAndSetPrefInt(SCREEN_SIZE, WindowSize.valueOf(arg.toUpperCase()).ordinal());
+ }
+ catch (IllegalArgumentException e)
+ {
+ argStack.push(arg);
+ }
+ if (Pref.lookupInt(SCREEN_SIZE) == 0)
+ {
+ try
+ {
+ arg = pop(argStack);
+ if (arg == null)
+ return;
+ Pref.useAndSetPrefInt(TOP_LEVEL_WIDTH, Integer.parseInt(arg));
+
+ arg = pop(argStack);
+ if (arg == null)
+ return;
+ Pref.useAndSetPrefInt(TOP_LEVEL_HEIGHT, Integer.parseInt(arg));
+ }
+ catch (IllegalArgumentException e)
+ {
+ argStack.push(arg);
+ }
+ }
+ }
+
+ /**
+ * request User's prefSet from the preferenceServlet and return the prefSetXML string.
+ *
+ * @author eunyee
+ * @param prefServlet
+ * @param translationScope
+ * TODO
+ * @param uid
+ * @return
+ */
+ @Override
+ protected PrefSet requestPrefFromServlet(String prefServlet, SimplTypesScope translationScope)
+ {
+ System.out.println("retrieving preferences set from servlet: " + prefServlet);
+ /*
+ * try { ParsedURL purl = new ParsedURL(new URL(prefServlet));
+ *
+ * PrefSet prefSet = (PrefSet) ElementState.translateFromXML(purl, PrefTranslations.get());
+ * return prefSet; } catch (MalformedURLException e1) { // TODO Auto-generated catch block
+ * e1.printStackTrace(); } catch (XmlTranslationException e) { // TODO Auto-generated catch
+ * block e.printStackTrace(); } return null;
+ */
+ try
+ {
+ URL url = new URL(prefServlet);
+ URLConnection connection = url.openConnection();
+
+ // specify the content type that binary data is sent
+ connection.setRequestProperty("Content-Type", "text/xml");
+
+ // define a new BufferedReader on the input stream
+ BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+
+ // receive data from the servlet
+ String prefSetXML = in.readLine();
+ PrefSet prfs = null;
+ try
+ {
+ prfs = PrefSet.loadFromCharSequence(prefSetXML, translationScope);
+ System.out.println("Prefs loaded From Servlet:: ");
+ if (prfs != null)
+ SimplTypesScope.serialize(prfs, System.out, StringFormat.XML);
+
+ System.out.println(" --- End Prefs");
+ }
+ catch (SIMPLTranslationException e)
+ {
+ e.printStackTrace();
+ }
+ in.close();
+
+ return prfs;
+ }
+ catch (IOException e)
+ {
+ warning("not a servlet URL: " + prefServlet);
+ }
+ return null;
+ }
+
+ /**
+ * Load MetaPrefs and Prefs, if possible
+ *
+ * @param baseClass
+ * @param translationScope
+ * @param argStack
+ * @param prefsAssetVersion
+ * TODO
+ * @throws SIMPLTranslationException
+ */
+ private void processPrefs(Class> baseClass, SimplTypesScope translationScope,
+ Stack argStack, float prefsAssetVersion) throws SIMPLTranslationException
+ {
+ LaunchType launchType = LaunchType.ECLIPSE; // current default
+
+ // look for launch method identifier in upper case
+ String arg = pop(argStack);
+
+ if (arg != null)
+ {
+ String uc = arg.toUpperCase();
+ if ("JNLP".equals(uc))
+ { // tells us how we were launched: e.g., JNLP, ECLIPSE, ...
+ launchType = LaunchType.JNLP;
+ }
+ else if ("STUDIES".equals(uc))
+ {
+ launchType = LaunchType.STUDIES;
+ }
+ else
+ {
+ // TODO -- recognize JAR here !!!
+ argStack.push(arg);
+ }
+ LAUNCH_TYPE_PREF.setValue(launchType);
+ }
+ println("LaunchType = " + launchType);
+ this.launchType = launchType;
+ // look for codeBase path
+ arg = pop(argStack);
+
+ // read perhaps meta-preferences and surely preferences from application data dir
+ File applicationDir = PropertiesAndDirectories.thisApplicationDir();
+
+ ParsedURL applicationDataPURL = new ParsedURL(applicationDir);
+ prefsPURL = applicationDataPURL.getRelative("preferences/prefs.xml");
+ debugA("prefsPURL= " + prefsPURL);
+
+ System.out.println("arg: " + arg);
+
+ switch (launchType)
+ {
+ case STUDIES:
+ case JNLP:
+ // next arg *should* be code base
+ if ((arg != null) && arg.endsWith("/"))
+ {
+ // JNLP only! (as of now)
+ // right now this only works for http://
+ ParsedURL codeBase = ParsedURL.getAbsolute(arg, "Setting up codebase");
+ this.setCodeBase(codeBase);
+
+ // XXX is this right?
+ final String host = codeBase.host();
+ if ("localhost".equals(host) || "127.0.0.1".equals(host))
+ {
+ debug("launched from localhost. must be a developer.");
+ LAUNCH_TYPE_PREF.setValue(LaunchType.LOCAL_JNLP);
+ }
+
+ SIMPLTranslationException metaPrefSetException = null;
+ ParsedURL metaPrefsPURL = null;
+ try
+ {
+ AssetsRoot prefAssetsRoot = new AssetsRoot(this, PREFERENCES, null);
+ File metaPrefsFile = Assets.getAsset( prefAssetsRoot,
+ METAPREFS_XML,
+ "prefs",
+ null,
+ false,
+ prefsAssetVersion);
+ metaPrefsPURL = new ParsedURL(metaPrefsFile);
+ metaPrefSet = MetaPrefSet.load(metaPrefsFile, translationScope);
+ println("OK: loaded MetaPrefs from " + metaPrefsFile);
+ }
+ catch (SIMPLTranslationException e)
+ {
+ metaPrefSetException = e;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ // from supplied URL instead of from here
+ try
+ {
+ debugA("Considering prefSet=" + prefSet + "\tprefsPURL=" + prefsPURL);
+ if (prefSet == null) // Normal Case
+ {
+ prefSet = PrefSet.load(prefsPURL, translationScope);
+ if (prefSet != null)
+ println("OK: Loaded Prefs from " + prefsPURL);
+ else
+ println("No Prefs to load from " + prefsPURL);
+ }
+ if (metaPrefSetException != null)
+ {
+ warning("Couldn't load MetaPrefs:");
+ metaPrefSetException.printTraceOrMessage(this, "MetaPrefs", metaPrefsPURL);
+ println("\tContinuing.");
+ }
+ }
+ catch (SIMPLTranslationException e)
+ {
+ if (metaPrefSetException != null)
+ {
+ error("Can't load MetaPrefs or Prefs. Quitting.");
+ metaPrefSetException.printTraceOrMessage(this, "MetaPrefs", metaPrefsPURL);
+ e.printTraceOrMessage(this, "Prefs", prefsPURL);
+ }
+ else
+ {
+ // meta prefs o.k. we can continue
+ warning("Couldn't load Prefs:");
+ e.printTraceOrMessage(this, "Prefs", prefsPURL);
+ println("\tContinuing.");
+ }
+ }
+
+ debugA("argStack.size() = " + argStack.size());
+ if (argStack.size() > 0)
+ {
+ String prefSpec = "";
+ if (arg.startsWith("http://"))
+ {
+ // PreferencesServlet
+ prefSpec = pop(argStack);
+
+ if (prefSpec != null)
+ {
+ // load URLEncoded prefs XML straight from the argument
+ PrefSet JNLPPrefSet = loadPrefsFromJNLP(prefSpec);
+
+ if (JNLPPrefSet != null)
+ {
+ if (prefSet == null)
+ prefSet = JNLPPrefSet;
+ else
+ prefSet.append(JNLPPrefSet);
+ }
+ else
+ { // if we got args straight from jnlp, then continue
+ if (JNLPPrefSet != null)
+ prefSpec = pop(argStack);
+
+ if (prefSpec != null)
+ {
+ PrefSet servletPrefSet = requestPrefFromServlet(prefSpec, translationScope);
+ if (servletPrefSet == null)
+ error("incorrect prefXML string returned from the servlet=" + prefSpec);
+ else
+ {
+ if (prefSet == null)
+ prefSet = servletPrefSet;
+ else
+ prefSet.append(servletPrefSet);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ error("No code base argument :-( Can't load preferences.");
+ }
+ break;
+ case ECLIPSE:
+ case JAR:
+ // NB: This gets executed even if arg was null!
+ File localCodeBasePath = deriveLocalFileCodeBase(baseClass); // sets codeBase()!
+ argStack.push(arg);
+
+ // AssetsRoot prefAssetsRoot = new AssetsRoot(Assets.getAssetsRoot().getRelative(PREFERENCES),
+ // Files.newFile(PropertiesAndDirectories.thisApplicationDir(), PREFERENCES));
+ // Assets.downloadZip(prefAssetsRoot, "prefs", null, false, prefsAssetVersion);
+
+ SIMPLTranslationException metaPrefSetException = null;
+ File metaPrefsFile = new File(localCodeBasePath, ECLIPSE_PREFS_DIR + METAPREFS_XML);
+ ParsedURL metaPrefsPURL = new ParsedURL(metaPrefsFile);
+ try
+ {
+ metaPrefSet = MetaPrefSet.load(metaPrefsPURL, translationScope);
+ println("OK: Loaded MetaPrefs from: " + metaPrefsFile);
+ }
+ catch (SIMPLTranslationException e)
+ {
+ metaPrefSetException = e;
+ }
+
+ // load the application dir prefs from this machine
+ // (e.g., c:\Documents and Settings\andruid\Application
+ // Data\combinFormation\preferences\prefs.xml
+ // these are the ones that get edited interactively!
+
+ prefSet = PrefSet.load(prefsPURL, translationScope);
+ if (prefSet != null)
+ println("Loaded Prefs from: " + prefsPURL);
+ else
+ println("No Prefs to load from: " + prefsPURL);
+
+ // now seek the path to an application specific xml preferences file
+ arg = pop(argStack);
+ // if (arg == null)
+ // return;
+ if (arg != null)
+ {
+ // load preferences specific to this invocation
+ if (arg.endsWith(".xml"))
+ {
+ File argPrefsFile = new File(localCodeBasePath, ECLIPSE_PREFS_DIR + arg);
+ ParsedURL argPrefsPURL = new ParsedURL(argPrefsFile);
+ try
+ {
+ PrefSet argPrefSet = PrefSet.load(argPrefsPURL, translationScope);
+ if (metaPrefSetException != null)
+ {
+ warning("Couldn't load MetaPrefs:");
+ metaPrefSetException.printTraceOrMessage(this, "MetaPrefs", metaPrefsPURL);
+ println("\tContinuing.");
+ }
+ if (argPrefSet != null)
+ {
+ println("OK: Loaded Prefs from: " + argPrefsFile);
+ if (prefSet != null)
+ prefSet.addPrefSet(argPrefSet);
+ else
+ prefSet = argPrefSet;
+ }
+ else
+ {
+ println("");
+ String doesntExist = argPrefsFile.exists() ? "" : "\n\tFile does not exist!!!\n\n";
+ println("ERROR: Loading Prefs from: " + argPrefsFile + doesntExist);
+ }
+
+ }
+ catch (SIMPLTranslationException e)
+ {
+ if (metaPrefSetException != null)
+ {
+ error("Can't load MetaPrefs or Prefs. Quitting.");
+ metaPrefSetException.printTraceOrMessage(this, "MetaPrefs", metaPrefsPURL);
+ e.printStackTrace();
+ throw e;
+ }
+ // meta prefs o.k. we can continue without having loaded Prefs now
+ e.printTraceOrMessage(this, "Couldn't load Prefs", argPrefsPURL);
+ println("\tContinuing.");
+ }
+ }
+ else
+ argStack.push(arg);
+ }
+ else
+ argStack.push(arg); // let the next code handle returning.
+ break;
+ }
+ System.out.println("Printing Prefs:\n");
+ try
+ {
+ if (prefSet != null)
+ SimplTypesScope.serialize(prefSet, System.out, StringFormat.XML);
+ }
+ catch (SIMPLTranslationException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ System.out.println("\nPrefs Printed");
+ if (prefSet != null)
+ postProcessPrefs(prefSet);
+ }
+
+ /**
+ * Look for pref Ops, if delayed: setup their timers, and also set scope for their ops.
+ *
+ * @param prefSet
+ */
+ private void postProcessPrefs(PrefSet prefSet)
+ {
+ if (sessionScope == null)
+ return;
+ for (Pref> pref : prefSet.values())
+ if (pref != null)
+ pref.postLoadHook(sessionScope);
+ }
+
+ private PrefSet loadPrefsFromJNLP(String prefSpec)
+ {
+ PrefSet prefSet = null;
+
+ debugA("loadPrefsFromJNLP()");
+ if (prefSpec.startsWith("%3Cpref_set"))
+ {
+ try
+ {
+ String decodedPrefsXML = URLDecoder.decode(prefSpec, "UTF-8");
+ debugA("Loading prefs from JNLP: " + decodedPrefsXML);
+
+ for (ClassDescriptor c : translationScope.getClassDescriptors())
+ {
+ debugA(c.toString());
+ }
+
+ prefSet = PrefSet.loadFromCharSequence(decodedPrefsXML, translationScope);
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ e.printStackTrace();
+ }
+ catch (SIMPLTranslationException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return prefSet;
+ }
+
+ /**
+ * Get the user.dir property. Form a path from it, ending in slash. See if there is path within
+ * that that includes the package of baseClass. If so, remove that component from the path.
+ *
+ * Form a File from this path, and a ParsedURL from the file. Set codeBase to this ParsedURL.
+ *
+ * @param baseClass
+ * Class of the subclass of this that is the main program that was executed.
+ *
+ * @return File that corresponds to the path of the local codeBase.
+ */
+ @Override
+ protected File deriveLocalFileCodeBase(Class> baseClass)
+ {
+ // setup codeBase
+ if (baseClass == null)
+ baseClass = this.getClass();
+
+ Package basePackage = baseClass.getPackage();
+ String packageName = basePackage.getName();
+ String packageNameAsPath = packageName.replace('.', Files.sep);
+
+ String pathName = System.getProperty("user.dir") + Files.sep;
+ File path = new File(pathName);
+ String pathString = path.getAbsolutePath();
+
+ // println("looking for " + packageNameAsPath +" in " + pathString);
+
+ int packageIndex = pathString.lastIndexOf(packageNameAsPath);
+ if (packageIndex != -1)
+ {
+ pathString = pathString.substring(0, packageIndex);
+ path = new File(pathString + Files.sep);
+ }
+
+ codeBase = new ParsedURL(path);
+ println("codeBase=" + codeBase);
+ return path;
+ }
+
+ /**
+ * @see ecologylab.appframework.Environment#runtimeEnv()
+ */
+ @Override
+ public int runtimeEnv()
+ {
+ return APPLICATION;
+ }
+
+ /**
+ * @see ecologylab.appframework.Environment#status(String)
+ */
+ @Override
+ public void showStatus(String s)
+ {
+ System.out.println(s);
+ }
+
+ /**
+ * @see ecologylab.appframework.Environment#status(String)
+ */
+ @Override
+ public void status(String msg)
+ {
+ if (msg != null)
+ showStatus(msg);
+ }
+
+ /**
+ * @see ecologylab.appframework.Environment#docBase() return the current working directory of the
+ * application which is "c:\web\code\java\cm"
+ */
+ @Override
+ public ParsedURL docBase()
+ {
+ ParsedURL purl = new ParsedURL(new File(System.getProperty("user.dir")));
+ return purl;
+ }
+
+ @Override
+ public ParsedURL preferencesDir()
+ {
+ ParsedURL codeBase = codeBase();
+ ParsedURL purl = codeBase.getRelative(ECLIPSE_PREFS_DIR, "forming preferences dir");
+ return purl;
+ }
+
+ static final String FIREFOX_PATH_WINDOWS = "C:\\Program Files\\Mozilla Firefox\\firefox.exe";
+
+ static final String FIREFOX_PATH_WINDOWS_64 = "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe";
+
+ static final String FIREFOX_PATH_VIRT = "C:\\Program Files (x86)\\Microsoft Application Virtualization Client\\sfttray.exe";
+
+ // TODO -- use "open" on the mac!!!
+ static final String FIREFOX_PATH_MAC = "/Applications/Firefox.app/Contents/MacOS/firefox";
+
+ // static final String FIREFOX_PATH_MAC = null;
+ static final String SAFARI_PATH_MAC = "/Applications/Safari.app/Contents/MacOS/Safari";
+
+ static final String FIREFOX_PATH_LINUX = "/usr/bin/firefox";
+
+ static final String IE_PATH_WINDOWS = "C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE";
+
+ static String browserPath;
+
+ /**
+ * Get the operating system dependent path to a suitable web browser for navigating to a web page.
+ * This is also dependent on what web browser(s) the user has installed. In particular, we use
+ * Firefox if it is in its normal place!
+ *
+ * @return String that specifies the OS and browser-specific command.
+ */
+ static String getBrowserPath()
+ {
+ int os = PropertiesAndDirectories.os();
+ String result = browserPath;
+ if (result == null)
+ {
+ switch (os)
+ {
+ case PropertiesAndDirectories.XP:
+ case PropertiesAndDirectories.VISTA_AND_7:
+ if (!Pref.lookupBoolean("navigate_with_ie"))
+ result = FIREFOX_PATH_WINDOWS;
+ if (result != null)
+ {
+ File existentialTester = new File(result);
+ if (!existentialTester.exists())
+ {
+ result = FIREFOX_PATH_WINDOWS_64;
+ existentialTester = new File(result);
+ if (!existentialTester.exists())
+ {
+ result = IE_PATH_WINDOWS;
+ existentialTester = new File(result);
+ if (!existentialTester.exists())
+ result = null;
+ }
+ }
+ }
+ break;
+ case PropertiesAndDirectories.MAC:
+ result = "/usr/bin/open";
+ break;
+ default:
+ error(PropertiesAndDirectories.getOsName(), "go(ParsedURL) not supported");
+ break;
+ }
+ if (result != null)
+ {
+ browserPath = result;
+ }
+ }
+ return result;
+ }
+
+ static String[] cachedNavigateArgs;
+
+ /**
+ * Get the operating system dependent path to a suitable web browser for navigating to a web page.
+ * This is also dependent on what web browser(s) the user has installed. In particular, we use
+ * Firefox if it is in its normal place!
+ *
+ * @return String that specifies the OS and browser-specific command.
+ */
+ static String[] getNavigateArgs()
+ {
+ int os = PropertiesAndDirectories.os();
+ String[] result = cachedNavigateArgs;
+ if (result == null)
+ {
+ switch (os)
+ {
+ case PropertiesAndDirectories.XP:
+ case PropertiesAndDirectories.VISTA_AND_7:
+ String path = null;
+ if (!Pref.lookupBoolean("navigate_with_ie"))
+ path = FIREFOX_PATH_WINDOWS;
+ if (path != null)
+ {
+ File existentialTester = new File(path);
+ firefoxExists = existentialTester.exists();
+ if (!firefoxExists)
+ {
+ path = FIREFOX_PATH_WINDOWS_64;
+ existentialTester = new File(path);
+ firefoxExists = existentialTester.exists();
+ }
+ if (firefoxExists)
+ { // cool! firefox
+ result = new String[3];
+ result[0] = path;
+ result[1] = "-new-tab";
+ } else {
+ //Use the SCC Virtualization Path
+ path = FIREFOX_PATH_VIRT;
+ existentialTester = new File(path);
+ firefoxExists = existentialTester.exists();
+ if(firefoxExists)
+ {
+ result = new String[5];
+ result[0] = path;
+ result[1] = "/launch";
+ result[2] = "\"Mozilla Firefox 11\"";
+ result[3] = "-new-tab";
+ }
+ }
+
+ }
+ if (result == null)
+ {
+ path = IE_PATH_WINDOWS;
+ File existentialTester = new File(path);
+ if (existentialTester.exists())
+ {
+ result = new String[2];
+ result[0] = path;
+ }
+ }
+ break;
+ case PropertiesAndDirectories.MAC:
+ result = new String[4];
+ result[0] = "/usr/bin/open";
+ result[1] = "-a";
+ result[2] = "firefox";
+ firefoxExists = true;
+ break;
+ case PropertiesAndDirectories.LINUX:
+ result = new String[2];
+ result[0] = FIREFOX_PATH_LINUX;
+ firefoxExists = true;
+ break;
+ default:
+ error(PropertiesAndDirectories.getOsName(), "go(ParsedURL) not supported");
+ break;
+ }
+ if (result != null)
+ {
+ cachedNavigateArgs = result;
+ }
+ }
+ return result;
+ }
+
+
+ /**
+ * Returns true if firefox was found on this system.
+ * @return
+ */
+ @Override
+ public boolean hasFirefox()
+ {
+ getNavigateArgs();//sets firefoxExists if true
+ return firefoxExists;
+ }
+
+
+ /**
+ * Navigate to the purl using the best browser we can find.
+ *
+ * @param purl
+ * @param frame
+ */
+ @Override
+ public void navigate(ParsedURL purl, String frame)
+ {
+ String[] navigateArgs = getNavigateArgs();
+ if (navigateArgs != null && purl != null)
+ {
+ String purlString = purl.toString();
+ int numArgs = navigateArgs.length;
+ navigateArgs[numArgs - 1] = purlString;
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < numArgs; i++)
+ sb.append(navigateArgs[i]).append(' ');
+ Debug.println("navigate: " + sb);
+ try
+ {
+ Process p = Runtime.getRuntime().exec(navigateArgs);
+ }
+ catch (IOException e)
+ {
+ error("navigate() - caught exception: ");
+ e.printStackTrace();
+ }
+ }
+ else
+ error("navigate() - Can't find browser to navigate to.");
+ }
+
+ @Override
+ public int browser()
+ {
+ return APPLICATION;
+ }
+
+ /**
+ * Called at the end of an invocation. Calls System.exit(code).
+ *
+ * @param code
+ * -- 0 for normal. other values are application specific.
+ */
+ @Override
+ public void exit(int code)
+ {
+ System.exit(code);
+ }
+
+ public static boolean isInUse()
+ {
+ return inUse;
+ }
+
+ public static boolean runningInEclipse()
+ {
+ return LaunchType.ECLIPSE == LAUNCH_TYPE_PREF.value();
+ }
+
+ public static boolean runningLocalhost()
+ {
+ return LaunchType.LOCAL_JNLP == LAUNCH_TYPE_PREF.value();
+ }
+
+ /**
+ * Create and show an editor for preferences, iff the MetaPrefSet and PrefSet are non-null. If the
+ * PrefSet is null, a new empty one will be created for the editor to use.
+ *
+ * @return
+ */
+ public Object createPrefsEditor(final boolean createJFrame, final boolean isStandalone)
+ {
+ Object result = null;
+ if (metaPrefSet != null)
+ {
+ if (prefSet == null)
+ prefSet = new PrefSet();
+ result = FundamentalPlatformSpecifics.get().getOrCreatePrefsEditor(metaPrefSet, prefSet, prefsPURL, createJFrame, isStandalone);
+ }
+ return result;
+ }
+
+ /**
+ * Create and show an editor for preferences, iff the MetaPrefSet and PrefSet are non-null. If the
+ * PrefSet is null, a new empty one will be created for the editor to use.
+ *
+ * @return
+ */
+ public Object createPrefsEditor()
+ {
+ return this.createPrefsEditor(true, false);
+ }
+
+ /**
+ *
+ * @return MetaPrefSet for this application, loaded from standard locations.
+ */
+ protected MetaPrefSet metaPrefSet()
+ {
+ return metaPrefSet;
+ }
+
+ @Override
+ public String getApplicationName()
+ {
+ return PropertiesAndDirectories.applicationName;
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/StatusReporter.java b/simplCore/src/ecologylab/appframework/StatusReporter.java
index ff900c2d..3c88f58e 100644
--- a/simplCore/src/ecologylab/appframework/StatusReporter.java
+++ b/simplCore/src/ecologylab/appframework/StatusReporter.java
@@ -1,35 +1,35 @@
-package ecologylab.appframework;
-
-/**
- * Interface for objects that report status to the user.
- *
- * @author andruid
- *
- */
-public interface StatusReporter
-{
- /**
- * Submit a message for display in the status line.
- * If there's nothing showing now, it will be displayed immediately.
- * Otherwise, it will be queued.
- * Uses the default minimum longevity level of 1 * 1/4 second.
- */
- public void display(String msg);
-
- /**
- * Submit a message for display in the status line.
- * If there's nothing showing now, it will be displayed immediately.
- * Otherwise, it will be queued.
- *
- * @param msg String to display.
- * @param priority Measure minimum message longevity of message in units
- * of 1/4 second.
- */
- public void display(String msg, int priority);
-
-
- public void display(String msg, int longevity,
- int progessNumerator, int progessDenominator);
-
-
-}
+package ecologylab.appframework;
+
+/**
+ * Interface for objects that report status to the user.
+ *
+ * @author andruid
+ *
+ */
+public interface StatusReporter
+{
+ /**
+ * Submit a message for display in the status line.
+ * If there's nothing showing now, it will be displayed immediately.
+ * Otherwise, it will be queued.
+ * Uses the default minimum longevity level of 1 * 1/4 second.
+ */
+ public void display(String msg);
+
+ /**
+ * Submit a message for display in the status line.
+ * If there's nothing showing now, it will be displayed immediately.
+ * Otherwise, it will be queued.
+ *
+ * @param msg String to display.
+ * @param priority Measure minimum message longevity of message in units
+ * of 1/4 second.
+ */
+ public void display(String msg, int priority);
+
+
+ public void display(String msg, int longevity,
+ int progessNumerator, int progessDenominator);
+
+
+}
diff --git a/simplCore/src/ecologylab/appframework/TraceSlots.java b/simplCore/src/ecologylab/appframework/TraceSlots.java
index ff8f1d67..ec3aa464 100644
--- a/simplCore/src/ecologylab/appframework/TraceSlots.java
+++ b/simplCore/src/ecologylab/appframework/TraceSlots.java
@@ -1,29 +1,29 @@
-/**
- *
- */
-package ecologylab.appframework;
-
-import ecologylab.generic.Debug;
-
-/**
- * Peephole slots used for tracing concurrent real time deadlocks.
- *
- * @author andruid
- *
- */
-public class TraceSlots extends Debug
-{
- public boolean fatPixelGridRendering;
- public int rolloverRenderStatus;
- public int dragDropEndStatus;
- public int setFocusStatus;
- public int mouseExitStatus;
- static public int rolloverRaiseStatus;
- public int handleMouseEventStatus;
- public int internalFocusStatus;
- public static int renderStatus;
- public int handleMouseEventId;
- static public int pieMenuRaiseStatus;
- static public int pieMenuRenderStatus;
-
-}
+/**
+ *
+ */
+package ecologylab.appframework;
+
+import ecologylab.generic.Debug;
+
+/**
+ * Peephole slots used for tracing concurrent real time deadlocks.
+ *
+ * @author andruid
+ *
+ */
+public class TraceSlots extends Debug
+{
+ public boolean fatPixelGridRendering;
+ public int rolloverRenderStatus;
+ public int dragDropEndStatus;
+ public int setFocusStatus;
+ public int mouseExitStatus;
+ static public int rolloverRaiseStatus;
+ public int handleMouseEventStatus;
+ public int internalFocusStatus;
+ public static int renderStatus;
+ public int handleMouseEventId;
+ static public int pieMenuRaiseStatus;
+ static public int pieMenuRenderStatus;
+
+}
diff --git a/simplCore/src/ecologylab/appframework/UndoRedo.java b/simplCore/src/ecologylab/appframework/UndoRedo.java
index ab94ca36..0e22bab7 100644
--- a/simplCore/src/ecologylab/appframework/UndoRedo.java
+++ b/simplCore/src/ecologylab/appframework/UndoRedo.java
@@ -1,183 +1,183 @@
-package ecologylab.appframework;
-
-import ecologylab.appframework.types.prefs.Pref;
-import ecologylab.appframework.types.prefs.PrefInt;
-import ecologylab.collections.SyncLinkedList;
-import ecologylab.generic.Debug;
-import ecologylab.oodss.logging.MixedInitiativeOp;
-
-/**
- * Undo and Redo Mixed Initiative Operations.
- * @author andruid, alexgrau
- */
-public class UndoRedo extends Debug{
-
- /**
- * Synced Linked List of Undo Operations.
- */
- protected final SyncLinkedList undoStack = new SyncLinkedList();
-
- /**
- * Syned Linked List of Redo Operations
- */
- protected final SyncLinkedList redoStack = new SyncLinkedList();
-
- /**
- * Semaphor Object Used For Undo and Redo
- */
- protected final Object undoRedoSemaphore = new Object();
-
- /**
- * Sets the Int Prefs for the number of Undo/Redo Levels
- */
- protected final PrefInt undoLevels = Pref.usePrefInt(UNDO_LEVELS, DEFAULT_UNDO_LEVELS);
-
- /**
- * Number of possible Undo/Redo levels
- */
- protected static final int DEFAULT_UNDO_LEVELS = 32;
-
- public static final String UNDO_LEVELS = "undo_levels";
-
- protected int humanUndoCount;
- protected int humanRedoCount;
-
- /**
- * Construct an Undo/Redo Object
- */
- public UndoRedo(){
- super();
- }
-
- /**
- * Undo an Operation. Returns the Operations.
- * @return
- */
- public MixedInitiativeOp undo(){
- synchronized (undoRedoSemaphore){
- MixedInitiativeOp op = popUndo();
- if(op == null)
- return null;
- op.performAction(true);
- pushRedo(op);
- return op;
- }
- }
-
- /**
- * Redo an Operation. Returns the Operation.
- * @return
- */
- public MixedInitiativeOp redo(){
- synchronized (undoRedoSemaphore){
- MixedInitiativeOp op = popRedo();
- if (op == null)
- return null;
- op.performAction(false);
- pushUndo(op);
- return op;
- }
- }
-
- /**
- * Pushes an Operation onto the undo stack.
- * Clears the redo stack because a new operation has taken place.
- * @param op
- */
- public MixedInitiativeOp pushOpToUndo(MixedInitiativeOp op){
- pushUndo(op);
- clearRedo();
- return op;
- }
-
- /**
- * Pushes an Operation onto the Undo stack.
- * If too many operations, removes oldest and adds op.
- * @param op
- */
- public void pushUndo(MixedInitiativeOp op){
- synchronized (undoStack){
- while (undoStack.size() >= undoLevels.value()){
- MixedInitiativeOp oldOp = (MixedInitiativeOp) undoStack.removeFirst();
- if (oldOp.isHuman())
- humanUndoCount--;
- oldOp.recycle(false);
- }
- undoStack.addLast(op);
- humanUndoCount++;
- }
- }
-
- /**
- * Pops an Operation from the Undo stack.
- * If empty, returns null.
- * @return
- */
- public MixedInitiativeOp popUndo(){
- synchronized (undoStack){
- return undoStack.isEmpty() ? null : (MixedInitiativeOp) undoStack.removeLast();
- }
- }
-
- /**
- * Peak an Operation from the Undo stack.
- * If empty, returns null.
- * @return
- */
- public MixedInitiativeOp peekUndo(){
- synchronized (undoStack){
- return undoStack.isEmpty() ? null : (MixedInitiativeOp) undoStack.getLast();
- }
- }
-
- /**
- * Pushes an Operation onto the Redo stack.
- * @param op
- */
- private void pushRedo(MixedInitiativeOp op){
- synchronized (redoStack){
- redoStack.addLast(op);
- }
- }
-
- /**
- * Pops an Operation from the Redo stack.
- * If empty, then returns null.
- * @return
- */
- private MixedInitiativeOp popRedo(){
- synchronized (redoStack){
- return redoStack.isEmpty() ? null : (MixedInitiativeOp) redoStack.removeLast();
- }
- }
-
- /**
- * Clears both the undo and redo stacks.
- */
- public synchronized void clear(){
- synchronized (undoStack){
- while (!undoStack.isEmpty()){
- MixedInitiativeOp op = popUndo();
- op.recycle(true);
- }
- }
- synchronized (redoStack){
- while (!redoStack.isEmpty()){
- MixedInitiativeOp op = popRedo();
- op.recycle(true);
- }
- }
- }
-
- /**
- * Clears and recycles the redo stack after a new operation has been done.
- */
- protected void clearRedo(){
- synchronized (redoStack){
- while (!redoStack.isEmpty()){
- MixedInitiativeOp op = popRedo();
- op.recycle(true);
- }
- }
- }
-}
+package ecologylab.appframework;
+
+import ecologylab.appframework.types.prefs.Pref;
+import ecologylab.appframework.types.prefs.PrefInt;
+import ecologylab.collections.SyncLinkedList;
+import ecologylab.generic.Debug;
+import ecologylab.oodss.logging.MixedInitiativeOp;
+
+/**
+ * Undo and Redo Mixed Initiative Operations.
+ * @author andruid, alexgrau
+ */
+public class UndoRedo extends Debug{
+
+ /**
+ * Synced Linked List of Undo Operations.
+ */
+ protected final SyncLinkedList undoStack = new SyncLinkedList();
+
+ /**
+ * Syned Linked List of Redo Operations
+ */
+ protected final SyncLinkedList redoStack = new SyncLinkedList();
+
+ /**
+ * Semaphor Object Used For Undo and Redo
+ */
+ protected final Object undoRedoSemaphore = new Object();
+
+ /**
+ * Sets the Int Prefs for the number of Undo/Redo Levels
+ */
+ protected final PrefInt undoLevels = Pref.usePrefInt(UNDO_LEVELS, DEFAULT_UNDO_LEVELS);
+
+ /**
+ * Number of possible Undo/Redo levels
+ */
+ protected static final int DEFAULT_UNDO_LEVELS = 32;
+
+ public static final String UNDO_LEVELS = "undo_levels";
+
+ protected int humanUndoCount;
+ protected int humanRedoCount;
+
+ /**
+ * Construct an Undo/Redo Object
+ */
+ public UndoRedo(){
+ super();
+ }
+
+ /**
+ * Undo an Operation. Returns the Operations.
+ * @return
+ */
+ public MixedInitiativeOp undo(){
+ synchronized (undoRedoSemaphore){
+ MixedInitiativeOp op = popUndo();
+ if(op == null)
+ return null;
+ op.performAction(true);
+ pushRedo(op);
+ return op;
+ }
+ }
+
+ /**
+ * Redo an Operation. Returns the Operation.
+ * @return
+ */
+ public MixedInitiativeOp redo(){
+ synchronized (undoRedoSemaphore){
+ MixedInitiativeOp op = popRedo();
+ if (op == null)
+ return null;
+ op.performAction(false);
+ pushUndo(op);
+ return op;
+ }
+ }
+
+ /**
+ * Pushes an Operation onto the undo stack.
+ * Clears the redo stack because a new operation has taken place.
+ * @param op
+ */
+ public MixedInitiativeOp pushOpToUndo(MixedInitiativeOp op){
+ pushUndo(op);
+ clearRedo();
+ return op;
+ }
+
+ /**
+ * Pushes an Operation onto the Undo stack.
+ * If too many operations, removes oldest and adds op.
+ * @param op
+ */
+ public void pushUndo(MixedInitiativeOp op){
+ synchronized (undoStack){
+ while (undoStack.size() >= undoLevels.value()){
+ MixedInitiativeOp oldOp = (MixedInitiativeOp) undoStack.removeFirst();
+ if (oldOp.isHuman())
+ humanUndoCount--;
+ oldOp.recycle(false);
+ }
+ undoStack.addLast(op);
+ humanUndoCount++;
+ }
+ }
+
+ /**
+ * Pops an Operation from the Undo stack.
+ * If empty, returns null.
+ * @return
+ */
+ public MixedInitiativeOp popUndo(){
+ synchronized (undoStack){
+ return undoStack.isEmpty() ? null : (MixedInitiativeOp) undoStack.removeLast();
+ }
+ }
+
+ /**
+ * Peak an Operation from the Undo stack.
+ * If empty, returns null.
+ * @return
+ */
+ public MixedInitiativeOp peekUndo(){
+ synchronized (undoStack){
+ return undoStack.isEmpty() ? null : (MixedInitiativeOp) undoStack.getLast();
+ }
+ }
+
+ /**
+ * Pushes an Operation onto the Redo stack.
+ * @param op
+ */
+ private void pushRedo(MixedInitiativeOp op){
+ synchronized (redoStack){
+ redoStack.addLast(op);
+ }
+ }
+
+ /**
+ * Pops an Operation from the Redo stack.
+ * If empty, then returns null.
+ * @return
+ */
+ private MixedInitiativeOp popRedo(){
+ synchronized (redoStack){
+ return redoStack.isEmpty() ? null : (MixedInitiativeOp) redoStack.removeLast();
+ }
+ }
+
+ /**
+ * Clears both the undo and redo stacks.
+ */
+ public synchronized void clear(){
+ synchronized (undoStack){
+ while (!undoStack.isEmpty()){
+ MixedInitiativeOp op = popUndo();
+ op.recycle(true);
+ }
+ }
+ synchronized (redoStack){
+ while (!redoStack.isEmpty()){
+ MixedInitiativeOp op = popRedo();
+ op.recycle(true);
+ }
+ }
+ }
+
+ /**
+ * Clears and recycles the redo stack after a new operation has been done.
+ */
+ protected void clearRedo(){
+ synchronized (redoStack){
+ while (!redoStack.isEmpty()){
+ MixedInitiativeOp op = popRedo();
+ op.recycle(true);
+ }
+ }
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/macos/MacOSApp.java b/simplCore/src/ecologylab/appframework/macos/MacOSApp.java
index a04ea4db..827ee42f 100644
--- a/simplCore/src/ecologylab/appframework/macos/MacOSApp.java
+++ b/simplCore/src/ecologylab/appframework/macos/MacOSApp.java
@@ -1,23 +1,23 @@
-package ecologylab.appframework.macos;
-
-import ecologylab.appframework.MacOSAppHandler;
-
-/**
- * Shadowed no-op version so we can avoid compile errors on non-mac platforms.
- *
- * Make sure if you're on the mac that the ecologylabMacOS project is before ecologylabFundamental.
- *
- * @author andrew
- *
- */
-public class MacOSApp
-{
- /**
- * Shadowed no-op version so we can avoid compile errors on non-mac platforms.
- *
- * @param macOSAppHandler
- */
- public static void addListener(MacOSAppHandler macOSAppHandler)
- {
- }
-}
+package ecologylab.appframework.macos;
+
+import ecologylab.appframework.MacOSAppHandler;
+
+/**
+ * Shadowed no-op version so we can avoid compile errors on non-mac platforms.
+ *
+ * Make sure if you're on the mac that the ecologylabMacOS project is before ecologylabFundamental.
+ *
+ * @author andrew
+ *
+ */
+public class MacOSApp
+{
+ /**
+ * Shadowed no-op version so we can avoid compile errors on non-mac platforms.
+ *
+ * @param macOSAppHandler
+ */
+ public static void addListener(MacOSAppHandler macOSAppHandler)
+ {
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/package.html b/simplCore/src/ecologylab/appframework/package.html
index c7c3054c..f9a7d672 100644
--- a/simplCore/src/ecologylab/appframework/package.html
+++ b/simplCore/src/ecologylab/appframework/package.html
@@ -1,4 +1,4 @@
-
-Interface Ecology Lab Application Development Framework makes
-interfacing with the runtime platform easier.
-
+
+Interface Ecology Lab Application Development Framework makes
+interfacing with the runtime platform easier.
+
diff --git a/simplCore/src/ecologylab/appframework/types/AppFrameworkTranslations.java b/simplCore/src/ecologylab/appframework/types/AppFrameworkTranslations.java
index e3000aea..2f0fdc6f 100644
--- a/simplCore/src/ecologylab/appframework/types/AppFrameworkTranslations.java
+++ b/simplCore/src/ecologylab/appframework/types/AppFrameworkTranslations.java
@@ -1,40 +1,40 @@
-package ecologylab.appframework.types;
-
-import ecologylab.appframework.types.prefs.PrefsTranslationsProvider;
-import ecologylab.generic.Debug;
-import ecologylab.oodss.messages.DefaultServicesTranslations;
-import ecologylab.serialization.SimplTypesScope;
-
-/**
- * Base translations for applications that use the ecologylab appframework and services.
- *
- * @author andruid
- * @author andrew
- */
-public class AppFrameworkTranslations extends Debug
-{
- public static final String PACKAGE_NAME = "ecologylab.appframework.types";
-
- public static final SimplTypesScope inheritedTranslations[] =
- {
- DefaultServicesTranslations.get(),
- PrefsTranslationsProvider.get()
- };
-
-
-
- /**
- * Do not use this accessor.
- */
- private AppFrameworkTranslations()
- {
- }
- /**
- * This accessor will work from anywhere, in any order, and stay efficient.
- * @return
- */
- public static SimplTypesScope get()
- {
- return SimplTypesScope.get(PACKAGE_NAME, inheritedTranslations);
- }
-}
+package ecologylab.appframework.types;
+
+import ecologylab.appframework.types.prefs.PrefsTranslationsProvider;
+import ecologylab.generic.Debug;
+import ecologylab.oodss.messages.DefaultServicesTranslations;
+import ecologylab.serialization.SimplTypesScope;
+
+/**
+ * Base translations for applications that use the ecologylab appframework and services.
+ *
+ * @author andruid
+ * @author andrew
+ */
+public class AppFrameworkTranslations extends Debug
+{
+ public static final String PACKAGE_NAME = "ecologylab.appframework.types";
+
+ public static final SimplTypesScope inheritedTranslations[] =
+ {
+ DefaultServicesTranslations.get(),
+ PrefsTranslationsProvider.get()
+ };
+
+
+
+ /**
+ * Do not use this accessor.
+ */
+ private AppFrameworkTranslations()
+ {
+ }
+ /**
+ * This accessor will work from anywhere, in any order, and stay efficient.
+ * @return
+ */
+ public static SimplTypesScope get()
+ {
+ return SimplTypesScope.get(PACKAGE_NAME, inheritedTranslations);
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/AssetState.java b/simplCore/src/ecologylab/appframework/types/AssetState.java
index 26fcb93c..da87b03f 100644
--- a/simplCore/src/ecologylab/appframework/types/AssetState.java
+++ b/simplCore/src/ecologylab/appframework/types/AssetState.java
@@ -1,56 +1,56 @@
-/**
- *
- */
-package ecologylab.appframework.types;
-
-import ecologylab.serialization.ElementState;
-import ecologylab.serialization.annotations.simpl_scalar;
-import ecologylab.serialization.types.element.IMappable;
-
-/**
- * @author robinson
- *
- */
-public class AssetState extends ElementState implements IMappable
-{
- @simpl_scalar String name;
- @simpl_scalar float version;
-
- public AssetState()
- {
-
- }
- public AssetState(String name)
- {
- this.name = name;
- }
- /**
- * @return Returns the version.
- */
- public float getVersion()
- {
- return version;
- }
-
- /**
- * @param version The version to set.
- */
- public void setVersion(float version)
- {
- this.version = version;
- }
-
- /**
- * @return Returns the id.
- */
- public String getName()
- {
- return name;
- }
-
- @Override
- public String key()
- {
- return name;
- }
-}
+/**
+ *
+ */
+package ecologylab.appframework.types;
+
+import ecologylab.serialization.ElementState;
+import ecologylab.serialization.annotations.simpl_scalar;
+import ecologylab.serialization.types.element.IMappable;
+
+/**
+ * @author robinson
+ *
+ */
+public class AssetState extends ElementState implements IMappable
+{
+ @simpl_scalar String name;
+ @simpl_scalar float version;
+
+ public AssetState()
+ {
+
+ }
+ public AssetState(String name)
+ {
+ this.name = name;
+ }
+ /**
+ * @return Returns the version.
+ */
+ public float getVersion()
+ {
+ return version;
+ }
+
+ /**
+ * @param version The version to set.
+ */
+ public void setVersion(float version)
+ {
+ this.version = version;
+ }
+
+ /**
+ * @return Returns the id.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ @Override
+ public String key()
+ {
+ return name;
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/AssetsState.java b/simplCore/src/ecologylab/appframework/types/AssetsState.java
index 71aeedcd..cef3e96c 100644
--- a/simplCore/src/ecologylab/appframework/types/AssetsState.java
+++ b/simplCore/src/ecologylab/appframework/types/AssetsState.java
@@ -1,60 +1,60 @@
-package ecologylab.appframework.types;
-
-import java.util.Collection;
-import java.util.HashMap;
-
-import ecologylab.serialization.ElementState;
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_map;
-import ecologylab.serialization.annotations.simpl_nowrap;
-
-/**
- * Handles the loading and parsing of the asset version XML file
- *
- * @author robinson
- * @author andruid
- */
-@simpl_inherit public class AssetsState extends ElementState
-{
- @simpl_map("asset")
- @simpl_nowrap
- HashMap assetsMap = new HashMap();
-
- public Collection getAssetStates()
- {
- return assetsMap.values();
- }
-
- /**
- * @param asset
- */
- private void register(AssetState asset)
- {
- assetsMap.put(asset.getName(), asset);
- }
-
- public AssetState lookup(String name)
- {
- return assetsMap.get(name);
- }
-
- public AssetState lookupAndUpdate(String name)
- {
- AssetState asset = lookup(name);
- if (asset == null)
- {
- asset = update(name);
- }
- return asset;
- }
-
- /**
- * @return
- */
- public AssetState update(String name)
- {
- AssetState asset = new AssetState(name);
- register(asset);
- return asset;
- }
+package ecologylab.appframework.types;
+
+import java.util.Collection;
+import java.util.HashMap;
+
+import ecologylab.serialization.ElementState;
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_map;
+import ecologylab.serialization.annotations.simpl_nowrap;
+
+/**
+ * Handles the loading and parsing of the asset version XML file
+ *
+ * @author robinson
+ * @author andruid
+ */
+@simpl_inherit public class AssetsState extends ElementState
+{
+ @simpl_map("asset")
+ @simpl_nowrap
+ HashMap assetsMap = new HashMap();
+
+ public Collection getAssetStates()
+ {
+ return assetsMap.values();
+ }
+
+ /**
+ * @param asset
+ */
+ private void register(AssetState asset)
+ {
+ assetsMap.put(asset.getName(), asset);
+ }
+
+ public AssetState lookup(String name)
+ {
+ return assetsMap.get(name);
+ }
+
+ public AssetState lookupAndUpdate(String name)
+ {
+ AssetState asset = lookup(name);
+ if (asset == null)
+ {
+ asset = update(name);
+ }
+ return asset;
+ }
+
+ /**
+ * @return
+ */
+ public AssetState update(String name)
+ {
+ AssetState asset = new AssetState(name);
+ register(asset);
+ return asset;
+ }
}
\ No newline at end of file
diff --git a/simplCore/src/ecologylab/appframework/types/AssetsTranslations.java b/simplCore/src/ecologylab/appframework/types/AssetsTranslations.java
index 013ec9a3..9faa0349 100644
--- a/simplCore/src/ecologylab/appframework/types/AssetsTranslations.java
+++ b/simplCore/src/ecologylab/appframework/types/AssetsTranslations.java
@@ -1,35 +1,35 @@
-/**
- *
- */
-package ecologylab.appframework.types;
-
-import ecologylab.generic.Debug;
-import ecologylab.serialization.SimplTypesScope;
-
-/**
- * Simple translations used just for loading the assets.xml file.
- *
- * @author robinson
- * @author andruid
- */
-public class AssetsTranslations extends Debug
-{
- public static final String PACKAGE_NAME = "ecologylab.assets.types";
-
- public static final Class> TRANSLATIONS[] =
- {
- AssetsState.class,
- AssetState.class,
-
- };
-
- /**
- * Get existing TranslationSpace with this name, or create a new one, and map it.
- *
- * @return TranslationSpace with simple translations used just for loading the assets.xml file.
- */
- public static SimplTypesScope get()
- {
- return SimplTypesScope.get(PACKAGE_NAME, TRANSLATIONS);
- }
-}
+/**
+ *
+ */
+package ecologylab.appframework.types;
+
+import ecologylab.generic.Debug;
+import ecologylab.serialization.SimplTypesScope;
+
+/**
+ * Simple translations used just for loading the assets.xml file.
+ *
+ * @author robinson
+ * @author andruid
+ */
+public class AssetsTranslations extends Debug
+{
+ public static final String PACKAGE_NAME = "ecologylab.assets.types";
+
+ public static final Class> TRANSLATIONS[] =
+ {
+ AssetsState.class,
+ AssetState.class,
+
+ };
+
+ /**
+ * Get existing TranslationSpace with this name, or create a new one, and map it.
+ *
+ * @return TranslationSpace with simple translations used just for loading the assets.xml file.
+ */
+ public static SimplTypesScope get()
+ {
+ return SimplTypesScope.get(PACKAGE_NAME, TRANSLATIONS);
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/package.html b/simplCore/src/ecologylab/appframework/types/package.html
index b5bc4b46..ae40a564 100644
--- a/simplCore/src/ecologylab/appframework/types/package.html
+++ b/simplCore/src/ecologylab/appframework/types/package.html
@@ -1,4 +1,4 @@
-
-Type declarations for the Interface Ecology Lab Application
-Development Framework.
-
+
+Type declarations for the Interface Ecology Lab Application
+Development Framework.
+
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/Choice.java b/simplCore/src/ecologylab/appframework/types/prefs/Choice.java
index 6d43d952..441c3375 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/Choice.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/Choice.java
@@ -1,58 +1,58 @@
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.ElementState;
-import ecologylab.serialization.annotations.simpl_scalar;
-
-/**
- * Multi-choice option for a preference.
- * This should be used for options that have
- * non-standard text associated with them.
- * (Standard text would be "Yes"/"No" for Booleans.)
- */
-abstract public class Choice extends ElementState
-{
- /**
- * The name for a choice
- */
- @simpl_scalar String name;
- /**
- * The label text for a choice
- */
- @simpl_scalar String label;
- //@xml_attribute T value;
-
- public Choice()
- {
- super();
- }
-
- /**
- * Get the value of a choice. Type-specific.
- */
- public abstract T getValue();
-
- /**
- * Set the value of a choice. Type-specific.
- */
- public abstract void setValue(T newValue);
-
- /**
- * Get the name of a choice
- *
- * @return Name of a choice
- */
- public String getName()
- {
- return this.name;
- }
-
- /**
- * Get the label of a choice
- *
- * @return Label of a choice
- */
- public String getLabel()
- {
- return this.label;
- }
-}
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.ElementState;
+import ecologylab.serialization.annotations.simpl_scalar;
+
+/**
+ * Multi-choice option for a preference.
+ * This should be used for options that have
+ * non-standard text associated with them.
+ * (Standard text would be "Yes"/"No" for Booleans.)
+ */
+abstract public class Choice extends ElementState
+{
+ /**
+ * The name for a choice
+ */
+ @simpl_scalar String name;
+ /**
+ * The label text for a choice
+ */
+ @simpl_scalar String label;
+ //@xml_attribute T value;
+
+ public Choice()
+ {
+ super();
+ }
+
+ /**
+ * Get the value of a choice. Type-specific.
+ */
+ public abstract T getValue();
+
+ /**
+ * Set the value of a choice. Type-specific.
+ */
+ public abstract void setValue(T newValue);
+
+ /**
+ * Get the name of a choice
+ *
+ * @return Name of a choice
+ */
+ public String getName()
+ {
+ return this.name;
+ }
+
+ /**
+ * Get the label of a choice
+ *
+ * @return Label of a choice
+ */
+ public String getLabel()
+ {
+ return this.label;
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/ChoiceBoolean.java b/simplCore/src/ecologylab/appframework/types/prefs/ChoiceBoolean.java
index 35e83906..2fb4dbd7 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/ChoiceBoolean.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/ChoiceBoolean.java
@@ -1,53 +1,53 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-
-
-/**
- * A Boolean Choice object, for a multi-choice preference.
- * @author awebb
- *
- */
-@simpl_inherit
-public class ChoiceBoolean extends Choice
-{
- /**
- * Value of the choice
- */
- @simpl_scalar boolean value;
-
-
- /**
- *
- */
- public ChoiceBoolean()
- {
- super();
- }
-
- /**
- * Get the value of a choice
- *
- * @return value Value of the choice
- */
- @Override
- public Boolean getValue()
- {
- return value;
- }
-
- /**
- * Set the value of a choice.
- *
- * @param newValue New value the choice will be set to.
- */
- @Override public void setValue(Boolean newValue)
- {
- this.value = newValue;
- }
-
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+
+
+/**
+ * A Boolean Choice object, for a multi-choice preference.
+ * @author awebb
+ *
+ */
+@simpl_inherit
+public class ChoiceBoolean extends Choice
+{
+ /**
+ * Value of the choice
+ */
+ @simpl_scalar boolean value;
+
+
+ /**
+ *
+ */
+ public ChoiceBoolean()
+ {
+ super();
+ }
+
+ /**
+ * Get the value of a choice
+ *
+ * @return value Value of the choice
+ */
+ @Override
+ public Boolean getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Set the value of a choice.
+ *
+ * @param newValue New value the choice will be set to.
+ */
+ @Override public void setValue(Boolean newValue)
+ {
+ this.value = newValue;
+ }
+
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/ChoiceFloat.java b/simplCore/src/ecologylab/appframework/types/prefs/ChoiceFloat.java
index c6c4467b..12480b82 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/ChoiceFloat.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/ChoiceFloat.java
@@ -1,43 +1,43 @@
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-
-/**
- * A Float Choice object, for a multi-choice preference.
- * @author awebb
- *
- */
-@simpl_inherit
-public class ChoiceFloat extends Choice
-{
- /**
- * Value of the choice
- */
- @simpl_scalar float value;
-
- public ChoiceFloat()
- {
- super();
- }
-
- /**
- * Get the value of a choice
- *
- * @return value Value of the choice
- */
- @Override public void setValue(Float newValue)
- {
- this.value = newValue;
- }
-
- /**
- * Set the value of a choice.
- *
- * @param newValue New value the choice will be set to.
- */
- @Override public Float getValue()
- {
- return this.value;
- }
-}
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+
+/**
+ * A Float Choice object, for a multi-choice preference.
+ * @author awebb
+ *
+ */
+@simpl_inherit
+public class ChoiceFloat extends Choice
+{
+ /**
+ * Value of the choice
+ */
+ @simpl_scalar float value;
+
+ public ChoiceFloat()
+ {
+ super();
+ }
+
+ /**
+ * Get the value of a choice
+ *
+ * @return value Value of the choice
+ */
+ @Override public void setValue(Float newValue)
+ {
+ this.value = newValue;
+ }
+
+ /**
+ * Set the value of a choice.
+ *
+ * @param newValue New value the choice will be set to.
+ */
+ @Override public Float getValue()
+ {
+ return this.value;
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/ChoiceInt.java b/simplCore/src/ecologylab/appframework/types/prefs/ChoiceInt.java
index 2d19339a..c60714db 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/ChoiceInt.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/ChoiceInt.java
@@ -1,43 +1,43 @@
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-
-/**
- * An Integer Choice object, for a multi-choice preference.
- * @author awebb
- *
- */
-@simpl_inherit
-public class ChoiceInt extends Choice
-{
- /**
- * Value of the choice
- */
- @simpl_scalar int value;
-
- public ChoiceInt()
- {
- super();
- }
-
- /**
- * Get the value of a choice
- *
- * @return value Value of the choice
- */
- @Override public void setValue(Integer newValue)
- {
- this.value = newValue;
- }
-
- /**
- * Set the value of a choice.
- *
- * @param newValue New value the choice will be set to.
- */
- @Override public Integer getValue()
- {
- return this.value;
- }
-}
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+
+/**
+ * An Integer Choice object, for a multi-choice preference.
+ * @author awebb
+ *
+ */
+@simpl_inherit
+public class ChoiceInt extends Choice
+{
+ /**
+ * Value of the choice
+ */
+ @simpl_scalar int value;
+
+ public ChoiceInt()
+ {
+ super();
+ }
+
+ /**
+ * Get the value of a choice
+ *
+ * @return value Value of the choice
+ */
+ @Override public void setValue(Integer newValue)
+ {
+ this.value = newValue;
+ }
+
+ /**
+ * Set the value of a choice.
+ *
+ * @param newValue New value the choice will be set to.
+ */
+ @Override public Integer getValue()
+ {
+ return this.value;
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/MetaPref.java b/simplCore/src/ecologylab/appframework/types/prefs/MetaPref.java
index ef116310..e9451b57 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/MetaPref.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/MetaPref.java
@@ -1,516 +1,516 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-
-import ecologylab.collections.Scope;
-import ecologylab.serialization.ElementState;
-import ecologylab.serialization.TranslationContext;
-import ecologylab.serialization.annotations.simpl_classes;
-import ecologylab.serialization.annotations.simpl_collection;
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-import ecologylab.serialization.annotations.simpl_tag;
-import ecologylab.serialization.types.ScalarType;
-
-/**
- * Metadata about a Preference. Defines information to enable editing the Preference.
- *
- * @author andruid
- *
- */
-
-@simpl_inherit
-public abstract class MetaPref extends ElementState implements WidgetTypes
-{
- /** The global registry of Pref objects. Used for providing lookup services. */
- static final Scope allMetaPrefsMap = new Scope();
-
- /**
- * Unique identifier for Preference name with convenient lookup in automatically generated
- * HashMap.
- */
- @simpl_tag("id")
- @simpl_scalar
- String m_id;
-
- /**
- * This is the short text that appears in the Swing panel for editing the value.
- */
- @simpl_scalar
- String description;
-
- /**
- * This is longer text about that describes what the Preference does and more about the
- * implications of its value.
- */
- @simpl_scalar
- String helpText;
-
- /**
- * Type of graphical user interface component used to interact with it. Must be a constant defined
- * in the interface WidgetTypes If this value is left as null, it should default to TEXT_FIELD.
- */
- @simpl_scalar
- String widget;
-
- /**
- * Categories enable tabbed panes of preferences to be edited.
- */
- @simpl_scalar
- String category;
-
- /**
- * Whether or not the application has to restart for this pref change to take effect.
- */
- @simpl_scalar
- boolean requiresRestart;
-
- /**
- * optional; for preferences with three or more choices
- */
- @simpl_collection
- @simpl_classes(
- { ChoiceBoolean.class, ChoiceFloat.class, ChoiceInt.class })
- ArrayList> choices;
-
- ScalarType scalarType;
-
- /**
- * LinkedHashMap to make locating exact choices easier
- */
- private LinkedHashMap> choiceList;
-
- ValueChangedListener valueChangedListener;
-
- // @xml_attribute T defaultValue;
-
- // @xml_nested RangeState range;
- /**
- * Instantiate.
- *
- * @param scalarType
- * TODO
- */
- public MetaPref(ScalarType scalarType)
- {
- super();
- this.scalarType = scalarType;
- }
-
- /**
- * Gets the default value of a MetaPref; type-specific behavior.
- *
- * @return Default value of MetaPref
- */
- public abstract T getDefaultValue();
-
- /**
- * Gets the min value of the range of a MetaPref.
- *
- * @return Min value of a MetaPref
- */
- public abstract T getMinValue();
-
- /**
- * Gets the max value of the range of a MetaPref.
- *
- * @return Max value of a MetaPref
- */
- public abstract T getMaxValue();
-
- /**
- * Gets the category for a MetaPref.
- *
- * @return Category of MetaPref
- */
- public String getCategory()
- {
- return category;
- }
-
- /**
- * Gets the description for a MetaPref.
- *
- * @return Description of MetaPref
- */
- public String getDescription()
- {
- String result = description;
- if (requiresRestart)
- result += "
Requires restart to take effect.";
- return result;
- }
-
- /**
- * Gets the help text for a MetaPref.
- *
- * @return Help Text of MetaPref
- */
- public String getHelpText()
- {
- return helpText;
- }
-
- /**
- * Gets the ID of a MetaPref. This is a unique identifier.
- *
- * @return ID (unique) of MetaPref.
- */
- public String getID()
- {
- return m_id;
- }
-
- /**
- * Gets the Choices of a MetaPref. This is optional and may be null.
- *
- * @return ID (unique) of MetaPref.
- */
- public ArrayList> getChoices()
- {
- return choices;
- }
-
- /**
- * Returns true if the metaPref has choices. False otherwise
- *
- * @return
- */
- public boolean hasChoices()
- {
- return choices != null;
- }
-
- /**
- * Get a Choice from the list of choices, whose value matches the value passed in.
- *
- * @param value
- * Value to find
- * @return Choice whose value equals the passed in value
- */
- public Choice getChoiceByValue(String value)
- {
- if (choiceList == null)
- populateChoiceList();
- return choiceList.get(value);
- }
-
- /**
- * Get Choice's name, for a choice whose value that matches the given value.
- *
- * @param value
- * @return Name of choice
- */
- public String getChoiceNameByValue(String value)
- {
- return getChoiceByValue(value).getName();
- }
-
- /**
- * Get Choice's name, for the choice at the given index.
- *
- * @param index
- * @return Name of choice
- */
- public String getChoiceNameByIndex(int index)
- {
- return choices.get(index).getName();
- }
-
- /**
- * Get the Choice at the given index.
- *
- * @param index
- * @return Name of choice
- */
- public Choice getChoiceByIndex(int index)
- {
- return choices.get(index);
- }
-
- /**
- * Get the index of a given Choice.
- *
- * @param choice
- * Given choice
- * @return Index of Choice in choices
- */
- public int getIndexByChoice(Choice choice)
- {
- if (choiceList == null)
- populateChoiceList();
- return choices.indexOf(choice);
- }
-
- /**
- * Get the index of a Choice with the given value.
- *
- * @param value
- * @return index of Choice with given value
- */
- public int getIndexByValue(String value)
- {
- Choice thisChoice = getChoiceByValue(value);
- return getIndexByChoice(thisChoice);
- }
-
- /**
- * Populate choiceList; this allows for easy searching by value.
- */
- private void populateChoiceList()
- {
- choiceList = new LinkedHashMap>();
- for (Choice choice : this.choices)
- {
- choiceList.put(choice.getValue().toString(), choice);
- }
- }
-
- /**
- * Gives printed output showing id, description, category, helpText, widget, default value, and
- * choices for a MetaPref.
- */
- public void print()
- {
- println(this.m_id + '\n' + this.description + '\n' + this.category + '\n' + this.helpText
- + '\n' + this.widget);
- println("" + this.getDefaultValue());
- if (choices != null)
- {
- for (Choice choice : choices)
- {
- println("Choice: " + choice.name + ", " + choice.label);
- }
- }
- println("\n");
- }
-
- /**
- * Returns whether or not a widget uses radio buttons.
- *
- * @return True = Uses radio buttons. False = Doesn't.
- */
- public boolean widgetIsRadio()
- {
- if (RADIO_BUTTONS.equals(widget))
- return true;
- return false;
- }
-
- /**
- * Returns whether or not a widget uses a slider.
- *
- * @return True = Uses a slider. False = Doesn't.
- */
- public boolean widgetIsSlider()
- {
- if (SLIDER.equals(widget))
- return true;
- return false;
- }
-
- /**
- * Returns whether or not a widget uses a spinner.
- *
- * @return True = Uses a spinner. False = Doesn't.
- */
- public boolean widgetIsSpinner()
- {
- if (SPINNER.equals(widget))
- return true;
- return false;
- }
-
- /**
- * Returns whether or not a widget uses one or more text fields.
- *
- * @return True = Uses text field(s). False = Doesn't.
- */
- public boolean widgetIsTextField()
- {
- if (TEXT_FIELD.equals(widget))
- return true;
- return false;
- }
-
- /**
- * Returns whether or not a widget uses check boxes.
- *
- * @return True = Uses check boxes. False = Doesn't.
- */
- public boolean widgetIsCheckBox()
- {
- if (CHECK_BOX.equals(widget))
- return true;
- return false;
- }
-
- /**
- * Returns whether or not a widget uses a drop down menu.
- *
- * @return True = Uses a drop down menu. False = Doesn't.
- */
- public boolean widgetIsDropDown()
- {
- if (DROP_DOWN.equals(widget))
- return true;
- return false;
- }
-
- /**
- * Returns whether or not a widget uses a color chooser.
- *
- * @return True = Uses a color chooser. False = Doesn't.
- */
- public boolean widgetIsColorChooser()
- {
- if (COLOR_CHOOSER.equals(widget))
- return true;
- return false;
- }
-
- /**
- * Returns whether or not a widget uses a file chooser.
- *
- * @return True = Uses a file chooser. False = Doesn't.
- */
- public boolean widgetIsFileChooser()
- {
- if (FILE_CHOOSER.equals(widget))
- return true;
- return false;
- }
-
- /**
- * Construct a new instance of the Pref that matches this.
- *
- * @return
- */
- protected abstract Pref getPrefInstance();
-
- /**
- * Create an instance of our associated type, from a String.
- *
- * @param string
- * @return
- */
- public T getInstance(String string)
- {
- return scalarType.getInstance(string);
- }
-
- public T getInstance(T value)
- {
- return value;
- }
-
- /**
- * Construct a new instance of the Pref that matches this. Use this to fill-in the default value.
- *
- * @return
- */
- public Pref getDefaultPrefInstance()
- {
- Pref result = getPrefInstance();
- result.name = m_id;
-
- result.setValue(this.getDefaultValue());
- return result;
- }
-
- /**
- * Get the Pref object associated with this. That is, look for one in the registry. Return it if
- * there is one. Otherwise, get a default Pref based on this, register it, and return it.
- *
- * @return The Pref object associated with this MetaPref.
- */
- public Pref getAssociatedPref()
- {
- Pref result = Pref.lookupPref(m_id);
- if (result == null)
- {
- result = getDefaultPrefInstance();
- result.register();
- }
- return result;
- }
-
- /**
- * Set object that receives a callback when the value of a Pref is changed through the
- * PrefsEditor.
- *
- * @param valueChangedListener
- */
- public void setValueChangedListener(ValueChangedListener valueChangedListener)
- {
- this.valueChangedListener = valueChangedListener;
- }
-
- /**
- * Set object that receives a callback when the value of a Pref is changed through the
- * PrefsEditor.
- *
- * @param valueChangedListener
- */
- public static void setValueChangedListener(String metaPrefId,
- ValueChangedListener valueChangedListener)
- {
- MetaPref metaPref = lookup(metaPrefId);
- if (metaPref != null)
- metaPref.setValueChangedListener(valueChangedListener);
- }
-
- /**
- * Create an entry for this in the allMetaPrefsMap.
- *
- */
- void register()
- {
- allMetaPrefsMap.put(this.m_id, this);
- }
-
- /**
- * Look up a MetaPref by name in the map of all MetaPrefs
- *
- * @param id
- * Name of MetaPref
- *
- * @return MetaPref with the given id
- */
- public static MetaPref lookup(String id)
- {
- MetaPref metaPref = allMetaPrefsMap.get(id);
- return metaPref;
- }
-
- public ValueChangedListener getValueChangedListener()
- {
- return valueChangedListener;
- }
-
- @Override
- public void deserializationPostHook(TranslationContext translationContext, Object object)
- {
- MetaPref metaPref = (MetaPref) object;
-
- if (metaPref.parent() instanceof MetaPrefSet)
- {
- ((MetaPrefSet) metaPref.parent()).addEntryToCategoryMap(metaPref);
- metaPref.getAssociatedPref(); // create one if needed
- }
- else
- {
- weird("parent of metaPref should be MetaPrefSet.");
- }
- }
-
- /*
- * public boolean isWithinRange(T newValue) { return (range == null) ? true :
- * range.isWithinRange(newValue); }
- */
-
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+import ecologylab.collections.Scope;
+import ecologylab.serialization.ElementState;
+import ecologylab.serialization.TranslationContext;
+import ecologylab.serialization.annotations.simpl_classes;
+import ecologylab.serialization.annotations.simpl_collection;
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+import ecologylab.serialization.annotations.simpl_tag;
+import ecologylab.serialization.types.ScalarType;
+
+/**
+ * Metadata about a Preference. Defines information to enable editing the Preference.
+ *
+ * @author andruid
+ *
+ */
+
+@simpl_inherit
+public abstract class MetaPref extends ElementState implements WidgetTypes
+{
+ /** The global registry of Pref objects. Used for providing lookup services. */
+ static final Scope allMetaPrefsMap = new Scope();
+
+ /**
+ * Unique identifier for Preference name with convenient lookup in automatically generated
+ * HashMap.
+ */
+ @simpl_tag("id")
+ @simpl_scalar
+ String m_id;
+
+ /**
+ * This is the short text that appears in the Swing panel for editing the value.
+ */
+ @simpl_scalar
+ String description;
+
+ /**
+ * This is longer text about that describes what the Preference does and more about the
+ * implications of its value.
+ */
+ @simpl_scalar
+ String helpText;
+
+ /**
+ * Type of graphical user interface component used to interact with it. Must be a constant defined
+ * in the interface WidgetTypes If this value is left as null, it should default to TEXT_FIELD.
+ */
+ @simpl_scalar
+ String widget;
+
+ /**
+ * Categories enable tabbed panes of preferences to be edited.
+ */
+ @simpl_scalar
+ String category;
+
+ /**
+ * Whether or not the application has to restart for this pref change to take effect.
+ */
+ @simpl_scalar
+ boolean requiresRestart;
+
+ /**
+ * optional; for preferences with three or more choices
+ */
+ @simpl_collection
+ @simpl_classes(
+ { ChoiceBoolean.class, ChoiceFloat.class, ChoiceInt.class })
+ ArrayList> choices;
+
+ ScalarType scalarType;
+
+ /**
+ * LinkedHashMap to make locating exact choices easier
+ */
+ private LinkedHashMap> choiceList;
+
+ ValueChangedListener valueChangedListener;
+
+ // @xml_attribute T defaultValue;
+
+ // @xml_nested RangeState range;
+ /**
+ * Instantiate.
+ *
+ * @param scalarType
+ * TODO
+ */
+ public MetaPref(ScalarType scalarType)
+ {
+ super();
+ this.scalarType = scalarType;
+ }
+
+ /**
+ * Gets the default value of a MetaPref; type-specific behavior.
+ *
+ * @return Default value of MetaPref
+ */
+ public abstract T getDefaultValue();
+
+ /**
+ * Gets the min value of the range of a MetaPref.
+ *
+ * @return Min value of a MetaPref
+ */
+ public abstract T getMinValue();
+
+ /**
+ * Gets the max value of the range of a MetaPref.
+ *
+ * @return Max value of a MetaPref
+ */
+ public abstract T getMaxValue();
+
+ /**
+ * Gets the category for a MetaPref.
+ *
+ * @return Category of MetaPref
+ */
+ public String getCategory()
+ {
+ return category;
+ }
+
+ /**
+ * Gets the description for a MetaPref.
+ *
+ * @return Description of MetaPref
+ */
+ public String getDescription()
+ {
+ String result = description;
+ if (requiresRestart)
+ result += "
Requires restart to take effect.";
+ return result;
+ }
+
+ /**
+ * Gets the help text for a MetaPref.
+ *
+ * @return Help Text of MetaPref
+ */
+ public String getHelpText()
+ {
+ return helpText;
+ }
+
+ /**
+ * Gets the ID of a MetaPref. This is a unique identifier.
+ *
+ * @return ID (unique) of MetaPref.
+ */
+ public String getID()
+ {
+ return m_id;
+ }
+
+ /**
+ * Gets the Choices of a MetaPref. This is optional and may be null.
+ *
+ * @return ID (unique) of MetaPref.
+ */
+ public ArrayList> getChoices()
+ {
+ return choices;
+ }
+
+ /**
+ * Returns true if the metaPref has choices. False otherwise
+ *
+ * @return
+ */
+ public boolean hasChoices()
+ {
+ return choices != null;
+ }
+
+ /**
+ * Get a Choice from the list of choices, whose value matches the value passed in.
+ *
+ * @param value
+ * Value to find
+ * @return Choice whose value equals the passed in value
+ */
+ public Choice getChoiceByValue(String value)
+ {
+ if (choiceList == null)
+ populateChoiceList();
+ return choiceList.get(value);
+ }
+
+ /**
+ * Get Choice's name, for a choice whose value that matches the given value.
+ *
+ * @param value
+ * @return Name of choice
+ */
+ public String getChoiceNameByValue(String value)
+ {
+ return getChoiceByValue(value).getName();
+ }
+
+ /**
+ * Get Choice's name, for the choice at the given index.
+ *
+ * @param index
+ * @return Name of choice
+ */
+ public String getChoiceNameByIndex(int index)
+ {
+ return choices.get(index).getName();
+ }
+
+ /**
+ * Get the Choice at the given index.
+ *
+ * @param index
+ * @return Name of choice
+ */
+ public Choice getChoiceByIndex(int index)
+ {
+ return choices.get(index);
+ }
+
+ /**
+ * Get the index of a given Choice.
+ *
+ * @param choice
+ * Given choice
+ * @return Index of Choice in choices
+ */
+ public int getIndexByChoice(Choice choice)
+ {
+ if (choiceList == null)
+ populateChoiceList();
+ return choices.indexOf(choice);
+ }
+
+ /**
+ * Get the index of a Choice with the given value.
+ *
+ * @param value
+ * @return index of Choice with given value
+ */
+ public int getIndexByValue(String value)
+ {
+ Choice thisChoice = getChoiceByValue(value);
+ return getIndexByChoice(thisChoice);
+ }
+
+ /**
+ * Populate choiceList; this allows for easy searching by value.
+ */
+ private void populateChoiceList()
+ {
+ choiceList = new LinkedHashMap>();
+ for (Choice choice : this.choices)
+ {
+ choiceList.put(choice.getValue().toString(), choice);
+ }
+ }
+
+ /**
+ * Gives printed output showing id, description, category, helpText, widget, default value, and
+ * choices for a MetaPref.
+ */
+ public void print()
+ {
+ println(this.m_id + '\n' + this.description + '\n' + this.category + '\n' + this.helpText
+ + '\n' + this.widget);
+ println("" + this.getDefaultValue());
+ if (choices != null)
+ {
+ for (Choice choice : choices)
+ {
+ println("Choice: " + choice.name + ", " + choice.label);
+ }
+ }
+ println("\n");
+ }
+
+ /**
+ * Returns whether or not a widget uses radio buttons.
+ *
+ * @return True = Uses radio buttons. False = Doesn't.
+ */
+ public boolean widgetIsRadio()
+ {
+ if (RADIO_BUTTONS.equals(widget))
+ return true;
+ return false;
+ }
+
+ /**
+ * Returns whether or not a widget uses a slider.
+ *
+ * @return True = Uses a slider. False = Doesn't.
+ */
+ public boolean widgetIsSlider()
+ {
+ if (SLIDER.equals(widget))
+ return true;
+ return false;
+ }
+
+ /**
+ * Returns whether or not a widget uses a spinner.
+ *
+ * @return True = Uses a spinner. False = Doesn't.
+ */
+ public boolean widgetIsSpinner()
+ {
+ if (SPINNER.equals(widget))
+ return true;
+ return false;
+ }
+
+ /**
+ * Returns whether or not a widget uses one or more text fields.
+ *
+ * @return True = Uses text field(s). False = Doesn't.
+ */
+ public boolean widgetIsTextField()
+ {
+ if (TEXT_FIELD.equals(widget))
+ return true;
+ return false;
+ }
+
+ /**
+ * Returns whether or not a widget uses check boxes.
+ *
+ * @return True = Uses check boxes. False = Doesn't.
+ */
+ public boolean widgetIsCheckBox()
+ {
+ if (CHECK_BOX.equals(widget))
+ return true;
+ return false;
+ }
+
+ /**
+ * Returns whether or not a widget uses a drop down menu.
+ *
+ * @return True = Uses a drop down menu. False = Doesn't.
+ */
+ public boolean widgetIsDropDown()
+ {
+ if (DROP_DOWN.equals(widget))
+ return true;
+ return false;
+ }
+
+ /**
+ * Returns whether or not a widget uses a color chooser.
+ *
+ * @return True = Uses a color chooser. False = Doesn't.
+ */
+ public boolean widgetIsColorChooser()
+ {
+ if (COLOR_CHOOSER.equals(widget))
+ return true;
+ return false;
+ }
+
+ /**
+ * Returns whether or not a widget uses a file chooser.
+ *
+ * @return True = Uses a file chooser. False = Doesn't.
+ */
+ public boolean widgetIsFileChooser()
+ {
+ if (FILE_CHOOSER.equals(widget))
+ return true;
+ return false;
+ }
+
+ /**
+ * Construct a new instance of the Pref that matches this.
+ *
+ * @return
+ */
+ protected abstract Pref getPrefInstance();
+
+ /**
+ * Create an instance of our associated type, from a String.
+ *
+ * @param string
+ * @return
+ */
+ public T getInstance(String string)
+ {
+ return scalarType.getInstance(string);
+ }
+
+ public T getInstance(T value)
+ {
+ return value;
+ }
+
+ /**
+ * Construct a new instance of the Pref that matches this. Use this to fill-in the default value.
+ *
+ * @return
+ */
+ public Pref getDefaultPrefInstance()
+ {
+ Pref result = getPrefInstance();
+ result.name = m_id;
+
+ result.setValue(this.getDefaultValue());
+ return result;
+ }
+
+ /**
+ * Get the Pref object associated with this. That is, look for one in the registry. Return it if
+ * there is one. Otherwise, get a default Pref based on this, register it, and return it.
+ *
+ * @return The Pref object associated with this MetaPref.
+ */
+ public Pref getAssociatedPref()
+ {
+ Pref result = Pref.lookupPref(m_id);
+ if (result == null)
+ {
+ result = getDefaultPrefInstance();
+ result.register();
+ }
+ return result;
+ }
+
+ /**
+ * Set object that receives a callback when the value of a Pref is changed through the
+ * PrefsEditor.
+ *
+ * @param valueChangedListener
+ */
+ public void setValueChangedListener(ValueChangedListener valueChangedListener)
+ {
+ this.valueChangedListener = valueChangedListener;
+ }
+
+ /**
+ * Set object that receives a callback when the value of a Pref is changed through the
+ * PrefsEditor.
+ *
+ * @param valueChangedListener
+ */
+ public static void setValueChangedListener(String metaPrefId,
+ ValueChangedListener valueChangedListener)
+ {
+ MetaPref metaPref = lookup(metaPrefId);
+ if (metaPref != null)
+ metaPref.setValueChangedListener(valueChangedListener);
+ }
+
+ /**
+ * Create an entry for this in the allMetaPrefsMap.
+ *
+ */
+ void register()
+ {
+ allMetaPrefsMap.put(this.m_id, this);
+ }
+
+ /**
+ * Look up a MetaPref by name in the map of all MetaPrefs
+ *
+ * @param id
+ * Name of MetaPref
+ *
+ * @return MetaPref with the given id
+ */
+ public static MetaPref lookup(String id)
+ {
+ MetaPref metaPref = allMetaPrefsMap.get(id);
+ return metaPref;
+ }
+
+ public ValueChangedListener getValueChangedListener()
+ {
+ return valueChangedListener;
+ }
+
+ @Override
+ public void deserializationPostHook(TranslationContext translationContext, Object object)
+ {
+ MetaPref metaPref = (MetaPref) object;
+
+ if (metaPref.parent() instanceof MetaPrefSet)
+ {
+ ((MetaPrefSet) metaPref.parent()).addEntryToCategoryMap(metaPref);
+ metaPref.getAssociatedPref(); // create one if needed
+ }
+ else
+ {
+ weird("parent of metaPref should be MetaPrefSet.");
+ }
+ }
+
+ /*
+ * public boolean isWithinRange(T newValue) { return (range == null) ? true :
+ * range.isWithinRange(newValue); }
+ */
+
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefBoolean.java b/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefBoolean.java
index cdc9774e..2abdea14 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefBoolean.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefBoolean.java
@@ -1,92 +1,92 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-import ecologylab.serialization.types.ScalarType;
-import ecologylab.serialization.types.TypeRegistry;
-
-/**
- * Metadata about a Boolean Preference.
- * Defines information to enable editing the Preference.
- *
- * @author andruid
- *
- */
-@simpl_inherit
-public class MetaPrefBoolean extends MetaPref
-{
- /**
- * Default value for this MetaPref
- */
- @simpl_scalar boolean defaultValue;
-
- public static final ScalarType BOOLEAN_SCALAR_TYPE = TypeRegistry.getScalarType(boolean.class);
-
- /**
- * Instantiate.
- */
- public MetaPrefBoolean()
- {
- super(BOOLEAN_SCALAR_TYPE);
- }
-
- /**
- * Gets the default value of a MetaPref.
- *
- * @return Default value of MetaPref
- */
- @Override
- public Boolean getDefaultValue()
- {
- return defaultValue;
- }
-
- /**
- * Construct a new instance of the Pref that matches this.
- * Use this to fill-in the default value.
- *
- * @return new Pref instance
- */
- protected @Override Pref getPrefInstance()
- {
- return new PrefBoolean();
- }
-
- /**
- * Get max value; returns null for this type.
- */
- @Override
- public Boolean getMaxValue()
- {
- return null;
- }
-
- /**
- * Get min value; returns null for this type.
- */
- @Override
- public Boolean getMinValue()
- {
- return null;
- }
-
- /**
- * Get the current PrefBoolean object associated with this.
- * If there is not one yet, create one with the default value specified in this.
- *
- * @return
- */
- public PrefBoolean usePrefBoolean()
- {
- return Pref.usePrefBoolean(getID(), getDefaultValue());
- }
-/*
- public boolean isWithinRange(Boolean newValue)
- {
- return (range == null) ? true : range.isWithinRange(newValue);
- }
- */
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+import ecologylab.serialization.types.ScalarType;
+import ecologylab.serialization.types.TypeRegistry;
+
+/**
+ * Metadata about a Boolean Preference.
+ * Defines information to enable editing the Preference.
+ *
+ * @author andruid
+ *
+ */
+@simpl_inherit
+public class MetaPrefBoolean extends MetaPref
+{
+ /**
+ * Default value for this MetaPref
+ */
+ @simpl_scalar boolean defaultValue;
+
+ public static final ScalarType BOOLEAN_SCALAR_TYPE = TypeRegistry.getScalarType(boolean.class);
+
+ /**
+ * Instantiate.
+ */
+ public MetaPrefBoolean()
+ {
+ super(BOOLEAN_SCALAR_TYPE);
+ }
+
+ /**
+ * Gets the default value of a MetaPref.
+ *
+ * @return Default value of MetaPref
+ */
+ @Override
+ public Boolean getDefaultValue()
+ {
+ return defaultValue;
+ }
+
+ /**
+ * Construct a new instance of the Pref that matches this.
+ * Use this to fill-in the default value.
+ *
+ * @return new Pref instance
+ */
+ protected @Override Pref getPrefInstance()
+ {
+ return new PrefBoolean();
+ }
+
+ /**
+ * Get max value; returns null for this type.
+ */
+ @Override
+ public Boolean getMaxValue()
+ {
+ return null;
+ }
+
+ /**
+ * Get min value; returns null for this type.
+ */
+ @Override
+ public Boolean getMinValue()
+ {
+ return null;
+ }
+
+ /**
+ * Get the current PrefBoolean object associated with this.
+ * If there is not one yet, create one with the default value specified in this.
+ *
+ * @return
+ */
+ public PrefBoolean usePrefBoolean()
+ {
+ return Pref.usePrefBoolean(getID(), getDefaultValue());
+ }
+/*
+ public boolean isWithinRange(Boolean newValue)
+ {
+ return (range == null) ? true : range.isWithinRange(newValue);
+ }
+ */
}
\ No newline at end of file
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefFile.java b/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefFile.java
index 012d6986..09f231aa 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefFile.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefFile.java
@@ -1,108 +1,108 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import java.io.File;
-
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-import ecologylab.serialization.types.ScalarType;
-import ecologylab.serialization.types.TypeRegistry;
-
-/**
- * Metadata about a File Preference.
- * Defines information to enable editing the Preference.
- *
- * @author andruid
- *
- */
-
-@simpl_inherit
-public class MetaPrefFile extends MetaPref
-{
- /**
- * Default value for this MetaPref
- */
- @simpl_scalar File defaultValue;
- @simpl_scalar int pathContext = ABSOLUTE_PATH;
-
- /** Indicates that value is an absolute path. */
- public static final int ABSOLUTE_PATH = 0;
-
- /**
- * Indicates that value is a path relative to the codebase of the
- * application using this Pref.
- */
- public static final int CODE_BASE = 1;
-
- /**
- * Indicates that value is a path relative to the data directory associated
- * with the application using this Pref.
- */
- public static final int APP_DATA_DIR = 2;
-
- public static final ScalarType FILE_SCALAR_TYPE = TypeRegistry.getScalarType(File.class);
-
- /**
- * Instantiate.
- */
- public MetaPrefFile()
- {
- super(FILE_SCALAR_TYPE);
- }
-
- /**
- * Gets the default value of a MetaPref.
- *
- * @return Default value of MetaPref
- */
- @Override
- public File getDefaultValue()
- {
- return defaultValue;
- }
-
- /**
- * Construct a new instance of the Pref that matches this.
- * Use this to fill-in the default value.
- *
- * @return
- */
- protected @Override Pref getPrefInstance()
- {
- return new PrefFile();
- }
-
- /**
- * Get max value; returns null for this type.
- */
- @Override
- public File getMaxValue()
- {
- return null;
- }
-
- /**
- * Get min value; returns null for this type.
- */
- @Override
- public File getMinValue()
- {
- return null;
- }
-
-// @Override
-// public File getInstance(String string)
-// {
-// return new File(string);
-// }
-
-
-/*
- public boolean isWithinRange(File newValue)
- {
- return (range == null) ? true : range.isWithinRange(newValue);
- }
- */
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import java.io.File;
+
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+import ecologylab.serialization.types.ScalarType;
+import ecologylab.serialization.types.TypeRegistry;
+
+/**
+ * Metadata about a File Preference.
+ * Defines information to enable editing the Preference.
+ *
+ * @author andruid
+ *
+ */
+
+@simpl_inherit
+public class MetaPrefFile extends MetaPref
+{
+ /**
+ * Default value for this MetaPref
+ */
+ @simpl_scalar File defaultValue;
+ @simpl_scalar int pathContext = ABSOLUTE_PATH;
+
+ /** Indicates that value is an absolute path. */
+ public static final int ABSOLUTE_PATH = 0;
+
+ /**
+ * Indicates that value is a path relative to the codebase of the
+ * application using this Pref.
+ */
+ public static final int CODE_BASE = 1;
+
+ /**
+ * Indicates that value is a path relative to the data directory associated
+ * with the application using this Pref.
+ */
+ public static final int APP_DATA_DIR = 2;
+
+ public static final ScalarType FILE_SCALAR_TYPE = TypeRegistry.getScalarType(File.class);
+
+ /**
+ * Instantiate.
+ */
+ public MetaPrefFile()
+ {
+ super(FILE_SCALAR_TYPE);
+ }
+
+ /**
+ * Gets the default value of a MetaPref.
+ *
+ * @return Default value of MetaPref
+ */
+ @Override
+ public File getDefaultValue()
+ {
+ return defaultValue;
+ }
+
+ /**
+ * Construct a new instance of the Pref that matches this.
+ * Use this to fill-in the default value.
+ *
+ * @return
+ */
+ protected @Override Pref getPrefInstance()
+ {
+ return new PrefFile();
+ }
+
+ /**
+ * Get max value; returns null for this type.
+ */
+ @Override
+ public File getMaxValue()
+ {
+ return null;
+ }
+
+ /**
+ * Get min value; returns null for this type.
+ */
+ @Override
+ public File getMinValue()
+ {
+ return null;
+ }
+
+// @Override
+// public File getInstance(String string)
+// {
+// return new File(string);
+// }
+
+
+/*
+ public boolean isWithinRange(File newValue)
+ {
+ return (range == null) ? true : range.isWithinRange(newValue);
+ }
+ */
}
\ No newline at end of file
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefFloat.java b/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefFloat.java
index b7f2e123..312cb42f 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefFloat.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefFloat.java
@@ -1,101 +1,101 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.annotations.simpl_composite;
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-import ecologylab.serialization.types.ScalarType;
-import ecologylab.serialization.types.TypeRegistry;
-
-/**
- * Metadata about a Float Preference.
- * Defines information to enable editing the Preference.
- *
- * @author andruid
- *
- */
-
-@simpl_inherit
-public class MetaPrefFloat extends MetaPref
-{
- /**
- * Default value for this MetaPref
- */
- @simpl_scalar float defaultValue;
- /**
- * Min/max values
- */
- @simpl_composite RangeFloatState range;
-
- public static final ScalarType FLOAT_SCALAR_TYPE = TypeRegistry.getScalarType(float.class);
-
- /**
- * Instantiate.
- */
- public MetaPrefFloat()
- {
- super(FLOAT_SCALAR_TYPE);
- }
-
- /**
- * Gets the default value of a MetaPref.
- *
- * @return Default value of MetaPref
- */
- @Override
- public Float getDefaultValue()
- {
- return defaultValue;
- }
-
- /**
- * Construct a new instance of the Pref that matches this.
- * Use this to fill-in the default value.
- *
- * @return
- */
- protected @Override Pref getPrefInstance()
- {
- return new PrefFloat();
- }
-
- /**
- * Get max value for this MetaPref; returns null if it is not defined.
- */
- @Override
- public Float getMaxValue()
- {
- if (range != null)
- return range.getMax();
- else
- return null;
- }
-
- /**
- * Get min value for this MetaPref; returns null if it is not defined.
- */
- @Override
- public Float getMinValue()
- {
- if (range != null)
- return range.getMin();
- else
- return null;
- }
-
-// @Override
-// public Float getInstance(String string)
-// {
-// // return scalarType.getInstance(string);
-// return new Float(string);
-// }
-
-/*
- public boolean isWithinRange(Float newValue)
- {
- return (range == null) ? true : range.isWithinRange(newValue);
- }
- */
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.annotations.simpl_composite;
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+import ecologylab.serialization.types.ScalarType;
+import ecologylab.serialization.types.TypeRegistry;
+
+/**
+ * Metadata about a Float Preference.
+ * Defines information to enable editing the Preference.
+ *
+ * @author andruid
+ *
+ */
+
+@simpl_inherit
+public class MetaPrefFloat extends MetaPref
+{
+ /**
+ * Default value for this MetaPref
+ */
+ @simpl_scalar float defaultValue;
+ /**
+ * Min/max values
+ */
+ @simpl_composite RangeFloatState range;
+
+ public static final ScalarType FLOAT_SCALAR_TYPE = TypeRegistry.getScalarType(float.class);
+
+ /**
+ * Instantiate.
+ */
+ public MetaPrefFloat()
+ {
+ super(FLOAT_SCALAR_TYPE);
+ }
+
+ /**
+ * Gets the default value of a MetaPref.
+ *
+ * @return Default value of MetaPref
+ */
+ @Override
+ public Float getDefaultValue()
+ {
+ return defaultValue;
+ }
+
+ /**
+ * Construct a new instance of the Pref that matches this.
+ * Use this to fill-in the default value.
+ *
+ * @return
+ */
+ protected @Override Pref getPrefInstance()
+ {
+ return new PrefFloat();
+ }
+
+ /**
+ * Get max value for this MetaPref; returns null if it is not defined.
+ */
+ @Override
+ public Float getMaxValue()
+ {
+ if (range != null)
+ return range.getMax();
+ else
+ return null;
+ }
+
+ /**
+ * Get min value for this MetaPref; returns null if it is not defined.
+ */
+ @Override
+ public Float getMinValue()
+ {
+ if (range != null)
+ return range.getMin();
+ else
+ return null;
+ }
+
+// @Override
+// public Float getInstance(String string)
+// {
+// // return scalarType.getInstance(string);
+// return new Float(string);
+// }
+
+/*
+ public boolean isWithinRange(Float newValue)
+ {
+ return (range == null) ? true : range.isWithinRange(newValue);
+ }
+ */
}
\ No newline at end of file
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefInt.java b/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefInt.java
index a6a405f3..47d6fe97 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefInt.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefInt.java
@@ -1,93 +1,93 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.annotations.simpl_composite;
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-import ecologylab.serialization.types.ScalarType;
-import ecologylab.serialization.types.TypeRegistry;
-/**
- * Metadata about an Integer Preference.
- * Defines information to enable editing the Preference.
- *
- * @author andruid
- *
- */
-@simpl_inherit
-public class MetaPrefInt extends MetaPref
-{
- /**
- * Default value for this MetaPref
- */
- @simpl_scalar int defaultValue;
-
- /**
- * Min/max values
- */
- @simpl_composite RangeIntState range;
-
- public static final ScalarType INT_SCALAR_TYPE = TypeRegistry.getScalarType(int.class);
-
- /**
- * Instantiate.
- */
- public MetaPrefInt()
- {
- super(INT_SCALAR_TYPE);
- }
-
- /**
- * Gets the default value of a MetaPref.
- *
- * @return Default value of MetaPref
- */
- @Override
- public Integer getDefaultValue()
- {
- return defaultValue;
- }
-
- /**
- * Construct a new instance of the Pref that matches this.
- * Use this to fill-in the default value.
- *
- * @return
- */
- protected @Override Pref getPrefInstance()
- {
- return new PrefInt();
- }
-
- /**
- * Get max value for this MetaPref; returns null if it is not defined.
- */
- @Override
- public Integer getMaxValue()
- {
- if (range != null)
- return range.getMax();
- else
- return null;
- }
-
- /**
- * Get min value for this MetaPref; returns null if it is not defined.
- */
- @Override
- public Integer getMinValue()
- {
- if (range != null)
- return range.getMin();
- else
- return null;
- }
-
-/*
- public boolean isWithinRange(Integer newValue)
- {
- return (range == null) ? true : range.isWithinRange(newValue);
- }
- */
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.annotations.simpl_composite;
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+import ecologylab.serialization.types.ScalarType;
+import ecologylab.serialization.types.TypeRegistry;
+/**
+ * Metadata about an Integer Preference.
+ * Defines information to enable editing the Preference.
+ *
+ * @author andruid
+ *
+ */
+@simpl_inherit
+public class MetaPrefInt extends MetaPref
+{
+ /**
+ * Default value for this MetaPref
+ */
+ @simpl_scalar int defaultValue;
+
+ /**
+ * Min/max values
+ */
+ @simpl_composite RangeIntState range;
+
+ public static final ScalarType INT_SCALAR_TYPE = TypeRegistry.getScalarType(int.class);
+
+ /**
+ * Instantiate.
+ */
+ public MetaPrefInt()
+ {
+ super(INT_SCALAR_TYPE);
+ }
+
+ /**
+ * Gets the default value of a MetaPref.
+ *
+ * @return Default value of MetaPref
+ */
+ @Override
+ public Integer getDefaultValue()
+ {
+ return defaultValue;
+ }
+
+ /**
+ * Construct a new instance of the Pref that matches this.
+ * Use this to fill-in the default value.
+ *
+ * @return
+ */
+ protected @Override Pref getPrefInstance()
+ {
+ return new PrefInt();
+ }
+
+ /**
+ * Get max value for this MetaPref; returns null if it is not defined.
+ */
+ @Override
+ public Integer getMaxValue()
+ {
+ if (range != null)
+ return range.getMax();
+ else
+ return null;
+ }
+
+ /**
+ * Get min value for this MetaPref; returns null if it is not defined.
+ */
+ @Override
+ public Integer getMinValue()
+ {
+ if (range != null)
+ return range.getMin();
+ else
+ return null;
+ }
+
+/*
+ public boolean isWithinRange(Integer newValue)
+ {
+ return (range == null) ? true : range.isWithinRange(newValue);
+ }
+ */
}
\ No newline at end of file
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefSet.java b/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefSet.java
index b9a13c1f..7d857e67 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefSet.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefSet.java
@@ -1,197 +1,197 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Set;
-
-import ecologylab.net.ParsedURL;
-import ecologylab.serialization.ElementState;
-import ecologylab.serialization.SIMPLTranslationException;
-import ecologylab.serialization.SimplTypesScope;
-import ecologylab.serialization.annotations.simpl_collection;
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_nowrap;
-import ecologylab.serialization.annotations.simpl_scalar;
-import ecologylab.serialization.annotations.simpl_scope;
-import ecologylab.serialization.formatenums.Format;
-/**
- * Groupings of MetaPrefs, by category. Categories
- * are also ordered in a separate ArrayList.
- * Contains functions related to adding MetaPrefs to the
- * grouping, getting MetaPrefs, getting the categories, etc.
- *
- * @author Cae
- *
- */
-
-@simpl_inherit
-public class MetaPrefSet extends ElementState
-{
- @simpl_scalar String title;
- @simpl_scalar int width;
- @simpl_scalar int height;
-
- @simpl_collection
- @simpl_nowrap
- @simpl_scope(MetaPrefsTranslationScope.NAME)
- ArrayList metaPreferences;
-
- /**
- * HashMap of category Strings to ArrayList of MetaPrefs.
- */
- private HashMap> categoryToMetaPrefs = new HashMap>();
- /**
- * ArrayList of category Strings, in the order they are gotten from
- * the xml file. This is used to order the tabs in GUI creation.
- */
- private ArrayList orderOfTabs = new ArrayList();
-
- /**
- * Perform custom processing on the newly created child node,
- * just before it is added to this.
- *
- * This is part of depth-first traversal during translateFromXML().
- *
- * Add the entry to the category map.
- *
- * Also, create a Pref to match the MetaPref child, if there isn't one already.
- *
- * @param child
- */
- @Override
- protected void createChildHook(ElementState child)
- {
- MetaPref metaPref = (MetaPref) child;
- addEntryToCategoryMap(metaPref);
- metaPref.getAssociatedPref(); // create one if needed
- }
-
- /**
- * Add entry to the Category-MetaPrefs map.
- * @param metaPref
- */
- void addEntryToCategoryMap(MetaPref metaPref)
- {
- ArrayList metaPrefList = categoryToMetaPrefs.get(metaPref.getCategory());
- if (metaPrefList == null)
- {
- metaPrefList = new ArrayList();
- categoryToMetaPrefs.put(metaPref.category, metaPrefList);
- orderOfTabs.add(metaPref.category);
- }
- metaPrefList.add(metaPref);
- }
-
- /**
- *
- */
- public MetaPrefSet()
- {
-
- }
-
- /**
- * Return the ordered list of categories.
- *
- * @param tabList String Array that will hold category names.
- *
- * @return tabList String Array that will hold category names.
- */
- public String[] getOrderedTabNames(String[] tabList)
- {
- return orderOfTabs.toArray(tabList);
- }
-
- /**
- * Return the number of categories.
- *
- * @return Number of categories
- */
- public int getNumberOfTabs()
- {
- return orderOfTabs.size();
- }
-
- /**
- * Get the category names in a Set of Strings.
- *
- * @return String Set of categories.
- */
- public Set getCategories()
- {
- return categoryToMetaPrefs.keySet();
- }
-
- /**
- * Get the MetaPref ArrayList for a category name.
- *
- * @param cat Name of category
- *
- * @return ArrayList of MetaPrefs
- */
- public ArrayList getMetaPrefListByCategory(String cat)
- {
- return categoryToMetaPrefs.get(cat);
- }
-
- /**
- * Register the MetaPref in the static global map, as well as adding it to the super ArrayListState.
- * @param metaPref
- * @return
- */
- public boolean add(MetaPref metaPref)
- {
- boolean result = metaPreferences.add(metaPref);
- metaPref.register();
- return result;
- }
-
- /**
- * Read MetaPref declarations from a file or across the net.
- *
- * @param file
- * @param translationScope
- * @return
- * @throws SIMPLTranslationException
- */
- public static MetaPrefSet load(File file, SimplTypesScope translationScope)
- throws SIMPLTranslationException
- {
- return load(new ParsedURL(file), translationScope);
-
- }
-
- /**
- * Read MetaPref declarations from a file or across the net.
- *
- * @param purl
- * @param translationScope
- * @return
- * @throws SIMPLTranslationException
- */
- public static MetaPrefSet load(ParsedURL purl, SimplTypesScope translationScope)
- throws SIMPLTranslationException
- {
- return (MetaPrefSet) translationScope.deserialize(purl, Format.XML);
-
- }
-
- public int getHeight()
- {
- return height;
- }
-
- public String getTitle()
- {
- return title;
- }
-
- public int getWidth()
- {
- return width;
- }
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Set;
+
+import ecologylab.net.ParsedURL;
+import ecologylab.serialization.ElementState;
+import ecologylab.serialization.SIMPLTranslationException;
+import ecologylab.serialization.SimplTypesScope;
+import ecologylab.serialization.annotations.simpl_collection;
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_nowrap;
+import ecologylab.serialization.annotations.simpl_scalar;
+import ecologylab.serialization.annotations.simpl_scope;
+import ecologylab.serialization.formatenums.Format;
+/**
+ * Groupings of MetaPrefs, by category. Categories
+ * are also ordered in a separate ArrayList.
+ * Contains functions related to adding MetaPrefs to the
+ * grouping, getting MetaPrefs, getting the categories, etc.
+ *
+ * @author Cae
+ *
+ */
+
+@simpl_inherit
+public class MetaPrefSet extends ElementState
+{
+ @simpl_scalar String title;
+ @simpl_scalar int width;
+ @simpl_scalar int height;
+
+ @simpl_collection
+ @simpl_nowrap
+ @simpl_scope(MetaPrefsTranslationScope.NAME)
+ ArrayList metaPreferences;
+
+ /**
+ * HashMap of category Strings to ArrayList of MetaPrefs.
+ */
+ private HashMap> categoryToMetaPrefs = new HashMap>();
+ /**
+ * ArrayList of category Strings, in the order they are gotten from
+ * the xml file. This is used to order the tabs in GUI creation.
+ */
+ private ArrayList orderOfTabs = new ArrayList();
+
+ /**
+ * Perform custom processing on the newly created child node,
+ * just before it is added to this.
+ *
+ * This is part of depth-first traversal during translateFromXML().
+ *
+ * Add the entry to the category map.
+ *
+ * Also, create a Pref to match the MetaPref child, if there isn't one already.
+ *
+ * @param child
+ */
+ @Override
+ protected void createChildHook(ElementState child)
+ {
+ MetaPref metaPref = (MetaPref) child;
+ addEntryToCategoryMap(metaPref);
+ metaPref.getAssociatedPref(); // create one if needed
+ }
+
+ /**
+ * Add entry to the Category-MetaPrefs map.
+ * @param metaPref
+ */
+ void addEntryToCategoryMap(MetaPref metaPref)
+ {
+ ArrayList metaPrefList = categoryToMetaPrefs.get(metaPref.getCategory());
+ if (metaPrefList == null)
+ {
+ metaPrefList = new ArrayList();
+ categoryToMetaPrefs.put(metaPref.category, metaPrefList);
+ orderOfTabs.add(metaPref.category);
+ }
+ metaPrefList.add(metaPref);
+ }
+
+ /**
+ *
+ */
+ public MetaPrefSet()
+ {
+
+ }
+
+ /**
+ * Return the ordered list of categories.
+ *
+ * @param tabList String Array that will hold category names.
+ *
+ * @return tabList String Array that will hold category names.
+ */
+ public String[] getOrderedTabNames(String[] tabList)
+ {
+ return orderOfTabs.toArray(tabList);
+ }
+
+ /**
+ * Return the number of categories.
+ *
+ * @return Number of categories
+ */
+ public int getNumberOfTabs()
+ {
+ return orderOfTabs.size();
+ }
+
+ /**
+ * Get the category names in a Set of Strings.
+ *
+ * @return String Set of categories.
+ */
+ public Set getCategories()
+ {
+ return categoryToMetaPrefs.keySet();
+ }
+
+ /**
+ * Get the MetaPref ArrayList for a category name.
+ *
+ * @param cat Name of category
+ *
+ * @return ArrayList of MetaPrefs
+ */
+ public ArrayList getMetaPrefListByCategory(String cat)
+ {
+ return categoryToMetaPrefs.get(cat);
+ }
+
+ /**
+ * Register the MetaPref in the static global map, as well as adding it to the super ArrayListState.
+ * @param metaPref
+ * @return
+ */
+ public boolean add(MetaPref metaPref)
+ {
+ boolean result = metaPreferences.add(metaPref);
+ metaPref.register();
+ return result;
+ }
+
+ /**
+ * Read MetaPref declarations from a file or across the net.
+ *
+ * @param file
+ * @param translationScope
+ * @return
+ * @throws SIMPLTranslationException
+ */
+ public static MetaPrefSet load(File file, SimplTypesScope translationScope)
+ throws SIMPLTranslationException
+ {
+ return load(new ParsedURL(file), translationScope);
+
+ }
+
+ /**
+ * Read MetaPref declarations from a file or across the net.
+ *
+ * @param purl
+ * @param translationScope
+ * @return
+ * @throws SIMPLTranslationException
+ */
+ public static MetaPrefSet load(ParsedURL purl, SimplTypesScope translationScope)
+ throws SIMPLTranslationException
+ {
+ return (MetaPrefSet) translationScope.deserialize(purl, Format.XML);
+
+ }
+
+ public int getHeight()
+ {
+ return height;
+ }
+
+ public String getTitle()
+ {
+ return title;
+ }
+
+ public int getWidth()
+ {
+ return width;
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefString.java b/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefString.java
index 4dd6a95f..06f5d4d0 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefString.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/MetaPrefString.java
@@ -1,89 +1,89 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-import ecologylab.serialization.types.ScalarType;
-import ecologylab.serialization.types.TypeRegistry;
-
-/**
- * Metadata about a String Preference.
- * Defines information to enable editing the Preference.
- *
- * @author andruid
- *
- */
-
-@simpl_inherit
-public class MetaPrefString extends MetaPref
-{
- /**
- * Default value for this MetaPref
- */
- @simpl_scalar String defaultValue;
-
- public static final ScalarType STRING_SCALAR_TYPE = TypeRegistry.getScalarType(String.class);
-
- /**
- * Instantiate.
- */
- public MetaPrefString()
- {
- super(STRING_SCALAR_TYPE);
- }
-
- /**
- * Gets the default value of a MetaPref.
- *
- * @return Default value of MetaPref
- */
- @Override
- public String getDefaultValue()
- {
- return defaultValue;
- }
-
- /**
- * Construct a new instance of the Pref that matches this.
- * Use this to fill-in the default value.
- *
- * @return
- */
- protected @Override Pref getPrefInstance()
- {
- return new PrefString();
- }
-
- /**
- * Get max value; returns null for this type.
- */
- @Override
- public String getMaxValue()
- {
- return null;
- }
-
- /**
- * Get min value; returns null for this type.
- */
- @Override
- public String getMinValue()
- {
- return null;
- }
-
- @Override
- public String getInstance(String string)
- {
- return string;
- }
-
-/*
- public boolean isWithinRange(String newValue)
- {
- return (range == null) ? true : range.isWithinRange(newValue);
- }
- */
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+import ecologylab.serialization.types.ScalarType;
+import ecologylab.serialization.types.TypeRegistry;
+
+/**
+ * Metadata about a String Preference.
+ * Defines information to enable editing the Preference.
+ *
+ * @author andruid
+ *
+ */
+
+@simpl_inherit
+public class MetaPrefString extends MetaPref
+{
+ /**
+ * Default value for this MetaPref
+ */
+ @simpl_scalar String defaultValue;
+
+ public static final ScalarType STRING_SCALAR_TYPE = TypeRegistry.getScalarType(String.class);
+
+ /**
+ * Instantiate.
+ */
+ public MetaPrefString()
+ {
+ super(STRING_SCALAR_TYPE);
+ }
+
+ /**
+ * Gets the default value of a MetaPref.
+ *
+ * @return Default value of MetaPref
+ */
+ @Override
+ public String getDefaultValue()
+ {
+ return defaultValue;
+ }
+
+ /**
+ * Construct a new instance of the Pref that matches this.
+ * Use this to fill-in the default value.
+ *
+ * @return
+ */
+ protected @Override Pref getPrefInstance()
+ {
+ return new PrefString();
+ }
+
+ /**
+ * Get max value; returns null for this type.
+ */
+ @Override
+ public String getMaxValue()
+ {
+ return null;
+ }
+
+ /**
+ * Get min value; returns null for this type.
+ */
+ @Override
+ public String getMinValue()
+ {
+ return null;
+ }
+
+ @Override
+ public String getInstance(String string)
+ {
+ return string;
+ }
+
+/*
+ public boolean isWithinRange(String newValue)
+ {
+ return (range == null) ? true : range.isWithinRange(newValue);
+ }
+ */
}
\ No newline at end of file
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/Pref.java b/simplCore/src/ecologylab/appframework/types/prefs/Pref.java
index 90efc1a7..28fcbb15 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/Pref.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/Pref.java
@@ -1,674 +1,674 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-//import java.awt.Color;
-import java.io.File;
-import java.util.LinkedList;
-
-import ecologylab.appframework.SingletonApplicationEnvironment;
-import ecologylab.collections.Scope;
-import ecologylab.platformspecifics.FundamentalPlatformSpecifics;
-import ecologylab.serialization.ElementState;
-import ecologylab.serialization.TranslationContext;
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-import ecologylab.serialization.types.element.IMappable;
-
-/**
- * Generic base class for application Preference objects.
- *
- * @author andruid
- */
-
-@simpl_inherit
-public abstract class Pref extends ElementState implements IMappable, Cloneable
-{
- /** The global registry of Pref objects. Used for providing lookup services. */
- static final Scope> allPrefsMap = new Scope>();
-
- /** The ApplicationEnvironment associated with this JVM. */
- static final SingletonApplicationEnvironment aE = null;
-
- /** Name of a Pref; provides index into the preferences map. */
- @simpl_scalar
- protected String name;
-
- /** Cached value */
- T valueCached;
-
- /**
- * The list of PrefChangedListeners registered to respond to changes in Prefs.
- */
- static LinkedList listeners = new LinkedList();
-
- /** No-argument constructor for XML translation. */
- public Pref()
- {
- super();
- }
-
- protected Pref(String name)
- {
- this.name = name;
- }
-
- /**
- * Public generic accessor for the value. Caches autoboxed values, for efficiency.
- *
- * @return
- */
- public T value()
- {
- T result = valueCached;
- if (result == null)
- {
- result = getValue();
- valueCached = result;
- }
- return result;
- }
-
- /**
- * Print Pref name and value
- */
- public void print()
- {
- println("Pref: name: " + name + ", value: " + this.getValue());
- }
-
- /**
- * Return String of Pref name and value
- *
- * @return String of Pref name and value
- */
- @Override
- public String toString()
- {
- return "Pref: " + name + "(" + this.getValue() + ")";
- }
-
- /**
- * Generic get value returns the value as the actual type you want. This version should only be
- * called by value(), so that autoboxed types can be cached. This method *does not* do the
- * caching.
- *
- * @return
- */
- protected abstract T getValue();
-
- /**
- * Generic value setter. Uses boxed reference objects for primitives, which are a bit extra
- * expensive.
- *
- * @param newValue
- */
- public abstract void setValue(T newValue);
-
- /**
- * Performs all housekeeping associated with updating this Pref. prefUpdated() should be called
- * whenever the value of this has been changed.
- *
- * Notifies all listeners that the pref's value has changed.
- *
- * Set valueCached to null
- */
- protected void prefChanged()
- {
- valueCached = null;
-
- Pref.firePrefChangedEvent(this);
- }
-
- /**
- * This is for working with Prefs whose values you will continue to access as they
- * are edited, live, by the user. The result will be immediate changes in the program's behavior.
- *
- * Lookup a Pref associated with name. If you find it return it. If not, create a new Pref object
- * of the correct type. Set its value to default value.
- *
- * @param name
- * Name of the Pref to lookup and find or create.
- * @param defaultValue
- * Initial value of the Pref if it didn't already exist.
- *
- * @return A usable Pref object associated with name, either from the registry or newly created
- */
- public static PrefBoolean usePrefBoolean(String name, boolean defaultValue)
- {
- PrefBoolean pref = (PrefBoolean) lookupPref(name);
- if (pref == null)
- {
- pref = new PrefBoolean(defaultValue);
- pref.name = name;
- pref.register();
- }
- return pref;
- }
-
- /**
- * This is for working with Prefs whose values you will continue to access as they
- * are edited, live, by the user. The result will be immediate changes in the program's behavior.
- *
- * Lookup a Pref associated with name. If you find it return it. If not, create a new Pref object
- * of the correct type. Set its value to default value.
- *
- * @param name
- * Name of the Pref to lookup and find or create.
- * @param defaultValue
- * Initial value of the Pref if it didn't already exist.
- *
- * @return A usable Pref object associated with name, either from the registry or newly created
- */
- public static PrefFloat usePrefFloat(String name, float defaultValue)
- {
- PrefFloat pref = (PrefFloat) lookupPref(name);
- if (pref == null)
- {
- pref = new PrefFloat(defaultValue);
- pref.name = name;
- pref.register();
- }
- return pref;
- }
-
- /**
- * This is for working with Prefs whose values you will continue to access as they
- * are edited, live, by the user. The result will be immediate changes in the program's behavior.
- *
- * Lookup a Pref associated with name. If you find it return it. If not, create a new Pref object
- * of the correct type. Set its value to default value.
- *
- * @param name
- * Name of the Pref to lookup and find or create.
- * @param defaultValue
- * Initial value of the Pref if it didn't already exist.
- *
- * @return A usable Pref object associated with name, either from the registry or newly created
- */
- public static PrefString usePrefString(String name, String defaultValue)
- {
- PrefString pref = (PrefString) lookupPref(name);
- if (pref == null)
- {
- pref = new PrefString(defaultValue);
- pref.name = name;
- pref.register();
- }
- return pref;
- }
-
- /**
- * This is for working with Prefs whose values you will continue to access as they
- * are edited, live, by the user. The result will be immediate changes in the program's behavior.
- *
- * Lookup a Pref associated with name. If you find it return it. If not, create a new Pref object
- * of the correct type. Set its value to default value.
- *
- * @param name
- * Name of the Pref to lookup and find or create.
- * @param defaultValue
- * Initial value of the Pref if it didn't already exist.
- *
- * @return A usable Pref object associated with name, either from the registry or newly created
- */
- public static PrefInt usePrefInt(String name, int defaultValue)
- {
- PrefInt pref = (PrefInt) lookupPref(name);
- if (pref == null)
- {
- pref = new PrefInt(defaultValue);
- pref.name = name;
- pref.register();
- }
- return pref;
- }
-
- /**
- * Lookup a Pref associated with name. If you find it, it is the operative Pref If not, create a
- * new Pref object of the correct type, and register it.
- *
- * Set the value of the operative Pref to that passed in here.
- *
- * @param name
- * Name of the Pref to lookup and find or create.
- * @param defaultValue
- * Initial value of the Pref if it didn't already exist.
- */
- public static void useAndSetPrefInt(String name, int value)
- {
- PrefInt thatPrefInt = usePrefInt(name, value);
- thatPrefInt.setValue(value);
- }
-
- public static void useAndSetPrefEnum(String name, Enum value)
- {
- PrefEnum thatPrefEnum = usePrefEnum(name, value);
- thatPrefEnum.setValue(value);
- }
-
- /**
- * This is for working with Prefs whose values you will continue to access as they
- * are edited, live, by the user. The result will be immediate changes in the program's behavior.
- *
- * Lookup a Pref associated with name. If you find it return it. If not, create a new Pref object
- * of the correct type. Set its value to default value.
- *
- * @param name
- * Name of the Pref to lookup and find or create.
- * @param defaultValue
- * Initial value of the Pref if it didn't already exist.
- *
- * @return A usable Pref object associated with name, either from the registry or newly created
- */
- public static Object usePrefColor(String name, Object defaultValue)
- {
- return FundamentalPlatformSpecifics.get().usePrefColor(name, defaultValue);
- }
-
- /**
- * This is for working with Prefs whose values you will continue to access as they
- * are edited, live, by the user. The result will be immediate changes in the program's behavior.
- *
- * Lookup a Pref associated with name. If you find it return it. If not, create a new Pref object
- * of the correct type. Set its value to default value.
- *
- * @param name
- * Name of the Pref to lookup and find or create.
- * @param defaultValue
- * Initial value of the Pref if it didn't already exist.
- *
- * @return A usable Pref object associated with name, either from the registry or newly created
- */
- public static PrefEnum usePrefEnum(String name, Enum defaultValue)
- {
- PrefEnum pref = (PrefEnum) lookupPref(name);
- if (pref == null)
- {
- pref = new PrefEnum(defaultValue);
- pref.name = name;
- pref.register();
- }
- return pref;
- }
-
- /**
- * Look up a Pref by name in the map of all Prefs
- *
- * @param name
- * Name of Pref
- *
- * @return Pref with the given name
- */
- public static Pref> lookupPref(String name)
- {
- Pref> pref = allPrefsMap.get(name);
- return pref;
- }
-
- public static void printAllPrefsMap()
- {
- for (Pref p : allPrefsMap.values())
- {
- System.out.println("PREF: " + p.getName() + " = " + p.value());
- }
- }
-
- /**
- * Turn the entry for a pref name to null in the global map.
- *
- * @param name
- */
- public static void clearPref(String name)
- {
- allPrefsMap.remove(name);
- }
-
- /**
- * Look up a PrefInt by name in the map of all Prefs. Return defaultValue if PrefInt's value is
- * null.
- *
- * @param name
- * Name of PrefInt
- * @param defaultValue
- * default value for PrefInt
- *
- * @return PrefInt's value or default value if doesn't exist
- */
- public static int lookupInt(String name, int defaultValue) throws ClassCastException
- {
- /*
- * could do this -- its heavier weight -- create a Pref if there wasn't one, and set its default
- * value as here PrefInt prefInt = usePrefInt(name, defaultValue); return prefInt.value();
- */
- PrefInt prefInt = ((PrefInt) lookupPref(name));
-
- return (prefInt == null) ? defaultValue : prefInt.value();
- }
-
- /**
- * Look up a PrefInt by name in the map of all Prefs.
- *
- * @param name
- * Name of PrefInt
- *
- * @return PrefInt's value or 0
- */
- public static int lookupInt(String name) throws ClassCastException
- {
- return lookupInt(name, 0);
- }
-
- /**
- * Look up a PrefLong by name in the map of all Prefs. Return defaultValue if PrefInt's value is
- * null.
- *
- * @param name
- * Name of PrefLong
- * @param defaultValue
- * default value for PrefLong
- *
- * @return PrefInt's value or default value if doesn't exist
- */
- public static long lookupLong(String name, long defaultValue) throws ClassCastException
- {
- PrefLong prefLong = ((PrefLong) lookupPref(name));
-
- return (prefLong == null) ? defaultValue : prefLong.value();
- }
-
- /**
- * Look up a PrefLong by name in the map of all Prefs.
- *
- * @param name
- * Name of PrefLong
- *
- * @return PrefInt's value or 0
- */
- public static long lookupLong(String name) throws ClassCastException
- {
- return lookupInt(name, 0);
- }
-
- /**
- * Look up a PrefBoolean by name in the map of all Prefs. Return defaultValue if PrefBoolean's
- * value is null.
- *
- * @param name
- * Name of PrefBoolean
- * @param defaultValue
- * default value for PrefBoolean
- *
- * @return PrefBoolean's value or default value if doesn't exist
- */
- public static boolean lookupBoolean(String name, boolean defaultValue) throws ClassCastException
- {
- PrefBoolean prefBoolean = ((PrefBoolean) lookupPref(name));
- return (prefBoolean == null) ? defaultValue : prefBoolean.value();
- }
-
- /**
- * Look up a PrefBoolean by name in the map of all Prefs.
- *
- * @param name
- * Name of PrefBoolean
- *
- * @return PrefBoolean's value or false if doesn't exist
- */
- public static boolean lookupBoolean(String name) throws ClassCastException
- {
- return lookupBoolean(name, false);
- }
-
- /**
- * Look up a PrefFloat by name in the map of all Prefs. Return defaultValue if PrefFloat's value
- * is null.
- *
- * @param name
- * Name of PrefFloat
- * @param defaultValue
- * default value to set PrefFloat to
- *
- * @return PrefFloat's value or default value if doesn't exist
- */
- public static float lookupFloat(String name, float defaultValue) throws ClassCastException
- {
- PrefFloat prefFloat = ((PrefFloat) lookupPref(name));
- return (prefFloat == null) ? defaultValue : prefFloat.value();
- }
-
- /**
- * Look up a PrefFloat by name in the map of all Prefs.
- *
- * @param name
- * Name of PrefFloat
- *
- * @return PrefFloat's value (if exists) or 1.0f
- */
- public static float lookupFloat(String name) throws ClassCastException
- {
- return lookupFloat(name, 1.0f);
- }
-
- /**
- * Look up a PrefDouble by name in the map of all Prefs. Return defaultValue if PrefDouble's value
- * is null.
- *
- * @param name
- * Name of PrefDouble
- * @param defaultValue
- * default value to set PrefDouble to
- *
- * @return PrefDouble's value or default value if doesn't exist
- */
- public static double lookupDouble(String name, double defaultValue) throws ClassCastException
- {
- PrefDouble prefDouble = ((PrefDouble) lookupPref(name));
- return (prefDouble == null) ? defaultValue : prefDouble.value();
- }
-
- /**
- * Look up a PrefDouble by name in the map of all Prefs.
- *
- * @param name
- * Name of PrefDouble
- *
- * @return PrefDouble's value (if exists) or 1.0
- */
- public static double lookupDouble(String name) throws ClassCastException
- {
- return lookupDouble(name, 1.0);
- }
-
- /**
- * Look up a PrefString by name in the map of all Prefs. Return defaultValue if PrefString's value
- * is null.
- *
- * @param name
- * Name of PrefString
- * @param defaultValue
- * default value for PrefString
- *
- * @return PrefString's value or default value if doesn't exist
- */
- public static String lookupString(String name, String defaultValue) throws ClassCastException
- {
- PrefString prefString = ((PrefString) lookupPref(name));
- return (prefString == null) ? defaultValue : prefString.value();
- }
-
- /**
- * Look up a PrefString by name in the map of all Prefs. Return null if PrefString's value is
- * null.
- *
- * @param name
- * Name of PrefString
- *
- * @return PrefString's value or null
- */
- public static String lookupString(String name) throws ClassCastException
- {
- return lookupString(name, null);
- }
-
- /**
- * Look up a PrefFile by name in the map of all Prefs. Return null if the PrefFile's value is
- * null;
- *
- * @param name
- * Name of the PrefFile
- * @return PrefFile's value or null, if the Pref associated with name does not exist
- * @throws ClassCastException
- * if name does not match a PrefFile object
- */
- public static File lookupFile(String name) throws ClassCastException
- {
- PrefFile prefFile = ((PrefFile) lookupPref(name));
- return (prefFile == null) ? null : prefFile.value();
- }
-
- /**
- * Look up a PrefColor by name in the map of all Prefs. Return defaultValue if PrefColor's value
- * is null.
- *
- * @param name
- * Name of PrefColor
- * @param defaultValue
- * default value for PrefColor
- *
- * @return PrefColor's value or default value if doesn't exist
- */
- public static Object lookupColor(String name, Object defaultValue)
- {
- return FundamentalPlatformSpecifics.get().lookupColor(name, defaultValue);
- }
-
- /**
- * Look up a PrefColor by name in the map of all Prefs.
- *
- * @param name
- * Name of PrefColor
- *
- * @return PrefColor's value or null
- */
- public static Object lookupColor(String name) throws ClassCastException
- {
- return lookupColor(name, null);
- }
-
- /**
- * Look up a PrefElementState by name in the map of all Prefs. Set to defaultValue if
- * PrefElementState's value is null.
- *
- * @param name
- * Name of PrefElementState
- *
- * @return PrefElementState's value or null if doesn't exist
- */
- public static ElementState lookupElementState(String name) throws ClassCastException
- {
- PrefElementState prefElementState = ((PrefElementState) lookupPref(name));
- return (ElementState) ((prefElementState == null) ? null : prefElementState.value());
- }
-
- public static Enum lookupEnum(String name, Enum defaultValue) throws ClassCastException
- {
- PrefEnum prefEnum = ((PrefEnum) lookupPref(name));
- return (prefEnum == null) ? defaultValue : prefEnum.value();
- }
-
- /**
- * Check for existence / membership.
- *
- * @param key
- *
- * @return true if there is a Pref already registered with name key
- */
- public static boolean hasPref(String name)
- {
- return allPrefsMap.containsKey(name);
- }
-
- /**
- * Create an entry for this in the allPrefsMap.
- *
- */
- void register()
- {
- allPrefsMap.put(this.name, this);
- }
-
- /**
- * Check for existence / membership.
- *
- * @param key
- *
- * @return true if there is a Pref already registered with name key
- */
- public static boolean containsKey(String key)
- {
- return allPrefsMap.containsKey(key);
- }
-
- public String getName()
- {
- return name;
- }
-
- public static void addPrefChangedListener(PrefChangedListener l)
- {
- listeners.add(l);
- }
-
- private static void firePrefChangedEvent(Pref> pref)
- {
- for (PrefChangedListener l : listeners)
- {
- l.prefChanged(pref);
- }
- }
-
- public static void prefUpdated(Pref> pref)
- {
- firePrefChangedEvent(pref);
- }
-
- /**
- * @see ecologylab.serialization.types.element.IMappable#key()
- */
- @Override
- public String key()
- {
- return name;
- }
-
- /**
- * @see ecologylab.serialization.types.element.ArrayListState#clone() This clone method is
- * REQUIRED for preferences being maintained by a servlet. The specific case that we have in
- * place (dec '09) that uses this is the Studies framework. The clone functionality enables
- * maintaining a preference set for each user in a user study.
- */
- @Override
- public abstract Pref clone();
-
- /**
- * This method can be called after the pref has translated, with the current session scope.
- *
- * @param scope
- */
- public void postLoadHook(Scope scope)
- {
-
- }
-
- @Override
- public void deserializationPostHook(TranslationContext translationContext, Object object)
- {
- if (object instanceof Pref>)
- {
- Pref> pref = (Pref>) object;
- pref.register();
- }
- }
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+//import java.awt.Color;
+import java.io.File;
+import java.util.LinkedList;
+
+import ecologylab.appframework.SingletonApplicationEnvironment;
+import ecologylab.collections.Scope;
+import ecologylab.platformspecifics.FundamentalPlatformSpecifics;
+import ecologylab.serialization.ElementState;
+import ecologylab.serialization.TranslationContext;
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+import ecologylab.serialization.types.element.IMappable;
+
+/**
+ * Generic base class for application Preference objects.
+ *
+ * @author andruid
+ */
+
+@simpl_inherit
+public abstract class Pref extends ElementState implements IMappable, Cloneable
+{
+ /** The global registry of Pref objects. Used for providing lookup services. */
+ static final Scope> allPrefsMap = new Scope>();
+
+ /** The ApplicationEnvironment associated with this JVM. */
+ static final SingletonApplicationEnvironment aE = null;
+
+ /** Name of a Pref; provides index into the preferences map. */
+ @simpl_scalar
+ protected String name;
+
+ /** Cached value */
+ T valueCached;
+
+ /**
+ * The list of PrefChangedListeners registered to respond to changes in Prefs.
+ */
+ static LinkedList listeners = new LinkedList();
+
+ /** No-argument constructor for XML translation. */
+ public Pref()
+ {
+ super();
+ }
+
+ protected Pref(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Public generic accessor for the value. Caches autoboxed values, for efficiency.
+ *
+ * @return
+ */
+ public T value()
+ {
+ T result = valueCached;
+ if (result == null)
+ {
+ result = getValue();
+ valueCached = result;
+ }
+ return result;
+ }
+
+ /**
+ * Print Pref name and value
+ */
+ public void print()
+ {
+ println("Pref: name: " + name + ", value: " + this.getValue());
+ }
+
+ /**
+ * Return String of Pref name and value
+ *
+ * @return String of Pref name and value
+ */
+ @Override
+ public String toString()
+ {
+ return "Pref: " + name + "(" + this.getValue() + ")";
+ }
+
+ /**
+ * Generic get value returns the value as the actual type you want. This version should only be
+ * called by value(), so that autoboxed types can be cached. This method *does not* do the
+ * caching.
+ *
+ * @return
+ */
+ protected abstract T getValue();
+
+ /**
+ * Generic value setter. Uses boxed reference objects for primitives, which are a bit extra
+ * expensive.
+ *
+ * @param newValue
+ */
+ public abstract void setValue(T newValue);
+
+ /**
+ * Performs all housekeeping associated with updating this Pref. prefUpdated() should be called
+ * whenever the value of this has been changed.
+ *
+ * Notifies all listeners that the pref's value has changed.
+ *
+ * Set valueCached to null
+ */
+ protected void prefChanged()
+ {
+ valueCached = null;
+
+ Pref.firePrefChangedEvent(this);
+ }
+
+ /**
+ * This is for working with Prefs whose values you will continue to access as they
+ * are edited, live, by the user. The result will be immediate changes in the program's behavior.
+ *
+ * Lookup a Pref associated with name. If you find it return it. If not, create a new Pref object
+ * of the correct type. Set its value to default value.
+ *
+ * @param name
+ * Name of the Pref to lookup and find or create.
+ * @param defaultValue
+ * Initial value of the Pref if it didn't already exist.
+ *
+ * @return A usable Pref object associated with name, either from the registry or newly created
+ */
+ public static PrefBoolean usePrefBoolean(String name, boolean defaultValue)
+ {
+ PrefBoolean pref = (PrefBoolean) lookupPref(name);
+ if (pref == null)
+ {
+ pref = new PrefBoolean(defaultValue);
+ pref.name = name;
+ pref.register();
+ }
+ return pref;
+ }
+
+ /**
+ * This is for working with Prefs whose values you will continue to access as they
+ * are edited, live, by the user. The result will be immediate changes in the program's behavior.
+ *
+ * Lookup a Pref associated with name. If you find it return it. If not, create a new Pref object
+ * of the correct type. Set its value to default value.
+ *
+ * @param name
+ * Name of the Pref to lookup and find or create.
+ * @param defaultValue
+ * Initial value of the Pref if it didn't already exist.
+ *
+ * @return A usable Pref object associated with name, either from the registry or newly created
+ */
+ public static PrefFloat usePrefFloat(String name, float defaultValue)
+ {
+ PrefFloat pref = (PrefFloat) lookupPref(name);
+ if (pref == null)
+ {
+ pref = new PrefFloat(defaultValue);
+ pref.name = name;
+ pref.register();
+ }
+ return pref;
+ }
+
+ /**
+ * This is for working with Prefs whose values you will continue to access as they
+ * are edited, live, by the user. The result will be immediate changes in the program's behavior.
+ *
+ * Lookup a Pref associated with name. If you find it return it. If not, create a new Pref object
+ * of the correct type. Set its value to default value.
+ *
+ * @param name
+ * Name of the Pref to lookup and find or create.
+ * @param defaultValue
+ * Initial value of the Pref if it didn't already exist.
+ *
+ * @return A usable Pref object associated with name, either from the registry or newly created
+ */
+ public static PrefString usePrefString(String name, String defaultValue)
+ {
+ PrefString pref = (PrefString) lookupPref(name);
+ if (pref == null)
+ {
+ pref = new PrefString(defaultValue);
+ pref.name = name;
+ pref.register();
+ }
+ return pref;
+ }
+
+ /**
+ * This is for working with Prefs whose values you will continue to access as they
+ * are edited, live, by the user. The result will be immediate changes in the program's behavior.
+ *
+ * Lookup a Pref associated with name. If you find it return it. If not, create a new Pref object
+ * of the correct type. Set its value to default value.
+ *
+ * @param name
+ * Name of the Pref to lookup and find or create.
+ * @param defaultValue
+ * Initial value of the Pref if it didn't already exist.
+ *
+ * @return A usable Pref object associated with name, either from the registry or newly created
+ */
+ public static PrefInt usePrefInt(String name, int defaultValue)
+ {
+ PrefInt pref = (PrefInt) lookupPref(name);
+ if (pref == null)
+ {
+ pref = new PrefInt(defaultValue);
+ pref.name = name;
+ pref.register();
+ }
+ return pref;
+ }
+
+ /**
+ * Lookup a Pref associated with name. If you find it, it is the operative Pref If not, create a
+ * new Pref object of the correct type, and register it.
+ *
+ * Set the value of the operative Pref to that passed in here.
+ *
+ * @param name
+ * Name of the Pref to lookup and find or create.
+ * @param defaultValue
+ * Initial value of the Pref if it didn't already exist.
+ */
+ public static void useAndSetPrefInt(String name, int value)
+ {
+ PrefInt thatPrefInt = usePrefInt(name, value);
+ thatPrefInt.setValue(value);
+ }
+
+ public static void useAndSetPrefEnum(String name, Enum value)
+ {
+ PrefEnum thatPrefEnum = usePrefEnum(name, value);
+ thatPrefEnum.setValue(value);
+ }
+
+ /**
+ * This is for working with Prefs whose values you will continue to access as they
+ * are edited, live, by the user. The result will be immediate changes in the program's behavior.
+ *
+ * Lookup a Pref associated with name. If you find it return it. If not, create a new Pref object
+ * of the correct type. Set its value to default value.
+ *
+ * @param name
+ * Name of the Pref to lookup and find or create.
+ * @param defaultValue
+ * Initial value of the Pref if it didn't already exist.
+ *
+ * @return A usable Pref object associated with name, either from the registry or newly created
+ */
+ public static Object usePrefColor(String name, Object defaultValue)
+ {
+ return FundamentalPlatformSpecifics.get().usePrefColor(name, defaultValue);
+ }
+
+ /**
+ * This is for working with Prefs whose values you will continue to access as they
+ * are edited, live, by the user. The result will be immediate changes in the program's behavior.
+ *
+ * Lookup a Pref associated with name. If you find it return it. If not, create a new Pref object
+ * of the correct type. Set its value to default value.
+ *
+ * @param name
+ * Name of the Pref to lookup and find or create.
+ * @param defaultValue
+ * Initial value of the Pref if it didn't already exist.
+ *
+ * @return A usable Pref object associated with name, either from the registry or newly created
+ */
+ public static PrefEnum usePrefEnum(String name, Enum defaultValue)
+ {
+ PrefEnum pref = (PrefEnum) lookupPref(name);
+ if (pref == null)
+ {
+ pref = new PrefEnum(defaultValue);
+ pref.name = name;
+ pref.register();
+ }
+ return pref;
+ }
+
+ /**
+ * Look up a Pref by name in the map of all Prefs
+ *
+ * @param name
+ * Name of Pref
+ *
+ * @return Pref with the given name
+ */
+ public static Pref> lookupPref(String name)
+ {
+ Pref> pref = allPrefsMap.get(name);
+ return pref;
+ }
+
+ public static void printAllPrefsMap()
+ {
+ for (Pref p : allPrefsMap.values())
+ {
+ System.out.println("PREF: " + p.getName() + " = " + p.value());
+ }
+ }
+
+ /**
+ * Turn the entry for a pref name to null in the global map.
+ *
+ * @param name
+ */
+ public static void clearPref(String name)
+ {
+ allPrefsMap.remove(name);
+ }
+
+ /**
+ * Look up a PrefInt by name in the map of all Prefs. Return defaultValue if PrefInt's value is
+ * null.
+ *
+ * @param name
+ * Name of PrefInt
+ * @param defaultValue
+ * default value for PrefInt
+ *
+ * @return PrefInt's value or default value if doesn't exist
+ */
+ public static int lookupInt(String name, int defaultValue) throws ClassCastException
+ {
+ /*
+ * could do this -- its heavier weight -- create a Pref if there wasn't one, and set its default
+ * value as here PrefInt prefInt = usePrefInt(name, defaultValue); return prefInt.value();
+ */
+ PrefInt prefInt = ((PrefInt) lookupPref(name));
+
+ return (prefInt == null) ? defaultValue : prefInt.value();
+ }
+
+ /**
+ * Look up a PrefInt by name in the map of all Prefs.
+ *
+ * @param name
+ * Name of PrefInt
+ *
+ * @return PrefInt's value or 0
+ */
+ public static int lookupInt(String name) throws ClassCastException
+ {
+ return lookupInt(name, 0);
+ }
+
+ /**
+ * Look up a PrefLong by name in the map of all Prefs. Return defaultValue if PrefInt's value is
+ * null.
+ *
+ * @param name
+ * Name of PrefLong
+ * @param defaultValue
+ * default value for PrefLong
+ *
+ * @return PrefInt's value or default value if doesn't exist
+ */
+ public static long lookupLong(String name, long defaultValue) throws ClassCastException
+ {
+ PrefLong prefLong = ((PrefLong) lookupPref(name));
+
+ return (prefLong == null) ? defaultValue : prefLong.value();
+ }
+
+ /**
+ * Look up a PrefLong by name in the map of all Prefs.
+ *
+ * @param name
+ * Name of PrefLong
+ *
+ * @return PrefInt's value or 0
+ */
+ public static long lookupLong(String name) throws ClassCastException
+ {
+ return lookupInt(name, 0);
+ }
+
+ /**
+ * Look up a PrefBoolean by name in the map of all Prefs. Return defaultValue if PrefBoolean's
+ * value is null.
+ *
+ * @param name
+ * Name of PrefBoolean
+ * @param defaultValue
+ * default value for PrefBoolean
+ *
+ * @return PrefBoolean's value or default value if doesn't exist
+ */
+ public static boolean lookupBoolean(String name, boolean defaultValue) throws ClassCastException
+ {
+ PrefBoolean prefBoolean = ((PrefBoolean) lookupPref(name));
+ return (prefBoolean == null) ? defaultValue : prefBoolean.value();
+ }
+
+ /**
+ * Look up a PrefBoolean by name in the map of all Prefs.
+ *
+ * @param name
+ * Name of PrefBoolean
+ *
+ * @return PrefBoolean's value or false if doesn't exist
+ */
+ public static boolean lookupBoolean(String name) throws ClassCastException
+ {
+ return lookupBoolean(name, false);
+ }
+
+ /**
+ * Look up a PrefFloat by name in the map of all Prefs. Return defaultValue if PrefFloat's value
+ * is null.
+ *
+ * @param name
+ * Name of PrefFloat
+ * @param defaultValue
+ * default value to set PrefFloat to
+ *
+ * @return PrefFloat's value or default value if doesn't exist
+ */
+ public static float lookupFloat(String name, float defaultValue) throws ClassCastException
+ {
+ PrefFloat prefFloat = ((PrefFloat) lookupPref(name));
+ return (prefFloat == null) ? defaultValue : prefFloat.value();
+ }
+
+ /**
+ * Look up a PrefFloat by name in the map of all Prefs.
+ *
+ * @param name
+ * Name of PrefFloat
+ *
+ * @return PrefFloat's value (if exists) or 1.0f
+ */
+ public static float lookupFloat(String name) throws ClassCastException
+ {
+ return lookupFloat(name, 1.0f);
+ }
+
+ /**
+ * Look up a PrefDouble by name in the map of all Prefs. Return defaultValue if PrefDouble's value
+ * is null.
+ *
+ * @param name
+ * Name of PrefDouble
+ * @param defaultValue
+ * default value to set PrefDouble to
+ *
+ * @return PrefDouble's value or default value if doesn't exist
+ */
+ public static double lookupDouble(String name, double defaultValue) throws ClassCastException
+ {
+ PrefDouble prefDouble = ((PrefDouble) lookupPref(name));
+ return (prefDouble == null) ? defaultValue : prefDouble.value();
+ }
+
+ /**
+ * Look up a PrefDouble by name in the map of all Prefs.
+ *
+ * @param name
+ * Name of PrefDouble
+ *
+ * @return PrefDouble's value (if exists) or 1.0
+ */
+ public static double lookupDouble(String name) throws ClassCastException
+ {
+ return lookupDouble(name, 1.0);
+ }
+
+ /**
+ * Look up a PrefString by name in the map of all Prefs. Return defaultValue if PrefString's value
+ * is null.
+ *
+ * @param name
+ * Name of PrefString
+ * @param defaultValue
+ * default value for PrefString
+ *
+ * @return PrefString's value or default value if doesn't exist
+ */
+ public static String lookupString(String name, String defaultValue) throws ClassCastException
+ {
+ PrefString prefString = ((PrefString) lookupPref(name));
+ return (prefString == null) ? defaultValue : prefString.value();
+ }
+
+ /**
+ * Look up a PrefString by name in the map of all Prefs. Return null if PrefString's value is
+ * null.
+ *
+ * @param name
+ * Name of PrefString
+ *
+ * @return PrefString's value or null
+ */
+ public static String lookupString(String name) throws ClassCastException
+ {
+ return lookupString(name, null);
+ }
+
+ /**
+ * Look up a PrefFile by name in the map of all Prefs. Return null if the PrefFile's value is
+ * null;
+ *
+ * @param name
+ * Name of the PrefFile
+ * @return PrefFile's value or null, if the Pref associated with name does not exist
+ * @throws ClassCastException
+ * if name does not match a PrefFile object
+ */
+ public static File lookupFile(String name) throws ClassCastException
+ {
+ PrefFile prefFile = ((PrefFile) lookupPref(name));
+ return (prefFile == null) ? null : prefFile.value();
+ }
+
+ /**
+ * Look up a PrefColor by name in the map of all Prefs. Return defaultValue if PrefColor's value
+ * is null.
+ *
+ * @param name
+ * Name of PrefColor
+ * @param defaultValue
+ * default value for PrefColor
+ *
+ * @return PrefColor's value or default value if doesn't exist
+ */
+ public static Object lookupColor(String name, Object defaultValue)
+ {
+ return FundamentalPlatformSpecifics.get().lookupColor(name, defaultValue);
+ }
+
+ /**
+ * Look up a PrefColor by name in the map of all Prefs.
+ *
+ * @param name
+ * Name of PrefColor
+ *
+ * @return PrefColor's value or null
+ */
+ public static Object lookupColor(String name) throws ClassCastException
+ {
+ return lookupColor(name, null);
+ }
+
+ /**
+ * Look up a PrefElementState by name in the map of all Prefs. Set to defaultValue if
+ * PrefElementState's value is null.
+ *
+ * @param name
+ * Name of PrefElementState
+ *
+ * @return PrefElementState's value or null if doesn't exist
+ */
+ public static ElementState lookupElementState(String name) throws ClassCastException
+ {
+ PrefElementState prefElementState = ((PrefElementState) lookupPref(name));
+ return (ElementState) ((prefElementState == null) ? null : prefElementState.value());
+ }
+
+ public static Enum lookupEnum(String name, Enum defaultValue) throws ClassCastException
+ {
+ PrefEnum prefEnum = ((PrefEnum) lookupPref(name));
+ return (prefEnum == null) ? defaultValue : prefEnum.value();
+ }
+
+ /**
+ * Check for existence / membership.
+ *
+ * @param key
+ *
+ * @return true if there is a Pref already registered with name key
+ */
+ public static boolean hasPref(String name)
+ {
+ return allPrefsMap.containsKey(name);
+ }
+
+ /**
+ * Create an entry for this in the allPrefsMap.
+ *
+ */
+ void register()
+ {
+ allPrefsMap.put(this.name, this);
+ }
+
+ /**
+ * Check for existence / membership.
+ *
+ * @param key
+ *
+ * @return true if there is a Pref already registered with name key
+ */
+ public static boolean containsKey(String key)
+ {
+ return allPrefsMap.containsKey(key);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public static void addPrefChangedListener(PrefChangedListener l)
+ {
+ listeners.add(l);
+ }
+
+ private static void firePrefChangedEvent(Pref> pref)
+ {
+ for (PrefChangedListener l : listeners)
+ {
+ l.prefChanged(pref);
+ }
+ }
+
+ public static void prefUpdated(Pref> pref)
+ {
+ firePrefChangedEvent(pref);
+ }
+
+ /**
+ * @see ecologylab.serialization.types.element.IMappable#key()
+ */
+ @Override
+ public String key()
+ {
+ return name;
+ }
+
+ /**
+ * @see ecologylab.serialization.types.element.ArrayListState#clone() This clone method is
+ * REQUIRED for preferences being maintained by a servlet. The specific case that we have in
+ * place (dec '09) that uses this is the Studies framework. The clone functionality enables
+ * maintaining a preference set for each user in a user study.
+ */
+ @Override
+ public abstract Pref clone();
+
+ /**
+ * This method can be called after the pref has translated, with the current session scope.
+ *
+ * @param scope
+ */
+ public void postLoadHook(Scope scope)
+ {
+
+ }
+
+ @Override
+ public void deserializationPostHook(TranslationContext translationContext, Object object)
+ {
+ if (object instanceof Pref>)
+ {
+ Pref> pref = (Pref>) object;
+ pref.register();
+ }
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/PrefBoolean.java b/simplCore/src/ecologylab/appframework/types/prefs/PrefBoolean.java
index 36541c04..56582d25 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/PrefBoolean.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/PrefBoolean.java
@@ -1,94 +1,94 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-
-/**
- * Pref for a Boolean
- *
- * @author andruid
- *
- */
-
-@simpl_inherit
-public class PrefBoolean extends Pref
-{
- /**
- * Value of Pref
- */
- @simpl_scalar
- boolean value;
-
- /**
- *
- */
- public PrefBoolean()
- {
- super();
- }
-
- /**
- * Instantiate Pref to value
- *
- * @param value
- */
- public PrefBoolean(boolean value)
- {
- super();
- this.value = value;
- }
-
- public PrefBoolean(String name, boolean value)
- {
- super(name);
- this.value = value;
- }
-
- /**
- * Get the value of the Pref
- *
- * @return The value of the Pref
- */
- @Override
- protected Boolean getValue()
- {
- return value;
- }
-
- /**
- * Set the value of the Pref given a Boolean (big B)
- *
- * @param The
- * Boolean value the Pref will be set to
- */
- @Override
- public void setValue(Boolean newValue)
- {
- setValue(newValue.booleanValue());
- }
-
- /**
- * Set the value of the Pref given a boolean (small b)
- *
- * @param The
- * boolean value the Pref will be set to
- */
- public void setValue(boolean value)
- {
- this.value = value;
-
- prefChanged();
- }
-
- /**
- * @see ecologylab.appframework.types.prefs.Pref#clone()
- */
- @Override
- public Pref clone()
- {
- return new PrefBoolean(this.name, this.value);
- }
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+
+/**
+ * Pref for a Boolean
+ *
+ * @author andruid
+ *
+ */
+
+@simpl_inherit
+public class PrefBoolean extends Pref
+{
+ /**
+ * Value of Pref
+ */
+ @simpl_scalar
+ boolean value;
+
+ /**
+ *
+ */
+ public PrefBoolean()
+ {
+ super();
+ }
+
+ /**
+ * Instantiate Pref to value
+ *
+ * @param value
+ */
+ public PrefBoolean(boolean value)
+ {
+ super();
+ this.value = value;
+ }
+
+ public PrefBoolean(String name, boolean value)
+ {
+ super(name);
+ this.value = value;
+ }
+
+ /**
+ * Get the value of the Pref
+ *
+ * @return The value of the Pref
+ */
+ @Override
+ protected Boolean getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Set the value of the Pref given a Boolean (big B)
+ *
+ * @param The
+ * Boolean value the Pref will be set to
+ */
+ @Override
+ public void setValue(Boolean newValue)
+ {
+ setValue(newValue.booleanValue());
+ }
+
+ /**
+ * Set the value of the Pref given a boolean (small b)
+ *
+ * @param The
+ * boolean value the Pref will be set to
+ */
+ public void setValue(boolean value)
+ {
+ this.value = value;
+
+ prefChanged();
+ }
+
+ /**
+ * @see ecologylab.appframework.types.prefs.Pref#clone()
+ */
+ @Override
+ public Pref clone()
+ {
+ return new PrefBoolean(this.name, this.value);
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/PrefChangedListener.java b/simplCore/src/ecologylab/appframework/types/prefs/PrefChangedListener.java
index 46331bf2..3417db14 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/PrefChangedListener.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/PrefChangedListener.java
@@ -1,24 +1,24 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-/**
- * An object that monitors a Pref or set of Prefs to respond to changes in
- * it/them.
- *
- * @author Zachary O. Toups (zach@ecologylab.net)
- *
- */
-public interface PrefChangedListener
-{
- /**
- * Responds to a change in a Pref object. This method will be called
- * whenever ANY Pref changes, so the Object implementing this interface must
- * decide what to do with the Pref, most likely based upon its getName()
- * method.
- *
- * @param pref
- */
- public void prefChanged(Pref pref);
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+/**
+ * An object that monitors a Pref or set of Prefs to respond to changes in
+ * it/them.
+ *
+ * @author Zachary O. Toups (zach@ecologylab.net)
+ *
+ */
+public interface PrefChangedListener
+{
+ /**
+ * Responds to a change in a Pref object. This method will be called
+ * whenever ANY Pref changes, so the Object implementing this interface must
+ * decide what to do with the Pref, most likely based upon its getName()
+ * method.
+ *
+ * @param pref
+ */
+ public void prefChanged(Pref pref);
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/PrefElementState.java b/simplCore/src/ecologylab/appframework/types/prefs/PrefElementState.java
index 6acf1e6d..42c50051 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/PrefElementState.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/PrefElementState.java
@@ -1,67 +1,67 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.ElementState;
-
-/**
- * A preference that is an ElementState.
- *
- * @author andruid
- */
-public class PrefElementState extends Pref
-{
-
- T elementStatePref;
-
- /**
- *
- */
- public PrefElementState()
- {
- super();
- }
-
- public PrefElementState(String name)
- {
- super();
- this.name = name;
- }
-
- /**
- * @see ecologylab.appframework.types.prefs.Pref#getValue()
- */
- @Override
- protected T getValue()
- {
- return elementStatePref;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ecologylab.appframework.types.prefs.Pref#setValue(T)
- */
- @Override
- public void setValue(T newValue)
- {
- elementStatePref = newValue;
- prefChanged();
- }
-
- /**
- * XXX NOTE: THIS IS AN UNSAFE CLONE. IF THE VALUE OF THIS PREFERENCE IS TO BE MODIFIED, THIS
- * METHOD MUST BE RECONSIDERED. A very cool and proper way to do this would be to translate value
- * to and from XML, but this is impossible without the correct translation scope.
- *
- * @see ecologylab.appframework.types.prefs.Pref#clone()
- */
- @Override
- public PrefElementState clone()
- {
- PrefElementState pES = new PrefElementState(this.name);
-
- return pES;
- }
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.ElementState;
+
+/**
+ * A preference that is an ElementState.
+ *
+ * @author andruid
+ */
+public class PrefElementState extends Pref
+{
+
+ T elementStatePref;
+
+ /**
+ *
+ */
+ public PrefElementState()
+ {
+ super();
+ }
+
+ public PrefElementState(String name)
+ {
+ super();
+ this.name = name;
+ }
+
+ /**
+ * @see ecologylab.appframework.types.prefs.Pref#getValue()
+ */
+ @Override
+ protected T getValue()
+ {
+ return elementStatePref;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ecologylab.appframework.types.prefs.Pref#setValue(T)
+ */
+ @Override
+ public void setValue(T newValue)
+ {
+ elementStatePref = newValue;
+ prefChanged();
+ }
+
+ /**
+ * XXX NOTE: THIS IS AN UNSAFE CLONE. IF THE VALUE OF THIS PREFERENCE IS TO BE MODIFIED, THIS
+ * METHOD MUST BE RECONSIDERED. A very cool and proper way to do this would be to translate value
+ * to and from XML, but this is impossible without the correct translation scope.
+ *
+ * @see ecologylab.appframework.types.prefs.Pref#clone()
+ */
+ @Override
+ public PrefElementState clone()
+ {
+ PrefElementState pES = new PrefElementState(this.name);
+
+ return pES;
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/PrefFile.java b/simplCore/src/ecologylab/appframework/types/prefs/PrefFile.java
index b42b2e17..179f5477 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/PrefFile.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/PrefFile.java
@@ -1,146 +1,146 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import java.io.File;
-
-import ecologylab.appframework.EnvironmentGeneric;
-import ecologylab.appframework.PropertiesAndDirectories;
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-
-/**
- * Pref indicating a File. Stores a value that indicates either an absolute path, or one relative to
- * the code base or application data dir for the application using the Pref.
- *
- * @author ross
- * @author Zachary O. Toups (zach@ecologylab.net)
- *
- */
-@simpl_inherit
-public class PrefFile extends Pref
-{
- /** Path associated with this preference. */
- @simpl_scalar
- String value;
-
- /**
- * Context indicating the type of path specified by value. Possible values are ABSOLUTE_PATH,
- * CODE_BASE, or APP_DATA_DIR.
- */
- @simpl_scalar
- int pathContext = ABSOLUTE_PATH;
-
- /** Indicates that value is an absolute path. */
- public static final int ABSOLUTE_PATH = 0;
-
- /**
- * Indicates that value is a path relative to the codebase of the application using this Pref.
- */
- public static final int CODE_BASE = 1;
-
- /**
- * Indicates that value is a path relative to the data directory associated with the application
- * using this Pref.
- */
- public static final int APP_DATA_DIR = 2;
-
- /**
- * The cached File object that goes with this Pref; lazilly evaluated. fileValue should NEVER be
- * directly referenced, it should only be accessed through the file() method.
- */
- File fileValue = null;
-
- /** No-argument constructor for XML translation. */
- public PrefFile()
- {
- super();
- }
-
- public PrefFile(String name, String value, int pathContext)
- {
- this.name = name;
- this.value = value;
- this.pathContext = pathContext;
- }
-
- /**
- * Instantiate Pref to value
- *
- * @param value
- */
- public PrefFile(File value)
- {
- super();
- this.setValue(value);
- }
-
- /**
- * Get the value of the Pref. If this's file path includes '$FIND_PATH', then this builds a file
- * based upon the pathname provided by the App Framework.
- *
- * @return The value of the Pref
- */
- @Override
- protected File getValue()
- {
- return file();
- }
-
- /**
- * Sets up this Pref object to be associated with newValue as an absolute path.
- *
- * @see ecologylab.appframework.types.prefs.Pref#setValue(java.lang.Object)
- */
- @Override
- public void setValue(File newValue)
- {
- this.value = newValue.getAbsolutePath();
-
- this.prefChanged();
- }
-
- /**
- * Sets up this Pref object to be associated with newValue as a path indicated by pathContext.
- *
- * @param newValue
- * @param pathContext
- */
- public void setValue(String newValue, int pathContext)
- {
- this.value = newValue;
- this.pathContext = pathContext;
-
- this.prefChanged();
- }
-
- private final File file()
- {
- if (fileValue == null)
- {
- switch (pathContext)
- {
- case (CODE_BASE):
- this.fileValue = new File(EnvironmentGeneric.codeBase().file(), value);
- break;
- case (APP_DATA_DIR):
- this.fileValue = new File(PropertiesAndDirectories.applicationDataDir(), value);
- break;
- default:
- this.fileValue = new File(value);
- }
- }
-
- return fileValue;
- }
-
- /**
- * @see ecologylab.appframework.types.prefs.Pref#clone()
- */
- @Override
- public Pref clone()
- {
- return new PrefFile(this.name, this.value, this.pathContext);
- }
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import java.io.File;
+
+import ecologylab.appframework.EnvironmentGeneric;
+import ecologylab.appframework.PropertiesAndDirectories;
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+
+/**
+ * Pref indicating a File. Stores a value that indicates either an absolute path, or one relative to
+ * the code base or application data dir for the application using the Pref.
+ *
+ * @author ross
+ * @author Zachary O. Toups (zach@ecologylab.net)
+ *
+ */
+@simpl_inherit
+public class PrefFile extends Pref
+{
+ /** Path associated with this preference. */
+ @simpl_scalar
+ String value;
+
+ /**
+ * Context indicating the type of path specified by value. Possible values are ABSOLUTE_PATH,
+ * CODE_BASE, or APP_DATA_DIR.
+ */
+ @simpl_scalar
+ int pathContext = ABSOLUTE_PATH;
+
+ /** Indicates that value is an absolute path. */
+ public static final int ABSOLUTE_PATH = 0;
+
+ /**
+ * Indicates that value is a path relative to the codebase of the application using this Pref.
+ */
+ public static final int CODE_BASE = 1;
+
+ /**
+ * Indicates that value is a path relative to the data directory associated with the application
+ * using this Pref.
+ */
+ public static final int APP_DATA_DIR = 2;
+
+ /**
+ * The cached File object that goes with this Pref; lazilly evaluated. fileValue should NEVER be
+ * directly referenced, it should only be accessed through the file() method.
+ */
+ File fileValue = null;
+
+ /** No-argument constructor for XML translation. */
+ public PrefFile()
+ {
+ super();
+ }
+
+ public PrefFile(String name, String value, int pathContext)
+ {
+ this.name = name;
+ this.value = value;
+ this.pathContext = pathContext;
+ }
+
+ /**
+ * Instantiate Pref to value
+ *
+ * @param value
+ */
+ public PrefFile(File value)
+ {
+ super();
+ this.setValue(value);
+ }
+
+ /**
+ * Get the value of the Pref. If this's file path includes '$FIND_PATH', then this builds a file
+ * based upon the pathname provided by the App Framework.
+ *
+ * @return The value of the Pref
+ */
+ @Override
+ protected File getValue()
+ {
+ return file();
+ }
+
+ /**
+ * Sets up this Pref object to be associated with newValue as an absolute path.
+ *
+ * @see ecologylab.appframework.types.prefs.Pref#setValue(java.lang.Object)
+ */
+ @Override
+ public void setValue(File newValue)
+ {
+ this.value = newValue.getAbsolutePath();
+
+ this.prefChanged();
+ }
+
+ /**
+ * Sets up this Pref object to be associated with newValue as a path indicated by pathContext.
+ *
+ * @param newValue
+ * @param pathContext
+ */
+ public void setValue(String newValue, int pathContext)
+ {
+ this.value = newValue;
+ this.pathContext = pathContext;
+
+ this.prefChanged();
+ }
+
+ private final File file()
+ {
+ if (fileValue == null)
+ {
+ switch (pathContext)
+ {
+ case (CODE_BASE):
+ this.fileValue = new File(EnvironmentGeneric.codeBase().file(), value);
+ break;
+ case (APP_DATA_DIR):
+ this.fileValue = new File(PropertiesAndDirectories.applicationDataDir(), value);
+ break;
+ default:
+ this.fileValue = new File(value);
+ }
+ }
+
+ return fileValue;
+ }
+
+ /**
+ * @see ecologylab.appframework.types.prefs.Pref#clone()
+ */
+ @Override
+ public Pref clone()
+ {
+ return new PrefFile(this.name, this.value, this.pathContext);
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/PrefFloat.java b/simplCore/src/ecologylab/appframework/types/prefs/PrefFloat.java
index 8a8af8ca..c47a4dd3 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/PrefFloat.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/PrefFloat.java
@@ -1,95 +1,95 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-
-/**
- * Pref for a Float
- *
- * @author andruid
- *
- */
-
-@simpl_inherit
-public class PrefFloat extends Pref
-{
- /**
- * Value of Pref
- */
- @simpl_scalar
- float value;
-
- /**
- *
- */
- public PrefFloat()
- {
- super();
- }
-
- /**
- * Instantiate Pref to value
- *
- * @param value
- */
- public PrefFloat(float value)
- {
- super();
- this.value = value;
- }
-
- public PrefFloat(String name, float value)
- {
- super();
- this.name = name;
- this.value = value;
- }
-
- /**
- * Get the value of the Pref
- *
- * @return The value of the Pref
- */
- @Override
- protected Float getValue()
- {
- return value;
- }
-
- /**
- * Set the value of the Pref given a Float (big F)
- *
- * @param The
- * Float value the Pref will be set to
- */
- @Override
- public void setValue(Float newValue)
- {
- setValue(newValue.floatValue());
- }
-
- /**
- * Set the value of the Pref given a float (small f)
- *
- * @param The
- * float value the Pref will be set to
- */
- public void setValue(float value)
- {
- this.value = value;
-
- prefChanged();
- }
-
- /**
- * @see ecologylab.appframework.types.prefs.Pref#clone()
- */
- @Override
- public Pref clone()
- {
- return new PrefFloat(this.name, this.value);
- }
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+
+/**
+ * Pref for a Float
+ *
+ * @author andruid
+ *
+ */
+
+@simpl_inherit
+public class PrefFloat extends Pref
+{
+ /**
+ * Value of Pref
+ */
+ @simpl_scalar
+ float value;
+
+ /**
+ *
+ */
+ public PrefFloat()
+ {
+ super();
+ }
+
+ /**
+ * Instantiate Pref to value
+ *
+ * @param value
+ */
+ public PrefFloat(float value)
+ {
+ super();
+ this.value = value;
+ }
+
+ public PrefFloat(String name, float value)
+ {
+ super();
+ this.name = name;
+ this.value = value;
+ }
+
+ /**
+ * Get the value of the Pref
+ *
+ * @return The value of the Pref
+ */
+ @Override
+ protected Float getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Set the value of the Pref given a Float (big F)
+ *
+ * @param The
+ * Float value the Pref will be set to
+ */
+ @Override
+ public void setValue(Float newValue)
+ {
+ setValue(newValue.floatValue());
+ }
+
+ /**
+ * Set the value of the Pref given a float (small f)
+ *
+ * @param The
+ * float value the Pref will be set to
+ */
+ public void setValue(float value)
+ {
+ this.value = value;
+
+ prefChanged();
+ }
+
+ /**
+ * @see ecologylab.appframework.types.prefs.Pref#clone()
+ */
+ @Override
+ public Pref clone()
+ {
+ return new PrefFloat(this.name, this.value);
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/PrefInt.java b/simplCore/src/ecologylab/appframework/types/prefs/PrefInt.java
index fc4d1dd9..9df02cf0 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/PrefInt.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/PrefInt.java
@@ -1,92 +1,92 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-
-/**
- * Pref for an Integer
- *
- * @author andruid
- *
- */
-
-@simpl_inherit
-public class PrefInt extends Pref
-{
- /**
- * Value of Pref
- */
- @simpl_scalar
- int value;
-
- /**
- *
- */
- public PrefInt()
- {
- super();
- }
-
- public PrefInt(String name, int value)
- {
- super(name);
-
- this.value = value;
- }
-
- /**
- * Instantiate Pref to value
- *
- * @param value
- */
- public PrefInt(int value)
- {
- this(null, value);
- }
-
- /**
- * @return The
- */
- @Override
- protected Integer getValue()
- {
- return value;
- }
-
- /**
- * Set the value of the Pref given an Integer
- *
- * @param The
- * Integer value the Pref will be set to
- */
- @Override
- public void setValue(Integer newValue)
- {
- setValue(newValue.intValue());
- }
-
- /**
- * Set the value of the Pref given an int
- *
- * @param The
- * int value the Pref will be set to
- */
- public void setValue(int value)
- {
- this.value = value;
-
- prefChanged();
- }
-
- /**
- * @see ecologylab.appframework.types.prefs.Pref#clone()
- */
- @Override
- public Pref clone()
- {
- return new PrefInt(this.name, this.value);
- }
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+
+/**
+ * Pref for an Integer
+ *
+ * @author andruid
+ *
+ */
+
+@simpl_inherit
+public class PrefInt extends Pref
+{
+ /**
+ * Value of Pref
+ */
+ @simpl_scalar
+ int value;
+
+ /**
+ *
+ */
+ public PrefInt()
+ {
+ super();
+ }
+
+ public PrefInt(String name, int value)
+ {
+ super(name);
+
+ this.value = value;
+ }
+
+ /**
+ * Instantiate Pref to value
+ *
+ * @param value
+ */
+ public PrefInt(int value)
+ {
+ this(null, value);
+ }
+
+ /**
+ * @return The
+ */
+ @Override
+ protected Integer getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Set the value of the Pref given an Integer
+ *
+ * @param The
+ * Integer value the Pref will be set to
+ */
+ @Override
+ public void setValue(Integer newValue)
+ {
+ setValue(newValue.intValue());
+ }
+
+ /**
+ * Set the value of the Pref given an int
+ *
+ * @param The
+ * int value the Pref will be set to
+ */
+ public void setValue(int value)
+ {
+ this.value = value;
+
+ prefChanged();
+ }
+
+ /**
+ * @see ecologylab.appframework.types.prefs.Pref#clone()
+ */
+ @Override
+ public Pref clone()
+ {
+ return new PrefInt(this.name, this.value);
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/PrefLong.java b/simplCore/src/ecologylab/appframework/types/prefs/PrefLong.java
index 68afea15..f7168747 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/PrefLong.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/PrefLong.java
@@ -1,90 +1,90 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-
-/**
- * Pref for a Long
- *
- * @author andruid, Zachary O. Toups (zach@ecologylab.net)
- *
- */
-
-@simpl_inherit
-public class PrefLong extends Pref
-{
- /** Value of Pref */
- @simpl_scalar
- long value;
-
- /**
- *
- */
- public PrefLong()
- {
- super();
- }
-
- public PrefLong(String name, long value)
- {
- super(name);
-
- this.value = value;
- }
-
- /**
- * Instantiate Pref to value
- *
- * @param value
- */
- public PrefLong(long value)
- {
- this(null, value);
- }
-
- /**
- * @return The
- */
- @Override
- protected Long getValue()
- {
- return value;
- }
-
- /**
- * Set the value of the Pref given an Integer
- *
- * @param The
- * Integer value the Pref will be set to
- */
- @Override
- public void setValue(Long newValue)
- {
- setValue(newValue.longValue());
- }
-
- /**
- * Set the value of the Pref given an int
- *
- * @param The
- * int value the Pref will be set to
- */
- public void setValue(long value)
- {
- this.value = value;
-
- prefChanged();
- }
-
- /**
- * @see ecologylab.appframework.types.prefs.Pref#clone()
- */
- @Override
- public Pref clone()
- {
- return new PrefLong(this.name, this.value);
- }
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+
+/**
+ * Pref for a Long
+ *
+ * @author andruid, Zachary O. Toups (zach@ecologylab.net)
+ *
+ */
+
+@simpl_inherit
+public class PrefLong extends Pref
+{
+ /** Value of Pref */
+ @simpl_scalar
+ long value;
+
+ /**
+ *
+ */
+ public PrefLong()
+ {
+ super();
+ }
+
+ public PrefLong(String name, long value)
+ {
+ super(name);
+
+ this.value = value;
+ }
+
+ /**
+ * Instantiate Pref to value
+ *
+ * @param value
+ */
+ public PrefLong(long value)
+ {
+ this(null, value);
+ }
+
+ /**
+ * @return The
+ */
+ @Override
+ protected Long getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Set the value of the Pref given an Integer
+ *
+ * @param The
+ * Integer value the Pref will be set to
+ */
+ @Override
+ public void setValue(Long newValue)
+ {
+ setValue(newValue.longValue());
+ }
+
+ /**
+ * Set the value of the Pref given an int
+ *
+ * @param The
+ * int value the Pref will be set to
+ */
+ public void setValue(long value)
+ {
+ this.value = value;
+
+ prefChanged();
+ }
+
+ /**
+ * @see ecologylab.appframework.types.prefs.Pref#clone()
+ */
+ @Override
+ public Pref clone()
+ {
+ return new PrefLong(this.name, this.value);
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/PrefSet.java b/simplCore/src/ecologylab/appframework/types/prefs/PrefSet.java
index 91c5887b..d18f4a66 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/PrefSet.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/PrefSet.java
@@ -1,245 +1,245 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Set;
-
-import ecologylab.appframework.ApplicationPropertyNames;
-import ecologylab.net.ParsedURL;
-import ecologylab.serialization.ElementState;
-import ecologylab.serialization.SIMPLTranslationException;
-import ecologylab.serialization.SimplTypesScope;
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_map;
-import ecologylab.serialization.annotations.simpl_nowrap;
-import ecologylab.serialization.annotations.simpl_scope;
-import ecologylab.serialization.formatenums.Format;
-import ecologylab.serialization.formatenums.StringFormat;
-
-/**
- * A serial set of Pref objects. Used for reading and writing (load and save). The static
- * allPrefsMap in Pref is used for lookup.
- *
- * @author Cae
- * @author andruid
- */
-
-@simpl_inherit
-public class PrefSet extends ElementState implements ApplicationPropertyNames, Cloneable
-{
- public static final String PREFS_TRANSLATION_SCOPE = "PREFS_TRANSLATION_SCOPE";
-
- @simpl_map
- @simpl_nowrap
- @simpl_scope(PREFS_TRANSLATION_SCOPE)
- HashMap> preferences;
-
- /** No-argument constructor for XML translation. */
- public PrefSet()
- {
- }
-
- /**
- * Register the Pref, as well as adding it to the super ArrayListState.
- *
- * @param pref
- * @return
- */
- public Pref> add(Pref> pref)
- {
- Pref> result = null;
-
- if (pref != null)
- {
- constructPreferencesIfNeeded();
-
- result = preferences.put(pref.key(), pref);
- pref.register();
- }
-
- return result;
- }
-
- public Pref> addLocalOnly(Pref> pref)
- {
- constructPreferencesIfNeeded();
-
- Pref> result = preferences.put(pref.key(), pref);
-
- return result;
- }
-
- /**
- *
- */
- private void constructPreferencesIfNeeded()
- {
- if (preferences == null)
- preferences = new HashMap>();
- }
-
- /**
- * Perform custom processing on the newly created child node, just before it is added to this.
- *
- * This is part of depth-first traversal during translateFromXML().
- *
- * Add the entry to the category map.
- *
- * @param child
- */
- // TODO -- get rid of this when we make ArrayListState implement Collection!!!
- // (cause then this.add() will get called!)
- @Override
- protected void createChildHook(ElementState child)
- {
- Pref> pref = (Pref>) child;
- pref.register();
- }
-
-
-
- /**
- * Read Pref declarations from a file or across the net.
- *
- * @param purl
- * @param translationScope
- * @return
- * @throws SIMPLTranslationException
- */
- public static PrefSet load(ParsedURL purl, SimplTypesScope translationScope)
- throws SIMPLTranslationException
- {
- File file = purl.file();
- PrefSet pS = null;
- if ((file != null) && file.exists())
- pS = (PrefSet) translationScope.deserialize(purl, Format.XML);
-
- return pS;
- }
-
- /**
- * Read Pref declarations from a file or across the net.
- *
- * @param prefXML
- * - Preferences in an XML format; to be translated into a PrefSet.
- * @param translationScope
- * @return
- * @throws SIMPLTranslationException
- */
- public static PrefSet load(String filename, SimplTypesScope translationScope)
- throws SIMPLTranslationException
- {
- PrefSet pS = (PrefSet) translationScope.deserialize(new File(filename), Format.XML);
-
- return pS;
- }
-
- /**
- * Read Pref declarations from a file or across the net.
- *
- * @param prefXML
- * - Preferences in an XML format; to be translated into a PrefSet.
- * @param translationScope
- * @return
- * @throws SIMPLTranslationException
- */
- public static PrefSet loadFromCharSequence(String prefXML, SimplTypesScope translationScope)
- throws SIMPLTranslationException
- {
- PrefSet pS = (PrefSet) translationScope.deserialize(prefXML, StringFormat.XML);
-
- return pS;
- }
-
- /**
- * Remove the Pref from this, and from the global set.
- *
- * @param key
- * @return
- */
- public Pref> clearPref(String key)
- {
- Pref.clearPref(key);
- return preferences == null ? null : preferences.remove(key);
- }
-
- /**
- * @see ecologylab.serialization.types.element.HashMapState#clone()
- */
- @Override
- public PrefSet clone()
- {
- PrefSet retVal = new PrefSet();
-
- if (preferences != null)
- {
- for (Pref> p : preferences.values())
- {
- retVal.add(p.clone());
- }
- }
- return retVal;
- }
-
- public static final Collection> EMPTY_ARRAY_LIST = new ArrayList>(0);
-
- public Collection> values()
- {
- return preferences == null ? EMPTY_ARRAY_LIST : preferences.values();
- }
-
- public void append(PrefSet jNLPPrefSet)
- {
- for (Pref> pref : jNLPPrefSet.values())
- {
- this.put(pref.key(), pref);
- pref.register();
- }
- }
-
- public Set keySet()
- {
- return preferences.keySet();
- }
-
- public Pref> get(String k)
- {
- return (preferences == null) ? null : preferences.get(k);
- }
-
- public void put(String k, Pref> object)
- {
- constructPreferencesIfNeeded();
-
- preferences.put(k, object);
- }
-
- public boolean containsKey(String key)
- {
- return (preferences == null) ? false : preferences.containsKey(key);
-
- }
-
- /**
- * Add another prefSet to this one.
- *
- * @param prefSet
- */
- public void addPrefSet(PrefSet prefSet)
- {
- constructPreferencesIfNeeded();
-
- for (Pref> pref : prefSet.values())
- add(pref);
- }
-
- public int size()
- {
- return (preferences != null) ? preferences.size() : 0;
- }
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Set;
+
+import ecologylab.appframework.ApplicationPropertyNames;
+import ecologylab.net.ParsedURL;
+import ecologylab.serialization.ElementState;
+import ecologylab.serialization.SIMPLTranslationException;
+import ecologylab.serialization.SimplTypesScope;
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_map;
+import ecologylab.serialization.annotations.simpl_nowrap;
+import ecologylab.serialization.annotations.simpl_scope;
+import ecologylab.serialization.formatenums.Format;
+import ecologylab.serialization.formatenums.StringFormat;
+
+/**
+ * A serial set of Pref objects. Used for reading and writing (load and save). The static
+ * allPrefsMap in Pref is used for lookup.
+ *
+ * @author Cae
+ * @author andruid
+ */
+
+@simpl_inherit
+public class PrefSet extends ElementState implements ApplicationPropertyNames, Cloneable
+{
+ public static final String PREFS_TRANSLATION_SCOPE = "PREFS_TRANSLATION_SCOPE";
+
+ @simpl_map
+ @simpl_nowrap
+ @simpl_scope(PREFS_TRANSLATION_SCOPE)
+ HashMap> preferences;
+
+ /** No-argument constructor for XML translation. */
+ public PrefSet()
+ {
+ }
+
+ /**
+ * Register the Pref, as well as adding it to the super ArrayListState.
+ *
+ * @param pref
+ * @return
+ */
+ public Pref> add(Pref> pref)
+ {
+ Pref> result = null;
+
+ if (pref != null)
+ {
+ constructPreferencesIfNeeded();
+
+ result = preferences.put(pref.key(), pref);
+ pref.register();
+ }
+
+ return result;
+ }
+
+ public Pref> addLocalOnly(Pref> pref)
+ {
+ constructPreferencesIfNeeded();
+
+ Pref> result = preferences.put(pref.key(), pref);
+
+ return result;
+ }
+
+ /**
+ *
+ */
+ private void constructPreferencesIfNeeded()
+ {
+ if (preferences == null)
+ preferences = new HashMap>();
+ }
+
+ /**
+ * Perform custom processing on the newly created child node, just before it is added to this.
+ *
+ * This is part of depth-first traversal during translateFromXML().
+ *
+ * Add the entry to the category map.
+ *
+ * @param child
+ */
+ // TODO -- get rid of this when we make ArrayListState implement Collection!!!
+ // (cause then this.add() will get called!)
+ @Override
+ protected void createChildHook(ElementState child)
+ {
+ Pref> pref = (Pref>) child;
+ pref.register();
+ }
+
+
+
+ /**
+ * Read Pref declarations from a file or across the net.
+ *
+ * @param purl
+ * @param translationScope
+ * @return
+ * @throws SIMPLTranslationException
+ */
+ public static PrefSet load(ParsedURL purl, SimplTypesScope translationScope)
+ throws SIMPLTranslationException
+ {
+ File file = purl.file();
+ PrefSet pS = null;
+ if ((file != null) && file.exists())
+ pS = (PrefSet) translationScope.deserialize(purl, Format.XML);
+
+ return pS;
+ }
+
+ /**
+ * Read Pref declarations from a file or across the net.
+ *
+ * @param prefXML
+ * - Preferences in an XML format; to be translated into a PrefSet.
+ * @param translationScope
+ * @return
+ * @throws SIMPLTranslationException
+ */
+ public static PrefSet load(String filename, SimplTypesScope translationScope)
+ throws SIMPLTranslationException
+ {
+ PrefSet pS = (PrefSet) translationScope.deserialize(new File(filename), Format.XML);
+
+ return pS;
+ }
+
+ /**
+ * Read Pref declarations from a file or across the net.
+ *
+ * @param prefXML
+ * - Preferences in an XML format; to be translated into a PrefSet.
+ * @param translationScope
+ * @return
+ * @throws SIMPLTranslationException
+ */
+ public static PrefSet loadFromCharSequence(String prefXML, SimplTypesScope translationScope)
+ throws SIMPLTranslationException
+ {
+ PrefSet pS = (PrefSet) translationScope.deserialize(prefXML, StringFormat.XML);
+
+ return pS;
+ }
+
+ /**
+ * Remove the Pref from this, and from the global set.
+ *
+ * @param key
+ * @return
+ */
+ public Pref> clearPref(String key)
+ {
+ Pref.clearPref(key);
+ return preferences == null ? null : preferences.remove(key);
+ }
+
+ /**
+ * @see ecologylab.serialization.types.element.HashMapState#clone()
+ */
+ @Override
+ public PrefSet clone()
+ {
+ PrefSet retVal = new PrefSet();
+
+ if (preferences != null)
+ {
+ for (Pref> p : preferences.values())
+ {
+ retVal.add(p.clone());
+ }
+ }
+ return retVal;
+ }
+
+ public static final Collection> EMPTY_ARRAY_LIST = new ArrayList>(0);
+
+ public Collection> values()
+ {
+ return preferences == null ? EMPTY_ARRAY_LIST : preferences.values();
+ }
+
+ public void append(PrefSet jNLPPrefSet)
+ {
+ for (Pref> pref : jNLPPrefSet.values())
+ {
+ this.put(pref.key(), pref);
+ pref.register();
+ }
+ }
+
+ public Set keySet()
+ {
+ return preferences.keySet();
+ }
+
+ public Pref> get(String k)
+ {
+ return (preferences == null) ? null : preferences.get(k);
+ }
+
+ public void put(String k, Pref> object)
+ {
+ constructPreferencesIfNeeded();
+
+ preferences.put(k, object);
+ }
+
+ public boolean containsKey(String key)
+ {
+ return (preferences == null) ? false : preferences.containsKey(key);
+
+ }
+
+ /**
+ * Add another prefSet to this one.
+ *
+ * @param prefSet
+ */
+ public void addPrefSet(PrefSet prefSet)
+ {
+ constructPreferencesIfNeeded();
+
+ for (Pref> pref : prefSet.values())
+ add(pref);
+ }
+
+ public int size()
+ {
+ return (preferences != null) ? preferences.size() : 0;
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/PrefSetBaseClassProvider.java b/simplCore/src/ecologylab/appframework/types/prefs/PrefSetBaseClassProvider.java
index 81d6b613..3c494fa7 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/PrefSetBaseClassProvider.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/PrefSetBaseClassProvider.java
@@ -1,40 +1,40 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.TranslationsClassProvider;
-
-/**
- * Provides the list of Class'es used for translating the PrefSet class. This class is used to
- * provide the base list of Class'es that will be provided to an ApplicationEnvironment.
- *
- * @author Zachary O. Toups (zach@ecologylab.net)
- */
-public class PrefSetBaseClassProvider extends TranslationsClassProvider
-{
- public static final PrefSetBaseClassProvider STATIC_INSTANCE = new PrefSetBaseClassProvider();
-
- protected PrefSetBaseClassProvider()
- {
- }
-
- /**
- * @see ecologylab.serialization.TranslationsClassProvider#specificSuppliedClasses()
- */
- @Override
- protected Class extends Pref>>[] specificSuppliedClasses()
- {
- Class[] prefSetClasses =
- { MetaPref.class, MetaPrefSet.class, MetaPrefBoolean.class, MetaPrefFloat.class,
- MetaPrefInt.class, MetaPrefString.class,
-
- Pref.class, PrefSet.class, PrefBoolean.class, PrefDouble.class, PrefFloat.class,
- PrefInt.class, PrefLong.class, PrefString.class, PrefElementState.class, PrefFile.class,
- PrefOp.class,
-
- };
-
- return prefSetClasses;
- }
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.TranslationsClassProvider;
+
+/**
+ * Provides the list of Class'es used for translating the PrefSet class. This class is used to
+ * provide the base list of Class'es that will be provided to an ApplicationEnvironment.
+ *
+ * @author Zachary O. Toups (zach@ecologylab.net)
+ */
+public class PrefSetBaseClassProvider extends TranslationsClassProvider
+{
+ public static final PrefSetBaseClassProvider STATIC_INSTANCE = new PrefSetBaseClassProvider();
+
+ protected PrefSetBaseClassProvider()
+ {
+ }
+
+ /**
+ * @see ecologylab.serialization.TranslationsClassProvider#specificSuppliedClasses()
+ */
+ @Override
+ protected Class extends Pref>>[] specificSuppliedClasses()
+ {
+ Class[] prefSetClasses =
+ { MetaPref.class, MetaPrefSet.class, MetaPrefBoolean.class, MetaPrefFloat.class,
+ MetaPrefInt.class, MetaPrefString.class,
+
+ Pref.class, PrefSet.class, PrefBoolean.class, PrefDouble.class, PrefFloat.class,
+ PrefInt.class, PrefLong.class, PrefString.class, PrefElementState.class, PrefFile.class,
+ PrefOp.class,
+
+ };
+
+ return prefSetClasses;
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/PrefString.java b/simplCore/src/ecologylab/appframework/types/prefs/PrefString.java
index 8932a980..5318f42e 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/PrefString.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/PrefString.java
@@ -1,83 +1,83 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-
-/**
- * Preference that is a String
- *
- * @author andruid
- *
- */
-@simpl_inherit
-public class PrefString extends Pref
-{
- /**
- * Value of Pref
- */
- @simpl_scalar
- String value;
-
- /**
- *
- */
- public PrefString()
- {
- super();
- }
-
- /**
- * Instantiate Pref to value
- *
- * @param value
- */
- public PrefString(String value)
- {
- super();
- this.value = value;
- }
-
- public PrefString(String name, String value)
- {
- super(name);
-
- this.value = value;
- }
-
- /**
- * Get the value of the Pref
- *
- * @return The value of the Pref
- */
- @Override
- protected String getValue()
- {
- return value;
- }
-
- /**
- * Set the value of the Pref
- *
- * @param The
- * value the Pref will be set to
- */
- @Override
- public void setValue(String value)
- {
- this.value = value;
-
- prefChanged();
- }
-
- /**
- * @see ecologylab.appframework.types.prefs.Pref#clone()
- */
- @Override
- public Pref clone()
- {
- return new PrefString(this.name, this.value);
- }
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+
+/**
+ * Preference that is a String
+ *
+ * @author andruid
+ *
+ */
+@simpl_inherit
+public class PrefString extends Pref
+{
+ /**
+ * Value of Pref
+ */
+ @simpl_scalar
+ String value;
+
+ /**
+ *
+ */
+ public PrefString()
+ {
+ super();
+ }
+
+ /**
+ * Instantiate Pref to value
+ *
+ * @param value
+ */
+ public PrefString(String value)
+ {
+ super();
+ this.value = value;
+ }
+
+ public PrefString(String name, String value)
+ {
+ super(name);
+
+ this.value = value;
+ }
+
+ /**
+ * Get the value of the Pref
+ *
+ * @return The value of the Pref
+ */
+ @Override
+ protected String getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Set the value of the Pref
+ *
+ * @param The
+ * value the Pref will be set to
+ */
+ @Override
+ public void setValue(String value)
+ {
+ this.value = value;
+
+ prefChanged();
+ }
+
+ /**
+ * @see ecologylab.appframework.types.prefs.Pref#clone()
+ */
+ @Override
+ public Pref clone()
+ {
+ return new PrefString(this.name, this.value);
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/PrefVisual.java b/simplCore/src/ecologylab/appframework/types/prefs/PrefVisual.java
index 6cdf88a7..db145937 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/PrefVisual.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/PrefVisual.java
@@ -1,739 +1,739 @@
-package ecologylab.appframework.types.prefs;
-
-import java.awt.Dimension;
-import java.awt.Rectangle;
-
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JRadioButton;
-import javax.swing.JScrollPane;
-import javax.swing.JTabbedPane;
-import javax.swing.JTextField;
-import javax.swing.ScrollPaneConstants;
-import javax.swing.SwingConstants;
-
-public class PrefVisual {
-
- private JTabbedPane jTabbedPane = null;
- private JButton jButton = null; // @jve:decl-index=0:visual-constraint="708,77"
- private JDialog jDialog = null; // @jve:decl-index=0:visual-constraint="159,42"
- private JPanel jContentPane = null;
- private JButton jButton1 = null;
- private JButton jButton2 = null;
- private JButton jButton3 = null;
- private JPanel jContentPane1 = null;
- private JPanel jContentPane2 = null;
- private JPanel jContentPane3 = null;
- private JRadioButton crawlYes = null;
- private JRadioButton crawlNo = null;
- private JLabel crawl = null;
- private JLabel download_images_automaticallyLabel = null;
- private JRadioButton download_images_automaticallyYes = null;
- private JRadioButton download_images_automaticallyNo = null;
- private JLabel coolSpaceRatioLabel = null;
- private JTextField coolSpaceRatioField = null;
- private JLabel spatial_grid = null;
- private JRadioButton spatial_gridYes = null;
- private JRadioButton spatial_gridNo = null;
- private JLabel incontext_slider = null;
- private JRadioButton incontext_sliderYes = null;
- private JRadioButton incontext_sliderNo = null;
- private JLabel dashboard_enabled = null;
- private JRadioButton dashboard_enabledYes = null;
- private JRadioButton dashboard_enabledNo = null;
- private JLabel elements_per_square_inch = null;
- private JTextField elements_per_square_inchField = null;
- private JLabel undo_levels = null;
- private JTextField undo_levelsField = null;
- private JLabel log_mode = null;
- private JRadioButton log_modeNone = null;
- private JRadioButton log_modeDesktop = null;
- private JRadioButton log_modeServer = null;
- private JLabel javascript_debug_mode = null;
- private JRadioButton javascript_debug_modeYes = null;
- private JRadioButton javascript_debug_modeNo = null;
- private JLabel codebase = null;
- private JTextField codebaseField = null;
- private JLabel undo_levels1 = null;
- private JTextField undo_levelsField1 = null;
- private JLabel log_mode1 = null;
- private JRadioButton log_modeNone1 = null;
- private JRadioButton log_modeDesktop1 = null;
- private JRadioButton log_modeServer1 = null;
- private JLabel javascript_debug_mode1 = null;
- private JRadioButton javascript_debug_modeYes1 = null;
- private JRadioButton javascript_debug_modeNo1 = null;
- private JLabel codebase1 = null;
- private JTextField codebaseField1 = null;
- private JScrollPane jScrollPane = null;
- /**
- * This method initializes jTabbedPane
- *
- * @return javax.swing.JTabbedPane
- */
- private JTabbedPane getJTabbedPane() {
- if (jTabbedPane == null) {
- jTabbedPane = new JTabbedPane();
- jTabbedPane.setName("jTabbedPane");
- jTabbedPane.setBounds(new Rectangle(0, 0, 595, 416));
- jTabbedPane.addTab("General", null, getJContentPane1(), null);
- jTabbedPane.addTab("Gen2", null, getJScrollPane(), null);
- jTabbedPane.addTab("Developers", null, getJContentPane2(), null);
- }
- return jTabbedPane;
- }
-
- /**
- * This method initializes jDialog
- *
- * @return javax.swing.JDialog
- */
- private JDialog getJDialog() {
- if (jDialog == null) {
- jDialog = new JDialog();
- jDialog.setSize(new Dimension(603, 532));
- jDialog.setTitle("combinFormation Preferences");
- jDialog.setContentPane(getJContentPane());
- }
- return jDialog;
- }
-
- /**
- * This method initializes jContentPane
- *
- * @return javax.swing.JPanel
- */
- private JPanel getJContentPane() {
- if (jContentPane == null) {
- jContentPane = new JPanel();
- jContentPane.setLayout(null);
- jContentPane.add(getJTabbedPane(), null);
- jContentPane.add(getJButton1(), null);
- jContentPane.add(getJButton2(), null);
- jContentPane.add(getJButton3(), null);
- }
- return jContentPane;
- }
-
- /**
- * This method initializes jButton1
- *
- * @return javax.swing.JButton
- */
- private JButton getJButton1() {
- if (jButton1 == null) {
- jButton1 = new JButton();
- jButton1.setBounds(new Rectangle(482, 435, 89, 35));
- jButton1.setText("Cancel");
- }
- return jButton1;
- }
-
- /**
- * This method initializes jButton2
- *
- * @return javax.swing.JButton
- */
- private JButton getJButton2() {
- if (jButton2 == null) {
- jButton2 = new JButton();
- jButton2.setBounds(new Rectangle(379, 435, 89, 35));
- jButton2.setText("Save");
- }
- return jButton2;
- }
-
- /**
- * This method initializes jButton3
- *
- * @return javax.swing.JButton
- */
- private JButton getJButton3() {
- if (jButton3 == null) {
- jButton3 = new JButton();
- jButton3.setBounds(new Rectangle(15, 435, 137, 35));
- jButton3.setText("Revert to Default");
- }
- return jButton3;
- }
-
- /**
- * This method initializes jContentPane1
- *
- * @return javax.swing.JPanel
- */
- private JPanel getJContentPane1() {
- if (jContentPane1 == null) {
- elements_per_square_inch = new JLabel();
- elements_per_square_inch.setBounds(new Rectangle(30, 300, 292, 16));
- elements_per_square_inch.setText("Density: Visible elements per square inch [.1,20]");
- elements_per_square_inch.setToolTipText("Controls how many elements will appear in the information space, relative to the area of the space. The default value is .5 elements per square inch.
This lets you decide how many total elements the program will place into the space. Doubling this number, will double the number of elements.");
-
- dashboard_enabled = new JLabel();
- dashboard_enabled.setBounds(new Rectangle(30, 255, 224, 16));
- dashboard_enabled.setText("Enable the dashboard?");
- dashboard_enabled.setToolTipText("Use the dashboard to modify searches and other seeds.");
-
- incontext_slider = new JLabel();
- incontext_slider.setBounds(new Rectangle(30, 210, 341, 16));
- incontext_slider.setText("Enable in-context slider?");
- incontext_slider.setToolTipText("Use the in-context slider to enable fine-grained expression of interest in metadata fields and individual words.");
-
- spatial_grid = new JLabel();
- spatial_grid.setBounds(new Rectangle(30, 165, 366, 16));
- spatial_grid.setText("Composition agent automatically clusters related elements?");
- spatial_grid.setHorizontalTextPosition(SwingConstants.LEADING);
- spatial_grid.setToolTipText("Use the visual composition that automatically clusters related elements into piles. You may wish to move elements around, and sometimes, to re-cluster.");
-
- coolSpaceRatioLabel = new JLabel();
- coolSpaceRatioLabel.setBounds(new Rectangle(30, 120, 187, 16));
- coolSpaceRatioLabel.setToolTipText("The hot space is the composition area that you share with the program. The cool space is exclusively yours to work with.
This parameter defines the proportion of the whole information space that is dedicated as the cool space, at startup time.");
- coolSpaceRatioLabel.setText("Cool Space Ratio");
-
- download_images_automaticallyLabel = new JLabel();
- download_images_automaticallyLabel.setBounds(new Rectangle(30, 75, 289, 16));
- download_images_automaticallyLabel.setToolTipText("At startup, do you want the information collecting agent to download the images from the web pages it processes?");
- download_images_automaticallyLabel.setText("Download images automatically?");
-
- crawl = new JLabel();
- crawl.setBounds(new Rectangle(30, 30, 358, 16));
- crawl.setToolTipText("At startup, do you want the information collecting agent to act as a web crawler, by periodically following hyperlinks to download more documents?");
- crawl.setText("Download linked documents automatically (crawl)?");
-
-
-
- jContentPane1 = new JPanel();
- jContentPane1.setLayout(null);
- jContentPane1.add(crawl, null);
- jContentPane1.add(getCrawlYes(), null);
- jContentPane1.add(getCrawlNo(), null);
- jContentPane1.add(download_images_automaticallyLabel, null);
- jContentPane1.add(getDownload_images_automaticallyYes(), null);
- jContentPane1.add(getDownload_images_automaticallyNo(), null);
- jContentPane1.add(coolSpaceRatioLabel, null);
- jContentPane1.add(getCoolSpaceRatioField(), null);
- jContentPane1.add(spatial_grid, null);
- jContentPane1.add(getSpatial_gridYes(), null);
- jContentPane1.add(getSpatial_gridNo(), null);
- jContentPane1.add(incontext_slider, null);
- jContentPane1.add(getIncontext_sliderYes(), null);
- jContentPane1.add(getIncontext_sliderNo(), null);
- jContentPane1.add(dashboard_enabled, null);
- jContentPane1.add(getUse_dashboardYes(), null);
- jContentPane1.add(getUse_dashboardNo(), null);
- jContentPane1.add(elements_per_square_inch, null);
- jContentPane1.add(getElements_per_square_inchField(), null);
- }
- return jContentPane1;
- }
-
- /**
- * This method initializes jContentPane2
- *
- * @return javax.swing.JPanel
- */
- private JPanel getJContentPane2() {
- if (jContentPane2 == null) {
- codebase = new JLabel();
- codebase.setBounds(new Rectangle(30, 240, 268, 16));
- codebase.setText("Jar File Directory");
- codebase.setToolTipText("Directory for the project a developer is working on.");
-
- javascript_debug_mode = new JLabel();
- javascript_debug_mode.setBounds(new Rectangle(30, 180, 197, 16));
- javascript_debug_mode.setText("Javascript Debug Mode");
- javascript_debug_mode.setToolTipText("Shows or hides extra buttons that can be used for debugging the javascript. Allows direct access to cookies & arrays");
-
- log_mode = new JLabel();
- log_mode.setBounds(new Rectangle(30, 105, 271, 16));
- log_mode.setText("Log Mode");
- log_mode.setToolTipText("Controls whether or not logging of actions to a file by you and the program is performed during each session. The default is log to Desktop. With this option, you will have trace information available to help us, in case a bug is discovered.");
-
- undo_levels = new JLabel();
- undo_levels.setBounds(new Rectangle(30, 30, 271, 16));
- undo_levels.setText("Undo Levels");
- undo_levels.setToolTipText("The number of steps backwards you can go, by using undo, or the reverse button.");
-
- jContentPane2 = new JPanel();
- jContentPane2.setLayout(null);
- jContentPane2.setSize(new java.awt.Dimension(586,500));
- jContentPane2.add(undo_levels, null);
- jContentPane2.add(getUndo_levelsField(), null);
- jContentPane2.add(log_mode, null);
- jContentPane2.add(getLog_modeNone(), null);
- jContentPane2.add(getLog_modeDesktop(), null);
- jContentPane2.add(getLog_modeServer(), null);
- jContentPane2.add(javascript_debug_mode, null);
- jContentPane2.add(getJavascript_debug_modeYes(), null);
- jContentPane2.add(getJavascript_debug_modeNo(), null);
- jContentPane2.add(codebase, null);
- jContentPane2.add(getCodebaseField(), null);
- }
- return jContentPane2;
- }
-
- /**
- * This method initializes jContentPane2
- *
- * @return javax.swing.JPanel
- */
- private JPanel getJContentPane3() {
- if (jContentPane3 == null) {
- codebase1 = new JLabel();
- codebase1.setBounds(new Rectangle(30, 240, 268, 16));
- codebase1.setText("Jar File Directory");
- codebase1.setToolTipText("Directory for the project a developer is working on.");
-
- javascript_debug_mode1 = new JLabel();
- javascript_debug_mode1.setBounds(new Rectangle(30, 180, 197, 16));
- javascript_debug_mode1.setText("Javascript Debug Mode");
- javascript_debug_mode1.setToolTipText("Shows or hides extra buttons that can be used for debugging the javascript. Allows direct access to cookies & arrays");
-
- log_mode1 = new JLabel();
- log_mode1.setBounds(new Rectangle(30, 105, 271, 16));
- log_mode1.setText("Log Mode");
- log_mode1.setToolTipText("Controls whether or not logging of actions to a file by you and the program is performed during each session. The default is log to Desktop. With this option, you will have trace information available to help us, in case a bug is discovered.");
-
- undo_levels1 = new JLabel();
- undo_levels1.setBounds(new Rectangle(30, 30, 271, 16));
- undo_levels1.setText("Undo Levels");
- undo_levels1.setToolTipText("The number of steps backwards you can go, by using undo, or the reverse button.");
-
- jContentPane3 = new JPanel();
- jContentPane3.setLayout(null);
- jContentPane3.setSize(new java.awt.Dimension(586,500));
- jContentPane3.add(undo_levels1, null);
- jContentPane3.add(getUndo_levelsField1(), null);
- jContentPane3.add(log_mode1, null);
- jContentPane3.add(getLog_modeNone1(), null);
- jContentPane3.add(getLog_modeDesktop1(), null);
- jContentPane3.add(getLog_modeServer1(), null);
- jContentPane3.add(javascript_debug_mode1, null);
- jContentPane3.add(getJavascript_debug_modeYes1(), null);
- jContentPane3.add(getJavascript_debug_modeNo1(), null);
- jContentPane3.add(codebase1, null);
- jContentPane3.add(getCodebaseField1(), null);
- }
- return jContentPane3;
- }
-
- /**
- * This method initializes crawlYes
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getCrawlYes() {
- if (crawlYes == null) {
- crawlYes = new JRadioButton();
- crawlYes.setBounds(new Rectangle(417, 28, 54, 21));
- crawlYes.setSelected(true);
- crawlYes.setText("Yes");
- }
- return crawlYes;
- }
-
- /**
- * This method initializes crawlNo
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getCrawlNo() {
- if (crawlNo == null) {
- crawlNo = new JRadioButton();
- crawlNo.setBounds(new Rectangle(493, 28, 46, 21));
- crawlNo.setName("No");
- crawlNo.setText("No");
- }
- return crawlNo;
- }
-
- /**
- * This method initializes download_images_automaticallyYes
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getDownload_images_automaticallyYes() {
- if (download_images_automaticallyYes == null) {
- download_images_automaticallyYes = new JRadioButton();
- download_images_automaticallyYes.setBounds(new Rectangle(418, 70, 46, 24));
- download_images_automaticallyYes.setSelected(true);
- download_images_automaticallyYes.setText("Yes");
- }
- return download_images_automaticallyYes;
- }
-
- /**
- * This method initializes download_images_automaticallyNo
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getDownload_images_automaticallyNo() {
- if (download_images_automaticallyNo == null) {
- download_images_automaticallyNo = new JRadioButton();
- download_images_automaticallyNo.setBounds(new Rectangle(494, 70, 40, 24));
- download_images_automaticallyNo.setText("No");
- download_images_automaticallyNo.setName("No");
- }
- return download_images_automaticallyNo;
- }
-
- /**
- * This method initializes coolSpaceRatioField
- *
- * @return javax.swing.JTextField
- */
- private JTextField getCoolSpaceRatioField() {
- if (coolSpaceRatioField == null) {
- coolSpaceRatioField = new JTextField();
- coolSpaceRatioField.setBounds(new Rectangle(451, 118, 55, 20));
- coolSpaceRatioField.setHorizontalAlignment(SwingConstants.CENTER);
- coolSpaceRatioField.setText("0.2");
- }
- return coolSpaceRatioField;
- }
-
- /**
- * This method initializes spatial_gridYes
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getSpatial_gridYes() {
- if (spatial_gridYes == null) {
- spatial_gridYes = new JRadioButton();
- spatial_gridYes.setBounds(new Rectangle(419, 162, 46, 24));
- spatial_gridYes.setText("Yes");
- spatial_gridYes.setSelected(true);
- }
- return spatial_gridYes;
- }
-
- /**
- * This method initializes spatial_gridNo
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getSpatial_gridNo() {
- if (spatial_gridNo == null) {
- spatial_gridNo = new JRadioButton();
- spatial_gridNo.setBounds(new Rectangle(494, 161, 40, 24));
- spatial_gridNo.setText("No");
- spatial_gridNo.setName("No");
- }
- return spatial_gridNo;
- }
-
- /**
- * This method initializes incontext_sliderYes
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getIncontext_sliderYes() {
- if (incontext_sliderYes == null) {
- incontext_sliderYes = new JRadioButton();
- incontext_sliderYes.setBounds(new Rectangle(419, 206, 46, 24));
- incontext_sliderYes.setText("Yes");
- incontext_sliderYes.setEnabled(true);
- incontext_sliderYes.setSelected(false);
- }
- return incontext_sliderYes;
- }
-
- /**
- * This method initializes incontext_sliderNo
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getIncontext_sliderNo() {
- if (incontext_sliderNo == null) {
- incontext_sliderNo = new JRadioButton();
- incontext_sliderNo.setBounds(new Rectangle(494, 206, 40, 24));
- incontext_sliderNo.setText("No");
- incontext_sliderNo.setSelected(true);
- incontext_sliderNo.setName("No");
- }
- return incontext_sliderNo;
- }
-
- /**
- * This method initializes use_dashboardYes
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getUse_dashboardYes() {
- if (dashboard_enabledYes == null) {
- dashboard_enabledYes = new JRadioButton();
- dashboard_enabledYes.setBounds(new Rectangle(419, 251, 46, 24));
- dashboard_enabledYes.setSelected(false);
- dashboard_enabledYes.setText("Yes");
- dashboard_enabledYes.setEnabled(true);
- }
- return dashboard_enabledYes;
- }
-
- /**
- * This method initializes use_dashboardNo
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getUse_dashboardNo() {
- if (dashboard_enabledNo == null) {
- dashboard_enabledNo = new JRadioButton();
- dashboard_enabledNo.setBounds(new Rectangle(494, 251, 40, 24));
- dashboard_enabledNo.setSelected(true);
- dashboard_enabledNo.setText("No");
- dashboard_enabledNo.setName("No");
- }
- return dashboard_enabledNo;
- }
-
- /**
- * This method initializes elements_per_square_inchField
- *
- * @return javax.swing.JTextField
- */
- private JTextField getElements_per_square_inchField() {
- if (elements_per_square_inchField == null) {
- elements_per_square_inchField = new JTextField();
- elements_per_square_inchField.setBounds(new Rectangle(451, 298, 55, 20));
- elements_per_square_inchField.setHorizontalAlignment(SwingConstants.CENTER);
- elements_per_square_inchField.setText("0.7");
- }
- return elements_per_square_inchField;
- }
-
- /**
- * This method initializes undo_levelsField
- *
- * @return javax.swing.JTextField
- */
- private JTextField getUndo_levelsField() {
- if (undo_levelsField == null) {
- undo_levelsField = new JTextField();
- undo_levelsField.setBounds(new Rectangle(451, 28, 55, 20));
- undo_levelsField.setHorizontalAlignment(SwingConstants.CENTER);
- undo_levelsField.setText("32");
- }
- return undo_levelsField;
- }
-
- /**
- * This method initializes log_modeNone
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getLog_modeNone() {
- if (log_modeNone == null) {
- log_modeNone = new JRadioButton();
- log_modeNone.setBounds(new Rectangle(417, 78, 85, 24));
- log_modeNone.setText("no logging");
- log_modeNone.setHorizontalTextPosition(SwingConstants.TRAILING);
- log_modeNone.setSelected(false);
- }
- return log_modeNone;
- }
-
- /**
- * This method initializes log_modeDesktop
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getLog_modeDesktop() {
- if (log_modeDesktop == null) {
- log_modeDesktop = new JRadioButton();
- log_modeDesktop.setBounds(new Rectangle(417, 100, 131, 24));
- log_modeDesktop.setSelected(true);
- log_modeDesktop.setText("log to desktop file");
- log_modeDesktop.setHorizontalTextPosition(SwingConstants.TRAILING);
- }
- return log_modeDesktop;
- }
-
- /**
- * This method initializes log_modeServer
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getLog_modeServer() {
- if (log_modeServer == null) {
- log_modeServer = new JRadioButton();
- log_modeServer.setBounds(new Rectangle(417, 122, 148, 24));
- log_modeServer.setSelected(false);
- log_modeServer.setText("log to logging server");
- log_modeServer.setHorizontalTextPosition(SwingConstants.TRAILING);
- }
- return log_modeServer;
- }
-
- /**
- * This method initializes javascript_debug_modeYes
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getJavascript_debug_modeYes() {
- if (javascript_debug_modeYes == null) {
- javascript_debug_modeYes = new JRadioButton();
- javascript_debug_modeYes.setBounds(new Rectangle(417, 176, 46, 24));
- javascript_debug_modeYes.setText("Yes");
- javascript_debug_modeYes.setSelected(true);
- }
- return javascript_debug_modeYes;
- }
-
- /**
- * This method initializes javascript_debug_modeNo
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getJavascript_debug_modeNo() {
- if (javascript_debug_modeNo == null) {
- javascript_debug_modeNo = new JRadioButton();
- javascript_debug_modeNo.setBounds(new Rectangle(494, 176, 40, 24));
- javascript_debug_modeNo.setText("No");
- javascript_debug_modeNo.setName("No");
- }
- return javascript_debug_modeNo;
- }
-
- /**
- * This method initializes codebaseField
- *
- * @return javax.swing.JTextField
- */
- private JTextField getCodebaseField() {
- if (codebaseField == null) {
- codebaseField = new JTextField();
- codebaseField.setHorizontalAlignment(SwingConstants.CENTER);
- codebaseField.setBounds(new java.awt.Rectangle(421,238,114,20));
- codebaseField.setText("code/java");
- }
- return codebaseField;
- }
-
- /**
- * This method initializes undo_levelsField
- *
- * @return javax.swing.JTextField
- */
- private JTextField getUndo_levelsField1() {
- if (undo_levelsField1 == null) {
- undo_levelsField1 = new JTextField();
- undo_levelsField1.setBounds(new Rectangle(451, 28, 55, 20));
- undo_levelsField1.setHorizontalAlignment(SwingConstants.CENTER);
- undo_levelsField1.setText("32");
- }
- return undo_levelsField1;
- }
-
- /**
- * This method initializes log_modeNone
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getLog_modeNone1() {
- if (log_modeNone1 == null) {
- log_modeNone1 = new JRadioButton();
- log_modeNone1.setBounds(new Rectangle(417, 78, 85, 24));
- log_modeNone1.setText("no logging");
- log_modeNone1.setHorizontalTextPosition(SwingConstants.TRAILING);
- log_modeNone1.setSelected(false);
- }
- return log_modeNone1;
- }
-
- /**
- * This method initializes log_modeDesktop
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getLog_modeDesktop1() {
- if (log_modeDesktop1 == null) {
- log_modeDesktop1 = new JRadioButton();
- log_modeDesktop1.setBounds(new Rectangle(417, 100, 131, 24));
- log_modeDesktop1.setSelected(true);
- log_modeDesktop1.setText("log to desktop file");
- log_modeDesktop1.setHorizontalTextPosition(SwingConstants.TRAILING);
- }
- return log_modeDesktop1;
- }
-
- /**
- * This method initializes log_modeServer
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getLog_modeServer1() {
- if (log_modeServer1 == null) {
- log_modeServer1 = new JRadioButton();
- log_modeServer1.setBounds(new Rectangle(417, 122, 148, 24));
- log_modeServer1.setSelected(false);
- log_modeServer1.setText("log to logging server");
- log_modeServer1.setHorizontalTextPosition(SwingConstants.TRAILING);
- }
- return log_modeServer1;
- }
-
- /**
- * This method initializes javascript_debug_modeYes
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getJavascript_debug_modeYes1() {
- if (javascript_debug_modeYes1 == null) {
- javascript_debug_modeYes1 = new JRadioButton();
- javascript_debug_modeYes1.setBounds(new Rectangle(417, 176, 46, 24));
- javascript_debug_modeYes1.setText("Yes");
- javascript_debug_modeYes1.setSelected(true);
- }
- return javascript_debug_modeYes1;
- }
-
- /**
- * This method initializes javascript_debug_modeNo
- *
- * @return javax.swing.JRadioButton
- */
- private JRadioButton getJavascript_debug_modeNo1() {
- if (javascript_debug_modeNo1 == null) {
- javascript_debug_modeNo1 = new JRadioButton();
- javascript_debug_modeNo1.setBounds(new Rectangle(494, 176, 40, 24));
- javascript_debug_modeNo1.setText("No");
- javascript_debug_modeNo1.setName("No");
- }
- return javascript_debug_modeNo1;
- }
-
- /**
- * This method initializes codebaseField
- *
- * @return javax.swing.JTextField
- */
- private JTextField getCodebaseField1() {
- if (codebaseField1 == null) {
- codebaseField1 = new JTextField();
- codebaseField1.setHorizontalAlignment(SwingConstants.CENTER);
- codebaseField1.setBounds(new java.awt.Rectangle(421,238,114,20));
- codebaseField1.setText("code/java");
- }
- return codebaseField1;
- }
-
- /**
- * This method initializes jScrollPane
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getJScrollPane() {
- if (jScrollPane == null) {
- jScrollPane = new JScrollPane();
- jScrollPane.setPreferredSize(new java.awt.Dimension(500,500));
- jScrollPane.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT);
- jScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
- jScrollPane.setName("");
- jScrollPane.setViewportView(getJContentPane3());
- }
- return jScrollPane;
- }
-
-}
+package ecologylab.appframework.types.prefs;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JScrollPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextField;
+import javax.swing.ScrollPaneConstants;
+import javax.swing.SwingConstants;
+
+public class PrefVisual {
+
+ private JTabbedPane jTabbedPane = null;
+ private JButton jButton = null; // @jve:decl-index=0:visual-constraint="708,77"
+ private JDialog jDialog = null; // @jve:decl-index=0:visual-constraint="159,42"
+ private JPanel jContentPane = null;
+ private JButton jButton1 = null;
+ private JButton jButton2 = null;
+ private JButton jButton3 = null;
+ private JPanel jContentPane1 = null;
+ private JPanel jContentPane2 = null;
+ private JPanel jContentPane3 = null;
+ private JRadioButton crawlYes = null;
+ private JRadioButton crawlNo = null;
+ private JLabel crawl = null;
+ private JLabel download_images_automaticallyLabel = null;
+ private JRadioButton download_images_automaticallyYes = null;
+ private JRadioButton download_images_automaticallyNo = null;
+ private JLabel coolSpaceRatioLabel = null;
+ private JTextField coolSpaceRatioField = null;
+ private JLabel spatial_grid = null;
+ private JRadioButton spatial_gridYes = null;
+ private JRadioButton spatial_gridNo = null;
+ private JLabel incontext_slider = null;
+ private JRadioButton incontext_sliderYes = null;
+ private JRadioButton incontext_sliderNo = null;
+ private JLabel dashboard_enabled = null;
+ private JRadioButton dashboard_enabledYes = null;
+ private JRadioButton dashboard_enabledNo = null;
+ private JLabel elements_per_square_inch = null;
+ private JTextField elements_per_square_inchField = null;
+ private JLabel undo_levels = null;
+ private JTextField undo_levelsField = null;
+ private JLabel log_mode = null;
+ private JRadioButton log_modeNone = null;
+ private JRadioButton log_modeDesktop = null;
+ private JRadioButton log_modeServer = null;
+ private JLabel javascript_debug_mode = null;
+ private JRadioButton javascript_debug_modeYes = null;
+ private JRadioButton javascript_debug_modeNo = null;
+ private JLabel codebase = null;
+ private JTextField codebaseField = null;
+ private JLabel undo_levels1 = null;
+ private JTextField undo_levelsField1 = null;
+ private JLabel log_mode1 = null;
+ private JRadioButton log_modeNone1 = null;
+ private JRadioButton log_modeDesktop1 = null;
+ private JRadioButton log_modeServer1 = null;
+ private JLabel javascript_debug_mode1 = null;
+ private JRadioButton javascript_debug_modeYes1 = null;
+ private JRadioButton javascript_debug_modeNo1 = null;
+ private JLabel codebase1 = null;
+ private JTextField codebaseField1 = null;
+ private JScrollPane jScrollPane = null;
+ /**
+ * This method initializes jTabbedPane
+ *
+ * @return javax.swing.JTabbedPane
+ */
+ private JTabbedPane getJTabbedPane() {
+ if (jTabbedPane == null) {
+ jTabbedPane = new JTabbedPane();
+ jTabbedPane.setName("jTabbedPane");
+ jTabbedPane.setBounds(new Rectangle(0, 0, 595, 416));
+ jTabbedPane.addTab("General", null, getJContentPane1(), null);
+ jTabbedPane.addTab("Gen2", null, getJScrollPane(), null);
+ jTabbedPane.addTab("Developers", null, getJContentPane2(), null);
+ }
+ return jTabbedPane;
+ }
+
+ /**
+ * This method initializes jDialog
+ *
+ * @return javax.swing.JDialog
+ */
+ private JDialog getJDialog() {
+ if (jDialog == null) {
+ jDialog = new JDialog();
+ jDialog.setSize(new Dimension(603, 532));
+ jDialog.setTitle("combinFormation Preferences");
+ jDialog.setContentPane(getJContentPane());
+ }
+ return jDialog;
+ }
+
+ /**
+ * This method initializes jContentPane
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jContentPane = new JPanel();
+ jContentPane.setLayout(null);
+ jContentPane.add(getJTabbedPane(), null);
+ jContentPane.add(getJButton1(), null);
+ jContentPane.add(getJButton2(), null);
+ jContentPane.add(getJButton3(), null);
+ }
+ return jContentPane;
+ }
+
+ /**
+ * This method initializes jButton1
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getJButton1() {
+ if (jButton1 == null) {
+ jButton1 = new JButton();
+ jButton1.setBounds(new Rectangle(482, 435, 89, 35));
+ jButton1.setText("Cancel");
+ }
+ return jButton1;
+ }
+
+ /**
+ * This method initializes jButton2
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getJButton2() {
+ if (jButton2 == null) {
+ jButton2 = new JButton();
+ jButton2.setBounds(new Rectangle(379, 435, 89, 35));
+ jButton2.setText("Save");
+ }
+ return jButton2;
+ }
+
+ /**
+ * This method initializes jButton3
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getJButton3() {
+ if (jButton3 == null) {
+ jButton3 = new JButton();
+ jButton3.setBounds(new Rectangle(15, 435, 137, 35));
+ jButton3.setText("Revert to Default");
+ }
+ return jButton3;
+ }
+
+ /**
+ * This method initializes jContentPane1
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJContentPane1() {
+ if (jContentPane1 == null) {
+ elements_per_square_inch = new JLabel();
+ elements_per_square_inch.setBounds(new Rectangle(30, 300, 292, 16));
+ elements_per_square_inch.setText("Density: Visible elements per square inch [.1,20]");
+ elements_per_square_inch.setToolTipText("Controls how many elements will appear in the information space, relative to the area of the space. The default value is .5 elements per square inch.
This lets you decide how many total elements the program will place into the space. Doubling this number, will double the number of elements.");
+
+ dashboard_enabled = new JLabel();
+ dashboard_enabled.setBounds(new Rectangle(30, 255, 224, 16));
+ dashboard_enabled.setText("Enable the dashboard?");
+ dashboard_enabled.setToolTipText("Use the dashboard to modify searches and other seeds.");
+
+ incontext_slider = new JLabel();
+ incontext_slider.setBounds(new Rectangle(30, 210, 341, 16));
+ incontext_slider.setText("Enable in-context slider?");
+ incontext_slider.setToolTipText("Use the in-context slider to enable fine-grained expression of interest in metadata fields and individual words.");
+
+ spatial_grid = new JLabel();
+ spatial_grid.setBounds(new Rectangle(30, 165, 366, 16));
+ spatial_grid.setText("Composition agent automatically clusters related elements?");
+ spatial_grid.setHorizontalTextPosition(SwingConstants.LEADING);
+ spatial_grid.setToolTipText("Use the visual composition that automatically clusters related elements into piles. You may wish to move elements around, and sometimes, to re-cluster.");
+
+ coolSpaceRatioLabel = new JLabel();
+ coolSpaceRatioLabel.setBounds(new Rectangle(30, 120, 187, 16));
+ coolSpaceRatioLabel.setToolTipText("The hot space is the composition area that you share with the program. The cool space is exclusively yours to work with.
This parameter defines the proportion of the whole information space that is dedicated as the cool space, at startup time.");
+ coolSpaceRatioLabel.setText("Cool Space Ratio");
+
+ download_images_automaticallyLabel = new JLabel();
+ download_images_automaticallyLabel.setBounds(new Rectangle(30, 75, 289, 16));
+ download_images_automaticallyLabel.setToolTipText("At startup, do you want the information collecting agent to download the images from the web pages it processes?");
+ download_images_automaticallyLabel.setText("Download images automatically?");
+
+ crawl = new JLabel();
+ crawl.setBounds(new Rectangle(30, 30, 358, 16));
+ crawl.setToolTipText("At startup, do you want the information collecting agent to act as a web crawler, by periodically following hyperlinks to download more documents?");
+ crawl.setText("Download linked documents automatically (crawl)?");
+
+
+
+ jContentPane1 = new JPanel();
+ jContentPane1.setLayout(null);
+ jContentPane1.add(crawl, null);
+ jContentPane1.add(getCrawlYes(), null);
+ jContentPane1.add(getCrawlNo(), null);
+ jContentPane1.add(download_images_automaticallyLabel, null);
+ jContentPane1.add(getDownload_images_automaticallyYes(), null);
+ jContentPane1.add(getDownload_images_automaticallyNo(), null);
+ jContentPane1.add(coolSpaceRatioLabel, null);
+ jContentPane1.add(getCoolSpaceRatioField(), null);
+ jContentPane1.add(spatial_grid, null);
+ jContentPane1.add(getSpatial_gridYes(), null);
+ jContentPane1.add(getSpatial_gridNo(), null);
+ jContentPane1.add(incontext_slider, null);
+ jContentPane1.add(getIncontext_sliderYes(), null);
+ jContentPane1.add(getIncontext_sliderNo(), null);
+ jContentPane1.add(dashboard_enabled, null);
+ jContentPane1.add(getUse_dashboardYes(), null);
+ jContentPane1.add(getUse_dashboardNo(), null);
+ jContentPane1.add(elements_per_square_inch, null);
+ jContentPane1.add(getElements_per_square_inchField(), null);
+ }
+ return jContentPane1;
+ }
+
+ /**
+ * This method initializes jContentPane2
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJContentPane2() {
+ if (jContentPane2 == null) {
+ codebase = new JLabel();
+ codebase.setBounds(new Rectangle(30, 240, 268, 16));
+ codebase.setText("Jar File Directory");
+ codebase.setToolTipText("Directory for the project a developer is working on.");
+
+ javascript_debug_mode = new JLabel();
+ javascript_debug_mode.setBounds(new Rectangle(30, 180, 197, 16));
+ javascript_debug_mode.setText("Javascript Debug Mode");
+ javascript_debug_mode.setToolTipText("Shows or hides extra buttons that can be used for debugging the javascript. Allows direct access to cookies & arrays");
+
+ log_mode = new JLabel();
+ log_mode.setBounds(new Rectangle(30, 105, 271, 16));
+ log_mode.setText("Log Mode");
+ log_mode.setToolTipText("Controls whether or not logging of actions to a file by you and the program is performed during each session. The default is log to Desktop. With this option, you will have trace information available to help us, in case a bug is discovered.");
+
+ undo_levels = new JLabel();
+ undo_levels.setBounds(new Rectangle(30, 30, 271, 16));
+ undo_levels.setText("Undo Levels");
+ undo_levels.setToolTipText("The number of steps backwards you can go, by using undo, or the reverse button.");
+
+ jContentPane2 = new JPanel();
+ jContentPane2.setLayout(null);
+ jContentPane2.setSize(new java.awt.Dimension(586,500));
+ jContentPane2.add(undo_levels, null);
+ jContentPane2.add(getUndo_levelsField(), null);
+ jContentPane2.add(log_mode, null);
+ jContentPane2.add(getLog_modeNone(), null);
+ jContentPane2.add(getLog_modeDesktop(), null);
+ jContentPane2.add(getLog_modeServer(), null);
+ jContentPane2.add(javascript_debug_mode, null);
+ jContentPane2.add(getJavascript_debug_modeYes(), null);
+ jContentPane2.add(getJavascript_debug_modeNo(), null);
+ jContentPane2.add(codebase, null);
+ jContentPane2.add(getCodebaseField(), null);
+ }
+ return jContentPane2;
+ }
+
+ /**
+ * This method initializes jContentPane2
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJContentPane3() {
+ if (jContentPane3 == null) {
+ codebase1 = new JLabel();
+ codebase1.setBounds(new Rectangle(30, 240, 268, 16));
+ codebase1.setText("Jar File Directory");
+ codebase1.setToolTipText("Directory for the project a developer is working on.");
+
+ javascript_debug_mode1 = new JLabel();
+ javascript_debug_mode1.setBounds(new Rectangle(30, 180, 197, 16));
+ javascript_debug_mode1.setText("Javascript Debug Mode");
+ javascript_debug_mode1.setToolTipText("Shows or hides extra buttons that can be used for debugging the javascript. Allows direct access to cookies & arrays");
+
+ log_mode1 = new JLabel();
+ log_mode1.setBounds(new Rectangle(30, 105, 271, 16));
+ log_mode1.setText("Log Mode");
+ log_mode1.setToolTipText("Controls whether or not logging of actions to a file by you and the program is performed during each session. The default is log to Desktop. With this option, you will have trace information available to help us, in case a bug is discovered.");
+
+ undo_levels1 = new JLabel();
+ undo_levels1.setBounds(new Rectangle(30, 30, 271, 16));
+ undo_levels1.setText("Undo Levels");
+ undo_levels1.setToolTipText("The number of steps backwards you can go, by using undo, or the reverse button.");
+
+ jContentPane3 = new JPanel();
+ jContentPane3.setLayout(null);
+ jContentPane3.setSize(new java.awt.Dimension(586,500));
+ jContentPane3.add(undo_levels1, null);
+ jContentPane3.add(getUndo_levelsField1(), null);
+ jContentPane3.add(log_mode1, null);
+ jContentPane3.add(getLog_modeNone1(), null);
+ jContentPane3.add(getLog_modeDesktop1(), null);
+ jContentPane3.add(getLog_modeServer1(), null);
+ jContentPane3.add(javascript_debug_mode1, null);
+ jContentPane3.add(getJavascript_debug_modeYes1(), null);
+ jContentPane3.add(getJavascript_debug_modeNo1(), null);
+ jContentPane3.add(codebase1, null);
+ jContentPane3.add(getCodebaseField1(), null);
+ }
+ return jContentPane3;
+ }
+
+ /**
+ * This method initializes crawlYes
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getCrawlYes() {
+ if (crawlYes == null) {
+ crawlYes = new JRadioButton();
+ crawlYes.setBounds(new Rectangle(417, 28, 54, 21));
+ crawlYes.setSelected(true);
+ crawlYes.setText("Yes");
+ }
+ return crawlYes;
+ }
+
+ /**
+ * This method initializes crawlNo
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getCrawlNo() {
+ if (crawlNo == null) {
+ crawlNo = new JRadioButton();
+ crawlNo.setBounds(new Rectangle(493, 28, 46, 21));
+ crawlNo.setName("No");
+ crawlNo.setText("No");
+ }
+ return crawlNo;
+ }
+
+ /**
+ * This method initializes download_images_automaticallyYes
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getDownload_images_automaticallyYes() {
+ if (download_images_automaticallyYes == null) {
+ download_images_automaticallyYes = new JRadioButton();
+ download_images_automaticallyYes.setBounds(new Rectangle(418, 70, 46, 24));
+ download_images_automaticallyYes.setSelected(true);
+ download_images_automaticallyYes.setText("Yes");
+ }
+ return download_images_automaticallyYes;
+ }
+
+ /**
+ * This method initializes download_images_automaticallyNo
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getDownload_images_automaticallyNo() {
+ if (download_images_automaticallyNo == null) {
+ download_images_automaticallyNo = new JRadioButton();
+ download_images_automaticallyNo.setBounds(new Rectangle(494, 70, 40, 24));
+ download_images_automaticallyNo.setText("No");
+ download_images_automaticallyNo.setName("No");
+ }
+ return download_images_automaticallyNo;
+ }
+
+ /**
+ * This method initializes coolSpaceRatioField
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getCoolSpaceRatioField() {
+ if (coolSpaceRatioField == null) {
+ coolSpaceRatioField = new JTextField();
+ coolSpaceRatioField.setBounds(new Rectangle(451, 118, 55, 20));
+ coolSpaceRatioField.setHorizontalAlignment(SwingConstants.CENTER);
+ coolSpaceRatioField.setText("0.2");
+ }
+ return coolSpaceRatioField;
+ }
+
+ /**
+ * This method initializes spatial_gridYes
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getSpatial_gridYes() {
+ if (spatial_gridYes == null) {
+ spatial_gridYes = new JRadioButton();
+ spatial_gridYes.setBounds(new Rectangle(419, 162, 46, 24));
+ spatial_gridYes.setText("Yes");
+ spatial_gridYes.setSelected(true);
+ }
+ return spatial_gridYes;
+ }
+
+ /**
+ * This method initializes spatial_gridNo
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getSpatial_gridNo() {
+ if (spatial_gridNo == null) {
+ spatial_gridNo = new JRadioButton();
+ spatial_gridNo.setBounds(new Rectangle(494, 161, 40, 24));
+ spatial_gridNo.setText("No");
+ spatial_gridNo.setName("No");
+ }
+ return spatial_gridNo;
+ }
+
+ /**
+ * This method initializes incontext_sliderYes
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getIncontext_sliderYes() {
+ if (incontext_sliderYes == null) {
+ incontext_sliderYes = new JRadioButton();
+ incontext_sliderYes.setBounds(new Rectangle(419, 206, 46, 24));
+ incontext_sliderYes.setText("Yes");
+ incontext_sliderYes.setEnabled(true);
+ incontext_sliderYes.setSelected(false);
+ }
+ return incontext_sliderYes;
+ }
+
+ /**
+ * This method initializes incontext_sliderNo
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getIncontext_sliderNo() {
+ if (incontext_sliderNo == null) {
+ incontext_sliderNo = new JRadioButton();
+ incontext_sliderNo.setBounds(new Rectangle(494, 206, 40, 24));
+ incontext_sliderNo.setText("No");
+ incontext_sliderNo.setSelected(true);
+ incontext_sliderNo.setName("No");
+ }
+ return incontext_sliderNo;
+ }
+
+ /**
+ * This method initializes use_dashboardYes
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getUse_dashboardYes() {
+ if (dashboard_enabledYes == null) {
+ dashboard_enabledYes = new JRadioButton();
+ dashboard_enabledYes.setBounds(new Rectangle(419, 251, 46, 24));
+ dashboard_enabledYes.setSelected(false);
+ dashboard_enabledYes.setText("Yes");
+ dashboard_enabledYes.setEnabled(true);
+ }
+ return dashboard_enabledYes;
+ }
+
+ /**
+ * This method initializes use_dashboardNo
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getUse_dashboardNo() {
+ if (dashboard_enabledNo == null) {
+ dashboard_enabledNo = new JRadioButton();
+ dashboard_enabledNo.setBounds(new Rectangle(494, 251, 40, 24));
+ dashboard_enabledNo.setSelected(true);
+ dashboard_enabledNo.setText("No");
+ dashboard_enabledNo.setName("No");
+ }
+ return dashboard_enabledNo;
+ }
+
+ /**
+ * This method initializes elements_per_square_inchField
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getElements_per_square_inchField() {
+ if (elements_per_square_inchField == null) {
+ elements_per_square_inchField = new JTextField();
+ elements_per_square_inchField.setBounds(new Rectangle(451, 298, 55, 20));
+ elements_per_square_inchField.setHorizontalAlignment(SwingConstants.CENTER);
+ elements_per_square_inchField.setText("0.7");
+ }
+ return elements_per_square_inchField;
+ }
+
+ /**
+ * This method initializes undo_levelsField
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getUndo_levelsField() {
+ if (undo_levelsField == null) {
+ undo_levelsField = new JTextField();
+ undo_levelsField.setBounds(new Rectangle(451, 28, 55, 20));
+ undo_levelsField.setHorizontalAlignment(SwingConstants.CENTER);
+ undo_levelsField.setText("32");
+ }
+ return undo_levelsField;
+ }
+
+ /**
+ * This method initializes log_modeNone
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getLog_modeNone() {
+ if (log_modeNone == null) {
+ log_modeNone = new JRadioButton();
+ log_modeNone.setBounds(new Rectangle(417, 78, 85, 24));
+ log_modeNone.setText("no logging");
+ log_modeNone.setHorizontalTextPosition(SwingConstants.TRAILING);
+ log_modeNone.setSelected(false);
+ }
+ return log_modeNone;
+ }
+
+ /**
+ * This method initializes log_modeDesktop
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getLog_modeDesktop() {
+ if (log_modeDesktop == null) {
+ log_modeDesktop = new JRadioButton();
+ log_modeDesktop.setBounds(new Rectangle(417, 100, 131, 24));
+ log_modeDesktop.setSelected(true);
+ log_modeDesktop.setText("log to desktop file");
+ log_modeDesktop.setHorizontalTextPosition(SwingConstants.TRAILING);
+ }
+ return log_modeDesktop;
+ }
+
+ /**
+ * This method initializes log_modeServer
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getLog_modeServer() {
+ if (log_modeServer == null) {
+ log_modeServer = new JRadioButton();
+ log_modeServer.setBounds(new Rectangle(417, 122, 148, 24));
+ log_modeServer.setSelected(false);
+ log_modeServer.setText("log to logging server");
+ log_modeServer.setHorizontalTextPosition(SwingConstants.TRAILING);
+ }
+ return log_modeServer;
+ }
+
+ /**
+ * This method initializes javascript_debug_modeYes
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getJavascript_debug_modeYes() {
+ if (javascript_debug_modeYes == null) {
+ javascript_debug_modeYes = new JRadioButton();
+ javascript_debug_modeYes.setBounds(new Rectangle(417, 176, 46, 24));
+ javascript_debug_modeYes.setText("Yes");
+ javascript_debug_modeYes.setSelected(true);
+ }
+ return javascript_debug_modeYes;
+ }
+
+ /**
+ * This method initializes javascript_debug_modeNo
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getJavascript_debug_modeNo() {
+ if (javascript_debug_modeNo == null) {
+ javascript_debug_modeNo = new JRadioButton();
+ javascript_debug_modeNo.setBounds(new Rectangle(494, 176, 40, 24));
+ javascript_debug_modeNo.setText("No");
+ javascript_debug_modeNo.setName("No");
+ }
+ return javascript_debug_modeNo;
+ }
+
+ /**
+ * This method initializes codebaseField
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getCodebaseField() {
+ if (codebaseField == null) {
+ codebaseField = new JTextField();
+ codebaseField.setHorizontalAlignment(SwingConstants.CENTER);
+ codebaseField.setBounds(new java.awt.Rectangle(421,238,114,20));
+ codebaseField.setText("code/java");
+ }
+ return codebaseField;
+ }
+
+ /**
+ * This method initializes undo_levelsField
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getUndo_levelsField1() {
+ if (undo_levelsField1 == null) {
+ undo_levelsField1 = new JTextField();
+ undo_levelsField1.setBounds(new Rectangle(451, 28, 55, 20));
+ undo_levelsField1.setHorizontalAlignment(SwingConstants.CENTER);
+ undo_levelsField1.setText("32");
+ }
+ return undo_levelsField1;
+ }
+
+ /**
+ * This method initializes log_modeNone
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getLog_modeNone1() {
+ if (log_modeNone1 == null) {
+ log_modeNone1 = new JRadioButton();
+ log_modeNone1.setBounds(new Rectangle(417, 78, 85, 24));
+ log_modeNone1.setText("no logging");
+ log_modeNone1.setHorizontalTextPosition(SwingConstants.TRAILING);
+ log_modeNone1.setSelected(false);
+ }
+ return log_modeNone1;
+ }
+
+ /**
+ * This method initializes log_modeDesktop
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getLog_modeDesktop1() {
+ if (log_modeDesktop1 == null) {
+ log_modeDesktop1 = new JRadioButton();
+ log_modeDesktop1.setBounds(new Rectangle(417, 100, 131, 24));
+ log_modeDesktop1.setSelected(true);
+ log_modeDesktop1.setText("log to desktop file");
+ log_modeDesktop1.setHorizontalTextPosition(SwingConstants.TRAILING);
+ }
+ return log_modeDesktop1;
+ }
+
+ /**
+ * This method initializes log_modeServer
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getLog_modeServer1() {
+ if (log_modeServer1 == null) {
+ log_modeServer1 = new JRadioButton();
+ log_modeServer1.setBounds(new Rectangle(417, 122, 148, 24));
+ log_modeServer1.setSelected(false);
+ log_modeServer1.setText("log to logging server");
+ log_modeServer1.setHorizontalTextPosition(SwingConstants.TRAILING);
+ }
+ return log_modeServer1;
+ }
+
+ /**
+ * This method initializes javascript_debug_modeYes
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getJavascript_debug_modeYes1() {
+ if (javascript_debug_modeYes1 == null) {
+ javascript_debug_modeYes1 = new JRadioButton();
+ javascript_debug_modeYes1.setBounds(new Rectangle(417, 176, 46, 24));
+ javascript_debug_modeYes1.setText("Yes");
+ javascript_debug_modeYes1.setSelected(true);
+ }
+ return javascript_debug_modeYes1;
+ }
+
+ /**
+ * This method initializes javascript_debug_modeNo
+ *
+ * @return javax.swing.JRadioButton
+ */
+ private JRadioButton getJavascript_debug_modeNo1() {
+ if (javascript_debug_modeNo1 == null) {
+ javascript_debug_modeNo1 = new JRadioButton();
+ javascript_debug_modeNo1.setBounds(new Rectangle(494, 176, 40, 24));
+ javascript_debug_modeNo1.setText("No");
+ javascript_debug_modeNo1.setName("No");
+ }
+ return javascript_debug_modeNo1;
+ }
+
+ /**
+ * This method initializes codebaseField
+ *
+ * @return javax.swing.JTextField
+ */
+ private JTextField getCodebaseField1() {
+ if (codebaseField1 == null) {
+ codebaseField1 = new JTextField();
+ codebaseField1.setHorizontalAlignment(SwingConstants.CENTER);
+ codebaseField1.setBounds(new java.awt.Rectangle(421,238,114,20));
+ codebaseField1.setText("code/java");
+ }
+ return codebaseField1;
+ }
+
+ /**
+ * This method initializes jScrollPane
+ *
+ * @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setPreferredSize(new java.awt.Dimension(500,500));
+ jScrollPane.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT);
+ jScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
+ jScrollPane.setName("");
+ jScrollPane.setViewportView(getJContentPane3());
+ }
+ return jScrollPane;
+ }
+
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/PrefsTranslationsProvider.java b/simplCore/src/ecologylab/appframework/types/prefs/PrefsTranslationsProvider.java
index 4c128fd7..ca588e48 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/PrefsTranslationsProvider.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/PrefsTranslationsProvider.java
@@ -1,47 +1,47 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.generic.Debug;
-import ecologylab.serialization.SimplTypesScope;
-import ecologylab.serialization.types.element.ElementTypeTranslationsProvider;
-
-/**
- * Translations for the pref/meta_pref system.
- *
- * @author Cae
- * @author Zachary O. Toups (zach@ecologylab.net)
- */
-public class PrefsTranslationsProvider extends Debug
-{
- /**
- * Package name
- */
- public static final String PREFS_TRANSLATIONS_NAME = "PREFS_TRANSLATIONS_NAME";
-
- /**
- * Additional classes needed to do Prefs translations. Most are provided by
- * PrefSetBaseClassProvider.
- */
- private static final Class[] translations =
- { RangeState.class,
- RangeIntState.class, RangeFloatState.class,
-
- Choice.class, ChoiceInt.class, ChoiceBoolean.class, ChoiceFloat.class };
-
- public static final PrefsTranslationsProvider STATIC_INSTANCE = new PrefsTranslationsProvider();
-
- private PrefsTranslationsProvider()
- {
- }
-
- /**
- * Get the translation space
- */
- public static SimplTypesScope get()
- {
- return SimplTypesScope.get(PREFS_TRANSLATIONS_NAME, ElementTypeTranslationsProvider.get(),
- translations, PrefSetBaseClassProvider.STATIC_INSTANCE.provideClasses());
- }
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.generic.Debug;
+import ecologylab.serialization.SimplTypesScope;
+import ecologylab.serialization.types.element.ElementTypeTranslationsProvider;
+
+/**
+ * Translations for the pref/meta_pref system.
+ *
+ * @author Cae
+ * @author Zachary O. Toups (zach@ecologylab.net)
+ */
+public class PrefsTranslationsProvider extends Debug
+{
+ /**
+ * Package name
+ */
+ public static final String PREFS_TRANSLATIONS_NAME = "PREFS_TRANSLATIONS_NAME";
+
+ /**
+ * Additional classes needed to do Prefs translations. Most are provided by
+ * PrefSetBaseClassProvider.
+ */
+ private static final Class[] translations =
+ { RangeState.class,
+ RangeIntState.class, RangeFloatState.class,
+
+ Choice.class, ChoiceInt.class, ChoiceBoolean.class, ChoiceFloat.class };
+
+ public static final PrefsTranslationsProvider STATIC_INSTANCE = new PrefsTranslationsProvider();
+
+ private PrefsTranslationsProvider()
+ {
+ }
+
+ /**
+ * Get the translation space
+ */
+ public static SimplTypesScope get()
+ {
+ return SimplTypesScope.get(PREFS_TRANSLATIONS_NAME, ElementTypeTranslationsProvider.get(),
+ translations, PrefSetBaseClassProvider.STATIC_INSTANCE.provideClasses());
+ }
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/RangeFloatState.java b/simplCore/src/ecologylab/appframework/types/prefs/RangeFloatState.java
index c2d5a82e..1b400c5a 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/RangeFloatState.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/RangeFloatState.java
@@ -1,77 +1,77 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.ElementState;
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-
-/**
- * @author andruid
- *
- */
-@simpl_inherit
-public class RangeFloatState extends ElementState /* RangeState */
-{
- /**
- * Min value.
- */
- @simpl_scalar float min;
- /**
- * Max value.
- */
- @simpl_scalar float max;
-
- /**
- *
- */
- public RangeFloatState()
- {
- super();
- }
-
-/**
- * Check to see that the newValue is within the range specifed by this.
- * @param newValue
- * @return
- */
- protected boolean isWithinRange(Float newValue)
- {
- float value = newValue.floatValue();
- return (min <= value) && (value <= max);
- }
-
- /**
- * Get max value.
- */
- public Float getMax()
- {
- return this.max;
- }
-
- /**
- * Get min value.
- */
- public Float getMin()
- {
- return this.min;
- }
-
- /**
- * Set max value.
- */
- public void setMax(Float newValue)
- {
- this.max = newValue;
- }
-
- /**
- * Set min value.
- */
- public void setMin(Float newValue)
- {
- this.min = newValue;
- }
-
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.ElementState;
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+
+/**
+ * @author andruid
+ *
+ */
+@simpl_inherit
+public class RangeFloatState extends ElementState /* RangeState */
+{
+ /**
+ * Min value.
+ */
+ @simpl_scalar float min;
+ /**
+ * Max value.
+ */
+ @simpl_scalar float max;
+
+ /**
+ *
+ */
+ public RangeFloatState()
+ {
+ super();
+ }
+
+/**
+ * Check to see that the newValue is within the range specifed by this.
+ * @param newValue
+ * @return
+ */
+ protected boolean isWithinRange(Float newValue)
+ {
+ float value = newValue.floatValue();
+ return (min <= value) && (value <= max);
+ }
+
+ /**
+ * Get max value.
+ */
+ public Float getMax()
+ {
+ return this.max;
+ }
+
+ /**
+ * Get min value.
+ */
+ public Float getMin()
+ {
+ return this.min;
+ }
+
+ /**
+ * Set max value.
+ */
+ public void setMax(Float newValue)
+ {
+ this.max = newValue;
+ }
+
+ /**
+ * Set min value.
+ */
+ public void setMin(Float newValue)
+ {
+ this.min = newValue;
+ }
+
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/RangeIntState.java b/simplCore/src/ecologylab/appframework/types/prefs/RangeIntState.java
index 1baabb35..bdb80e06 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/RangeIntState.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/RangeIntState.java
@@ -1,77 +1,77 @@
-/**
- *
- */
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.ElementState;
-import ecologylab.serialization.annotations.simpl_inherit;
-import ecologylab.serialization.annotations.simpl_scalar;
-
-/**
- * @author andruid
- *
- */
-@simpl_inherit
-public class RangeIntState extends ElementState /* RangeState */
-{
- /**
- * Min value.
- */
- @simpl_scalar int min;
- /**
- * Max value.
- */
- @simpl_scalar int max;
-
- /**
- *
- */
- public RangeIntState()
- {
- super();
- }
-
-/**
- * Check to see that the newValue is within the range specifed by this.
- * @param newValue
- * @return
- */
- protected boolean isWithinRange(Integer newValue)
- {
- int value = newValue.intValue();
- return (min <= value) && (value <= max);
- }
-
- /**
- * Get max value.
- */
- public Integer getMax()
- {
- return this.max;
- }
-
- /**
- * Get min value.
- */
- public Integer getMin()
- {
- return this.min;
- }
-
- /**
- * Set max value.
- */
- public void setMax(Integer newValue)
- {
- this.max = newValue;
- }
-
- /**
- * Set min value.
- */
- public void setMin(Integer newValue)
- {
- this.min = newValue;
- }
-
-}
+/**
+ *
+ */
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.ElementState;
+import ecologylab.serialization.annotations.simpl_inherit;
+import ecologylab.serialization.annotations.simpl_scalar;
+
+/**
+ * @author andruid
+ *
+ */
+@simpl_inherit
+public class RangeIntState extends ElementState /* RangeState */
+{
+ /**
+ * Min value.
+ */
+ @simpl_scalar int min;
+ /**
+ * Max value.
+ */
+ @simpl_scalar int max;
+
+ /**
+ *
+ */
+ public RangeIntState()
+ {
+ super();
+ }
+
+/**
+ * Check to see that the newValue is within the range specifed by this.
+ * @param newValue
+ * @return
+ */
+ protected boolean isWithinRange(Integer newValue)
+ {
+ int value = newValue.intValue();
+ return (min <= value) && (value <= max);
+ }
+
+ /**
+ * Get max value.
+ */
+ public Integer getMax()
+ {
+ return this.max;
+ }
+
+ /**
+ * Get min value.
+ */
+ public Integer getMin()
+ {
+ return this.min;
+ }
+
+ /**
+ * Set max value.
+ */
+ public void setMax(Integer newValue)
+ {
+ this.max = newValue;
+ }
+
+ /**
+ * Set min value.
+ */
+ public void setMin(Integer newValue)
+ {
+ this.min = newValue;
+ }
+
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/RangeState.java b/simplCore/src/ecologylab/appframework/types/prefs/RangeState.java
index 351c8229..bca8a1fd 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/RangeState.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/RangeState.java
@@ -1,43 +1,43 @@
-package ecologylab.appframework.types.prefs;
-
-import ecologylab.serialization.ElementState;
-
-abstract public class RangeState extends ElementState
-{
- //@xml_attribute T min;
- //@xml_attribute T max;
-
- public RangeState()
- {
- super();
- }
-
- /**
- * Whether or not the value is in the range.
- * @param newValue
- */
- abstract protected boolean isWithinRange(T newValue);
- /**
- * Get the min of a choice. Type-specific.
- */
- public abstract T getMin();
-
- /**
- * Set the min of a choice. Type-specific.
- */
- public abstract void setMin(T newValue);
- /**
- * Get the max of a choice. Type-specific.
- */
- public abstract T getMax();
-
- /**
- * Set the max of a choice. Type-specific.
- */
- public abstract void setMax(T newValue);
-/* protected boolean isWithinRange(T newValue)
- {
- return (newValue >= min) && (newValue <= max);
- }
- */
-}
+package ecologylab.appframework.types.prefs;
+
+import ecologylab.serialization.ElementState;
+
+abstract public class RangeState extends ElementState
+{
+ //@xml_attribute T min;
+ //@xml_attribute T max;
+
+ public RangeState()
+ {
+ super();
+ }
+
+ /**
+ * Whether or not the value is in the range.
+ * @param newValue
+ */
+ abstract protected boolean isWithinRange(T newValue);
+ /**
+ * Get the min of a choice. Type-specific.
+ */
+ public abstract T getMin();
+
+ /**
+ * Set the min of a choice. Type-specific.
+ */
+ public abstract void setMin(T newValue);
+ /**
+ * Get the max of a choice. Type-specific.
+ */
+ public abstract T getMax();
+
+ /**
+ * Set the max of a choice. Type-specific.
+ */
+ public abstract void setMax(T newValue);
+/* protected boolean isWithinRange(T newValue)
+ {
+ return (newValue >= min) && (newValue <= max);
+ }
+ */
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/ValueChangedListener.java b/simplCore/src/ecologylab/appframework/types/prefs/ValueChangedListener.java
index 85d174aa..5087bb0b 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/ValueChangedListener.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/ValueChangedListener.java
@@ -1,6 +1,6 @@
-package ecologylab.appframework.types.prefs;
-
-public interface ValueChangedListener
-{
- public void valueChanged(Pref pref);
-}
+package ecologylab.appframework.types.prefs;
+
+public interface ValueChangedListener
+{
+ public void valueChanged(Pref pref);
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/WidgetTypes.java b/simplCore/src/ecologylab/appframework/types/prefs/WidgetTypes.java
index 195ba55e..eac28a3a 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/WidgetTypes.java
+++ b/simplCore/src/ecologylab/appframework/types/prefs/WidgetTypes.java
@@ -1,29 +1,29 @@
-package ecologylab.appframework.types.prefs;
-
-/**
- * Types of graphical user interface components for interactive setting /
- * editing Preference values.
- *
- * @author andruid
- */
-public interface WidgetTypes
-{
- public static final String TEXT_FIELD = "TEXT_FIELD";
-
- public static final String RADIO_BUTTONS = "RADIO";
-
- /** Not used. * */
- public static final String TEXT_AREA = "TEXT_AREA";
-
- public static final String CHECK_BOX = "CHECK_BOX";
-
- public static final String DROP_DOWN = "DROP_DOWN";
-
- public static final String COLOR_CHOOSER = "COLOR_CHOOSER";
-
- public static final String FILE_CHOOSER = "FILE_CHOOSER";
-
- public static final String SLIDER = "SLIDER";
-
- public static final String SPINNER = "SPINNER";
-}
+package ecologylab.appframework.types.prefs;
+
+/**
+ * Types of graphical user interface components for interactive setting /
+ * editing Preference values.
+ *
+ * @author andruid
+ */
+public interface WidgetTypes
+{
+ public static final String TEXT_FIELD = "TEXT_FIELD";
+
+ public static final String RADIO_BUTTONS = "RADIO";
+
+ /** Not used. * */
+ public static final String TEXT_AREA = "TEXT_AREA";
+
+ public static final String CHECK_BOX = "CHECK_BOX";
+
+ public static final String DROP_DOWN = "DROP_DOWN";
+
+ public static final String COLOR_CHOOSER = "COLOR_CHOOSER";
+
+ public static final String FILE_CHOOSER = "FILE_CHOOSER";
+
+ public static final String SLIDER = "SLIDER";
+
+ public static final String SPINNER = "SPINNER";
+}
diff --git a/simplCore/src/ecologylab/appframework/types/prefs/package.html b/simplCore/src/ecologylab/appframework/types/prefs/package.html
index 0b61dd68..a8e78726 100644
--- a/simplCore/src/ecologylab/appframework/types/prefs/package.html
+++ b/simplCore/src/ecologylab/appframework/types/prefs/package.html
@@ -1,4 +1,4 @@
-
-Type declarations for preferences, in the Interface Ecology Lab Application
-Development Framework.
-
+
+Type declarations for preferences, in the Interface Ecology Lab Application
+Development Framework.
+
diff --git a/simplCore/src/ecologylab/collections/AbstractSetElement.java b/simplCore/src/ecologylab/collections/AbstractSetElement.java
index 97be442e..8e41c3ba 100644
--- a/simplCore/src/ecologylab/collections/AbstractSetElement.java
+++ b/simplCore/src/ecologylab/collections/AbstractSetElement.java
@@ -1,16 +1,16 @@
-package ecologylab.collections;
-
-public interface AbstractSetElement
-{
- public void delete();
-
- public void addSet(WeightSet s);
- public void removeSet(WeightSet s);
- public boolean isInSet();
-
- public void deleteHook();
- public void insertHook();
-
- public void recycle(boolean allContents);
- public boolean recycled();
-}
+package ecologylab.collections;
+
+public interface AbstractSetElement
+{
+ public void delete();
+
+ public void addSet(WeightSet s);
+ public void removeSet(WeightSet s);
+ public boolean isInSet();
+
+ public void deleteHook();
+ public void insertHook();
+
+ public void recycle(boolean allContents);
+ public boolean recycled();
+}
diff --git a/simplCore/src/ecologylab/collections/ArrayListFloatSet.java b/simplCore/src/ecologylab/collections/ArrayListFloatSet.java
index 3fbe86c7..2423044d 100644
--- a/simplCore/src/ecologylab/collections/ArrayListFloatSet.java
+++ b/simplCore/src/ecologylab/collections/ArrayListFloatSet.java
@@ -1,92 +1,92 @@
-/*
- * Created on Jun 26, 2005
- */
-package ecologylab.collections;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * A set of FloatSetElements, that uses ArrayList as the storage medium.
- *
- * @author andruid
- */
-public class ArrayListFloatSet
-extends ArrayList
-implements BasicFloatSet