Browse Source

Add JavaDoc comments to everything

tags/2.1
Skylar 4 years ago
parent
commit
c463db0138
39 changed files with 848 additions and 75 deletions
  1. 2
    2
      nbproject/project.properties
  2. 6
    23
      src/fi/iki/elonen/NanoHTTPD.java
  3. 7
    0
      src/net/apocalypselabs/symat/BadInputException.java
  4. 4
    0
      src/net/apocalypselabs/symat/CodeCompleter.java
  5. 6
    0
      src/net/apocalypselabs/symat/CodeExport.java
  6. 46
    0
      src/net/apocalypselabs/symat/CodeRunner.java
  7. 5
    1
      src/net/apocalypselabs/symat/Debug.java
  8. 19
    3
      src/net/apocalypselabs/symat/Editor.java
  9. 14
    0
      src/net/apocalypselabs/symat/FileUtils.java
  10. 12
    0
      src/net/apocalypselabs/symat/FontOptions.java
  11. 265
    3
      src/net/apocalypselabs/symat/Functions.java
  12. 32
    0
      src/net/apocalypselabs/symat/Graph.java
  13. 4
    0
      src/net/apocalypselabs/symat/InstallPlugin.java
  14. 3
    0
      src/net/apocalypselabs/symat/Interpreter.java
  15. 12
    0
      src/net/apocalypselabs/symat/KeyValListItem.java
  16. 8
    0
      src/net/apocalypselabs/symat/License.java
  17. 82
    0
      src/net/apocalypselabs/symat/Main.java
  18. 5
    0
      src/net/apocalypselabs/symat/PackagePlugin.java
  19. 6
    3
      src/net/apocalypselabs/symat/Pads.java
  20. 29
    0
      src/net/apocalypselabs/symat/PrefStorage.java
  21. 9
    0
      src/net/apocalypselabs/symat/PrettifyToHtml.java
  22. 4
    0
      src/net/apocalypselabs/symat/SingleInstanceClient.java
  23. 3
    0
      src/net/apocalypselabs/symat/SingleInstanceServer.java
  24. 4
    0
      src/net/apocalypselabs/symat/Tasks.java
  25. 4
    0
      src/net/apocalypselabs/symat/TasksExport.java
  26. 28
    0
      src/net/apocalypselabs/symat/Theme.java
  27. 54
    0
      src/net/apocalypselabs/symat/WebBrowser.java
  28. 3
    0
      src/net/apocalypselabs/symat/codesamples/graph.java.txt
  29. 7
    0
      src/net/apocalypselabs/symat/codesamples/helloworld.java.txt
  30. 20
    0
      src/net/apocalypselabs/symat/components/Task.java
  31. 19
    0
      src/net/apocalypselabs/symat/components/TaskList.java
  32. 8
    0
      src/net/apocalypselabs/symat/components/TaskMenu.java
  33. 15
    0
      src/net/apocalypselabs/symat/components/TextBox.java
  34. 30
    0
      src/net/apocalypselabs/symat/plugin/LoadPlugin.java
  35. 14
    0
      src/net/apocalypselabs/symat/plugin/Plugin.java
  36. 3
    0
      src/net/apocalypselabs/symat/sync/BackgroundSync.java
  37. 1
    0
      src/net/apocalypselabs/symat/sync/Start.java
  38. 15
    0
      src/net/apocalypselabs/symat/sync/UserLogin.java
  39. 40
    40
      src/org/etherpad_lite_client/EPLiteClient.java

+ 2
- 2
nbproject/project.properties View File

@@ -3,9 +3,9 @@ annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.desc=Math and Programming for People
application.desc=Math and programming in style.
application.homepage=https://symatapp.com/
application.splash=C:\\Users\\Skylar\\Documents\\Apocalypse Labs\\appmedia\\SyMAT\\splashscreen.png
application.splash=C:\\Users\\Skylar\\Documents\\Projects\\Assets\\SyMAT\\splashscreen.png
application.title=SyMAT
application.vendor=Netsyms Technologies
auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml

+ 6
- 23
src/fi/iki/elonen/NanoHTTPD.java View File

@@ -26,17 +26,12 @@ import java.util.TimeZone;

/**
* A simple, tiny, nicely embeddable HTTP server in Java
* <p/>
* <p/>
* NanoHTTPD
* <p>
* </p>Copyright (c) 2012-2013 by Paul S. Hawke, 2001,2005-2013 by Jarno Elonen,
* 2010 by Konstantinos Togias</p>
* <p/>
* <p/>
* <b>Features + limitations: </b>
* <ul>
* <p/>
* <li>Only one Java file</li>
* <li>Java 5 compatible</li>
* <li>Released as open source, Modified BSD licence</li>
@@ -61,17 +56,11 @@ import java.util.TimeZone;
* <li>Contains a built-in list of most common mime types</li>
* <li>All header names are converted lowercase so they don't vary between
* browsers/clients</li>
* <p/>
* </ul>
* <p/>
* <p/>
* <b>How to use: </b>
* <ul>
* <p/>
* <li>Subclass and implement serve() and embed to your own program</li>
* <p/>
* </ul>
* <p/>
* See the separate "LICENSE.md" file for the distribution license (Modified BSD
* licence)
*/
@@ -263,8 +252,8 @@ public abstract class NanoHTTPD {

/**
* Override this to customize the server.
* <p/>
* <p/>
*
*
* (By default, this delegates to serveFile() and allows directory listing.)
*
* @param uri Percent-decoded URI without parameters, for example
@@ -283,8 +272,8 @@ public abstract class NanoHTTPD {

/**
* Override this to customize the server.
* <p/>
* <p/>
*
*
* (By default, this delegates to serveFile() and allows directory listing.)
*
* @param session The HTTP session
@@ -432,7 +421,6 @@ public abstract class NanoHTTPD {
// ------------------------------------------------------------------------------- //
/**
* Temp file manager.
* <p/>
* <p>
* Temp file managers are created 1-to-1 with incoming requests, to create
* and cleanup temporary files created as a result of handling the
@@ -447,7 +435,6 @@ public abstract class NanoHTTPD {

/**
* A temp file.
* <p/>
* <p>
* Temp files are responsible for managing the actual temporary storage and
* cleaning themselves up when no longer needed.</p>
@@ -463,7 +450,6 @@ public abstract class NanoHTTPD {

/**
* Default threading strategy for NanoHttpd.
* <p/>
* <p>
* By default, the server spawns a new Thread for every incoming request.
* These are set to <i>daemon</i> status, and named according to the request
@@ -485,9 +471,7 @@ public abstract class NanoHTTPD {

/**
* Default strategy for creating and cleaning up temporary files.
* <p/>
* <p>
* </p>This class stores its files in the standard location (that is,
* <p>This class stores its files in the standard location (that is,
* wherever <code>java.io.tmpdir</code> points to). Files are added to an
* internal list, and deleted when no longer needed (that is, when
* <code>clear()</code> is invoked at the end of processing a request).</p>
@@ -523,7 +507,6 @@ public abstract class NanoHTTPD {

/**
* Default strategy for creating and cleaning up temporary files.
* <p/>
* <p>
* </p></[>By default, files are created by
* <code>File.createTempFile()</code> in the directory specified.</p>
@@ -855,7 +838,7 @@ public abstract class NanoHTTPD {
/**
* Adds the files in the request body to the files map.
*
* @arg files - map to modify
* @param files - map to modify
*/
void parseBody(Map<String, String> files) throws IOException, ResponseException;
}

+ 7
- 0
src/net/apocalypselabs/symat/BadInputException.java View File

@@ -63,10 +63,17 @@ package net.apocalypselabs.symat;
*/
public class BadInputException extends Exception {

/**
*
*/
public BadInputException() {
super();
}

/**
*
* @param msg
*/
public BadInputException(String msg) {
super(msg);
}

+ 4
- 0
src/net/apocalypselabs/symat/CodeCompleter.java View File

@@ -81,6 +81,10 @@ public class CodeCompleter {
provider = makeCompletions();
}

/**
*
* @return
*/
public CompletionProvider getProvider() {
return provider;
}

+ 6
- 0
src/net/apocalypselabs/symat/CodeExport.java View File

@@ -124,6 +124,12 @@ public class CodeExport extends javax.swing.JInternalFrame {
codeLang = lang;
}

/**
*
* @param code
* @param lang
* @param out
*/
public CodeExport(String code, String lang, String out) {
this(code, lang);
outputTxt = out;

+ 46
- 0
src/net/apocalypselabs/symat/CodeRunner.java View File

@@ -87,14 +87,25 @@ public class CodeRunner {
// What codez are we speaking?
private String scriptLang = "";

/**
*
*/
public CodeRunner() {
this("javascript");
}

/**
*
* @param lang
*/
public CodeRunner(int lang) {
this(lang == 0 ? "js" : (lang == 2 ? "ja" : "py"));
}

/**
*
* @param lang
*/
public CodeRunner(String lang) {
scriptLang = lang;
switch (lang) {
@@ -162,6 +173,13 @@ public class CodeRunner {
}
}

/**
*
* @param name
* @param classLoader
* @return
* @throws IOException
*/
public static List<InputStream> loadResources(final String name,
final ClassLoader classLoader) throws IOException {
final List<InputStream> list = new ArrayList<InputStream>();
@@ -205,6 +223,12 @@ public class CodeRunner {
return out;
}

/**
*
* @param lang
* @param shell
* @deprecated
*/
@Deprecated
public CodeRunner(String lang, boolean shell) {
this(lang);
@@ -227,14 +251,26 @@ public class CodeRunner {
}
}

/**
*
* @return
*/
public StringWriter getStringWriter() {
return sw;
}

/**
*
* @return
*/
public PrintWriter getPrintWriter() {
return pw;
}

/**
*
* @return
*/
public String getBufferDump() {
String dump = sw.toString();
sw.getBuffer().setLength(0);
@@ -308,10 +344,20 @@ public class CodeRunner {
return eval;
}

/**
*
* @param var
* @param val
*/
public void setVar(String var, Object val) {
se.put(var, val);
}

/**
*
* @param var
* @return
*/
public Object getVar(String var) {
return se.get(var);
}

+ 5
- 1
src/net/apocalypselabs/symat/Debug.java View File

@@ -63,7 +63,11 @@ package net.apocalypselabs.symat;
public class Debug {

// If output should be on or off
public static boolean debug = true;

/**
*
*/
public static boolean debug = true;

/**
* Turn debug output on and off.

+ 19
- 3
src/net/apocalypselabs/symat/Editor.java View File

@@ -96,8 +96,19 @@ public class Editor extends javax.swing.JInternalFrame {
private AutoCompletion jsac = new AutoCompletion(jscomp);
private AutoCompletion pyac = new AutoCompletion(pycomp);

/**
* The JavaScript language.
*/
public static final int JAVASCRIPT = 1;

/**
* The Python language.
*/
public static final int PYTHON = 2;

/**
* The Javs language.
*/
public static final int JAVA = 3;

private File filedata;
@@ -217,6 +228,9 @@ public class Editor extends javax.swing.JInternalFrame {
}
}

/**
*
*/
public Editor() {
this(false);
}
@@ -1026,7 +1040,9 @@ public class Editor extends javax.swing.JInternalFrame {
*/
private void openSample(String name) {
String ext = "js";
if (!javascriptOption.isSelected()) {
if (javaOption.isSelected()) {
ext = "java.txt";
} else if (pythonOption.isSelected()) {
ext = "py";
}
String text = "";
@@ -1042,10 +1058,10 @@ public class Editor extends javax.swing.JInternalFrame {
}
} catch (Exception e) {
text = "Error: Could not open embedded sample file.";
if (ext.equals("js")) {
if (ext.startsWith("j")) {
text = "/* " + text + " */";
} else {
text = "# " + text;
text = "## " + text;
}
}
openString(text, name + "." + ext, false);

+ 14
- 0
src/net/apocalypselabs/symat/FileUtils.java View File

@@ -113,6 +113,13 @@ public class FileUtils {
return file;
}

/**
*
* @param content
* @param path
* @param addToRecent
* @throws IOException
*/
public static void saveFile(String content, String path, boolean addToRecent)
throws IOException {
try (PrintStream out = new PrintStream(new FileOutputStream(path))) {
@@ -146,6 +153,13 @@ public class FileUtils {
return null;
}

/**
*
* @param url
* @return
* @throws MalformedURLException
* @throws IOException
*/
public static String getUrl(String url) throws MalformedURLException, IOException {
String out;
try (Scanner sc = new Scanner(new URL(url).openStream(), "UTF-8")) {

+ 12
- 0
src/net/apocalypselabs/symat/FontOptions.java View File

@@ -70,6 +70,10 @@ public class FontOptions extends javax.swing.JPanel {
initComponents();
}

/**
*
* @param size
*/
public FontOptions(int size) {
this();
jSpinner1.setValue(size);
@@ -130,10 +134,18 @@ public class FontOptions extends javax.swing.JPanel {
modified = true;
}//GEN-LAST:event_jSpinner1StateChanged

/**
*
* @return
*/
public int getResult() {
return (int) jSpinner1.getValue();
}

/**
*
* @return
*/
public boolean isModified() {
return modified;
}

+ 265
- 3
src/net/apocalypselabs/symat/Functions.java View File

@@ -95,6 +95,9 @@ import org.python.core.PyList;
*/
public class Functions {

/**
*
*/
public static final HashMap<String, Object> GLOBALS = new HashMap<>();

private final EvalUtilities util = new EvalUtilities(true, true);
@@ -151,7 +154,7 @@ public class Functions {
}

/**
* @see pause()
* @see pause(long millis)
* @param millis
*/
public void sleep(long millis) {
@@ -222,6 +225,12 @@ public class Functions {
return in.modPow(new BigInteger(b), new BigInteger(m)).toString();
}

/**
*
* @param a
* @param b
* @return
*/
public long gcd(long a, long b) {
if (b == 0) {
return a;
@@ -229,6 +238,12 @@ public class Functions {
return gcd(b, a % b);
}

/**
*
* @param a
* @param b
* @return
*/
public String gcd(String a, String b) {
return (new BigInteger(a).gcd(new BigInteger(b)).toString());
}
@@ -255,11 +270,25 @@ public class Functions {
return diff(function, "x");
}

/**
*
* @param function
* @param idv
* @return
* @deprecated
*/
@Deprecated
public String D(String function, String idv) {
return diff(function, idv);
}

/**
*
* @param function
* @param idv
* @param eq
* @return
*/
public double[] solve(String function, String idv, int eq) {
String res = $("Solve[" + function + "==" + eq + ", " + idv + "]");
res = res.substring(1, res.length() - 1);
@@ -287,10 +316,21 @@ public class Functions {
return out;
}

/**
*
* @param function
* @param idv
* @return
*/
public double[] solve(String function, String idv) {
return solve(function, idv, 0);
}

/**
*
* @param function
* @return
*/
public double[] solve(String function) {
return solve(function, "x");
}
@@ -322,6 +362,11 @@ public class Functions {
return out;
}

/**
*
* @param o
* @return
*/
public String printa(Object o) {
String out = "[";
if (o instanceof int[]) {
@@ -401,6 +446,11 @@ public class Functions {
return integrate(function, "x");
}

/**
*
* @param function
* @return
*/
public String factor(String function) {
return sym("Factor(" + function + ")");
}
@@ -415,6 +465,11 @@ public class Functions {
return sym("Simplify(" + expr + ")");
}

/**
*
* @param expr
* @return
*/
public Object vpa(String expr) {
IExpr ans = util.evaluate("N(" + expr + ")");
if (ans.isNumber()) {
@@ -423,6 +478,11 @@ public class Functions {
return ans.toString();
}

/**
*
* @param in
* @return
*/
public int[] primes(int in) {
boolean[] prime = new boolean[in];
for (int i = 0; i < prime.length; i++) {
@@ -450,50 +510,110 @@ public class Functions {
return out;
}

/**
*
* @param d
* @return
*/
public double sec(double d) {
return 1.0 / Math.cos(d);
}

/**
*
* @param d
* @return
*/
public double csc(double d) {
return 1.0 / Math.sin(d);
}

/**
*
* @param d
* @return
*/
public double cot(double d) {
return 1.0 / Math.tan(d);
}

/**
*
* @param d
* @return
*/
public double asec(double d) {
return Math.acos(1.0 / d);
}

/**
*
* @param d
* @return
*/
public double acsc(double d) {
return Math.asin(1.0 / d);
}

/**
*
* @param d
* @return
*/
public double acot(double d) {
return Math.atan(1.0 / d);
}

/**
*
* @param d
* @return
*/
public double sinh(double d) {
return Math.sinh(d);
}

/**
*
* @param d
* @return
*/
public double cosh(double d) {
return Math.cosh(d);
}

/**
*
* @param d
* @return
*/
public double tanh(double d) {
return Math.tanh(d);
}

/**
*
* @param d
* @return
*/
public double sech(double d) {
return pow(Math.cosh(d), -1);
}

/**
*
* @param d
* @return
*/
public double csch(double d) {
return pow(Math.sinh(d), -1);
}

/**
*
* @param d
* @return
*/
public double coth(double d) {
return Math.cosh(d) / Math.sinh(d);
}
@@ -610,6 +730,7 @@ public class Functions {
* Add the given numbers together.
*
* @param a numbers. Calculates first + second + third, etc.
* @param b
* @return The sum of the numbers or the value of input if there is only one
* input.
*/
@@ -640,6 +761,7 @@ public class Functions {
* Subtract the given numbers.
*
* @param a numbers. Calculates (first - second) - third, etc.
* @param b
* @return The difference of the numbers or the value of input if there is
* only one input.
*/
@@ -649,6 +771,11 @@ public class Functions {
return ans.toString();
}

/**
*
* @param a
* @return
*/
public double[][] minvert(double a[][]) {
int n = a.length;
double x[][] = new double[n][n];
@@ -762,6 +889,11 @@ public class Functions {
return a;
}

/**
*
* @param n
* @return
*/
public boolean isprime(long n) {
int i = 2;
while (i <= sqrt(n)) {
@@ -773,6 +905,11 @@ public class Functions {
return true;
}

/**
*
* @param nn
* @return
*/
public boolean isprime(String nn) {
BigInteger n = new BigInteger(nn);
BigInteger i = new BigInteger("2");
@@ -902,7 +1039,7 @@ public class Functions {
* Multiply the given matrix by itself b times.
*
* @param a Square matrix
* @param b Power ( >= 0 )
* @param b Power ( &gt;= 0 )
* @return The matrix result
* @throws BadInputException if the matrix is not square or power is less
* than 0
@@ -947,6 +1084,11 @@ public class Functions {
return radians * (180 / PI);
}

/**
*
* @param input
* @return
*/
public String sym(String input) {
return util.evaluate(input).toString();
}
@@ -976,7 +1118,7 @@ public class Functions {
/**
* Substitute newvar for variable in function and attempt to calculate a
* numerical answer.
* <br />Example: subs('32*x','x',2) = 64.0
* <br>Example: subs('32*x','x',2) = 64.0
*
* @param function Function
* @param variable Variable to substitute
@@ -1004,10 +1146,21 @@ public class Functions {
/*
Graphing interfaces
*/

/**
*
* @param xmin
* @param xmax
*/
public void xlim(double xmin, double xmax) {
graphwin.setRange(xmin, xmax);
}

/**
*
* @param function
*/
public void plot(String function) {
showGraph();
if (!function.equals("")) {
@@ -1015,35 +1168,75 @@ public class Functions {
}
}

/**
*
* @param x
* @param y
*/
public void plot(double[] x, double[] y) {
graphwin.plotPoints(x, y);
}

/**
*
* @param x
* @param y
* @param name
*/
public void plot(double[] x, double[] y, String name) {
graphwin.plotPoints(x, y, name);
}

/**
*
* @param function
* @param xmin
* @param xmax
*/
public void plot(String function, double xmin, double xmax) {
graphwin.setRange(xmin, xmax);
plot(function);
}

/**
*
* @param f
*/
public void ezplot(String f) {
plot(f);
}

/**
*
* @param function
* @param xmin
* @param xmax
*/
public void ezplot(String function, double xmin, double xmax) {
plot(function, xmin, xmax);
}

/**
*
* @param f
*/
public void graph(String f) {
plot(f);
}

/**
*
* @return
*/
public String plotname() {
return graphwin.getTitle();
}

/**
*
* @param t
* @return
*/
public String plotname(String t) {
if (t.equals("symatpythonnullplotname")) {
return graphwin.getTitle();
@@ -1054,31 +1247,60 @@ public class Functions {
}
}

/**
*
*/
public void plot() {
showGraph();
}

/**
*
*/
public void plotclr() {
graphwin.clearDraw();
}

/**
*
*/
public void clearplot() {
plotclr();
}

/**
*
*/
public void plotclear() {
plotclr();
}

/**
*
* @param x
* @param y
*/
public void drawdot(double x, double y) {
showGraph();
graphwin.drawDot(x, y);
}

/**
*
* @param path
* @return
* @throws IOException
*/
public String readfile(String path) throws IOException {
return FileUtils.readFile(path);
}

/**
*
* @param content
* @param path
* @throws IOException
*/
public void savefile(String content, String path) throws IOException {
FileUtils.saveFile(content, path, false);
}
@@ -1098,10 +1320,20 @@ public class Functions {
return "";
}

/**
*
* @param data
* @return
*/
public String md5sum(String data) {
return FileUtils.MD5(data);
}

/**
*
* @param key
* @param val
*/
public void save(String key, String val) {
Preferences prefs = Preferences.userNodeForPackage(Functions.class);
prefs.put(key, val);
@@ -1112,6 +1344,11 @@ public class Functions {
}
}

/**
*
* @param key
* @return
*/
public String load(String key) {
Preferences prefs = Preferences.userNodeForPackage(Functions.class);
return prefs.get(key, "");
@@ -1120,6 +1357,12 @@ public class Functions {
/*
Other
*/

/**
*
* @return
*/
public String sysinfo() {
String info = "==Java Information==\n";
info += "Java version: " + System.getProperty("java.version");
@@ -1145,6 +1388,10 @@ public class Functions {
}
}

/**
*
* @return
*/
public String license() {
String expires = "Error";
if (PrefStorage.getSetting("licensetype").equals("demo")) {
@@ -1191,10 +1438,18 @@ public class Functions {
graphwin.toFront();
}

/**
*
* @return
*/
public TextBox textbox() {
return new TextBox();
}

/**
*
* @return
*/
public WebBrowser browser() {
return new WebBrowser();
}
@@ -1202,10 +1457,17 @@ public class Functions {
Constructor.
*/

/**
*
*/
public Functions() {
Main.loadFrame(graphwin, false);
}

/**
*
* @param l
*/
public void setLang(String l) {
lang = l;
}

+ 32
- 0
src/net/apocalypselabs/symat/Graph.java View File

@@ -99,6 +99,10 @@ public class Graph extends javax.swing.JInternalFrame {
init();
}

/**
*
* @param isInternal
*/
public Graph(boolean isInternal) {
init();
standalone = !isInternal;
@@ -125,6 +129,9 @@ public class Graph extends javax.swing.JInternalFrame {
}
}

/**
*
*/
public void forceClose() {
dispose();
}
@@ -379,10 +386,21 @@ public class Graph extends javax.swing.JInternalFrame {
private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
}//GEN-LAST:event_formComponentShown

/**
*
* @param x
* @param y
*/
public void plotPoints(double[] x, double[] y) {
plotPoints(x, y, "Points");
}

/**
*
* @param x
* @param y
* @param name
*/
public void plotPoints(double[] x, double[] y, String name) {
plot.addLinePlot(name, x, y);
}
@@ -398,6 +416,11 @@ public class Graph extends javax.swing.JInternalFrame {
return 15.0;
}

/**
*
* @param x
* @param y
*/
public void drawDot(double x, double y) {
double[] xpt = {x};
double[] ypt = {y};
@@ -455,6 +478,11 @@ public class Graph extends javax.swing.JInternalFrame {
return range;
}

/**
*
* @param min
* @param max
*/
public void setRange(double min, double max) {
xmin = min;
xmax = max;
@@ -486,6 +514,10 @@ public class Graph extends javax.swing.JInternalFrame {
plotBtnActionPerformed(null);
}

/**
*
* @param label
*/
public void setLabel(String label) {
lbl.setText(label);
}

+ 4
- 0
src/net/apocalypselabs/symat/InstallPlugin.java View File

@@ -84,6 +84,10 @@ public class InstallPlugin extends javax.swing.JInternalFrame {
initComponents();
}

/**
*
* @param f
*/
public InstallPlugin(File f) {
this();
openPlugin(f);

+ 3
- 0
src/net/apocalypselabs/symat/Interpreter.java View File

@@ -145,6 +145,9 @@ public class Interpreter extends javax.swing.JInternalFrame {
inputBox.requestFocus();
}

/**
*
*/
public Interpreter() {
this("default");
}

+ 12
- 0
src/net/apocalypselabs/symat/KeyValListItem.java View File

@@ -67,14 +67,26 @@ public class KeyValListItem {
private String VAL = "";
private String KEY = "";

/**
*
*/
public KeyValListItem() {

}

/**
*
* @param key
*/
public KeyValListItem(String key) {
KEY = key;
}

/**
*
* @param key
* @param val
*/
public KeyValListItem(String key, String val) {
KEY = key;
VAL = val;

+ 8
- 0
src/net/apocalypselabs/symat/License.java View File

@@ -314,11 +314,19 @@ public class License extends javax.swing.JInternalFrame {
}
}

/**
*
* @param email
* @return
*/
public static boolean checkEmail(String email) {
String regex = "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]+$";
return (email.matches(regex));
}

/**
*
*/
public void exit() {
dispose();
}

+ 82
- 0
src/net/apocalypselabs/symat/Main.java View File

@@ -134,13 +134,32 @@ public class Main extends JRibbonFrame {
* Becomes default sans-serif if something bad happens.
*/
public static Font ubuntuRegular;

/**
*
*/
public static boolean skipPython = false; // Skip python init on start?

/**
*
*/
public static boolean skipEditor = false; // Skip editor init on start?

private static boolean recentItemsMinimized = false;

/**
*
*/
public static boolean updateAvailable = false; // Update available?

/**
*
*/
public static String updateString = "";

/**
*
*/
public static boolean licValid = false; // License valid?

/**
@@ -153,8 +172,14 @@ public class Main extends JRibbonFrame {
*/
public static SingleInstanceServer sisrv;

/**
*
*/
public static Main maingui;

/**
*
*/
public JRibbonBand pluginband;

/**
@@ -440,12 +465,22 @@ public class Main extends JRibbonFrame {
ribbon.addTask(plugintask);
}

/**
*
* @param name
* @return
*/
public static ResizableIcon getRibbonIcon(String name) {
return ImageWrapperResizableIcon.getIcon(
Main.class.getResource("images/" + name + ".png"),
new Dimension(100, 76));
}

/**
*
* @param name
* @return
*/
public static ResizableIcon getTinyRibbonIcon(String name) {
int d = 32;
return ImageWrapperResizableIcon.getIcon(
@@ -453,6 +488,10 @@ public class Main extends JRibbonFrame {
new Dimension(d, d));
}

/**
*
* @param restricted
*/
public static void licenseRestrict(boolean restricted) {
graphbtn.setEnabled(!restricted);
padsbtn.setEnabled(!restricted);
@@ -474,6 +513,10 @@ public class Main extends JRibbonFrame {
mainPane.getWidth(), mainPane.getHeight());
}

/**
*
* @param recent
*/
public static void loadRibbonMenu(RibbonApplicationMenuEntrySecondary[] recent) {
RibbonApplicationMenuEntryPrimary helpbtn
= new RibbonApplicationMenuEntryPrimary(
@@ -1074,24 +1117,63 @@ public class Main extends JRibbonFrame {
});
}

/**
*
*/
public static JCommandButton shellbtn
= new JCommandButton("Shell", getRibbonIcon("shell"));

/**
*
*/
public static JCommandButton editorbtn
= new JCommandButton("Editor", getRibbonIcon("editor"));

/**
*
*/
public static JCommandButton graphbtn
= new JCommandButton("Graph", getRibbonIcon("graph"));

/**
*
*/
public static JCommandButton notepadbtn
= new JCommandButton("Notepad", getRibbonIcon("notepad"));

/**
*
*/
public static JCommandButton wikibtn
= new JCommandButton("Wiki", getRibbonIcon("wiki"));

/**
*
*/
public static JCommandButton forumbtn
= new JCommandButton("Forum", getRibbonIcon("forum"));

/**
*
*/
public static JCommandButton padsbtn
= new JCommandButton("Pads", getRibbonIcon("pads"));

/**
*
*/
public static JCommandButton tasksbtn
= new JCommandButton("Tasks", getRibbonIcon("tasks"));

/**
*
*/
public static JCommandButton installpluginbtn
= new JCommandButton("Install", getRibbonIcon("installplugin"));

/**
*
*/
public static RibbonApplicationMenuEntryPrimary openbtn;

// Variables declaration - do not modify//GEN-BEGIN:variables

+ 5
- 0
src/net/apocalypselabs/symat/PackagePlugin.java View File

@@ -75,6 +75,11 @@ public class PackagePlugin extends javax.swing.JInternalFrame {
private final JFileChooser fcexp = new JFileChooser();
private ImageIcon icon;

/**
*
* @param code
* @param lang
*/
public PackagePlugin(String code, int lang) {
this();
try {

+ 6
- 3
src/net/apocalypselabs/symat/Pads.java View File

@@ -69,6 +69,9 @@ import org.etherpad_lite_client.EPLiteException;
*/
public class Pads extends javax.swing.JInternalFrame {

/**
* URL of the pad server.
*/
public static final String PADS_URL = "http://pad.symatapp.com";

/**
@@ -113,7 +116,7 @@ public class Pads extends javax.swing.JInternalFrame {

/**
* Delete the pad with the given ID from local memory.
* <br />It will still exist online.
* <br>It will still exist online.
*
* @param id the pad ID.
*/
@@ -179,8 +182,8 @@ public class Pads extends javax.swing.JInternalFrame {

/**
* Generate a random pad ID with length 15.
* <br />There are about 1.217 x 10^26 possibilities (121 septillion).
* <br />If this starts giving out used IDs, I'll be too rich to care.
* <br>There are about 1.217 x 10^26 possibilities (121 septillion).
* <br>If this starts giving out used IDs, I'll be too rich to care.
*
* @return the ID.
*/

+ 29
- 0
src/net/apocalypselabs/symat/PrefStorage.java View File

@@ -70,14 +70,28 @@ public class PrefStorage {

private static final Preferences prefs = Preferences.userNodeForPackage(PrefStorage.class);

/**
*
* @param key
* @param value
*/
public static void saveSetting(String key, String value) {
prefs.put(key, value);
}

/**
*
* @param key
* @return
*/
public static boolean isset(String key) {
return !getSetting(key, "NULL").equals("NULL");
}

/**
*
* @param key
*/
public static void unset(String key) {
saveSetting(key, "");
save();
@@ -85,14 +99,29 @@ public class PrefStorage {
save();
}

/**
*
* @param key
* @return
*/
public static String getSetting(String key) {
return prefs.get(key, "");
}

/**
*
* @param key
* @param emptyResponse
* @return
*/
public static String getSetting(String key, String emptyResponse) {
return prefs.get(key, emptyResponse);
}

/**
*
* @return
*/
public static boolean save() {
try {
prefs.flush();

+ 9
- 0
src/net/apocalypselabs/symat/PrettifyToHtml.java View File

@@ -24,6 +24,10 @@ import syntaxhighlight.ParseResult;
import syntaxhighlight.Style;
import syntaxhighlight.Theme;

/**
*
* @author Skylar
*/
public class PrettifyToHtml {

private static final String MAIN_CLASS = "prettyprint";
@@ -58,6 +62,11 @@ public class PrettifyToHtml {
return sb.toString();
}

/**
*
* @param theme
* @return
*/
public static String toCss(Theme theme) {
StringBuilder sb = new StringBuilder();
sb.append("." + MAIN_CLASS + " {");

+ 4
- 0
src/net/apocalypselabs/symat/SingleInstanceClient.java View File

@@ -68,6 +68,10 @@ import java.net.URL;
*/
public class SingleInstanceClient {

/**
*
* @param arg
*/
public SingleInstanceClient(String arg) {
String response = "";
String args = (arg.equals("") ? "" : "?arg=" + arg);

+ 3
- 0
src/net/apocalypselabs/symat/SingleInstanceServer.java View File

@@ -65,6 +65,9 @@ import java.util.Map;
*/
public class SingleInstanceServer extends NanoHTTPD {

/**
*
*/
public SingleInstanceServer() {
super(26879);
}

+ 4
- 0
src/net/apocalypselabs/symat/Tasks.java View File

@@ -91,6 +91,10 @@ public class Tasks extends javax.swing.JInternalFrame {
initComponents();
}

/**
*
* @param f
*/
public Tasks(File f) {
this();
try {

+ 4
- 0
src/net/apocalypselabs/symat/TasksExport.java View File

@@ -149,6 +149,10 @@ public class TasksExport extends javax.swing.JInternalFrame {
});
}

/**
*
* @param content
*/
public void loadString(final String content) {
Platform.runLater(new Runnable() {
@Override

+ 28
- 0
src/net/apocalypselabs/symat/Theme.java View File

@@ -131,6 +131,10 @@ public class Theme {
}
}

/**
*
* @return
*/
public static String getTheme() {
switch (currentTheme) {
case THEME_DARK:
@@ -143,6 +147,10 @@ public class Theme {
}
}

/**
*
* @return
*/
public static Color textColor() {
if (currentTheme == THEME_NEO) {
return Color.GREEN;
@@ -150,22 +158,42 @@ public class Theme {
return (currentTheme == THEME_LIGHT) ? BLACK : WHITE;
}

/**
*
* @return
*/
public static Color boxColor() {
return (currentTheme == THEME_LIGHT) ? WHITE : DBACK;
}
/**
*
* @return
*/
public static Color notepadColor() {
return (currentTheme == THEME_LIGHT) ? NTPAD : DBACK;
}

/**
*
* @return
*/
public static Color windowColor() {
return (currentTheme == THEME_LIGHT) ? LGRAY : DGRAY;
}

/**
*
* @return
*/
public static Color tabColor() {
return (currentTheme == THEME_LIGHT) ? LBACK : DBACK;
}

/**
*
* @return
*/
public static String editorTheme() {
if (currentTheme == THEME_NEO) {
return "neo";

+ 54
- 0
src/net/apocalypselabs/symat/WebBrowser.java View File

@@ -91,9 +91,24 @@ public class WebBrowser extends javax.swing.JInternalFrame {
private Group root;
private Scene scene;

/**
*
*/
public static final int DEFAULT_LOGO = 0;

/**
*
*/
public static final int WIKI_LOGO = 1;

/**
*
*/
public static final int FORUM_LOGO = 2;

/**
*
*/
public static final int PAD_LOGO = 3;
private JInternalFrame thisFrame;

@@ -165,12 +180,20 @@ public class WebBrowser extends javax.swing.JInternalFrame {
browserBox.add(jfxPanel, BorderLayout.CENTER);
}

/**
*
* @param title
*/
public WebBrowser(String title) {
this();
setTitle(title);
loadURL("http://wiki.symatapp.com/");
}

/**
*
* @return
*/
public String homepage() {
try {
String text = "";
@@ -188,12 +211,23 @@ public class WebBrowser extends javax.swing.JInternalFrame {
}
}

/**
*
* @param title
* @param url
*/
public WebBrowser(String title, String url) {
this();
setTitle(title);
loadURL(url);
}

/**
*
* @param title
* @param url
* @param icon
*/
public WebBrowser(String title, String url, int icon) {
this(title, url);
switch (icon) {
@@ -215,17 +249,30 @@ public class WebBrowser extends javax.swing.JInternalFrame {

}

/**
*
* @param url
* @param isurl
*/
public WebBrowser(String url, boolean isurl) {
this();
loadURL(url);
}

/**
*
* @param yesno
*/
public void showNavbar(boolean yesno) {
navBar.setVisible(yesno);
goBtn.setEnabled(yesno);
backBtn.setEnabled(yesno);
}

/**
*
* @param url
*/
public void loadURL(final String url) {
Platform.runLater(new Runnable() {
@Override
@@ -237,10 +284,17 @@ public class WebBrowser extends javax.swing.JInternalFrame {
urlBox.setText(url);
}

/**
*
*/
public void open() {
Main.loadFrame(this, true);
}

/**
*
* @param content
*/
public void loadString(final String content) {
Platform.runLater(new Runnable() {
@Override

+ 3
- 0
src/net/apocalypselabs/symat/codesamples/graph.java.txt View File

@@ -0,0 +1,3 @@
String formula = ask("Enter formula:");
plot(formula);
plotname("Cool graph!");

+ 7
- 0
src/net/apocalypselabs/symat/codesamples/helloworld.java.txt View File

@@ -0,0 +1,7 @@
public class HelloWorld {
public static void main(String[] args) {
print("Hello world");
}
}

HelloWorld.main(null);

+ 20
- 0
src/net/apocalypselabs/symat/components/Task.java View File

@@ -67,10 +67,22 @@ public class Task extends javax.swing.JPanel {

private int percent = 0;

/**
*
* @param complete
* @param name
* @param desc
*/
public Task(boolean complete, String name, String desc) {
this((complete ? 100 : 0), name, desc);
}

/**
*
* @param complete
* @param name
* @param desc
*/
public Task(int complete, String name, String desc) {
this();
percent = complete;
@@ -92,10 +104,18 @@ public class Task extends javax.swing.JPanel {
return taskName.getText();
}

/**
*
* @return
*/
public String getDesc() {
return taskDesc.getText();
}

/**
*
* @return
*/
public int getComplete() {
return percent;
}

+ 19
- 0
src/net/apocalypselabs/symat/components/TaskList.java View File

@@ -70,6 +70,10 @@ public class TaskList implements Serializable {
private final ArrayList<SingleTask> tasks = new ArrayList<>();
private String title = "Untitled";

/**
*
* @param t
*/
public void addTask(Task t) {
SingleTask st = new SingleTask();
st.name = t.toString();
@@ -78,6 +82,10 @@ public class TaskList implements Serializable {
tasks.add(st);
}

/**
*
* @return
*/
public Task[] getTasks() {
Task[] a = new Task[tasks.size()];
for (int i = 0; i < tasks.size(); i++) {
@@ -89,14 +97,25 @@ public class TaskList implements Serializable {
return a;
}

/**
*
* @param t
*/
public void setTitle(String t) {
title = t;
}

/**
*
* @return
*/
public String getTitle() {
return title;
}

/**
*
*/
public TaskList() {

}

+ 8
- 0
src/net/apocalypselabs/symat/components/TaskMenu.java View File

@@ -92,10 +92,18 @@ public class TaskMenu extends javax.swing.JPanel {
loadTheme();
}

/**
*
* @return
*/
public int getPercent() {
return percentSlider.getValue();
}

/**
*
* @return
*/
public boolean deleteMe() {
return delCheck.isSelected();
}

+ 15
- 0
src/net/apocalypselabs/symat/components/TextBox.java View File

@@ -77,18 +77,33 @@ public class TextBox extends javax.swing.JInternalFrame {
textBox.setFont(Main.ubuntuRegular.deriveFont((float) font_size));
}

/**
*
* @param txt
*/
public void set(String txt) {
textBox.setText(txt);
}

/**
*
* @return
*/
public String get() {
return textBox.getText();
}

/**
*
* @param is
*/
public void edit(boolean is) {
textBox.setEditable(is);
}

/**
*
*/
public void open() {
Main.loadFrame(this, true);
}

+ 30
- 0
src/net/apocalypselabs/symat/plugin/LoadPlugin.java View File

@@ -81,6 +81,14 @@ public class LoadPlugin {

private Plugin p;

/**
*
* @param f
* @throws FileNotFoundException
* @throws IOException
* @throws ClassNotFoundException
* @throws InvalidClassException
*/
public LoadPlugin(File f) throws FileNotFoundException, IOException, ClassNotFoundException, InvalidClassException {
FileInputStream fin = new FileInputStream(f);
ObjectInputStream ois = new ObjectInputStream(fin);
@@ -88,6 +96,13 @@ public class LoadPlugin {
ois.close();
}

/**
*
* @param path
* @throws FileNotFoundException
* @throws IOException
* @throws ClassNotFoundException
*/
public LoadPlugin(String path) throws FileNotFoundException, IOException, ClassNotFoundException {
this(new File(path));
}
@@ -103,6 +118,10 @@ public class LoadPlugin {
}
}

/**
*
* @return
*/
public JCommandButton getRibbonBtn() {
JCommandButton b = new JCommandButton((p.getTitle().equals("") ? "Untitled" : p.getTitle()), getRibbonIcon());
if (!p.getLongTitle().equals("")) {
@@ -119,6 +138,10 @@ public class LoadPlugin {
return b;
}

/**
*
* @return
*/
public JCommandToggleButton getGalleryBtn() {
JCommandToggleButton b = new JCommandToggleButton((p.getTitle().equals("") ? "Untitled" : p.getTitle()), getRibbonIcon());
if (!p.getLongTitle().equals("")) {
@@ -134,11 +157,18 @@ public class LoadPlugin {
return b;
}

/**
*
*/
public void exec() {
CodeRunner cr = new CodeRunner(p.getLang());
cr.evalString(p.getScript());
}

/**
*
* @return
*/
public Plugin getPlugin() {
return p;
}

+ 14
- 0
src/net/apocalypselabs/symat/plugin/Plugin.java View File

@@ -65,8 +65,19 @@ public class Plugin implements Serializable {

private static final long serialVersionUID = 13371L;

/**
*
*/
public final int LANG_JS = 0;

/**
*
*/
public final int LANG_PY = 1;

/**
*
*/
public final int LANG_JAVA = 2;

private ImageIcon icon;
@@ -81,6 +92,9 @@ public class Plugin implements Serializable {
private String version = "";
private int lang = LANG_JS;

/**
*
*/
public Plugin() {

}

+ 3
- 0
src/net/apocalypselabs/symat/sync/BackgroundSync.java View File

@@ -87,6 +87,9 @@ public class BackgroundSync extends Thread {
}
}

/**
*
*/
public BackgroundSync() {

}

+ 1
- 0
src/net/apocalypselabs/symat/sync/Start.java View File

@@ -78,6 +78,7 @@ public class Start extends javax.swing.JPanel {

/**
* Creates new form Start
* @param parent
*/
public Start(JInternalFrame parent) {
parentComponent = parent;

+ 15
- 0
src/net/apocalypselabs/symat/sync/UserLogin.java View File

@@ -63,7 +63,14 @@ package net.apocalypselabs.symat.sync;

public class UserLogin extends javax.swing.JPanel {

/**
*
*/
public static final int LOGIN_MODE = 0;

/**
*
*/
public static final int SIGNUP_MODE = 1;
private static final String signup_help = "Sign up for a Sync acount.";
/**
@@ -77,10 +84,18 @@ public class UserLogin extends javax.swing.JPanel {
}
}
/**
*
* @return
*/
public String getEmail() {
return emailBox.getText();
}
/**
*
* @return
*/
public String getPassword() {
return new String(passwdBox.getPassword());
}

+ 40
- 40
src/org/etherpad_lite_client/EPLiteClient.java View File

@@ -4,13 +4,13 @@ import java.util.Date;
import java.util.HashMap;

/**
* A client for talking to Etherpad Lite's HTTP JSON API.<br />
* <br />
* Example:<br />
* <br />
* A client for talking to Etherpad Lite's HTTP JSON API.<br>
* <br>
* Example:<br>
* <br>
* <code>
* EPLiteClient api = new EPLiteClient("http://etherpad.mysite.com", "FJ7jksalksdfj83jsdflkj");<br />
* HashMap pad = api.getText("my_pad");<br />
* EPLiteClient api = new EPLiteClient("http://etherpad.mysite.com", "FJ7jksalksdfj83jsdflkj");<br>
* HashMap pad = api.getText("my_pad");<br>
* String pad = pad.get("text").toString();
* </code>
*/
@@ -217,15 +217,15 @@ public class EPLiteClient {

/**
* Create a new session for the given author in the given group, valid until the given UNIX time.
* The session id will be returned in "sessionID".<br />
* <br />
* Example:<br />
* <br />
* The session id will be returned in "sessionID".<br>
* <br>
* Example:<br>
* <br>
* <code>
* import java.util.Date;<br />
* ...<br />
* Date now = new Date();<br />
* long in1Hour = (now.getTime() + (60L * 60L * 1000L) / 1000L);<br />
* import java.util.Date;<br>
* ...<br>
* Date now = new Date();<br>
* long in1Hour = (now.getTime() + (60L * 60L * 1000L) / 1000L);<br>
* String sessID1 = api.createSession(groupID, authorID, in1Hour).get("sessionID").toString();
* </code>
*
@@ -244,18 +244,18 @@ public class EPLiteClient {

/**
* Create a new session for the given author in the given group valid for the given number of hours.
* The session id will be returned in "sessionID".<br />
* <br />
* Example:<br />
* <br />
* The session id will be returned in "sessionID".<br>
* <br>
* Example:<br>
* <br>
* <code>
* // in 2 hours<br />
* // in 2 hours<br>
* String sessID1 = api.createSession(groupID, authorID, 2).get("sessionID").toString();
* </code>
*
* @param groupID string
* @param authorID string
* @param validUntil int length of session in hours
* @param length int length of session in hours
* @return HashMap
*/
public HashMap createSession(String groupID, String authorID, int length) {
@@ -265,19 +265,19 @@ public class EPLiteClient {

/**
* Create a new session for the given author in the given group, valid until the given datetime.
* The session id will be returned in "sessionID".<br />
* <br />
* Example:<br />
* <br />
* The session id will be returned in "sessionID".<br>
* <br>
* Example:<br>
* <br>
* <code>
* import java.util.Date;<br />
* import java.text.DateFormat;<br />
* import java.text.SimpleDateFormat;<br />
* import java.util.TimeZone;<br />
* ...<br />
* DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");<br />
* dfm.setTimeZone(TimeZone.getTimeZone("GMT-5"));<br />
* Date longTime = dfm.parse("2056-01-15 20:15:00");<br />
* import java.util.Date;<br>
* import java.text.DateFormat;<br>
* import java.text.SimpleDateFormat;<br>
* import java.util.TimeZone;<br>
* ...<br>
* DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");<br>
* dfm.setTimeZone(TimeZone.getTimeZone("GMT-5"));<br>
* Date longTime = dfm.parse("2056-01-15 20:15:00");<br>
* String sessID = api.createSession(groupID, authorID, longTime).get("sessionID").toString();
* </code>
*
@@ -562,10 +562,10 @@ public class EPLiteClient {