added fmobjlist piechart breakdown, cohesive css

This commit is contained in:
aj 2018-04-22 16:42:44 -07:00
parent 1e5539d4f1
commit 1e77421d1b
19 changed files with 602 additions and 98 deletions

View File

@ -8,6 +8,7 @@ import java.util.Locale;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import sarsoo.fmframework.fx.controller.FMObjListPaneController; import sarsoo.fmframework.fx.controller.FMObjListPaneController;
import sarsoo.fmframework.fx.controller.FMObjListPaneEditController;
import sarsoo.fmframework.music.FMObj; import sarsoo.fmframework.music.FMObj;
import sarsoo.fmframework.util.FMObjList; import sarsoo.fmframework.util.FMObjList;
import sarsoo.fmframework.util.Maths; import sarsoo.fmframework.util.Maths;
@ -39,6 +40,28 @@ public class FMObjListTab extends Tab {
}
public FMObjListTab() throws IOException {
setText("List");
FXMLLoader loader = new FXMLLoader(getClass().getResource("ui/FMObjListPaneEdit.fxml"));
AnchorPane pane = (AnchorPane) loader.load();
AnchorPane.setTopAnchor(pane, 0.0);
AnchorPane.setLeftAnchor(pane, 0.0);
AnchorPane.setRightAnchor(pane, 0.0);
AnchorPane.setBottomAnchor(pane, 0.0);
// BorderPane
setContent(pane);
FMObjListPaneEditController control = (FMObjListPaneEditController) loader.getController();
} }
} }

View File

@ -34,7 +34,7 @@ public class FmFramework extends Application {
control = (ControllerMain)loader.getController(); control = (ControllerMain)loader.getController();
// (new Thread(new TagCaller())).start(); // (new Thread(new TagCaller())).start();
stage.setMinHeight(800); stage.setMinHeight(800);
stage.setMinWidth(1000); stage.setMinWidth(960);
stage.setTitle("fm framework"); stage.setTitle("fm framework");
stage.setScene(scene); stage.setScene(scene);
stage.show(); stage.show();

View File

@ -11,6 +11,8 @@ 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.ArtistTab;
import sarsoo.fmframework.fx.FMObjListTab;
import sarsoo.fmframework.fx.FmFramework; import sarsoo.fmframework.fx.FmFramework;
import sarsoo.fmframework.music.Album; import sarsoo.fmframework.music.Album;
import sarsoo.fmframework.music.Artist; import sarsoo.fmframework.music.Artist;
@ -105,6 +107,16 @@ public class ArtistPaneController {
Network.openURL(artist.getRymURL()); Network.openURL(artist.getRymURL());
} }
@FXML
protected void handleViewTracks(ActionEvent event) {
try {
FmFramework.getController().addTab(new FMObjListTab(Getter.getArtistTracks(artist.getName(), Reference.getUserName())));
} catch (IOException e) {
e.printStackTrace();
}
}
public void refresh() { public void refresh() {
artist.refresh(); artist.refresh();

View File

@ -76,7 +76,7 @@ public class ControllerMain {
String scrobblesToday = numberFormat.format(Getter.getScrobblesToday(Reference.getUserName())); String scrobblesToday = numberFormat.format(Getter.getScrobblesToday(Reference.getUserName()));
String scrobbles = numberFormat.format(Getter.getScrobbles(Reference.getUserName())); String scrobbles = numberFormat.format(Getter.getScrobbles(Reference.getUserName()));
tags = Getter.getUserTags(Reference.getUserName());
TrackTab tab = new TrackTab(Getter.getLastTrack()); TrackTab tab = new TrackTab(Getter.getLastTrack());
@ -93,12 +93,36 @@ public class ControllerMain {
addTab(tab); addTab(tab);
refreshPieCharts(); refreshPieCharts();
updateTagMenu();
} finally {
latch.countDown();
}
}
});
latch.await();
// Keep with the background work
return null;
}
};
}
};
service.start();
}
private ArrayList<Tag> tags;
public void updateTagMenu() {
tags = Getter.getUserTags(Reference.getUserName());
Collections.sort(tags);
int counter; int counter;
for (counter = 0; counter < tags.size(); counter++) { for (counter = 0; counter < tags.size(); counter++) {
String name = tags.get(counter).getName().toLowerCase(); String name = tags.get(counter).getName().toLowerCase();
// System.out.println(name); // System.out.println(name);
MenuItem item = new MenuItem(name); MenuItem item = new MenuItem(name);
@ -142,21 +166,6 @@ public class ControllerMain {
menuTag.getItems().add(item); menuTag.getItems().add(item);
} }
} finally {
latch.countDown();
}
}
});
latch.await();
// Keep with the background work
return null;
}
};
}
};
service.start();
} }
public void updateGenrePieChart() { public void updateGenrePieChart() {
@ -295,8 +304,6 @@ public class ControllerMain {
@FXML @FXML
private Menu menuTag; private Menu menuTag;
private ArrayList<Tag> tags;
// @FXML // @FXML
// protected void handleTagClick(ActionEvent event) throws IOException { // protected void handleTagClick(ActionEvent event) throws IOException {
// // System.out.println("clicked"); // // System.out.println("clicked");
@ -588,4 +595,16 @@ public class ControllerMain {
service.start(); service.start();
} }
@FXML
protected void handleCreateList(ActionEvent event) {
try {
Tab tab = new FMObjListTab();
addTab(tab);
} catch (IOException e) {
e.printStackTrace();
}
}
} }

