Upload new file

parent c834f282
Pipeline #2793 skipped
package org.uebung7.gui;
/*
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.scene.layout.GridPane;
import javafx.geometry.Pos;
/**
* GUI Uebungsblatt 7 + 8
* @author mariabarbatei
*
*/
/*
@SuppressWarnings("restriction")
public class Uebung7Gui extends Application implements EventHandler<ActionEvent> {
private static Button btnAufgabe1 = new Button();
private static Button btnAufgabe2 = new Button();
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
StackPane root = new StackPane();
GridPane grid = new GridPane();
primaryStage.setTitle("Uebung 7 + 8");
btnAufgabe1.setText("Aufgabe 1");
btnAufgabe2.setText("Aufgabe 2 + 3");
grid.setAlignment(Pos.CENTER);
grid.setVgap(10);
//add two grid two buttons
grid.add(btnAufgabe1, 2, 1);
grid.add(btnAufgabe2, 2, 2);
root.getChildren().add(grid);
primaryStage.setScene(new Scene(root, 300, 250));
//display box
primaryStage.show();
}
@Override
public void handle(ActionEvent event) {
// TODO Auto-generated method stub
}
}
*/
import java.util.Scanner;
import javafx.application.Application;
import java.awt.Desktop;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.event.ActionEvent;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import java.io.File;
import java.io.IOException;
import javafx.scene.input.MouseEvent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollBar;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
/**
*
*/
@SuppressWarnings("restriction")
public class Uebung7Gui extends Application {
// Für den einfach Zugriff mit statischen globalen Variablen gelöst
static TextField centertextfield = new TextField();
TreeView<String> tree;
static TreeItem<String> root = new TreeItem<String>();
static TreeItem<String> tmp_id = new TreeItem<String>();
static TreeItem<String> tmp_prop = new TreeItem<String>();
private String arztbrief = "";
private Desktop desktop = Desktop.getDesktop();
public static void main( String[] args )
{
launch(args); // Für das Window
// Surpress logging via log4J
org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.OFF);
}
@Override
public void start(Stage primaryStage) {
//Root von vornherein ausgeklappt darstellen
root.setExpanded(true);
//Baum erstellen und Wurzel verstecken
tree = new TreeView<>(root);
tree.setShowRoot(false);
//Baum interaktiv gestalten (Blätter können angegklickt werden)
tree.getSelectionModel().selectedItemProperty()
.addListener((v, oldValue, newValue) -> {
if (newValue != null)
// Aktion beim Ankicken des jeweiligen Blattes
System.out.println(newValue.getValue()); // Zum Testen Value des Blatts ausgeben
});
// Allgemeines
primaryStage.setTitle("Übungsblatt 7+8 - Gruppe 2"); // Titel des Windows
BorderPane bp = new BorderPane(); // BorderPane initialisieren
bp.setPadding(new Insets(10, 20, 10, 20));
final FileChooser fileChooser = new FileChooser();
final Button btnBrowse = new Button("Arztbrief auswählen");
final Button btnJSON = new Button("Als JSON exportieren");
final Button btnAnalyze = new Button("Arztbrief analysieren");
btnBrowse.setOnAction(
new EventHandler<ActionEvent>() {
@Override
public void handle(final ActionEvent e) {
configureFileChooser(fileChooser);
File file = fileChooser.showOpenDialog(primaryStage);
if (file != null) {
arztbrief = file.getPath();
}
}
});
btnAnalyze.setOnAction(
new EventHandler<ActionEvent>() {
@Override
public void handle(final ActionEvent e) {
//Arztbrief ans Backend übergeben
System.out.println(arztbrief);
}
});
// Elemente des TopPanes initialisieren
Insets standardabstand = new Insets (10, 10, 10, 10);
Label toplabel1 = new Label("Arztbrief auswählen");
toplabel1.setPadding(standardabstand);
HBox topbox1 = new HBox(20);
topbox1.setPadding(standardabstand);
HBox topbox2 = new HBox(20);
topbox2.setPadding(standardabstand);
VBox main_topbox = new VBox(5);
topbox1.getChildren().setAll(btnBrowse);
topbox2.getChildren().setAll(btnAnalyze);
main_topbox.getChildren().setAll(topbox1, topbox2);
bp.setTop(main_topbox);
// Elemente der TreeView (LeftPane) initialisieren
VBox leftbox = new VBox();
Label treelabel = new Label("Gefundene Diagnosen");
leftbox.getChildren().setAll(treelabel, tree);
bp.setLeft(leftbox);
// Elemente für Standardausgabe (CenterPane) in JSON initialisieren
VBox centerbox_main = new VBox();
Label centerlabel = new Label("Weitere Informationen zur Diagnose (wikidata zeugs)");
centertextfield.setPadding(new Insets(10, 10, 10, 10));
centertextfield.setPrefSize(510, 400);
centertextfield.setMaxSize(510, 400);
centertextfield.setEditable(false);
centerbox_main.getChildren().setAll(centerlabel, centertextfield);
centerbox_main.setTranslateX(55);
bp.setCenter(centerbox_main);
Scene scene = new Scene(bp, 900, 600);
primaryStage.setScene(scene);
primaryStage.show();
//Elemente der BottomPane initialisieren
//btnJSON.setTranslateX(scene.getWidth()*0.75);
bp.setBottom(btnJSON);
}
/* handle wird aufgerufen sobald ein Button geklickt wird
@Override
public void handle(ActionEvent event) {
if (event.getSource() == btnJSON) {
}
}
*/
private static void configureFileChooser(
final FileChooser fileChooser) {
fileChooser.setTitle("Arztbrief auswählen");
fileChooser.setInitialDirectory(
new File(System.getProperty("user.home"))
);
fileChooser.getExtensionFilters().addAll(
//new FileChooser.ExtensionFilter("All Images", "*.*"),
new FileChooser.ExtensionFilter("Textdokumente (.txt)", "*.txt")
);
}
public static void CreateTree (String ID) {
// tmp beinhaltet immer die aktuelle ID zu der die Properties als Blätter hinzugefügt werden
tmp_id = makeBranch(ID, root);
}
public static void AddToTree (String ID ) {
tmp_prop = makeBranch(ID, tmp_id);
}
//Create branches
static public TreeItem<String> makeBranch(String title, TreeItem<String> parent) {
TreeItem<String> item = new TreeItem<>(title);
item.setExpanded(false);
parent.getChildren().add(item);
return item;
}
// GETTER-Methode um den ausgewählten Arztbrief ans Backend zu übergeben (als Pfad)
public String GetArztbrief () {
return arztbrief;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment