more things

master
skylarmt 9 years ago
parent 9e7b64740d
commit 3336eee268

@ -67,7 +67,7 @@ public class CodeRunner {
// Add custom functions.
se.eval("importClass(net.apocalypselabs.symat.Functions);"
+ "SyMAT_Functions = new net.apocalypselabs.symat.Functions();"
+ jsFunctions());
+ getFunctions("js"));
} catch (Exception ex) {
initError(ex);
}
@ -75,7 +75,10 @@ public class CodeRunner {
case "python":
se = new ScriptEngineManager().getEngineByName("python");
try {
se.eval("from math import *\nfrom net.apocalypselabs.symat import Functions\n_=Functions()\n");
se.eval("from math import *\n"
+ "from net.apocalypselabs.symat import Functions\n"
+ "_=Functions()\n\n"
+ getFunctions("py"));
} catch (Exception ex) {
initError(ex);
}
@ -160,13 +163,13 @@ public class CodeRunner {
return se.get(var);
}
private String jsFunctions() {
private String getFunctions(String lang) {
String text = "";
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(
CodeRunner.class
.getResourceAsStream("functions.js")));
.getResourceAsStream("functions."+lang)));
String line;
while ((line = reader.readLine()) != null) {
text += line;
@ -175,13 +178,4 @@ public class CodeRunner {
}
return text;
}
// TODO: Run Javascript in separate thread from rest of app.
private class JsThread extends Thread {
@Override
public void run() {
}
}
}

@ -0,0 +1,42 @@
'''def notify(msg):
_.notify(msg)
def ask(msg):
return _.ask(msg)
def diff(fun,var):
return _.diff(fun,var)
def integrate(fun,var):
return _.integrate(fun,var)
def rad(num):
return _.rad(num)
def deg(num):
return _.deg(num)
def subs(fun,var):
return _.subs(fun,var)
def plot():
_.plot()
def plot(fun):
_.plot(fun)
def plotname(fun):
_.plotname(fun)
def plotname():
return _.plotname()
def xlim(min,max):
_.xlim(min,max)
def plotclr():
_.plotclr()
def drawdot(x, y):
_.drawdot(x, y)
'''

@ -7,13 +7,10 @@ deg(0)|Convert a given number in radians to degrees.
subs('',"x")|Solve an equation for the second argument.
plot()|Show the plot window.
plot('')|Graph the given function.
plot(x[],y[])|Graph the lists of points given.
graph('')|Alias of plot('')
plotname("")|Sets the title of the graph window.
plotname()|Gets the title of the graph window.
xlim(min,max)|Sets the x-axis min and max values. Cannot be used after a formula has been graphed.
plotclr()|Reset the graph.
clearplot()|Alias of plotclr()
drawdot(x, y)|Places a dot at the given coordinates.
abs(0)|Absolute value of number.
asin(0)|

@ -7,13 +7,10 @@ _.deg(0)|Convert a given number in radians to degrees.
_.subs('',"x")|Solve an equation for the second argument.
_.plot()|Show the plot window.
_.plot('')|Graph the given function.
_.plot(x[],y[])|Graph the lists of points given.
_.graph('')|Alias of plot('')
_.plotname("")|Sets the title of the graph window.
_.plotname()|Gets the title of the graph window.
_.xlim(min,max)|Sets the x-axis min and max values. Cannot be used after a formula has been graphed.
_.plotclr()|Reset the graph.
_.clearplot()|Alias of plotclr()
_.drawdot(x, y)|Places a dot at the given coordinates.
fabs(0)|Absolute value of number.
asin(0)|

Loading…
Cancel
Save