View File

@ -3,6 +3,7 @@ package sarsoo.fmframework.fx.controller;
import java.io.IOException; import java.io.IOException;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.Locale; import java.util.Locale;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
@ -11,7 +12,7 @@ import javafx.event.ActionEvent;
import javafx.event.Event; import javafx.event.Event;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Label; import javafx.scene.control.*;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
import sarsoo.fmframework.fx.AlbumTab; import sarsoo.fmframework.fx.AlbumTab;
import sarsoo.fmframework.fx.ArtistTab; import sarsoo.fmframework.fx.ArtistTab;
@ -24,6 +25,7 @@ import sarsoo.fmframework.util.Maths;
import sarsoo.fmframework.util.Reference; import sarsoo.fmframework.util.Reference;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.scene.chart.*; import javafx.scene.chart.*;
import javafx.scene.chart.PieChart.Data;
public class FMObjListPaneController { public class FMObjListPaneController {
@ -39,6 +41,9 @@ public class FMObjListPaneController {
@FXML @FXML
private PieChart pieChart; private PieChart pieChart;
@FXML
private PieChart pieChartArtists;
private FMObjList list; private FMObjList list;
public void populate(FMObjList list) { public void populate(FMObjList list) {
@ -88,11 +93,30 @@ public class FMObjListPaneController {
} }
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(
new PieChart.Data(list.getGroupName(), list.getTotalUserScrobbles()), new PieChart.Data(list.getGroupName(), list.getTotalUserScrobbles()),
new PieChart.Data("other", Getter.getScrobbles(Reference.getUserName()) - list.getTotalUserScrobbles())); new PieChart.Data("other", Getter.getScrobbles(Reference.getUserName()) - list.getTotalUserScrobbles()));
ObservableList<PieChart.Data> pieChartArtistsData = FXCollections.observableArrayList();
int counter2;
for(counter2 = 0; counter2 < list.size(); counter2++) {
PieChart.Data data = new PieChart.Data(list.get(counter2).getName(), list.get(counter2).getUserPlayCount());
pieChartArtistsData.add(data);
}
Collections.sort(pieChartArtistsData, new Comparator<PieChart.Data>() {
@Override
public int compare(Data arg0, Data arg1) {
return (int) (arg1.getPieValue() - arg0.getPieValue());
}
});
pieChart.setData(pieChartData); pieChart.setData(pieChartData);
pieChartArtists.setData(pieChartArtistsData);
} }
@ -155,4 +179,5 @@ public class FMObjListPaneController {
pieChart.setData(pieChartData); pieChart.setData(pieChartData);
} }
} }

View File

