Initial commit

master
skylarmt 9 years ago
commit f117c32bb6

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="MeetLeeb" default="default" basedir=".">
<description>Builds, tests, and runs 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="MeetLeeb-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.
-->
<target name="-unjar-and-copy-lib-jars">
<unjar dest="${build.classes.dir}">
<fileset dir="dist/lib">
<include name="**/*.jar"/>
</fileset>
<patternset>
<exclude name="META-INF/**"/>
<exclude name="/*"/>
</patternset>
</unjar>
</target>
<target depends="init,compile,-pre-pre-jar,-pre-jar,-unjar-and-copy-lib-jars" name="fat-jar">
<property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
<jar destfile="${dist.jar}">
<fileset dir="${build.classes.dir}"/>
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
</manifest>
</jar>
<echo>To run this application from the command line without Ant, try (HAXX):</echo>
<property location="${dist.jar}" name="dist.jar.resolved"/>
<echo>java -jar "${dist.jar.resolved}"</echo>
</target>
<target depends="clean,fat-jar" name="clean-and-fat-jar"/>
</project>

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>gui</headerType>
<jar>C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\dist\SyMAT.jar</jar>
<outfile>C:\Users\Skylar\Documents\NetBeansProjects\SyMAT\SyMAT-0.5.1.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir>.</chdir>
<priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl>
<supportUrl></supportUrl>
<stayAlive>false</stayAlive>
<manifest></manifest>
<icon>C:\Users\Skylar\SparkleShare\aplabs\appmedia\SyMAT\icon.ico</icon>
<jre>
<path></path>
<bundledJre64Bit>false</bundledJre64Bit>
<minVersion>1.7.0</minVersion>
<maxVersion></maxVersion>
<jdkPreference>preferJre</jdkPreference>
<runtimeBits>64/32</runtimeBits>
</jre>
<splash>
<file>C:\Users\Skylar\SparkleShare\aplabs\appmedia\SyMAT\splash0.5.bmp</file>
<waitForWindow>true</waitForWindow>
<timeout>60</timeout>
<timeoutErr>true</timeoutErr>
</splash>
<versionInfo>
<fileVersion>0.5.1.0</fileVersion>
<txtFileVersion>Version 0.5</txtFileVersion>
<fileDescription>SyMAT</fileDescription>
<copyright>2014 Apocalypse Laboratories</copyright>
<productVersion>0.5.1.0</productVersion>
<txtProductVersion>Version 0.5</txtProductVersion>
<productName>SyMAT</productName>
<companyName>Apocalypse Laboratories</companyName>
<internalName>SyMAT</internalName>
<originalFilename>SyMAT-0.5.exe</originalFilename>
</versionInfo>
</launch4jConfig>

@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -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

Binary file not shown.

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

File diff suppressed because it is too large Load Diff

