From 84562c700ed1b23d6b2d3035e5e96dfa18883f58 Mon Sep 17 00:00:00 2001 From: aj Date: Tue, 17 Apr 2018 21:45:37 -0700 Subject: [PATCH] working on fmobjlisttab --- .../sarsoo/fmframework/fx/FMObjListTab.java | 74 +++++++++++++++++++ .../fx/controller/AlbumGetPaneController.java | 25 +++++++ .../fx/controller/AlbumTabController.java | 2 +- .../fx/controller/ControllerMain.java | 43 ++++++----- .../fmframework/fx/styles/FMObjListTab.css | 26 +++++++ .../fmframework/fx/ui/albumgetpane.fxml | 24 ++++++ .../src/sarsoo/fmframework/fx/ui/changed.fxml | 12 --- 7 files changed, 175 insertions(+), 31 deletions(-) create mode 100644 fmframework/src/sarsoo/fmframework/fx/FMObjListTab.java create mode 100644 fmframework/src/sarsoo/fmframework/fx/controller/AlbumGetPaneController.java create mode 100644 fmframework/src/sarsoo/fmframework/fx/styles/FMObjListTab.css create mode 100644 fmframework/src/sarsoo/fmframework/fx/ui/albumgetpane.fxml delete mode 100644 fmframework/src/sarsoo/fmframework/fx/ui/changed.fxml diff --git a/fmframework/src/sarsoo/fmframework/fx/FMObjListTab.java b/fmframework/src/sarsoo/fmframework/fx/FMObjListTab.java new file mode 100644 index 0000000..2ed57d6 --- /dev/null +++ b/fmframework/src/sarsoo/fmframework/fx/FMObjListTab.java @@ -0,0 +1,74 @@ +package sarsoo.fmframework.fx; + +import java.text.NumberFormat; +import java.util.Collections; +import java.util.Locale; + +import javafx.scene.control.*; +import javafx.scene.layout.*; +import sarsoo.fmframework.music.FMObj; +import sarsoo.fmframework.util.FMObjList; +import sarsoo.fmframework.util.Maths; +import sarsoo.fmframework.util.Reference; + +public class FMObjListTab extends BorderPane{ + + public FMObjListTab(FMObjList list) { + getStylesheets().add("sarsoo/fmframework/fx/styles/FMObjListTab.css"); + + Collections.sort(list); + Collections.reverse(list); + + VBox stats = new VBox(); + GridPane statsPane = new GridPane(); + Label total = new Label(Integer.toString(list.getTotalUserScrobbles())); + total.getStyleClass().add("totalScrobbles"); + statsPane.add(total, 0, 0); + + double percent = Maths.getPercentListening(list, Reference.getUserName()); + Label percentLabel = new Label(String.format("%.2f%%", percent)); + percentLabel.getStyleClass().add("percent"); + statsPane.add(percentLabel, 1, 0); + + stats.getChildren().add(statsPane); + setBottom(stats); + + ScrollPane scroll = new ScrollPane(); + scroll.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); + + GridPane pane = new GridPane(); + scroll.setContent(pane); + + NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US); + FMObj FMObj; + int counter; + for(counter = 0; counter < list.size(); counter++) { + FMObj = list.get(counter); + + Label name = new Label(FMObj.getName()); + name.getStyleClass().add("nameLabel"); + + Label scrobbles = new Label(numberFormat.format(FMObj.getUserPlayCount())); + Label totalScrobbles = new Label(numberFormat.format(FMObj.getPlayCount())); + totalScrobbles.getStyleClass().add("number"); + + pane.add(name, 0, counter); + pane.add(scrobbles, 1, counter); + pane.add(totalScrobbles, 2, counter); + } + + ColumnConstraints column1 = new ColumnConstraints(); + column1.setPercentWidth(50); + column1.setHgrow(Priority.ALWAYS); + ColumnConstraints column2 = new ColumnConstraints(); + column2.setPercentWidth(25); + column2.setHgrow(Priority.ALWAYS); + pane.getColumnConstraints().add(column1); + pane.getColumnConstraints().add(column2); + pane.getColumnConstraints().add(column2); + + setCenter(scroll); + + } + +} diff --git a/fmframework/src/sarsoo/fmframework/fx/controller/AlbumGetPaneController.java b/fmframework/src/sarsoo/fmframework/fx/controller/AlbumGetPaneController.java new file mode 100644 index 0000000..dd23cf3 --- /dev/null +++ b/fmframework/src/sarsoo/fmframework/fx/controller/AlbumGetPaneController.java @@ -0,0 +1,25 @@ +package sarsoo.fmframework.fx.controller; + +import javafx.fxml.FXML; +import javafx.scene.control.*; +import javafx.event.ActionEvent; + +public class AlbumGetPaneController { + + @FXML + private Label albumName; + + @FXML + private Label artistName; + + @FXML + private Button getButton; + +// private + +// @FXML +// protected void handleGetButton(ActionEvent event) { +// +// } + +} diff --git a/fmframework/src/sarsoo/fmframework/fx/controller/AlbumTabController.java b/fmframework/src/sarsoo/fmframework/fx/controller/AlbumTabController.java index a41a91f..8f1e489 100644 --- a/fmframework/src/sarsoo/fmframework/fx/controller/AlbumTabController.java +++ b/fmframework/src/sarsoo/fmframework/fx/controller/AlbumTabController.java @@ -58,7 +58,7 @@ public class AlbumTabController { + String.format(" Scrobbles (%.2f%%)", Maths.getPercentListening(album, Reference.getUserName()))); labelTotalListeners.setText(numberFormat.format(album.getListeners()) + " Listeners"); - labelTotalScrobbles.setText(numberFormat.format(album.getPlayCount()) + "Total Scrobbles"); + labelTotalScrobbles.setText(numberFormat.format(album.getPlayCount()) + " Total Scrobbles"); double ratio = album.getTimeListenRatio(); diff --git a/fmframework/src/sarsoo/fmframework/fx/controller/ControllerMain.java b/fmframework/src/sarsoo/fmframework/fx/controller/ControllerMain.java index 3dbd2b9..ecf2a72 100644 --- a/fmframework/src/sarsoo/fmframework/fx/controller/ControllerMain.java +++ b/fmframework/src/sarsoo/fmframework/fx/controller/ControllerMain.java @@ -10,6 +10,7 @@ import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.text.Text; +import sarsoo.fmframework.fx.FMObjListTab; import sarsoo.fmframework.music.Album; import sarsoo.fmframework.util.FMObjList; import sarsoo.fmframework.util.Getter; @@ -88,27 +89,33 @@ public class ControllerMain { @FXML protected void handleLookupAlbum(ActionEvent event) throws IOException { - FXMLLoader loader = new FXMLLoader(getClass().getResource("../ui/albumview.fxml")); - - Pane pane = (Pane)loader.load(); - -// AlbumTabController controller = new AlbumTabController(Album.getAlbum("recovery", "eminem", Reference.getUserName())); -// loader.setController(controller); -// pane.setController(controller); - -// Parent pane = loader.load(); - - Tab tab = new Tab("Recovery"); - - tab.setContent(pane); - - AlbumTabController albumControl = (AlbumTabController)loader.getController(); - - - albumControl.populateTab(Getter.getAlbum()); +// FXMLLoader loader = new FXMLLoader(getClass().getResource("../ui/albumview.fxml")); +// +// Pane pane = (Pane)loader.load(); +// +//// AlbumTabController controller = new AlbumTabController(Album.getAlbum("recovery", "eminem", Reference.getUserName())); +//// loader.setController(controller); +//// pane.setController(controller); +// +//// Parent pane = loader.load(); +// +// Tab tab = new Tab("Album View"); +// +// tab.setContent(pane); +// +// AlbumTabController albumControl = (AlbumTabController)loader.getController(); +// +// +// albumControl.populateTab(Getter.getAlbum()); +// +// +// tabPane.getTabs().add(tab); + Tab tab = new Tab("rock"); + tab.setContent(new FMObjListTab(Getter.getUserTag(Reference.getUserName(), "rock"))); tabPane.getTabs().add(tab); + } diff --git a/fmframework/src/sarsoo/fmframework/fx/styles/FMObjListTab.css b/fmframework/src/sarsoo/fmframework/fx/styles/FMObjListTab.css new file mode 100644 index 0000000..c4115e7 --- /dev/null +++ b/fmframework/src/sarsoo/fmframework/fx/styles/FMObjListTab.css @@ -0,0 +1,26 @@ +.nameLabel{ + -fx-alignment: center; + + -fx-font-style: italic; + +} + +.number{ + -fx-text-alignment: right; + + -fx-font-style: italic; + +} + +.totalScrobbles{ + + -fx-font-style: italic; + +} + +.percent{ + -fx-text-alignment: right; + + -fx-font-style: italic; + +} \ No newline at end of file diff --git a/fmframework/src/sarsoo/fmframework/fx/ui/albumgetpane.fxml b/fmframework/src/sarsoo/fmframework/fx/ui/albumgetpane.fxml new file mode 100644 index 0000000..99000d5 --- /dev/null +++ b/fmframework/src/sarsoo/fmframework/fx/ui/albumgetpane.fxml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + +