Browse Source

Re-init Git, minor tweaks

tags/2.1
Skylar 4 years ago
commit
abe9ec5959
100 changed files with 17292 additions and 0 deletions
  1. 6
    0
      .gitignore
  2. 58
    0
      LICENSE
  3. 18
    0
      README.md
  4. 121
    0
      build.xml
  5. BIN
      lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
  6. BIN
      lib/JavaPrettify-1.2.1.jar
  7. BIN
      lib/absolutelayout/AbsoluteLayout.jar
  8. BIN
      lib/autocomplete-2.5.4.jar
  9. BIN
      lib/beautyeye_lnf.jar
  10. BIN
      lib/commons-codec-1.9.jar
  11. BIN
      lib/commons-logging-1.2.jar
  12. BIN
      lib/flamingo-6.3-javadoc.jar
  13. BIN
      lib/flamingo-6.3.jar
  14. BIN
      lib/fluent-hc-4.5.jar
  15. BIN
      lib/htmlcleaner-2.10.jar
  16. BIN
      lib/httpclient-4.5.jar
  17. BIN
      lib/httpclient-cache-4.5.jar
  18. BIN
      lib/httpclient-win-4.5.jar
  19. BIN
      lib/httpcore-4.4.1.jar
  20. BIN
      lib/httpmime-4.5.jar
  21. BIN
      lib/iText-4.2.0-com.itextpdf.jar
  22. BIN
      lib/jmathplot.jar
  23. BIN
      lib/jna-4.1.0.jar
  24. BIN
      lib/jna-platform-4.1.0.jar
  25. BIN
      lib/js-engine.jar
  26. BIN
      lib/js.jar
  27. BIN
      lib/json-simple-1.1.1.jar
  28. BIN
      lib/jython-standalone-2.7-b3.jar
  29. BIN
      lib/jython-standalone-2.7.0.jar
  30. BIN
      lib/log4j-1.2.11.jar
  31. 89
    0
      lib/nblibraries.properties
  32. BIN
      lib/org-netbeans-api-visual.jar
  33. BIN
      lib/org-openide-util.jar
  34. BIN
      lib/rsyntaxtextarea-2.5.6.jar
  35. BIN
      lib/seaglasslookandfeel-0.2.jar
  36. BIN
      lib/symja-2014-11-01.jar
  37. BIN
      lib/trident-6.3.jar
  38. BIN
      lib/ujmp-complete-0.2.5-javadoc.zip
  39. BIN
      lib/ujmp-complete-0.2.5.jar
  40. 3
    0
      manifest.mf
  41. 1421
    0
      nbproject/build-impl.xml
  42. 8
    0
      nbproject/genfiles.properties
  43. 59
    0
      nbproject/licenseheader.txt
  44. 149
    0
      nbproject/project.properties
  45. 16
    0
      nbproject/project.xml
  46. BIN
      src/Ubuntu-R.ttf
  47. 1469
    0
      src/fi/iki/elonen/NanoHTTPD.java
  48. BIN
      src/net/apocalypselabs/symat/128x128.png
  49. BIN
      src/net/apocalypselabs/symat/16x16.png
  50. BIN
      src/net/apocalypselabs/symat/24x24.png
  51. BIN
      src/net/apocalypselabs/symat/256x256.png
  52. BIN
      src/net/apocalypselabs/symat/32x32.png
  53. BIN
      src/net/apocalypselabs/symat/48x48.png
  54. BIN
      src/net/apocalypselabs/symat/512x512.png
  55. BIN
      src/net/apocalypselabs/symat/64x64.png
  56. BIN
      src/net/apocalypselabs/symat/96x96.png
  57. 73
    0
      src/net/apocalypselabs/symat/BadInputException.java
  58. 121
    0
      src/net/apocalypselabs/symat/CodeCompleter.java
  59. 287
    0
      src/net/apocalypselabs/symat/CodeExport.form
  60. 488
    0
      src/net/apocalypselabs/symat/CodeExport.java
  61. 314
    0
      src/net/apocalypselabs/symat/CodeRunner.java
  62. 119
    0
      src/net/apocalypselabs/symat/Debug.java
  63. 439
    0
      src/net/apocalypselabs/symat/Editor.form
  64. 1054
    0
      src/net/apocalypselabs/symat/Editor.java
  65. 156
    0
      src/net/apocalypselabs/symat/FileUtils.java
  66. 66
    0
      src/net/apocalypselabs/symat/FontOptions.form
  67. 145
    0
      src/net/apocalypselabs/symat/FontOptions.java
  68. 1307
    0
      src/net/apocalypselabs/symat/Functions.java
  69. 210
    0
      src/net/apocalypselabs/symat/Globals.form
  70. 327
    0
      src/net/apocalypselabs/symat/Globals.java
  71. 147
    0
      src/net/apocalypselabs/symat/Graph.form
  72. 549
    0
      src/net/apocalypselabs/symat/Graph.java
  73. 124
    0
      src/net/apocalypselabs/symat/Help.form
  74. 311
    0
      src/net/apocalypselabs/symat/Help.java
  75. 198
    0
      src/net/apocalypselabs/symat/InstallPlugin.form
  76. 317
    0
      src/net/apocalypselabs/symat/InstallPlugin.java
  77. 200
    0
      src/net/apocalypselabs/symat/Interpreter.form
  78. 562
    0
      src/net/apocalypselabs/symat/Interpreter.java
  79. 129
    0
      src/net/apocalypselabs/symat/KeyValListItem.java
  80. 166
    0
      src/net/apocalypselabs/symat/License.form
  81. 437
    0
      src/net/apocalypselabs/symat/License.java
  82. 220
    0
      src/net/apocalypselabs/symat/Main.form
  83. 1127
    0
      src/net/apocalypselabs/symat/Main.java
  84. 104
    0
      src/net/apocalypselabs/symat/Notepad.form
  85. 241
    0
      src/net/apocalypselabs/symat/Notepad.java
  86. 408
    0
      src/net/apocalypselabs/symat/PackagePlugin.form
  87. 474
    0
      src/net/apocalypselabs/symat/PackagePlugin.java
  88. 219
    0
      src/net/apocalypselabs/symat/Pads.form
  89. 568
    0
      src/net/apocalypselabs/symat/Pads.java
  90. 134
    0
      src/net/apocalypselabs/symat/PrefStorage.java
  91. 100
    0
      src/net/apocalypselabs/symat/PrettifyToHtml.java
  92. 454
    0
      src/net/apocalypselabs/symat/Settings.form
  93. 458
    0
      src/net/apocalypselabs/symat/Settings.java
  94. 146
    0
      src/net/apocalypselabs/symat/SharePad.form
  95. 289
    0
      src/net/apocalypselabs/symat/SharePad.java
  96. 92
    0
      src/net/apocalypselabs/symat/SingleInstanceClient.java
  97. 113
    0
      src/net/apocalypselabs/symat/SingleInstanceServer.java
  98. 153
    0
      src/net/apocalypselabs/symat/SplashScreen.form
  99. 329
    0
      src/net/apocalypselabs/symat/SplashScreen.java
  100. 0
    0
      src/net/apocalypselabs/symat/SyncLogin.form

