Skip to content

Commit

Permalink
introduces java 11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
rladstaetter committed Apr 25, 2020
1 parent 20c7af1 commit a15a3a8
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 56 deletions.
61 changes: 57 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<version>2020.1-SNAPSHOT</version>
<packaging>pom</packaging>

<name>nxs.ladstatt.sudoku.pom</name>
<name>nxs.ladstatt.sudoku.sudokufx</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -17,6 +17,7 @@
<opencv.full.version>${opencv.major.version}.0</opencv.full.version>
<opencv.install.path>/Users/lad/custom-builds/opencv-4.3.0/out/</opencv.install.path>
<opencv.java.jar>${opencv.install.path}share/java/opencv4/opencv-430.jar</opencv.java.jar>
<openjfx.version>11.0.2</openjfx.version>
</properties>

<modules>
Expand All @@ -31,6 +32,26 @@

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
Expand Down Expand Up @@ -111,7 +132,6 @@
<arg>-language:implicitConversions</arg>
<arg>-unchecked</arg>
<arg>-Xcheckinit</arg>
<!-- arg>-Xfatal-warnings</arg -->
<arg>-Xlint:adapted-args</arg>
<arg>-Xlint:constant</arg>
<arg>-Xlint:delayedinit-select</arg>
Expand Down Expand Up @@ -139,15 +159,17 @@
<arg>-Ywarn-unused:privates</arg>
<arg>-Ywarn-value-discard</arg>
<arg>-Yrangepos</arg>
<arg>-P:semanticdb:synthetics:on</arg>
<!-- arg>-P:semanticdb:synthetics:on</arg -->
</args>
<!--
<compilerPlugins>
<compilerPlugin>
<groupId>org.scalameta</groupId>
<artifactId>semanticdb-scalac_${scala.full.version}</artifactId>
<version>4.3.9</version>
</compilerPlugin>
</compilerPlugins>
-->
</configuration>
</plugin>
<plugin>
Expand All @@ -169,6 +191,7 @@
</execution>
</executions>
</plugin>
<!--
<plugin>
<groupId>io.github.evis</groupId>
<artifactId>scalafix-maven-plugin</artifactId>
Expand All @@ -186,6 +209,13 @@
</dependency>
</dependencies>
</plugin>
-->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
<!--
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
Expand All @@ -203,6 +233,30 @@
-->
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-jdk</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.6.2</version>
</requireMavenVersion>
<requireJavaVersion>
<version>11</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
Expand All @@ -214,7 +268,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>enforce-opencv</id>
Expand Down
40 changes: 23 additions & 17 deletions sudoku-javafx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,31 @@

<dependencies>
<dependency>
<groupId>net.ladstatt.sudoku</groupId>
<artifactId>sudoku-core</artifactId>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</dependency>
<dependency>
<groupId>org.jfxtras</groupId>
<artifactId>jfxtras-controls</artifactId>
<version>8.0-r4</version>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
</dependency>
<dependency>
<groupId>org.jfxtras</groupId>
<artifactId>jfxtras-labs</artifactId>
<version>8.0-r4</version>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
</dependency>

<dependency>
<groupId>net.ladstatt.sudoku</groupId>
<artifactId>sudoku-core</artifactId>
</dependency>

<dependency>
<groupId>org.scalacheck</groupId>
<artifactId>scalacheck_${scala.major.version}</artifactId>
Expand All @@ -51,13 +59,7 @@
</dependency>
</dependencies>
<build>
<!-- <sourceDirectory>src/main/scala</sourceDirectory> -->
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
</plugin>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
Expand All @@ -79,12 +81,16 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
</plugin>
</plugins>

</plugins>
</build>


Expand Down
17 changes: 4 additions & 13 deletions sudoku-javafx/src/main/resources/net/ladstatt/sudoku/sudokufx.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>
<?import jfxtras.labs.scene.control.gauge.linear.SimpleMetroArcGauge?>
<VBox prefHeight="830.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="net.ladstatt.sudoku.SudokuFXController">
<children>
Expand All @@ -25,31 +24,23 @@
<children>
<TitledPane text="Frame number">
<content>
<SimpleMetroArcGauge fx:id="frameNumberGauge" minHeight="130" maxHeight="130"
minWidth="130"
maxWidth="130"/>


</content>
</TitledPane>
<TitledPane text="Detected Sudokus">
<content>
<SimpleMetroArcGauge fx:id="detectionGauge" minHeight="130" maxHeight="130"
minWidth="130"
maxWidth="130"/>

</content>
</TitledPane>
<TitledPane text="Last detection numbers">
<content>
<SimpleMetroArcGauge fx:id="lastDetectionGauge" minHeight="130" maxHeight="130"
minWidth="130"
maxWidth="130"/>

</content>
</TitledPane>
<TitledPane text="Frame rate">
<content>
<SimpleMetroArcGauge fx:id="frameRateGauge" minHeight="130" maxHeight="130"
minWidth="130"
maxWidth="130"/>

</content>
</TitledPane>
</children>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package net.ladstatt.sudoku

import java.awt.image.BufferedImage
import java.io.{ByteArrayInputStream, File}

import javafx.embed.swing.SwingFXUtils
import javafx.scene.image.Image

import net.ladstatt.core.CanLog
import org.opencv.core.{Mat, MatOfByte, Point}
import org.opencv.imgcodecs.Imgcodecs
Expand All @@ -14,14 +14,14 @@ import scala.concurrent.Future

trait OpenCVJfxUtils extends CanLog {

// TODO profile if toImage or toImage2 is faster
def toImage(mat: Mat): Image = {
// TODO profile if toImage or toImage2 is faster
def toImage(mat: Mat): Image = {
val byteMat = new MatOfByte()
Imgcodecs.imencode(".bmp", mat, byteMat)
new Image(new ByteArrayInputStream(byteMat.toArray))
}

def toImage2(matrix: Mat): Image = logWithTimer("frame2",{
def toImage2(matrix: Mat): Image = logWithTimer("frame2", {
val cols = matrix.cols()
val rows = matrix.rows()
val elemSize = matrix.elemSize()
Expand Down Expand Up @@ -58,7 +58,7 @@ trait OpenCVJfxUtils extends CanLog {
val image = new BufferedImage(cols, rows, lType)
image.getRaster.setDataElements(0, 0, cols, rows, data)
SwingFXUtils.toFXImage(image, null)
} )
})


def convert2PolyLinePoints(points: Iterable[Point]): List[java.lang.Double] = {
Expand Down
17 changes: 0 additions & 17 deletions sudoku-javafx/src/main/scala/net/ladstatt/sudoku/SudokuFX.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import javafx.scene.image.{Image, ImageView}
import javafx.scene.layout.{AnchorPane, FlowPane, VBox}
import javafx.scene.paint.Color
import javafx.scene.shape.{Circle, Polygon, Polyline, Rectangle}
import jfxtras.labs.scene.control.gauge.linear.SimpleMetroArcGauge
import net.ladstatt.core.CanLog
import net.ladstatt.opencv.OpenCV
import org.opencv.core.{Mat, MatOfPoint, Point}
Expand Down Expand Up @@ -106,11 +105,6 @@ class SudokuFXController extends Initializable with OpenCVJfxUtils with CanLog w
@FXML var mainMenuBar: MenuBar = _
@FXML var modeButtons: ToggleGroup = _

@FXML var frameNumberGauge: SimpleMetroArcGauge = _
@FXML var detectionGauge: SimpleMetroArcGauge = _
@FXML var frameRateGauge: SimpleMetroArcGauge = _
@FXML var lastDetectionGauge: SimpleMetroArcGauge = _

@FXML var contourModeChoiceBox: ChoiceBox[Int] = _
@FXML var contourMethodChoiceBox: ChoiceBox[Int] = _
@FXML var contourRatioChoiceBox: ChoiceBox[Int] = _
Expand Down Expand Up @@ -268,14 +262,6 @@ class SudokuFXController extends Initializable with OpenCVJfxUtils with CanLog w
canvas.getChildren.add(sudokuBorder)
canvas.getChildren.addAll(analysisCellBounds.toList.asJava)
canvas.getChildren.addAll(analysisCellCorners.toList.asJava)
frameNumberGauge.setMaxValue(5000)
frameNumberGauge.setMinValue(0)
detectionGauge.setMinValue(0)
detectionGauge.setMaxValue(500)
frameRateGauge.setMinValue(0)
frameRateGauge.setMaxValue(60)
lastDetectionGauge.setMinValue(0)
lastDetectionGauge.setMaxValue(81)

()
}
Expand Down Expand Up @@ -511,11 +497,8 @@ class SudokuFXController extends Initializable with OpenCVJfxUtils with CanLog w
setAnalysisMouseTransparent(false)
updateDigitLibraryView(getCurrentSudokuState.library, as[ImageView](numberFlowPane.getChildren.asScala.toSeq))

frameRateGauge.setValue(Float.float2double(getPerformanceTracker.getAverageFPS))
result match {
case success: SSuccess if success.someSolution.isDefined =>
detectionGauge.setValue(detectionGauge.getValue + 1)
lastDetectionGauge.setValue(Int.int2double(success.sudokuFrame.detectedCells.length))
updateStatus(mkFps(success.inputFrame.pipeline.start), Color.GREEN)
case onlyCorners: SSuccess if onlyCorners.someSolution.isEmpty =>
updateStatus(mkFps(onlyCorners.inputFrame.pipeline.start), Color.ORANGE)
Expand Down

0 comments on commit a15a3a8

Please sign in to comment.