commit f117c32bb6be4409f728824ac9763a58ea8e7aa4 Author: skylarmt Date: Sun Nov 30 00:34:17 2014 -0700 Initial commit diff --git a/SyMAT-0.3.exe b/SyMAT-0.3.exe new file mode 100644 index 0000000..5cc0b89 Binary files /dev/null and b/SyMAT-0.3.exe differ diff --git a/SyMAT-0.5.1.exe b/SyMAT-0.5.1.exe new file mode 100644 index 0000000..d3cce6f Binary files /dev/null and b/SyMAT-0.5.1.exe differ diff --git a/SyMAT-0.5.exe b/SyMAT-0.5.exe new file mode 100644 index 0000000..afbc373 Binary files /dev/null and b/SyMAT-0.5.exe differ diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..ae40c6a --- /dev/null +++ b/build.xml @@ -0,0 +1,99 @@ + + + + + + + + + + + Builds, tests, and runs SyMAT. + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try (HAXX): + + java -jar "${dist.jar.resolved}" + + + + diff --git a/launch4j.cfg.xml b/launch4j.cfg.xml new file mode 100644 index 0000000..6f6beee --- /dev/null +++ b/launch4j.cfg.xml @@ -0,0 +1,42 @@ + + + false + gui + C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\dist\SyMAT.jar + C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\SyMAT-0.5.1.exe + + + . + normal + http://java.com/download + + false + + C:\Users\Skylar\SparkleShare\aplabs\appmedia\SyMAT\icon.ico + + + false + 1.7.0 + + preferJre + 64/32 + + + C:\Users\Skylar\SparkleShare\aplabs\appmedia\SyMAT\splash0.5.bmp + true + 60 + true + + + 0.5.1.0 + Version 0.5 + SyMAT + 2014 Apocalypse Laboratories + 0.5.1.0 + Version 0.5 + SyMAT + Apocalypse Laboratories + SyMAT + SyMAT-0.5.exe + + \ No newline at end of file diff --git a/launch4j.log b/launch4j.log new file mode 100644 index 0000000..5a11a72 --- /dev/null +++ b/launch4j.log @@ -0,0 +1,128 @@ + + +Version: 3.4 +CmdLine: C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\SyMAT-0.3.exe --l4j-debug +WOW64: yes +Working dir: C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\. +64-bit search: SOFTWARE\JavaSoft\Java Runtime Environment... +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.6 +Ignore: 1.6 +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.6.0_45 +Ignore: 1.6.0_45 +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.7 +Ignore: 1.7 +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.7.0_40 +Check launcher: C:\Program Files\Java\jre7\bin\javaw.exe (OK) +Match: 1.7.0_40 +64-bit search: SOFTWARE\JavaSoft\Java Development Kit... +Check: SOFTWARE\JavaSoft\Java Development Kit\1.6 +Ignore: 1.6 +Check: SOFTWARE\JavaSoft\Java Development Kit\1.6.0_45 +Ignore: 1.6.0_45 +Check: SOFTWARE\JavaSoft\Java Development Kit\1.7 +Ignore: 1.7 +Check: SOFTWARE\JavaSoft\Java Development Kit\1.7.0_40 +Ignore: 1.7.0_40 +Runtime used: 1.7.0_40 (64-bit) +Add classpath: lib\log4j-1.2.11.jar +Add classpath: lib\symja-2014-11-01.jar +Launcher: C:\Program Files\Java\jre7\bin\javaw.exe +Launcher args: -classpath "C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\SyMAT-0.3.exe;lib\log4j-1.2.11.jar;lib\symja-2014-11-01.jar" net.apocalypselabs.symat.MainGUI +Args length: 154/32768 chars +Exit code: 259 + + +Version: 3.4 +CmdLine: C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\SyMAT-0.3.exe --l4j-debug +WOW64: yes +Working dir: C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\. +64-bit search: SOFTWARE\JavaSoft\Java Runtime Environment... +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.6 +Ignore: 1.6 +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.6.0_45 +Ignore: 1.6.0_45 +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.7 +Ignore: 1.7 +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.7.0_40 +Check launcher: C:\Program Files\Java\jre7\bin\javaw.exe (OK) +Match: 1.7.0_40 +64-bit search: SOFTWARE\JavaSoft\Java Development Kit... +Check: SOFTWARE\JavaSoft\Java Development Kit\1.6 +Ignore: 1.6 +Check: SOFTWARE\JavaSoft\Java Development Kit\1.6.0_45 +Ignore: 1.6.0_45 +Check: SOFTWARE\JavaSoft\Java Development Kit\1.7 +Ignore: 1.7 +Check: SOFTWARE\JavaSoft\Java Development Kit\1.7.0_40 +Ignore: 1.7.0_40 +Runtime used: 1.7.0_40 (64-bit) +Add classpath: lib\log4j-1.2.11.jar +Add classpath: lib\symja-2014-11-01.jar +Launcher: C:\Program Files\Java\jre7\bin\javaw.exe +Launcher args: -classpath "C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\SyMAT-0.3.exe;lib\log4j-1.2.11.jar;lib\symja-2014-11-01.jar" net.apocalypselabs.symat.MainGUI +Args length: 154/32768 chars +Exit code: 259 + + +Version: 3.4 +CmdLine: C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\SyMAT-0.3.exe --l4j-debug +WOW64: yes +Working dir: C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\. +64-bit search: SOFTWARE\JavaSoft\Java Runtime Environment... +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.6 +Ignore: 1.6 +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.6.0_45 +Ignore: 1.6.0_45 +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.7 +Ignore: 1.7 +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.7.0_40 +Check launcher: C:\Program Files\Java\jre7\bin\javaw.exe (OK) +Match: 1.7.0_40 +64-bit search: SOFTWARE\JavaSoft\Java Development Kit... +Check: SOFTWARE\JavaSoft\Java Development Kit\1.6 +Ignore: 1.6 +Check: SOFTWARE\JavaSoft\Java Development Kit\1.6.0_45 +Ignore: 1.6.0_45 +Check: SOFTWARE\JavaSoft\Java Development Kit\1.7 +Ignore: 1.7 +Check: SOFTWARE\JavaSoft\Java Development Kit\1.7.0_40 +Ignore: 1.7.0_40 +Runtime used: 1.7.0_40 (64-bit) +Add classpath: lib\log4j-1.2.11.jar +Add classpath: lib\symja-2014-11-01.jar +Launcher: C:\Program Files\Java\jre7\bin\javaw.exe +Launcher args: -classpath "C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\SyMAT-0.3.exe;lib\log4j-1.2.11.jar;lib\symja-2014-11-01.jar" net.apocalypselabs.symat.MainGUI +Args length: 154/32768 chars +Exit code: 259 + + +Version: 3.4 +CmdLine: C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\SyMAT-0.3.exe --l4j-debug +WOW64: yes +Working dir: C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\. +64-bit search: SOFTWARE\JavaSoft\Java Runtime Environment... +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.6 +Ignore: 1.6 +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.6.0_45 +Ignore: 1.6.0_45 +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.7 +Ignore: 1.7 +Check: SOFTWARE\JavaSoft\Java Runtime Environment\1.7.0_40 +Check launcher: C:\Program Files\Java\jre7\bin\javaw.exe (OK) +Match: 1.7.0_40 +64-bit search: SOFTWARE\JavaSoft\Java Development Kit... +Check: SOFTWARE\JavaSoft\Java Development Kit\1.6 +Ignore: 1.6 +Check: SOFTWARE\JavaSoft\Java Development Kit\1.6.0_45 +Ignore: 1.6.0_45 +Check: SOFTWARE\JavaSoft\Java Development Kit\1.7 +Ignore: 1.7 +Check: SOFTWARE\JavaSoft\Java Development Kit\1.7.0_40 +Ignore: 1.7.0_40 +Runtime used: 1.7.0_40 (64-bit) +Add classpath: lib\log4j-1.2.11.jar +Add classpath: lib\symja-2014-11-01.jar +Launcher: C:\Program Files\Java\jre7\bin\javaw.exe +Launcher args: -classpath "C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\SyMAT-0.3.exe;lib\log4j-1.2.11.jar;lib\symja-2014-11-01.jar" net.apocalypselabs.symat.MainGUI +Args length: 154/32768 chars +Exit code: 259 diff --git a/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar b/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar new file mode 100644 index 0000000..8e1ec53 Binary files /dev/null and b/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar differ diff --git a/lib/JavaPrettify-1.2.1.jar b/lib/JavaPrettify-1.2.1.jar new file mode 100644 index 0000000..0771244 Binary files /dev/null and b/lib/JavaPrettify-1.2.1.jar differ diff --git a/lib/htmlcleaner-2.10.jar b/lib/htmlcleaner-2.10.jar new file mode 100644 index 0000000..4221573 Binary files /dev/null and b/lib/htmlcleaner-2.10.jar differ diff --git a/lib/iText-4.2.0-com.itextpdf.jar b/lib/iText-4.2.0-com.itextpdf.jar new file mode 100644 index 0000000..af75b58 Binary files /dev/null and b/lib/iText-4.2.0-com.itextpdf.jar differ diff --git a/lib/js-engine.jar b/lib/js-engine.jar new file mode 100644 index 0000000..94e2c13 Binary files /dev/null and b/lib/js-engine.jar differ diff --git a/lib/js.jar b/lib/js.jar new file mode 100644 index 0000000..6f0dafb Binary files /dev/null and b/lib/js.jar differ diff --git a/lib/log4j-1.2.11.jar b/lib/log4j-1.2.11.jar new file mode 100644 index 0000000..b603fe6 Binary files /dev/null and b/lib/log4j-1.2.11.jar differ diff --git a/lib/nblibraries.properties b/lib/nblibraries.properties new file mode 100644 index 0000000..6d0afb5 --- /dev/null +++ b/lib/nblibraries.properties @@ -0,0 +1,4 @@ +libs.CopyLibs.classpath=\ + ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar +libs.CopyLibs.displayName=CopyLibs Task +libs.CopyLibs.prop-version=2.0 diff --git a/lib/symja-2014-11-01.jar b/lib/symja-2014-11-01.jar new file mode 100644 index 0000000..63e947a Binary files /dev/null and b/lib/symja-2014-11-01.jar differ diff --git a/manifest.mf b/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..fb4f4c9 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1439 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/build-native.xml b/nbproject/build-native.xml new file mode 100644 index 0000000..75448ad --- /dev/null +++ b/nbproject/build-native.xml @@ -0,0 +1,953 @@ + + + + + + + + + Native Packager Ant calls based on SE support in JavaFX packager + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + self.addMappedName( + (source.indexOf("jfxrt.jar") >= 0) || + (source.indexOf("deploy.jar") >= 0) || + (source.indexOf("javaws.jar") >= 0) || + (source.indexOf("plugin.jar") >= 0) + ? "" : source + ); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..4f17ff5 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=df50d06e +build.xml.script.CRC32=43ba75c8 +build.xml.stylesheet.CRC32=8064a381@1.75.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=5e7cbec2 +nbproject/build-impl.xml.script.CRC32=fb76102b +nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.1.48 diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..87d6adf --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,108 @@ +annotation.processing.enabled=true +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.splash=C:\\Users\\Skylar\\SparkleShare\\aplabs\\appmedia\\SyMAT\\splash0.5.png +application.title=SyMAT +application.vendor=Apocalypse Laboratories +auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/SyMAT.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +file.reference.htmlcleaner-2.10.jar=lib/htmlcleaner-2.10.jar +file.reference.iText-4.2.0-com.itextpdf.jar=lib/iText-4.2.0-com.itextpdf.jar +file.reference.JavaPrettify-1.2.1.jar=lib/JavaPrettify-1.2.1.jar +file.reference.js-engine.jar=lib/js-engine.jar +file.reference.js.jar=lib/js.jar +file.reference.log4j-1.2.11.jar=lib/log4j-1.2.11.jar +file.reference.symja-2014-11-01.jar=lib/symja-2014-11-01.jar +includes=** +jar.archive.disabled=${jnlp.enabled} +jar.compress=true +jar.index=${jnlp.enabled} +javac.classpath=\ + ${file.reference.log4j-1.2.11.jar}:\ + ${file.reference.symja-2014-11-01.jar}:\ + ${file.reference.JavaPrettify-1.2.1.jar}:\ + ${file.reference.iText-4.2.0-com.itextpdf.jar}:\ + ${file.reference.htmlcleaner-2.10.jar}:\ + ${file.reference.js-engine.jar}:\ + ${file.reference.js.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +jnlp.codebase.type=no.codebase +jnlp.descriptor=application +jnlp.enabled=false +jnlp.mixed.code=default +jnlp.offline-allowed=false +jnlp.signed=false +jnlp.signing= +jnlp.signing.alias= +jnlp.signing.keystore= +main.class=net.apocalypselabs.symat.MainGUI +# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed +manifest.custom.codebase= +# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) +manifest.custom.permissions= +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +native.bundling.enabled=true +platform.active=default_platform +project.license=lgpl21 +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..5585b37 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,21 @@ + + + org.netbeans.modules.java.j2seproject + + + + + + SyMAT + + + + + + + + + .\lib\nblibraries.properties + + + diff --git a/src/net/apocalypselabs/symat/CodeEditor.form b/src/net/apocalypselabs/symat/CodeEditor.form new file mode 100644 index 0000000..e3c4f4e --- /dev/null +++ b/src/net/apocalypselabs/symat/CodeEditor.form @@ -0,0 +1,263 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/net/apocalypselabs/symat/CodeEditor.java b/src/net/apocalypselabs/symat/CodeEditor.java new file mode 100644 index 0000000..863f52c --- /dev/null +++ b/src/net/apocalypselabs/symat/CodeEditor.java @@ -0,0 +1,415 @@ +/* + * Copyright (C) 2014 Apocalypse Laboratories. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package net.apocalypselabs.symat; + +import java.awt.Font; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTextPane; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.text.AttributeSet; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyleContext; +import javax.swing.text.TabSet; +import javax.swing.text.TabStop; + +/** + * + * @author Skylar + */ +public class CodeEditor extends javax.swing.JInternalFrame { + + private final JFileChooser fc = new JFileChooser(); + private boolean isSaved = false; + private final JTextPane codeBox = new JTextPane(); + private final TextLineNumber tln; + private String lastSaved = ""; + + /** + * Creates new form CodeEditor + */ + public CodeEditor() { + initComponents(); + FileFilter filter = new FileNameExtensionFilter("SyMAT script (.symt)", "symt"); + fc.setFileFilter(filter); + fc.addChoosableFileFilter(filter); + filter = new FileNameExtensionFilter("JavaScript file (.js)", "js"); + fc.addChoosableFileFilter(filter); + filter = new FileNameExtensionFilter("MeetLeeb script (.mls)", "mls"); + fc.addChoosableFileFilter(filter); + int font_size = 12; + try { + font_size = Integer.valueOf(PrefStorage.getSetting("editor-fontsize")); + } catch (Exception ex) { } + codeBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, font_size)); + TabStop[] tabs = new TabStop[30]; + for (int i = 0; i < tabs.length; i++) { + tabs[i] = new TabStop(15*i, TabStop.ALIGN_RIGHT, TabStop.LEAD_NONE); + } + TabSet tabset = new TabSet(tabs); + StyleContext sc = StyleContext.getDefaultStyleContext(); + AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, + StyleConstants.TabSet, tabset); + codeBox.setParagraphAttributes(aset, false); + tln = new TextLineNumber(codeBox); + scrollPane.setRowHeaderView(tln); + codeBox.setVisible(true); + tln.setVisible(true); + codeBox.requestFocus(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jMenuItem4 = new javax.swing.JMenuItem(); + jMenuBar2 = new javax.swing.JMenuBar(); + jMenu3 = new javax.swing.JMenu(); + jMenu4 = new javax.swing.JMenu(); + jPanel1 = new javax.swing.JPanel(); + jSplitPane1 = new javax.swing.JSplitPane(); + scrollPane = new JScrollPane(codeBox); + jPanel2 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + outputPane = new javax.swing.JTextArea(); + jMenuBar1 = new javax.swing.JMenuBar(); + jMenu1 = new javax.swing.JMenu(); + jMenuItem1 = new javax.swing.JMenuItem(); + jMenuItem2 = new javax.swing.JMenuItem(); + jMenuItem3 = new javax.swing.JMenuItem(); + jMenuItem8 = new javax.swing.JMenuItem(); + jMenu5 = new javax.swing.JMenu(); + jMenuItem6 = new javax.swing.JMenuItem(); + jMenuItem7 = new javax.swing.JMenuItem(); + jMenu2 = new javax.swing.JMenu(); + jMenuItem5 = new javax.swing.JMenuItem(); + + jMenuItem4.setText("jMenuItem4"); + + jMenu3.setText("File"); + jMenuBar2.add(jMenu3); + + jMenu4.setText("Edit"); + jMenuBar2.add(jMenu4); + + setClosable(true); + setIconifiable(true); + setMaximizable(true); + setResizable(true); + setTitle("Editor"); + setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/editor.png"))); // NOI18N + + jSplitPane1.setDividerLocation(275); + jSplitPane1.setDividerSize(3); + jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); + jSplitPane1.setResizeWeight(0.7); + + scrollPane.setRequestFocusEnabled(false); + jSplitPane1.setTopComponent(scrollPane); + + jLabel1.setText("Output:"); + + outputPane.setEditable(false); + outputPane.setColumns(20); + outputPane.setRows(5); + jScrollPane1.setViewportView(outputPane); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel1) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 524, Short.MAX_VALUE) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE)) + ); + + jSplitPane1.setRightComponent(jPanel2); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jSplitPane1) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 359, Short.MAX_VALUE) + ); + + jMenu1.setText("File"); + + jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem1.setText("Open..."); + jMenuItem1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem1ActionPerformed(evt); + } + }); + jMenu1.add(jMenuItem1); + + jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem2.setText("Save..."); + jMenuItem2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem2ActionPerformed(evt); + } + }); + jMenu1.add(jMenuItem2); + + jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem3.setText("Save as..."); + jMenuItem3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem3ActionPerformed(evt); + } + }); + jMenu1.add(jMenuItem3); + + jMenuItem8.setText("Export..."); + jMenuItem8.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem8ActionPerformed(evt); + } + }); + jMenu1.add(jMenuItem8); + + jMenuBar1.add(jMenu1); + + jMenu5.setText("Edit"); + + jMenuItem6.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem6.setText("Clear output"); + jMenuItem6.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem6ActionPerformed(evt); + } + }); + jMenu5.add(jMenuItem6); + + jMenuItem7.setText("Font size..."); + jMenuItem7.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem7ActionPerformed(evt); + } + }); + jMenu5.add(jMenuItem7); + + jMenuBar1.add(jMenu5); + + jMenu2.setText("Run"); + jMenu2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenu2ActionPerformed(evt); + } + }); + + jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, 0)); + jMenuItem5.setText("Run code"); + jMenuItem5.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem5ActionPerformed(evt); + } + }); + jMenu2.add(jMenuItem5); + + jMenuBar1.add(jMenu2); + + setJMenuBar(jMenuBar1); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + + pack(); + }// //GEN-END:initComponents + + private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed + int r = fc.showOpenDialog(this); + if (r == JFileChooser.APPROVE_OPTION) { + try { + File f = fc.getSelectedFile(); + codeBox.setText(readFile(f.toString(), StandardCharsets.UTF_8)); + isSaved = true; + setTitle("Editor - " + f.getName()); + } catch (IOException ex) { + JOptionPane.showInternalMessageDialog(this, "Error: Cannot load file: " + ex.getMessage()); + } + } + codeBox.setCaretPosition(0); + }//GEN-LAST:event_jMenuItem1ActionPerformed + + private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed + if (!isSaved) { + int r = fc.showSaveDialog(this); + if (r == JFileChooser.APPROVE_OPTION) { + try { + saveFile(codeBox.getText(), addSaveExt(fc.getSelectedFile().toString())); + } catch (IOException ex) { + JOptionPane.showInternalMessageDialog(this, "Error: Cannot save file: " + ex.getMessage()); + } + } + } else { + try { + saveFile(codeBox.getText(), addSaveExt(fc.getSelectedFile().toString())); + } catch (IOException ex) { + JOptionPane.showInternalMessageDialog(this, "Error: Cannot save file: " + ex.getMessage()); + } + } + }//GEN-LAST:event_jMenuItem2ActionPerformed + + private String addSaveExt(String path) { + if (!path.matches(".*\\.(js|mls|symt)")) { + path += ".symt"; + } + return path; + } + private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed + isSaved = false; // Reset saved status, force dialog + jMenuItem2ActionPerformed(evt); + }//GEN-LAST:event_jMenuItem3ActionPerformed + + private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu2ActionPerformed + + }//GEN-LAST:event_jMenu2ActionPerformed + + private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed + CodeRunner cr = new CodeRunner(); + Object result = cr.evalString(codeBox.getText()); + try { + outputPane.append(result.toString() + "\n"); + } catch (NullPointerException ex) { + + } + }//GEN-LAST:event_jMenuItem5ActionPerformed + + private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed + outputPane.setText(""); + }//GEN-LAST:event_jMenuItem6ActionPerformed + + private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed + try { + int size = Integer.parseInt(JOptionPane.showInternalInputDialog(this, + "New font size (8-36):", + "Font Size", + JOptionPane.QUESTION_MESSAGE)); + if (size >= 8 && size <= 36) { + codeBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, size)); + PrefStorage.saveSetting("editor-fontsize", size+""); + } + } catch (Exception ex) { + + } + }//GEN-LAST:event_jMenuItem7ActionPerformed + + private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed + CodeExport ce = new CodeExport(codeBox.getText()); + MainGUI.loadFrame(ce); + }//GEN-LAST:event_jMenuItem8ActionPerformed + + private void saveFile(String content, String path) + throws IOException { + try (PrintStream out = new PrintStream(new FileOutputStream(path))) { + out.print(content); + } + setTitle("Editor - " + (new File(path)).getName()); + lastSaved = content; + isSaved = true; + } + + @Override + public void doDefaultCloseAction() { + if (lastSaved.equals(codeBox.getText())) { + dispose(); + } else { + int p = JOptionPane.showInternalConfirmDialog(this, + "Are you sure you want to exit without saving this file?", + "Unsaved Changes", + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + if (p == JOptionPane.YES_OPTION) { + dispose(); + } else { + jMenuItem3ActionPerformed(null); + } + } + } + + private static String readFile(String path, Charset encoding) + throws IOException { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded, encoding); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JMenu jMenu1; + private javax.swing.JMenu jMenu2; + private javax.swing.JMenu jMenu3; + private javax.swing.JMenu jMenu4; + private javax.swing.JMenu jMenu5; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JMenuBar jMenuBar2; + private javax.swing.JMenuItem jMenuItem1; + private javax.swing.JMenuItem jMenuItem2; + private javax.swing.JMenuItem jMenuItem3; + private javax.swing.JMenuItem jMenuItem4; + private javax.swing.JMenuItem jMenuItem5; + private javax.swing.JMenuItem jMenuItem6; + private javax.swing.JMenuItem jMenuItem7; + private javax.swing.JMenuItem jMenuItem8; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JSplitPane jSplitPane1; + private javax.swing.JTextArea outputPane; + private javax.swing.JScrollPane scrollPane; + // End of variables declaration//GEN-END:variables +} diff --git a/src/net/apocalypselabs/symat/CodeExport.form b/src/net/apocalypselabs/symat/CodeExport.form new file mode 100644 index 0000000..472d701 --- /dev/null +++ b/src/net/apocalypselabs/symat/CodeExport.form @@ -0,0 +1,246 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/net/apocalypselabs/symat/CodeExport.java b/src/net/apocalypselabs/symat/CodeExport.java new file mode 100644 index 0000000..3461267 --- /dev/null +++ b/src/net/apocalypselabs/symat/CodeExport.java @@ -0,0 +1,373 @@ +/* + * Copyright (C) 2014 Skylar. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package net.apocalypselabs.symat; + +import com.itextpdf.text.Document; +import com.itextpdf.text.DocumentException; +import com.itextpdf.text.html.simpleparser.HTMLWorker; +import com.itextpdf.text.html.simpleparser.StyleSheet; +import com.itextpdf.text.pdf.PdfWriter; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.StringReader; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import org.htmlcleaner.CleanerProperties; +import org.htmlcleaner.HtmlCleaner; +import org.htmlcleaner.SimpleHtmlSerializer; +import org.htmlcleaner.TagNode; +import prettify.PrettifyParser; +import syntaxhighlight.ParseResult; + +/** + * + * @author Skylar + */ +public class CodeExport extends javax.swing.JInternalFrame { + + private String html; + private final String origCode; + private final JFileChooser fc = new JFileChooser(); + + /** + * Creates new form CodeExport + * + * @param code + */ + public CodeExport(String code) { + origCode = code; + initComponents(); + html = genHtml(code); + previewPane.setText(html); + previewPane.setCaretPosition(0); + } + + private String genHtml(String code) { + String css = ""; + BufferedReader reader = new BufferedReader( + new InputStreamReader( + CodeExport.class + .getResourceAsStream("pretty.css"))); + String line; + try { + while ((line = reader.readLine()) != null) { + css += line; + } + } catch (IOException ex) { + Logger.getLogger(CodeExport.class.getName()).log(Level.SEVERE, null, ex); + } + html = "" + + "" + + "" + + "" + + "" + + "" + + "" + + "

