Skip to content
Snippets Groups Projects
Commit 11097450 authored by Eilert Tunheim's avatar Eilert Tunheim
Browse files

Rewritten gui from FXML file to custom JavaFX code. Basic gui with...

Rewritten gui from FXML file to custom JavaFX code. Basic gui with functionality to plot graphs to play around with.
parent f22da23e
No related branches found
No related tags found
No related merge requests found
Showing
with 218 additions and 15 deletions
<component name="libraryTable">
<library name="Maven: org.controlsfx:controlsfx:8.40.14">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/controlsfx/controlsfx/8.40.14/controlsfx-8.40.14.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/controlsfx/controlsfx/8.40.14/controlsfx-8.40.14-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/controlsfx/controlsfx/8.40.14/controlsfx-8.40.14-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.jfxtras:jmetro:8.6.9">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jfxtras/jmetro/8.6.9/jmetro-8.6.9.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/jfxtras/jmetro/8.6.9/jmetro-8.6.9-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jfxtras/jmetro/8.6.9/jmetro-8.6.9-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
......@@ -52,5 +52,7 @@
<orderEntry type="library" name="Maven: com.google.cloud:google-cloud-storage:2.4.0" level="project" />
<orderEntry type="library" name="Maven: com.google.apis:google-api-services-storage:v1-rev20211201-1.32.1" level="project" />
<orderEntry type="library" name="Maven: com.google.auto.value:auto-value-annotations:1.9" level="project" />
<orderEntry type="library" name="Maven: org.jfxtras:jmetro:8.6.9" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.controlsfx:controlsfx:8.40.14" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -46,7 +46,7 @@ public class DB {
// Step 2: Prepare query job
// A "QueryJob" is a type of job that executes SQL queries
// we create a new job configuration from our SQL query and
final String GET_WORD_COUNT = "SELECT VariantValue, TimeStamp FROM sf-drying-optimization.124.int_sd_winccsensordata WHERE TimeStamp BETWEEN \"2020-06-09\" AND \"2020-06-29\" ORDER BY TimeStamp";
final String GET_WORD_COUNT = "SELECT VariantValue, TimeStamp FROM sf-drying-optimization.124.int_sd_winccsensordata WHERE treeSpecies LIKE AND TimeStamp BETWEEN \"2020-06-09\" AND \"2020-06-29\" ORDER BY TimeStamp";
QueryJobConfiguration queryConfig =
QueryJobConfiguration.newBuilder(GET_WORD_COUNT).build();
......
package com.application.DB;
public class Sort {
}
package com.application;
import com.application.DB.DB;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.chart.LineChart;
import javafx.scene.control.ToggleButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Objects;
......@@ -18,6 +32,12 @@ import java.util.Objects;
*/
public class Main extends Application {
private BorderPane topBar;
private HBox menuBar;
private HBox logoBar;
private VBox sideBar;
private LineChart lineChart;
/**
* Starts the application
* @param args
......@@ -27,6 +47,22 @@ public class Main extends Application {
launch(args);
}
/**
* Initializes the application with all the different panes.
*
* @throws Exception Exception in super.
*/
@Override
public void init() throws Exception {
super.init();
// Initializing variables
this.topBar = new BorderPane();
this.menuBar = new HBox();
this.logoBar = new HBox();
this.sideBar = new VBox();
}
/**
* Sets the primaryStage and sets the scene for the window.
* @param primaryStage
......@@ -35,18 +71,138 @@ public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
DB.getFromExistingTable();
// Create panes for root
BorderPane root = new BorderPane();
this.menuBar = createMenuBar();
this.logoBar = createLogoBar();
this.lineChart = createLineChart();
// Sets alignment for the topBar
this.topBar.setTop(menuBar);
this.topBar.setCenter(logoBar);
this.sideBar.setMinWidth(300);
//Set id for panes
root.setId("root");
this.menuBar.setId("menuBar");
// Sets alignment for the panes to the parent root
root.setTop(this.topBar);
root.setLeft(this.sideBar);
root.setCenter(this.lineChart);
// Loading the GUI-fxml file from resources
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/com.application/GUI/graphical_user_interface.fxml")));
// Sets the scene and defines boundaries
//Scene scene = new Scene(root, 1200, 600);
Scene scene = new Scene(root, 1200, 600);
primaryStage.setMaximized(true);
scene.getStylesheets().add(Objects.requireNonNull(getClass().getResource("/com.application/styleSheet.css")).toExternalForm());
primaryStage.setTitle("Moelven Drying Application");
//primaryStage.setMaximized(true);
primaryStage.setMinHeight(600);
primaryStage.setMinWidth(1200);
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* Creates the menubar with buttons.
* Defines each action when button is clicked.
*
* @return MenuBar as a HBox
*/
private HBox createMenuBar() {
// Creating buttons for menubar
ToggleGroup btnMenuGroup = new ToggleGroup();
ToggleButton btnMenuHome = new ToggleButton("Home");
ToggleButton btnMenuInput = new ToggleButton("Input");
ToggleButton btnMenuFinish = new ToggleButton("Finish");
ToggleButton btnMenuHelp = new ToggleButton("Help");
// Set the buttons toggleable
btnMenuHome.setToggleGroup(btnMenuGroup);
btnMenuInput.setToggleGroup(btnMenuGroup);
btnMenuFinish.setToggleGroup(btnMenuGroup);
btnMenuHelp.setToggleGroup(btnMenuGroup);
// Set the home button as default selected
btnMenuHome.setSelected(true);
//Make sure always one button is selected
btnMenuGroup.selectedToggleProperty().addListener((obsVal, oldVal, newVal) -> {
if (newVal == null)
oldVal.setSelected(true);
});
/*
btnMenuMetaImage.setOnAction(e -> featurePane.loadMetaImage());
btnMenuImport.setOnAction(e -> featurePane.loadImport());
btnMenuCreate.setOnAction(e -> featurePane.loadCreate());
btnMenuSearch.setOnAction(e -> featurePane.loadSearch());
*/
menuBar.getChildren().addAll(btnMenuHome, btnMenuInput, btnMenuFinish, btnMenuHelp);
return menuBar;
}
private HBox createLogoBar() throws FileNotFoundException {
//Creating an image
Image moelvenLogoM = new Image(new FileInputStream("src/main/resources/com.application/GUI/moelven_logo_m.jpg"));
Image moelvenLogoTitle = new Image(new FileInputStream("src/main/resources/com.application/GUI/moelven_logo_title.jpg"));
//Setting the image view
ImageView imageViewM = new ImageView(moelvenLogoM);
ImageView imageViewTitle = new ImageView(moelvenLogoTitle);
imageViewM.setFitHeight(100);
imageViewM.setPreserveRatio(true);
imageViewTitle.setFitHeight(100);
imageViewTitle.setPreserveRatio(true);
Region region1 = new Region();
HBox.setHgrow(region1, Priority.ALWAYS);
Region region2 = new Region();
HBox.setHgrow(region2, Priority.ALWAYS);
return new HBox(imageViewM, region1, imageViewTitle, region2);
}
private LineChart<String,Number> createLineChart() {
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();
xAxis.setLabel("Month");
final LineChart<String, Number> lineChart =
new LineChart<String, Number>(xAxis, yAxis);
lineChart.setTitle("Stock Monitoring, 2010");
XYChart.Series series1 = new XYChart.Series();
series1.setName("Portfolio 1");
series1.getData().add(new XYChart.Data("Jan", 23));
series1.getData().add(new XYChart.Data("Feb", 14));
series1.getData().add(new XYChart.Data("Mar", 15));
series1.getData().add(new XYChart.Data("Apr", 24));
series1.getData().add(new XYChart.Data("May", 34));
series1.getData().add(new XYChart.Data("Jun", 36));
series1.getData().add(new XYChart.Data("Jul", 22));
series1.getData().add(new XYChart.Data("Aug", 45));
series1.getData().add(new XYChart.Data("Sep", 43));
series1.getData().add(new XYChart.Data("Oct", 17));
series1.getData().add(new XYChart.Data("Nov", 29));
series1.getData().add(new XYChart.Data("Dec", 25));
lineChart.getData().add(series1);
return lineChart;
}
}
......@@ -62,7 +62,7 @@
<center>
<ImageView fitHeight="30.0" fitWidth="125.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@moelven_logo_tittle.jpg" />
<Image url="@moelven_logo_title.jpg" />
</image>
</ImageView>
</center>
......
/* General css for alle the main windows */
/*noinspection CssUnusedSymbol*/
.root {
-fx-pref-width: 1150;
-fx-pref-height: 600;
-fx-fill-height: true;
-fx-max-width: infinity;
-fx-font-size: 14;
}
......@@ -62,7 +62,7 @@
<center>
<ImageView fitHeight="30.0" fitWidth="125.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@moelven_logo_tittle.jpg" />
<Image url="@moelven_logo_title.jpg" />
</image>
</ImageView>
</center>
......
/* General css for alle the main windows */
/*noinspection CssUnusedSymbol*/
.root {
-fx-pref-width: 1150;
-fx-pref-height: 600;
-fx-fill-height: true;
-fx-max-width: infinity;
-fx-font-size: 14;
}
No preview for this file type
File added
No preview for this file type
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