working on fmobjlisttab

This commit is contained in:
aj 2018-04-17 21:45:37 -07:00
parent 507f732861
commit 84562c700e
7 changed files with 175 additions and 31 deletions

View File

@ -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);
}
}

View File

@ -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) {
//
// }
}

View File

@ -58,7 +58,7 @@ public class AlbumTabController {
+ String.format(" Scrobbles (%.2f%%)", Maths.getPercentListening(album, Reference.getUserName()))); + String.format(" Scrobbles (%.2f%%)", Maths.getPercentListening(album, Reference.getUserName())));
labelTotalListeners.setText(numberFormat.format(album.getListeners()) + " Listeners"); 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(); double ratio = album.getTimeListenRatio();

View File

@ -10,6 +10,7 @@ import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.text.Text; import javafx.scene.text.Text;
import sarsoo.fmframework.fx.FMObjListTab;
import sarsoo.fmframework.music.Album; import sarsoo.fmframework.music.Album;
import sarsoo.fmframework.util.FMObjList; import sarsoo.fmframework.util.FMObjList;
import sarsoo.fmframework.util.Getter; import sarsoo.fmframework.util.Getter;
@ -88,27 +89,33 @@ public class ControllerMain {
@FXML @FXML
protected void handleLookupAlbum(ActionEvent event) throws IOException { protected void handleLookupAlbum(ActionEvent event) throws IOException {
FXMLLoader loader = new FXMLLoader(getClass().getResource("../ui/albumview.fxml")); // FXMLLoader loader = new FXMLLoader(getClass().getResource("../ui/albumview.fxml"));
//
Pane pane = (Pane)loader.load(); // Pane pane = (Pane)loader.load();
//
// AlbumTabController controller = new AlbumTabController(Album.getAlbum("recovery", "eminem", Reference.getUserName())); //// AlbumTabController controller = new AlbumTabController(Album.getAlbum("recovery", "eminem", Reference.getUserName()));
// loader.setController(controller); //// loader.setController(controller);
// pane.setController(controller); //// pane.setController(controller);
//
// Parent pane = loader.load(); //// Parent pane = loader.load();
//
Tab tab = new Tab("Recovery"); // Tab tab = new Tab("Album View");
//
tab.setContent(pane); // tab.setContent(pane);
//
AlbumTabController albumControl = (AlbumTabController)loader.getController(); // AlbumTabController albumControl = (AlbumTabController)loader.getController();
//
//
albumControl.populateTab(Getter.getAlbum()); // 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); tabPane.getTabs().add(tab);
} }

View File

@ -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;
}

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="sarsoo.fmframework.fx.controller.albumGetPaneController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="343.0" minWidth="10.0" prefWidth="238.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="423.0" minWidth="10.0" prefWidth="362.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Button fx:id="getButton" mnemonicParsing="false" text="get" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="2" />
<TextField fx:id="albumName" GridPane.columnIndex="1" />
<TextField fx:id="artistName" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="album" GridPane.halignment="CENTER" />
<Label text="artist" GridPane.halignment="CENTER" GridPane.rowIndex="1" />
</children>
</GridPane>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label text="CHANGED" />
</children>
</VBox>