" + titleBox.getText() + "

"; + if (!authBox.getText().equals("")) { + html += "

Author: " + authBox.getText() + "

"; + } + if (!dateBox.getText().equals("")) { + html += "

Date: " + dateBox.getText() + "

"; + } + if (!headerBox.getText().equals("")) { + html += "

" + headerBox.getText() + "

"; + } + PrettifyParser parser = new PrettifyParser(); + List parseResults = parser.parse("js", code); + html += PrettifyToHtml.toHtml(code, parseResults); + html += ""; + html = html.replace("\t", "    "); + html = html.replace("\n", "
"); + HtmlCleaner cleaner = new HtmlCleaner(); + CleanerProperties props = cleaner.getProperties(); + TagNode node = cleaner.clean(html); + html = new SimpleHtmlSerializer(props).getAsString(node); + html = html.replace("'", "'"); + html = html.replace("", ""); + System.out.println(html); + return html; + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + previewPane = new javax.swing.JTextPane(); + jPanel1 = new javax.swing.JPanel(); + titleBox = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + authBox = new javax.swing.JTextField(); + dateBox = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + jScrollPane2 = new javax.swing.JScrollPane(); + headerBox = new javax.swing.JTextArea(); + jLabel4 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); + jPanel2 = new javax.swing.JPanel(); + exHtml = new javax.swing.JButton(); + exPdf = new javax.swing.JButton(); + + setClosable(true); + setIconifiable(true); + setMaximizable(true); + setResizable(true); + setTitle("Export Code"); + + previewPane.setEditable(false); + previewPane.setContentType("text/html"); // NOI18N + jScrollPane1.setViewportView(previewPane); + + titleBox.setText("SyMAT Project"); + + jLabel1.setText("Title:"); + + jLabel2.setText("Author:"); + + jLabel3.setText("Date:"); + + headerBox.setColumns(20); + headerBox.setLineWrap(true); + headerBox.setRows(2); + headerBox.setTabSize(4); + headerBox.setWrapStyleWord(true); + jScrollPane2.setViewportView(headerBox); + + jLabel4.setText("Header:"); + + jButton1.setText("Update Preview"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Export as:")); + + exHtml.setText("HTML"); + exHtml.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + exHtmlActionPerformed(evt); + } + }); + + exPdf.setText("PDF"); + exPdf.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + exPdfActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(exHtml, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(exPdf, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)) + .addContainerGap()) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(exHtml) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(exPdf) + .addGap(0, 13, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel1) + .addGap(18, 18, 18) + .addComponent(titleBox, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2) + .addComponent(jLabel3)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(dateBox) + .addComponent(authBox)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jButton1)) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(5, 5, 5) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(titleBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1) + .addComponent(jLabel4) + .addComponent(jButton1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(authBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(dateBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3))) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGap(0, 0, 0)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 286, Short.MAX_VALUE) + .addGap(4, 4, 4) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0)) + ); + + pack(); + }// //GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + html = genHtml(origCode); + previewPane.setText(html); + previewPane.setCaretPosition(0); + }//GEN-LAST:event_jButton1ActionPerformed + + private void exHtmlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exHtmlActionPerformed + doSave("html"); + }//GEN-LAST:event_exHtmlActionPerformed + + private void exPdfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exPdfActionPerformed + doSave("pdf"); + }//GEN-LAST:event_exPdfActionPerformed + + private void doSave(String format) { + int r = fc.showSaveDialog(this); + if (r == JFileChooser.APPROVE_OPTION) { + switch (format) { + case "html": + saveFile(html, addSaveExt(fc.getSelectedFile().toString(), format)); + break; + case "pdf": + savePdfFile(html, addSaveExt(fc.getSelectedFile().toString(), format)); + break; + } + } + } + + private void savePdfFile(String html, String path) { + try { + String k = html; + try (OutputStream file = new FileOutputStream(new File(path))) { + Document document = new Document(); + PdfWriter.getInstance(document, file); + document.open(); + HTMLWorker htmlWorker = new HTMLWorker(document); + StyleSheet styles = new StyleSheet(); + styles.loadStyle("com", "color", "green"); + styles.loadStyle("kwd", "color", "blue"); + styles.loadStyle("pln", "color", "black"); + styles.loadStyle("lit", "color", "#0099cc"); + styles.loadStyle("pun", "color", "black"); + styles.loadStyle("pun", "font-weight", "bold"); + htmlWorker.setStyleSheet(styles); + htmlWorker.parse(new StringReader(k)); + document.close(); + } + } catch (IOException | DocumentException e) { + JOptionPane.showInternalMessageDialog(this, "Error saving: " + e.getMessage()); + } + } + + private void saveFile(String content, String path) { + try { + PrintStream out = new PrintStream(new FileOutputStream(path)); + out.print(content); + } catch (Exception ex) { + JOptionPane.showInternalMessageDialog(this, "Error saving: " + ex.getMessage()); + } + } + + private String addSaveExt(String path, String format) { + if (!path.matches(".*\\.(" + format + ")")) { + path += "." + format; + } + return path; + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField authBox; + private javax.swing.JTextField dateBox; + private javax.swing.JButton exHtml; + private javax.swing.JButton exPdf; + private javax.swing.JTextArea headerBox; + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JTextPane previewPane; + private javax.swing.JTextField titleBox; + // End of variables declaration//GEN-END:variables +} diff --git a/src/net/apocalypselabs/symat/CodeRunner.java b/src/net/apocalypselabs/symat/CodeRunner.java new file mode 100644 index 0000000..0113b42 --- /dev/null +++ b/src/net/apocalypselabs/symat/CodeRunner.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2014 Apocalypse Laboratories. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package net.apocalypselabs.symat; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import javax.script.*; +import javax.swing.JOptionPane; + +/** + * + * @author Skylar + */ +public class CodeRunner { + + ScriptEngine jse = new ScriptEngineManager().getEngineByName("rhino"); + boolean isJava8 = false; + + public CodeRunner() { + try { + // Add custom functions. + jse.eval("importClass(net.apocalypselabs.symat.Functions);" + + "SyMAT_Functions = new net.apocalypselabs.symat.Functions();"); + } catch (ScriptException ex) { + JOptionPane.showMessageDialog(null, "Error: " + + "Could not properly initialize scripting engine." + + "\n\nSome functions may not work.\n\n" + + "(" + ex.getMessage() + ")"); + } + } + + /** + * Parse a String of JavaScript. + * + * @param eval A String of JavaScript to evaluate. + * @return the result. + */ + public Object evalString(String eval) { + try { + return jse.eval(wrapMath(eval)); + } catch (ScriptException ex) { + return formatEx(ex); + } + } + + private String formatEx(ScriptException ex) { + String err = ex.getMessage(); + //err = err.replace("sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: ", ""); + //err = err.replace("", "file"); + //err = err.replace("sun.org.mozilla.javascript.internal.EvaluatorException: ", ""); + return "Error: " + err; + } + + /** + * Allows use of Math.blah() as just blah(). + * Also gives access to SyMAT Java functions. + * @param eval input string + * @return wrapped input + */ + private String wrapMath(String eval) { + String with = "with(SyMAT_Functions){with(Math){" + eval + "}}"; + //System.out.println(with); + return with; + } + + public void setVar(String var, Object val) { + jse.put(var, val); + } + + public Object getVar(String var) { + return jse.get(var); + } + + private String jsFunctions() { + String text = ""; + try { + BufferedReader reader = new BufferedReader( + new InputStreamReader( + CodeRunner.class + .getResourceAsStream("functions.js"))); + String line; + while ((line = reader.readLine()) != null) { + text += line; + } + } catch (Exception e) { + } + return text; + } +} diff --git a/src/net/apocalypselabs/symat/Functions.java b/src/net/apocalypselabs/symat/Functions.java new file mode 100644 index 0000000..9fd0e98 --- /dev/null +++ b/src/net/apocalypselabs/symat/Functions.java @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2014 Apocalypse Laboratories. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package net.apocalypselabs.symat; + +import javax.swing.JOptionPane; +import org.matheclipse.core.eval.EvalUtilities; +import org.matheclipse.parser.client.math.MathException; + +/** + * These functions are accessible from JavaScript. + * + * There are a lot of aliases in here too. + * + * @author Skylar + */ +public class Functions { + EvalUtilities util = new EvalUtilities(false, true); + Graph graphwin = new Graph(true); + + /* + Useful interactions + */ + public void notify(Object message) { + JOptionPane.showInternalMessageDialog(MainGUI.mainPane, message.toString()); + } + + public String ask(String question) { + return JOptionPane.showInternalInputDialog(MainGUI.mainPane, question); + } + + public void write(String content) { + // TODO: enable output logging + } + + + /* + Math commands + */ + public String d(String function, String idv) { + return util.evaluate("diff("+function+","+idv+")").toString(); + } + + public String sym(String input) { + return util.evaluate(input).toString(); + } + + public String replace(String function, String variable, String newvar) { + return function.replaceAll(variable, newvar); + } + + public double subs(String function, String variable, String newvar) { + return numof(function.replaceAll(variable, newvar)); + } + + public double numof(String f) { + try { + return Double.parseDouble(util.evaluate("N("+f+")").toString()); + } catch (MathException | NumberFormatException ex) { + return 0.0; + } + } + + /* + Graphing interfaces + */ + public void plot(String function) { + graphwin.setVisible(true); + graphwin.graphFunction(function); + } + + public void ezplot(String f) { + plot(f); + } + + public void graph(String f) { + plot(f); + } + + public void plotname(String t) { + graphwin.setVisible(true); + graphwin.setWindowTitle(t); + } + + public String plotname() { + return graphwin.getTitle(); + } + + public void plotclr() { + graphwin.clearDraw(); + } + + public void clearplot() { + plotclr(); + } + + public void plotclear() { + plotclr(); + } + + public void plotscale(int level) { + graphwin.setVisible(true); + graphwin.setZoom(level); + } + + public void drawdot(double x, double y) { + graphwin.setVisible(true); + graphwin.drawDot(x, y); + } + + + /* + Other + */ + + public String sysinfo() { + String info = "==Java System Information==\n"; + info += "Java version: "+System.getProperty("java.version"); + info += "\nJava vendor: "+System.getProperty("java.vendor"); + info += "\nJava home: "+System.getProperty("java.home"); + return info; + } + + /* + Constructor. + */ + public Functions() { + MainGUI.mainPane.add(graphwin); + } +} diff --git a/src/net/apocalypselabs/symat/Graph.form b/src/net/apocalypselabs/symat/Graph.form new file mode 100644 index 0000000..d27b83b --- /dev/null +++ b/src/net/apocalypselabs/symat/Graph.form @@ -0,0 +1,180 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/net/apocalypselabs/symat/Graph.java b/src/net/apocalypselabs/symat/Graph.java new file mode 100644 index 0000000..ae2e545 --- /dev/null +++ b/src/net/apocalypselabs/symat/Graph.java @@ -0,0 +1,456 @@ +/* + * Copyright (C) 2014 Apocalypse Laboratories. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package net.apocalypselabs.symat; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileNameExtensionFilter; +import org.matheclipse.core.eval.EvalUtilities; +import org.matheclipse.parser.client.math.MathException; + +/** + * + * @author Skylar + */ +public class Graph extends javax.swing.JInternalFrame { + + private final JFileChooser fc = new JFileChooser(); + private BufferedImage gpnl; + private Graphics gg; // Main graphics object + private boolean standalone = true; + private boolean customName = false; + + private double xtimes = 15; + private double ytimes = 15; + private double scale = 1; + + /** + * Creates new form Graph + */ + public Graph() { + init(); + } + + public Graph(boolean isInternal) { + init(); + standalone = !isInternal; + } + + private void init() { + initComponents(); + gpnl = new BufferedImage(300, 300, BufferedImage.TYPE_INT_ARGB); + FileFilter filter = new FileNameExtensionFilter("PNG image (.png)", "png"); + fc.setFileFilter(filter); + fc.addChoosableFileFilter(filter); + filter = new FileNameExtensionFilter("JPEG image (.jpg)", "jpg"); + fc.addChoosableFileFilter(filter); + } + + @Override + public void doDefaultCloseAction() { + if (standalone) { + dispose(); + } else { + hide(); + } + } + + public void forceClose() { + dispose(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + inBox = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); + gLbl = new javax.swing.JLabel(); + jMenuBar1 = new javax.swing.JMenuBar(); + jMenu1 = new javax.swing.JMenu(); + jMenuItem2 = new javax.swing.JMenuItem(); + jMenu2 = new javax.swing.JMenu(); + jMenuItem1 = new javax.swing.JMenuItem(); + jMenuItem6 = new javax.swing.JMenuItem(); + jMenuItem3 = new javax.swing.JMenuItem(); + scaleLbl = new javax.swing.JMenu(); + + setClosable(true); + setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); + setIconifiable(true); + setTitle("Graph"); + setToolTipText(""); + setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/graph.png"))); // NOI18N + addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { + public void mouseDragged(java.awt.event.MouseEvent evt) { + formMouseDragged(evt); + } + public void mouseMoved(java.awt.event.MouseEvent evt) { + formMouseMoved(evt); + } + }); + addComponentListener(new java.awt.event.ComponentAdapter() { + public void componentMoved(java.awt.event.ComponentEvent evt) { + formComponentMoved(evt); + } + public void componentShown(java.awt.event.ComponentEvent evt) { + formComponentShown(evt); + } + }); + + inBox.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { + inBoxKeyTyped(evt); + } + }); + + jLabel1.setText("f(x)="); + + jButton1.setText(">>"); + jButton1.setToolTipText(""); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + gLbl.setBackground(new java.awt.Color(255, 255, 255)); + gLbl.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + gLbl.setMaximumSize(new java.awt.Dimension(300, 300)); + gLbl.setMinimumSize(new java.awt.Dimension(300, 300)); + gLbl.setOpaque(true); + gLbl.setPreferredSize(new java.awt.Dimension(300, 300)); + + jMenu1.setText("File"); + + jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem2.setText("Export graph..."); + jMenuItem2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem2ActionPerformed(evt); + } + }); + jMenu1.add(jMenuItem2); + + jMenuBar1.add(jMenu1); + + jMenu2.setText("Edit"); + + jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem1.setText("Clear Graph"); + jMenuItem1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem1ActionPerformed(evt); + } + }); + jMenu2.add(jMenuItem1); + + jMenuItem6.setText("Scale..."); + jMenuItem6.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem6ActionPerformed(evt); + } + }); + jMenu2.add(jMenuItem6); + + jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK)); + jMenuItem3.setText("Set Title..."); + jMenuItem3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem3ActionPerformed(evt); + } + }); + jMenu2.add(jMenuItem3); + + jMenuBar1.add(jMenu2); + + scaleLbl.setForeground(java.awt.Color.blue); + scaleLbl.setText("Scale: 1 to 1"); + scaleLbl.setEnabled(false); + jMenuBar1.add(scaleLbl); + + setJMenuBar(jMenuBar1); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(inBox, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1)) + .addComponent(gLbl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(gLbl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(inBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1) + .addComponent(jButton1)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + CodeRunner cr = new CodeRunner(); + String formula = inBox.getText().replaceAll("x", "\\$x"); + EvalUtilities solver = new EvalUtilities(); + double xx, yy, xo, yo, x; + xo = 0; + yo = 0; + gg = gpnl.getGraphics(); + drawAxes(); + gg.setColor(Color.BLUE); + for (x = (-10 * scale); x <= (10 * scale); x += (10 * scale * .01)) { + try { + cr.setVar("x", x); + yy = (-(Double.parseDouble(solver.evaluate("$x=" + x + ";N[" + formula + "]").toString())) * ytimes) + (gpnl.getHeight() / 2); + //System.err.println(solver.evaluate("$x="+x+";N["+formula+"]").toString()); + xx = (x * xtimes) + (gpnl.getWidth() / 2); + //gg.drawOval(xx-1, yy-1, 2, 2); + if (x != (-10 * scale)) { + gg.drawLine((int) xo, (int) yo, (int) xx, (int) yy); + } + xo = xx; + yo = yy; + } catch (MathException | NumberFormatException ex) { + + } + } + gg.translate(gpnl.getWidth() / 2, gpnl.getHeight() / 2); + dispGraph(); + if (!customName) { + setTitle("Graph | " + inBox.getText()); + } + }//GEN-LAST:event_jButton1ActionPerformed + + private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown + gg = gpnl.getGraphics(); + drawAxes(); + gg.translate(gpnl.getWidth() / 2, gpnl.getHeight() / 2); + dispGraph(); + }//GEN-LAST:event_formComponentShown + + /** + * Set the zoom level. The larger the int, the more zoomed it is. + * + * @param zoomLevel Level to zoom. 0 is default (10x10). + */ + public void setZoom(int zoomLevel) { + switch (zoomLevel) { + case -1: + xtimes = 7.5; + ytimes = 7.5; + scale = 2; + case 1: + xtimes = 30; + ytimes = 30; + scale = .5; + break; + case 2: + xtimes = 60; + ytimes = 60; + scale = .25; + break; + case 3: + xtimes = 120; + ytimes = 120; + scale = .125; + break; + default: + xtimes = 15; + ytimes = 15; + scale = 1; + } + scaleLbl.setText("Scale: 1 to " + scale); + clearDraw(); + } + + private void dispGraph() { + gLbl.setIcon(new ImageIcon(gpnl)); + } + + public void drawDot(double x, double y) { + gg.setColor(Color.RED); + gg.drawOval((int) (x * xtimes - 2), (int) (y * -ytimes - 2), 4, 4); + dispGraph(); + } + + private void inBoxKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inBoxKeyTyped + if (evt.getKeyChar() == '\n') { + jButton1ActionPerformed(null); + } + }//GEN-LAST:event_inBoxKeyTyped + + private void formComponentMoved(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentMoved + + }//GEN-LAST:event_formComponentMoved + + private void formMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseMoved + // TODO add your handling code here: + }//GEN-LAST:event_formMouseMoved + + private void formMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseDragged + + }//GEN-LAST:event_formMouseDragged + + private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed + gpnl = new BufferedImage(300, 300, BufferedImage.TYPE_INT_ARGB); + gg = gpnl.getGraphics(); + drawAxes(); + gg.translate(gpnl.getWidth() / 2, gpnl.getHeight() / 2); + dispGraph(); + setTitle("Graph"); + }//GEN-LAST:event_jMenuItem1ActionPerformed + + private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed + int r = fc.showSaveDialog(this); + if (r == JFileChooser.APPROVE_OPTION) { + try { + File file = new File(addSaveExt(fc.getSelectedFile().toString())); + if (file.toString().endsWith("png")) { + ImageIO.write(gpnl, "png", file); + } else if (file.toString().endsWith("jpg")) { + ImageIO.write(gpnl, "jpg", file); + } + } catch (IOException ex) { + JOptionPane.showInternalMessageDialog(this, "Error: Cannot save file: " + ex.getMessage()); + } + } + }//GEN-LAST:event_jMenuItem2ActionPerformed + + private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed + String wintitle = JOptionPane.showInternalInputDialog(this, + "New window title:", + "Rename", + JOptionPane.QUESTION_MESSAGE); + if (wintitle != null && !wintitle.equals("")) { + setWindowTitle(wintitle); + } + }//GEN-LAST:event_jMenuItem3ActionPerformed + + private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed + try { + int size = Integer.parseInt(JOptionPane.showInternalInputDialog(this, + "Graph scale, -1 to 3 (-1 least detail, 3 most detail):", + "Scale", + JOptionPane.QUESTION_MESSAGE)); + setZoom(size); + } catch (Exception ex) { + + } + }//GEN-LAST:event_jMenuItem6ActionPerformed + + /** + * Graph the given function. Same as typing into input box and pressing + * Enter. + * + * @param f f(x) = f + */ + public void graphFunction(String f) { + inBox.setText(f); + jButton1ActionPerformed(null); + } + + private String addSaveExt(String path) { + if (!path.matches(".*\\.(png|jpg)")) { + path += ".png"; + } + return path; + } + + /** + * Set the wintitle of this graph window. + * + * @param t The wintitle. + */ + public void setWindowTitle(String t) { + setTitle(t); + customName = true; + } + + /** + * Get the wintitle of the window. + * + * @return the wintitle, stupid! + */ + public String getWindowTitle() { + return getTitle(); + } + + /** + * Erase the graph. + */ + public void clearDraw() { + jMenuItem1ActionPerformed(null); + } + + private void drawAxes() { + gg.setColor(Color.GRAY); + gg.drawLine(150, 0, 150, 300); + gg.drawLine(0, 150, 300, 150); + // Draw points + for (int i = 0; i <= 315; i += 15) { + gg.drawOval(150 - 1, i - 1, 2, 2); + gg.drawOval(i - 1, 150 - 1, 2, 2); + } + gg.setColor(Color.BLUE); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel gLbl; + private javax.swing.JTextField inBox; + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JMenu jMenu1; + private javax.swing.JMenu jMenu2; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JMenuItem jMenuItem1; + private javax.swing.JMenuItem jMenuItem2; + private javax.swing.JMenuItem jMenuItem3; + private javax.swing.JMenuItem jMenuItem6; + private javax.swing.JMenu scaleLbl; + // End of variables declaration//GEN-END:variables +} diff --git a/src/net/apocalypselabs/symat/Help.form b/src/net/apocalypselabs/symat/Help.form new file mode 100644 index 0000000..46d7b95 --- /dev/null +++ b/src/net/apocalypselabs/symat/Help.form @@ -0,0 +1,110 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/net/apocalypselabs/symat/Help.java b/src/net/apocalypselabs/symat/Help.java new file mode 100644 index 0000000..c6f1367 --- /dev/null +++ b/src/net/apocalypselabs/symat/Help.java @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2014 Apocalypse Laboratories. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package net.apocalypselabs.symat; + +import java.io.BufferedReader; +import java.io.InputStreamReader; + +/** + * + * @author Skylar + */ +public class Help extends javax.swing.JInternalFrame { + + /** + * Creates new form Help + */ + public Help() { + initComponents(); + } + + public void loadTopic(String name) { + try { + String text = ""; + BufferedReader reader = new BufferedReader( + new InputStreamReader( + CodeRunner.class + .getResourceAsStream("help/"+name+".html"))); + String line; + while ((line = reader.readLine()) != null) { + text += line; + } + topicBrowser.setText(text); + topicBrowser.setCaretPosition(0); + } catch (Exception e) { + //JOptionPane.showInternalMessageDialog(MainGUI.mainPane, + //"Error: Cannot load help topic "+name+".\n\n"+e.getMessage()); + topicBrowser.setText("

Error:
Cannot get help topic \"" + +name+"\".
("+e.getMessage()+")

"); + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jSplitPane1 = new javax.swing.JSplitPane(); + jScrollPane1 = new javax.swing.JScrollPane(); + topicList = new javax.swing.JList(); + jScrollPane2 = new javax.swing.JScrollPane(); + topicBrowser = new javax.swing.JEditorPane(); + + setClosable(true); + setIconifiable(true); + setMaximizable(true); + setResizable(true); + setTitle("Help"); + setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/help.png"))); // NOI18N + addComponentListener(new java.awt.event.ComponentAdapter() { + public void componentShown(java.awt.event.ComponentEvent evt) { + formComponentShown(evt); + } + }); + + jSplitPane1.setDividerLocation(100); + jSplitPane1.setDividerSize(3); + jSplitPane1.setResizeWeight(0.1); + + topicList.setModel(new javax.swing.AbstractListModel() { + String[] strings = { "Welcome", "Basics", "Editor", "Graphing", "Commands", "Licenses" }; + public int getSize() { return strings.length; } + public Object getElementAt(int i) { return strings[i]; } + }); + topicList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + topicList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + topicListValueChanged(evt); + } + }); + jScrollPane1.setViewportView(topicList); + + jSplitPane1.setLeftComponent(jScrollPane1); + + topicBrowser.setEditable(false); + topicBrowser.setContentType("text/html"); // NOI18N + topicBrowser.setText("\r\n \r\n\r\n \r\n \r\n

\r\n \rHi there\n

\r\n \r\n\r\n"); + jScrollPane2.setViewportView(topicBrowser); + + jSplitPane1.setRightComponent(jScrollPane2); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE) + ); + + pack(); + }//
//GEN-END:initComponents + + private void topicListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_topicListValueChanged + loadTopic(topicList.getSelectedValue().toString().toLowerCase()); + }//GEN-LAST:event_topicListValueChanged + + private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown + loadTopic("welcome"); + }//GEN-LAST:event_formComponentShown + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JSplitPane jSplitPane1; + private javax.swing.JEditorPane topicBrowser; + private javax.swing.JList topicList; + // End of variables declaration//GEN-END:variables +} diff --git a/src/net/apocalypselabs/symat/Interpreter.form b/src/net/apocalypselabs/symat/Interpreter.form new file mode 100644 index 0000000..ef983ad --- /dev/null +++ b/src/net/apocalypselabs/symat/Interpreter.form @@ -0,0 +1,125 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/net/apocalypselabs/symat/Interpreter.java b/src/net/apocalypselabs/symat/Interpreter.java new file mode 100644 index 0000000..94578c9 --- /dev/null +++ b/src/net/apocalypselabs/symat/Interpreter.java @@ -0,0 +1,187 @@ +/* + * Copyright (C) 2014 Apocalypse Laboratories. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package net.apocalypselabs.symat; + +import java.awt.Font; +import javax.swing.JOptionPane; +import javax.swing.text.DefaultCaret; + +/** + * + * @author Skylar + */ +public class Interpreter extends javax.swing.JInternalFrame { + + private final CodeRunner cr = new CodeRunner(); + /** + * Creates new form Interpreter + */ + public Interpreter() { + initComponents(); + int font_size = 12; + try { + font_size = Integer.valueOf(PrefStorage.getSetting("shell-fontsize")); + } catch (Exception ex) { } + jTextArea1.setFont(new Font(Font.MONOSPACED, Font.PLAIN, font_size)); + jTextArea1.setLineWrap(true); + jTextArea1.setWrapStyleWord(true); + jTextArea1.setText(">>"); + jTextField1.requestFocus(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + jTextArea1 = new javax.swing.JTextArea(); + jTextField1 = new javax.swing.JTextField(); + jButton1 = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + jMenuBar1 = new javax.swing.JMenuBar(); + jMenu2 = new javax.swing.JMenu(); + jMenuItem1 = new javax.swing.JMenuItem(); + + setClosable(true); + setIconifiable(true); + setMaximizable(true); + setResizable(true); + setTitle("Shell"); + setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/shell.png"))); // NOI18N + + jTextArea1.setEditable(false); + jTextArea1.setColumns(20); + jTextArea1.setFont(new java.awt.Font("Courier New", 0, 15)); // NOI18N + jTextArea1.setRows(5); + jTextArea1.setTabSize(4); + DefaultCaret caret = (DefaultCaret)jTextArea1.getCaret(); + caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); + jScrollPane1.setViewportView(jTextArea1); + + jTextField1.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { + jTextField1KeyTyped(evt); + } + }); + + jButton1.setText("Run"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setText(">>"); + + jMenu2.setText("Edit"); + + jMenuItem1.setText("Font size..."); + jMenuItem1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem1ActionPerformed(evt); + } + }); + jMenu2.add(jMenuItem1); + + jMenuBar1.add(jMenu2); + + setJMenuBar(jMenuBar1); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTextField1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING))) + .addGap(2, 2, 2)) + ); + + pack(); + }// //GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + doRunCode(); + }//GEN-LAST:event_jButton1ActionPerformed + + private void jTextField1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyTyped + if (evt.getKeyChar() == '\n') { + doRunCode(); + } + }//GEN-LAST:event_jTextField1KeyTyped + + private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed + try { + int size = Integer.parseInt(JOptionPane.showInternalInputDialog(this, + "New font size (8-36):", + "Font Size", + JOptionPane.QUESTION_MESSAGE)); + if (size >= 8 && size <= 36) { + jTextArea1.setFont(new Font(Font.MONOSPACED, Font.PLAIN, size)); + PrefStorage.saveSetting("shell-fontsize", size+""); + } + } catch (Exception ex) { + + } + }//GEN-LAST:event_jMenuItem1ActionPerformed + + private void doRunCode() { + String code = jTextField1.getText(); + jTextArea1.append(" "+code+"\n"); + try { + jTextArea1.append(cr.evalString(code).toString()+"\n"); + } catch (NullPointerException ex) { + + } + jTextArea1.append(">>"); + jTextField1.setText(""); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JMenu jMenu2; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JMenuItem jMenuItem1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea jTextArea1; + private javax.swing.JTextField jTextField1; + // End of variables declaration//GEN-END:variables +} diff --git a/src/net/apocalypselabs/symat/MainGUI.form b/src/net/apocalypselabs/symat/MainGUI.form new file mode 100644 index 0000000..72588f4 --- /dev/null +++ b/src/net/apocalypselabs/symat/MainGUI.form @@ -0,0 +1,169 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/net/apocalypselabs/symat/MainGUI.java b/src/net/apocalypselabs/symat/MainGUI.java new file mode 100644 index 0000000..5d60076 --- /dev/null +++ b/src/net/apocalypselabs/symat/MainGUI.java @@ -0,0 +1,261 @@ +/* + * Copyright (C) 2014 Apocalypse Laboratories. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package net.apocalypselabs.symat; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import javax.swing.ImageIcon; +import javax.swing.JInternalFrame; + +/** + * + * @author Skylar + */ +public class MainGUI extends javax.swing.JFrame { + + public static final String APP_NAME = "SyMAT 0.5"; + public static final double APP_CODE = 0.5; + + /** + * Creates new form MainGUI + */ + public MainGUI() { + initComponents(); + setIconImage((new ImageIcon(getClass().getResource("icon.png"))).getImage()); + setLocationRelativeTo(null); + try { + URL url = new URL("http://symat.aplabs.us/version.txt"); + InputStream is = url.openStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + + String line = br.readLine(); + br.close(); + is.close(); + double version = Double.parseDouble(line); + if (version > APP_CODE) { + if (PrefStorage.getSetting("update-ignore").equals(APP_CODE+"|"+version)) { + System.err.println("An update was found, but has been ignored by the user."); + } else { + loadFrame(new Update(version)); + } + } + } catch (IOException | NumberFormatException e) { + System.err.println("Fail: Cannot check update server. \n" + + " Assuming local copy up-to-date."); + } + Interpreter sh = new Interpreter(); + loadFrame(sh); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + mainPane = new javax.swing.JDesktopPane(); + jToolBar1 = new javax.swing.JToolBar(); + shellBtn = new javax.swing.JButton(); + editorBtn = new javax.swing.JButton(); + graphBtn = new javax.swing.JButton(); + helpBtn = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle(APP_NAME); + addComponentListener(new java.awt.event.ComponentAdapter() { + public void componentShown(java.awt.event.ComponentEvent evt) { + formComponentShown(evt); + } + }); + + mainPane.setBackground(new java.awt.Color(204, 204, 204)); + + javax.swing.GroupLayout mainPaneLayout = new javax.swing.GroupLayout(mainPane); + mainPane.setLayout(mainPaneLayout); + mainPaneLayout.setHorizontalGroup( + mainPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 690, Short.MAX_VALUE) + ); + mainPaneLayout.setVerticalGroup( + mainPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 416, Short.MAX_VALUE) + ); + + jToolBar1.setFloatable(false); + jToolBar1.setRollover(true); + + shellBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/shell.png"))); // NOI18N + shellBtn.setText("Shell"); + shellBtn.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); + shellBtn.setFocusable(false); + shellBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + shellBtn.setOpaque(false); + shellBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + shellBtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + shellBtnActionPerformed(evt); + } + }); + jToolBar1.add(shellBtn); + + editorBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/editor.png"))); // NOI18N + editorBtn.setText("Editor"); + editorBtn.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); + editorBtn.setFocusable(false); + editorBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + editorBtn.setOpaque(false); + editorBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + editorBtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + editorBtnActionPerformed(evt); + } + }); + jToolBar1.add(editorBtn); + + graphBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/graph.png"))); // NOI18N + graphBtn.setText("Graph"); + graphBtn.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); + graphBtn.setFocusable(false); + graphBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + graphBtn.setOpaque(false); + graphBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + graphBtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + graphBtnActionPerformed(evt); + } + }); + jToolBar1.add(graphBtn); + + helpBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/help.png"))); // NOI18N + helpBtn.setText("Help"); + helpBtn.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); + helpBtn.setFocusable(false); + helpBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + helpBtn.setOpaque(false); + helpBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + helpBtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + helpBtnActionPerformed(evt); + } + }); + jToolBar1.add(helpBtn); + + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel1.setText("        "+APP_NAME+""); + jToolBar1.add(jLabel1); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(mainPane) + .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(mainPane)) + ); + + pack(); + }// //GEN-END:initComponents + + private void shellBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shellBtnActionPerformed + Interpreter i = new Interpreter(); + loadFrame(i); + }//GEN-LAST:event_shellBtnActionPerformed + + private void editorBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editorBtnActionPerformed + CodeEditor e = new CodeEditor(); + loadFrame(e); + }//GEN-LAST:event_editorBtnActionPerformed + + private void graphBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_graphBtnActionPerformed + Graph g = new Graph(); + loadFrame(g); + }//GEN-LAST:event_graphBtnActionPerformed + + private void helpBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpBtnActionPerformed + Help h = new Help(); + loadFrame(h); + }//GEN-LAST:event_helpBtnActionPerformed + + private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown + setLocationRelativeTo(null); + }//GEN-LAST:event_formComponentShown + + public static void loadFrame(JInternalFrame frame) { + mainPane.add(frame); + frame.setLocation( + (mainPane.getWidth() / 2) - (frame.getWidth() / 2), + (mainPane.getHeight() / 2) - (frame.getHeight() / 2)); + frame.setVisible(true); + } + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(MainGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + new MainGUI().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton editorBtn; + private javax.swing.JButton graphBtn; + private javax.swing.JButton helpBtn; + private javax.swing.JLabel jLabel1; + private javax.swing.JToolBar jToolBar1; + public static javax.swing.JDesktopPane mainPane; + private javax.swing.JButton shellBtn; + // End of variables declaration//GEN-END:variables +} diff --git a/src/net/apocalypselabs/symat/PrefStorage.java b/src/net/apocalypselabs/symat/PrefStorage.java new file mode 100644 index 0000000..ced91f0 --- /dev/null +++ b/src/net/apocalypselabs/symat/PrefStorage.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2014 Skylar. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package net.apocalypselabs.symat; + +import java.util.prefs.Preferences; + +/** + * + * @author Skylar Ittner + */ +public class PrefStorage { + + private static Preferences prefs = Preferences.userNodeForPackage(PrefStorage.class); + + public static void saveSetting(String key, String value) { + prefs.put(key, value); + } + + public static String getSetting(String key) { + return prefs.get(key, ""); + } + + public static String getSetting(String key, String emptyResponse) { + return prefs.get(key, emptyResponse); + } +} diff --git a/src/net/apocalypselabs/symat/PrettifyToHtml.java b/src/net/apocalypselabs/symat/PrettifyToHtml.java new file mode 100644 index 0000000..a6aff23 --- /dev/null +++ b/src/net/apocalypselabs/symat/PrettifyToHtml.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright 2013 Jeremie Bresson + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ +package net.apocalypselabs.symat; // Package name changed. + +import java.awt.Color; +import java.util.List; +import java.util.Map.Entry; +import syntaxhighlight.ParseResult; +import syntaxhighlight.Style; +import syntaxhighlight.Theme; + +public class PrettifyToHtml { + private static final String MAIN_CLASS = "prettyprint"; + + /** + * Format the {@link ParseResult} into an HTML file. + * @param content + * @param parseResults + * @return + */ + public static String toHtml(String content, List parseResults) { + int endIndex = 0; + StringBuilder sb = new StringBuilder(); + sb.append("
"); + sb.append("
");
+		for (ParseResult pr : parseResults) {
+			int startIndex = pr.getOffset();
+			if(startIndex > endIndex) {
+				sb.append(content.substring(endIndex, startIndex));
+			}
+			endIndex = startIndex + pr.getLength();
+			sb.append("");
+			sb.append(content.substring(startIndex, endIndex));
+			sb.append("");
+		}
+		if(content.length() > endIndex) {
+			sb.append(content.substring(endIndex, content.length()));				
+		}
+		sb.append("
"); + sb.append("
"); + return sb.toString(); + } + + public static String toCss(Theme theme) { + StringBuilder sb = new StringBuilder(); + sb.append("." + MAIN_CLASS + " {"); + sb.append("font-family:monospace; "); + appendCssColor(sb, "background-color", theme.getBackground()); + sb.append("}\n"); + for (Entry entry : theme.getStyles().entrySet()) { + sb.append("." + MAIN_CLASS + " ."+entry.getKey()+" {"); + Style style = entry.getValue(); + appendCssColor(sb, "background-color", style.getBackground()); + appendCssColor(sb, "color", style.getColor()); + appendCssText(sb, "font-weight: bold", style.isBold()); + appendCssText(sb, "font-style: italic", style.isItalic()); + appendCssText(sb, "text-decoration: underline", style.isUnderline()); + sb.append("}\n"); + } + theme.getStyles(); + return sb.toString(); + } + + private static void appendCssColor(StringBuilder sb, String cssKey, Color color) { + if(color != null) { + sb.append(cssKey +": "+ encode(color) + "; "); + } + } + + private final static String encode(Color color) { + String s = Integer.toHexString(color.getRGB() & 0xffffff); + if (s.length() < 6) { + s = "000000".substring(0, 6 - s.length()) + s; + } + return '#' + s; + } + + private static void appendCssText(StringBuilder sb, String cssProp, boolean isSet) { + if(isSet) { + sb.append(cssProp + "; "); + } + } +} diff --git a/src/net/apocalypselabs/symat/TextLineNumber.java b/src/net/apocalypselabs/symat/TextLineNumber.java new file mode 100644 index 0000000..bc698c2 --- /dev/null +++ b/src/net/apocalypselabs/symat/TextLineNumber.java @@ -0,0 +1,435 @@ +/* + * Copyright (C) 2014 Apocalypse Laboratories. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package net.apocalypselabs.symat; + +import java.awt.*; +import java.beans.*; +import java.util.HashMap; +import javax.swing.*; +import javax.swing.border.*; +import javax.swing.event.*; +import javax.swing.text.*; + +/** + * This class will display line numbers for a related text component. The text + * component must use the same line height for each line. TextLineNumber + * supports wrapped lines and will highlight the line number of the current line + * in the text component. + * + * This class was designed to be used as a component added to the row header of + * a JScrollPane. + */ +public class TextLineNumber extends JPanel + implements CaretListener, DocumentListener, PropertyChangeListener { + + public final static float LEFT = 0.0f; + public final static float CENTER = 0.5f; + public final static float RIGHT = 1.0f; + + private final static Border OUTER = new MatteBorder(0, 0, 0, 2, Color.GRAY); + + private final static int HEIGHT = Integer.MAX_VALUE - 1000000; + + // Text component this TextTextLineNumber component is in sync with + private JTextComponent component; + + // Properties that can be changed + private boolean updateFont; + private int borderGap; + private Color currentLineForeground; + private float digitAlignment; + private int minimumDisplayDigits; + + // Keep history information to reduce the number of times the component + // needs to be repainted + private int lastDigits; + private int lastHeight; + private int lastLine; + + private HashMap fonts; + + /** + * Create a line number component for a text component. This minimum display + * width will be based on 3 digits. + * + * @param component the related text component + */ + public TextLineNumber(JTextComponent component) { + this(component, 3); + } + + /** + * Create a line number component for a text component. + * + * @param component the related text component + * @param minimumDisplayDigits the number of digits used to calculate the + * minimum width of the component + */ + public TextLineNumber(JTextComponent component, int minimumDisplayDigits) { + this.component = component; + + setFont(component.getFont()); + + setBorderGap(5); + setCurrentLineForeground(Color.RED); + setDigitAlignment(RIGHT); + setMinimumDisplayDigits(minimumDisplayDigits); + + component.getDocument().addDocumentListener(this); + component.addCaretListener(this); + component.addPropertyChangeListener("font", this); + } + + /** + * Gets the update font property + * + * @return the update font property + */ + public boolean getUpdateFont() { + return updateFont; + } + + /** + * Set the update font property. Indicates whether this Font should be + * updated automatically when the Font of the related text component is + * changed. + * + * @param updateFont when true update the Font and repaint the line numbers, + * otherwise just repaint the line numbers. + */ + public void setUpdateFont(boolean updateFont) { + this.updateFont = updateFont; + } + + /** + * Gets the border gap + * + * @return the border gap in pixels + */ + public int getBorderGap() { + return borderGap; + } + + /** + * The border gap is used in calculating the left and right insets of the + * border. Default value is 5. + * + * @param borderGap the gap in pixels + */ + public void setBorderGap(int borderGap) { + this.borderGap = borderGap; + Border inner = new EmptyBorder(0, borderGap, 0, borderGap); + setBorder(new CompoundBorder(OUTER, inner)); + lastDigits = 0; + setPreferredWidth(); + } + + /** + * Gets the current line rendering Color + * + * @return the Color used to render the current line number + */ + public Color getCurrentLineForeground() { + return currentLineForeground == null ? getForeground() : currentLineForeground; + } + + /** + * The Color used to render the current line digits. Default is Coolor.RED. + * + * @param currentLineForeground the Color used to render the current line + */ + public void setCurrentLineForeground(Color currentLineForeground) { + this.currentLineForeground = currentLineForeground; + } + + /** + * Gets the digit alignment + * + * @return the alignment of the painted digits + */ + public float getDigitAlignment() { + return digitAlignment; + } + + /** + * Specify the horizontal alignment of the digits within the component. + * Common values would be: + *
    + *
  • TextLineNumber.LEFT + *
  • TextLineNumber.CENTER + *
  • TextLineNumber.RIGHT (default) + *
+ * + * @param currentLineForeground the Color used to render the current line + */ + public void setDigitAlignment(float digitAlignment) { + this.digitAlignment + = digitAlignment > 1.0f ? 1.0f : digitAlignment < 0.0f ? -1.0f : digitAlignment; + } + + /** + * Gets the minimum display digits + * + * @return the minimum display digits + */ + public int getMinimumDisplayDigits() { + return minimumDisplayDigits; + } + + /** + * Specify the mimimum number of digits used to calculate the preferred + * width of the component. Default is 3. + * + * @param minimumDisplayDigits the number digits used in the preferred width + * calculation + */ + public void setMinimumDisplayDigits(int minimumDisplayDigits) { + this.minimumDisplayDigits = minimumDisplayDigits; + setPreferredWidth(); + } + + /** + * Calculate the width needed to display the maximum line number + */ + private void setPreferredWidth() { + Element root = component.getDocument().getDefaultRootElement(); + int lines = root.getElementCount(); + int digits = Math.max(String.valueOf(lines).length(), minimumDisplayDigits); + + // Update sizes when number of digits in the line number changes + if (lastDigits != digits) { + lastDigits = digits; + FontMetrics fontMetrics = getFontMetrics(getFont()); + int width = fontMetrics.charWidth('0') * digits; + Insets insets = getInsets(); + int preferredWidth = insets.left + insets.right + width; + + Dimension d = getPreferredSize(); + d.setSize(preferredWidth, HEIGHT); + setPreferredSize(d); + setSize(d); + } + } + + /** + * Draw the line numbers + */ + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + + // Determine the width of the space available to draw the line number + FontMetrics fontMetrics = component.getFontMetrics(component.getFont()); + Insets insets = getInsets(); + int availableWidth = getSize().width - insets.left - insets.right; + + // Determine the rows to draw within the clipped bounds. + Rectangle clip = g.getClipBounds(); + int rowStartOffset = component.viewToModel(new Point(0, clip.y)); + int endOffset = component.viewToModel(new Point(0, clip.y + clip.height)); + + while (rowStartOffset <= endOffset) { + try { + if (isCurrentLine(rowStartOffset)) { + g.setColor(getCurrentLineForeground()); + } else { + g.setColor(getForeground()); + } + + // Get the line number as a string and then determine the + // "X" and "Y" offsets for drawing the string. + String lineNumber = getTextLineNumber(rowStartOffset); + int stringWidth = fontMetrics.stringWidth(lineNumber); + int x = getOffsetX(availableWidth, stringWidth) + insets.left; + int y = getOffsetY(rowStartOffset, fontMetrics); + g.drawString(lineNumber, x, y); + + // Move to the next row + rowStartOffset = Utilities.getRowEnd(component, rowStartOffset) + 1; + } catch (Exception e) { + break; + } + } + } + + /* + * We need to know if the caret is currently positioned on the line we + * are about to paint so the line number can be highlighted. + */ + private boolean isCurrentLine(int rowStartOffset) { + int caretPosition = component.getCaretPosition(); + Element root = component.getDocument().getDefaultRootElement(); + + if (root.getElementIndex(rowStartOffset) == root.getElementIndex(caretPosition)) { + return true; + } else { + return false; + } + } + + /* + * Get the line number to be drawn. The empty string will be returned + * when a line of text has wrapped. + */ + protected String getTextLineNumber(int rowStartOffset) { + Element root = component.getDocument().getDefaultRootElement(); + int index = root.getElementIndex(rowStartOffset); + Element line = root.getElement(index); + + if (line.getStartOffset() == rowStartOffset) { + return String.valueOf(index + 1); + } else { + return ""; + } + } + + /* + * Determine the X offset to properly align the line number when drawn + */ + private int getOffsetX(int availableWidth, int stringWidth) { + return (int) ((availableWidth - stringWidth) * digitAlignment); + } + + /* + * Determine the Y offset for the current row + */ + private int getOffsetY(int rowStartOffset, FontMetrics fontMetrics) + throws BadLocationException { + // Get the bounding rectangle of the row + + Rectangle r = component.modelToView(rowStartOffset); + int lineHeight = fontMetrics.getHeight(); + int y = r.y + r.height; + int descent = 0; + + // The text needs to be positioned above the bottom of the bounding + // rectangle based on the descent of the font(s) contained on the row. + if (r.height == lineHeight) // default font is being used + { + descent = fontMetrics.getDescent(); + } else // We need to check all the attributes for font changes + { + if (fonts == null) { + fonts = new HashMap(); + } + + Element root = component.getDocument().getDefaultRootElement(); + int index = root.getElementIndex(rowStartOffset); + Element line = root.getElement(index); + + for (int i = 0; i < line.getElementCount(); i++) { + Element child = line.getElement(i); + AttributeSet as = child.getAttributes(); + String fontFamily = (String) as.getAttribute(StyleConstants.FontFamily); + Integer fontSize = (Integer) as.getAttribute(StyleConstants.FontSize); + String key = fontFamily + fontSize; + + FontMetrics fm = fonts.get(key); + + if (fm == null) { + Font font = new Font(fontFamily, Font.PLAIN, fontSize); + fm = component.getFontMetrics(font); + fonts.put(key, fm); + } + + descent = Math.max(descent, fm.getDescent()); + } + } + + return y - descent; + } + +// +// Implement CaretListener interface +// + @Override + public void caretUpdate(CaretEvent e) { + // Get the line the caret is positioned on + + int caretPosition = component.getCaretPosition(); + Element root = component.getDocument().getDefaultRootElement(); + int currentLine = root.getElementIndex(caretPosition); + + // Need to repaint so the correct line number can be highlighted + if (lastLine != currentLine) { + repaint(); + lastLine = currentLine; + } + } + +// +// Implement DocumentListener interface +// + @Override + public void changedUpdate(DocumentEvent e) { + documentChanged(); + } + + @Override + public void insertUpdate(DocumentEvent e) { + documentChanged(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + documentChanged(); + } + + /* + * A document change may affect the number of displayed lines of text. + * Therefore the lines numbers will also change. + */ + private void documentChanged() { + // View of the component has not been updated at the time + // the DocumentEvent is fired + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + int endPos = component.getDocument().getLength(); + Rectangle rect = component.modelToView(endPos); + + if (rect != null && rect.y != lastHeight) { + setPreferredWidth(); + repaint(); + lastHeight = rect.y; + } + } catch (BadLocationException ex) { /* nothing to do */ } + } + }); + } + +// +// Implement PropertyChangeListener interface +// + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() instanceof Font) { + if (updateFont) { + Font newFont = (Font) evt.getNewValue(); + setFont(newFont); + lastDigits = 0; + setPreferredWidth(); + } else { + repaint(); + } + } + } +} diff --git a/src/net/apocalypselabs/symat/Update.form b/src/net/apocalypselabs/symat/Update.form new file mode 100644 index 0000000..e78c929 --- /dev/null +++ b/src/net/apocalypselabs/symat/Update.form @@ -0,0 +1,137 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/net/apocalypselabs/symat/Update.java b/src/net/apocalypselabs/symat/Update.java new file mode 100644 index 0000000..586f806 --- /dev/null +++ b/src/net/apocalypselabs/symat/Update.java @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2014 Skylar. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package net.apocalypselabs.symat; + +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import javax.swing.JOptionPane; + +/** + * + * @author Skylar + */ +public class Update extends javax.swing.JInternalFrame { + + private final double latestVersion; + + /** + * Creates new form Update + * @param latest The new version. + */ + public Update(double latest) { + latestVersion = latest; + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); + jLabel5 = new javax.swing.JLabel(); + + setBackground(new java.awt.Color(255, 255, 255)); + setClosable(true); + setTitle("Update SyMAT"); + setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/update.png"))); // NOI18N + setLayer(100); + + jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setText("An update is available."); + + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icon.png"))); // NOI18N + + jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel3.setText("Latest version: "+String.valueOf(latestVersion)); + + jLabel4.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel4.setText("Your version: "+String.valueOf(MainGUI.APP_CODE)); + + jButton1.setBackground(new java.awt.Color(51, 153, 255)); + jButton1.setFont(new java.awt.Font("Tahoma", 3, 18)); // NOI18N + jButton1.setText("Download"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + jLabel5.setText("Ignore"); + jLabel5.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel5MouseClicked(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 50, Short.MAX_VALUE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(99, 99, 99) + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(65, 65, 65) + .addComponent(jLabel5)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE) + .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE) + .addContainerGap()) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jLabel5)))) + ); + + pack(); + }// //GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + if (Desktop.isDesktopSupported()) { + try { + Desktop.getDesktop().browse(new URI("http://symat.aplabs.us/")); + } catch (IOException | URISyntaxException ex) { + JOptionPane.showInternalMessageDialog(this, "Cannot open browser. Please go to symat.aplabs.us."); + } + } else { + JOptionPane.showInternalMessageDialog(this, "Cannot open browser. Please go to symat.aplabs.us."); + } + }//GEN-LAST:event_jButton1ActionPerformed + + private void jLabel5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel5MouseClicked + PrefStorage.saveSetting("update-ignore", MainGUI.APP_CODE+"|"+latestVersion); + dispose(); + }//GEN-LAST:event_jLabel5MouseClicked + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + // End of variables declaration//GEN-END:variables +} diff --git a/src/net/apocalypselabs/symat/editor.png b/src/net/apocalypselabs/symat/editor.png new file mode 100644 index 0000000..8cc1900 Binary files /dev/null and b/src/net/apocalypselabs/symat/editor.png differ diff --git a/src/net/apocalypselabs/symat/functions.js b/src/net/apocalypselabs/symat/functions.js new file mode 100644 index 0000000..e69de29 diff --git a/src/net/apocalypselabs/symat/graph.png b/src/net/apocalypselabs/symat/graph.png new file mode 100644 index 0000000..cd01708 Binary files /dev/null and b/src/net/apocalypselabs/symat/graph.png differ diff --git a/src/net/apocalypselabs/symat/help.png b/src/net/apocalypselabs/symat/help.png new file mode 100644 index 0000000..6ed6bbe Binary files /dev/null and b/src/net/apocalypselabs/symat/help.png differ diff --git a/src/net/apocalypselabs/symat/help/basics.html b/src/net/apocalypselabs/symat/help/basics.html new file mode 100644 index 0000000..c571d04 --- /dev/null +++ b/src/net/apocalypselabs/symat/help/basics.html @@ -0,0 +1,12 @@ + + + Basics + + +

Getting Started

+

Open a new shell by clicking the button. +
Try typing commands, like "2*2" or "sin[.5]". +
You can make variables too, try "x=.5" then "sin[x]". +

Fun fact: You can use the Enter key OR the run button to run the command!

+ + diff --git a/src/net/apocalypselabs/symat/help/commands.html b/src/net/apocalypselabs/symat/help/commands.html new file mode 100644 index 0000000..9446dfc --- /dev/null +++ b/src/net/apocalypselabs/symat/help/commands.html @@ -0,0 +1,30 @@ + + + Commands + + +

Command Reference

+

+ notify(var) Creates a popup box with the given content. +
ask(prompt) Returns the entered text. +
d("3*x", "x") Returns the derivative of the function with respect to the second argument. +
sym("command") Parses the given text with the Symja library. +
replace("text", "find", "replace") Returns "text" with all occurrences of "find" changed to "replace". +
subs("function", "var", "replace") Replaces all occurrences of "var" with "replace" and solves. + Returns the answer or 0.0 if there is no numerical answer. +
plot("function") Graphs the given function as if it were typed into a graph window. + Uses the graph window bound to the current action. +
   Aliases: ezplot, graph +
plotname("name") Set the window title of the bound graph window. +
plotname() Get the name of the plot window. +
plotclr() Clears all drawings from the plot window. +
   Aliases: clearplot, plotclear +
plotscale({-1,0,1,2,3}) Scale the graph. Erases content when scaled. + Smaller is farther out, larger closer. +
drawDot(x,y) Draw a small red dot wherever you tell it. +
+
+
+

+ + diff --git a/src/net/apocalypselabs/symat/help/editor.html b/src/net/apocalypselabs/symat/help/editor.html new file mode 100644 index 0000000..96c4e42 --- /dev/null +++ b/src/net/apocalypselabs/symat/help/editor.html @@ -0,0 +1,12 @@ + + + Editor + + +

Code Editor

+

You can write code here. This code will be run all at once. +
You can even open and save code files. +
Press F5 to run your script. + Whatever it spits out will appear in the Output box.

+ + diff --git a/src/net/apocalypselabs/symat/help/graphing.html b/src/net/apocalypselabs/symat/help/graphing.html new file mode 100644 index 0000000..7f196e2 --- /dev/null +++ b/src/net/apocalypselabs/symat/help/graphing.html @@ -0,0 +1,14 @@ + + + Graphing + + +

Graphing

+

You can open a graph window with its button. + You can also start it with s function to graph with + the command plot("sin[x]") or whatever.

+

Pretty much, if you want to graph "y=32*x", enter "32*x".

+

Protip: You can save your cool graphs as a + picture without using a camera, check it out!

+ + diff --git a/src/net/apocalypselabs/symat/help/licenses.html b/src/net/apocalypselabs/symat/help/licenses.html new file mode 100644 index 0000000..10e36b8 --- /dev/null +++ b/src/net/apocalypselabs/symat/help/licenses.html @@ -0,0 +1,898 @@ + + + Licenses + + +

Licenses

+

This application uses libraries from third-parties.

+

Symja (parser), log4j, Java-Prettify:

+
Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ +

HtmlCleaner

+
Copyright (c) 2006-2014, HtmlCleaner team.
+    All rights reserved.
+    Redistribution and use of this software in source and binary forms, 
+    with or without modification, are permitted provided that the 
+    following conditions are met:
+    
+    * Redistributions of source code must retain the above
+      copyright notice, this list of conditions and the
+      following disclaimer.
+    
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the
+      following disclaimer in the documentation and/or other
+      materials provided with the distribution.
+    
+    * The name of HtmlCleaner may not be used to endorse or promote
+      products derived from this software without specific prior
+      written permission.
+    
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+        
+ +

iTextPDF, Symja (core):

+
                   GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. (http://fsf.org/)
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+  This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+  0. Additional Definitions.
+
+  As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+  "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+  An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+  A "Combined Work" is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+  The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+  The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+  1. Exception to Section 3 of the GNU GPL.
+
+  You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+  2. Conveying Modified Versions.
+
+  If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+   a) under this License, provided that you make a good faith effort to
+   ensure that, in the event an Application does not supply the
+   function or data, the facility still operates, and performs
+   whatever part of its purpose remains meaningful, or
+
+   b) under the GNU GPL, with none of the additional permissions of
+   this License applicable to that copy.
+
+  3. Object Code Incorporating Material from Library Header Files.
+
+  The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+   a) Give prominent notice with each copy of the object code that the
+   Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the object code with a copy of the GNU GPL and this license
+   document.
+
+  4. Combined Works.
+
+  You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+   a) Give prominent notice with each copy of the Combined Work that
+   the Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
+   document.
+
+   c) For a Combined Work that displays copyright notices during
+   execution, include the copyright notice for the Library among
+   these notices, as well as a reference directing the user to the
+   copies of the GNU GPL and this license document.
+
+   d) Do one of the following:
+
+       0) Convey the Minimal Corresponding Source under the terms of this
+       License, and the Corresponding Application Code in a form
+       suitable for, and under terms that permit, the user to
+       recombine or relink the Application with a modified version of
+       the Linked Version to produce a modified Combined Work, in the
+       manner specified by section 6 of the GNU GPL for conveying
+       Corresponding Source.
+
+       1) Use a suitable shared library mechanism for linking with the
+       Library.  A suitable mechanism is one that (a) uses at run time
+       a copy of the Library already present on the user's computer
+       system, and (b) will operate properly with a modified version
+       of the Library that is interface-compatible with the Linked
+       Version.
+
+   e) Provide Installation Information, but only if you would otherwise
+   be required to provide such information under section 6 of the
+   GNU GPL, and only to the extent that such information is
+   necessary to install and execute a modified version of the
+   Combined Work produced by recombining or relinking the
+   Application with a modified version of the Linked Version. (If
+   you use option 4d0, the Installation Information must accompany
+   the Minimal Corresponding Source and Corresponding Application
+   Code. If you use option 4d1, you must provide the Installation
+   Information in the manner specified by section 6 of the GNU GPL
+   for conveying Corresponding Source.)
+
+  5. Combined Libraries.
+
+  You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+   a) Accompany the combined library with a copy of the same work based
+   on the Library, uncombined with any other library facilities,
+   conveyed under the terms of this License.
+
+   b) Give prominent notice with the combined library that part of it
+   is a work based on the Library, and explaining where to find the
+   accompanying uncombined form of the same work.
+
+  6. Revised Versions of the GNU Lesser General Public License.
+
+  The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+  Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+  If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+        
+


+
                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. 
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    
+    Copyright (C)   
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+      Copyright (C)   
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+.
+
+ + diff --git a/src/net/apocalypselabs/symat/help/welcome.html b/src/net/apocalypselabs/symat/help/welcome.html new file mode 100644 index 0000000..a468f9a --- /dev/null +++ b/src/net/apocalypselabs/symat/help/welcome.html @@ -0,0 +1,12 @@ + + + Welcome! + + +

Welcome to SyMAT!

+

SyMAT is a Java-based algebra and calculus system. + Scripts and commands are in JavaScript.

+

License:
+ SyMAT is licensed under the GNU Lesser General Public License.

+ + diff --git a/src/net/apocalypselabs/symat/icon.png b/src/net/apocalypselabs/symat/icon.png new file mode 100644 index 0000000..62a0b46 Binary files /dev/null and b/src/net/apocalypselabs/symat/icon.png differ diff --git a/src/net/apocalypselabs/symat/icons/editor.png b/src/net/apocalypselabs/symat/icons/editor.png new file mode 100644 index 0000000..e127ddb Binary files /dev/null and b/src/net/apocalypselabs/symat/icons/editor.png differ diff --git a/src/net/apocalypselabs/symat/icons/graph.png b/src/net/apocalypselabs/symat/icons/graph.png new file mode 100644 index 0000000..8b87c51 Binary files /dev/null and b/src/net/apocalypselabs/symat/icons/graph.png differ diff --git a/src/net/apocalypselabs/symat/icons/help.png b/src/net/apocalypselabs/symat/icons/help.png new file mode 100644 index 0000000..fb75708 Binary files /dev/null and b/src/net/apocalypselabs/symat/icons/help.png differ diff --git a/src/net/apocalypselabs/symat/icons/shell.png b/src/net/apocalypselabs/symat/icons/shell.png new file mode 100644 index 0000000..c6a6542 Binary files /dev/null and b/src/net/apocalypselabs/symat/icons/shell.png differ diff --git a/src/net/apocalypselabs/symat/icons/update.png b/src/net/apocalypselabs/symat/icons/update.png new file mode 100644 index 0000000..b38fc68 Binary files /dev/null and b/src/net/apocalypselabs/symat/icons/update.png differ diff --git a/src/net/apocalypselabs/symat/menugradient.png b/src/net/apocalypselabs/symat/menugradient.png new file mode 100644 index 0000000..c7dea7e Binary files /dev/null and b/src/net/apocalypselabs/symat/menugradient.png differ diff --git a/src/net/apocalypselabs/symat/pretty.css b/src/net/apocalypselabs/symat/pretty.css new file mode 100644 index 0000000..dc9cee2 --- /dev/null +++ b/src/net/apocalypselabs/symat/pretty.css @@ -0,0 +1,23 @@ +.header { + +} +.com { + color: green; +} + +.kwd { + color: blue; +} + +.pln { + color: black; +} + +.lit { + color: #0099cc; +} + +.pun { + color: black; + font-weight: bold; +} \ No newline at end of file diff --git a/src/net/apocalypselabs/symat/shell.png b/src/net/apocalypselabs/symat/shell.png new file mode 100644 index 0000000..161cbc0 Binary files /dev/null and b/src/net/apocalypselabs/symat/shell.png differ