@ -0,0 +1,953 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
*** GENERATED FROM TEMPLATE - DO NOT EDIT ***
*** EDIT ../build.xml INSTEAD ***
-->
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 Oracle and/or its affiliates. All rights reserved.
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Other names may be trademarks of their respective owners.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://www.netbeans.org/cddl-gplv2.html
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License file at
nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
particular file as subject to the "Classpath" exception as provided
by Oracle in the GPL Version 2 section of the License file that
accompanied this code. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 2, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 2] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 2 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 2 code and therefore, elected the GPL
Version 2 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2013 Sun Microsystems, Inc.
-->
<project name="Build Native Packages" default="build-native" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1"
xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:fx="javafx:com.sun.javafx.tools.ant">
<description>Native Packager Ant calls based on SE support in JavaFX packager</description>
<!-- Check system and JDK version -->
<target name="-check-operating-system">
<condition property="running.on.mac">
<os family="mac"/>
</condition>
<condition property="running.on.unix">
<os family="unix"/>
</condition>
<condition property="running.on.windows">
<os family="windows"/>
</condition>
<echo message="running.on.mac = ${running.on.mac}" level="verbose"/>
<echo message="running.on.unix = ${running.on.unix}" level="verbose"/>
<echo message="running.on.windows = ${running.on.windows}" level="verbose"/>
</target>
<!-- Check availability of JavaFX SDK deployment support (ant-javafx.jar) -->
<target name="-check-endorsed-javafx-ant-classpath">
<condition property="endorsed-javafx-ant-classpath-available">
<and>
<isset property="endorsed.javafx.ant.classpath"/>
<not>
<equals arg1="${endorsed.javafx.ant.classpath}" arg2=""/>
</not>
</and>
</condition>
<echo message="endorsed-javafx-ant-classpath-available = ${endorsed-javafx-ant-classpath-available}" level="verbose"/>
</target>
<target name="-check-property-javafx.sdk">
<echo message="javafx.sdk = ${javafx.sdk}" level="verbose"/>
<condition property="javafx.sdk.defined">
<and>
<isset property="javafx.sdk"/>
<not><contains string="${javafx.sdk}" substring="$${platform" casesensitive="false"/></not>
</and>
</condition>
<condition property="javafx.sdk.missing+default">
<and>
<equals arg1="${platform.active}" arg2="Default_JavaFX_Platform" trim="true"/>
<not><isset property="javafx.sdk.defined"/></not>
</and>
</condition>
<condition property="javafx.sdk.missing-default">
<and>
<not><equals arg1="${platform.active}" arg2="Default_JavaFX_Platform" trim="true"/></not>
<not><isset property="javafx.sdk.defined"/></not>
</and>
</condition>
<echo message="javafx.sdk.defined = ${javafx.sdk.defined}" level="verbose"/>
<echo message="javafx.sdk.missing+default = ${javafx.sdk.missing+default}" level="verbose"/>
<echo message="javafx.sdk.missing-default = ${javafx.sdk.missing-default}" level="verbose"/>
</target>
<target name="-check-ant-javafx-in-fxsdk-lib" depends="-check-property-javafx.sdk" if="javafx.sdk.defined">
<condition property="do.set.ant-javafx.in.fxsdk.lib">
<and>
<not><isset property="ant-javafx.jar.location"/></not>
<available file="${javafx.sdk}${file.separator}lib${file.separator}ant-javafx.jar"/>
</and>
</condition>
</target>
<target name="-set-ant-javafx-in-fxsdk-lib" depends="-check-ant-javafx-in-fxsdk-lib" if="do.set.ant-javafx.in.fxsdk.lib">
<property name="ant-javafx.jar.location" value="${javafx.sdk}${file.separator}lib${file.separator}ant-javafx.jar"/>
</target>
<target name="-check-ant-javafx-in-fxsdk-tools" depends="-check-property-javafx.sdk" if="javafx.sdk.defined">
<condition property="do.set.ant-javafx.in.fxsdk.tools">
<and>
<not><isset property="ant-javafx.jar.location"/></not>
<available file="${javafx.sdk}${file.separator}tools${file.separator}ant-javafx.jar"/>
</and>
</condition>
</target>
<target name="-set-ant-javafx-in-fxsdk-tools" depends="-set-ant-javafx-in-fxsdk-lib,-check-ant-javafx-in-fxsdk-tools" if="do.set.ant-javafx.in.fxsdk.tools">
<property name="ant-javafx.jar.location" value="${javafx.sdk}${file.separator}tools${file.separator}ant-javafx.jar"/>
</target>
<target name="-check-ant-javafx-in-platform-home-lib" if="platform.home">
<condition property="do.set.ant-javafx.in.platform.home.lib">
<and>
<not><isset property="ant-javafx.jar.location"/></not>
<available file="${platform.home}${file.separator}lib${file.separator}ant-javafx.jar"/>
</and>
</condition>
</target>
<target name="-set-ant-javafx-in-platform-home-lib" depends="-set-ant-javafx-in-fxsdk-tools,-check-ant-javafx-in-platform-home-lib" if="do.set.ant-javafx.in.platform.home.lib">
<property name="ant-javafx.jar.location" value="${platform.home}${file.separator}lib${file.separator}ant-javafx.jar"/>
</target>
<target name="-check-ant-javafx-in-platform-home-tools" if="platform.home">
<condition property="do.set.ant-javafx.in.platform.home.tools">
<and>
<not><isset property="ant-javafx.jar.location"/></not>
<available file="${platform.home}${file.separator}tools${file.separator}ant-javafx.jar"/>
</and>
</condition>
</target>
<target name="-set-ant-javafx-in-platform-home-tools" depends="-set-ant-javafx-in-platform-home-lib,-check-ant-javafx-in-platform-home-tools" if="do.set.ant-javafx.in.platform.home.tools">
<property name="ant-javafx.jar.location" value="${platform.home}${file.separator}tools${file.separator}ant-javafx.jar"/>
</target>
<target name="-check-ant-javafx-in-probjdk-lib" unless="ant-javafx.jar.location">
<condition property="do.set.ant-javafx.in.probjdk.lib">
<and>
<not><isset property="ant-javafx.jar.location"/></not>
<available file="${java.home}${file.separator}..${file.separator}lib${file.separator}ant-javafx.jar"/>
</and>
</condition>
</target>
<target name="-set-ant-javafx-in-probjdk-lib" depends="-set-ant-javafx-in-platform-home-tools,-check-ant-javafx-in-probjdk-lib" if="do.set.ant-javafx.in.probjdk.lib">
<property name="ant-javafx.jar.location" value="${java.home}${file.separator}..${file.separator}lib${file.separator}ant-javafx.jar"/>
</target>
<target name="-check-ant-javafx-in-probjdk-tools" unless="ant-javafx.jar.location">
<condition property="do.set.ant-javafx.in.probjdk.tools">
<and>
<not><isset property="ant-javafx.jar.location"/></not>
<available file="${java.home}${file.separator}..${file.separator}tools${file.separator}ant-javafx.jar"/>
</and>
</condition>
</target>
<target name="-set-ant-javafx-in-probjdk-tools" depends="-set-ant-javafx-in-probjdk-lib,-check-ant-javafx-in-probjdk-tools" if="do.set.ant-javafx.in.probjdk.tools">
<property name="ant-javafx.jar.location" value="${java.home}${file.separator}..${file.separator}tools${file.separator}ant-javafx.jar"/>
</target>
<target name="-check-ant-javafx-in-macjdk-lib" unless="ant-javafx.jar.location">
<condition property="do.set.ant-javafx.in.macjdk.lib">
<and>
<not><isset property="ant-javafx.jar.location"/></not>
<available file="${java.home}${file.separator}lib${file.separator}ant-javafx.jar"/>
</and>
</condition>
</target>
<target name="-set-ant-javafx-in-macjdk-lib" depends="-set-ant-javafx-in-probjdk-tools,-check-ant-javafx-in-macjdk-lib" if="do.set.ant-javafx.in.macjdk.lib">
<property name="ant-javafx.jar.location" value="${java.home}${file.separator}lib${file.separator}ant-javafx.jar"/>
</target>
<target name="-check-ant-javafx-in-envjdk-lib" unless="ant-javafx.jar.location">
<property environment="env"/>
<condition property="do.set.ant-javafx.in.envjdk.lib">
<and>
<not><isset property="ant-javafx.jar.location"/></not>
<available file="${env.JAVA_HOME}${file.separator}lib${file.separator}ant-javafx.jar"/>
</and>
</condition>
</target>
<target name="-set-ant-javafx-in-envjdk-lib" depends="-set-ant-javafx-in-macjdk-lib,-check-ant-javafx-in-envjdk-lib" if="do.set.ant-javafx.in.envjdk.lib">
<property name="ant-javafx.jar.location" value="${env.JAVA_HOME}${file.separator}lib${file.separator}ant-javafx.jar"/>
</target>
<target name="-check-ant-javafx-in-envjdk-tools" unless="ant-javafx.jar.location">
<property environment="env"/>
<condition property="do.set.ant-javafx.in.envjdk.tools">
<and>
<not><isset property="ant-javafx.jar.location"/></not>
<available file="${env.JAVA_HOME}${file.separator}tools${file.separator}ant-javafx.jar"/>
</and>
</condition>
</target>
<target name="-set-ant-javafx-in-envjdk-tools" depends="-set-ant-javafx-in-envjdk-lib,-check-ant-javafx-in-envjdk-tools" if="do.set.ant-javafx.in.envjdk.tools">
<property name="ant-javafx.jar.location" value="${env.JAVA_HOME}${file.separator}tools${file.separator}ant-javafx.jar"/>
</target>
<target name="-pre-check-ant-javafx-version" depends="-set-ant-javafx-in-envjdk-tools" unless="ant-javafx-version-already-checked-in-jfximpl">
<condition property="do.check.ant-javafx.version">
<and>
<isset property="ant-javafx.jar.location"/>
<not><isset property="ant-javafx-version-already-checked-in-jfximpl"/></not>
</and>
</condition>
</target>
<target name="-set-endorsed-javafx-ant-classpath" depends="-check-endorsed-javafx-ant-classpath,-pre-check-ant-javafx-version" if="endorsed-javafx-ant-classpath-available">
<property name="javafx.ant.classpath" value="${endorsed.javafx.ant.classpath}:${ant-javafx.jar.location}"/>
</target>
<target name="-set-javafx-ant-classpath" depends="-check-endorsed-javafx-ant-classpath,-pre-check-ant-javafx-version" unless="endorsed-javafx-ant-classpath-available">
<property name="javafx.ant.classpath" value="${ant-javafx.jar.location}"/>
</target>
<target name="-check-ant-javafx-version" depends="-pre-check-ant-javafx-version,
-set-endorsed-javafx-ant-classpath,-set-javafx-ant-classpath" if="do.check.ant-javafx.version">
<echo message="ant-javafx.jar.location = ${ant-javafx.jar.location}" level="verbose"/>
<echo message="javafx.ant.classpath = ${javafx.ant.classpath}" level="verbose"/>
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
uri="javafx:com.sun.javafx.tools.ant"
classpath="${javafx.ant.classpath}"/>
<condition property="have-fx-ant-init">
<typefound name="javafx:com.sun.javafx.tools.ant:init-ant"/>
</condition>
<property name="ant-javafx-version-already-checked-in-jfximpl" value="true"/>
<echo message="have-fx-ant-init = ${have-fx-ant-init}" level="verbose"/>
</target>
<target name="-check-jfx-sdk-version-old" depends="-check-ant-javafx-version" unless="have-fx-ant-init">
<property name="javafx.ant.version" value="1.0"/>
</target>
<target name="-check-jfx-sdk-version-new" depends="-check-ant-javafx-version" if="have-fx-ant-init">
<fx:init-ant/>
<condition property="have-fx-ant-api-1.1">
<!-- new features from JavaFX 2.0.2 are available in API version 1.1 or later -->
<matches pattern="1.[1-9]" string="${javafx.ant.version}"/>
</condition>
<condition property="have-fx-ant-api-1.2">
<!-- new features from JavaFX 2.2 are available in API version 1.2 or later -->
<matches pattern="1.[2-9]" string="${javafx.ant.version}"/>
</condition>
</target>
<target name="-check-jfx-sdk-version" depends="-check-jfx-sdk-version-old, -check-jfx-sdk-version-new" unless="jfx.sdk.version.checked">
<echo message="Detected JavaFX Ant API version ${javafx.ant.version}" level="info"/>
<echo message="have-fx-ant-api-1.1 = ${have-fx-ant-api-1.1}" level="verbose"/>
<echo message="have-fx-ant-api-1.2 = ${have-fx-ant-api-1.2}" level="verbose"/>
<echo message="javafx.ant.classpath = ${javafx.ant.classpath}" level="verbose"/>
<property name="jfx.sdk.version.checked" value="true"/>
</target>
<target name="-check-ant-jre-version" unless="ant-jre-version-checked-in-jfximpl">
<local name="version-output"/>
<exec executable="${java.home}${file.separator}bin${file.separator}java" outputproperty="version-output">
<arg value="-version"/>
</exec>
<echo message="version-output:${line.separator}${version-output}" level="verbose"/>
<condition property="have-ant-jre-pre7u6">
<or>
<contains string="${version-output}" substring="java version &quot;1.0"/>
<contains string="${version-output}" substring="java version &quot;1.1"/>
<contains string="${version-output}" substring="java version &quot;1.2"/>
<contains string="${version-output}" substring="java version &quot;1.3"/>
<contains string="${version-output}" substring="java version &quot;1.4"/>
<contains string="${version-output}" substring="java version &quot;1.5"/>
<contains string="${version-output}" substring="java version &quot;1.6"/>
<contains string="${version-output}" substring="java version &quot;1.7.0&quot;"/>
<contains string="${version-output}" substring="java version &quot;1.7.0_01"/>
<contains string="${version-output}" substring="java version &quot;1.7.0_02"/>
<contains string="${version-output}" substring="java version &quot;1.7.0_03"/>
<contains string="${version-output}" substring="java version &quot;1.7.0_04"/>
<contains string="${version-output}" substring="java version &quot;1.7.0_05"/>
</or>
</condition>
<property name="ant-jre-version-checked-in-jfximpl" value="true"/>
<echo message="have-ant-jre-pre7u6 = ${have-ant-jre-pre7u6}" level="verbose"/>
</target>
<!-- Native Packaging main target -->
<target name="build-native" depends="-set-do-build-native-package, -check-ant-jre-supports-native-packaging, -check-native-packager-external-tools, -fx-jar-impl, -build-native-impl, -post-build-native-cleanup"/>
<target name="build-native-noscript">
<fail message="Java Application Native Packager requires JDK JavaScript support but has not found any."/>
</target>
<target name="-check-do-jar">
<condition property="do-jar-false">
<and>
<isset property="do.jar"/>
<equals arg1="${do.jar}" arg2="false"/>
</and>
</condition>
</target>
<target name="-set-do-build-native-package">
<property name="do.build.native.package" value="true"/>
<echo message="do.build.native.package = ${do.build.native.package}" level="verbose"/>
</target>
<target name="-check-ant-jre-supports-native-packaging" depends="-check-jfx-sdk-version, -check-ant-javafx-version, -check-ant-jre-version">
<fail message="Error:${line.separator}JavaFX native packager requires NetBeans to run on JDK 1.7u6 or later !" if="have-ant-jre-pre7u6"/>
</target>
<target name="-check-native-bundling-type" depends="-check-operating-system" if="do.build.native.package">
<condition property="need.Inno.presence">
<and>
<isset property="running.on.windows"/>
<isset property="native.bundling.type"/>
<or>
<equals arg1="${native.bundling.type}" arg2="all" casesensitive="false"/>
<equals arg1="${native.bundling.type}" arg2="installer" casesensitive="false"/>
<equals arg1="${native.bundling.type}" arg2="exe" casesensitive="false"/>
</or>
</and>
</condition>
<condition property="need.WiX.presence">
<and>
<isset property="running.on.windows"/>
<isset property="native.bundling.type"/>
<or>
<equals arg1="${native.bundling.type}" arg2="all" casesensitive="false"/>
<equals arg1="${native.bundling.type}" arg2="installer" casesensitive="false"/>
<equals arg1="${native.bundling.type}" arg2="msi" casesensitive="false"/>
</or>
</and>
</condition>
<condition property="need.dpkg.presence">
<and>
<isset property="running.on.unix"/>
<isset property="native.bundling.type"/>
<or>
<equals arg1="${native.bundling.type}" arg2="deb" casesensitive="false"/>
</or>
</and>
</condition>
<condition property="need.rpmbuild.presence">
<and>
<isset property="running.on.unix"/>
<isset property="native.bundling.type"/>
<or>
<equals arg1="${native.bundling.type}" arg2="rpm" casesensitive="false"/>
</or>
</and>
</condition>
<echo message="need.Inno.presence:${need.Inno.presence}" level="verbose"/>
<echo message="need.WiX.presence:${need.WiX.presence}" level="verbose"/>
<echo message="need.dpkg.presence:${need.dpkg.presence}" level="verbose"/>
<echo message="need.rpmbuild.presence:${need.rpmbuild.presence}" level="verbose"/>
</target>
<target name="-check-Inno-presence" depends="-check-native-bundling-type" if="need.Inno.presence">
<local name="exec-output"/>
<local name="exec-error"/>
<local name="exec-result"/>
<exec executable="iscc" outputproperty="exec-output" failifexecutionfails="false" errorproperty="exec-error" resultproperty="exec-result"/>
<echo message="exec-output:${exec-output}" level="verbose"/>
<echo message="exec-error:${exec-error}" level="verbose"/>
<echo message="exec-result:${exec-result}" level="verbose"/>
<condition property="missing.Inno">
<not><and>
<contains string="${exec-output}" substring="Inno Setup"/>
<not><contains string="${exec-output}" substring="Inno Setup 1"/></not>
<not><contains string="${exec-output}" substring="Inno Setup 2"/></not>
<not><contains string="${exec-output}" substring="Inno Setup 3"/></not>
<not><contains string="${exec-output}" substring="Inno Setup 4"/></not>
</and></not>
</condition>
</target>
<target name="-check-WiX-presence" depends="-check-native-bundling-type" if="need.WiX.presence">
<local name="exec-output"/>
<local name="exec-error"/>
<local name="exec-result"/>
<exec executable="candle" outputproperty="exec-output" failifexecutionfails="false" errorproperty="exec-error" resultproperty="exec-result">
<arg value="-?"/>
</exec>
<echo message="exec-output:${exec-output}" level="verbose"/>
<echo message="exec-error:${exec-error}" level="verbose"/>
<echo message="exec-result:${exec-result}" level="verbose"/>
<condition property="missing.WiX">
<not><and>
<contains string="${exec-output}" substring="Windows Installer Xml Compiler version"/>
<not><contains string="${exec-output}" substring="Windows Installer Xml Compiler version 1"/></not>
<not><contains string="${exec-output}" substring="Windows Installer Xml Compiler version 2"/></not>
</and></not>
</condition>
</target>
<target name="-check-dpkg-presence" depends="-check-native-bundling-type" if="need.dpkg.presence">
<local name="exec.which.dpkg.result"/>
<local name="exec.which.dpkg.output"/>
<exec executable="command" failifexecutionfails="false" failonerror="false" resultproperty="exec.which.dpkg.result" outputproperty="exec.which.dpkg.output">
<arg line="-v dpkg"/>
</exec>
<condition property="missing.dpkg">
<not><and>
<isset property="exec.which.dpkg.result"/>
<equals arg1="${exec.which.dpkg.result}" arg2="0"/>
<isset property="exec.which.dpkg.output"/>
<not><equals arg1="${exec.which.dpkg.output}" arg2=""/></not>
</and></not>
</condition>
</target>
<target name="-check-rpmbuild-presence" depends="-check-native-bundling-type" if="need.rpmbuild.presence">
<local name="exec.which.rpmbuild.result"/>
<local name="exec.which.rpmbuild.output"/>
<exec executable="command" failifexecutionfails="false" failonerror="false" resultproperty="exec.which.rpmbuild.result" outputproperty="exec.which.rpmbuild.output">
<arg line="-v rpmbuild"/>
</exec>
<condition property="missing.rpmbuild">
<not><and>
<isset property="exec.which.rpmbuild.result"/>
<equals arg1="${exec.which.rpmbuild.result}" arg2="0"/>
<isset property="exec.which.rpmbuild.output"/>
<not><equals arg1="${exec.which.rpmbuild.output}" arg2=""/></not>
</and></not>
</condition>
</target>
<target name="-check-native-packager-external-tools" depends="-check-Inno-presence, -check-WiX-presence, -check-dpkg-presence, -check-rpmbuild-presence">
<property name="missing.Inno.message" value="JavaFX native packager requires external Inno Setup 5+ tools installed and included on PATH to create EXE installer. See http://www.jrsoftware.org/"/>
<property name="missing.WiX.message" value="JavaFX native packager requires external WiX 3.0+ tools installed and included on PATH to create MSI installer. See http://wix.sourceforge.net/"/>
<property name="missing.dpkg.message" value="JavaFX native packager requires Debian Packager tools to create DEB package, but dpkg could not be found."/>
<property name="missing.rpmbuild.message" value="JavaFX native packager requires RPMBuild to create RPM package, but rpmbuild could not be found."/>
<condition property="missing.Inno.WiX">
<and>
<isset property="missing.Inno"/>
<isset property="missing.WiX"/>
</and>
</condition>
<fail message="Error:${line.separator}${missing.Inno.message}${line.separator}${missing.WiX.message}" if="missing.Inno.WiX"/>
<fail message="Error:${line.separator}${missing.Inno.message}" if="missing.Inno"/>
<fail message="Error:${line.separator}${missing.WiX.message}" if="missing.WiX"/>
<fail message="Error:${line.separator}${missing.dpkg.message}" if="missing.dpkg"/>
<fail message="Error:${line.separator}${missing.rpmbuild.message}" if="missing.rpmbuild"/>
</target>
<!-- Copy dependent libraries -->
<target name="-jfx-copylibs" depends="init,compile,-pre-pre-jar,-pre-jar,-jfx-copylibs-warning" unless="fallback.no.javascript">
<jfx-copylibs-js-impl/>
</target>
<target name="-jfx-copylibs-warning" if="fallback.no.javascript">
<echo message="Warning: Dependent Libraries copy (-jfx-copylibs) skipped in fallback build mode due to JDK missing JavaScript support."/>
</target>
<macrodef name="jfx-copylibs-js-impl">
<sequential>
<local name="run.classpath.without.build.classes.and.dist.dir"/>
<pathconvert property="run.classpath.without.build.classes.and.dist.dir">
<path path="${run.classpath}"/>
<map from="${basedir}${file.separator}${build.classes.dir}" to=""/>
<map from="${basedir}${file.separator}${dist.jar}" to=""/>
<scriptmapper language="javascript">
self.addMappedName(
(source.indexOf("jfxrt.jar") >= 0) ||
(source.indexOf("deploy.jar") >= 0) ||
(source.indexOf("javaws.jar") >= 0) ||
(source.indexOf("plugin.jar") >= 0)
? "" : source
);
</scriptmapper>
</pathconvert>
<!-- add possibly missing dependencies at distance 2 (build system logic thus provides transitive closure) -->
<local name="run.and.lib.classpath"/>
<echo message="JavaScript: -jfx-copylibs" level="verbose"/>
<script language="javascript">
<![CDATA[
function prefix(s, len) {
if(s == null || len <= 0 || s.length == 0) {
return new String("");
}
return new String(s.substr(0, len));
}
function defined(s) {
return (s != null) && (s != "null") && (s.length > 0);
}
var classPath = new String(project.getProperty("run.classpath.without.build.classes.and.dist.dir"));
if(defined(classPath)) {
var fileSeparator = new String(project.getProperty("file.separator"));
var pathConvert = project.createTask("pathconvert");
pathConvert.setProperty("run.and.lib.classpath");
var classPathCopy = pathConvert.createPath();
classPathCopy.setPath(classPath);
var pathArray;
if(classPath.indexOf(";") != -1) {
pathArray = classPath.split(";");
} else {
pathArray = classPath.split(":");
}
var added = new java.lang.StringBuilder();
for (var i = 0; i < pathArray.length; i++) {
var index = pathArray[i].lastIndexOf(fileSeparator);
if (index >= 0) {
var onePath = prefix(pathArray[i], index+1).concat("lib");
var oneDir = new java.io.File(onePath);
if(oneDir.exists()) {
var fs = project.createDataType( "fileset" );
fs.setDir( oneDir );
fs.setIncludes("*.jar");
var ds = fs.getDirectoryScanner(project);
var srcFiles = ds.getIncludedFiles();
for (var j = 0; j < srcFiles.length; j++) {
if(classPath.indexOf( srcFiles[j] ) == -1 && added.indexOf( srcFiles[j] ) == -1) {
var path = pathConvert.createPath();
path.setPath( onePath.concat(fileSeparator).concat(srcFiles[j]) );
added.append( srcFiles[j] );
}
}
}
}
}
pathConvert.perform();
}
]]>
</script>
<echo message="run.and.lib.classpath = ${run.and.lib.classpath}" level="verbose"/>
<property name="run.and.lib.classpath" value=""/> <!-- fallback -->
<delete dir="${dist.dir}${file.separator}lib" includeEmptyDirs="true" quiet="true"/>
<copy todir="${dist.dir}${file.separator}lib" flatten="true" preservelastmodified="true" overwrite="true">
<path>
<pathelement path="${run.and.lib.classpath}"/>
</path>
</copy>
</sequential>
</macrodef>
<!-- <fx:jar> replacing standard jar, because native packager up to JDK7u21 refuses to package standard jars -->
<target name="-fx-jar-impl" depends="-check-jfx-sdk-version, -check-ant-javafx-version, -check-ant-jre-version, clean, compile, -jfx-copylibs">
<echo message="javafx.ant.classpath = ${javafx.ant.classpath}" level="verbose"/>
<typedef name="fx_jar" classname="com.sun.javafx.tools.ant.FXJar" classpath="${javafx.ant.classpath}"/>
<echo message="Launching &lt;fx:jar&gt; task from ${ant-javafx.jar.location}" level="info"/>
<property name="deployment.dir" location="${dist.dir}"/>
<basename property="deployment.jar" file="${dist.jar}"/>
<property name="pp_jar_destfile" value="${deployment.dir}${file.separator}${deployment.jar}"/>
<property name="pp_jar_buildclasses" value="${basedir}${file.separator}${build.classes.dir}"/>
<property name="pp_jar_dir" value="${deployment.dir}"/>
<property name="pp_jar_fs2" value="lib${file.separator}*.jar"/>
<echo message="fx_jar: pp_jar_destfile = ${pp_jar_destfile}" level="verbose"/>
<echo message="fx_jar: pp_jar_buildclasses = ${pp_jar_buildclasses}" level="verbose"/>
<echo message="fx_jar: pp_jar_dir = ${pp_jar_dir}" level="verbose"/>
<echo message="fx_jar: pp_jar_fs2 = ${pp_jar_fs2}" level="verbose"/>
<echo message="JavaScript: fx-jar" level="verbose"/>
<script language="javascript">
<![CDATA[
function isTrue(prop) {
return prop != null &&
( prop.toLowerCase() == "true" || prop.toLowerCase() == "yes" || prop.toLowerCase() == "on" );
}
function prefix(s, len) {
if(s == null || len <= 0 || s.length == 0) {
return new String("");
}
return new String(s.substr(0, len));
}
function replaceSuffix(s, os, ns) {
return prefix(s, s.indexOf(os)).concat(ns);
}
function startsWith(s, prefix) {
return (s != null) && (s.indexOf(prefix) == 0);
}
function endsWith(s, suffix) {
var i = s.lastIndexOf(suffix);
return (i != -1) && (i == (s.length - suffix.length));
}
function defined(s) {
return (s != null) && (s != "null") && (s.length > 0);
}
function contains(array, prop) {
for (var i = 0; i < array.length; i++) {
var s1 = new String(array[i]);
var s2 = new String(prop);
if( s1.toLowerCase() == s2.toLowerCase() ) {
return true;
}
}
return false;
}
var S = new String(java.io.File.separator);
var JFXLAZY = "download.mode.lazy.jar";
var fx_ant_api_1_1 = new String(project.getProperty("have-fx-ant-api-1.1"));
var fx_ant_api_1_2 = new String(project.getProperty("have-fx-ant-api-1.2"));
// get jars with lazy download mode property set
function getLazyJars() {
var jars = new Array();
var keys = project.getProperties().keys();
while(keys.hasMoreElements()) {
var pn = new String(keys.nextElement());
if(startsWith(pn, JFXLAZY)) {
var fname = new String(pn.substring(JFXLAZY.length+1));
jars.push(fname);
}
}
return jars.length > 0 ? jars : null;
}
// set download mode of dependent libraries
function setDownloadMode(fsEager, fsLazy, jars) {
for(var i = 0; i < jars.length; i++) {
fsEager.setExcludes("lib" + S + jars[i]);
fsLazy.setIncludes("lib" + S + jars[i]);
}
}
// fx:jar
var jar = project.createTask("fx_jar");
jar.setProject(project);
var destfile = new String(project.getProperty("pp_jar_destfile"));
jar.setDestfile(destfile);
// fx:application
var app = jar.createApplication();
app.setProject(project);
var title = new String(project.getProperty("application.title"));
var mainclass;
mainclass = new String(project.getProperty("main.class"));
if(isTrue(fx_ant_api_1_2)) {
app.setToolkit("swing");
}
app.setName(title);
app.setMainClass(mainclass);
var appversion = new String(project.getProperty("application.implementation.version"));
if(defined(appversion)) {
app.setVersion(appversion);
} else {
app.setVersion("1.0");
}
// fx:resources
var res = jar.createResources();
res.setProject(project);
var pdir = new String(project.getProperty("pp_jar_dir"));
var fn = res.createFileSet();
fn.setProject(project);
fn.setDir(new java.io.File(pdir));
var ia = new String(project.getProperty("deployment.jar"));
var ib = new String(project.getProperty("pp_jar_fs2"));
fn.setIncludes(ia);
fn.setIncludes(ib);
fn.setRequiredFor("startup");
var lazyjars = getLazyJars();
if(lazyjars != null) {
var fn2 = res.createFileSet();
fn2.setProject(project);
fn2.setDir(new java.io.File(pdir));
fn2.setRequiredFor("runtime");
setDownloadMode(fn,fn2,lazyjars);
}
// fileset to include classes
var fs = jar.createFileSet();
fs.setProject(project);
var buildcls = new String(project.getProperty("pp_jar_buildclasses"));
fs.setDir(new java.io.File(buildcls));
// manifest
var man = jar.createManifest();
var a1val = new String(project.getProperty("application.vendor"));
var a1 = new org.apache.tools.ant.taskdefs.Manifest.Attribute();
a1.setName("Implementation-Vendor");
a1.setValue(a1val);
man.addConfiguredAttribute(a1);
var a2val = new String(project.getProperty("application.title"));
var a2 = new org.apache.tools.ant.taskdefs.Manifest.Attribute();
a2.setName("Implementation-Title");
a2.setValue(a2val);
man.addConfiguredAttribute(a2);
if(defined(appversion)) {
var a3 = new org.apache.tools.ant.taskdefs.Manifest.Attribute();
a3.setName("Implementation-Version");
a3.setValue(appversion);
man.addConfiguredAttribute(a3);
}
var profileAvailable = new String(project.getProperty("profile.available"));
if (defined(profileAvailable)) {
var profileAttribute = new org.apache.tools.ant.taskdefs.Manifest.Attribute();
profileAttribute.setName("Profile");
profileAttribute.setValue(new String(project.getProperty("javac.profile")));
man.addConfiguredAttribute(profileAttribute);
}
var splashScreenAvailable = new String(project.getProperty("splashscreen.available"));
if (defined(splashScreenAvailable)) {
project.setProperty("deploy.splash.image",new String(project.getProperty("application.splash")));
}
jar.perform();
]]>
</script>
</target>
<!-- Native Packaging main implementation -->
<target name="-build-native-impl" depends="-check-ant-jre-supports-native-packaging, -check-native-packager-external-tools, -fx-jar-impl">
<!--<property name="runtime.jre.home" value="${platform.home}"/>-->
<echo message="javafx.ant.classpath = ${javafx.ant.classpath}" level="verbose"/>
<typedef name="fx_deploy" classname="com.sun.javafx.tools.ant.DeployFXTask" classpath="${javafx.ant.classpath}"/>
<echo message="Launching &lt;fx:deploy&gt; task from ${ant-javafx.jar.location}" level="info"/>
<property name="deployment.dir" location="${dist.dir}"/>
<property name="pp_deploy_fs2" value="lib${file.separator}*.jar"/>
<basename property="deployment.jar" file="${dist.jar}"/>
<basename property="deployment.base" file="${deployment.jar}" suffix=".jar"/>
<echo message="deploy_deploy: pp_deploy_fs2 = ${pp_deploy_fs2}" level="verbose"/>
<echo message="deploy_deploy: deployment.dir = ${deployment.dir}" level="verbose"/>
<echo message="deploy_deploy: deployment.jar = ${deployment.jar}" level="verbose"/>
<echo message="deploy_deploy: deployment.base = ${deployment.base}" level="verbose"/>
<echo message="JavaScript: deploy-deploy" level="verbose"/>
<script language="javascript">
<![CDATA[
function isTrue(prop) {
return prop != null &&
(prop.toLowerCase()=="true" || prop.toLowerCase()=="yes" || prop.toLowerCase()=="on");
}
function prefix(s, len) {
if(s == null || len <= 0 || s.length == 0) {
return new String("");
}
return new String(s.substr(0, len));
}
function replaceSuffix(s, os, ns) {
return prefix(s, s.indexOf(os)).concat(ns);
}
function startsWith(s, prefix) {
return (s != null) && (s.indexOf(prefix) == 0);
}
function endsWith(s, suffix) {
var i = s.lastIndexOf(suffix);
return (i != -1) && (i == (s.length - suffix.length));
}
function defined(s) {
return (s != null) && (s != "null") && (s.length > 0);
}
function contains(array, prop) {
for (var i = 0; i < array.length; i++) {
var s1 = new String(array[i]);
var s2 = new String(prop);
if( s1.toLowerCase() == s2.toLowerCase() ) {
return true;
}
}
return false;
}
var S = java.io.File.separator;
var JFXLAZY = "download.mode.lazy.jar";
var fx_ant_api_1_1 = new String(project.getProperty("have-fx-ant-api-1.1"));
var fx_ant_api_1_2 = new String(project.getProperty("have-fx-ant-api-1.2"));
var have_jdk_pre7u14 = new String(project.getProperty("have-jdk-pre7u14"));
// get jars with lazy download mode property set
function getLazyJars() {
var jars = new Array();
var keys = project.getProperties().keys();
while(keys.hasMoreElements()) {
var pn = new String(keys.nextElement());
if(startsWith(pn, JFXLAZY)) {
var fname = pn.substring(JFXLAZY.length+1);
jars.push(fname);
}
}
return jars.length > 0 ? jars : null;
}
// set download mode of dependent libraries
function setDownloadMode(fsEager, fsLazy, jars) {
for(var i = 0; i < jars.length; i++) {
fsEager.setExcludes("lib" + S + jars[i]);
fsLazy.setIncludes("lib" + S + jars[i]);
}
}
// convert path to absolute if relative
function derelativizePath(path) {
var f = new java.io.File(path);
if(!f.exists()) {
f = new java.io.File(new String(project.getBaseDir()) + S + path);
}
if(f.exists()) {
try {
return f.getCanonicalPath();
} catch(err) {
return path;
}
}
return path;
}
// fx:deploy
var deploy = project.createTask("fx_deploy");
deploy.setProject(project);
var width = new String(project.getProperty("javafx.width"));
var height = new String(project.getProperty("javafx.height"));
var outdir = new String(project.getProperty("deployment.dir"));
var outfile = new String(project.getProperty("application.title"));
if(!defined(width)) width=new String("0");
if(!defined(height)) height=new String("0");
deploy.setWidth(width);
deploy.setHeight(height);
deploy.setOutdir(outdir);
deploy.setOutfile(outfile);
// native packaging (time consuming, thus applied in explicit build only)
var nativeEnabled = new String(project.getProperty("do.build.native.package"));
var nativeType = new String(project.getProperty("native.bundling.type"));
var projStateRun = new String(project.getProperty("project.state.running"));
var projStateDbg = new String(project.getProperty("project.state.debugging"));
var projStatePrf = new String(project.getProperty("project.state.profiling"));
if(isTrue(nativeEnabled) && defined(nativeType) && nativeType != "none") {
if(!isTrue(projStateRun) && !isTrue(projStateDbg) && !isTrue(projStatePrf)) {
if(isTrue(fx_ant_api_1_2)) {
deploy.setNativeBundles(nativeType);
print("Note: To create native bundles the <fx:deploy> task may require external tools. See JavaFX 2.2+ documentation for details.");
print("");
print("Launching <fx:deploy> in native packager mode...");
} else {
print("Warning: Native packaging is not supported by this version of JavaFX SDK deployment Ant task. Please upgrade to JDK 7u6 or higher.");
}
}
}
// fx:application
var app = deploy.createApplication();
app.setProject(project);
var title = new String(project.getProperty("application.title"));
var mainclass;
mainclass = new String(project.getProperty("main.class"));
if(isTrue(fx_ant_api_1_2)) {
app.setToolkit("swing");
}
app.setName(title);
app.setMainClass(mainclass);
var appversion = new String(project.getProperty("application.implementation.version"));
if(defined(appversion)) {
app.setVersion(appversion);
} else {
app.setVersion("1.0");
}
// fx:resources
var res = deploy.createResources();
res.setProject(project);
var deploydir = new String(project.getProperty("deployment.dir"));
var fn = res.createFileSet();
fn.setProject(project);
fn.setDir(new java.io.File(deploydir));
var ia = new String(project.getProperty("deployment.jar"));
var ib = new String(project.getProperty("pp_deploy_fs2"));
fn.setIncludes(ia);
fn.setIncludes(ib);
fn.setRequiredFor("startup");
var lazyjars = getLazyJars();
if(lazyjars != null) {
var fn2 = res.createFileSet();
fn2.setProject(project);
fn2.setDir(new java.io.File(deploydir));
fn2.setRequiredFor("runtime");
setDownloadMode(fn,fn2,lazyjars);
}
// fx:info
var info = deploy.createInfo();
info.setProject(project);
var vendor = new String(project.getProperty("application.vendor"));
var description = new String(project.getProperty("application.desc"));
info.setTitle(title); // title known from before
info.setVendor(vendor);
info.setDescription(description);
var splash = new String(project.getProperty("deploy.splash.image"));
if(defined(splash)) {
if(isTrue(fx_ant_api_1_1)) {
var sicon = info.createSplash();
sicon.setHref(splash);
sicon.setMode("any");
print("Adding splash image reference: " + splash);
} else {
print("Warning: Splash Image not supported by this version of JavaFX SDK deployment Ant task. Please upgrade JavaFX to 2.0.2 or higher.");
}
}
if(isTrue(nativeEnabled) && defined(nativeType) && nativeType != "none") {
var icon = new String(project.getProperty("deploy.icon.native"));
if(defined(icon)) {
if(isTrue(fx_ant_api_1_2) && !isTrue(have_jdk_pre7u14)) {
var dicon = derelativizePath(icon);
// create temporary icon copy renamed to application name (required by native packager)
var baseDir = new String(project.getProperty("basedir"));
var buildDir = new String(project.getProperty("build.dir"));
var deployBase = new String(project.getProperty("deployment.base"));
var copyTask = project.createTask("copy");
var source = new java.io.File(dicon);
var sourceName = new String(source.getName());
var lastDot = sourceName.lastIndexOf(".");
var sourceExt;
if(lastDot >=0) {
sourceExt = sourceName.substr(lastDot);
} else {
sourceExt = new String("");
}
var target = new java.io.File(baseDir.concat(S).concat(buildDir).concat(S).concat("icon").concat(S).concat(deployBase).concat(sourceExt));
copyTask.setFile(source);
copyTask.setTofile(target);
copyTask.setFlatten(true);
copyTask.setFailOnError(false);
copyTask.perform();
var tempicon;
if(target.exists()) {
try {
tempicon = target.getCanonicalPath();
} catch(err) {
tempicon = dicon;
}
} else {
tempicon = dicon;
}
var nicon = info.createIcon();
nicon.setHref(tempicon);
print("Source native icon reference: " + dicon);
print("Processed native icon reference: " + tempicon);
} else {
print("Warning: Native Package icon not supported by this version of JavaFX SDK deployment Ant task. Please upgrade to JDK7u14.");
}
}
} else {
var icon = new String(project.getProperty("deploy.icon.webstart"));
if(defined(icon)) {
if(isTrue(fx_ant_api_1_1)) {
var iicon = info.createIcon();
iicon.setHref(icon);
print("Adding WebStart icon reference: " + icon);
} else {
print("Warning: WebStart Icon not supported by this version of JavaFX SDK deployment Ant task. Please upgrade JavaFX to 2.0.2 or higher.");
}
}
}
deploy.perform();
]]>
</script>
</target>
<target name="-post-build-native-cleanup">
<delete file="${dist.dir}/${application.title}.html" quiet="true"/>
<delete file="${dist.dir}/${application.title}.jnlp" quiet="true"/>
<delete file="${dist.dir}/${application.title}_browser.jnlp" quiet="true"/>
</target>
</project>

