From: Harvie Date: Mon, 24 May 2010 21:44:24 +0000 (+0200) Subject: Some booring school homeworks in java X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=2623b47bd3bb0e632812259a6c639ed1eda4f222;p=mirrors%2FPrograms.git Some booring school homeworks in java --- diff --git a/java/Kalkulator/applet.policy b/java/Kalkulator/applet.policy new file mode 100644 index 0000000..53a9d40 --- /dev/null +++ b/java/Kalkulator/applet.policy @@ -0,0 +1,3 @@ +grant { +permission java.security.AllPermission; +}; diff --git a/java/Kalkulator/build.xml b/java/Kalkulator/build.xml new file mode 100644 index 0000000..82680c6 --- /dev/null +++ b/java/Kalkulator/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + Builds, tests, and runs the project Kalkulator. + + + diff --git a/java/Kalkulator/build/built-jar.properties b/java/Kalkulator/build/built-jar.properties new file mode 100644 index 0000000..220f5f8 --- /dev/null +++ b/java/Kalkulator/build/built-jar.properties @@ -0,0 +1,2 @@ +#Fri Apr 02 01:58:29 CEST 2010 +/home/harvie/Work/NetBeansProjects/Kalkulator= diff --git a/java/Kalkulator/build/classes/.netbeans_automatic_build b/java/Kalkulator/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/java/Kalkulator/build/classes/Kalkulator/AppGui$1.class b/java/Kalkulator/build/classes/Kalkulator/AppGui$1.class new file mode 100644 index 0000000..5dc4551 Binary files /dev/null and b/java/Kalkulator/build/classes/Kalkulator/AppGui$1.class differ diff --git a/java/Kalkulator/build/classes/Kalkulator/AppGui.class b/java/Kalkulator/build/classes/Kalkulator/AppGui.class new file mode 100644 index 0000000..12986f3 Binary files /dev/null and b/java/Kalkulator/build/classes/Kalkulator/AppGui.class differ diff --git a/java/Kalkulator/build/classes/Kalkulator/Kalkulator.class b/java/Kalkulator/build/classes/Kalkulator/Kalkulator.class new file mode 100644 index 0000000..1f9e72f Binary files /dev/null and b/java/Kalkulator/build/classes/Kalkulator/Kalkulator.class differ diff --git a/java/Kalkulator/build/classes/Kalkulator/Kalkulator.html b/java/Kalkulator/build/classes/Kalkulator/Kalkulator.html new file mode 100644 index 0000000..be83f3c --- /dev/null +++ b/java/Kalkulator/build/classes/Kalkulator/Kalkulator.html @@ -0,0 +1,28 @@ + + + Applet HTML Page + + + + + +


Applet HTML Page

+ +

+ +

+ +
Generated by NetBeans IDE + + diff --git a/java/Kalkulator/build/classes/Kalkulator/Kalkulator.rs b/java/Kalkulator/build/classes/Kalkulator/Kalkulator.rs new file mode 100644 index 0000000..936eb8a --- /dev/null +++ b/java/Kalkulator/build/classes/Kalkulator/Kalkulator.rs @@ -0,0 +1,3 @@ +Kalkulator.AppGui$1 +Kalkulator.AppGui +Kalkulator.Kalkulator diff --git a/java/Kalkulator/dist/Kalkulator.jar b/java/Kalkulator/dist/Kalkulator.jar new file mode 100644 index 0000000..59b6f72 Binary files /dev/null and b/java/Kalkulator/dist/Kalkulator.jar differ diff --git a/java/Kalkulator/dist/README.TXT b/java/Kalkulator/dist/README.TXT new file mode 100644 index 0000000..794dcf6 --- /dev/null +++ b/java/Kalkulator/dist/README.TXT @@ -0,0 +1,33 @@ +======================== +BUILD OUTPUT DESCRIPTION +======================== + +When you build an Java application project that has a main class, the IDE +automatically copies all of the JAR +files on the projects classpath to your projects dist/lib folder. The IDE +also adds each of the JAR files to the Class-Path element in the application +JAR files manifest file (MANIFEST.MF). + +To run the project from the command line, go to the dist folder and +type the following: + +java -jar "Kalkulator.jar" + +To distribute this project, zip up the dist folder (including the lib folder) +and distribute the ZIP file. + +Notes: + +* If two JAR files on the project classpath have the same name, only the first +JAR file is copied to the lib folder. +* Only JAR files are copied to the lib folder. +If the classpath contains other types of files or folders, none of the +classpath elements are copied to the lib folder. In such a case, +you need to copy the classpath elements to the lib folder manually after the build. +* If a library on the projects classpath also has a Class-Path element +specified in the manifest,the content of the Class-Path element has to be on +the projects runtime path. +* To set a main class in a standard Java project, right-click the project node +in the Projects window and choose Properties. Then click Run and enter the +class name in the Main Class field. Alternatively, you can manually type the +class name in the manifest Main-Class element. diff --git a/java/Kalkulator/manifest.mf b/java/Kalkulator/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/java/Kalkulator/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/java/Kalkulator/nbproject/build-impl.xml b/java/Kalkulator/nbproject/build-impl.xml new file mode 100644 index 0000000..78f1007 --- /dev/null +++ b/java/Kalkulator/nbproject/build-impl.xml @@ -0,0 +1,805 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/Kalkulator/nbproject/genfiles.properties b/java/Kalkulator/nbproject/genfiles.properties new file mode 100644 index 0000000..6577b61 --- /dev/null +++ b/java/Kalkulator/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=d9ae5764 +build.xml.script.CRC32=788da26d +build.xml.stylesheet.CRC32=958a1d3e@1.32.1.45 +# 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=d9ae5764 +nbproject/build-impl.xml.script.CRC32=81593c81 +nbproject/build-impl.xml.stylesheet.CRC32=576378a2@1.32.1.45 diff --git a/java/Kalkulator/nbproject/private/private.properties b/java/Kalkulator/nbproject/private/private.properties new file mode 100644 index 0000000..f76702a --- /dev/null +++ b/java/Kalkulator/nbproject/private/private.properties @@ -0,0 +1,3 @@ +compile.on.save=true +jaxbwiz.endorsed.dirs=/usr/share/netbeans/ide12/modules/ext/jaxb/api +user.properties.file=/home/harvie/.netbeans/6.8/build.properties diff --git a/java/Kalkulator/nbproject/private/private.xml b/java/Kalkulator/nbproject/private/private.xml new file mode 100644 index 0000000..c1f155a --- /dev/null +++ b/java/Kalkulator/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/java/Kalkulator/nbproject/project.properties b/java/Kalkulator/nbproject/project.properties new file mode 100644 index 0000000..bc789c8 --- /dev/null +++ b/java/Kalkulator/nbproject/project.properties @@ -0,0 +1,63 @@ +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} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/Kalkulator.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.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= +jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api" +main.class=Kalkulator.Kalkulator +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +platform.active=default_platform +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 +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs=-Djava.security.policy=applet.policy +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/java/Kalkulator/nbproject/project.xml b/java/Kalkulator/nbproject/project.xml new file mode 100644 index 0000000..e79652d --- /dev/null +++ b/java/Kalkulator/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + Kalkulator + + + + + + + + + diff --git a/java/Kalkulator/src/Kalkulator/Kalkulator.html b/java/Kalkulator/src/Kalkulator/Kalkulator.html new file mode 100644 index 0000000..be83f3c --- /dev/null +++ b/java/Kalkulator/src/Kalkulator/Kalkulator.html @@ -0,0 +1,28 @@ + + + Applet HTML Page + + + + + +


Applet HTML Page

+ +

+ +