+ 6
- 0
.gitignore View File

@@ -0,0 +1,6 @@
bin/
dist/
*.exe
/src/padkey
/nbproject/private/
/build/

+ 58
- 0
LICENSE View File

@@ -0,0 +1,58 @@
==============================
Code License
==============================

Copyright (c) 2015, Netsyms Technologies
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. 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.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

4. You adhere to the Media License detailed below. If you do not, this license
is automatically revoked and you must purge all copies of the software you
possess, in source or binary form.

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 HOLDER 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.


==============================
Media License
==============================

All images and other graphical files (the "graphics") included with this
software are copyright (c) 2015 Netsyms Technologies. You may not distribute
the graphics or any program, source code repository, or other digital storage
media containing them without written permission from Netsyms Technologies.
This ban on distribution only applies to publicly available systems.
A password-protected network file share, USB drive, or other storage scheme that
cannot be easily accessed by the public is generally allowed. If in doubt,
contact Netsyms Technologies. If Netsyms Technologies allows or denies
you permission, that decision is considered final and binding.

==============================
Other Licenses
==============================

This software contains third-party components. These components may fall under
a different license and have a different copyright holder than the above.
Consult their license information or the Manual system for more information.

+ 18
- 0
README.md View File

@@ -0,0 +1,18 @@
SyMAT
=====

SyMAT is a computer science and math system written in Java.

This repository is extremely bleeding-edge, and we won't help you compile it.
We test new features before committing, but there are bugs.
If you want a stable release, download the latest one from our website.

Get SyMAT
------

To get SyMAT for your platform, go to:
http://symatapp.com/

Report a Bug
------
To report bugs, go to: https://github.com/Netsyms/SyMAT/issues

+ 121
- 0
build.xml View File

@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015, Netsyms Technologies
All rights reserved.


CODE LICENSE ==========
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. 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.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

4. You adhere to the Media License detailed below. If you do not, this license
is automatically revoked and you must purge all copies of the software you
possess, in source or binary form.

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 HOLDER 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.


MEDIA LICENSE ==========
All images and other graphical files ("media") included with this
software are copyright (c) 2015 Netsyms Technologies. You may not distribute
the graphics or any program, source code repository, or other digital storage
media containing them without permission from Netsyms Technologies.
This ban on distribution only applies to publicly available systems.
A password-protected network file share, USB drive, or other storage scheme that
cannot be easily accessed by the public is generally allowed. If in doubt,
contact Netsyms Technologies. If Netsyms Technologies allows or denies
you permission, that decision is considered final and binding.

You may only use the media for personal,
non-commercial, non-educational use unless:
1, You have paid for the software and media via the SyMAT website,
or 2, you are using it as part of the 15-day trial period.
Other uses are prohibited without permission.
If any part of this license is deemed unenforcable, the remainder
of the license remains in full effect.
-->

<project name="SyMAT" default="default" basedir=".">
<description>Builds, tests, and runs the project SyMAT.</description>
<import file="nbproject/build-impl.xml"/>
<!--

There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:

-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products

(Targets beginning with '-' are not intended to be called on their own.)

Example of inserting an obfuscator after compilation could look like this:

<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>

For list of available properties check the imported
nbproject/build-impl.xml file.


Another way to customize the build is by overriding existing main targets.
The targets of interest are:

-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation

An example of overriding the target for project execution could look like this:

<target name="run" depends="SyMAT-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>

Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.

-->
</project>

BIN
lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar View File


BIN
lib/JavaPrettify-1.2.1.jar View File


BIN
lib/absolutelayout/AbsoluteLayout.jar View File


BIN
lib/autocomplete-2.5.4.jar View File


BIN
lib/beautyeye_lnf.jar View File


BIN
lib/commons-codec-1.9.jar View File


BIN
lib/commons-logging-1.2.jar View File


BIN
lib/flamingo-6.3-javadoc.jar View File


BIN
lib/flamingo-6.3.jar View File


BIN
lib/fluent-hc-4.5.jar View File


BIN
lib/htmlcleaner-2.10.jar View File


BIN
lib/httpclient-4.5.jar View File


BIN
lib/httpclient-cache-4.5.jar View File


BIN
lib/httpclient-win-4.5.jar View File


BIN
lib/httpcore-4.4.1.jar View File


BIN
lib/httpmime-4.5.jar View File


BIN
lib/iText-4.2.0-com.itextpdf.jar View File


BIN
lib/jmathplot.jar View File


BIN
lib/jna-4.1.0.jar View File


BIN
lib/jna-platform-4.1.0.jar View File


BIN
lib/js-engine.jar View File


BIN
lib/js.jar View File


BIN
lib/json-simple-1.1.1.jar View File


BIN
lib/jython-standalone-2.7-b3.jar View File


BIN
lib/jython-standalone-2.7.0.jar View File


BIN
lib/log4j-1.2.11.jar View File


+ 89
- 0
lib/nblibraries.properties View File

@@ -0,0 +1,89 @@
#
# Copyright (c) 2015, Netsyms Technologies
# All rights reserved.
#
#
# CODE LICENSE ==========
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. 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.
#
# 3. Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# 4. You adhere to the Media License detailed below. If you do not, this license
# is automatically revoked and you must purge all copies of the software you
# possess, in source or binary form.
#
# 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 HOLDER 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.
#
#
# MEDIA LICENSE ==========
# All images and other graphical files ("media") included with this
# software are copyright (c) 2015 Netsyms Technologies. You may not distribute
# the graphics or any program, source code repository, or other digital storage
# media containing them without permission from Netsyms Technologies.
# This ban on distribution only applies to publicly available systems.
# A password-protected network file share, USB drive, or other storage scheme that
# cannot be easily accessed by the public is generally allowed. If in doubt,
# contact Netsyms Technologies. If Netsyms Technologies allows or denies
# you permission, that decision is considered final and binding.
#
# You may only use the media for personal,
# non-commercial, non-educational use unless:
# 1, You have paid for the software and media via the SyMAT website,
# or 2, you are using it as part of the 15-day trial period.
# Other uses are prohibited without permission.
# If any part of this license is deemed unenforcable, the remainder
# of the license remains in full effect.
#
libs.absolutelayout.classpath=\
${base}/absolutelayout/AbsoluteLayout.jar
libs.absolutelayout.displayName=Absolute Layout
#
# Netsyms Technologies
# Open Source License
#
# Source code can be used for any purpose, as long as:
# - Compiled binaries are rebranded and trademarks are not
# visible by the end user at any time, except to give
# credit to Netsyms Technologies, such as by showing
# "Based on <product> by Netsyms Technologies" or a
# similar notice;
# - You do not use the code for evil;
# - Rebranded compiled applications have significant
# differences in functionality;
# - and you provide your modified source code for download,
# under the terms of the GNU LGPL v3 or a comparable
# license.
#
# Compiled binaries cannot be redistributed or mirrored,
# unless:
# - You have written permission from Netsyms Technologies;
# - Downloads are not available from Netsyms Technologies,
# not even behind a paywall or other blocking mechanism;
# - or you have received a multi-computer license, in which
# case you should take measures to prevent unauthorized
# downloads, such as preventing download access from the
# Internet.
#
libs.CopyLibs.classpath=\
${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
libs.CopyLibs.displayName=CopyLibs Task
libs.CopyLibs.prop-version=2.0

BIN
lib/org-netbeans-api-visual.jar View File


BIN
lib/org-openide-util.jar View File


BIN
lib/rsyntaxtextarea-2.5.6.jar View File


BIN
lib/seaglasslookandfeel-0.2.jar View File


BIN
lib/symja-2014-11-01.jar View File


BIN
lib/trident-6.3.jar View File


BIN
lib/ujmp-complete-0.2.5-javadoc.zip View File


BIN
lib/ujmp-complete-0.2.5.jar View File


+ 3
- 0
manifest.mf View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build


+ 1421
- 0
nbproject/build-impl.xml
File diff suppressed because it is too large
View File


+ 8
- 0
nbproject/genfiles.properties View File

@@ -0,0 +1,8 @@
build.xml.data.CRC32=70b2413f
build.xml.script.CRC32=cfce77fe
build.xml.stylesheet.CRC32=8064a381@1.75.2.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=70b2413f
nbproject/build-impl.xml.script.CRC32=e6773cad
nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48

+ 59
- 0
nbproject/licenseheader.txt View File

@@ -0,0 +1,59 @@
<#if licenseFirst??>
${licenseFirst}
</#if>
${licensePrefix}Copyright (c) 2015, Netsyms Technologies
${licensePrefix}All rights reserved.
${licensePrefix}
${licensePrefix}
${licensePrefix}CODE LICENSE ==========
${licensePrefix}Redistribution and use in source and binary forms, with or without modification,
${licensePrefix}are permitted provided that the following conditions are met:
${licensePrefix}
${licensePrefix}1. Redistributions of source code must retain the above copyright notice, this
${licensePrefix}list of conditions and the following disclaimer.
${licensePrefix}
${licensePrefix}2. Redistributions in binary form must reproduce the above copyright notice,
${licensePrefix}this list of conditions and the following disclaimer in the documentation and/or
${licensePrefix}other materials provided with the distribution.
${licensePrefix}
${licensePrefix}3. Neither the name of the copyright holder nor the names of its contributors
${licensePrefix}may be used to endorse or promote products derived from this software without
${licensePrefix}specific prior written permission.
${licensePrefix}
${licensePrefix}4. You adhere to the Media License detailed below. If you do not, this license
${licensePrefix}is automatically revoked and you must purge all copies of the software you
${licensePrefix}possess, in source or binary form.
${licensePrefix}
${licensePrefix}THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
${licensePrefix}ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
${licensePrefix}WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
${licensePrefix}DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
${licensePrefix}ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
${licensePrefix}(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
${licensePrefix}LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
${licensePrefix}ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
${licensePrefix}(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
${licensePrefix}SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
${licensePrefix}
${licensePrefix}
${licensePrefix}MEDIA LICENSE ==========
${licensePrefix}All images and other graphical files ("media") included with this
${licensePrefix}software are copyright (c) 2015 Netsyms Technologies. You may not distribute
${licensePrefix}the graphics or any program, source code repository, or other digital storage
${licensePrefix}media containing them without permission from Netsyms Technologies.
${licensePrefix}This ban on distribution only applies to publicly available systems.
${licensePrefix}A password-protected network file share, USB drive, or other storage scheme that
${licensePrefix}cannot be easily accessed by the public is generally allowed. If in doubt,
${licensePrefix}contact Netsyms Technologies. If Netsyms Technologies allows or denies
${licensePrefix}you permission, that decision is considered final and binding.
${licensePrefix}
${licensePrefix}You may only use the media for personal,
${licensePrefix}non-commercial, non-educational use unless:
${licensePrefix}1, You have paid for the software and media via the SyMAT website,
${licensePrefix}or 2, you are using it as part of the 15-day trial period.
${licensePrefix}Other uses are prohibited without permission.
${licensePrefix}If any part of this license is deemed unenforcable, the remainder
${licensePrefix}of the license remains in full effect.
<#if licenseLast??>
${licenseLast}
</#if>

+ 149
- 0
nbproject/project.properties View File

@@ -0,0 +1,149 @@
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.desc=Math and Programming for People
application.homepage=https://symatapp.com/
application.splash=C:\\Users\\Skylar\\Documents\\Apocalypse Labs\\appmedia\\SyMAT\\splashscreen.png
application.title=SyMAT
application.vendor=Netsyms Technologies
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.autocomplete-2.5.4.jar=lib/autocomplete-2.5.4.jar
file.reference.beautyeye_lnf.jar=lib/beautyeye_lnf.jar
file.reference.commons-codec-1.9.jar=lib/commons-codec-1.9.jar
file.reference.commons-logging-1.2.jar=lib/commons-logging-1.2.jar
file.reference.flamingo-6.3.jar=lib/flamingo-6.3.jar
file.reference.htmlcleaner-2.10.jar=lib/htmlcleaner-2.10.jar
file.reference.httpclient-4.5.jar=lib/httpclient-4.5.jar
file.reference.httpclient-cache-4.5.jar=lib/httpclient-cache-4.5.jar
file.reference.httpclient-win-4.5.jar=lib/httpclient-win-4.5.jar
file.reference.httpcore-4.4.1.jar=lib/httpcore-4.4.1.jar
file.reference.httpmime-4.5.jar=lib/httpmime-4.5.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.jmathplot.jar=lib/jmathplot.jar
file.reference.jna-4.1.0.jar=lib/jna-4.1.0.jar
file.reference.jna-platform-4.1.0.jar=lib/jna-platform-4.1.0.jar
file.reference.js-engine.jar=lib/js-engine.jar
file.reference.js.jar=lib/js.jar
file.reference.json-simple-1.1.1.jar=lib/json-simple-1.1.1.jar
file.reference.jython-standalone-2.7.0.jar=lib/jython-standalone-2.7.0.jar
file.reference.log4j-1.2.11.jar=lib/log4j-1.2.11.jar
file.reference.rsyntaxtextarea-2.5.6.jar=lib/rsyntaxtextarea-2.5.6.jar
file.reference.seaglasslookandfeel-0.2.jar=lib/seaglasslookandfeel-0.2.jar
file.reference.SyMAT-src=src
file.reference.symja-2014-11-01.jar=lib/symja-2014-11-01.jar
file.reference.trident-6.3.jar=lib/trident-6.3.jar
file.reference.ujmp-complete-0.2.5.jar=lib\\ujmp-complete-0.2.5.jar
includes=**
jar.archive.disabled=${jnlp.enabled}
jar.compress=false
jar.index=${jnlp.enabled}
javac.classpath=\
${file.reference.autocomplete-2.5.4.jar}:\
${file.reference.beautyeye_lnf.jar}:\
${file.reference.flamingo-6.3.jar}:\
${file.reference.htmlcleaner-2.10.jar}:\
${file.reference.iText-4.2.0-com.itextpdf.jar}:\
${file.reference.jmathplot.jar}:\
${file.reference.js-engine.jar}:\
${file.reference.js.jar}:\
${file.reference.json-simple-1.1.1.jar}:\
${file.reference.log4j-1.2.11.jar}:\
${file.reference.rsyntaxtextarea-2.5.6.jar}:\
${file.reference.seaglasslookandfeel-0.2.jar}:\
${file.reference.symja-2014-11-01.jar}:\
${file.reference.trident-6.3.jar}:\
${file.reference.JavaPrettify-1.2.1.jar}:\
${file.reference.ujmp-complete-0.2.5.jar}:\
${file.reference.commons-codec-1.9.jar}:\
${file.reference.commons-logging-1.2.jar}:\
${file.reference.httpclient-4.5.jar}:\
${file.reference.httpclient-cache-4.5.jar}:\
${file.reference.httpclient-win-4.5.jar}:\
${file.reference.httpcore-4.4.1.jar}:\
${file.reference.httpmime-4.5.jar}:\
${file.reference.jna-4.1.0.jar}:\
${file.reference.jna-platform-4.1.0.jar}:\
${file.reference.jython-standalone-2.7.0.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=1.8
javac.target=1.8
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.reference.flamingo-6.3.jar=lib/flamingo-6.3-javadoc.jar
javadoc.reference.ujmp-complete-0.2.5.jar=lib\\ujmp-complete-0.2.5-javadoc.zip!/0.2.5/ujmp-core/apidocs/
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=SyMAT Code Docs
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.Main
# 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
platform.active=default_platform
project.license=licenseheader
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=${file.reference.SyMAT-src}

+ 16
- 0
nbproject/project.xml View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>SyMAT</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots/>
</data>
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
<definitions>.\lib\nblibraries.properties</definitions>
</libraries>
</configuration>
</project>

BIN
src/Ubuntu-R.ttf View File


+ 1469
- 0
src/fi/iki/elonen/NanoHTTPD.java
File diff suppressed because it is too large
View File


BIN
src/net/apocalypselabs/symat/128x128.png View File


BIN
src/net/apocalypselabs/symat/16x16.png View File


BIN
src/net/apocalypselabs/symat/24x24.png View File


BIN
src/net/apocalypselabs/symat/256x256.png View File


BIN
src/net/apocalypselabs/symat/32x32.png View File


BIN
src/net/apocalypselabs/symat/48x48.png View File


BIN
src/net/apocalypselabs/symat/512x512.png View File


BIN
src/net/apocalypselabs/symat/64x64.png View File


BIN
src/net/apocalypselabs/symat/96x96.png View File


+ 73
- 0
src/net/apocalypselabs/symat/BadInputException.java View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
*
*
* CODE LICENSE ==========
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. You adhere to the Media License detailed below. If you do not, this license
* is automatically revoked and you must purge all copies of the software you
* possess, in source or binary form.
*
* 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 HOLDER 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.
*
*
* MEDIA LICENSE ==========
* All images and other graphical files ("media") included with this
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
* the graphics or any program, source code repository, or other digital storage
* media containing them without permission from Netsyms Technologies.
* This ban on distribution only applies to publicly available systems.
* A password-protected network file share, USB drive, or other storage scheme that
* cannot be easily accessed by the public is generally allowed. If in doubt,
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
* you permission, that decision is considered final and binding.
*
* You may only use the media for personal,
* non-commercial, non-educational use unless:
* 1, You have paid for the software and media via the SyMAT website,
* or 2, you are using it as part of the 15-day trial period.
* Other uses are prohibited without permission.
* If any part of this license is deemed unenforcable, the remainder
* of the license remains in full effect.
*/
package net.apocalypselabs.symat;

/**
*
* Bad input exception. Useful for throwing errors in user code.
*
* @author Skylar
*/
public class BadInputException extends Exception {

public BadInputException() {
super();
}

public BadInputException(String msg) {
super(msg);
}
}

+ 121
- 0
src/net/apocalypselabs/symat/CodeCompleter.java View File

@@ -0,0 +1,121 @@
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
*
*
* CODE LICENSE ==========
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. You adhere to the Media License detailed below. If you do not, this license
* is automatically revoked and you must purge all copies of the software you
* possess, in source or binary form.
*
* 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 HOLDER 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.
*
*
* MEDIA LICENSE ==========
* All images and other graphical files ("media") included with this
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
* the graphics or any program, source code repository, or other digital storage
* media containing them without permission from Netsyms Technologies.
* This ban on distribution only applies to publicly available systems.
* A password-protected network file share, USB drive, or other storage scheme that
* cannot be easily accessed by the public is generally allowed. If in doubt,
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
* you permission, that decision is considered final and binding.
*
* You may only use the media for personal,
* non-commercial, non-educational use unless:
* 1, You have paid for the software and media via the SyMAT website,
* or 2, you are using it as part of the 15-day trial period.
* Other uses are prohibited without permission.
* If any part of this license is deemed unenforcable, the remainder
* of the license remains in full effect.
*/
package net.apocalypselabs.symat;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.fife.ui.autocomplete.BasicCompletion;
import org.fife.ui.autocomplete.CompletionProvider;
import org.fife.ui.autocomplete.DefaultCompletionProvider;
import org.fife.ui.autocomplete.VariableCompletion;

/**
*
* @author Skylar
*/
public class CodeCompleter {

private final CompletionProvider provider;
private final String lang;

/**
*
* @param language Either js or py.
*/
public CodeCompleter(String language) {
lang = language;
provider = makeCompletions();
}

public CompletionProvider getProvider() {
return provider;
}

private CompletionProvider makeCompletions() {
DefaultCompletionProvider provider = new DefaultCompletionProvider();
try {
String[] files = {"functions", "constants"};
for (String fileid : files) {
BufferedReader reader = new BufferedReader(
new InputStreamReader(
CodeCompleter.class.getResourceAsStream("resources/" + (fileid.equals(files[0]) ? "" : lang) + fileid + ".txt")));
String line;
while ((line = reader.readLine()) != null) {
switch (fileid) {
case "functions":
String[] args = line.split("\\|");
if (args.length == 2) {
provider.addCompletion(new BasicCompletion(provider, args[0], args[1]));
} else if (args.length == 3) {
provider.addCompletion(new BasicCompletion(provider, args[0], args[1], args[2]));
} else {
provider.addCompletion(new BasicCompletion(provider, args[0]));
}
break;
case "constants":
provider.addCompletion(new VariableCompletion(provider, line, "double"));
break;
}
}
}
} catch (IOException ex) {
Debug.printerr(ex.getMessage());
}
return provider;
}

}

+ 287
- 0
src/net/apocalypselabs/symat/CodeExport.form View File

@@ -0,0 +1,287 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<Properties>
<Property name="closable" type="boolean" value="true"/>
<Property name="iconifiable" type="boolean" value="true"/>
<Property name="maximizable" type="boolean" value="true"/>
<Property name="resizable" type="boolean" value="true"/>
<Property name="title" type="java.lang.String" value="Export Code"/>
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/net/apocalypselabs/symat/icons/export.png"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>

<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" pref="583" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="10" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jScrollPane1" pref="273" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>

<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextPane" name="previewPane">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="contentType" type="java.lang.String" value="text/html" noResource="true"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel1">

<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="outputPlaceBox" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="titleBox" min="-2" pref="154" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="authBox" max="32767" attributes="0"/>
<Component id="dateBox" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jScrollPane2" pref="239" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="5" pref="5" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="titleBox" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jScrollPane2" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="authBox" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="dateBox" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="outputPlaceBox" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="jPanel2" max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JTextField" name="titleBox">
<Properties>
<Property name="text" type="java.lang.String" value="SyMAT Project"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Title:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Author:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="authBox">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="PrefStorage.getSetting(&quot;author&quot;, &quot;&quot;)" type="code"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="dateBox">
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="Date:"/>
</Properties>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>

<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="headerBox">
<Properties>
<Property name="columns" type="int" value="20"/>
<Property name="lineWrap" type="boolean" value="true"/>
<Property name="rows" type="int" value="2"/>
<Property name="tabSize" type="int" value="4"/>
<Property name="wrapStyleWord" type="boolean" value="true"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="text" type="java.lang.String" value="Header:"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="Update Preview"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Export to:"/>
</Border>
</Property>
</Properties>

<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="exPdf" max="32767" attributes="0"/>
<Component id="exHtml" alignment="0" pref="80" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Component id="exHtml" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="exPdf" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="exHtml">
<Properties>
<Property name="text" type="java.lang.String" value="HTML"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exHtmlActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="exPdf">
<Properties>
<Property name="text" type="java.lang.String" value="PDF"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exPdfActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JComboBox" name="outputPlaceBox">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="3">
<StringItem index="0" value="Below code"/>
<StringItem index="1" value="Above code"/>
<StringItem index="2" value="No"/>
</StringArray>
</Property>
<Property name="selectedIndex" type="int" value="2"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" value="Include output:"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

+ 488
- 0
src/net/apocalypselabs/symat/CodeExport.java View File

@@ -0,0 +1,488 @@
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
*
*
* CODE LICENSE ==========
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. You adhere to the Media License detailed below. If you do not, this license
* is automatically revoked and you must purge all copies of the software you
* possess, in source or binary form.
*
* 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 HOLDER 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.
*
*
* MEDIA LICENSE ==========
* All images and other graphical files ("media") included with this
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
* the graphics or any program, source code repository, or other digital storage
* media containing them without permission from Netsyms Technologies.
* This ban on distribution only applies to publicly available systems.
* A password-protected network file share, USB drive, or other storage scheme that
* cannot be easily accessed by the public is generally allowed. If in doubt,
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
* you permission, that decision is considered final and binding.
*
* You may only use the media for personal,
* non-commercial, non-educational use unless:
* 1, You have paid for the software and media via the SyMAT website,
* or 2, you are using it as part of the 15-day trial period.
* Other uses are prohibited without permission.
* If any part of this license is deemed unenforcable, the remainder
* of the license remains in full effect.
*/
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 javax.swing.SwingUtilities;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
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 codeLang = "js";
private String html;
private final String origCode;
private String outputTxt = "";

/**
* Creates new form CodeExport
*
* @param code The code.
*/
public CodeExport(String code) {
origCode = code;
initComponents();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
html = genHtml(code);
}
});
html = genHtml(code);
previewPane.setText(html);
previewPane.setCaretPosition(0);
}

/**
* Create CodeExport window with a set language for syntax highlighting.
*
* @param code The code.
* @param lang Options are "js" or "python".
*/
public CodeExport(String code, String lang) {
this(code);
codeLang = lang;
}

public CodeExport(String code, String lang, String out) {
this(code, lang);
outputTxt = out;
}

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 = "<!DOCTYPE html>"
+ "<html><head>"
+ "<meta charset=\"utf-8\">"
+ "<title></title>"
+ "<style type=\"text/css\"><!--" + css + "--></style>"
+ "</head>"
+ "<body>"
+ "<h1>" + titleBox.getText() + "</h1>";
if (!authBox.getText().equals("")) {
html += "<h2>Author: " + authBox.getText() + "</h2>";
}
if (!dateBox.getText().equals("")) {
html += "<h3>Date: " + dateBox.getText() + "</h3>";
}
if (!headerBox.getText().equals("")) {
html += "<p class=\"header\">" + headerBox.getText() + "</p>";
}
if (outputPlaceBox.getSelectedIndex() == 1) {
html += getOutput();
}
PrettifyParser parser = new PrettifyParser();
List<ParseResult> parseResults = parser.parse(codeLang, code);
html += PrettifyToHtml.toHtml(code, parseResults);
if (outputPlaceBox.getSelectedIndex() == 0) {
html += getOutput();
}
html += "</body></html>";
html = html.replace("\t", "<span class=\"tab\">&nbsp;&nbsp;&nbsp;&nbsp;</span>");
html = html.replace("\n", "<br>");
HtmlCleaner cleaner = new HtmlCleaner();
CleanerProperties props = cleaner.getProperties();
TagNode node = cleaner.clean(html);
html = new SimpleHtmlSerializer(props).getAsString(node);
html = html.replace("&apos;", "'");
html = html.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "");
Debug.println(html);
return html;
}

private String getOutput() {
return "<p><b>Output:</b></p><pre class=\"plaintxt\">"
+ outputTxt.replace("<", "&lt;").
replace("&", "&amp;").
replace(">", "&gt;").
replace("\"", "''")
+ "\n\n</pre>";
}

/**
* 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
outputPlaceBox = new javax.swing.JComboBox();
jLabel5 = new javax.swing.JLabel();

setClosable(true);
setIconifiable(true);
setMaximizable(true);
setResizable(true);
setTitle("Export Code");
setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/export.png"))); // NOI18N

previewPane.setEditable(false);
previewPane.setContentType("text/html"); // NOI18N
jScrollPane1.setViewportView(previewPane);

titleBox.setText("SyMAT Project");

jLabel1.setText("Title:");

jLabel2.setText("Author:");

authBox.setText(PrefStorage.getSetting("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 to:"));

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(exPdf, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(exHtml, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(exHtml)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(exPdf)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

outputPlaceBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Below code", "Above code", "No" }));
outputPlaceBox.setSelectedIndex(2);

jLabel5.setText("Include output:");

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)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(outputPlaceBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(titleBox, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.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(authBox)
.addComponent(dateBox))))
.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.DEFAULT_SIZE, 239, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(5, 5, 5)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.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, false)
.addComponent(jScrollPane2)
.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))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(outputPlaceBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, Short.MAX_VALUE)))
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.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, javax.swing.GroupLayout.DEFAULT_SIZE, 583, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 10, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);

pack();
}// </editor-fold>//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) {
html = genHtml(origCode);
JFileChooser fc = new JFileChooser();
FileFilter filter;
switch (format) {
case "pdf":
filter = new FileNameExtensionFilter("Portable Document Format (PDF)", "pdf");
break;
default:
filter = new FileNameExtensionFilter("Web Document (HTML)", "html");
}
fc.setFileFilter(filter);
fc.addChoosableFileFilter(filter);
int r = fc.showSaveDialog(this);
if (r == JFileChooser.APPROVE_OPTION) {
String file = FileUtils.getFileWithExtension(fc).getAbsolutePath();
switch (format) {
case "html":
saveFile(html, file);
break;
case "pdf":
savePdfFile(html, file);
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();
savedMsg();
}
} 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);
savedMsg();
} catch (Exception ex) {
JOptionPane.showInternalMessageDialog(this, "Error saving: " + ex.getMessage());
}
}

private void savedMsg() {
JOptionPane.showInternalMessageDialog(this, "Export complete!");
}

// 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.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JComboBox outputPlaceBox;
private javax.swing.JTextPane previewPane;
private javax.swing.JTextField titleBox;
// End of variables declaration//GEN-END:variables
}

+ 314
- 0
src/net/apocalypselabs/symat/CodeRunner.java View File

@@ -0,0 +1,314 @@
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
*
*
* CODE LICENSE ==========
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. You adhere to the Media License detailed below. If you do not, this license
* is automatically revoked and you must purge all copies of the software you
* possess, in source or binary form.
*
* 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 HOLDER 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.
*
*
* MEDIA LICENSE ==========
* All images and other graphical files ("media") included with this
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
* the graphics or any program, source code repository, or other digital storage
* media containing them without permission from Netsyms Technologies.
* This ban on distribution only applies to publicly available systems.
* A password-protected network file share, USB drive, or other storage scheme that
* cannot be easily accessed by the public is generally allowed. If in doubt,
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
* you permission, that decision is considered final and binding.
*
* You may only use the media for personal,
* non-commercial, non-educational use unless:
* 1, You have paid for the software and media via the SyMAT website,
* or 2, you are using it as part of the 15-day trial period.
* Other uses are prohibited without permission.
* If any part of this license is deemed unenforcable, the remainder
* of the license remains in full effect.
*/
package net.apocalypselabs.symat;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.swing.JOptionPane;

/**
*
* @author Skylar
*/
public class CodeRunner {

private ScriptEngine se;
private StringWriter sw = new StringWriter();
private PrintWriter pw = new PrintWriter(sw);
private String modules = "";
private String moduleterm = "";

// If we need to wrap code around input to make everything nice.
private boolean wrapRequired = false;
// What codez are we speaking?
private String scriptLang = "";

public CodeRunner() {
this("javascript");
}

public CodeRunner(int lang) {
this(lang == 0 ? "js" : "py");
}

public CodeRunner(String lang) {
scriptLang = lang;
switch (lang) {
case "javascript":
case "js":
case "rhino":
scriptLang = "javascript";
se = new ScriptEngineManager().getEngineByName("rhino");
wrapRequired = true;
try {
// Add custom functions.
se.eval("importClass(net.apocalypselabs.symat.Functions);"
+ "SyMAT_Functions = new net.apocalypselabs.symat.Functions();"
+ "SyMAT_Functions.setLang('js');\n"
+ getFunctions("js")
+ loadToolkits());
// Allow engine access from scripts.
se.put("engine", se);
attachWriters();
} catch (Exception ex) {
initError(ex);
}
break;
case "python":
case "jython":
case "py":
scriptLang = "python";
se = new ScriptEngineManager().getEngineByName("python");
try {
se.eval("from math import *\n"
+ "from net.apocalypselabs.symat import Functions\n"
+ "_=Functions()\n"
+ "_.setLang('py')\n\n"
+ getFunctions("py")
+ loadToolkits());
// Allow engine access from scripts.
se.put("engine", se);
attachWriters();
} catch (Exception ex) {
initError(ex);
}
break;
default:
throw new UnsupportedOperationException("Script language " + lang + " not supported.");
}
}

public static List<InputStream> loadResources(final String name,
final ClassLoader classLoader) throws IOException {
final List<InputStream> list = new ArrayList<InputStream>();
final Enumeration<URL> systemResources
= (classLoader == null ? ClassLoader.getSystemClassLoader() : classLoader)
.getResources(name);
while (systemResources.hasMoreElements()) {
list.add(systemResources.nextElement().openStream());
}
return list;
}

private String loadToolkits() {
String out = "";
try {
List<InputStream> il = loadResources("meta.txt", null);
InputStream[] ii = new InputStream[il.size()];
for (InputStream i : il.toArray(ii)) {
BufferedReader br = new BufferedReader(new InputStreamReader(i));
while (br.ready()) {
String l = br.readLine();
if (l.contains("=")) {
String classname = l.split("=")[0];
String varname = l.split("=")[1];
if (scriptLang.equals("javascript")) {
out += "importClass(" + classname + ");"
+ varname + " = new " + classname + "();";
} else {
out += "from "
+ classname.substring(0, classname.lastIndexOf("."))
+ " import " + classname.substring(classname.lastIndexOf(".") + 1) + "\n"
+ varname + " = " + classname.substring(classname.lastIndexOf(".") + 1) + "()\n";
}
}
}
}
} catch (Exception ex) {

}
Debug.println(out);
return out;
}

@Deprecated
public CodeRunner(String lang, boolean shell) {
this(lang);
}

private void attachWriters() {
se.getContext().setWriter(pw);
se.getContext().setErrorWriter(pw);
Debug.println("Attached writers.");
}

/**
* Inits the Python engine on application start.
*
* @param fakeInit Set it to true.
*/
public CodeRunner(boolean fakeInit) {
if (fakeInit) {
se = new ScriptEngineManager().getEngineByName("python");
}
}

public StringWriter getStringWriter() {
return sw;
}

public PrintWriter getPrintWriter() {
return pw;
}

public String getBufferDump() {
String dump = sw.toString();
sw.getBuffer().setLength(0);
return dump;
}

private void initError(Exception ex) {
JOptionPane.showMessageDialog(null, "Error: "
+ "Could not properly initialize " + scriptLang + " scripting engine."
+ "\n\nSome functions may not work.\n\n"
+ "(" + ex.getMessage() + ")");
}

/**
* Parse a String of code.
*
* @param eval A String of code to evaluate.
* @return the result.
*/
public Object evalString(String eval) {
try {
Object res = se.eval(wrapMath(eval));
if (res == null) {
res = "";
}
String result = res + sw.getBuffer().toString().trim();
sw.getBuffer().setLength(0);
return result;
} catch (ScriptException ex) {
return formatEx(ex);
}
}

/**
* Parse code and use the default output writers.
*
* @param eval A String of code to evaluate.
*/
public void evalCode(String eval) {
try {
Object res = se.eval(wrapMath(eval));
if (res == null) {
res = "";
}
} catch (ScriptException ex) {
sw.append(formatEx(ex));
}
}

private String formatEx(ScriptException ex) {
String err = ex.getMessage();
//err = err.replace("sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: ", "");
//err = err.replace("<Unknown source>", "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) {
if (wrapRequired) {
String with = "with(SyMAT_Functions){with(Math){" + eval + "}}";
Debug.println(with);
return with;
}
return eval;
}

public void setVar(String var, Object val) {
se.put(var, val);
}

public Object getVar(String var) {
return se.get(var);
}

private String getFunctions(String lang) {
String text = "";
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(
CodeRunner.class
.getResourceAsStream("functions." + lang)));
String line;
while ((line = reader.readLine()) != null) {
text += line + "\n";
}
} catch (Exception e) {
}
return text;
}
}

+ 119
- 0
src/net/apocalypselabs/symat/Debug.java View File

@@ -0,0 +1,119 @@
/*
* Copyright (c) 2015, Netsyms Technologies
* All rights reserved.
*
*
* CODE LICENSE ==========
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. You adhere to the Media License detailed below. If you do not, this license
* is automatically revoked and you must purge all copies of the software you
* possess, in source or binary form.
*
* 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 HOLDER 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.
*
*
* MEDIA LICENSE ==========
* All images and other graphical files ("media") included with this
* software are copyright (c) 2015 Netsyms Technologies. You may not distribute
* the graphics or any program, source code repository, or other digital storage
* media containing them without permission from Netsyms Technologies.
* This ban on distribution only applies to publicly available systems.
* A password-protected network file share, USB drive, or other storage scheme that
* cannot be easily accessed by the public is generally allowed. If in doubt,
* contact Netsyms Technologies. If Netsyms Technologies allows or denies
* you permission, that decision is considered final and binding.
*
* You may only use the media for personal,
* non-commercial, non-educational use unless:
* 1, You have paid for the software and media via the SyMAT website,
* or 2, you are using it as part of the 15-day trial period.
* Other uses are prohibited without permission.
* If any part of this license is deemed unenforcable, the remainder
* of the license remains in full effect.
*/
package net.apocalypselabs.symat;

/**
* This class handles debug logging, so it's easy to disable.
*
* @author Skylar
*/
public class Debug {

// If output should be on or off
public static boolean debug = true;

/**
* Turn debug output on and off.
*
* @param b
*/
public static void setDebug(boolean b) {
debug = b;
}

/**
* Check if debug output is enabled.
*
* @return true if it is.
*/
public static boolean getDebug() {
return debug;
}

/**
* Call System.out.println(data) if debug output enabled.
*
* @param data Data to print.
*/
public static void println(Object data) {
if (debug) {
System.out.println(data);
}
}

/**
* Call System.err.println(data) if debug output enabled.
*
* @param data Data to print.
*/
public static void printerr(Object data) {
if (debug) {
System.err.println(data);
}
}

/**
* Call e.printStackTrace() if debug output enabled.
*
* @param e an Exception.