@ -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

@ -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

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

@ -0,0 +1,263 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<NonVisualComponents>
<Component class="javax.swing.JMenuItem" name="jMenuItem4">
<Properties>
<Property name="text" type="java.lang.String" value="jMenuItem4"/>
</Properties>
</Component>
<Container class="javax.swing.JMenuBar" name="jMenuBar2">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="true"/>
</Layout>
<SubComponents>
<Menu class="javax.swing.JMenu" name="jMenu3">
<Properties>
<Property name="text" type="java.lang.String" value="File"/>
</Properties>
</Menu>
<Menu class="javax.swing.JMenu" name="jMenu4">
<Properties>
<Property name="text" type="java.lang.String" value="Edit"/>
</Properties>
</Menu>
</SubComponents>
</Container>
<Menu class="javax.swing.JMenuBar" name="jMenuBar1">
<SubComponents>
<Menu class="javax.swing.JMenu" name="jMenu1">
<Properties>
<Property name="text" type="java.lang.String" value="File"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem1">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+O"/>
</Property>
<Property name="text" type="java.lang.String" value="Open..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem1ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem2">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+S"/>
</Property>
<Property name="text" type="java.lang.String" value="Save..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem2ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem3">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Shift+Ctrl+S"/>
</Property>
<Property name="text" type="java.lang.String" value="Save as..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem3ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem8">
<Properties>
<Property name="text" type="java.lang.String" value="Export..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem8ActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
<Menu class="javax.swing.JMenu" name="jMenu5">
<Properties>
<Property name="text" type="java.lang.String" value="Edit"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem6">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+W"/>
</Property>
<Property name="text" type="java.lang.String" value="Clear output"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem6ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem7">
<Properties>
<Property name="text" type="java.lang.String" value="Font size..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem7ActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
<Menu class="javax.swing.JMenu" name="jMenu2">
<Properties>
<Property name="text" type="java.lang.String" value="Run"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenu2ActionPerformed"/>
</Events>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem5">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="F5"/>
</Property>
<Property name="text" type="java.lang.String" value="Run code"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem5ActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
</SubComponents>
</Menu>
</NonVisualComponents>
<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="Editor"/>
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/net/apocalypselabs/symat/icons/editor.png"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
<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="jPanel1" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jSplitPane1" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jSplitPane1" alignment="0" pref="359" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JSplitPane" name="jSplitPane1">
<Properties>
<Property name="dividerLocation" type="int" value="275"/>
<Property name="dividerSize" type="int" value="3"/>
<Property name="orientation" type="int" value="0"/>
<Property name="resizeWeight" type="double" value="0.7"/>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="scrollPane">
<Properties>
<Property name="requestFocusEnabled" type="boolean" value="false"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new JScrollPane(codeBox)"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="top"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
</Container>
<Container class="javax.swing.JPanel" name="jPanel2">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="right"/>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="jScrollPane1" pref="524" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="72" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Output:"/>
</Properties>
</Component>
<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.JTextArea" name="outputPane">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="columns" type="int" value="20"/>
<Property name="rows" type="int" value="5"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

@ -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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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
}

@ -0,0 +1,246 @@
<?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"/>
</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" max="32767" attributes="0"/>
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jScrollPane1" pref="286" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" 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" max="-2" attributes="0">
<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"/>
</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="dateBox" max="32767" attributes="0"/>
<Component id="authBox" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace type="unrelated" 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" min="-2" pref="239" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" 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="5" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<Group type="102" 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" attributes="0">
<Group type="102" 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>
</Group>
<Component id="jScrollPane2" min="-2" pref="55" max="-2" attributes="0"/>
</Group>
</Group>
</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">
</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 as:"/>
</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="exHtml" alignment="0" max="32767" attributes="0"/>
<Component id="exPdf" 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">
<Component id="exHtml" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="exPdf" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="13" 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>
</SubComponents>
</Container>
</SubComponents>
</Form>

@ -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 = "<!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>";
}
PrettifyParser parser = new PrettifyParser();
List<ParseResult> parseResults = parser.parse("js", code);
html += PrettifyToHtml.toHtml(code, parseResults);
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\"?>", "");
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")
// <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();
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();
}// </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) {
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
}

@ -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("<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) {
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;
}
}

@ -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);
}
}

@ -0,0 +1,180 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<NonVisualComponents>
<Menu class="javax.swing.JMenuBar" name="jMenuBar1">
<SubComponents>
<Menu class="javax.swing.JMenu" name="jMenu1">
<Properties>
<Property name="text" type="java.lang.String" value="File"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem2">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+S"/>
</Property>
<Property name="text" type="java.lang.String" value="Export graph..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem2ActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
<Menu class="javax.swing.JMenu" name="jMenu2">
<Properties>
<Property name="text" type="java.lang.String" value="Edit"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem1">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+W"/>
</Property>
<Property name="text" type="java.lang.String" value="Clear Graph"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem1ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem6">
<Properties>
<Property name="text" type="java.lang.String" value="Scale..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem6ActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem3">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+T"/>
</Property>
<Property name="text" type="java.lang.String" value="Set Title..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem3ActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
<Menu class="javax.swing.JMenu" name="scaleLbl">
<Properties>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="0" id="blue" palette="1" red="0" type="palette"/>
</Property>
<Property name="text" type="java.lang.String" value="Scale: 1 to 1"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
</Menu>
</SubComponents>
</Menu>
</NonVisualComponents>
<Properties>
<Property name="closable" type="boolean" value="true"/>
<Property name="defaultCloseOperation" type="int" value="1"/>
<Property name="iconifiable" type="boolean" value="true"/>
<Property name="title" type="java.lang.String" value="Graph"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/net/apocalypselabs/symat/icons/graph.png"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<Events>
<EventHandler event="mouseDragged" listener="java.awt.event.MouseMotionListener" parameters="java.awt.event.MouseEvent" handler="formMouseDragged"/>
<EventHandler event="mouseMoved" listener="java.awt.event.MouseMotionListener" parameters="java.awt.event.MouseEvent" handler="formMouseMoved"/>
<EventHandler event="componentMoved" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="formComponentMoved"/>
<EventHandler event="componentShown" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="formComponentShown"/>
</Events>
<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">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="inBox" min="-2" pref="215" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="gLbl" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="gLbl" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="inBox" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JTextField" name="inBox">
<Events>
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="inBoxKeyTyped"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="f(x)="/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="&gt;&gt;"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="gLbl">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[300, 300]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[300, 300]"/>
</Property>
<Property name="opaque" type="boolean" value="true"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[300, 300]"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Form>

@ -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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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
}

@ -0,0 +1,110 @@
<?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="Help"/>
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/net/apocalypselabs/symat/icons/help.png"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<Events>
<EventHandler event="componentShown" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="formComponentShown"/>
</Events>
<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="jSplitPane1" alignment="0" pref="394" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jSplitPane1" alignment="0" pref="278" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JSplitPane" name="jSplitPane1">
<Properties>
<Property name="dividerLocation" type="int" value="100"/>
<Property name="dividerSize" type="int" value="3"/>
<Property name="resizeWeight" type="double" value="0.1"/>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="left"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JList" name="topicList">
<Properties>
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
<StringArray count="6">
<StringItem index="0" value="Welcome"/>
<StringItem index="1" value="Basics"/>
<StringItem index="2" value="Editor"/>
<StringItem index="3" value="Graphing"/>
<StringItem index="4" value="Commands"/>
<StringItem index="5" value="Licenses"/>
</StringArray>
</Property>
<Property name="selectionMode" type="int" value="0"/>
</Properties>
<Events>
<EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="topicListValueChanged"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="right"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JEditorPane" name="topicBrowser">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="contentType" type="java.lang.String" value="text/html" noResource="true"/>
<Property name="text" type="java.lang.String" value="&lt;html&gt;&#xd;&#xa; &lt;head&gt;&#xd;&#xa;&#xd;&#xa; &lt;/head&gt;&#xd;&#xa; &lt;body&gt;&#xd;&#xa; &lt;p style=&quot;margin-top: 0&quot;&gt;&#xd;&#xa; &#xd;Hi there&#xa; &lt;/p&gt;&#xd;&#xa; &lt;/body&gt;&#xd;&#xa;&lt;/html&gt;&#xd;&#xa;"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

@ -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("<html><head></head><body><p><b>Error:</b><br>Cannot get help topic \""
+name+"\".<br>("+e.getMessage()+")</p></body></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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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("<html>\r\n <head>\r\n\r\n </head>\r\n <body>\r\n <p style=\"margin-top: 0\">\r\n \rHi there\n </p>\r\n </body>\r\n</html>\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();
}// </editor-fold>//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
}

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<NonVisualComponents>
<Menu class="javax.swing.JMenuBar" name="jMenuBar1">
<SubComponents>
<Menu class="javax.swing.JMenu" name="jMenu2">
<Properties>
<Property name="text" type="java.lang.String" value="Edit"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem1">
<Properties>
<Property name="text" type="java.lang.String" value="Font size..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem1ActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
</SubComponents>
</Menu>
</NonVisualComponents>
<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="Shell"/>
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/net/apocalypselabs/symat/icons/shell.png"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
<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="422" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jTextField1" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" 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="231" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jButton1" min="-2" pref="26" max="-2" attributes="0"/>
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
<Component id="jLabel1" alignment="0" max="32767" attributes="0"/>
<Component id="jTextField1" alignment="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace min="2" pref="2" 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.JTextArea" name="jTextArea1">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="columns" type="int" value="20"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Courier New" size="15" style="0"/>
</Property>
<Property name="rows" type="int" value="5"/>
<Property name="tabSize" type="int" value="4"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="DefaultCaret caret = (DefaultCaret)jTextArea1.getCaret();&#xd;&#xa;caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JTextField" name="jTextField1">
<Events>
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="jTextField1KeyTyped"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="Run"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="&gt;&gt;"/>
</Properties>
</Component>
</SubComponents>
</Form>

@ -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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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
}

@ -0,0 +1,169 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="APP_NAME" type="code"/>
</Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<Events>
<EventHandler event="componentShown" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="formComponentShown"/>
</Events>
<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="mainPane" max="32767" attributes="0"/>
<Component id="jToolBar1" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jToolBar1" min="-2" pref="63" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="mainPane" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JDesktopPane" name="mainPane">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="690" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="416" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Container class="javax.swing.JToolBar" name="jToolBar1">
<Properties>
<Property name="floatable" type="boolean" value="false"/>
<Property name="rollover" type="boolean" value="true"/>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
<SubComponents>
<Component class="javax.swing.JButton" name="shellBtn">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/net/apocalypselabs/symat/shell.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Shell"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.SoftBevelBorderInfo">
<BevelBorder/>
</Border>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="opaque" type="boolean" value="false"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="shellBtnActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="editorBtn">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/net/apocalypselabs/symat/editor.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Editor"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.SoftBevelBorderInfo">
<BevelBorder/>
</Border>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="opaque" type="boolean" value="false"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="editorBtnActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="graphBtn">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/net/apocalypselabs/symat/graph.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Graph"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.SoftBevelBorderInfo">
<BevelBorder/>
</Border>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="opaque" type="boolean" value="false"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="graphBtnActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="helpBtn">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/net/apocalypselabs/symat/help.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Help"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.SoftBevelBorderInfo">
<BevelBorder/>
</Border>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="opaque" type="boolean" value="false"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="helpBtnActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="&quot;&lt;html&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=\&quot;color: gray; font-size: 130%;\&quot;&gt;&lt;i&gt;&quot;+APP_NAME+&quot;&lt;/i&gt;&lt;/span&gt;&quot;" type="code"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

@ -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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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("<html>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: gray; font-size: 130%;\"><i>"+APP_NAME+"</i></span>");
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();
}// </editor-fold>//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 */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* 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);
}
//</editor-fold>
//</editor-fold>
/* 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
}

@ -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);
}
}

@ -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<ParseResult> parseResults) {
int endIndex = 0;
StringBuilder sb = new StringBuilder();
sb.append("<div class=\"" + MAIN_CLASS + "\">");
sb.append("<pre>");
for (ParseResult pr : parseResults) {
int startIndex = pr.getOffset();
if(startIndex > endIndex) {
sb.append(content.substring(endIndex, startIndex));
}
endIndex = startIndex + pr.getLength();
sb.append("<span class=\""+pr.getStyleKeysString()+"\">");
sb.append(content.substring(startIndex, endIndex));
sb.append("</span>");
}
if(content.length() > endIndex) {
sb.append(content.substring(endIndex, content.length()));
}
sb.append("</pre>");
sb.append("</div>");
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<String, Style> 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 + "; ");
}
}
}

@ -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<String, FontMetrics> 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:
* <ul>
* <li>TextLineNumber.LEFT
* <li>TextLineNumber.CENTER
* <li>TextLineNumber.RIGHT (default)
* </ul>
*
* @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<String, FontMetrics>();
}
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();
}
}
}
}

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="closable" type="boolean" value="true"/>
<Property name="title" type="java.lang.String" value="Update SyMAT"/>
<Property name="frameIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/net/apocalypselabs/symat/icons/update.png"/>
</Property>
<Property name="layer" type="int" value="100"/>
</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="jLabel1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel2" alignment="1" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel4" min="-2" pref="180" max="-2" attributes="0"/>
<EmptySpace pref="50" max="32767" attributes="0"/>
<Component id="jLabel3" min="-2" pref="180" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="99" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" pref="212" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="65" max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" pref="88" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" pref="49" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jLabel4" pref="46" max="32767" attributes="0"/>
<Component id="jLabel3" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jButton1" pref="66" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="24" style="0"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="An update is available."/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/net/apocalypselabs/symat/icon.png"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="18" style="0"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="&quot;Latest version: &quot;+String.valueOf(latestVersion)" type="code"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="18" style="0"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="&quot;Your version: &quot;+String.valueOf(MainGUI.APP_CODE)" type="code"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="99" red="33" type="rgb"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="18" style="3"/>
</Property>
<Property name="text" type="java.lang.String" value="Download"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" value="Ignore"/>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jLabel5MouseClicked"/>
</Events>
</Component>
</SubComponents>
</Form>

@ -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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//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
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 972 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

@ -0,0 +1,12 @@
<html>
<head>
<title>Basics</title>
</head>
<body>
<h1>Getting Started</h1>
<p>Open a new shell by clicking the button.
<br>Try typing commands, like "2*2" or "sin[.5]".
<br>You can make variables too, try "x=.5" then "sin[x]".
<br><br><i>Fun fact: You can use the Enter key OR the run button to run the command!</i></p>
</body>
</html>

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

@ -0,0 +1,12 @@
<html>
<head>
<title>Editor</title>
</head>
<body>
<h1>Code Editor</h1>
<p>You can write code here. This code will be run all at once.
<br>You can even open and save code files.
<br>Press F5 to run your script.
Whatever it spits out will appear in the Output box.</p>
</body>
</html>

@ -0,0 +1,14 @@
<html>
<head>
<title>Graphing</title>
</head>
<body>
<h1>Graphing</h1>
<p>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.</p>
<p>Pretty much, if you want to graph "y=32*x", enter "32*x".</p>
<p><i>Protip: You can save your cool graphs as a
picture without using a camera, check it out!</i></p>
</body>
</html>

@ -0,0 +1,898 @@
<html>
<head>
<title>Licenses</title>
</head>
<body>
<h1>Licenses</h1>
<p>This application uses libraries from third-parties.</p>
<p><b>Symja (parser), log4j, Java-Prettify:</b></p>
<pre>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.</pre>
<p><b>HtmlCleaner</b></p>
<pre>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.
</pre>
<p><b>iTextPDF, Symja (core):</b></p>
<pre> 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.
</pre>
<p><br></p>
<pre> GNU 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.
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.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 <http://www.gnu.org/licenses/>.
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:
<program> Copyright (C) <year> <name of author>
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
<http://www.gnu.org/licenses/>.
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
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
</pre>
</body>
</html>

@ -0,0 +1,12 @@
<html>
<head>
<title>Welcome!</title>
</head>
<body>
<h1>Welcome to SyMAT!</h1>
<p>SyMAT is a Java-based algebra and calculus system.
Scripts and commands are in JavaScript.</p>
<p><b>License:</b><br>
SyMAT is licensed under the GNU Lesser General Public License.</p>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

@ -0,0 +1,23 @@
.header {
}
.com {
color: green;
}
.kwd {
color: blue;
}
.pln {
color: black;
}
.lit {
color: #0099cc;
}
.pun {
color: black;
font-weight: bold;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Loading…
Cancel
Save