initial commit

This commit is contained in:
Hendrik Schutter 2019-03-30 22:10:16 +01:00
parent a05dcdde53
commit 6d8aab1d7f
16 changed files with 662 additions and 0 deletions

61
.classpath Normal file
View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="/home/hendrik/.m2/repository/org/openjfx/javafx-graphics/11.0.1/javafx-graphics-11.0.1-linux.jar">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="maven.groupId" value="org.openjfx"/>
<attribute name="maven.artifactId" value="javafx-graphics"/>
<attribute name="maven.version" value="11.0.1"/>
<attribute name="maven.classifier" value="linux"/>
<attribute name="maven.scope" value="compile"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/home/hendrik/.m2/repository/org/openjfx/javafx-controls/11.0.1/javafx-controls-11.0.1-linux.jar">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="maven.groupId" value="org.openjfx"/>
<attribute name="maven.artifactId" value="javafx-controls"/>
<attribute name="maven.version" value="11.0.1"/>
<attribute name="maven.classifier" value="linux"/>
<attribute name="maven.scope" value="compile"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/home/hendrik/.m2/repository/org/openjfx/javafx-controls/11/javafx-controls-11-linux.jar">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="maven.groupId" value="org.openjfx"/>
<attribute name="maven.artifactId" value="javafx-controls"/>
<attribute name="maven.version" value="11"/>
<attribute name="maven.classifier" value="linux"/>
<attribute name="maven.scope" value="compile"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/home/hendrik/.m2/repository/org/openjfx/javafx-fxml/11/javafx-fxml-11-linux.jar" sourcepath="/home/hendrik/.m2/repository/org/openjfx/javafx-fxml/11/javafx-fxml-11-sources.jar">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="maven.groupId" value="org.openjfx"/>
<attribute name="maven.artifactId" value="javafx-fxml"/>
<attribute name="maven.version" value="11"/>
<attribute name="maven.classifier" value="linux"/>
<attribute name="maven.scope" value="compile"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-11-openjdk-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/home/hendrik/.m2/repository/org/openjfx/javafx-base/11/javafx-base-11-linux.jar" sourcepath="/home/hendrik/.m2/repository/org/openjfx/javafx-base/11/javafx-base-11-sources.jar">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="maven.groupId" value="org.openjfx"/>
<attribute name="maven.artifactId" value="javafx-base"/>
<attribute name="maven.version" value="11"/>
<attribute name="maven.classifier" value="linux"/>
<attribute name="maven.scope" value="compile"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>FxStoppuhr</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=9
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=9
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=9

1
bin/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/main/

8
build.fxbuild Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="ASCII"?>
<anttasks:AntTask xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:anttasks="http://org.eclipse.fx.ide.jdt/1.0" buildDirectory="${project}/build">
<deploy>
<application name="FxStoppuhr"/>
<info/>
</deploy>
<signjar/>
</anttasks:AntTask>

89
pom.xml Normal file
View File

@ -0,0 +1,89 @@
<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>
<version>0.0.1</version>
<name>Stoppuhr</name>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>com.jfoenix</groupId>
<artifactId>jfoenix</artifactId>
<version>9.0.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
<!--<release>11</release> -->
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<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>main.java.com.Stoppuhr.application.Main</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<finalName>Stoppuhr</finalName>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.Stoppuhr.application.JavaFX11Main</mainClass>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<artifactId>Stoppuhr</artifactId>
<groupId>application</groupId>
</project>

View File

@ -0,0 +1,10 @@
package main.java.com.Stoppuhr.application;
public class JavaFX11Main
{
public static void main(String[] args)
{
Main.main(args);
}
}

View File

@ -0,0 +1,238 @@
package main.java.com.Stoppuhr.application;
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.animation.Animation.Status;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.util.Duration;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.AnchorPane;
/**
* Praktikum OOSE SS 2018 Aufgabenblatt 3, Aufgabe 4
*
* @author [Hendrik Schutter]
*/
public class Main extends Application
{
@FXML
private Label zeitAnzeige;
@FXML
private AnchorPane mainAnchorpane;
@FXML
private MenuItem menuItemStart;
@FXML
private MenuItem menuItemReset;
@FXML
private MenuItem menuItemClose;
@FXML
private MenuItem menuItemHilfe;
@FXML
private Button startStopButton;
@FXML
private Button resetButton;
private static Timeline timeline;
private int min = 0;
private int sec = 0;
private int mil = 0;
private static boolean timer = true;
@Override
public void start(Stage primaryStage)
{
try {
FXMLLoader loader = new FXMLLoader(
getClass().getResource("/fxml/MainWindow.fxml"));
AnchorPane pane = loader.load();
primaryStage.setTitle("Stoppuhr");
Scene scene = new Scene(pane);
/**
* alle event listener mit fxml-loader
*
*/
scene.getStylesheets().add(
Main.class.getResource("/css/application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch (Exception e) {
e.printStackTrace();
}
}
@FXML
public void menuItemStartAction(ActionEvent event)
{
startOrStopCounting();
}
@FXML
public void menuItemResetAction(ActionEvent event)
{
resetTime();
updateTimeLabel();
}
@FXML
public void menuItemCloseAction(ActionEvent event)
{
System.exit(0);
}
@FXML
public void menuItemHilfeAction(ActionEvent event)
{
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Information");
alert.setHeaderText("Praktikum OOSE SS 2018 Aufgabenblatt 3, Aufgabe 4");
alert.setContentText("Author: Hendrik Schutter - 183129");
alert.showAndWait();
}
@FXML
public void startStopButtonAction(ActionEvent event)
{
startOrStopCounting();
}
@FXML
public void resetButtonAction(ActionEvent event)
{
resetTime();
updateTimeLabel();
}
public static void main(String[] args)
{
launch(args);
}
/**
* Aktualisiert die Zeitanzeige.
*/
private void updateTimeLabel()
{
if (mil > 99) {
sec = sec + 1;
mil = 0;
}
if (sec > 59) {
min = min + 1;
sec = 0;
}
String timeMin = Integer.toString(min);
String timeSec = Integer.toString(sec);
String timeMil = Integer.toString(mil);
if (mil < 10) {
timeMil = "0" + Integer.toString(mil);
}
if (sec < 10) {
timeSec = "0" + Integer.toString(sec);
}
if (min < 10) {
timeMin = "0" + Integer.toString(min);
}
String time = timeMin + ":" + timeSec + ":" + timeMil;
zeitAnzeige.setText(time);
// System.out.println("Die Zeit: " + time);
// Text im Label neu setzen
}
/**
* Diese Methode startet bzw. stoppt die Uhr. Sie soll beim Drücken des
* Start/Stop-Buttons aufgerufen werden.
*/
private void startOrStopCounting()
{
// Je nachdem, ob die Uhr gerade läuft oder nicht:
// Timer pausieren oder starten, dann
if (timer) {
timeline = new Timeline(new KeyFrame(Duration.millis(10), event -> {
incrementTime(); // update time
}));
timeline.setCycleCount(Animation.INDEFINITE);
timer = false;
}
if (timeline.getStatus() == Status.STOPPED
|| timeline.getStatus() == Status.PAUSED) {
timeline.play();
startStopButton.setText("Stop");
menuItemStart.setText("Stop");
} else {
timeline.stop();
startStopButton.setText("Start");
menuItemStart.setText("Start");
}
}
/**
* Diese Methode setzt die Uhr auf 00:00:00 zurück. Sie soll beim Drücken des
* Start/Stop-Buttons aufgerufen werden.
*/
private void resetTime()
{
min = 0;
sec = 0;
mil = 0;
}
/**
* Diese Methode erhöht die Zeit um eine hunderstel Sekunde. Sie muss vom
* Timer (s. Methode 'start') jede hundertstel Sekunde aufgerufen werden.
*/
private void incrementTime()
{
// Zeitvariable(n) erhöhen
// und Anzeige aktualisieren
mil = mil + 1;
updateTimeLabel();
}
}
class InnerClassHandler implements EventHandler<ActionEvent>
{
@Override
public void handle(ActionEvent event)
{
System.out.println("text");
}
}

View File

@ -0,0 +1 @@
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */

View File

@ -0,0 +1,71 @@
<?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.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SeparatorMenuItem?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.text.Font?>
<AnchorPane fx:id="mainAnchorpane" maxHeight="400.0" maxWidth="500.0" minHeight="400.0" minWidth="500.0" prefHeight="400.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/9" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.java.com.Stoppuhr.application.Main">
<children>
<BorderPane prefHeight="400.0" prefWidth="500.0">
<bottom>
<HBox prefHeight="100.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<Button fx:id="startStopButton" maxHeight="30.0" maxWidth="60.0" minHeight="30.0" minWidth="60.0" mnemonicParsing="false" onAction="#startStopButtonAction" prefHeight="30.0" prefWidth="60.0" text="Start">
<font>
<Font name="Cantarell Regular" size="13.0" />
</font>
<HBox.margin>
<Insets left="180.0" top="20.0" />
</HBox.margin>
</Button>
<Button fx:id="resetButton" maxHeight="30.0" maxWidth="60.0" minHeight="30.0" minWidth="60.0" mnemonicParsing="false" onAction="#resetButtonAction" prefHeight="30.0" prefWidth="60.0" text="Reset">
<font>
<Font name="Cantarell Regular" size="13.0" />
</font>
<HBox.margin>
<Insets left="20.0" top="20.0" />
</HBox.margin>
</Button>
</children>
</HBox>
</bottom>
<center>
<Label fx:id="zeitAnzeige" text="00:00:00" textAlignment="CENTER" BorderPane.alignment="CENTER_LEFT">
<font>
<Font name="Cantarell Regular" size="96.0" />
</font>
<padding>
<Insets left="45.0" />
</padding>
</Label>
</center>
<top>
<MenuBar BorderPane.alignment="CENTER">
<menus>
<Menu mnemonicParsing="false" text="Aktion">
<items>
<MenuItem fx:id="menuItemStart" mnemonicParsing="false" onAction="#menuItemStartAction" text="Start" />
<MenuItem fx:id="menuItemReset" mnemonicParsing="false" onAction="#menuItemResetAction" text="Reset" />
<SeparatorMenuItem mnemonicParsing="false" />
<MenuItem fx:id="menuItemClose" mnemonicParsing="false" onAction="#menuItemCloseAction" text="Beenden" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Hilfe">
<items>
<MenuItem fx:id="menuItemHilfe" mnemonicParsing="false" onAction="#menuItemHilfeAction" text="Info" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
</BorderPane>
</children>
</AnchorPane>

View File

@ -0,0 +1,71 @@
<?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.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SeparatorMenuItem?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.text.Font?>
<AnchorPane fx:id="mainAnchorpane" maxHeight="400.0" maxWidth="500.0" minHeight="400.0" minWidth="500.0" prefHeight="400.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/9" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Stoppuhr">
<children>
<BorderPane prefHeight="400.0" prefWidth="500.0">
<bottom>
<HBox prefHeight="100.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<Button fx:id="startStopButton" maxHeight="30.0" maxWidth="60.0" minHeight="30.0" minWidth="60.0" mnemonicParsing="false" onAction="#startStopButtonAction" prefHeight="30.0" prefWidth="60.0" text="Start">
<font>
<Font name="Cantarell Regular" size="13.0" />
</font>
<HBox.margin>
<Insets left="180.0" top="20.0" />
</HBox.margin>
</Button>
<Button fx:id="resetButton" maxHeight="30.0" maxWidth="60.0" minHeight="30.0" minWidth="60.0" mnemonicParsing="false" onAction="#resetButtonAction" prefHeight="30.0" prefWidth="60.0" text="Reset">
<font>
<Font name="Cantarell Regular" size="13.0" />
</font>
<HBox.margin>
<Insets left="20.0" top="20.0" />
</HBox.margin>
</Button>
</children>
</HBox>
</bottom>
<center>
<Label fx:id="zeitAnzeige" text="00:00:00" textAlignment="CENTER" BorderPane.alignment="CENTER_LEFT">
<font>
<Font name="Cantarell Regular" size="96.0" />
</font>
<padding>
<Insets left="45.0" />
</padding>
</Label>
</center>
<top>
<MenuBar BorderPane.alignment="CENTER">
<menus>
<Menu mnemonicParsing="false" text="Aktion">
<items>
<MenuItem fx:id="menuItemStart" mnemonicParsing="false" onAction="#menuItemStartAction" text="Start" />
<MenuItem fx:id="menuItemReset" mnemonicParsing="false" onAction="#menuItemResetAction" text="Reset" />
<SeparatorMenuItem mnemonicParsing="false" />
<MenuItem fx:id="menuItemClose" mnemonicParsing="false" onAction="#menuItemCloseAction" text="Beenden" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Hilfe">
<items>
<MenuItem fx:id="menuItemHilfe" mnemonicParsing="false" onAction="#menuItemHilfeAction" text="Info" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
</BorderPane>
</children>
</AnchorPane>

View File

@ -0,0 +1 @@
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */

View File

@ -0,0 +1 @@
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */

View File

@ -0,0 +1,71 @@
<?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.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SeparatorMenuItem?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.text.Font?>
<AnchorPane fx:id="mainAnchorpane" maxHeight="400.0" maxWidth="500.0" minHeight="400.0" minWidth="500.0" prefHeight="400.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/9" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.java.com.Stoppuhr.application.Main">
<children>
<BorderPane prefHeight="400.0" prefWidth="500.0">
<bottom>
<HBox prefHeight="100.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<Button fx:id="startStopButton" maxHeight="30.0" maxWidth="60.0" minHeight="30.0" minWidth="60.0" mnemonicParsing="false" onAction="#startStopButtonAction" prefHeight="30.0" prefWidth="60.0" text="Start">
<font>
<Font name="Cantarell Regular" size="13.0" />
</font>
<HBox.margin>
<Insets left="180.0" top="20.0" />
</HBox.margin>
</Button>
<Button fx:id="resetButton" maxHeight="30.0" maxWidth="60.0" minHeight="30.0" minWidth="60.0" mnemonicParsing="false" onAction="#resetButtonAction" prefHeight="30.0" prefWidth="60.0" text="Reset">
<font>
<Font name="Cantarell Regular" size="13.0" />
</font>
<HBox.margin>
<Insets left="20.0" top="20.0" />
</HBox.margin>
</Button>
</children>
</HBox>
</bottom>
<center>
<Label fx:id="zeitAnzeige" text="00:00:00" textAlignment="CENTER" BorderPane.alignment="CENTER_LEFT">
<font>
<Font name="Cantarell Regular" size="96.0" />
</font>
<padding>
<Insets left="45.0" />
</padding>
</Label>
</center>
<top>
<MenuBar BorderPane.alignment="CENTER">
<menus>
<Menu mnemonicParsing="false" text="Aktion">
<items>
<MenuItem fx:id="menuItemStart" mnemonicParsing="false" onAction="#menuItemStartAction" text="Start" />
<MenuItem fx:id="menuItemReset" mnemonicParsing="false" onAction="#menuItemResetAction" text="Reset" />
<SeparatorMenuItem mnemonicParsing="false" />
<MenuItem fx:id="menuItemClose" mnemonicParsing="false" onAction="#menuItemCloseAction" text="Beenden" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Hilfe">
<items>
<MenuItem fx:id="menuItemHilfe" mnemonicParsing="false" onAction="#menuItemHilfeAction" text="Info" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
</BorderPane>
</children>
</AnchorPane>

View File

@ -0,0 +1,3 @@
main/java/com/Stoppuhr/application/JavaFX11Main.class
main/java/com/Stoppuhr/application/Main.class
main/java/com/Stoppuhr/application/InnerClassHandler.class

View File

@ -0,0 +1 @@
/home/hendrik/eclipse-workspace/Java/FxStoppuhr/src/main/java/Stoppuhr.java