+ +
Generated by NetBeans IDE + + diff --git a/java/Kalkulator/src/Kalkulator/Kalkulator.java b/java/Kalkulator/src/Kalkulator/Kalkulator.java new file mode 100644 index 0000000..4424fee --- /dev/null +++ b/java/Kalkulator/src/Kalkulator/Kalkulator.java @@ -0,0 +1,63 @@ +package Kalkulator; + +import javax.swing.*; + +/** + * This example shows how to create GUI application which can be run both + * as HTML embeded web applet and as standalone application + * @author harvie + */ + +class AppGui extends JPanel { + AppGui() { + setLayout(new java.awt.GridLayout(0, 2)); + + JLabel lblVklad = new JLabel("vklad"); + final JTextField txtVklad = new JTextField(); + + JLabel lblMira = new JLabel("urok. mira"); + final JTextField txtMira = new JTextField(); + + JLabel lblRoky = new JLabel("pocet let"); + final JTextField txtRoky = new JTextField(); + + JButton btnGo = new JButton("Go"); + final JLabel lblCelkem = new JLabel("zadej data"); + + add(lblVklad); + add(txtVklad); + add(lblMira); + add(txtMira); + add(lblRoky); + add(txtRoky); + add(btnGo); + add(lblCelkem); + + btnGo.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + double v = new Double(txtVklad.getText()); + double u = new Double(txtMira.getText()); + double r = new Double(txtRoky.getText()); + for(;r>0;r--) v += v*(u/100); + lblCelkem.setText(v+""); + } + }); + } +} + +public class Kalkulator extends JApplet { + + public void init() { + getContentPane().add(new AppGui()); + } + + public static void main(String[] args) { + JFrame f = new JFrame("Applet window"); + f.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + f.setSize(640,480); + f.getContentPane().add(new AppGui()); + f.setVisible(true); + } + + // TODO overwrite start(), stop() and destroy() methods +} diff --git a/java/SinusDiff/applet.policy b/java/SinusDiff/applet.policy new file mode 100644 index 0000000..53a9d40 --- /dev/null +++ b/java/SinusDiff/applet.policy @@ -0,0 +1,3 @@ +grant { +permission java.security.AllPermission; +}; diff --git a/java/SinusDiff/build.xml b/java/SinusDiff/build.xml new file mode 100644 index 0000000..9bd5267 --- /dev/null +++ b/java/SinusDiff/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + Builds, tests, and runs the project SinusDiff. + + + diff --git a/java/SinusDiff/build/built-jar.properties b/java/SinusDiff/build/built-jar.properties new file mode 100644 index 0000000..61c5934 --- /dev/null +++ b/java/SinusDiff/build/built-jar.properties @@ -0,0 +1,2 @@ +#Thu Apr 29 12:52:30 CEST 2010 +/home/harvie/Work/NetBeansProjects/SinusDiff= diff --git a/java/SinusDiff/build/classes/SinusDiff/AppGui$1.class b/java/SinusDiff/build/classes/SinusDiff/AppGui$1.class new file mode 100644 index 0000000..447f764 Binary files /dev/null and b/java/SinusDiff/build/classes/SinusDiff/AppGui$1.class differ diff --git a/java/SinusDiff/build/classes/SinusDiff/AppGui.class b/java/SinusDiff/build/classes/SinusDiff/AppGui.class new file mode 100644 index 0000000..7145043 Binary files /dev/null and b/java/SinusDiff/build/classes/SinusDiff/AppGui.class differ diff --git a/java/SinusDiff/build/classes/SinusDiff/Kalkulator.html b/java/SinusDiff/build/classes/SinusDiff/Kalkulator.html new file mode 100644 index 0000000..219ee4a --- /dev/null +++ b/java/SinusDiff/build/classes/SinusDiff/Kalkulator.html @@ -0,0 +1,28 @@ + + + Applet HTML Page + + + + + +


Applet HTML Page

+ +

+ +

+ +
Generated by NetBeans IDE + + diff --git a/java/SinusDiff/build/classes/SinusDiff/SinusDiff.class b/java/SinusDiff/build/classes/SinusDiff/SinusDiff.class new file mode 100644 index 0000000..63709d3 Binary files /dev/null and b/java/SinusDiff/build/classes/SinusDiff/SinusDiff.class differ diff --git a/java/SinusDiff/build/classes/SinusDiff/SinusDiff.html b/java/SinusDiff/build/classes/SinusDiff/SinusDiff.html new file mode 100644 index 0000000..f34c0ef --- /dev/null +++ b/java/SinusDiff/build/classes/SinusDiff/SinusDiff.html @@ -0,0 +1,36 @@ + + + Applet HTML Page + + + + + + +


Applet HTML Page

+ +

+ + + +

+ +
Generated by NetBeans IDE + + diff --git a/java/SinusDiff/manifest.mf b/java/SinusDiff/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/java/SinusDiff/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/java/SinusDiff/nbproject/build-impl.xml b/java/SinusDiff/nbproject/build-impl.xml new file mode 100644 index 0000000..e176802 --- /dev/null +++ b/java/SinusDiff/nbproject/build-impl.xml @@ -0,0 +1,805 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/SinusDiff/nbproject/genfiles.properties b/java/SinusDiff/nbproject/genfiles.properties new file mode 100644 index 0000000..e332e71 --- /dev/null +++ b/java/SinusDiff/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=a1f39a06 +build.xml.script.CRC32=ce5cf40d +build.xml.stylesheet.CRC32=958a1d3e@1.32.1.45 +# 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=a1f39a06 +nbproject/build-impl.xml.script.CRC32=16412c3d +nbproject/build-impl.xml.stylesheet.CRC32=576378a2@1.32.1.45 diff --git a/java/SinusDiff/nbproject/private/private.properties b/java/SinusDiff/nbproject/private/private.properties new file mode 100644 index 0000000..9df8488 --- /dev/null +++ b/java/SinusDiff/nbproject/private/private.properties @@ -0,0 +1,2 @@ +jaxbwiz.endorsed.dirs=/usr/share/netbeans/ide12/modules/ext/jaxb/api +user.properties.file=/home/harvie/.netbeans/6.8/build.properties diff --git a/java/SinusDiff/nbproject/private/private.xml b/java/SinusDiff/nbproject/private/private.xml new file mode 100644 index 0000000..c1f155a --- /dev/null +++ b/java/SinusDiff/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/java/SinusDiff/nbproject/project.properties b/java/SinusDiff/nbproject/project.properties new file mode 100644 index 0000000..7154f85 --- /dev/null +++ b/java/SinusDiff/nbproject/project.properties @@ -0,0 +1,63 @@ +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} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/SinusDiff.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.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= +jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api" +main.class=SinusDiff.SinusDiff +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +platform.active=default_platform +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 +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs=-Djava.security.policy=applet.policy +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/java/SinusDiff/nbproject/project.xml b/java/SinusDiff/nbproject/project.xml new file mode 100644 index 0000000..cec38ba --- /dev/null +++ b/java/SinusDiff/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + SinusDiff + + + + + + + + + diff --git a/java/SinusDiff/src/SinusDiff/SinusDiff.html b/java/SinusDiff/src/SinusDiff/SinusDiff.html new file mode 100644 index 0000000..f34c0ef --- /dev/null +++ b/java/SinusDiff/src/SinusDiff/SinusDiff.html @@ -0,0 +1,36 @@ + + + Applet HTML Page + + + + + + +


Applet HTML Page

+ +

+ + + +

+ +
Generated by NetBeans IDE + + diff --git a/java/SinusDiff/src/SinusDiff/SinusDiff.java b/java/SinusDiff/src/SinusDiff/SinusDiff.java new file mode 100644 index 0000000..65adc8a --- /dev/null +++ b/java/SinusDiff/src/SinusDiff/SinusDiff.java @@ -0,0 +1,134 @@ +package SinusDiff; + +import static java.lang.Math.*; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.*; +import java.awt.*; + +/** + * This example shows how to create GUI application which can be run both + * as HTML embeded web applet and as standalone application + * @author harvie + */ +class AppGui extends JPanel implements Runnable { + + double offA=0,offB=0, + speedA=50,speedB=-55, + freqA=25,freqB=35; + + @Override + public void paint(Graphics g) { + /* + Graphics2D g2D = (Graphics2D) g; // cast to 2D + g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + */ + + g.setColor(Color.BLACK); + g.fillRect(0, 0, getWidth(), getHeight()); + g.setColor(Color.GREEN); + //g.setXORMode(Color.GREEN); + + int mid = round(getHeight()/2); + int y1,y2; + for(int x = 0;x<=getWidth();x++) { + y1=(int)round(mid+mid*sin((double)(x+offA)/freqA)); + y2=(int)round(mid+mid*sin((double)(x+offB)/freqB)); + g.drawLine(x,y1,x,y2); + } + } + + int fps = 24; + + synchronized public void run() { + System.out.println("FPS::: "+fps); + while(true) { + try { + Thread.sleep(round(1000 / fps)); + } catch (InterruptedException ex) { + Logger.getLogger(AppGui.class.getName()).log(Level.SEVERE, null, ex); + } + offA += round(speedA/fps); + offB += round(speedB/fps); + this.repaint(); + } + } + + Thread t = null; + + AppGui(int fps) { + this.fps = fps; + this.setDoubleBuffered(true); + + t = new Thread(this); + t.start(); + } + + AppGui() { + this(20); + } + + AppGui(String fps) { + this(new Integer(fps)!=null?(int)new Integer(fps):20); + System.out.println("Setting FPS from string: "+fps); + } + + synchronized public void start() throws InterruptedException { + notifyAll(); + } + + public void stop() throws InterruptedException { + t.wait(); + } + + public void destroy() { + this.setVisible(false); + t.interrupt(); + } + +} + +public class SinusDiff extends JApplet { + + static AppGui appGui = null; + + @Override + public void init() { + appGui = new AppGui(getParameter("fps")); + getContentPane().add(appGui); + } + + public static void main(String[] args) { + JFrame f = new JFrame("Applet window"); + f.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + f.setSize(640, 480); + appGui = new AppGui(args.length > 0?args[0]:"20"); + f.getContentPane().add(appGui); + f.setVisible(true); + } + + // TODO overwrite start(), stop() and destroy() methods + @Override + public void start() { + try { + appGui.start(); + } catch (InterruptedException ex) { + Logger.getLogger(SinusDiff.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @Override + public void stop() { + try { + appGui.stop(); + } catch (InterruptedException ex) { + Logger.getLogger(SinusDiff.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @Override + public void destroy() { + appGui.destroy(); + } +}