Add filedialog() function, make everything work 100% with Python
This commit is contained in:
parent
1228b7254f
commit
cde9e7e1db
@ -66,6 +66,7 @@ import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
import java.util.prefs.Preferences;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import static net.apocalypselabs.symat.Main.API_URL;
|
||||
import org.matheclipse.core.eval.EvalUtilities;
|
||||
@ -848,7 +849,10 @@ public class Functions {
|
||||
* @param max Maximum value, inclusive
|
||||
* @return random integer
|
||||
*/
|
||||
public int rand(int min, int max) {
|
||||
public double rand(int min, int max) {
|
||||
if (min == 0 && max == 0) {
|
||||
return rand();
|
||||
}
|
||||
return rng.nextInt((max - min) + 1) + min;
|
||||
}
|
||||
|
||||
@ -995,7 +999,9 @@ public class Functions {
|
||||
|
||||
public void plot(String function) {
|
||||
showGraph();
|
||||
graphwin.graphFunction(function);
|
||||
if (!function.equals("")) {
|
||||
graphwin.graphFunction(function);
|
||||
}
|
||||
}
|
||||
|
||||
public void plot(double[] x, double[] y) {
|
||||
@ -1023,15 +1029,20 @@ public class Functions {
|
||||
plot(f);
|
||||
}
|
||||
|
||||
public void plotname(String t) {
|
||||
graphwin.setWindowTitle(t);
|
||||
graphwin.setLabel(t);
|
||||
}
|
||||
|
||||
public String plotname() {
|
||||
return graphwin.getTitle();
|
||||
}
|
||||
|
||||
public String plotname(String t) {
|
||||
if (t.equals("symatpythonnullplotname")) {
|
||||
return graphwin.getTitle();
|
||||
} else {
|
||||
graphwin.setWindowTitle(t);
|
||||
graphwin.setLabel(t);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public void plot() {
|
||||
showGraph();
|
||||
}
|
||||
@ -1061,6 +1072,21 @@ public class Functions {
|
||||
FileUtils.saveFile(content, path, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a file dialog and return the path of the chosen file (or "" if
|
||||
* canceled).
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String filedialog() {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
int result = fc.showDialog(Main.maingui, "Choose");
|
||||
if (result == JFileChooser.APPROVE_OPTION) {
|
||||
return fc.getSelectedFile().getPath();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String md5sum(String data) {
|
||||
return FileUtils.MD5(data);
|
||||
}
|
||||
|
@ -14,14 +14,10 @@ def deg(num):
|
||||
return _.deg(num)
|
||||
def subs(fun,var):
|
||||
return _.subs(fun,var)
|
||||
def plot():
|
||||
_.plot()
|
||||
def plot(fun):
|
||||
def plot(fun=""):
|
||||
_.plot(fun)
|
||||
def plotname(fun):
|
||||
_.plotname(fun)
|
||||
def plotname():
|
||||
return _.plotname()
|
||||
def plotname(fun='symatpythonnullplotname'):
|
||||
return _.plotname(fun)
|
||||
def xlim(min,max):
|
||||
_.xlim(min,max)
|
||||
def plotclr():
|
||||
@ -50,9 +46,7 @@ def divide(*a):
|
||||
return _.divide(a)
|
||||
def mod(*a):
|
||||
return _.mod(a)
|
||||
def rand():
|
||||
return _.rand()
|
||||
def rand(min,max):
|
||||
def rand(min=0,max=0):
|
||||
return _.rand(min,max)
|
||||
def randb():
|
||||
return _.randb()
|
||||
@ -93,4 +87,6 @@ def sech(a):
|
||||
def csch(a):
|
||||
return _.csch(a)
|
||||
def coth(a):
|
||||
return _.coth(a)
|
||||
return _.coth(a)
|
||||
def filedialog():
|
||||
return _.filedialog()
|
@ -59,4 +59,5 @@ solve(f,'x',0)|Solve function f for 'x' when it equals 0.
|
||||
solve(f,'x')|Solve function f for 'x', assuming equal to 0.
|
||||
solve(f)|Solve function f, assuming 'x' and 0.
|
||||
printa(array)|Get array contents as text.
|
||||
primes(n)|Find all prime numbers up to n.
|
||||
primes(n)|Find all prime numbers up to n.
|
||||
filedialog()|Open a file chooser and return the chosen file path.
|
Loading…
x
Reference in New Issue
Block a user