Skip to content

Commit f838e96

Browse files
committed
fixed small bugs and added Launcher for fat jar
1 parent 11cf4a9 commit f838e96

File tree

8 files changed

+78
-18
lines changed

8 files changed

+78
-18
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea
22
out/
33
target/
4+
shade/
45
*.iml

Diff for: README.md

+3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ Main features:
1010
- OpenJFX
1111

1212
# Running
13+
There are several ways to run the application. If you have JDK installed you can use maven wrapper to compile and run application.
1314
```shell script
1415
./mvnw javafx:run
1516
```
17+
18+
Another way is to download binary package and run shell script `run.sh` or `run.bat` from the command line.
1619
# Example sreenshots
1720
![](https://github.com/vadimkim/dotmatrix/raw/master/images/single_segment.png "single segment")
1821
![](https://github.com/vadimkim/dotmatrix/raw/master/images/multi_segment.png "multi segment")

Diff for: pom.xml

+52-9
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,44 @@
88
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
99
<maven.compiler.source>13</maven.compiler.source>
1010
<maven.compiler.target>13</maven.compiler.target>
11+
<javafx.version>13.0.1</javafx.version>
1112
</properties>
1213
<dependencies>
1314
<dependency>
1415
<groupId>org.openjfx</groupId>
1516
<artifactId>javafx-controls</artifactId>
16-
<version>13.0.1</version>
17+
<version>${javafx.version}</version>
1718
</dependency>
1819
<dependency>
1920
<groupId>org.openjfx</groupId>
2021
<artifactId>javafx-fxml</artifactId>
21-
<version>13.0.1</version>
22+
<version>${javafx.version}</version>
23+
</dependency>
24+
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
25+
<dependency>
26+
<groupId>commons-codec</groupId>
27+
<artifactId>commons-codec</artifactId>
28+
<version>1.13</version>
29+
</dependency>
30+
31+
<!-- Uncomment for cross-platform fat jar-->
32+
<dependency>
33+
<groupId>org.openjfx</groupId>
34+
<artifactId>javafx-graphics</artifactId>
35+
<version>${javafx.version}</version>
36+
<classifier>win</classifier>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.openjfx</groupId>
40+
<artifactId>javafx-graphics</artifactId>
41+
<version>${javafx.version}</version>
42+
<classifier>linux</classifier>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.openjfx</groupId>
46+
<artifactId>javafx-graphics</artifactId>
47+
<version>${javafx.version}</version>
48+
<classifier>mac</classifier>
2249
</dependency>
2350
</dependencies>
2451
<build>
@@ -36,16 +63,32 @@
3663
<artifactId>javafx-maven-plugin</artifactId>
3764
<version>0.0.3</version>
3865
<configuration>
39-
<stripDebug>true</stripDebug>
40-
<compress>2</compress>
41-
<noHeaderFiles>true</noHeaderFiles>
42-
<noManPages>true</noManPages>
43-
<launcher>dotmatrix</launcher>
44-
<jlinkImageName>dotmatrix</jlinkImageName>
45-
<jlinkZipName>dotmatrix.zip</jlinkZipName>
4666
<mainClass>ee.ant.dotmatrix.App</mainClass>
4767
</configuration>
4868
</plugin>
69+
<plugin>
70+
<groupId>org.apache.maven.plugins</groupId>
71+
<artifactId>maven-shade-plugin</artifactId>
72+
<version>3.2.0</version>
73+
<executions>
74+
<execution>
75+
<phase>package</phase>
76+
<goals>
77+
<goal>shade</goal>
78+
</goals>
79+
<configuration>
80+
<shadedArtifactAttached>true</shadedArtifactAttached>
81+
<shadedClassifierName>project-classifier</shadedClassifierName>
82+
<outputFile>shade\${project.artifactId}.jar</outputFile>
83+
<transformers>
84+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
85+
<mainClass>ee.ant.dotmatrix.Launcher</mainClass>
86+
</transformer>
87+
</transformers>
88+
</configuration>
89+
</execution>
90+
</executions>
91+
</plugin>
4992
</plugins>
5093
</build>
5194
</project>

Diff for: run.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@ECHO OFF
2-
java -jar target\dotmatrix-1.0.0-RELEASE.jar
2+
java -jar shade\dot-matrix.jar

Diff for: run.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
#!/bin/sh
2-
./mvnw clean package
3-
java -jar target/dot-matrix-1.1.0.jar
2+
java -jar shade/dot-matrix.jar

Diff for: src/main/java/ee/ant/dotmatrix/App.java

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import javafx.scene.image.Image;
99
import javafx.stage.Stage;
1010

11-
import java.util.Objects;
12-
1311
/**
1412
* JavaFX App
1513
*/

Diff for: src/main/java/ee/ant/dotmatrix/Launcher.java

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package ee.ant.dotmatrix;
2+
3+
public class Launcher {
4+
5+
public static void main(String[] args) {
6+
App.main(args);
7+
}
8+
}

Diff for: src/main/java/ee/ant/dotmatrix/PrimaryController.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
import javafx.scene.image.ImageView;
99
import javafx.scene.layout.*;
1010
import javafx.scene.paint.Color;
11+
import org.apache.commons.codec.DecoderException;
12+
import org.apache.commons.codec.binary.Hex;
1113

1214
import java.util.ArrayList;
1315
import java.util.Arrays;
14-
import java.util.Base64;
1516
import java.util.List;
1617

1718
public class PrimaryController {
@@ -71,7 +72,13 @@ private void initialize() {
7172
rbutton1616.setOnAction(event -> createEmptyMatrix(16, 16));
7273

7374
// Handle draw button event
74-
drawButton.setOnAction(event -> parseHexString(hexString.getText()));
75+
drawButton.setOnAction(event -> {
76+
try {
77+
parseHexString(hexString.getText());
78+
} catch (DecoderException e) {
79+
e.printStackTrace();
80+
}
81+
});
7582

7683
// default is 5x8 matrix
7784
createEmptyMatrix(8, 5);
@@ -151,7 +158,7 @@ private void drawLines(int columns) {
151158
*
152159
* @param text - line with symbol hex code. Either for single segment or 4 segments
153160
*/
154-
private void parseHexString(String text) {
161+
private void parseHexString(String text) throws DecoderException {
155162
// Assume that hex string contains words separated by comas like
156163
// 0x00, 0x07, 0x05, 0x07, 0x00
157164
// create corresponding byte[] array
@@ -160,7 +167,8 @@ private void parseHexString(String text) {
160167
.replace("0x", "")
161168
.replace(",", "")
162169
.replace(" ", "");
163-
var bytes = Base64.getMimeDecoder().decode(binaryString.getBytes());
170+
171+
var bytes = Hex.decodeHex(binaryString);
164172
fillMatrixWithDots(bytes);
165173
}
166174

0 commit comments

Comments
 (0)