diff --git a/README.md b/README.md index 1fb7c190f32b45e67986b8dbca6f9464f90d7479..8acde39911ac9c325323098c051f57252a351952 100644 --- a/README.md +++ b/README.md @@ -1,41 +1 @@ -palauttaja: Tuukka Aro - -# Project description - -Simple template for projects that make use of JavaFX and FXML (Scene Builder). -Requires Java 11 or later. Compatible with -Eclipse and IntelliJ IDEA. Minor issues with Netbeans. Automatically -integrates with Gitlab CI. - -## Installation - -Maven: - -```bash -$ git clone https://gitlab.utu.fi/tech/education/gui/template-javafx - -$ cd template-javafx - -$ mvn compile exec:java -``` - -SBT: - -```bash -$ git clone https://gitlab.utu.fi/tech/education/gui/template-javafx - -$ cd template-javafx - -$ sbt compile run -``` - -## Further instructions - - * Java platform: https://gitlab.utu.fi/soft/ftdev/wikis/tutorials/jvm-platform - * Maven: https://gitlab.utu.fi/soft/ftdev/wikis/tutorials/maven-misc - * SBT: https://gitlab.utu.fi/soft/ftdev/wikis/tutorials/sbt-misc - -External sources: - - * JavaFX: https://openjfx.io/javadoc/11/ - * Scene Builder: https://docs.gluonhq.com/scenebuilder/ +# Revitty Jari-Matti Mäkelän projektista. Tuukan koodinäyte ZIP-pakkaaja. \ No newline at end of file diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5bfb48ed0b155fac605c25bfac13ca2115525da1 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,20 @@ +contracts/ +.classpath +.project +.history/ +.idea +.jqwik-database +.lib/ +.worksheet +.settings/ +*.iml +*.ipr +*.iws +*.log +project/boot/ +project/plugins/project/ +project/project/ +project/*-shim.sbt +project/target/ +target/ +openjfx/ diff --git a/bin/.gitlab-ci.yml b/bin/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..4b3553b42ff83c2ef7e7ea37ffa030aaaf554898 --- /dev/null +++ b/bin/.gitlab-ci.yml @@ -0,0 +1,13 @@ +image: maven:latest + +stages: + - build + - test + +build: + script: + - mvn compile + +test: + script: + - mvn test \ No newline at end of file diff --git a/bin/README.md b/bin/README.md new file mode 100644 index 0000000000000000000000000000000000000000..1fb7c190f32b45e67986b8dbca6f9464f90d7479 --- /dev/null +++ b/bin/README.md @@ -0,0 +1,41 @@ +palauttaja: Tuukka Aro + +# Project description + +Simple template for projects that make use of JavaFX and FXML (Scene Builder). +Requires Java 11 or later. Compatible with +Eclipse and IntelliJ IDEA. Minor issues with Netbeans. Automatically +integrates with Gitlab CI. + +## Installation + +Maven: + +```bash +$ git clone https://gitlab.utu.fi/tech/education/gui/template-javafx + +$ cd template-javafx + +$ mvn compile exec:java +``` + +SBT: + +```bash +$ git clone https://gitlab.utu.fi/tech/education/gui/template-javafx + +$ cd template-javafx + +$ sbt compile run +``` + +## Further instructions + + * Java platform: https://gitlab.utu.fi/soft/ftdev/wikis/tutorials/jvm-platform + * Maven: https://gitlab.utu.fi/soft/ftdev/wikis/tutorials/maven-misc + * SBT: https://gitlab.utu.fi/soft/ftdev/wikis/tutorials/sbt-misc + +External sources: + + * JavaFX: https://openjfx.io/javadoc/11/ + * Scene Builder: https://docs.gluonhq.com/scenebuilder/ diff --git a/bin/build.sbt b/bin/build.sbt new file mode 100644 index 0000000000000000000000000000000000000000..e703e9051c964d2e35d6f297a81b241437860648 --- /dev/null +++ b/bin/build.sbt @@ -0,0 +1,236 @@ +// Project template + +// Supported operating systems: Windows, Mac, Linux +// Supported JDKs: 8, 10+ + +// Project name +name := "template-javafx" + +// organization name +organization := "fi.utu.tech" + +version := "1.0" + +// project description +description := "JavaFX project template" + +// main class +Compile/mainClass := Some("fi.utu.tech.gui.javafx.Main") + +// force the java version by typing it here (remove the comment) +val force_javaVersion = None // Some(13) + +// force the javafx version by typing it here (remove the comment) +val force_javaFxVersion = None // Some(13) + +val useJavaFX = true + +val useScalaOrScalaFX = true + +// END_OF_SIMPLE_CONFIGURATION +// you can copy the rest for each new project +// --- --- --- + +def fail(msg: String) = { + println("Error :-/") + println + println(msg) + System.exit(1) + null +} + +val detectedJDK = System.getProperty("java.version").replace("-ea","").split('.').dropWhile(_.toInt<8).head.toInt + +val javaVersionNum = force_javaVersion.getOrElse(detectedJDK) + +val javaVersionString = javaVersionNum match { + case 7 => "1.7" + case 8 => "1.8" + case x if x > 8 => x.toString +} + +val lts = 11 +val dev = 13 + +val supported = javaVersionNum match { + case x if x < 8 => fail("Your Java installation is obsolete. Please upgrade to Java " + lts + "LTS") + case 9 => fail("Your Java installation is unsupported and has known issues. Please upgrade to Java " + lts + "LTS") + case x if x < lts => println("Consider upgrading to Java " + lts + " LTS"); true + case x if x > lts && x < dev => println("Consider upgrading to Java " + dev); true + case x if x > dev => println("Unsupported early access version. Consider switching back to Java " + dev); true + case _ => true +} + +javacOptions ++= Seq("-source", javaVersionString, "-target", javaVersionString, "-encoding", "utf8", "-Xlint:unchecked", "-Xlint:deprecation") +javacOptions in doc := Seq("-source", javaVersionString) + +enablePlugins(JShellPlugin) + +compileOrder := CompileOrder.JavaThenScala + +// Enables publishing to maven repo +publishMavenStyle := true + +// Do not append Scala versions to the generated artifacts +crossPaths := false + +// This forbids including Scala related libraries into the dependency +autoScalaLibrary := false + +assemblyMergeStrategy in assembly := { + case PathList("META-INF", xs @ _*) => MergeStrategy.discard + case _ => MergeStrategy.first +} + +// contains libraries provided by utu/ft dep +resolvers += "ftdev" at "https://ftdev.utu.fi/maven2" + +fork in Global := true + +val javaVersion = taskKey[Unit]("Prints the Java version.") + +javaVersion := { println("SBT uses Java SDK located at "+System.getProperty("java.home")) } + +publishTo := Some(Resolver.file("file", new File("/tmp/repository"))) + +val oomkit = "fi.utu.tech" % "oomkit" % "1.15" + +libraryDependencies ++= Seq() + +//// +//// JQWIK / JUNIT configuration +//// + +resolvers in ThisBuild += Resolver.jcenterRepo + +val junit_version = "5.5.2" + +// library dependencies. (orginization name) % (project name) % (version) +libraryDependencies ++= Seq( + "net.aichler" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test, + "org.junit.platform" % "junit-platform-commons" % ("1"+junit_version.tail) % Test, + "org.junit.platform" % "junit-platform-runner" % ("1"+junit_version.tail) % Test, + "org.junit.jupiter" % "junit-jupiter-engine" % junit_version % Test, + "org.junit.jupiter" % "junit-jupiter-api" % junit_version % Test, + "org.junit.jupiter" % "junit-jupiter-migrationsupport" % junit_version % Test, + "org.junit.jupiter" % "junit-jupiter-params" % junit_version % Test, + "net.jqwik" % "jqwik" % "1.2.0" % Test, + "org.scalatest" %% "scalatest" % "3.0.8" % Test, +) + +testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-c") + +//// +//// JAVAFX configuration +//// + +val javafx_versions = if (!useJavaFX) (0,"-","-") else (force_javaFxVersion getOrElse javaVersionNum) match { + case 7 => (7, "7", "8.0.181-R13") + case 8 => (8, "8", "8.0.181-R13") + case 10 => (11, "11.0.2", "11-R16") + case x if x>10 => (13, "13", "12.0.2-R18") + case _ => fail("Unsupported Java version for JavaFX") +} + +// JAVA_HOME location +val javaHomeDir = { + val path = try { + if (scala.sys.env("JAVA_HOME").trim.isEmpty) throw new Exception("Empty JAVA_HOME") else scala.sys.env("JAVA_HOME") + } catch { + case _: Throwable => System.getProperty("java.home") // not set -> ask from current JVM + } + + val f = file(path) + if (!f.exists()) fail("The environment variable JAVA_HOME points to a non-existent directory!\nSolution: Edit your system settings (Windows control panel / *nix .bashrc) and fix the JAVA_HOME location.") + f +} + +val osName: SettingKey[String] = SettingKey[String]("osName") + +osName := (System.getProperty("os.name") match { + case n if n.startsWith("Linux") => "linux" + case n if n.startsWith("Mac") => "mac" + case n if n.startsWith("Windows") => "win" + case _ => throw new Exception("Unknown platform!") +}) + +def legacyJavaFX() = { + val searchDirs = Seq( + "/jre/lib/jfxrt.jar", // OpenJDK 7 + "/jre/lib/ext/jfxrt.jar", // OpenJDK 8 + "/lib/ext/jfxrt.jar" // Windows & Oracle Java 8 + ) + + if (detectedJDK > 8) fail(s"Trying to use legacy non-modular JavaFX with a modern JDK [$detectedJDK].\nSolution: Check the line 'val force_javaFxVersion =' in build.sbt.") + + val javaFxJAR = searchDirs.map{ searchDir => file(javaHomeDir + searchDir) }.find{ _.exists() } + + javaFxJAR.getOrElse { + fail(s"Java FX runtime not installed in [${javaHomeDir.toString}]!\nSolution: Install JavaFX or consider upgrading your JDK so that JavaFX can be installed automatically.") + } +} + +val jfx_sdk_version = javafx_versions._2 +val jfx_scalafx_version = javafx_versions._3 + +val javaFxPath = Def.taskKey[File]("OpenJFX fetcher") +javaFxPath := { + val javaFxHome = + try { + val envHome = file(scala.sys.env("JAVAFX_HOME")) + if (envHome.toString.trim.isEmpty) throw new Exception("Empty JAVAFX_HOME") + println("Using OpenJFX from " + envHome) + envHome + } + catch { case _: Throwable => + println("Using local OpenJFX") + baseDirectory.value / "openjfx" + } + + if (!javaFxHome.exists()) java.nio.file.Files.createDirectory(javaFxHome.toPath) + + val jfx_os = osName.value match { + case "linux" => "linux" + case "mac" => "osx" + case "win" => "windows" + } + + val sdkURL = "http://download2.gluonhq.com/openjfx/" + jfx_sdk_version + "/openjfx-" + jfx_sdk_version + "_" + jfx_os + "-x64_bin-sdk.zip" + + try { + val testDir = javaFxHome / "all.ok" + if (!testDir.exists()) { + println("Fetching OpenJFX from "+sdkURL+"..") + IO.unzipURL(new URL(sdkURL), javaFxHome) + java.nio.file.Files.createDirectory(testDir.toPath) + println("Fetching OpenJFX done.") + } else { + println("Using OpenJFX from "+javaFxHome) + } + + javaFxHome + } + catch { + case t: Throwable => fail("Could not load OpenJFX! Reason:" + t.getMessage) + } +} + +val jfxModules = Seq("base","controls","fxml","graphics","media","swing","web") + + +if (!useJavaFX) Seq() else javafx_versions._1 match { + case 7 => + // TODO libraryDependencies + Seq(unmanagedJars in Compile += Attributed.blank(legacyJavaFX())) + case 8 => + (if (useScalaOrScalaFX) Seq(libraryDependencies += "org.scalafx" %% "scalafx" % jfx_scalafx_version) else Seq()) ++ + Seq(unmanagedJars in Compile += Attributed.blank(legacyJavaFX())) + case _ => + Seq( + javaOptions in run ++= Seq( + "--module-path", (javaFxPath.value / ("javafx-sdk-" + jfx_sdk_version) / "lib").toString, + "--add-modules=" + jfxModules.map("javafx."+_).mkString(",")) + ) ++ + (if (useScalaOrScalaFX) Seq(libraryDependencies += "org.scalafx" % "scalafx_2.13" % jfx_scalafx_version) else Seq()) ++ + jfxModules.map(module => libraryDependencies += "org.openjfx" % ("javafx-"+module) % jfx_sdk_version classifier osName.value) +} diff --git a/bin/pom.xml b/bin/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..d5e648244ca21b15feef4d86023c7ce15e3b51c6 --- /dev/null +++ b/bin/pom.xml @@ -0,0 +1,452 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <!-- + + Welcome! + This pom.xml is *THE* file that defines your Maven style Java project. + + Eclipse, IDEA and other development environments with Maven support + or plugins can *import* this project by reading this file. + + It usually contains tons of barely readable configuration. Luckily + this basic pom.xml is somewhat readable. All necessary configuration + for customizing your project if located here on top before the + 'END OF SIMPLE CONFIGURATION' line below. + + Some basics: + + - Maven is a build system for Java/JVM + - the Maven projects define an artifact that has a three part id: + groupId - artifactId - version + + - For example, this project is called: + fi.utu.tech - oomkit - 1.15 + + - The group id is usually a web domain in reverse order. + + - You can use these id parts to search for projects at + https://search.maven.org/ + + - If your version is not final and you have plans to modify the + source code at some point, please use a version id that ends with + -SNAPSHOT, e.g 1.0-SNAPSHOT. Maven may cache the project jar + and refuse to overwrite old cached versions with new ones unless + you remember this convention. + + - This file supports + compiling the project with 'mvn compile' (see target/) + cleaning the class files with 'mvn clean' + executing the main routine with 'mvn exec:java' + executing the unit tests with 'mvn test' + packaging the application with 'mvn package' (see target/) + + - the Maven project structure is as follows: + https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html + + --> + + <!-- ==== START OF SIMPLE CONFIGURATION ==== --> + + <!-- the three parts of the artifact name --> + <groupId>fi.utu.tech</groupId> + <artifactId>template-javafx</artifactId> + <version>1.0</version> + + <!-- additional information about the project --> + <name>JavaFX project template</name> + <url>https://gitlab.utu.fi/tech/education/gui/template-javafx</url> + + <packaging>jar</packaging> + + <!-- HINT: More configuration here! --> + <properties> + <!-- Configures this project to use 'fi.utu.tech.AppMain' as its main class --> + <project.mainclass>fi.utu.tech.gui.javafx.Main</project.mainclass> + + + <!-- Don't touch these unless you know what you're doing! + + For example, the source encoding should always be utf-8. + You're probably doing something stupid if you think it + should be a 8-bit code page in 2019. --> + <jdk.version>11</jdk.version> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <jqwik.version>1.2.0</jqwik.version> + <junit.version>5.5.2</junit.version> + <junitplatform.version>1.5.2</junitplatform.version> + <javafx.version>13.0.2</javafx.version> + </properties> + + <!-- ==== END OF SIMPLE CONFIGURATION ==== --> + + <repositories> + <repository> + <snapshots> + <enabled>false</enabled> + </snapshots> + <id>central</id> + <name>Central Repository</name> + <url>https://repo.maven.apache.org/maven2</url> + </repository> + <repository> + <id>jcenter</id> + <name>jcenter</name> + <url>https://jcenter.bintray.com/</url> + </repository> + <!-- UTU repository --> + <repository> + <id>ftdev</id> + <name>ftdev</name> + <url>https://ftdev.utu.fi/maven2</url> + </repository> + </repositories> + + <dependencies> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <version>${junit.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <version>${junit.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-params</artifactId> + <version>${junit.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.platform</groupId> + <artifactId>junit-platform-commons</artifactId> + <version>${junitplatform.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>net.jqwik</groupId> + <artifactId>jqwik</artifactId> + <version>${jqwik.version}</version> + <scope>test</scope> + </dependency><!-- + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-migrationsupport</artifactId> + <version>${junit.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.platform</groupId> + <artifactId>junit-platform-runner</artifactId> + <version>${junitplatform.version}</version> + <scope>test</scope> + </dependency> --> + + <!-- JavaFX (remove if not needed to speed up dep downloads)--> + <dependency> + <groupId>org.openjfx</groupId> + <artifactId>javafx-base</artifactId> + <version>${javafx.version}</version> + </dependency> + <dependency> + <groupId>org.openjfx</groupId> + <artifactId>javafx-controls</artifactId> + <version>${javafx.version}</version> + </dependency> + <dependency> + <groupId>org.openjfx</groupId> + <artifactId>javafx-fxml</artifactId> + <version>${javafx.version}</version> + </dependency> + <dependency> + <groupId>org.openjfx</groupId> + <artifactId>javafx-graphics</artifactId> + <version>${javafx.version}</version> + </dependency> + <dependency> + <groupId>org.openjfx</groupId> + <artifactId>javafx-media</artifactId> + <version>${javafx.version}</version> + </dependency> + <dependency> + <groupId>org.openjfx</groupId> + <artifactId>javafx-swing</artifactId> + <version>${javafx.version}</version> + </dependency> + <dependency> + <groupId>org.openjfx</groupId> + <artifactId>javafx-web</artifactId> + <version>${javafx.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <!-- Make a 'fat' jar, that is, jar that contains all its dependencies and runs as is. + See: https://stackoverflow.com/a/57691362 --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>2.3</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <filters> + <filter> + <artifact>*:*</artifact> + <excludes> + <exclude>module-info.class</exclude> + <exclude>META-INF/*.SF</exclude> + <exclude>META-INF/*.DSA</exclude> + <exclude>META-INF/*.RSA</exclude> + </excludes> + </filter> + </filters> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <mainClass>${project.mainclass}</mainClass> + </transformer> + </transformers> + </configuration> + </execution> + </executions> + </plugin> + + <!-- Run this app with exec:java --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.6.0</version> + <executions> + <execution> + <goals> + <goal>java</goal> + </goals> + </execution> + </executions> + <configuration> + <mainClass>${project.mainclass}</mainClass> + <arguments> + <argument>arg1</argument> + <argument>arg2</argument> + </arguments> + </configuration> + </plugin> + + <!-- Make the packaged jar executable --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>3.1.2</version> + <configuration> + <!-- DO NOT include log4j.properties file in your Jar --> + <excludes> + <exclude>**/log4j.properties</exclude> + </excludes> + <archive> + <manifest> + <!-- Jar file entry point --> + <mainClass>${project.mainclass}</mainClass> + </manifest> + </archive> + </configuration> + </plugin> + + <!-- download source code in Eclipse, best practice --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-eclipse-plugin</artifactId> + <version>2.10</version> + <configuration> + <downloadSources>true</downloadSources> + <downloadJavadocs>false</downloadJavadocs> + </configuration> + </plugin> + + <!-- JDK source/target versions --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.1</version> + <configuration> + <source>${jdk.version}</source> + <target>${jdk.version}</target> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>3.1.0</version> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>3.1.1</version> + <executions> + <execution> + <id>attach-javadocs</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + <configuration> + <tags> + <tag> + <name>toDo</name> + <placement>a</placement> + <head>To do:</head> + </tag> + <tag> + <name>classInvariant</name> + <placement>t</placement> + <head>Class invariant:</head> + </tag> + <tag> + <name>classInvariantProtected</name> + <placement>t</placement> + <head>Protected class invariant:</head> + </tag> + <tag> + <name>classInvariantPrivate</name> + <placement>t</placement> + <head>Private class invariant:</head> + </tag> + <tag> + <name>abstractionFunction</name> + <placement>t</placement> + <head>Abstraction function:</head> + </tag> + <tag> + <name>pre</name> + <placement>cm</placement> + <head>Precondition:</head> + </tag> + <tag> + <name>post</name> + <placement>cm</placement> + <head>Postcondition:</head> + </tag> + <tag> + <name>postProtected</name> + <placement>cm</placement> + <head>Protected postcondition:</head> + </tag> + <tag> + <name>postPrivate</name> + <placement>cm</placement> + <head>Private postcondition:</head> + </tag> + <tag> + <name>time</name> + <placement>cmf</placement> + <head>Time complexity:</head> + </tag> + <tag> + <name>space</name> + <placement>cmf</placement> + <head>Space complexity:</head> + </tag> + <tag> + <name>correspondence</name> + <placement>a</placement> + <head>Correspondence:</head> + </tag> + <tag> + <name>download</name> + <placement>a</placement> + <head>Download:</head> + </tag> + </tags> + <show>protected</show> + <failOnError>false</failOnError> + <sourceFileExcludes> + <sourceFileExclude>**/module-info.java</sourceFileExclude> + </sourceFileExcludes> + </configuration> + </plugin> + + <!-- JUnit & JQwik test integration --> + + <!-- junit-platform-maven-plugin: supports modular tests + maven-surefire-plugin: non-modular tests + + Modular testing works via command line mvn, but is + still broken in Eclipse due to this + https://bugs.eclipse.org/bugs/show_bug.cgi?id=520667 + --> + <plugin> + <groupId>de.sormuras.junit</groupId> + <artifactId>junit-platform-maven-plugin</artifactId> + <version>1.0.0-M5</version> + <extensions>true</extensions> + <configuration> + <executor>JAVA</executor> + </configuration> + </plugin> + + <!-- + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>3.0.0-M3</version> + </plugin> + <plugin> + <artifactId>maven-failsafe-plugin</artifactId> + <version>3.0.0-M3</version> + </plugin> --> + + <!-- javafx:jlink: + https://github.com/openjfx/javafx-maven-plugin + Use 'mvn package' instead if you don't need jlink. + + <plugin> + <groupId>org.openjfx</groupId> + <artifactId>javafx-maven-plugin</artifactId> + <version>0.0.3</version> + <configuration> + <mainClass>${project.mainclass}</mainClass> + </configuration> + </plugin> --> + + </plugins> + <extensions> + <!-- Enables the use of SSH for deployments --> + <extension> + <groupId>org.apache.maven.wagon</groupId> + <artifactId>wagon-ssh-external</artifactId> + <version>3.3.3</version> + </extension> + <extension> + <groupId>org.apache.maven.wagon</groupId> + <artifactId>wagon-ssh</artifactId> + <version>3.3.3</version> + </extension> + </extensions> + </build> + <distributionManagement> + <repository> + <id>ftdev</id> + <name>UTU tech ftdev repository</name> + <url>scp://localhost:2222/var/www/maven2</url> + </repository> + </distributionManagement> +</project> diff --git a/bin/project/build.properties b/bin/project/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..6adcdc753fdca1b4b851d8b75426dee24044bf6d --- /dev/null +++ b/bin/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.3.3 diff --git a/bin/project/plugins.sbt b/bin/project/plugins.sbt new file mode 100644 index 0000000000000000000000000000000000000000..37ca261463b6a1800a62a0d5a5279fbb22915638 --- /dev/null +++ b/bin/project/plugins.sbt @@ -0,0 +1,7 @@ +resolvers += Resolver.jcenterRepo + +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9") +addSbtPlugin("net.aichler" % "sbt-jupiter-interface" % "0.8.3") +addSbtPlugin("com.github.xuwei-k" % "sbt-jshell" % "0.1.2") +//addSbtPlugin("org.xerial.sbt" % "sbt-sql-sqlite" % "0.8") +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.4.0") diff --git a/bin/src/main/java/fi/utu/tech/gui/javafx/Dialogs.class b/bin/src/main/java/fi/utu/tech/gui/javafx/Dialogs.class new file mode 100644 index 0000000000000000000000000000000000000000..1562f84c0b6d6736eeac85bee405050ceddfcf05 Binary files /dev/null and b/bin/src/main/java/fi/utu/tech/gui/javafx/Dialogs.class differ diff --git a/bin/src/main/java/fi/utu/tech/gui/javafx/Main.class b/bin/src/main/java/fi/utu/tech/gui/javafx/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..831b20e24b1ade98fa60338102f17021707ebb4d Binary files /dev/null and b/bin/src/main/java/fi/utu/tech/gui/javafx/Main.class differ diff --git a/bin/src/main/java/fi/utu/tech/gui/javafx/MainApp.class b/bin/src/main/java/fi/utu/tech/gui/javafx/MainApp.class new file mode 100644 index 0000000000000000000000000000000000000000..45a02d6c9bfd8442c8fe716d05e5559d56256463 Binary files /dev/null and b/bin/src/main/java/fi/utu/tech/gui/javafx/MainApp.class differ diff --git a/bin/src/main/java/fi/utu/tech/gui/javafx/ResourceLoader.class b/bin/src/main/java/fi/utu/tech/gui/javafx/ResourceLoader.class new file mode 100644 index 0000000000000000000000000000000000000000..4bc43658c164eb9c8be11b69451575124bd21120 Binary files /dev/null and b/bin/src/main/java/fi/utu/tech/gui/javafx/ResourceLoader.class differ diff --git a/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/GimmickController.class b/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/GimmickController.class new file mode 100644 index 0000000000000000000000000000000000000000..1b6faaa7b30110a945cff64d6871593b9d1bb153 Binary files /dev/null and b/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/GimmickController.class differ diff --git a/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/MainApp2.class b/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/MainApp2.class new file mode 100644 index 0000000000000000000000000000000000000000..1eb992795b9b9ea385074f67dec92f997a2352d1 Binary files /dev/null and b/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/MainApp2.class differ diff --git a/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/View.class b/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/View.class new file mode 100644 index 0000000000000000000000000000000000000000..0fad06d169934e1a46b9adcd09346509f3a646c8 Binary files /dev/null and b/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/View.class differ diff --git a/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/View1.class b/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/View1.class new file mode 100644 index 0000000000000000000000000000000000000000..ebf979a26c208689c29533625d6c7fa0e31fe23a Binary files /dev/null and b/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/View1.class differ diff --git a/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/View2.class b/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/View2.class new file mode 100644 index 0000000000000000000000000000000000000000..8a1363ccc12de13b0b77d8a27103650eec902288 Binary files /dev/null and b/bin/src/main/java/fi/utu/tech/gui/javafx/gimmick/View2.class differ diff --git a/bin/src/main/java/fi/utu/tech/gui/javafx/zipper/MainApp1.class b/bin/src/main/java/fi/utu/tech/gui/javafx/zipper/MainApp1.class new file mode 100644 index 0000000000000000000000000000000000000000..7558d140e19f2b3d3a43b4ae01774ddcec654b22 Binary files /dev/null and b/bin/src/main/java/fi/utu/tech/gui/javafx/zipper/MainApp1.class differ diff --git a/bin/src/main/java/fi/utu/tech/gui/javafx/zipper/Zipper.class b/bin/src/main/java/fi/utu/tech/gui/javafx/zipper/Zipper.class new file mode 100644 index 0000000000000000000000000000000000000000..2189885295bb2fca045e3f9d11486833561dc7e2 Binary files /dev/null and b/bin/src/main/java/fi/utu/tech/gui/javafx/zipper/Zipper.class differ diff --git a/bin/src/main/java/fi/utu/tech/gui/javafx/zipper/ZipperController.class b/bin/src/main/java/fi/utu/tech/gui/javafx/zipper/ZipperController.class new file mode 100644 index 0000000000000000000000000000000000000000..63ad565cecd936258732f24b0a3e45a802190fb8 Binary files /dev/null and b/bin/src/main/java/fi/utu/tech/gui/javafx/zipper/ZipperController.class differ diff --git a/src/main/resources/fi/utu/tech/gui/javafx/alien.png b/bin/src/main/resources/fi/utu/tech/gui/javafx/alien.png similarity index 100% rename from src/main/resources/fi/utu/tech/gui/javafx/alien.png rename to bin/src/main/resources/fi/utu/tech/gui/javafx/alien.png diff --git a/src/main/resources/fi/utu/tech/gui/javafx/gimmick.fxml b/bin/src/main/resources/fi/utu/tech/gui/javafx/gimmick.fxml similarity index 100% rename from src/main/resources/fi/utu/tech/gui/javafx/gimmick.fxml rename to bin/src/main/resources/fi/utu/tech/gui/javafx/gimmick.fxml diff --git a/src/main/resources/fi/utu/tech/gui/javafx/hmm.png b/bin/src/main/resources/fi/utu/tech/gui/javafx/hmm.png similarity index 100% rename from src/main/resources/fi/utu/tech/gui/javafx/hmm.png rename to bin/src/main/resources/fi/utu/tech/gui/javafx/hmm.png diff --git a/bin/src/main/resources/fi/utu/tech/gui/javafx/package.png b/bin/src/main/resources/fi/utu/tech/gui/javafx/package.png new file mode 100644 index 0000000000000000000000000000000000000000..643eff6d60113e5e16ab4426c1f3a47ac4878c01 Binary files /dev/null and b/bin/src/main/resources/fi/utu/tech/gui/javafx/package.png differ diff --git a/bin/src/main/resources/fi/utu/tech/gui/javafx/styles.css b/bin/src/main/resources/fi/utu/tech/gui/javafx/styles.css new file mode 100644 index 0000000000000000000000000000000000000000..d1e250b8df11265e6345bd142497f6feee8630e8 --- /dev/null +++ b/bin/src/main/resources/fi/utu/tech/gui/javafx/styles.css @@ -0,0 +1,7 @@ +.scroll-pane { + -fx-background-color:transparent; +} + +.scroll-pane > .viewport { + -fx-background-color: transparent; +} diff --git a/bin/src/main/resources/fi/utu/tech/gui/javafx/zipper.fxml b/bin/src/main/resources/fi/utu/tech/gui/javafx/zipper.fxml new file mode 100644 index 0000000000000000000000000000000000000000..9a011d163b0ec3090860b42f5c8681417ac75f25 --- /dev/null +++ b/bin/src/main/resources/fi/utu/tech/gui/javafx/zipper.fxml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.Insets?> +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.Label?> +<?import javafx.scene.control.TextField?> +<?import javafx.scene.image.Image?> +<?import javafx.scene.image.ImageView?> +<?import javafx.scene.layout.BorderPane?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.text.Font?> + +<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="300.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.0" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fi.utu.tech.gui.javafx.zipper.ZipperController"> + <left> + <ImageView fitHeight="368.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" BorderPane.alignment="CENTER"> + <image> + <Image url="@package.png" /> + </image> + <BorderPane.margin> + <Insets bottom="16.0" left="16.0" right="16.0" top="16.0" /> + </BorderPane.margin> + </ImageView> + </left> + <center> + <BorderPane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER"> + <padding> + <Insets bottom="16.0" left="16.0" right="16.0" top="16.0" /> + </padding> + <center> + <VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0" spacing="16.0" BorderPane.alignment="CENTER"> + <padding> + <Insets bottom="16.0" left="16.0" right="16.0" top="16.0" /> + </padding> + <children> + <HBox alignment="CENTER_LEFT" prefHeight="30.0" prefWidth="200.0"> + <children> + <Label prefHeight="30.0" text="Source: " /> + <TextField fx:id="sourceField" prefHeight="30.0" HBox.hgrow="ALWAYS"> + <HBox.margin> + <Insets left="8.0" right="8.0" /> + </HBox.margin> + </TextField> + <Button maxHeight="30.0" maxWidth="30.0" mnemonicParsing="false" onAction="#chooseSource" prefHeight="30.0" prefWidth="30.0" text="..." /> + </children> + </HBox> + <HBox alignment="CENTER_LEFT" prefHeight="30.0" prefWidth="200.0"> + <children> + <Label prefHeight="30.0" text="Destination:" /> + <TextField fx:id="destField" prefHeight="30.0" HBox.hgrow="ALWAYS"> + <HBox.margin> + <Insets left="8.0" right="8.0" /> + </HBox.margin> + </TextField> + <Button maxHeight="30.0" maxWidth="30.0" mnemonicParsing="false" onAction="#chooseDest" prefHeight="30.0" prefWidth="30.0" text="..." /> + </children> + </HBox> + <Button fx:id="zipItButton" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#zipIt" text="Zip it!" /> + <Label fx:id="statusLabel" text="Loading..." /> + </children></VBox> + </center> + <top> + <Label text="Zip Master 2020" BorderPane.alignment="CENTER"> + <font> + <Font size="26.0" /> + </font></Label> + </top> + </BorderPane> + </center> +</BorderPane> diff --git a/src/main/java/fi/utu/tech/gui/javafx/Main.java b/src/main/java/fi/utu/tech/gui/javafx/Main.java index aebe6ec128f36d4c1006bc2063b7b0e1513c3c6e..a1398bbcbed867834e72c8e73ac5b0e4325308c7 100644 --- a/src/main/java/fi/utu/tech/gui/javafx/Main.java +++ b/src/main/java/fi/utu/tech/gui/javafx/Main.java @@ -1,6 +1,5 @@ package fi.utu.tech.gui.javafx; -import fi.utu.tech.gui.javafx.gimmick.MainApp2; import fi.utu.tech.gui.javafx.zipper.MainApp1; public class Main { @@ -15,17 +14,6 @@ public class Main { public static void main(String[] args) { System.out.println("Launching.."); if (args.length == 1 && args[0].equals("--test")) return; - - int exercise = 1; - if (args.length == 1) exercise = Integer.parseInt(args[0]); - switch (exercise) { - case 1: - MainApp1.launch(MainApp1.class, args); - break; - default: - MainApp2.launch(MainApp2.class, args); - break; - } + MainApp1.launch(MainApp1.class, args); } - -} +} \ No newline at end of file diff --git a/src/main/java/fi/utu/tech/gui/javafx/gimmick/GimmickController.java b/src/main/java/fi/utu/tech/gui/javafx/gimmick/GimmickController.java deleted file mode 100644 index a84cc8c5e059e39230b2de5914d1aa73c8b0fafe..0000000000000000000000000000000000000000 --- a/src/main/java/fi/utu/tech/gui/javafx/gimmick/GimmickController.java +++ /dev/null @@ -1,41 +0,0 @@ -package fi.utu.tech.gui.javafx.gimmick; - -import java.util.ArrayList; - -import fi.utu.tech.gui.javafx.zipper.Zipper; -import javafx.animation.FadeTransition; -import javafx.application.Platform; -import javafx.concurrent.Task; -import javafx.fxml.FXML; -import javafx.scene.layout.TilePane; -import javafx.util.Duration; - -public class GimmickController { - @FXML - private TilePane tilePane; - - public void initialize() { - tilePane.getChildren().clear(); - for (int i = 0; i < 20; i++) { - final int j = i; - - try { Thread.sleep(100); } - catch(Exception e) { - } - /*new Thread(() -> { - View c = j % 2 == 0 ? new View1(150, 150) : new View2(150, 150); - Platform.runLater(() -> tilePane.getChildren().add(c)); - new Thread(c).run(); - }).start();*/ - - - - Platform.runLater(() -> { - View c = j % 2 == 0 ? new View1(150, 150, j) : new View2(150, 150, j); - tilePane.getChildren().add(c); - new Thread(c).start(); - }); - - } - } -} diff --git a/src/main/java/fi/utu/tech/gui/javafx/gimmick/MainApp2.java b/src/main/java/fi/utu/tech/gui/javafx/gimmick/MainApp2.java deleted file mode 100644 index 353ad8da1ca64146f8f0bfdc1e5e25c92dbe6ca6..0000000000000000000000000000000000000000 --- a/src/main/java/fi/utu/tech/gui/javafx/gimmick/MainApp2.java +++ /dev/null @@ -1,20 +0,0 @@ -package fi.utu.tech.gui.javafx.gimmick; - -import fi.utu.tech.gui.javafx.MainApp; -import fi.utu.tech.gui.javafx.ResourceLoader; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.stage.Stage; - -public class MainApp2 extends MainApp { - @Override - public void start(Stage stage) { - ResourceLoader<Parent, GimmickController> loader = new ResourceLoader<>("gimmick.fxml"); - - Scene scene = new Scene(loader.root); - - stage.setTitle("The Gimmick Show"); - stage.setScene(scene); - stage.show(); - } -} \ No newline at end of file diff --git a/src/main/java/fi/utu/tech/gui/javafx/gimmick/View.java b/src/main/java/fi/utu/tech/gui/javafx/gimmick/View.java deleted file mode 100644 index 3dce0c7ba9f44f6df97920c87ca5059ca6e9f7f5..0000000000000000000000000000000000000000 --- a/src/main/java/fi/utu/tech/gui/javafx/gimmick/View.java +++ /dev/null @@ -1,18 +0,0 @@ -package fi.utu.tech.gui.javafx.gimmick; - -import javafx.scene.canvas.Canvas; - -abstract class View extends Canvas implements Runnable { - protected boolean active = true; - - public View(double width, double height) { - super(width, height); - - setOnMouseClicked(e -> { - active = false; - setVisible(false); - setManaged(false); - Thread.currentThread().interrupt(); - }); - } -} \ No newline at end of file diff --git a/src/main/java/fi/utu/tech/gui/javafx/gimmick/View1.java b/src/main/java/fi/utu/tech/gui/javafx/gimmick/View1.java deleted file mode 100644 index 0e256bba63fbd9727f4f95846b1a5051e5710abf..0000000000000000000000000000000000000000 --- a/src/main/java/fi/utu/tech/gui/javafx/gimmick/View1.java +++ /dev/null @@ -1,69 +0,0 @@ -package fi.utu.tech.gui.javafx.gimmick; - -import javafx.application.Platform; -import javafx.scene.image.PixelFormat; -import javafx.scene.image.WritableImage; - -import java.util.Random; -import java.util.Timer; -import java.util.TimerTask; - - -class View1 extends View { - protected final int width, height; - private final WritableImage buffer; - private final int[] data; - int wait; - - View1(int width, int height, int wait) { - super(width, height); - this.width = width; - this.height = height; - this.wait = wait; - buffer = new WritableImage(width, height); - data = new int[width * height]; - } - - public void run() { - launchTimer(); - // uncomment to test if it fails (java.lang.InternalError). - // it should work if you managed to program this correctly! - } - - void render() { - // uncomment to test if it fails - // it should work if you managed to program this correctly! - if (!Platform.isFxApplicationThread()) throw new Error("Wrong thread!"); - - for (int pixelIdx = 0; pixelIdx < data.length; pixelIdx++) { - final int idx = pixelIdx; - data[idx] = new Random().nextInt(200) | ((new Random().nextInt(16) * 16) << 24); - - } - - buffer.getPixelWriter().setPixels( - 0, 0, - width, height, - PixelFormat.getIntArgbPreInstance(), data, 0, width); - - getGraphicsContext2D().clearRect(0.0, 0.0, width, height); - getGraphicsContext2D().drawImage(buffer, 0.0, 0.0); - } - - void launchTimer() { - final Thread t = new Thread(() -> { - Platform.runLater(() -> render()); - }); - try { - Thread.sleep(wait*500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - new Timer().schedule(new TimerTask() { - @Override - public void run() { - t.run(); - } - }, 0l, 1000l); - } -} \ No newline at end of file diff --git a/src/main/java/fi/utu/tech/gui/javafx/gimmick/View2.java b/src/main/java/fi/utu/tech/gui/javafx/gimmick/View2.java deleted file mode 100644 index 3c0a9d8d19f1b84e3369315ce4bb326c11265002..0000000000000000000000000000000000000000 --- a/src/main/java/fi/utu/tech/gui/javafx/gimmick/View2.java +++ /dev/null @@ -1,56 +0,0 @@ -package fi.utu.tech.gui.javafx.gimmick; - -import javafx.application.Platform; -import javafx.scene.paint.Color; - -import java.util.Random; - -class View2 extends View { - protected final int width, height; - int wait; - int laskuri; - - View2(int width, int height, int wait) { - super(width, height); - this.width = width; - this.height = height; - this.wait = wait; - } - - public void run() { - try { - Thread.sleep(wait*500); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } - - while (true) { - Platform.runLater(() -> render()); - try { - Thread.sleep(200 + new Random().nextInt(10) * 100); - } catch (Exception e) { - } - } - } - - void render() { - // uncomment to test if it fails - // it should work if you managed to program this correctly! - if (!Platform.isFxApplicationThread()) throw new Error("Wrong thread!"); - - - if(laskuri == 7) { - laskuri = 0; - getGraphicsContext2D().clearRect(0.0, 0.0, width, height); - getGraphicsContext2D().setFill(new Color(0.5,0,0,0.5)); - getGraphicsContext2D().fillRect(0.0, 0.0, width, height); - getGraphicsContext2D().setFill(new Color(0,0,1,0.9)); - } else { - laskuri++; - getGraphicsContext2D().setFill(new Color(0.5,0,0,0.5)); - getGraphicsContext2D().fillRect(0.0, 0.0, width, height); - getGraphicsContext2D().setFill(new Color(0,0,1,0.9)); - getGraphicsContext2D().fillOval(new Random().nextDouble() * width, new Random().nextDouble() * height, 20, 20); - } - } -} \ No newline at end of file diff --git a/src/main/java/fi/utu/tech/gui/javafx/zipper/MainApp1.java b/src/main/java/fi/utu/tech/gui/javafx/zipper/MainApp1.java index 798b18076676a9f08ef754199799b84497d5eaa8..359de4111a020785fadab56b89d52e5a2fc44e77 100644 --- a/src/main/java/fi/utu/tech/gui/javafx/zipper/MainApp1.java +++ b/src/main/java/fi/utu/tech/gui/javafx/zipper/MainApp1.java @@ -16,7 +16,7 @@ public class MainApp1 extends MainApp { Scene scene = new Scene(loader.root); - stage.setTitle("Zip Master 2020"); + stage.setTitle("ZIP-pakkaaja"); stage.setScene(scene); stage.show(); } diff --git a/src/main/resources/fi/utu/tech/gui/javafx/zipper.fxml b/src/main/resources/fi/utu/tech/gui/javafx/zipper.fxml index 9a011d163b0ec3090860b42f5c8681417ac75f25..0b6a2b40fb506bd03f2000f82624d55a5c7c417a 100644 --- a/src/main/resources/fi/utu/tech/gui/javafx/zipper.fxml +++ b/src/main/resources/fi/utu/tech/gui/javafx/zipper.fxml @@ -60,7 +60,7 @@ </children></VBox> </center> <top> - <Label text="Zip Master 2020" BorderPane.alignment="CENTER"> + <Label text="Näyte INIDIUM:lle" BorderPane.alignment="CENTER"> <font> <Font size="26.0" /> </font></Label>