diff --git a/.gitignore b/.gitignore
index 9154f4c..5016647 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,26 +1,3 @@
-# ---> Java
-# Compiled class file
-*.class
-
-# Log file
-*.log
-
-# BlueJ files
-*.ctxt
-
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-
-# Package Files #
-*.jar
-*.war
-*.nar
-*.ear
-*.zip
-*.tar.gz
-*.rar
-
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid*
-replay_pid*
-
+/build
+/dist
+/nbproject/private
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..da98a56
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+E:\Avans\OGP1\TMCProjects\2017_avans_ti_breda-2D_Graphics-2019\week3-005.Screensaver
\ No newline at end of file
diff --git a/.idea/artifacts/week3_005_Screensaver_jar.xml b/.idea/artifacts/week3_005_Screensaver_jar.xml
new file mode 100644
index 0000000..7089146
--- /dev/null
+++ b/.idea/artifacts/week3_005_Screensaver_jar.xml
@@ -0,0 +1,15 @@
+
+
+ $PROJECT_DIR$/out/artifacts/week3_005_Screensaver_jar
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..15a15b2
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
new file mode 100644
index 0000000..1ed91d0
--- /dev/null
+++ b/.idea/libraries/lib.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/tmc_junit_runner.xml b/.idea/libraries/tmc_junit_runner.xml
new file mode 100644
index 0000000..e93e952
--- /dev/null
+++ b/.idea/libraries/tmc_junit_runner.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..0548357
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..3f7a447
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/week3_005_Screensaver.xml b/.idea/runConfigurations/week3_005_Screensaver.xml
new file mode 100644
index 0000000..56528c4
--- /dev/null
+++ b/.idea/runConfigurations/week3_005_Screensaver.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..e96534f
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..caa3b75
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,143 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1582272091452
+
+
+ 1582272091452
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build.xml b/build.xml
new file mode 100644
index 0000000..c576d53
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project 001.Moon.
+
+
+
diff --git a/lib/edu-test-utils-0.4.2.jar b/lib/edu-test-utils-0.4.2.jar
new file mode 100644
index 0000000..5585edb
Binary files /dev/null and b/lib/edu-test-utils-0.4.2.jar differ
diff --git a/lib/fxgraphics2d-1.9.jar b/lib/fxgraphics2d-1.9.jar
new file mode 100644
index 0000000..14955cc
Binary files /dev/null and b/lib/fxgraphics2d-1.9.jar differ
diff --git a/lib/hamcrest-core-1.3.jar b/lib/hamcrest-core-1.3.jar
new file mode 100644
index 0000000..9d5fe16
Binary files /dev/null and b/lib/hamcrest-core-1.3.jar differ
diff --git a/lib/junit-4.11.jar b/lib/junit-4.11.jar
new file mode 100644
index 0000000..aaf7444
Binary files /dev/null and b/lib/junit-4.11.jar differ
diff --git a/lib/testfx-core-4.0.13-alpha.jar b/lib/testfx-core-4.0.13-alpha.jar
new file mode 100644
index 0000000..6d1f707
Binary files /dev/null and b/lib/testfx-core-4.0.13-alpha.jar differ
diff --git a/lib/testfx-junit-4.0.13-alpha.jar b/lib/testfx-junit-4.0.13-alpha.jar
new file mode 100644
index 0000000..dc04044
Binary files /dev/null and b/lib/testfx-junit-4.0.13-alpha.jar differ
diff --git a/lib/testrunner/tmc-junit-runner.jar b/lib/testrunner/tmc-junit-runner.jar
new file mode 100644
index 0000000..0313ece
Binary files /dev/null and b/lib/testrunner/tmc-junit-runner.jar differ
diff --git a/manifest.mf b/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml
new file mode 100644
index 0000000..e54d800
--- /dev/null
+++ b/nbproject/build-impl.xml
@@ -0,0 +1,1420 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nbproject/build-impl.xml~ b/nbproject/build-impl.xml~
new file mode 100644
index 0000000..49643a2
--- /dev/null
+++ b/nbproject/build-impl.xml~
@@ -0,0 +1,1042 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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 set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+
+
+
+
+
+ java -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 one file in the IDE or set profile.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/nbproject/genfiles.properties b/nbproject/genfiles.properties
new file mode 100644
index 0000000..ecdd6af
--- /dev/null
+++ b/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=c2a9ffde
+build.xml.script.CRC32=8bda9acc
+build.xml.stylesheet.CRC32=28e38971@1.44.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=aa12f475
+nbproject/build-impl.xml.script.CRC32=0e6a05f2
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/nbproject/project.properties b/nbproject/project.properties
new file mode 100644
index 0000000..74af0db
--- /dev/null
+++ b/nbproject/project.properties
@@ -0,0 +1,98 @@
+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.title=005.Screensaver
+application.vendor=
+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}
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/005.Screensaver.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
+excludes=
+file.reference.fxgraphics2d-1.9.jar-1=lib/fxgraphics2d-1.9.jar
+file.reference.testfx-core-4.0.13-alpha.jar=lib/testfx-core-4.0.13-alpha.jar
+file.reference.testfx-junit-4.0.13-alpha.jar=lib/testfx-junit-4.0.13-alpha.jar
+file.reference.fxgraphics2d-1.9.jar=lib/fxgraphics2d-1.5.jar
+file.reference.edu-test-utils-0.4.2.jar=lib/edu-test-utils-0.4.2.jar
+file.reference.junit-4.11.jar=lib/junit-4.11.jar
+file.reference.hamcrest-core-1.3.jar=lib/hamcrest-core-1.3.jar
+includes=**
+jar.archive.disabled=${jnlp.enabled}
+jar.compress=false
+jar.index=${jnlp.enabled}
+javac.classpath=\
+ ${file.reference.fxgraphics2d-1.9.jar-1}
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=false
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${file.reference.hamcrest-core-1.3.jar}:\
+ ${file.reference.junit-4.11.jar}:\
+ ${file.reference.edu-test-utils-0.4.2.jar}:\
+ ${file.reference.fxgraphics2d-1.9.jar-1}
+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=Screensaver
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+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=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/nbproject/project.xml b/nbproject/project.xml
new file mode 100644
index 0000000..bbf31b0
--- /dev/null
+++ b/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ 005.Screensaver
+
+
+
+
+
+
+
+
+
diff --git a/out/artifacts/week3_005_Screensaver_jar/dashboard.png b/out/artifacts/week3_005_Screensaver_jar/dashboard.png
new file mode 100644
index 0000000..7599076
Binary files /dev/null and b/out/artifacts/week3_005_Screensaver_jar/dashboard.png differ
diff --git a/out/artifacts/week3_005_Screensaver_jar/fd.xml b/out/artifacts/week3_005_Screensaver_jar/fd.xml
new file mode 100644
index 0000000..40fc969
--- /dev/null
+++ b/out/artifacts/week3_005_Screensaver_jar/fd.xml
@@ -0,0 +1,40 @@
+
+
+ false
+ gui
+ F:\User Files\Sem\Documents\Projects\Java\java2d-screensaver\out\artifacts\week3_005_Screensaver_jar\week3-005.Screensaver.jar
+ F:\User Files\Sem\Documents\Projects\Java\java2d-screensaver\out\artifacts\week3_005_Screensaver_jar\screensaver.exe
+
+
+ .
+ normal
+ http://java.com/download
+
+ true
+ false
+
+ F:\User Files\Sem\Documents\Projects\Java\java2d-screensaver\out\artifacts\week3_005_Screensaver_jar\icon.ico
+
+
+ false
+ false
+ 1.8.0
+
+ preferJre
+ 64/32
+
+
+ 1.0.2.0
+ 1.0.2.0
+ A screensaver in java2d
+ 2020 Sem van der Hoeven
+ 1.0.2.0
+ 1.0.2.0
+ Screensaver
+
+ screensaver
+ screensaver.exe
+
+ DUTCH
+
+
\ No newline at end of file
diff --git a/out/artifacts/week3_005_Screensaver_jar/screensaver.exe b/out/artifacts/week3_005_Screensaver_jar/screensaver.exe
new file mode 100644
index 0000000..4b8ec86
Binary files /dev/null and b/out/artifacts/week3_005_Screensaver_jar/screensaver.exe differ
diff --git a/out/artifacts/week3_005_Screensaver_jar/week3-005.Screensaver.jar b/out/artifacts/week3_005_Screensaver_jar/week3-005.Screensaver.jar
new file mode 100644
index 0000000..3222e32
Binary files /dev/null and b/out/artifacts/week3_005_Screensaver_jar/week3-005.Screensaver.jar differ
diff --git a/out/production/week3-005.Screensaver/.gitkeep b/out/production/week3-005.Screensaver/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/out/production/week3-005.Screensaver/META-INF/MANIFEST.MF b/out/production/week3-005.Screensaver/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..6bac4e6
--- /dev/null
+++ b/out/production/week3-005.Screensaver/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: Screensaver
+
diff --git a/out/production/week3-005.Screensaver/META-INF/week3-005.Screensaver.kotlin_module b/out/production/week3-005.Screensaver/META-INF/week3-005.Screensaver.kotlin_module
new file mode 100644
index 0000000..a49347a
Binary files /dev/null and b/out/production/week3-005.Screensaver/META-INF/week3-005.Screensaver.kotlin_module differ
diff --git a/out/production/week3-005.Screensaver/MovingLine.class b/out/production/week3-005.Screensaver/MovingLine.class
new file mode 100644
index 0000000..37e4dee
Binary files /dev/null and b/out/production/week3-005.Screensaver/MovingLine.class differ
diff --git a/out/production/week3-005.Screensaver/MovingPoint.class b/out/production/week3-005.Screensaver/MovingPoint.class
new file mode 100644
index 0000000..4bc374a
Binary files /dev/null and b/out/production/week3-005.Screensaver/MovingPoint.class differ
diff --git a/out/production/week3-005.Screensaver/Screensaver$1.class b/out/production/week3-005.Screensaver/Screensaver$1.class
new file mode 100644
index 0000000..23570bb
Binary files /dev/null and b/out/production/week3-005.Screensaver/Screensaver$1.class differ
diff --git a/out/production/week3-005.Screensaver/Screensaver.class b/out/production/week3-005.Screensaver/Screensaver.class
new file mode 100644
index 0000000..6b1e62c
Binary files /dev/null and b/out/production/week3-005.Screensaver/Screensaver.class differ
diff --git a/out/production/week3-005.Screensaver/sound/AudioCapture02$1.class b/out/production/week3-005.Screensaver/sound/AudioCapture02$1.class
new file mode 100644
index 0000000..cde5d0a
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/AudioCapture02$1.class differ
diff --git a/out/production/week3-005.Screensaver/sound/AudioCapture02$2.class b/out/production/week3-005.Screensaver/sound/AudioCapture02$2.class
new file mode 100644
index 0000000..f0fdb22
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/AudioCapture02$2.class differ
diff --git a/out/production/week3-005.Screensaver/sound/AudioCapture02$3.class b/out/production/week3-005.Screensaver/sound/AudioCapture02$3.class
new file mode 100644
index 0000000..7cfc2bd
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/AudioCapture02$3.class differ
diff --git a/out/production/week3-005.Screensaver/sound/AudioCapture02$CaptureThread.class b/out/production/week3-005.Screensaver/sound/AudioCapture02$CaptureThread.class
new file mode 100644
index 0000000..130a365
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/AudioCapture02$CaptureThread.class differ
diff --git a/out/production/week3-005.Screensaver/sound/AudioCapture02$PlayThread.class b/out/production/week3-005.Screensaver/sound/AudioCapture02$PlayThread.class
new file mode 100644
index 0000000..d16a7a1
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/AudioCapture02$PlayThread.class differ
diff --git a/out/production/week3-005.Screensaver/sound/AudioCapture02.class b/out/production/week3-005.Screensaver/sound/AudioCapture02.class
new file mode 100644
index 0000000..d22c927
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/AudioCapture02.class differ
diff --git a/out/production/week3-005.Screensaver/sound/Capture$1.class b/out/production/week3-005.Screensaver/sound/Capture$1.class
new file mode 100644
index 0000000..1eb7e05
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/Capture$1.class differ
diff --git a/out/production/week3-005.Screensaver/sound/Capture$2.class b/out/production/week3-005.Screensaver/sound/Capture$2.class
new file mode 100644
index 0000000..a0c37d3
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/Capture$2.class differ
diff --git a/out/production/week3-005.Screensaver/sound/Capture$3.class b/out/production/week3-005.Screensaver/sound/Capture$3.class
new file mode 100644
index 0000000..f0dc793
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/Capture$3.class differ
diff --git a/out/production/week3-005.Screensaver/sound/Capture$4.class b/out/production/week3-005.Screensaver/sound/Capture$4.class
new file mode 100644
index 0000000..5274266
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/Capture$4.class differ
diff --git a/out/production/week3-005.Screensaver/sound/Capture$5.class b/out/production/week3-005.Screensaver/sound/Capture$5.class
new file mode 100644
index 0000000..34af9e0
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/Capture$5.class differ
diff --git a/out/production/week3-005.Screensaver/sound/Capture.class b/out/production/week3-005.Screensaver/sound/Capture.class
new file mode 100644
index 0000000..74616b8
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/Capture.class differ
diff --git a/out/production/week3-005.Screensaver/sound/JavaSoundRecorder.class b/out/production/week3-005.Screensaver/sound/JavaSoundRecorder.class
new file mode 100644
index 0000000..872a664
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/JavaSoundRecorder.class differ
diff --git a/out/production/week3-005.Screensaver/sound/SoundRecordingUtil.class b/out/production/week3-005.Screensaver/sound/SoundRecordingUtil.class
new file mode 100644
index 0000000..43fc4ef
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/SoundRecordingUtil.class differ
diff --git a/out/production/week3-005.Screensaver/sound/TestSoundRecordingUtil$1.class b/out/production/week3-005.Screensaver/sound/TestSoundRecordingUtil$1.class
new file mode 100644
index 0000000..f916288
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/TestSoundRecordingUtil$1.class differ
diff --git a/out/production/week3-005.Screensaver/sound/TestSoundRecordingUtil.class b/out/production/week3-005.Screensaver/sound/TestSoundRecordingUtil.class
new file mode 100644
index 0000000..bb123b9
Binary files /dev/null and b/out/production/week3-005.Screensaver/sound/TestSoundRecordingUtil.class differ
diff --git a/out/test/week3-005.Screensaver/.gitkeep b/out/test/week3-005.Screensaver/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/out/test/week3-005.Screensaver/TestStub.class b/out/test/week3-005.Screensaver/TestStub.class
new file mode 100644
index 0000000..89a4ff3
Binary files /dev/null and b/out/test/week3-005.Screensaver/TestStub.class differ
diff --git a/src/.gitkeep b/src/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..6bac4e6
--- /dev/null
+++ b/src/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: Screensaver
+
diff --git a/src/MovingLine.java b/src/MovingLine.java
new file mode 100644
index 0000000..cf29a58
--- /dev/null
+++ b/src/MovingLine.java
@@ -0,0 +1,61 @@
+import org.jfree.fx.FXGraphics2D;
+
+import java.awt.*;
+import java.awt.geom.Line2D;
+
+public class MovingLine {
+
+ private MovingPoint beginPoint;
+ private MovingPoint endPoint;
+ private Color color;
+
+ private int counter = 0;
+
+ private int MAX_LINES = 30;
+
+ private Line2D.Double[] trailingLines;
+
+ public MovingLine(MovingPoint beginPoint, MovingPoint endPoint, Color color) {
+ this.beginPoint = beginPoint;
+ this.endPoint = endPoint;
+ this.color = color;
+
+ trailingLines = new Line2D.Double[MAX_LINES];
+ }
+
+ public void draw(FXGraphics2D graphics) {
+ graphics.setColor(color);
+ graphics.draw(getAsLine());
+
+ for (int i = trailingLines.length-1; i >= 0; i--) {
+ if (trailingLines[i] != null)
+ graphics.draw(trailingLines[i]);
+ }
+ }
+
+ public void update() {
+ this.beginPoint.update();
+ this.endPoint.update();
+
+ counter++;
+ if (counter == MAX_LINES) {
+ counter = 0;
+ }
+
+ for (int i = trailingLines.length-1; i > 0; i--) {
+ trailingLines[i] = trailingLines[i-1];
+ }
+
+ trailingLines[0] = getAsLine();
+
+ }
+
+ public void setMovingBounds(double canvasWidth, double canvasHeight) {
+ this.beginPoint.setMovingBounds(canvasWidth, canvasHeight);
+ this.endPoint.setMovingBounds(canvasWidth, canvasHeight);
+ }
+
+ public Line2D.Double getAsLine() {
+ return new Line2D.Double(beginPoint.getxPos(), beginPoint.getyPos(), endPoint.getxPos(), endPoint.getyPos());
+ }
+}
diff --git a/src/MovingPoint.java b/src/MovingPoint.java
new file mode 100644
index 0000000..0b77405
--- /dev/null
+++ b/src/MovingPoint.java
@@ -0,0 +1,45 @@
+import org.jfree.fx.FXGraphics2D;
+
+import java.awt.geom.Point2D;
+
+public class MovingPoint {
+ private double xPos;
+ private double yPos;
+
+ private double xSpeed;
+ private double ySpeed;
+ private double canvasWidth;
+ private double canvasHeight;
+
+ public MovingPoint(double startX, double startY, double xStartSpeed, double yStartSpeed) {
+ this.xPos = startX;
+ this.yPos = startY;
+ this.xSpeed = xStartSpeed * 0.8;
+ this.ySpeed = yStartSpeed * 0.8;
+ }
+
+ public void update() {
+ if (this.xPos > canvasWidth || this.xPos < 0) xSpeed = -xSpeed;
+ if (this.yPos > canvasHeight || this.yPos < 0) ySpeed = -ySpeed;
+
+ this.xPos += xSpeed;
+ this.yPos += ySpeed;
+ }
+
+ public void setMovingBounds(double canvasWidth, double canvasHeight) {
+ this.canvasHeight = canvasHeight;
+ this.canvasWidth = canvasWidth;
+ }
+
+ public double getxPos() {
+ return xPos;
+ }
+
+ public double getyPos() {
+ return yPos;
+ }
+
+ public Point2D.Double getAsPoint() {
+ return new Point2D.Double(xPos, yPos);
+ }
+}
diff --git a/src/Screensaver.java b/src/Screensaver.java
new file mode 100644
index 0000000..bacd819
--- /dev/null
+++ b/src/Screensaver.java
@@ -0,0 +1,119 @@
+import java.awt.*;
+import java.awt.geom.*;
+import java.util.ArrayList;
+import java.util.Random;
+import javafx.animation.AnimationTimer;
+import javafx.application.Application;
+import javafx.scene.Scene;
+import javafx.scene.layout.BorderPane;
+import javafx.stage.Stage;
+import org.jfree.fx.FXGraphics2D;
+import org.jfree.fx.ResizableCanvas;
+
+public class Screensaver extends Application {
+ private ResizableCanvas canvas;
+
+ private double frameTime = 0;
+
+ private ArrayList lines;
+ private Random r;
+
+ @Override
+ public void start(Stage stage) throws Exception {
+
+ r = new Random();
+ BorderPane mainPane = new BorderPane();
+ canvas = new ResizableCanvas(this::draw, mainPane);
+ mainPane.setCenter(canvas);
+ FXGraphics2D g2d = new FXGraphics2D(canvas.getGraphicsContext2D());
+
+ this.lines = new ArrayList<>();
+ makeLines();
+
+ new AnimationTimer() {
+ long last = -1;
+
+ @Override
+ public void handle(long now) {
+ if (last == -1)
+ last = now;
+ update((now - last) / 1000000000.0);
+ last = now;
+ draw(g2d);
+ }
+ }.start();
+
+ stage.setScene(new Scene(mainPane));
+ stage.setTitle("Screensaver");
+ stage.show();
+ draw(g2d);
+ }
+
+ public void makeLines() {
+ //min + (max - min) * r.nextDouble();
+ MovingPoint point1 = new MovingPoint(generateRandomInt(), generateRandomInt(), generateRandomDouble(), generateRandomDouble());
+ MovingPoint point2 = new MovingPoint(generateRandomInt(), generateRandomInt(), generateRandomDouble(), generateRandomDouble());
+ MovingPoint point3 = new MovingPoint(generateRandomInt(), generateRandomInt(), generateRandomDouble(), generateRandomDouble());
+ MovingPoint point4 = new MovingPoint(generateRandomInt(), generateRandomInt(), generateRandomDouble(), generateRandomDouble());
+ MovingPoint point5 = new MovingPoint(generateRandomInt(), generateRandomInt(), generateRandomDouble(), generateRandomDouble());
+ MovingPoint point6 = new MovingPoint(generateRandomInt(), generateRandomInt(), generateRandomDouble(), generateRandomDouble());
+
+
+ lines.add(new MovingLine(point1, point2, Color.magenta));
+ lines.add(new MovingLine(point3, point2, Color.green));
+ lines.add(new MovingLine(point1, point3, Color.cyan));
+ lines.add(new MovingLine(point4, point5, Color.RED));
+ lines.add(new MovingLine(point4, point6, Color.yellow));
+ lines.add(new MovingLine(point5, point6, Color.LIGHT_GRAY));
+// lines.add(new MovingLine(point4,point1,Color.magenta));
+// lines.add(new MovingLine(point3, point2, Color.red));
+
+
+ }
+
+
+ public void draw(FXGraphics2D graphics) {
+ graphics.setTransform(new AffineTransform());
+ graphics.setBackground(Color.black);
+ graphics.clearRect(0, 0, (int) canvas.getWidth(), (int) canvas.getHeight());
+
+ for (MovingLine line : this.lines) {
+ line.draw(graphics);
+ }
+
+ }
+
+
+ public void update(double deltaTime) {
+ frameTime += deltaTime;
+ if (frameTime > 1d / 60d) {
+ updateFrame();
+ frameTime = 0.0;
+ }
+
+ }
+
+ private void updateFrame() {
+
+ for (MovingLine line : this.lines) {
+ line.setMovingBounds(canvas.getWidth(), canvas.getHeight());
+ line.update();
+ }
+
+ }
+
+ private double generateRandomDouble() {
+ double rand = -2d + (2d - -2d) * r.nextDouble();
+ System.out.println(rand);
+ return rand;
+ }
+
+ private double generateRandomInt() {
+ return r.nextInt((500 - 10) + 1) - 10;
+ }
+
+ public static void main(String[] args) {
+ launch(Screensaver.class);
+ }
+
+}
diff --git a/src/sound/AudioCapture02.java b/src/sound/AudioCapture02.java
new file mode 100644
index 0000000..48a6237
--- /dev/null
+++ b/src/sound/AudioCapture02.java
@@ -0,0 +1,321 @@
+package sound;
+
+/*File AudioCapture02.java
+This program demonstrates the capture and
+subsequent playback of audio data.
+
+A GUI appears on the screen containing the
+following buttons:
+Capture
+Stop
+Playback
+
+Input data from a microphone is captured and
+saved in a ByteArrayOutputStream object when the
+user clicks the Capture button.
+
+Data capture stops when the user clicks the Stop
+button.
+
+Playback begins when the user clicks the Playback
+button.
+
+This version of the program gets and displays a
+list of available mixers, producing the following
+output:
+
+Available mixers:
+Java Sound Audio Engine
+Microsoft Sound Mapper
+Modem #0 Line Record
+ESS Maestro
+
+Thus, this machine had the four mixers listed
+above available at the time the program was run.
+
+Then the program gets and uses one of the
+available mixers instead of simply asking for a
+compatible mixer as was the case in a previous
+version of the program.
+
+Either of the following two mixers can be used in
+this program:
+
+Microsoft Sound Mapper
+ESS Maestro
+
+Neither of the following two mixers will work in
+this program. The mixers fail at runtime for
+different reasons:
+
+Java Sound Audio Engine
+Modem #0 Line Record
+
+The Java Sound Audio Engine mixer fails due to a
+data format compatibility problem.
+
+The Modem #0 Line Record mixer fails due to an
+"Unexpected Error"
+
+Tested using SDK 1.4.0 under Win2000
+************************************************/
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.io.*;
+import javax.sound.sampled.*;
+
+public class AudioCapture02 extends JFrame{
+
+ boolean stopCapture = false;
+ ByteArrayOutputStream byteArrayOutputStream;
+ AudioFormat audioFormat;
+ TargetDataLine targetDataLine;
+ AudioInputStream audioInputStream;
+ SourceDataLine sourceDataLine;
+
+ public static void main(String args[]){
+ new AudioCapture02();
+ }//end main
+
+ public AudioCapture02(){//constructor
+ final JButton captureBtn =
+ new JButton("Capture");
+ final JButton stopBtn = new JButton("Stop");
+ final JButton playBtn =
+ new JButton("Playback");
+
+ captureBtn.setEnabled(true);
+ stopBtn.setEnabled(false);
+ playBtn.setEnabled(false);
+
+ //Register anonymous listeners
+ captureBtn.addActionListener(
+ new ActionListener(){
+ public void actionPerformed(
+ ActionEvent e){
+ captureBtn.setEnabled(false);
+ stopBtn.setEnabled(true);
+ playBtn.setEnabled(false);
+ //Capture input data from the
+ // microphone until the Stop button is
+ // clicked.
+ captureAudio();
+ }//end actionPerformed
+ }//end ActionListener
+ );//end addActionListener()
+ getContentPane().add(captureBtn);
+
+ stopBtn.addActionListener(
+ new ActionListener(){
+ public void actionPerformed(
+ ActionEvent e){
+ captureBtn.setEnabled(true);
+ stopBtn.setEnabled(false);
+ playBtn.setEnabled(true);
+ //Terminate the capturing of input data
+ // from the microphone.
+ stopCapture = true;
+ }//end actionPerformed
+ }//end ActionListener
+ );//end addActionListener()
+ getContentPane().add(stopBtn);
+
+ playBtn.addActionListener(
+ new ActionListener(){
+ public void actionPerformed(
+ ActionEvent e){
+ //Play back all of the data that was
+ // saved during capture.
+ playAudio();
+ }//end actionPerformed
+ }//end ActionListener
+ );//end addActionListener()
+ getContentPane().add(playBtn);
+
+ getContentPane().setLayout(new FlowLayout());
+ setTitle("Capture/Playback Demo");
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
+ setSize(250,70);
+ setVisible(true);
+ }//end constructor
+
+ //This method captures audio input from a
+ // microphone and saves it in a
+ // ByteArrayOutputStream object.
+ private void captureAudio(){
+ try{
+ //Get and display a list of
+ // available mixers.
+ Mixer.Info[] mixerInfo =
+ AudioSystem.getMixerInfo();
+ System.out.println("Available mixers:");
+ for(int cnt = 0; cnt < mixerInfo.length;
+ cnt++){
+ System.out.println(mixerInfo[cnt].
+ getName());
+ }//end for loop
+
+ //Get everything set up for capture
+ audioFormat = getAudioFormat();
+
+ DataLine.Info dataLineInfo =
+ new DataLine.Info(
+ TargetDataLine.class,
+ audioFormat);
+
+ //Select one of the available
+ // mixers.
+ Mixer mixer = AudioSystem.
+ getMixer(mixerInfo[3]);
+
+ //Get a TargetDataLine on the selected
+ // mixer.
+ targetDataLine = (TargetDataLine)
+ mixer.getLine(dataLineInfo);
+ //Prepare the line for use.
+ targetDataLine.open(audioFormat);
+ targetDataLine.start();
+
+ //Create a thread to capture the microphone
+ // data and start it running. It will run
+ // until the Stop button is clicked.
+ Thread captureThread = new CaptureThread();
+ captureThread.start();
+ } catch (Exception e) {
+ System.out.println(e);
+ System.exit(0);
+ }//end catch
+ }//end captureAudio method
+
+ //This method plays back the audio data that
+ // has been saved in the ByteArrayOutputStream
+ private void playAudio() {
+ try{
+ //Get everything set up for playback.
+ //Get the previously-saved data into a byte
+ // array object.
+ byte audioData[] = byteArrayOutputStream.
+ toByteArray();
+ //Get an input stream on the byte array
+ // containing the data
+ InputStream byteArrayInputStream =
+ new ByteArrayInputStream(audioData);
+ AudioFormat audioFormat = getAudioFormat();
+ audioInputStream = new AudioInputStream(
+ byteArrayInputStream,
+ audioFormat,
+ audioData.length/audioFormat.
+ getFrameSize());
+ DataLine.Info dataLineInfo =
+ new DataLine.Info(
+ SourceDataLine.class,
+ audioFormat);
+ sourceDataLine = (SourceDataLine)
+ AudioSystem.getLine(dataLineInfo);
+ sourceDataLine.open(audioFormat);
+ sourceDataLine.start();
+
+ //Create a thread to play back the data and
+ // start it running. It will run until
+ // all the data has been played back.
+ Thread playThread = new PlayThread();
+ playThread.start();
+ } catch (Exception e) {
+ System.out.println(e);
+ System.exit(0);
+ }//end catch
+ }//end playAudio
+
+ //This method creates and returns an
+ // AudioFormat object for a given set of format
+ // parameters. If these parameters don't work
+ // well for you, try some of the other
+ // allowable parameter values, which are shown
+ // in comments following the declartions.
+ private AudioFormat getAudioFormat(){
+ float sampleRate = 8000;
+ //8000,11025,16000,22050,44100
+ int sampleSizeInBits = 16;
+ //8,16
+ int channels = 2;
+ //1,2
+ boolean signed = true;
+ //true,false
+ boolean bigEndian = true;
+ //true,false
+ return new AudioFormat(
+ sampleRate,
+ sampleSizeInBits,
+ channels,
+ signed,
+ bigEndian);
+ }//end getAudioFormat
+//=============================================//
+
+ //Inner class to capture data from microphone
+ class CaptureThread extends Thread{
+ //An arbitrary-size temporary holding buffer
+ byte tempBuffer[] = new byte[10000];
+ public void run(){
+ byteArrayOutputStream =
+ new ByteArrayOutputStream();
+ stopCapture = false;
+ try{//Loop until stopCapture is set by
+ // another thread that services the Stop
+ // button.
+ while(!stopCapture){
+ //Read data from the internal buffer of
+ // the data line.
+ int cnt = targetDataLine.read(tempBuffer,
+ 0,
+ tempBuffer.length);
+ if(cnt > 0){
+ //Save data in output stream object.
+ byteArrayOutputStream.write(tempBuffer,
+ 0,
+ cnt);
+ }//end if
+ }//end while
+ byteArrayOutputStream.close();
+ }catch (Exception e) {
+ System.out.println(e);
+ System.exit(0);
+ }//end catch
+ }//end run
+ }//end inner class CaptureThread
+ //===================================//
+//Inner class to play back the data
+// that was saved.
+ class PlayThread extends Thread{
+ byte tempBuffer[] = new byte[10000];
+
+ public void run(){
+ try{
+ int cnt;
+ //Keep looping until the input read method
+ // returns -1 for empty stream.
+ while((cnt = audioInputStream.read(
+ tempBuffer, 0,
+ tempBuffer.length)) != -1){
+ if(cnt > 0){
+ //Write data to the internal buffer of
+ // the data line where it will be
+ // delivered to the speaker.
+ sourceDataLine.write(tempBuffer,0,cnt);
+ }//end if
+ }//end while
+ //Block and wait for internal buffer of the
+ // data line to empty.
+ sourceDataLine.drain();
+ sourceDataLine.close();
+ }catch (Exception e) {
+ System.out.println(e);
+ System.exit(0);
+ }//end catch
+ }//end run
+ }//end inner class PlayThread
+//=============================================//
+
+}//end outer class AudioCapture02.java
diff --git a/src/sound/Capture.java b/src/sound/Capture.java
new file mode 100644
index 0000000..65e79b7
--- /dev/null
+++ b/src/sound/Capture.java
@@ -0,0 +1,162 @@
+package sound;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.io.*;
+import javax.sound.sampled.*;
+
+public class Capture extends JFrame {
+
+ protected boolean running;
+ ByteArrayOutputStream out;
+
+ public Capture() {
+ super("sound.Capture Sound Demo");
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
+ Container content = getContentPane();
+
+ final JButton capture = new JButton("sound.Capture");
+ final JButton stop = new JButton("Stop");
+ final JButton play = new JButton("Play");
+
+ capture.setEnabled(true);
+ stop.setEnabled(false);
+ play.setEnabled(false);
+
+ ActionListener captureListener =
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ capture.setEnabled(false);
+ stop.setEnabled(true);
+ play.setEnabled(false);
+ captureAudio();
+ }
+ };
+ capture.addActionListener(captureListener);
+ content.add(capture, BorderLayout.NORTH);
+
+ ActionListener stopListener =
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ capture.setEnabled(true);
+ stop.setEnabled(false);
+ play.setEnabled(true);
+ running = false;
+ }
+ };
+ stop.addActionListener(stopListener);
+ content.add(stop, BorderLayout.CENTER);
+
+ ActionListener playListener =
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ playAudio();
+ }
+ };
+ play.addActionListener(playListener);
+ content.add(play, BorderLayout.SOUTH);
+ }
+
+ private void captureAudio() {
+ try {
+ final AudioFormat format = getFormat();
+ DataLine.Info info = new DataLine.Info(
+ TargetDataLine.class, format);
+ final TargetDataLine line = (TargetDataLine)
+ AudioSystem.getLine(info);
+ line.open(format);
+ line.start();
+ Runnable runner = new Runnable() {
+ int bufferSize = (int)format.getSampleRate()
+ * format.getFrameSize();
+ byte buffer[] = new byte[bufferSize];
+
+ public void run() {
+ out = new ByteArrayOutputStream();
+ running = true;
+ try {
+ while (running) {
+ int count =
+ line.read(buffer, 0, buffer.length);
+ if (count > 0) {
+ out.write(buffer, 0, count);
+ }
+ }
+ out.close();
+ } catch (IOException e) {
+ System.err.println("I/O problems: " + e);
+ System.exit(-1);
+ }
+ }
+ };
+ Thread captureThread = new Thread(runner);
+ captureThread.start();
+ } catch (LineUnavailableException e) {
+ System.err.println("Line unavailable: " + e);
+ System.exit(-2);
+ }
+ }
+
+ private void playAudio() {
+ try {
+ byte audio[] = out.toByteArray();
+ InputStream input =
+ new ByteArrayInputStream(audio);
+ final AudioFormat format = getFormat();
+ final AudioInputStream ais =
+ new AudioInputStream(input, format,
+ audio.length / format.getFrameSize());
+ DataLine.Info info = new DataLine.Info(
+ SourceDataLine.class, format);
+ final SourceDataLine line = (SourceDataLine)
+ AudioSystem.getLine(info);
+ line.open(format);
+ line.start();
+
+ Runnable runner = new Runnable() {
+ int bufferSize = (int) format.getSampleRate()
+ * format.getFrameSize();
+ byte buffer[] = new byte[bufferSize];
+
+ public void run() {
+ try {
+ int count;
+ while ((count = ais.read(
+ buffer, 0, buffer.length)) != -1) {
+ if (count > 0) {
+ line.write(buffer, 0, count);
+ }
+ }
+ line.drain();
+ line.close();
+ } catch (IOException e) {
+ System.err.println("I/O problems: " + e);
+ System.exit(-3);
+ }
+ }
+ };
+ Thread playThread = new Thread(runner);
+ playThread.start();
+ } catch (LineUnavailableException e) {
+ System.err.println("Line unavailable: " + e);
+ System.exit(-4);
+ }
+ }
+
+ private AudioFormat getFormat() {
+ float sampleRate = 16000;
+ int sampleSizeInBits = 8;
+ int channels = 2;
+ boolean signed = false;
+ boolean bigEndian = true;
+ return new AudioFormat(sampleRate,
+ sampleSizeInBits, channels, signed, bigEndian);
+ }
+
+ public static void main(String args[]) {
+ JFrame frame = new Capture();
+ frame.pack();
+ frame.show();
+ }
+}
\ No newline at end of file
diff --git a/src/sound/JavaSoundRecorder.java b/src/sound/JavaSoundRecorder.java
new file mode 100644
index 0000000..2c447f2
--- /dev/null
+++ b/src/sound/JavaSoundRecorder.java
@@ -0,0 +1,108 @@
+package sound;
+
+import javax.sound.sampled.*;
+import java.io.*;
+
+/**
+ * A sample program is to demonstrate how to record sound in Java
+ * author: www.codejava.net
+ */
+public class JavaSoundRecorder {
+ // record duration, in milliseconds
+ static final long RECORD_TIME = 10000; // 1 minute
+
+ // path of the wav file
+ File wavFile = new File("RecordAudio.wav");
+
+ // format of audio file
+ AudioFileFormat.Type fileType = AudioFileFormat.Type.WAVE;
+
+ // the line from which audio data is captured
+ TargetDataLine line;
+ SourceDataLine sourceDataLine;
+
+ /**
+ * Defines an audio format
+ */
+ AudioFormat getAudioFormat() {
+ float sampleRate = 16000;
+ int sampleSizeInBits = 8;
+ int channels = 2;
+ boolean signed = true;
+ boolean bigEndian = true;
+ AudioFormat format = new AudioFormat(sampleRate, sampleSizeInBits,
+ channels, signed, bigEndian);
+ return format;
+ }
+
+ /**
+ * Captures the sound and record into a WAV file
+ */
+ void start() {
+ try {
+ AudioFormat format = getAudioFormat();
+ DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
+
+ // checks if system supports the data line
+ if (!AudioSystem.isLineSupported(info)) {
+ System.out.println("Line not supported");
+ System.exit(0);
+ }
+
+ sourceDataLine = AudioSystem.getSourceDataLine(format);
+ sourceDataLine.open(format);
+ sourceDataLine.start();
+ line = (TargetDataLine) AudioSystem.getLine(info);
+ line.open(format);
+ line.start(); // start capturing
+
+ System.out.println("Start capturing...");
+
+ AudioInputStream ais = new AudioInputStream(line);
+
+ System.out.println("Start recording...");
+
+ // start recording
+ AudioSystem.write(ais, fileType, wavFile);
+
+ } catch (LineUnavailableException ex) {
+ ex.printStackTrace();
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+
+ /**
+ * Closes the target data line to finish capturing and recording
+ */
+ void finish() {
+ line.stop();
+ line.close();
+ System.out.println("Finished");
+ }
+
+ /**
+ * Entry to run the program
+ */
+ public static void main(String[] args) {
+ final JavaSoundRecorder recorder = new JavaSoundRecorder();
+
+ // creates a new thread that waits for a specified
+ // of time before stopping
+ Thread stopper = new Thread(() -> {
+ try {
+ Thread.sleep(RECORD_TIME);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ recorder.finish();
+ });
+
+ stopper.start();
+
+ // start recording
+ recorder.start();
+
+// System.out.println(Arrays.toString(AudioSystem.getMixerInfo()));
+ }
+}
\ No newline at end of file
diff --git a/src/sound/SoundRecordingUtil.java b/src/sound/SoundRecordingUtil.java
new file mode 100644
index 0000000..b92ee17
--- /dev/null
+++ b/src/sound/SoundRecordingUtil.java
@@ -0,0 +1,104 @@
+package sound;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+
+import javax.sound.sampled.*;
+
+/**
+ * A utility class provides general functions for recording sound.
+ * @author www.codejava.net
+ *
+ */
+public class SoundRecordingUtil {
+ private static final int BUFFER_SIZE = 4096;
+ private ByteArrayOutputStream recordBytes;
+ private TargetDataLine audioLine;
+ private AudioFormat format;
+
+ private boolean isRunning;
+
+ /**
+ * Defines a default audio format used to record
+ */
+ AudioFormat getAudioFormat() {
+ float sampleRate = 8000;
+ int sampleSizeInBits = 16;
+ int channels = 2;
+ boolean signed = true;
+ boolean bigEndian = true;
+ return new AudioFormat(sampleRate, sampleSizeInBits, channels, signed,
+ bigEndian);
+ }
+
+ /**
+ * Start recording sound.
+ * @throws LineUnavailableException if the system does not support the specified
+ * audio format nor open the audio data line.
+ */
+ public void start() throws LineUnavailableException {
+ System.out.println("starting method");
+ format = getAudioFormat();
+ DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
+
+ // checks if system supports the data line
+ if (!AudioSystem.isLineSupported(info)) {
+ throw new LineUnavailableException(
+ "The system does not support the specified format.");
+ }
+
+ audioLine = AudioSystem.getTargetDataLine(format);
+
+ audioLine.open(format);
+ audioLine.start();
+ System.out.println("started line");
+
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int bytesRead = 0;
+
+ recordBytes = new ByteArrayOutputStream();
+ isRunning = true;
+
+ while (isRunning) {
+ System.out.println("running");
+ bytesRead = audioLine.read(buffer, 0, buffer.length);
+ recordBytes.write(buffer, 0, bytesRead);
+ }
+ }
+
+ /**
+ * Stop recording sound.
+ * @throws IOException if any I/O error occurs.
+ */
+ public void stop() throws IOException {
+ isRunning = false;
+
+ System.out.println("running is false");
+ if (audioLine != null) {
+ System.out.println("audioline is not null");
+// audioLine.drain();
+ System.out.println("audioline drained");
+ audioLine.close();
+ System.out.println("audioline closed");
+ }
+ }
+
+ /**
+ * Save recorded sound data into a .wav file format.
+ * @param wavFile The file to be saved.
+ * @throws IOException if any I/O error occurs.
+ */
+ public void save(File wavFile) throws IOException {
+ byte[] audioData = recordBytes.toByteArray();
+ ByteArrayInputStream bais = new ByteArrayInputStream(audioData);
+ AudioInputStream audioInputStream = new AudioInputStream(bais, format,
+ audioData.length / format.getFrameSize());
+
+ AudioSystem.write(audioInputStream, AudioFileFormat.Type.WAVE, wavFile);
+
+ audioInputStream.close();
+ recordBytes.close();
+ }
+}
\ No newline at end of file
diff --git a/src/sound/TestSoundRecordingUtil.java b/src/sound/TestSoundRecordingUtil.java
new file mode 100644
index 0000000..a02b2b6
--- /dev/null
+++ b/src/sound/TestSoundRecordingUtil.java
@@ -0,0 +1,56 @@
+package sound;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.sound.sampled.LineUnavailableException;
+
+/**
+ * A sample program that tests the sound.SoundRecordingUtil utility class.
+ * @author www.codejava.net
+ *
+ */
+public class TestSoundRecordingUtil {
+ private static final int RECORD_TIME = 10000; // 1 seconds
+
+ public static void main(String[] args) {
+ File wavFile = new File("Record.wav");
+
+ final SoundRecordingUtil recorder = new SoundRecordingUtil();
+
+ // create a separate thread for recording
+ Thread recordThread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ System.out.println("Start recording...");
+ recorder.start();
+ } catch (LineUnavailableException ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ }
+ }
+ });
+
+ recordThread.start();
+
+ try {
+ Thread.sleep(RECORD_TIME);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+
+ System.out.println("time over");
+ try {
+ recorder.stop();
+ System.out.println("stopped");
+ recorder.save(wavFile);
+ System.out.println("STOPPED");
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+
+ System.out.println("DONE");
+ }
+
+}
\ No newline at end of file
diff --git a/test/.gitkeep b/test/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/test/TestStub.java b/test/TestStub.java
new file mode 100644
index 0000000..a0a1a33
--- /dev/null
+++ b/test/TestStub.java
@@ -0,0 +1,16 @@
+
+import fi.helsinki.cs.tmc.edutestutils.Points;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+
+
+@Points("3-5")
+public class TestStub {
+
+ @Test
+ public void testCalls()
+ {
+ assertTrue("You shall pass", true);
+ }
+}
diff --git a/week3-005.Screensaver.iml b/week3-005.Screensaver.iml
new file mode 100644
index 0000000..c62b691
--- /dev/null
+++ b/week3-005.Screensaver.iml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file