Skip to content
Snippets Groups Projects
Commit a92a178b authored by Dennis Eisold's avatar Dennis Eisold
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #133 failed with stages
in 1 minute and 51 seconds
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file://C:/javafx-sdk-11.0.2/lib" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://C:/javafx-sdk-11.0.2/lib" />
</SOURCES>
<jarDirectory url="file://C:/javafx-sdk-11.0.2/lib" recursive="false" />
<jarDirectory url="file://C:/javafx-sdk-11.0.2/lib" recursive="false" type="SOURCES" />
</library>
</orderEntry>
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/resources" type="java-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file://C:/javafx-sdk-11.0.2/lib" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://C:/javafx-sdk-11.0.2/lib" />
</SOURCES>
<jarDirectory url="file://C:/javafx-sdk-11.0.2/lib" recursive="false" />
<jarDirectory url="file://C:/javafx-sdk-11.0.2/lib" recursive="false" type="SOURCES" />
</library>
</orderEntry>
</component>
</module>
\ No newline at end of file
package pausenuhr;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import pausenuhr.model.TrayNotification;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("view/Pausenuhr.fxml"));
primaryStage.setTitle("Pausenuhr");
primaryStage.setScene(new Scene(root));
primaryStage.show();
primaryStage.setAlwaysOnTop(true);
TrayNotification tim = new TrayNotification();
tim.showTray("Pausenuhr gestartet");
}
}
package pausenuhr.model;
import javax.swing.*;
import java.awt.*;
public class TrayNotification {
public void showTray(String message) {
String header = "Pausenuhr";
JFrame frame = new JFrame();
frame.setSize(300,125);
frame.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridx = 0;
constraints.gridy = 0;
constraints.weightx = 1.0f;
constraints.weighty = 1.0f;
constraints.insets = new Insets(5, 5, 5, 5);
constraints.fill = GridBagConstraints.BOTH;
JLabel headingLabel = new JLabel(header);
//headingLabel .setIcon("images/icon.png"); // --- use image icon you want to be as heading image.
headingLabel.setOpaque(false);
frame.add(headingLabel, constraints);
constraints.gridx++;
constraints.weightx = 0f;
constraints.weighty = 0f;
constraints.fill = GridBagConstraints.NONE;
constraints.anchor = GridBagConstraints.NORTH;
constraints.gridx = 0;
constraints.gridy++;
constraints.weightx = 1.0f;
constraints.weighty = 1.0f;
constraints.insets = new Insets(5, 5, 5, 5);
constraints.fill = GridBagConstraints.BOTH;
JLabel messageLabel = new JLabel("<HtMl>" + message);
frame.add(messageLabel, constraints);
frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
frame.setUndecorated(true);
frame.setVisible(true);
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();// size of the screen
Insets toolHeight = Toolkit.getDefaultToolkit().getScreenInsets(frame.getGraphicsConfiguration());// height of the task bar
frame.setLocation(scrSize.width - frame.getWidth(), scrSize.height - toolHeight.bottom - frame.getHeight());
new Thread(){
@Override
public void run() {
try {
Thread.sleep(5000); // time after which pop up will be disappeared.
frame.dispose();
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();
}
}
package pausenuhr.model;
public enum Zustand {
UNTERRICHT, PAUSE, FREIZEIT;
}
package pausenuhr.model;
import java.time.LocalTime;
public class ZustandBestimmen {
/**
* Bestimmt anhand der übergebenen Uhrzeit den Zustand ob es sich um Unterricht, Pause oder Freizeit handelt
* für normale Wochen mit einer Unterrichtszeit von 8:30 - 15:35
*
* @param zeit Zeit zu der der Zustand zurückgegeben werden soll
* @return Der zu der übergebenen Zeit passende Zustand aus der Klasse "Zustand"
*/
public static Zustand aktuellerZustandNormal(LocalTime zeit) {
if (zeit.isAfter(LocalTime.of(8, 29, 59, 999999)) && zeit.isBefore(LocalTime.of(15, 35))) {
// Hiermit ist sichergestellt, dass sich die übergebene Zeit zwischen 8:30 und 15:35 befindet
if (zeit.isBefore(LocalTime.of(10,00))) {
return Zustand.UNTERRICHT;
} else if (zeit.isBefore(LocalTime.of(10,15))) {
return Zustand.PAUSE;
} else if (zeit.isBefore(LocalTime.of(11,45))) {
return Zustand.UNTERRICHT;
} else if (zeit.isBefore(LocalTime.of(11,50))) {
return Zustand.PAUSE;
} else if (zeit.isBefore(LocalTime.of(12,35))) {
return Zustand.UNTERRICHT;
} else if (zeit.isBefore(LocalTime.of(13,15))) {
return Zustand.PAUSE;
} else if (zeit.isBefore(LocalTime.of(14,45))) {
return Zustand.UNTERRICHT;
} else if (zeit.isBefore(LocalTime.of(14,50))) {
return Zustand.PAUSE;
} else {
return Zustand.UNTERRICHT;
}
} else {
return Zustand.FREIZEIT;
}
}
/**
* Bestimmt anhand der übergebenen Uhrzeit den Zustand ob es sich um Unterricht, Pause oder Freizeit handelt
* für lange Wochen mit einer Unterrichtszeit von 8:30 - 17:10
*
* @param zeit Zeit zu der der Zustand zurückgegeben werden soll
* @return Der zu der übergebenen Zeit passende Zustand aus der Klasse "Zustand"
*/
public static Zustand aktuellerZustandLang(LocalTime zeit) {
if (zeit.isAfter(LocalTime.of(8, 29, 59, 999999)) && zeit.isBefore(LocalTime.of(17, 10))) {
// Hiermit ist sichergestellt, dass sich die übergebene Zeit zwischen 8:30 und 17:10 befindet
if (zeit.isBefore(LocalTime.of(10,00))) {
return Zustand.UNTERRICHT;
} else if (zeit.isBefore(LocalTime.of(10,15))) {
return Zustand.PAUSE;
} else if (zeit.isBefore(LocalTime.of(11,45))) {
return Zustand.UNTERRICHT;
} else if (zeit.isBefore(LocalTime.of(11,50))) {
return Zustand.PAUSE;
} else if (zeit.isBefore(LocalTime.of(12,35))) {
return Zustand.UNTERRICHT;
} else if (zeit.isBefore(LocalTime.of(13,15))) {
return Zustand.PAUSE;
} else if (zeit.isBefore(LocalTime.of(14,45))) {
return Zustand.UNTERRICHT;
} else if (zeit.isBefore(LocalTime.of(14,50))) {
return Zustand.PAUSE;
} else if (zeit.isBefore(LocalTime.of(16,20))) {
return Zustand.UNTERRICHT;
} else if (zeit.isBefore(LocalTime.of(16,25))) {
return Zustand.PAUSE;
} else {
return Zustand.UNTERRICHT;
}
} else {
return Zustand.FREIZEIT;
}
}
/**
* Bestimmt anhand der übergebenen Uhrzeit die Dauer bis zum nächsten Zustandswechsel
* für normale Wochen mit einer Unterrichtszeit von 8:30 - 15:35
*
* @param zeit Zeit zu der die Endzeit ermittelt werden soll
* @return Die zu der übergebenen Zeit passende Endzeit
*/
public static LocalTime aktuellerZustandNormalBis(LocalTime zeit) {
if (zeit.isBefore(LocalTime.of(8,30))) {
return LocalTime.of(8, 30);
} else if (zeit.isBefore(LocalTime.of(10,00))) {
return LocalTime.of(10, 00);
} else if (zeit.isBefore(LocalTime.of(10,15))) {
return LocalTime.of(10, 15);
} else if (zeit.isBefore(LocalTime.of(11,45))) {
return LocalTime.of(11, 45);
} else if (zeit.isBefore(LocalTime.of(11,50))) {
return LocalTime.of(11, 50);
} else if (zeit.isBefore(LocalTime.of(12,35))) {
return LocalTime.of(12, 35);
} else if (zeit.isBefore(LocalTime.of(13,15))) {
return LocalTime.of(13, 15);
} else if (zeit.isBefore(LocalTime.of(14,45))) {
return LocalTime.of(14, 45);
} else if (zeit.isBefore(LocalTime.of(14,50))) {
return LocalTime.of(14, 50);
}else if (zeit.isBefore(LocalTime.of(15,35))) {
return LocalTime.of(15, 35);
} else {
return LocalTime.of(8, 30);
}
}
/**
* Bestimmt anhand der übergebenen Uhrzeit die Dauer bis zum nächsten Zustandswechsel
* für lange Wochen mit einer Unterrichtszeit von 8:30 - 17:10
*
* @param zeit Zeit zu der die Endzeit ermittelt werden soll
* @return Die zu der übergebenen Zeit passende Endzeit
*/
public static LocalTime aktuellerZustandLangBis(LocalTime zeit) {
if (zeit.isBefore(LocalTime.of(8,30))) {
return LocalTime.of(8, 30);
} else if (zeit.isBefore(LocalTime.of(10,00))) {
return LocalTime.of(10, 00);
} else if (zeit.isBefore(LocalTime.of(10,15))) {
return LocalTime.of(10, 15);
} else if (zeit.isBefore(LocalTime.of(11,45))) {
return LocalTime.of(11, 45);
} else if (zeit.isBefore(LocalTime.of(11,50))) {
return LocalTime.of(11, 50);
} else if (zeit.isBefore(LocalTime.of(12,35))) {
return LocalTime.of(12, 35);
} else if (zeit.isBefore(LocalTime.of(13,15))) {
return LocalTime.of(13, 15);
} else if (zeit.isBefore(LocalTime.of(14,45))) {
return LocalTime.of(14, 45);
} else if (zeit.isBefore(LocalTime.of(14,50))) {
return LocalTime.of(14, 50);
} else if (zeit.isBefore(LocalTime.of(16,20))) {
return LocalTime.of(16, 20);
} else if (zeit.isBefore(LocalTime.of(16,25))) {
return LocalTime.of(16, 25);
} else if (zeit.isBefore(LocalTime.of(17,10))) {
return LocalTime.of(17, 10);
}else {
return LocalTime.of(8, 30);
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.Cursor?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.RowConstraints?>
<GridPane alignment="center" hgap="10" vgap="10" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="pausenuhr.view.PausenuhrController">
<columnConstraints>
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints />
</rowConstraints>
<children>
<Pane prefHeight="35.0" prefWidth="594.0">
<children>
<Label fx:id="lblZeit" alignment="CENTER" contentDisplay="CENTER" layoutX="14.0" layoutY="9.0" prefHeight="17.0" prefWidth="176.0" text="test" textAlignment="CENTER">
<cursor>
<Cursor fx:constant="DEFAULT" />
</cursor>
</Label>
<Label fx:id="lblZustand" alignment="CENTER" contentDisplay="CENTER" layoutX="190.0" layoutY="9.0" prefHeight="17.0" prefWidth="393.0" text="" textAlignment="CENTER">
<cursor>
<Cursor fx:constant="DEFAULT" />
</cursor>
</Label>
</children>
</Pane>
</children>
</GridPane>
package pausenuhr.view;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import pausenuhr.model.TrayNotification;
import pausenuhr.model.ZustandBestimmen;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
public class PausenuhrController {
String lastState = null;
@FXML
private Label lblZeit;
@FXML
private Label lblZustand;
@FXML
void initialize() {
assert lblZeit != null : "fx:id=\"lblZeit\" was not injected: check your FXML file 'sample.fxml'.";
assert lblZustand != null : "fx:id=\"lblZustand\" was not injected: check your FXML file 'sample.fxml'.";
lblZeit.setText("Aktuelle Zeit:\n16:28:01");
lblZustand.setText("UNTERRICHT bis\n17:10:00");
start();
}
public void aktuellerZustand() {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HH:mm:ss");
LocalTime jetzt = LocalTime.now();
String tempState = String.valueOf(ZustandBestimmen.aktuellerZustandLang(jetzt));
if (this.lastState != null && this.lastState != tempState) {
TrayNotification tim = new TrayNotification();
tim.showTray(tempState);
}
this.lastState = tempState;
lblZeit.setText("Aktuelle Zeit: " + dtf.format(jetzt));
lblZustand.setText(this.lastState + " bis " + dtf.format(ZustandBestimmen.aktuellerZustandLangBis(jetzt)));
}
public void start() {
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
}
Platform.runLater(new Runnable() {
@Override
public void run() {
aktuellerZustand();
}
});
}
}
}).start();
}
}
src/resources/images/icon.png

216 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment