diff --git a/fmframework/src/sarsoo/fmframework/fx/FmFramework.java b/fmframework/src/sarsoo/fmframework/fx/FmFramework.java index cc46a2f..4c48ad2 100644 --- a/fmframework/src/sarsoo/fmframework/fx/FmFramework.java +++ b/fmframework/src/sarsoo/fmframework/fx/FmFramework.java @@ -1,18 +1,28 @@ package sarsoo.fmframework.fx; +import java.io.IOException; + import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; +import sarsoo.fmframework.util.Reference; public class FmFramework extends Application { + + private Stage stage; + private Scene rootScene; @Override public void start(Stage stage) throws Exception { + this.stage = stage; + Parent root = FXMLLoader.load(getClass().getResource("ui/main.fxml")); - + Scene scene = new Scene(root, 800, 400); + + rootScene = scene; // scene.getStylesheets().add("styles/style.css"); stage.setTitle("FM Framework"); @@ -24,5 +34,12 @@ public class FmFramework extends Application { public static void main(String[] args) { launch(args); } + + public void changeScene() throws IOException { + Parent root = FXMLLoader.load(getClass().getResource("ui/changed.fxml")); + + + + } } diff --git a/fmframework/src/sarsoo/fmframework/fx/Stats.java b/fmframework/src/sarsoo/fmframework/fx/Stats.java new file mode 100644 index 0000000..0e25a43 --- /dev/null +++ b/fmframework/src/sarsoo/fmframework/fx/Stats.java @@ -0,0 +1,18 @@ +package sarsoo.fmframework.fx; + +import javafx.fxml.FXML; +import javafx.scene.control.*; + +public class Stats { + + /*@FXML + private static Label scrobblesToday; + + *//** + * @param scrobbles + *//* + public static void updateScrobblesToday(int scrobbles) { + +// scrobblesToday.setText(Integer.toString(scrobbles)); + }*/ +} diff --git a/fmframework/src/sarsoo/fmframework/fx/controller/ControllerMain.java b/fmframework/src/sarsoo/fmframework/fx/controller/ControllerMain.java index 20babbc..4dd140f 100644 --- a/fmframework/src/sarsoo/fmframework/fx/controller/ControllerMain.java +++ b/fmframework/src/sarsoo/fmframework/fx/controller/ControllerMain.java @@ -1,21 +1,75 @@ package sarsoo.fmframework.fx.controller; +import java.text.NumberFormat; +import java.util.ArrayList; + import javax.swing.JOptionPane; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.text.Text; -import javafx.scene.control.Button; +import sarsoo.fmframework.util.FMObjList; +import sarsoo.fmframework.util.Getter; +import sarsoo.fmframework.util.Reference; +import javafx.scene.control.*; +import javafx.scene.layout.GridPane; +import javafx.scene.chart.*; +import javafx.collections.ObservableList; +import javafx.collections.FXCollections; public class ControllerMain { - - @FXML - private Button changeScene; - - private int clicked = 0; @FXML - protected void handleButtonClick(ActionEvent event) { - JOptionPane.showMessageDialog(null, "Changed"); + private Label labelStatsScrobblesToday; + + @FXML + private Label labelStatsUsername; + + @FXML + private Label labelStatsScrobblesTotal; + + @FXML + private PieChart pieChartGenres; + + @FXML + public void initialize() { + Reference.setUserName("sarsoo"); + + labelStatsScrobblesToday.setText(Integer.toString(Getter.getScrobblesToday(Reference.getUserName()))); + + labelStatsUsername.setText(Reference.getUserName()); + + +// updateGenrePieChart(); + + labelStatsScrobblesTotal.setText(NumberFormat.getInstance().format(Getter.getScrobbles(Reference.getUserName()))); + } + + public void updateGenrePieChart() { + + String[] names = { + "rock", + "rap", + "classic rock", + "pop punk", + "electronic", + "metal", + "grime", + "classic rap", + "indie", + "jazz", + "blues", + "core" + }; + + ObservableList pieChartData = + FXCollections.observableArrayList( +// new PieChart.Data("rap", Getter.getUserTag(Reference.getUserName(), "rap").getTotalUserScrobbles()), + new PieChart.Data("rock", Getter.getUserTag(Reference.getUserName(), "rap").getTotalUserScrobbles())); + pieChartGenres = new PieChart(pieChartData); + + + } + } diff --git a/fmframework/src/sarsoo/fmframework/fx/styles/mainPane.css b/fmframework/src/sarsoo/fmframework/fx/styles/mainPane.css new file mode 100644 index 0000000..df72bdc --- /dev/null +++ b/fmframework/src/sarsoo/fmframework/fx/styles/mainPane.css @@ -0,0 +1,13 @@ +.vBoxStats{ + -fx-background-color: #001a44; +} + +.gridPane{ + + -fx-background-color: #a2aec1; +} + +.vBoxStatsLabel{ + + -fx-text-fill: white; +} \ No newline at end of file diff --git a/fmframework/src/sarsoo/fmframework/fx/ui/changed.fxml b/fmframework/src/sarsoo/fmframework/fx/ui/changed.fxml new file mode 100644 index 0000000..006a9e1 --- /dev/null +++ b/fmframework/src/sarsoo/fmframework/fx/ui/changed.fxml @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/fmframework/src/sarsoo/fmframework/fx/ui/main.fxml b/fmframework/src/sarsoo/fmframework/fx/ui/main.fxml index db9c375..c9b3c8f 100644 --- a/fmframework/src/sarsoo/fmframework/fx/ui/main.fxml +++ b/fmframework/src/sarsoo/fmframework/fx/ui/main.fxml @@ -1,25 +1,90 @@ + - - -
- - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + -