{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "package test.beaker;\n", "\n", "import java.util.Date;\n", "import java.text.SimpleDateFormat;\n", "\n", "public class BeakerTest {\n", " private Date _date;\n", " private SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy-MM-dd'T'HH:mmZ\");\n", " \n", " public BeakerTest() {\n", " _date = new Date();\n", " }\n", "\n", " public String getDateTxt() {\n", " return \"Today:\" + sdf.format(_date);\n", " }\n", "\n", " public String getDateUpperCaseTxt() {\n", " return getDateTxt().toUpperCase();\n", " }\n", "\n", "}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "package test.beaker;\n", "\n", "BeakerTest bt = new BeakerTest();\n", "return bt.getDateTxt();" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import java.util.List;\n", "import java.util.ArrayList;\n", "import com.twosigma.beakerx.chart.xychart.Plot;\n", "import com.twosigma.beakerx.chart.xychart.plotitem.*;\n", "import com.twosigma.beakerx.chart.Color;\n", "\n", "Plot p = new Plot();\n", "\n", "p.setTitle(\"this is a Java plot\");\n", "\n", "Bars b = new Bars();\n", "\n", "List yList = new ArrayList();\n", "yList.add(2);\n", "yList.add(5);\n", "yList.add(4);\n", "yList.add(8);\n", "\n", "b.setY(yList);\n", "b.setColor(Color.blue);\n", "b.setWidth(0.5);\n", "\n", "p.add(b);\n", " \n", "return p;" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "package test.beaker;\n", "interface DateGetter {\n", " public String getDateTxt();\n", "}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "package test.beaker;\n", "public class DG2 extends BeakerTest implements DateGetter {\n", "}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%classpath add jar ../../../doc/resources/jar/BeakerXClasspathTest.jar" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "System.out.println(\"The Groovy working folder is :\");\n", "System.out.println(java.nio.file.Paths.get(\".\").toAbsolutePath().normalize().toString());\n", "System.out.println(\"BeakerXClasspathTest.jar exists in this folder\");" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import com.beaker.BeakerXClasspathTest;\n", "\n", "BeakerXClasspathTest t = new BeakerXClasspathTest();\n", "System.out.println(com.beaker.BeakerXClasspathTest.staticTest);\n", "System.out.println(t.getObjectTest());" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "press 'Tab' for autocomplete" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "press 'Shift' + 'Tab' for doc" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Output usage" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import com.twosigma.beakerx.widget.Output;\n", "Output out2 = new Output();\n", "OutputManager.setOutput(out2);\n", "return out2;" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import static java.lang.System.out;\n", "\n", "Thread t = new Thread(() -> {\n", " out.println(\"Some output init\");\n", " try {\n", " Thread.sleep(2000);\n", " } catch (InterruptedException e) {\n", " }\n", " for (int i = 0; i <10 ; i++){\n", " out.println(\"Some output \"+ i); \n", " }\n", "});\n", "out.println(\"Start\");\n", "t.start();\n", "//t.join();\n", "out.println(\"end\");\n", "return \"Thread example result\";" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "OutputManager.clearOutput();" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import static java.lang.System.out;\n", "for (int i = 0; i <30 ; i++){\n", " out.println(\"Done \"+ i); \n", "}\n", "return 3+5;" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "OutputManager.setOutput(null);" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Java", "language": "java", "name": "java" }, "language_info": { "codemirror_mode": "text/x-java", "file_extension": ".java", "mimetype": "", "name": "Java", "nbconverter_exporter": "", "version": "1.8.0_121" } }, "nbformat": 4, "nbformat_minor": 2 }