diff --git a/src/main/java/com/application/GUI/InputPopUpWindow.java b/src/main/java/com/application/GUI/InputPopUpWindow.java index af64cb94cbdf22bb59d0708ae933f951bf481ebe..d69a71d019f743952a134e5746d5468f40fd7007 100644 --- a/src/main/java/com/application/GUI/InputPopUpWindow.java +++ b/src/main/java/com/application/GUI/InputPopUpWindow.java @@ -2,12 +2,17 @@ package com.application.GUI; import javafx.geometry.Pos; import javafx.scene.*; -import javafx.scene.chart.LineChart; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.stage.*; +import org.checkerframework.checker.units.qual.K; + +import java.util.Map; import static com.application.DB.Constants.*; +import static com.application.DB.DB.setInputParameters; +import static com.application.GUI.LineChartFunctionality.loadSingleSeries; + /** * This class handles the popup input window @@ -79,15 +84,77 @@ public class InputPopUpWindow { window.close(); - // Call på getKwh() + + class KwhThread implements Runnable { + + Map<Integer, Map<String, Number>> dataVariable; + private volatile boolean finished; + + @Override + public void run() { + try{ + dataVariable = setInputParameters(); + } catch (Exception ex) { + ex.printStackTrace(); + } + finished = true; + + synchronized (this){ + this.notify(); + } + } + + + + public Map<Integer, Map<String, Number>> getDataVariable() throws InterruptedException { + + synchronized (this){ + if(!finished) + this.wait(); + } + return dataVariable; + } + } + + KwhThread kwhThread = new KwhThread(); + + Thread thread = new Thread(kwhThread); + thread.setName("GetKwhThread"); + thread.start(); + try { - LineChartFunctionality.loadSingleSeries(); - //LineChartFunctionality.loadMultipleSeries(); + loadSingleSeries(kwhThread.getDataVariable()); + } catch (Exception ex) { + ex.printStackTrace(); + } + + + + + + /* + // Fungerende ny thread!!@@@@@ + try{ + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + try { + loadSingleSeries(setInputParameters()); + //loadSingleSeries(); + //loadMultipleSeries(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + }); + thread.start(); + //thread.join(); } catch (Exception ex) { ex.printStackTrace(); } + */ }); VBox layout = new VBox(10); diff --git a/src/main/java/com/application/GUI/LineChartFunctionality.java b/src/main/java/com/application/GUI/LineChartFunctionality.java index 821ee6a7cd9100557f26561d5f2378b9d523225b..f856137e2c6fce477d7b180b86ba30736784cca9 100644 --- a/src/main/java/com/application/GUI/LineChartFunctionality.java +++ b/src/main/java/com/application/GUI/LineChartFunctionality.java @@ -26,7 +26,11 @@ public class LineChartFunctionality { lineChart.setTitle("Drying Processes"); } - public LineChart<String, Number> getLineChart() { + public static void setLineChart(LineChart<String, Number> lineChart) { + LineChartFunctionality.lineChart = lineChart; + } + + public static LineChart<String, Number> getLineChart() { return lineChart; } @@ -39,13 +43,14 @@ public class LineChartFunctionality { } - public static void loadSingleSeries() throws Exception { + public static LineChart<String, Number> loadSingleSeries(Map<Integer, Map<String, Number>> userInput) throws Exception { clearLineChart(); - Map<Integer, Map<String, Number>> kWh = DB.setInputParameters(); + //Map<Integer, Map<String, Number>> kWh = userInput; + //Map<Integer, Map<String, Number>> kWh = DB.setInputParameters(); //System.out.println(kWh.size()); - for (Map.Entry<Integer, Map<String, Number>> entryKwh : kWh.entrySet()) { + for (Map.Entry<Integer, Map<String, Number>> entryKwh : userInput.entrySet()) { Map data = entryKwh.getValue(); //System.out.println(data.size()); @@ -67,6 +72,7 @@ public class LineChartFunctionality { } updateLineChart(newSeries); } + return getLineChart(); } public static void loadMultipleSeries() throws Exception { diff --git a/target/classes/com.application/CSS/styleSheet.css b/target/classes/com.application/CSS/styleSheet.css index 76111b5e69c7085c3fc25b6f99d29126621ace76..9669a07744aad57b8c6008f9f4901770737b37ed 100644 --- a/target/classes/com.application/CSS/styleSheet.css +++ b/target/classes/com.application/CSS/styleSheet.css @@ -104,6 +104,7 @@ #inputButtonStart { -fx-pref-width: infinity; + -fx-translate-y: 10; -fx-pref-height: 25; -fx-font-size: 20; -fx-font-family: Arial; diff --git a/target/classes/com/application/GUI/InputPopUpWindow.class b/target/classes/com/application/GUI/InputPopUpWindow.class index 97f734cb6427535c2b5d47da833e92a806a0fc53..5c8bdbb587857b0435a8caf341dc7a0ab82de3d6 100644 Binary files a/target/classes/com/application/GUI/InputPopUpWindow.class and b/target/classes/com/application/GUI/InputPopUpWindow.class differ diff --git a/target/classes/com/application/GUI/LineChartFunctionality.class b/target/classes/com/application/GUI/LineChartFunctionality.class index b77b52c27533ea481f924a8716e9cf5e13ea0918..91dc1af6a9f30bf19ccc6610890a96bfcee57fc4 100644 Binary files a/target/classes/com/application/GUI/LineChartFunctionality.class and b/target/classes/com/application/GUI/LineChartFunctionality.class differ diff --git a/target/classes/com/application/Main.class b/target/classes/com/application/Main.class index 71eeb5ead13fb84c7ab9e631dbf0ef1482c293cc..ec100d83456ca16a4143282fd327717037863c9a 100644 Binary files a/target/classes/com/application/Main.class and b/target/classes/com/application/Main.class differ