@ -0,0 +1,224 @@
package sarsoo.fmframework.fx.controller;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.Collections;
import java.util.Comparator;
import java.util.Locale;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.input.MouseEvent;
import sarsoo.fmframework.fx.AlbumTab;
import sarsoo.fmframework.fx.ArtistTab;
import sarsoo.fmframework.fx.FmFramework;
import sarsoo.fmframework.music.Album;
import sarsoo.fmframework.music.Artist;
import sarsoo.fmframework.music.FMObj;
import sarsoo.fmframework.music.Track;
import sarsoo.fmframework.util.FMObjList;
import sarsoo.fmframework.util.Getter;
import sarsoo.fmframework.util.Maths;
import sarsoo.fmframework.util.Reference;
import javafx.scene.layout.*;
import javafx.scene.chart.*;
import javafx.scene.chart.PieChart.Data;
public class FMObjListPaneEditController {
@FXML
private Label labelTotalScrobbles;
@FXML
private Label labelPercent;
@FXML
private GridPane gridPaneFMObjs;
@FXML
private PieChart pieChart;
@FXML
private PieChart pieChartArtists;
private FMObjList list = new FMObjList();
// public void populate(FMObjList list) {
// this.list = list;
//
// double percent = Maths.getPercentListening(list, Reference.getUserName());
// NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
//
// labelTotalScrobbles.setText("Σ " + list.getTotalUserScrobbles());
// labelPercent.setText(String.format("%.2f%%", percent));
//
// Collections.sort(list);
// Collections.reverse(list);
//
// int counter;
// for (counter = 0; counter < list.size(); counter++) {
//
// FMObj obj = list.get(counter);
//
// Label name = new Label(obj.getName().toLowerCase());
//
// name.getStyleClass().add("nameLabel");
//
// name.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<Event>() {
//
// @Override
// public void handle(Event event) {
//
// try {
// FmFramework.getController().addTab(new ArtistTab((Artist) obj));
// } catch (IOException e) {
//
// e.printStackTrace();
// }
//
// }
//
// });
//
// Label userScrobbles = new Label(numberFormat.format(obj.getUserPlayCount()));
// Label totalScrobbles = new Label(numberFormat.format(obj.getPlayCount()));
//
// gridPaneFMObjs.add(name, 0, counter);
// gridPaneFMObjs.add(userScrobbles, 1, counter);
// gridPaneFMObjs.add(totalScrobbles, 2, counter);
//
// }
//
//
// ObservableList<PieChart.Data> pieChartData =
// FXCollections.observableArrayList(
// new PieChart.Data(list.getGroupName(), list.getTotalUserScrobbles()),
// new PieChart.Data("other", Getter.getScrobbles(Reference.getUserName()) -
// list.getTotalUserScrobbles()));
//
// ObservableList<PieChart.Data> pieChartArtistsData =
// FXCollections.observableArrayList();
// int counter2;
// for(counter2 = 0; counter2 < list.size(); counter2++) {
//
// PieChart.Data data = new PieChart.Data(list.get(counter2).getName(),
// list.get(counter2).getUserPlayCount());
//
// pieChartArtistsData.add(data);
//
// }
//
// Collections.sort(pieChartArtistsData, new Comparator<PieChart.Data>() {
//
// @Override
// public int compare(Data arg0, Data arg1) {
// return (int) (arg1.getPieValue() - arg0.getPieValue());
// }
// });
//
// pieChart.setData(pieChartData);
// pieChartArtists.setData(pieChartArtistsData);
//
// }
@FXML
protected void handleRefresh(ActionEvent event) {
refresh();
}
public void refresh() {
double percent = Maths.getPercentListening(list, Reference.getUserName());
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
labelTotalScrobbles.setText("Σ " + list.getTotalUserScrobbles());
labelPercent.setText(String.format("%.2f%%", percent));
Collections.sort(list);
Collections.reverse(list);
gridPaneFMObjs.getChildren().clear();
int counter;
for (counter = 0; counter < list.size(); counter++) {
FMObj obj = list.get(counter);
Label name = new Label(obj.getName().toLowerCase());
name.getStyleClass().add("nameLabel");
name.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<Event>() {
@Override
public void handle(Event event) {
try {
FmFramework.getController().addTab(new ArtistTab((Artist) obj));
} catch (IOException e) {
e.printStackTrace();
}
}
});
Label userScrobbles = new Label(numberFormat.format(obj.getUserPlayCount()));
Label totalScrobbles = new Label(numberFormat.format(obj.getPlayCount()));
gridPaneFMObjs.add(name, 0, counter);
gridPaneFMObjs.add(userScrobbles, 1, counter);
gridPaneFMObjs.add(totalScrobbles, 2, counter);
}
ObservableList<PieChart.Data> pieChartData = FXCollections
.observableArrayList(new PieChart.Data("list", list.getTotalUserScrobbles()), new PieChart.Data("other",
Getter.getScrobbles(Reference.getUserName()) - list.getTotalUserScrobbles()));
pieChart.setData(pieChartData);
}
@FXML
protected TextField textArtist;
@FXML
protected TextField textTrack;
@FXML
protected TextField textAlbum;
@FXML
protected void handleAddTrack(ActionEvent event) {
String name = textTrack.getText();
System.out.println(name + ".");
String album = textAlbum.getText();
System.out.println(album + ".");
String artist = textArtist.getText();
System.out.println(artist + ".");
System.out.println("Click");
if ((name != null) && (artist != null)) {
System.out.println("not null");
Track track = Track.getTrack(name, artist, Reference.getUserName());
System.out.println("track created");
if (album != null) {
Album albumObj = Album.getAlbum(album, artist, Reference.getUserName());
System.out.println("album created");
track.setAlbum(albumObj);
System.out.println("no album");
}
list.add(track);
}
refresh();
}
}

View File

@ -1,16 +1,23 @@
.title{ .titleLabel{
-fx-font-size: 400%; -fx-font-size: 600%;
-fx-font-weight: bolder;
} }
.sub{ .subLabel{
-fx-font-size: 300%;
-fx-font-weight: bold;
}
.normalLabel{
-fx-font-size: 200%;
} }
.wiki{ .wikiTextArea{
} }

View File

@ -28,32 +28,32 @@
<RowConstraints maxHeight="37.0" minHeight="10.0" prefHeight="35.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="37.0" minHeight="10.0" prefHeight="35.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<Label fx:id="labelAlbumName" alignment="CENTER" styleClass="title" text="Album Name" wrapText="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER"> <Label fx:id="labelAlbumName" alignment="CENTER" styleClass="titleLabel" text="Album Name" wrapText="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
<font> <font>
<Font name="System Bold" size="18.0" /> <Font name="System Bold" size="18.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelArtistName" alignment="CENTER" styleClass="sub" text="Artist Name" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER"> <Label fx:id="labelArtistName" alignment="CENTER" styleClass="subLabel" text="Artist Name" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelUserScrobbles" alignment="CENTER" text="User Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER"> <Label fx:id="labelUserScrobbles" alignment="CENTER" styleClass="normalLabel" text="User Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelRatio" alignment="CENTER" text="Ratio" GridPane.halignment="CENTER" GridPane.rowIndex="3"> <Label fx:id="labelRatio" alignment="CENTER" styleClass="normalLabel" text="Ratio" GridPane.halignment="CENTER" GridPane.rowIndex="3">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelTotalListeners" alignment="CENTER" text="Total Listeners" GridPane.halignment="CENTER" GridPane.rowIndex="4"> <Label fx:id="labelTotalListeners" alignment="CENTER" styleClass="normalLabel" text="Total Listeners" GridPane.halignment="CENTER" GridPane.rowIndex="4">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelTotalScrobbles" alignment="CENTER" text="Total Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="5"> <Label fx:id="labelTotalScrobbles" alignment="CENTER" styleClass="normalLabel" text="Total Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="5">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
@ -64,7 +64,7 @@
</AnchorPane> </AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0"> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children> <children>
<TextArea fx:id="textAreaWiki" editable="false" layoutX="37.0" layoutY="34.0" prefHeight="285.0" prefWidth="296.0" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> <TextArea fx:id="textAreaWiki" editable="false" layoutX="37.0" layoutY="34.0" prefHeight="285.0" prefWidth="296.0" styleClass="wikiTextArea" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children> </children>
</AnchorPane> </AnchorPane>
</items> </items>

View File

@ -9,7 +9,7 @@
<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sarsoo.fmframework.fx.controller.ArtistPaneController"> <AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sarsoo.fmframework.fx.controller.ArtistPaneController">
<children> <children>
<BorderPane fx:id="albumBorderPane" prefHeight="327.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <BorderPane fx:id="albumBorderPane" prefHeight="327.0" prefWidth="600.0" stylesheets="@../styles/ObjPane.css" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<center> <center>
<SplitPane dividerPositions="0.5" prefHeight="327.0" prefWidth="600.0" BorderPane.alignment="CENTER"> <SplitPane dividerPositions="0.5" prefHeight="327.0" prefWidth="600.0" BorderPane.alignment="CENTER">
<items> <items>
@ -27,27 +27,27 @@
<RowConstraints maxHeight="37.0" minHeight="10.0" prefHeight="35.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="37.0" minHeight="10.0" prefHeight="35.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<Label fx:id="labelArtistName" alignment="CENTER" text="Artist Name" wrapText="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER"> <Label fx:id="labelArtistName" alignment="CENTER" prefHeight="165.0" prefWidth="296.0" styleClass="titleLabel" text="Artist Name" wrapText="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
<font> <font>
<Font name="System Bold" size="18.0" /> <Font name="System Bold" size="18.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelUserScrobbles" alignment="CENTER" text="User Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER"> <Label fx:id="labelUserScrobbles" alignment="CENTER" styleClass="normalLabel" text="User Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelRatio" alignment="CENTER" text="Ratio" GridPane.halignment="CENTER" GridPane.rowIndex="2"> <Label fx:id="labelRatio" alignment="CENTER" styleClass="normalLabel" text="Ratio" GridPane.halignment="CENTER" GridPane.rowIndex="2">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelTotalListeners" alignment="CENTER" text="Total Listeners" GridPane.halignment="CENTER" GridPane.rowIndex="3"> <Label fx:id="labelTotalListeners" alignment="CENTER" styleClass="normalLabel" text="Total Listeners" GridPane.halignment="CENTER" GridPane.rowIndex="3">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelTotalScrobbles" alignment="CENTER" text="Total Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="4"> <Label fx:id="labelTotalScrobbles" alignment="CENTER" styleClass="normalLabel" text="Total Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="4">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
@ -58,7 +58,7 @@
</AnchorPane> </AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0"> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children> <children>
<TextArea fx:id="textAreaWiki" editable="false" layoutX="37.0" layoutY="34.0" prefHeight="285.0" prefWidth="296.0" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> <TextArea fx:id="textAreaWiki" editable="false" layoutX="37.0" layoutY="34.0" prefHeight="285.0" prefWidth="296.0" styleClass="wikiTextArea" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children> </children>
</AnchorPane> </AnchorPane>
</items> </items>
@ -68,6 +68,7 @@
<ToolBar fx:id="toolBar" prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER"> <ToolBar fx:id="toolBar" prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<items> <items>
<Button fx:id="buttonRefresh" mnemonicParsing="false" onAction="#handleRefresh" text="refresh" /> <Button fx:id="buttonRefresh" mnemonicParsing="false" onAction="#handleRefresh" text="refresh" />
<Button fx:id="buttonViewTracks" mnemonicParsing="false" onAction="#handleViewTracks" text="view tracks" />
<Button fx:id="buttonViewOnline" mnemonicParsing="false" onAction="#viewOnline" text="view online" /> <Button fx:id="buttonViewOnline" mnemonicParsing="false" onAction="#viewOnline" text="view online" />
<Button fx:id="buttonViewRYM" mnemonicParsing="false" onAction="#viewRYM" text="view rym" /> <Button fx:id="buttonViewRYM" mnemonicParsing="false" onAction="#viewRYM" text="view rym" />
</items> </items>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.scene.chart.*?> <?import javafx.scene.chart.*?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import java.lang.*?> <?import java.lang.*?>
@ -17,12 +18,17 @@
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="301.0" minWidth="10.0" prefWidth="301.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="301.0" minWidth="10.0" prefWidth="301.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="290.0" minWidth="10.0" prefWidth="157.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="290.0" minWidth="10.0" prefWidth="157.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="194.0" minWidth="10.0" prefWidth="142.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="194.0" minWidth="10.0" prefWidth="106.0" />
</columnConstraints> </columnConstraints>
</GridPane> </GridPane>
</content> </content>
</ScrollPane> </ScrollPane>
<PieChart fx:id="pieChart" labelsVisible="false" legendVisible="false" styleClass="pieChart" /> <SplitPane dividerPositions="0.5" orientation="VERTICAL">
<items>
<PieChart fx:id="pieChart" legendVisible="false" prefHeight="250.0" styleClass="pieChart" />
<PieChart fx:id="pieChartArtists" legendVisible="false" prefHeight="250.0" styleClass="pieChart" stylesheets="@../styles/mainPane.css" />
</items>
</SplitPane>
</items> </items>
</SplitPane> </SplitPane>
</center> </center>

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.scene.chart.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<AnchorPane prefWidth="800.0" styleClass="pane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sarsoo.fmframework.fx.controller.FMObjListPaneEditController">
<children>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefWidth="800.0" styleClass="pane" stylesheets="@../styles/FMObjListPane.css" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<center>
<SplitPane dividerPositions="0.6353383458646616">
<items>
<ScrollPane fitToHeight="true" fitToWidth="true" prefViewportHeight="369.0" prefViewportWidth="600.0">
<content>
<GridPane fx:id="gridPaneFMObjs" alignment="CENTER" BorderPane.alignment="CENTER">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="301.0" minWidth="10.0" prefWidth="301.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="290.0" minWidth="10.0" prefWidth="157.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="194.0" minWidth="10.0" prefWidth="106.0" />
<ColumnConstraints halignment="RIGHT" hgrow="NEVER" maxWidth="194.0" minWidth="10.0" prefWidth="60.0" />
</columnConstraints>
</GridPane>
</content>
</ScrollPane>
<SplitPane dividerPositions="0.5" orientation="VERTICAL">
<items>
<PieChart fx:id="pieChart" legendVisible="false" prefHeight="250.0" styleClass="pieChart" />
<PieChart fx:id="pieChartArtists" legendVisible="false" prefHeight="250.0" styleClass="pieChart" stylesheets="@../styles/mainPane.css" />
</items>
</SplitPane>
</items>
</SplitPane>
</center>
<top>
<VBox prefHeight="31.0" BorderPane.alignment="CENTER">
<children>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="383.0" minWidth="10.0" prefWidth="382.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="533.0" minWidth="10.0" prefWidth="339.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="78.0" minWidth="0.0" prefWidth="78.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label fx:id="labelTotalScrobbles" styleClass="stats" text="0" GridPane.halignment="CENTER" />
<Label fx:id="labelPercent" styleClass="stats" text="0%" GridPane.columnIndex="1" GridPane.halignment="CENTER" />
<Button fx:id="buttonRefresh" contentDisplay="CENTER" mnemonicParsing="false" onAction="#handleRefresh" prefHeight="25.0" prefWidth="57.0" text="refresh" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" />
</children>
</GridPane>
</children>
</VBox>
</top>
<bottom>
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<items>
<TextField fx:id="textTrack" prefHeight="25.0" prefWidth="217.0" promptText="track" />
<TextField fx:id="textAlbum" prefHeight="25.0" prefWidth="239.0" promptText="album" />
<TextField fx:id="textArtist" prefHeight="25.0" prefWidth="230.0" promptText="artist" />
<MenuButton fx:id="menuButtonAdd" alignment="CENTER_RIGHT" contentDisplay="CENTER" mnemonicParsing="false" text="add">
<items>
<MenuItem fx:id="menuItemTrack" mnemonicParsing="false" onAction="#handleAddTrack" text="track" />
<MenuItem fx:id="menuItemAlbum" mnemonicParsing="false" text="album" />
<MenuItem fx:id="menuItemArtist" mnemonicParsing="false" text="artist" />
</items>
</MenuButton>
</items>
</ToolBar>
</bottom>
</BorderPane>
</children>
</AnchorPane>

View File

@ -9,7 +9,7 @@
<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sarsoo.fmframework.fx.controller.TrackPaneController"> <AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sarsoo.fmframework.fx.controller.TrackPaneController">
<children> <children>
<BorderPane fx:id="albumBorderPane" prefHeight="327.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <BorderPane fx:id="albumBorderPane" prefHeight="327.0" prefWidth="600.0" stylesheets="@../styles/ObjPane.css" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<center> <center>
<SplitPane dividerPositions="0.5" prefHeight="327.0" prefWidth="600.0" BorderPane.alignment="CENTER"> <SplitPane dividerPositions="0.5" prefHeight="327.0" prefWidth="600.0" BorderPane.alignment="CENTER">
<items> <items>
@ -29,37 +29,37 @@
<RowConstraints maxHeight="37.0" minHeight="10.0" prefHeight="35.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="37.0" minHeight="10.0" prefHeight="35.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<Label fx:id="labelTrackName" alignment="CENTER" text="Track Name" wrapText="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER"> <Label fx:id="labelTrackName" alignment="CENTER" styleClass="titleLabel" text="Track Name" wrapText="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
<font> <font>
<Font name="System Bold" size="18.0" /> <Font name="System Bold" size="18.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelArtistName" alignment="CENTER" text="Artist Name" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER"> <Label fx:id="labelArtistName" alignment="CENTER" styleClass="subLabel" text="Artist Name" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelUserScrobbles" alignment="CENTER" text="User Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="3" GridPane.valignment="CENTER"> <Label fx:id="labelUserScrobbles" alignment="CENTER" styleClass="normalLabel" text="User Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="3" GridPane.valignment="CENTER">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelRatio" alignment="CENTER" text="Ratio" GridPane.halignment="CENTER" GridPane.rowIndex="4"> <Label fx:id="labelRatio" alignment="CENTER" styleClass="normalLabel" text="Ratio" GridPane.halignment="CENTER" GridPane.rowIndex="4">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelTotalListeners" alignment="CENTER" text="Total Listeners" GridPane.halignment="CENTER" GridPane.rowIndex="5"> <Label fx:id="labelTotalListeners" alignment="CENTER" styleClass="normalLabel" text="Total Listeners" GridPane.halignment="CENTER" GridPane.rowIndex="5">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelTotalScrobbles" alignment="CENTER" text="Total Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="6"> <Label fx:id="labelTotalScrobbles" alignment="CENTER" styleClass="normalLabel" text="Total Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="6">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
</Label> </Label>
<Label fx:id="labelAlbumName" alignment="CENTER" text="Album Name" GridPane.halignment="CENTER" GridPane.rowIndex="1"> <Label fx:id="labelAlbumName" alignment="CENTER" styleClass="subLabel" text="Album Name" GridPane.halignment="CENTER" GridPane.rowIndex="1">
<font> <font>
<Font size="13.0" /> <Font size="13.0" />
</font> </font>
@ -70,7 +70,7 @@
</AnchorPane> </AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0"> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children> <children>
<TextArea fx:id="textAreaWiki" editable="false" layoutX="37.0" layoutY="34.0" prefHeight="285.0" prefWidth="296.0" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> <TextArea fx:id="textAreaWiki" editable="false" layoutX="37.0" layoutY="34.0" prefHeight="285.0" prefWidth="296.0" styleClass="wikiTextArea" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children> </children>
</AnchorPane> </AnchorPane>
</items> </items>

View File

@ -21,6 +21,7 @@
<Menu fx:id="menuUtil" mnemonicParsing="false" text="util"> <Menu fx:id="menuUtil" mnemonicParsing="false" text="util">
<items> <items>
<MenuItem fx:id="menuItemScrobble" mnemonicParsing="false" onAction="#handleScrobble" text="scrobble" /> <MenuItem fx:id="menuItemScrobble" mnemonicParsing="false" onAction="#handleScrobble" text="scrobble" />
<MenuItem fx:id="menuItemCreateList" mnemonicParsing="false" onAction="#handleCreateList" text="create list" />
</items> </items>
</Menu> </Menu>
</menus> </menus>

View File

@ -1,6 +1,6 @@
package sarsoo.fmframework.music; package sarsoo.fmframework.music;
public class Tag { public class Tag implements Comparable<Tag>{
private String name; private String name;
private String url; private String url;
private int count; private int count;
@ -42,4 +42,9 @@ public class Tag {
public String toString() { public String toString() {
return name; return name;
} }
@Override
public int compareTo(Tag arg0) {
return name.compareTo(arg0.getName());
}
} }

View File

@ -20,6 +20,8 @@ public class Track extends FMObj {
protected boolean isLoved; protected boolean isLoved;
protected ArrayList<Tag> tagList; protected ArrayList<Tag> tagList;
private int utsFirstListen;
public Track(String name, String artist) { public Track(String name, String artist) {
super(name, null, null, 0, 0, 0, null); super(name, null, null, 0, 0, 0, null);
this.artist = new Artist(artist); this.artist = new Artist(artist);
@ -32,6 +34,8 @@ public class Track extends FMObj {
} }
public static Track getTrack(String name, String artist, String username) { public static Track getTrack(String name, String artist, String username) {
System.out.println("Artist " + artist);
System.out.println("track " + name);
String url = URLBuilder.getTrackInfoUrl(name, artist, username); String url = URLBuilder.getTrackInfoUrl(name, artist, username);
// TestCall.test(url); // TestCall.test(url);
Document response = Network.getResponse(url); Document response = Network.getResponse(url);
@ -103,4 +107,12 @@ public class Track extends FMObj {
this.isLoved = track.isLoved; this.isLoved = track.isLoved;
} }
public int getUtsFirstListen() {
return utsFirstListen;
}
public void setUtsFirstListen(int utsFirstListen) {
this.utsFirstListen = utsFirstListen;
}
} }

View File

@ -45,6 +45,23 @@ public class URLBuilder {
} }
public static String getArtistTracks(String artist, int page, String username) {
String urlString;
try {
urlString = String.format(
"http://ws.audioscrobbler.com/2.0/?method=user.getartisttracks&user=%s&artist=%s&page=%d&api_key=%s",
URLEncoder.encode(username, "UTF-8"),
URLEncoder.encode(artist, "UTF-8"),
page,
URLEncoder.encode(Key.getKey(), "UTF-8"));
return urlString;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
public static String getAlbumInfoUrl(String album, String artist, String username) { public static String getAlbumInfoUrl(String album, String artist, String username) {
String urlString; String urlString;
try { try {
@ -64,8 +81,10 @@ public class URLBuilder {
try { try {
urlString = String.format( urlString = String.format(
"http://ws.audioscrobbler.com/2.0/?method=track.getInfo&track=%s&artist=%s&autocorrect=0&username=%s&api_key=%s", "http://ws.audioscrobbler.com/2.0/?method=track.getInfo&track=%s&artist=%s&autocorrect=0&username=%s&api_key=%s",
URLEncoder.encode(name, "UTF-8"), URLEncoder.encode(artist, "UTF-8"), URLEncoder.encode(name, "UTF-8"),
URLEncoder.encode(username, "UTF-8"), URLEncoder.encode(Key.getKey(), "UTF-8")); URLEncoder.encode(artist, "UTF-8"),
URLEncoder.encode(username, "UTF-8"),
URLEncoder.encode(Key.getKey(), "UTF-8"));
return urlString; return urlString;
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -92,7 +92,6 @@ public class Parser {
return null; return null;
} }
public static Artist parseArtist(Document doc) { public static Artist parseArtist(Document doc) {
if (doc.getDocumentElement().getAttribute("status").equals("ok")) { if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
String name = doc.getElementsByTagName("name").item(0).getTextContent(); String name = doc.getElementsByTagName("name").item(0).getTextContent();
@ -299,7 +298,7 @@ public class Parser {
Tag tag = new Tag(name, url); Tag tag = new Tag(name, url);
// System.out.println(name + " " + url); // System.out.println(name + " " + url);
list.add(tag); list.add(tag);
} }
return list; return list;
@ -330,7 +329,7 @@ public class Parser {
// System.out.println(obj.getTextContent()); // System.out.println(obj.getTextContent());
Artist artist = Artist.getArtist(name, Reference.getUserName()); Artist artist = Artist.getArtist(name, Reference.getUserName());
// System.out.println(artist); // System.out.println(artist);
list.add(artist); list.add(artist);
} }
return list; return list;
@ -339,6 +338,43 @@ public class Parser {
} }
public static FMObjList parseArtistTracks(Document doc) {
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
NodeList objList = doc.getElementsByTagName("track");
// Node obj = objList.item(0);
FMObjList list = new FMObjList();
// String name = obj.getFirstChild().getTextContent();
// System.out.println(name);
//
// Artist artist = Artist.getArtist(name, Reference.getUserName());
//
// System.out.println(artist);
int counter;
for (counter = 0; counter < objList.getLength(); counter++) {
Node obj = objList.item(counter);
NodeList objNodes = obj.getChildNodes();
String artist = objNodes.item(0).getTextContent();
// System.out.println(artist);
String name = objNodes.item(2).getTextContent();
// System.out.println(name);
// System.out.println(name + ".");
// System.out.println(obj.getTextContent());
// System.out.println(counter);
// System.out.println(artist);
Track track = Track.getTrack(name, artist, Reference.getUserName());
list.add(track);
}
return list;
}
return null;
}
public static void printDocument(Document doc, OutputStream out) throws IOException, TransformerException { public static void printDocument(Document doc, OutputStream out) throws IOException, TransformerException {
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer(); Transformer transformer = tf.newTransformer();

View File

@ -58,7 +58,8 @@ class NetworkTest {
void testTag() { void testTag() {
// System.out.println(Instant.parse("2018-04-05T07:00:00.00Z").getEpochSecond()); // System.out.println(Instant.parse("2018-04-05T07:00:00.00Z").getEpochSecond());
System.out.println(URLBuilder.getUserPersonalTags("sarsoo", "rap", 2)); Reference.setUserName("sarsoo");
Getter.getArtistTracks("eminem", "sarsoo");
// System.out.println(url); // System.out.println(url);
} }

View File

@ -86,6 +86,44 @@ public class Getter {
return null; return null;
} }
public static FMObjList getArtistTracks(String artist, String username) {
// String url = URLBuilder.getArtistTracks(artist, 1, username);
// Document doc = Network.getResponse(url);
// if (doc != null) {
// int pages = Integer.valueOf(
// doc.getFirstChild().getFirstChild().getAttributes().getNamedItem("totalPages").getNodeValue());
//
// FMObjList list = Parser.parseArtistTracks(doc);
//// list.setGroupName(artist + " tracks");
//
// System.out.println(pages);
//
//
// return list;
// }
FMObjList totalList = new FMObjList();
FMObjList list = new FMObjList();
int counter = 1;
do {
String url = URLBuilder.getArtistTracks(artist, counter, username);
Document doc = Network.getResponse(url);
list = Parser.parseArtistTracks(doc);
totalList.addAll(list);
counter++;
}while(list.size() > 0);
return totalList;
}
public static ArrayList<Tag> getUserTags(String username) { public static ArrayList<Tag> getUserTags(String username) {
String url = URLBuilder.getUserTopTags(username); String url = URLBuilder.getUserTopTags(username);
Document doc = Network.getResponse(url); Document doc = Network.getResponse(url);