In [10]:
import static com.twosigma.beaker.groovy.widgets.Interactive.interact;

class PlotHolder{
    static Plot plot = null;
}

public static Object f(x){
    if(PlotHolder.plot == null){
     PlotHolder.plot = new Plot(title: x)
     PlotHolder.plot.display()
    }
    PlotHolder.plot.title = x
}

interact(this.&f, "s");
Out[10]:
null
In [2]:
public Object f(x){
    return x + " ABC";
}

com.twosigma.beaker.groovy.widgets.Interactive.interact(this.&f, "F");
Fe ABC
In [2]:
public Object f(x){
    return x + 2;
}

com.twosigma.beaker.groovy.widgets.Interactive.interact(this.&f, 10d);
Out[2]:
null
In [3]:
public Object f(x){
    return x + 2;
}

com.twosigma.beaker.groovy.widgets.Interactive.interact(this.&f, 10);
Out[3]:
null
In [4]:
public Object f(x){
    return !x;
}

com.twosigma.beaker.groovy.widgets.Interactive.interact(this.&f, true);
Out[4]:
null
In [7]:
public Object f(x, y){
    return [x + 2, y + 4];
}

com.twosigma.beaker.groovy.widgets.Interactive.interact(this.&f, 10, 100);
Out[7]:
null
In [3]:
public Object d(x, y){
    return [x + 2, "abc " + y];
}

com.twosigma.beaker.groovy.widgets.Interactive.interact(this.&d, 10, "0");
Out[3]:
null
In [2]:
import static com.twosigma.beaker.groovy.widgets.Interactive.interact;

class PlotHolder{
    static String text = ""
    static Plot plot = null;
}

public static Object f(x){
    PlotHolder.text = x;
    if(PlotHolder.plot != null){
        PlotHolder.plot.close();
    }
    PlotHolder.plot = new Plot(title: PlotHolder.text)
    PlotHolder.plot.display()
    PlotHolder.text
}

interact(this.&f, "s");
sfffff
In [ ]:
import static com.twosigma.beaker.groovy.widgets.Interactive.interact;

public Object f(x){
    println "Hello World !!!"
    return x
}

interact(this.&f, "s");
In [3]:
import static com.twosigma.beaker.groovy.widgets.Interactive.interact;

class DataHolder{
    static Plot plot = null;
}

public static Object f(num){
    if(DataHolder.plot != null){
        DataHolder.plot.close();
    }
    
    List x = [0, 10]
    List y = [4, num]
    DataHolder.plot = new Plot().add(new Line(x, y))
    DataHolder.plot.display()
    num
}

interact(this.&f, 4);
Out[3]:
null
In [13]:
import static com.twosigma.beaker.groovy.widgets.Interactive.interact;

class DataHolder{
    static Plot plot = null;
}

public static Object f(x1,x2,y1,y2){
    if(DataHolder.plot != null){
        DataHolder.plot.close();
    }
    
    List x = [x1, x2]
    List y = [y1, y2]
    DataHolder.plot = new Plot().add(new Line(x, y))
    DataHolder.plot.display()
    "x = " + x +" y = " + y
}

interact(this.&f, 0, 10, 4, 4);
x = [0, 7] y = [3, 1]
In [11]:
import static com.twosigma.beaker.groovy.widgets.Interactive.interact;

class DataHolder{
    static Plot plot = null;
}

public static Object f(x1,x2,y1,y2){
    if(DataHolder.plot == null){
        DataHolder.plot = new Plot()
        DataHolder.plot.display()
    }
    List x = [x1, x2]
    List y = [y1, y2]
    DataHolder.plot.getGraphics().clear()
    DataHolder.plot.add(new Line(x, y))
    "x = " + x +" y = " + y
}

interact(this.&f, 0, 10, 4, 4);
x = [0, 24] y = [4, 1]
In [15]:
import static com.twosigma.beaker.groovy.widgets.Interactive.interact;

class PlotHolder{
    static Plot plot = null;
}

public static Object f(x){
    if(PlotHolder.plot == null){
     PlotHolder.plot = new Plot(title: x)
     PlotHolder.plot.display()
    }
    PlotHolder.plot.title = x
}

interact(this.&f, "s");
Out[15]:
null
In [ ]: