threaded piechart updating
This commit is contained in:
parent
0ea8f91e14
commit
31146c5452
@ -26,13 +26,15 @@ public class FmFramework extends Application {
|
|||||||
// Parent root = FXMLLoader.load(getClass().getResource("ui/main.fxml"));
|
// Parent root = FXMLLoader.load(getClass().getResource("ui/main.fxml"));
|
||||||
Parent root = (Parent)loader.load();
|
Parent root = (Parent)loader.load();
|
||||||
|
|
||||||
Scene scene = new Scene(root, 800, 400);
|
Scene scene = new Scene(root, 1000, 800);
|
||||||
|
|
||||||
rootScene = scene;
|
rootScene = scene;
|
||||||
// scene.getStylesheets().add("styles/style.css");
|
// scene.getStylesheets().add("styles/style.css");
|
||||||
|
|
||||||
control = (ControllerMain)loader.getController();
|
control = (ControllerMain)loader.getController();
|
||||||
|
// (new Thread(new TagCaller())).start();
|
||||||
|
stage.setMinHeight(800);
|
||||||
|
stage.setMinWidth(1000);
|
||||||
stage.setTitle("fm framework");
|
stage.setTitle("fm framework");
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.show();
|
stage.show();
|
||||||
|
14
fmframework/src/sarsoo/fmframework/fx/TagCaller.java
Normal file
14
fmframework/src/sarsoo/fmframework/fx/TagCaller.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package sarsoo.fmframework.fx;
|
||||||
|
|
||||||
|
import javafx.concurrent.*;
|
||||||
|
import sarsoo.fmframework.util.Getter;
|
||||||
|
import sarsoo.fmframework.util.Reference;
|
||||||
|
|
||||||
|
public class TagCaller extends Task{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Object call() throws Exception {
|
||||||
|
|
||||||
|
return Getter.getUserTags(Reference.getUserName());
|
||||||
|
}
|
||||||
|
}
|
@ -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.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
@ -15,9 +16,12 @@ import javafx.scene.text.Text;
|
|||||||
import sarsoo.fmframework.fx.AlbumTab;
|
import sarsoo.fmframework.fx.AlbumTab;
|
||||||
import sarsoo.fmframework.fx.ArtistTab;
|
import sarsoo.fmframework.fx.ArtistTab;
|
||||||
import sarsoo.fmframework.fx.FMObjListTab;
|
import sarsoo.fmframework.fx.FMObjListTab;
|
||||||
|
import sarsoo.fmframework.fx.FmFramework;
|
||||||
import sarsoo.fmframework.fx.TrackTab;
|
import sarsoo.fmframework.fx.TrackTab;
|
||||||
import sarsoo.fmframework.music.Album;
|
import sarsoo.fmframework.music.Album;
|
||||||
|
import sarsoo.fmframework.music.Artist;
|
||||||
import sarsoo.fmframework.music.Tag;
|
import sarsoo.fmframework.music.Tag;
|
||||||
|
import sarsoo.fmframework.music.Track;
|
||||||
import sarsoo.fmframework.util.FMObjList;
|
import sarsoo.fmframework.util.FMObjList;
|
||||||
import sarsoo.fmframework.util.Getter;
|
import sarsoo.fmframework.util.Getter;
|
||||||
import sarsoo.fmframework.util.Reference;
|
import sarsoo.fmframework.util.Reference;
|
||||||
@ -33,6 +37,9 @@ import javafx.scene.Parent;
|
|||||||
|
|
||||||
import javafx.scene.layout.*;
|
import javafx.scene.layout.*;
|
||||||
|
|
||||||
|
import javafx.concurrent.*;
|
||||||
|
import javafx.application.Platform;
|
||||||
|
|
||||||
public class ControllerMain {
|
public class ControllerMain {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@ -81,7 +88,7 @@ public class ControllerMain {
|
|||||||
FMObjListTab tab = new FMObjListTab(Getter.getUserTag(Reference.getUserName(), name));
|
FMObjListTab tab = new FMObjListTab(Getter.getUserTag(Reference.getUserName(), name));
|
||||||
|
|
||||||
tabPane.getTabs().add(tab);
|
tabPane.getTabs().add(tab);
|
||||||
// System.out.println("tab added");
|
// System.out.println("tab added");
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -91,6 +98,31 @@ public class ControllerMain {
|
|||||||
menuTag.getItems().add(item);
|
menuTag.getItems().add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FMObjList rap = Getter.getUserTag(Reference.getUserName(), "rap");
|
||||||
|
// FMObjList classicRap = Getter.getUserTag(Reference.getUserName(), "classic
|
||||||
|
// rap");
|
||||||
|
// FMObjList grime = Getter.getUserTag(Reference.getUserName(), "grime");
|
||||||
|
//
|
||||||
|
// int rapTotal = rap.getTotalUserScrobbles() -
|
||||||
|
// classicRap.getTotalUserScrobbles() - grime.getTotalUserScrobbles();
|
||||||
|
//
|
||||||
|
// ObservableList<PieChart.Data> rapData = FXCollections.observableArrayList(
|
||||||
|
// new PieChart.Data("rap", rapTotal),
|
||||||
|
// new PieChart.Data("classic rap", classicRap.getTotalUserScrobbles()),
|
||||||
|
// new PieChart.Data("grime", grime.getTotalUserScrobbles()));
|
||||||
|
// pieChartRap.setData(rapData);
|
||||||
|
//
|
||||||
|
// int other = Getter.getScrobbles(Reference.getUserName()) -
|
||||||
|
// rap.getTotalUserScrobbles();
|
||||||
|
//
|
||||||
|
// ObservableList<PieChart.Data> rapTotalData =
|
||||||
|
// FXCollections.observableArrayList(
|
||||||
|
// new PieChart.Data("rap", rapTotal),
|
||||||
|
// new PieChart.Data("classic rap", classicRap.getTotalUserScrobbles()),
|
||||||
|
// new PieChart.Data("grime", grime.getTotalUserScrobbles()),
|
||||||
|
// new PieChart.Data("other", other));
|
||||||
|
// pieChartRapTotal.setData(rapTotalData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateGenrePieChart() {
|
public void updateGenrePieChart() {
|
||||||
@ -99,10 +131,7 @@ public class ControllerMain {
|
|||||||
"indie", "jazz", "blues", "core" };
|
"indie", "jazz", "blues", "core" };
|
||||||
|
|
||||||
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(
|
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(
|
||||||
// new PieChart.Data("rap", Getter.getUserTag(Reference.getUserName(),
|
|
||||||
// "rap").getTotalUserScrobbles()),
|
|
||||||
// new PieChart.Data("rock", Getter.getUserTag(Reference.getUserName(),
|
|
||||||
// "rap").getTotalUserScrobbles()),
|
|
||||||
new PieChart.Data("rock", 5), new PieChart.Data("rock", 5), new PieChart.Data("rock", 5));
|
new PieChart.Data("rock", 5), new PieChart.Data("rock", 5), new PieChart.Data("rock", 5));
|
||||||
pieChartGenres = new PieChart(pieChartData);
|
pieChartGenres = new PieChart(pieChartData);
|
||||||
|
|
||||||
@ -111,38 +140,6 @@ 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"));
|
|
||||||
//
|
|
||||||
// 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);
|
|
||||||
//
|
|
||||||
|
|
||||||
tabPane.getTabs().add(new AlbumTab(Getter.getAlbum()));
|
tabPane.getTabs().add(new AlbumTab(Getter.getAlbum()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,6 +155,15 @@ public class ControllerMain {
|
|||||||
tabPane.getTabs().add(new TrackTab(Getter.getTrack()));
|
tabPane.getTabs().add(new TrackTab(Getter.getTrack()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected void handleScrobble(ActionEvent event) throws IOException {
|
||||||
|
Album album = Getter.getAlbum();
|
||||||
|
if (album != null) {
|
||||||
|
Track track = Getter.getTrack(album);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Menu menuTag;
|
private Menu menuTag;
|
||||||
|
|
||||||
@ -205,7 +211,7 @@ public class ControllerMain {
|
|||||||
|
|
||||||
if (event.getCode() == KeyCode.F5) {
|
if (event.getCode() == KeyCode.F5) {
|
||||||
refresh();
|
refresh();
|
||||||
// System.out.println("refreshed");
|
// System.out.println("refreshed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,6 +224,7 @@ public class ControllerMain {
|
|||||||
.setText(NumberFormat.getInstance().format(Getter.getScrobbles(Reference.getUserName())));
|
.setText(NumberFormat.getInstance().format(Getter.getScrobbles(Reference.getUserName())));
|
||||||
|
|
||||||
tags = Getter.getUserTags(Reference.getUserName());
|
tags = Getter.getUserTags(Reference.getUserName());
|
||||||
|
menuTag.getItems().clear();
|
||||||
|
|
||||||
int counter;
|
int counter;
|
||||||
for (counter = 0; counter < tags.size(); counter++) {
|
for (counter = 0; counter < tags.size(); counter++) {
|
||||||
@ -241,8 +248,6 @@ public class ControllerMain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
menuTag.getItems().clear();
|
|
||||||
menuTag.getItems().add(item);
|
menuTag.getItems().add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -253,4 +258,78 @@ public class ControllerMain {
|
|||||||
|
|
||||||
selectionModel.select(tab);
|
selectionModel.select(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private PieChart pieChartRap;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private PieChart pieChartRapTotal;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Accordion accordionCharts;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TitledPane titledPaneGenres;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TitledPane titledPaneRap;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected void handleRefreshPieChart(ActionEvent event) throws IOException {
|
||||||
|
|
||||||
|
refreshPieCharts();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshPieCharts() {
|
||||||
|
Service<Void> service = new Service<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Task<Void> createTask() {
|
||||||
|
return new Task<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void call() throws Exception {
|
||||||
|
|
||||||
|
FMObjList rap = Getter.getUserTag(Reference.getUserName(), "rap");
|
||||||
|
FMObjList classicRap = Getter.getUserTag(Reference.getUserName(), "classic rap");
|
||||||
|
FMObjList grime = Getter.getUserTag(Reference.getUserName(), "grime");
|
||||||
|
|
||||||
|
int rapTotal = rap.getTotalUserScrobbles() - classicRap.getTotalUserScrobbles() - grime.getTotalUserScrobbles();
|
||||||
|
|
||||||
|
ObservableList<PieChart.Data> rapData = FXCollections.observableArrayList(new PieChart.Data("rap", rapTotal),
|
||||||
|
new PieChart.Data("classic rap", classicRap.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("grime", grime.getTotalUserScrobbles()));
|
||||||
|
|
||||||
|
int other = Getter.getScrobbles(Reference.getUserName()) - rap.getTotalUserScrobbles();
|
||||||
|
|
||||||
|
ObservableList<PieChart.Data> rapTotalData = FXCollections.observableArrayList(
|
||||||
|
new PieChart.Data("rap", rapTotal),
|
||||||
|
new PieChart.Data("classic rap", classicRap.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("grime", grime.getTotalUserScrobbles()), new PieChart.Data("other", other));
|
||||||
|
|
||||||
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
Platform.runLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try{
|
||||||
|
pieChartRap.setData(rapData);
|
||||||
|
|
||||||
|
|
||||||
|
pieChartRapTotal.setData(rapTotalData);
|
||||||
|
|
||||||
|
accordionCharts.setExpandedPane(titledPaneRap);
|
||||||
|
}finally{
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
latch.await();
|
||||||
|
//Keep with the background work
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
service.start();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,9 @@ import java.text.NumberFormat;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
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;
|
||||||
@ -16,9 +19,11 @@ import sarsoo.fmframework.fx.FmFramework;
|
|||||||
import sarsoo.fmframework.music.Artist;
|
import sarsoo.fmframework.music.Artist;
|
||||||
import sarsoo.fmframework.music.FMObj;
|
import sarsoo.fmframework.music.FMObj;
|
||||||
import sarsoo.fmframework.util.FMObjList;
|
import sarsoo.fmframework.util.FMObjList;
|
||||||
|
import sarsoo.fmframework.util.Getter;
|
||||||
import sarsoo.fmframework.util.Maths;
|
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.*;
|
||||||
|
|
||||||
public class FMObjListPaneController {
|
public class FMObjListPaneController {
|
||||||
|
|
||||||
@ -31,7 +36,14 @@ public class FMObjListPaneController {
|
|||||||
@FXML
|
@FXML
|
||||||
private GridPane gridPaneFMObjs;
|
private GridPane gridPaneFMObjs;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private PieChart pieChart;
|
||||||
|
|
||||||
|
private FMObjList list;
|
||||||
|
|
||||||
public void populate(FMObjList list) {
|
public void populate(FMObjList list) {
|
||||||
|
this.list = list;
|
||||||
|
|
||||||
double percent = Maths.getPercentListening(list, Reference.getUserName());
|
double percent = Maths.getPercentListening(list, Reference.getUserName());
|
||||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||||
|
|
||||||
@ -48,6 +60,8 @@ public class FMObjListPaneController {
|
|||||||
|
|
||||||
Label name = new Label(obj.getName().toLowerCase());
|
Label name = new Label(obj.getName().toLowerCase());
|
||||||
|
|
||||||
|
name.getStyleClass().add("nameLabel");
|
||||||
|
|
||||||
name.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<Event>() {
|
name.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<Event>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -73,6 +87,72 @@ public class FMObjListPaneController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(
|
||||||
|
new PieChart.Data(list.getGroupName(), list.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("other", Getter.getScrobbles(Reference.getUserName()) - list.getTotalUserScrobbles()));
|
||||||
|
pieChart.setData(pieChartData);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected void handleRefresh(ActionEvent event) {
|
||||||
|
|
||||||
|
list = Getter.getUserTag(Reference.getUserName(), list.getGroupName());
|
||||||
|
|
||||||
|
|
||||||
|
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.getGroupName(), list.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("other", Getter.getScrobbles(Reference.getUserName()) - list.getTotalUserScrobbles()));
|
||||||
|
pieChart.setData(pieChartData);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
.nameLabel{
|
.nameLabel{
|
||||||
-fx-alignment: center;
|
-fx-alignment: center;
|
||||||
|
-fx-font-size: 150%;
|
||||||
-fx-font-style: italic;
|
-fx-font-style: italic;
|
||||||
|
-fx-text-alignment: center;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,9 +20,27 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.percent{
|
.stats{
|
||||||
-fx-text-alignment: right;
|
|
||||||
|
|
||||||
|
-fx-font-size: 300%;
|
||||||
|
|
||||||
-fx-font-style: italic;
|
-fx-font-style: italic;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pane{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.pieChart{
|
||||||
|
|
||||||
|
-fx-start-angle: 90;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.default-color0.chart-pie { -fx-pie-color: #820000; }
|
||||||
|
.default-color1.chart-pie { -fx-pie-color: #49505b; }
|
22
fmframework/src/sarsoo/fmframework/fx/styles/ObjPane.css
Normal file
22
fmframework/src/sarsoo/fmframework/fx/styles/ObjPane.css
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
.title{
|
||||||
|
|
||||||
|
-fx-font-size: 400%;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.sub{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.wiki{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,9 +0,0 @@
|
|||||||
.statsLabel{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.pane{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -11,3 +11,8 @@
|
|||||||
|
|
||||||
-fx-text-fill: white;
|
-fx-text-fill: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pieChart{
|
||||||
|
|
||||||
|
-fx-start-angle: 90;
|
||||||
|
}
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sarsoo.fmframework.fx.controller.AlbumPaneController">
|
<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sarsoo.fmframework.fx.controller.AlbumPaneController">
|
||||||
<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>
|
||||||
@ -28,12 +28,12 @@
|
|||||||
<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" text="Album Name" wrapText="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
|
<Label fx:id="labelAlbumName" alignment="CENTER" styleClass="title" 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" text="Artist Name" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
|
<Label fx:id="labelArtistName" alignment="CENTER" styleClass="sub" text="Artist Name" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
|
@ -1,42 +1,47 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.chart.*?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import java.lang.*?>
|
<?import java.lang.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
<AnchorPane styleClass="pane" stylesheets="@../styles/fmObjListTab.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sarsoo.fmframework.fx.controller.FMObjListPaneController">
|
<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.FMObjListPaneController">
|
||||||
<children>
|
<children>
|
||||||
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" styleClass="pane" stylesheets="@../styles/fmObjListPane.css" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<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>
|
<center>
|
||||||
|
<SplitPane dividerPositions="0.6353383458646616">
|
||||||
|
<items>
|
||||||
<ScrollPane fitToHeight="true" fitToWidth="true" prefViewportHeight="369.0" prefViewportWidth="600.0">
|
<ScrollPane fitToHeight="true" fitToWidth="true" prefViewportHeight="369.0" prefViewportWidth="600.0">
|
||||||
<content>
|
<content>
|
||||||
<GridPane fx:id="gridPaneFMObjs" BorderPane.alignment="CENTER">
|
<GridPane fx:id="gridPaneFMObjs" alignment="CENTER" BorderPane.alignment="CENTER">
|
||||||
<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="142.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
|
||||||
<RowConstraints maxHeight="-Infinity" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
</rowConstraints>
|
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</content>
|
</content>
|
||||||
</ScrollPane>
|
</ScrollPane>
|
||||||
|
<PieChart fx:id="pieChart" labelsVisible="false" legendVisible="false" styleClass="pieChart" />
|
||||||
|
</items>
|
||||||
|
</SplitPane>
|
||||||
</center>
|
</center>
|
||||||
<top>
|
<top>
|
||||||
<VBox prefHeight="31.0" BorderPane.alignment="CENTER">
|
<VBox prefHeight="31.0" BorderPane.alignment="CENTER">
|
||||||
<children>
|
<children>
|
||||||
<GridPane>
|
<GridPane>
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="383.0" minWidth="10.0" prefWidth="382.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.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>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Label fx:id="labelTotalScrobbles" styleClass="statsLabel" text="Label" GridPane.halignment="CENTER" />
|
<Label fx:id="labelTotalScrobbles" styleClass="stats" text="Label" GridPane.halignment="CENTER" />
|
||||||
<Label fx:id="labelPercent" styleClass="statsLabel" text="Label" GridPane.columnIndex="1" GridPane.halignment="CENTER" />
|
<Label fx:id="labelPercent" styleClass="stats" text="Label" 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>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
|
@ -18,6 +18,11 @@
|
|||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu fx:id="menuTag" mnemonicParsing="false" text="tags" />
|
<Menu fx:id="menuTag" mnemonicParsing="false" text="tags" />
|
||||||
|
<Menu fx:id="menuUtil" mnemonicParsing="false" text="util">
|
||||||
|
<items>
|
||||||
|
<MenuItem fx:id="menuItemScrobble" mnemonicParsing="false" onAction="#handleScrobble" text="scrobble" />
|
||||||
|
</items>
|
||||||
|
</Menu>
|
||||||
</menus>
|
</menus>
|
||||||
</MenuBar>
|
</MenuBar>
|
||||||
</top>
|
</top>
|
||||||
@ -47,7 +52,9 @@
|
|||||||
<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" />
|
||||||
<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>
|
||||||
<Accordion fx:id="accordionCharts" prefHeight="325.0" prefWidth="222.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<BorderPane prefHeight="354.0" prefWidth="211.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<center>
|
||||||
|
<Accordion fx:id="accordionCharts" prefHeight="325.0" prefWidth="222.0" BorderPane.alignment="CENTER">
|
||||||
<panes>
|
<panes>
|
||||||
<TitledPane fx:id="titledPaneGenres" animated="false" text="genres">
|
<TitledPane fx:id="titledPaneGenres" animated="false" text="genres">
|
||||||
<content>
|
<content>
|
||||||
@ -62,13 +69,34 @@
|
|||||||
<content>
|
<content>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
<children>
|
<children>
|
||||||
<PieChart prefHeight="274.0" prefWidth="220.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
<GridPane prefHeight="303.0" prefWidth="209.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<PieChart fx:id="pieChartRapTotal" prefHeight="274.0" prefWidth="220.0" styleClass="pieChart" stylesheets="@../styles/mainPane.css" title="total" GridPane.rowIndex="1" />
|
||||||
|
<PieChart fx:id="pieChartRap" styleClass="pieChart" stylesheets="@../styles/mainPane.css" title="rap" />
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</content>
|
</content>
|
||||||
</TitledPane>
|
</TitledPane>
|
||||||
</panes>
|
</panes>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
</center>
|
||||||
|
<bottom>
|
||||||
|
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||||
|
<items>
|
||||||
|
<Button fx:id="buttonPieChartRefresh" mnemonicParsing="false" onAction="#handleRefreshPieChart" text="refresh" />
|
||||||
|
</items>
|
||||||
|
</ToolBar>
|
||||||
|
</bottom>
|
||||||
|
</BorderPane>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</items>
|
</items>
|
||||||
|
58
fmframework/src/sarsoo/fmframework/net/Authenticator.java
Normal file
58
fmframework/src/sarsoo/fmframework/net/Authenticator.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package sarsoo.fmframework.net;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Authenticator {
|
||||||
|
public String write() {
|
||||||
|
URL url;
|
||||||
|
try {
|
||||||
|
url = new URL("http://ws.audioscrobbler.com/2.0/");
|
||||||
|
|
||||||
|
Map<String, Object> params = new LinkedHashMap<>();
|
||||||
|
params.put("name", "Freddie the Fish");
|
||||||
|
params.put("email", "fishie@seamail.example.com");
|
||||||
|
params.put("reply_to_thread", 10394);
|
||||||
|
params.put("message",
|
||||||
|
"Shark attacks in Botany Bay have gotten out of control. We need more defensive dolphins to protect the schools here, but Mayor Porpoise is too busy stuffing his snout with lobsters. He's so shellfish.");
|
||||||
|
|
||||||
|
StringBuilder postData = new StringBuilder();
|
||||||
|
for (Map.Entry<String, Object> param : params.entrySet()) {
|
||||||
|
if (postData.length() != 0)
|
||||||
|
postData.append('&');
|
||||||
|
postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
|
||||||
|
postData.append('=');
|
||||||
|
postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
|
||||||
|
}
|
||||||
|
byte[] postDataBytes = postData.toString().getBytes("UTF-8");
|
||||||
|
|
||||||
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("POST");
|
||||||
|
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
conn.getOutputStream().write(postDataBytes);
|
||||||
|
|
||||||
|
Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int c; (c = in.read()) >= 0;)
|
||||||
|
sb.append((char)c);
|
||||||
|
String response = sb.toString();
|
||||||
|
|
||||||
|
return response.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,18 @@
|
|||||||
package sarsoo.fmframework.net;
|
package sarsoo.fmframework.net;
|
||||||
|
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.Reader;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
@ -63,6 +69,49 @@ public class Network {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Document write(byte[] postDataBytes) {
|
||||||
|
|
||||||
|
URL url;
|
||||||
|
try {
|
||||||
|
url = new URL("http://ws.audioscrobbler.com/2.0/");
|
||||||
|
|
||||||
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("POST");
|
||||||
|
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
conn.getOutputStream().write(postDataBytes);
|
||||||
|
|
||||||
|
InputStream input = conn.getInputStream();
|
||||||
|
|
||||||
|
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||||
|
DocumentBuilder dBuilder;
|
||||||
|
try {
|
||||||
|
dBuilder = dbFactory.newDocumentBuilder();
|
||||||
|
try {
|
||||||
|
Document doc = dBuilder.parse(input);
|
||||||
|
conn.disconnect();
|
||||||
|
doc.getDocumentElement().normalize();
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
|
||||||
|
} catch (SAXException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static void openURL(String url) {
|
public static void openURL(String url) {
|
||||||
try {
|
try {
|
||||||
Desktop desktop = java.awt.Desktop.getDesktop();
|
Desktop desktop = java.awt.Desktop.getDesktop();
|
||||||
|
13
fmframework/src/sarsoo/fmframework/net/ParamAssembler.java
Normal file
13
fmframework/src/sarsoo/fmframework/net/ParamAssembler.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package sarsoo.fmframework.net;
|
||||||
|
|
||||||
|
public class ParamAssembler {
|
||||||
|
public static byte[] getToken() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void getSignature() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,8 @@ import java.net.URLEncoder;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import sarsoo.fmframework.music.Track;
|
||||||
|
|
||||||
public class URLBuilder {
|
public class URLBuilder {
|
||||||
|
|
||||||
public enum FMObjType{
|
public enum FMObjType{
|
||||||
@ -22,7 +24,6 @@ public class URLBuilder {
|
|||||||
URLEncoder.encode(Key.getKey(), "UTF-8"));
|
URLEncoder.encode(Key.getKey(), "UTF-8"));
|
||||||
return urlString;
|
return urlString;
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -38,7 +39,6 @@ public class URLBuilder {
|
|||||||
URLEncoder.encode(Key.getKey(), "UTF-8"));
|
URLEncoder.encode(Key.getKey(), "UTF-8"));
|
||||||
return urlString;
|
return urlString;
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -54,7 +54,6 @@ public class URLBuilder {
|
|||||||
URLEncoder.encode(username, "UTF-8"), URLEncoder.encode(Key.getKey(), "UTF-8"));
|
URLEncoder.encode(username, "UTF-8"), URLEncoder.encode(Key.getKey(), "UTF-8"));
|
||||||
return urlString;
|
return urlString;
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -69,7 +68,6 @@ public class URLBuilder {
|
|||||||
URLEncoder.encode(username, "UTF-8"), URLEncoder.encode(Key.getKey(), "UTF-8"));
|
URLEncoder.encode(username, "UTF-8"), URLEncoder.encode(Key.getKey(), "UTF-8"));
|
||||||
return urlString;
|
return urlString;
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -83,7 +81,6 @@ public class URLBuilder {
|
|||||||
URLEncoder.encode(username, "UTF-8"), URLEncoder.encode(Key.getKey(), "UTF-8"));
|
URLEncoder.encode(username, "UTF-8"), URLEncoder.encode(Key.getKey(), "UTF-8"));
|
||||||
return urlString;
|
return urlString;
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// System.out.println(urlString);
|
// System.out.println(urlString);
|
||||||
@ -97,7 +94,6 @@ public class URLBuilder {
|
|||||||
URLEncoder.encode(username, "UTF-8"), URLEncoder.encode(Key.getKey(), "UTF-8"));
|
URLEncoder.encode(username, "UTF-8"), URLEncoder.encode(Key.getKey(), "UTF-8"));
|
||||||
return urlString;
|
return urlString;
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// System.out.println(urlString);
|
// System.out.println(urlString);
|
||||||
@ -123,7 +119,6 @@ public class URLBuilder {
|
|||||||
URLEncoder.encode(Key.getKey(), "UTF-8"));
|
URLEncoder.encode(Key.getKey(), "UTF-8"));
|
||||||
return urlString;
|
return urlString;
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// System.out.println(urlString);
|
// System.out.println(urlString);
|
||||||
@ -141,7 +136,6 @@ public class URLBuilder {
|
|||||||
URLEncoder.encode(Key.getKey(), "UTF-8"));
|
URLEncoder.encode(Key.getKey(), "UTF-8"));
|
||||||
return urlString;
|
return urlString;
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// System.out.println(urlString);
|
// System.out.println(urlString);
|
||||||
@ -156,7 +150,6 @@ public class URLBuilder {
|
|||||||
URLEncoder.encode(Key.getKey(), "UTF-8"));
|
URLEncoder.encode(Key.getKey(), "UTF-8"));
|
||||||
return urlString;
|
return urlString;
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// System.out.println(urlString);
|
// System.out.println(urlString);
|
||||||
@ -193,35 +186,25 @@ public class URLBuilder {
|
|||||||
URLEncoder.encode(Key.getKey(), "UTF-8"));
|
URLEncoder.encode(Key.getKey(), "UTF-8"));
|
||||||
return urlString;
|
return urlString;
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// System.out.println(urlString);
|
// System.out.println(urlString);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static String getUserTopTags() {
|
public static String getScrobble(Track track, String username) {
|
||||||
//
|
String urlString;
|
||||||
// }
|
try {
|
||||||
|
urlString = String.format("http://ws.audioscrobbler.com/2.0/?method=user.gettoptags&user=%s&api_key=%s",
|
||||||
|
URLEncoder.encode(username, "UTF-8"),
|
||||||
|
URLEncoder.encode(Key.getKey(), "UTF-8"));
|
||||||
|
return urlString;
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// System.out.println(urlString);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// public static String getRecentTracaksUrl(String username) {
|
|
||||||
//// Date date = new Date();
|
|
||||||
//// Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
|
||||||
//// Calendar cal2 = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
|
||||||
////
|
|
||||||
//// cal.set(cal.YEAR, cal.MONTH, cal.DATE);
|
|
||||||
//// System.out.println(cal.getTime());
|
|
||||||
// //System.out.println(cal2.getTime());
|
|
||||||
//
|
|
||||||
// String urlString = String.format(
|
|
||||||
// "http://ws.audioscrobbler.com/2.0/"
|
|
||||||
// + "?method=user.getRecentTracks&"
|
|
||||||
// + "user=%s&"
|
|
||||||
// + "limit = 200&"
|
|
||||||
// + "from=%d&"
|
|
||||||
// + "api_key=%s",
|
|
||||||
// username, Key.getKey());
|
|
||||||
// return urlString;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import sarsoo.fmframework.music.Artist;
|
|||||||
import sarsoo.fmframework.music.FMObj;
|
import sarsoo.fmframework.music.FMObj;
|
||||||
import sarsoo.fmframework.music.Track;
|
import sarsoo.fmframework.music.Track;
|
||||||
|
|
||||||
public class FMObjList extends ArrayList<FMObj> {
|
public class FMObjList extends ArrayList<FMObj> implements Comparable<FMObjList>{
|
||||||
|
|
||||||
private String groupName = null;
|
private String groupName = null;
|
||||||
|
|
||||||
@ -98,4 +98,17 @@ public class FMObjList extends ArrayList<FMObj> {
|
|||||||
public void setGroupName(String name) {
|
public void setGroupName(String name) {
|
||||||
this.groupName = name;
|
this.groupName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(FMObjList list) {
|
||||||
|
return getTotalUserScrobbles() - list.getTotalUserScrobbles();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh() {
|
||||||
|
int counter;
|
||||||
|
for(counter = 0; counter < size(); counter++) {
|
||||||
|
get(counter).refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,16 @@ public class Getter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Track getTrack(Album album) {
|
||||||
|
String trackName = JOptionPane.showInputDialog(null, "Enter Track Name");
|
||||||
|
if (trackName != null) {
|
||||||
|
Track track = Track.getTrack(album.getArtist().getName(), trackName, Reference.getUserName());
|
||||||
|
track.setAlbum(album);
|
||||||
|
return track;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static Track getLastTrack() {
|
public static Track getLastTrack() {
|
||||||
|
|
||||||
String url = URLBuilder.getLastTrackUrl(Reference.getUserName());
|
String url = URLBuilder.getLastTrackUrl(Reference.getUserName());
|
||||||
|
9
fmframework/src/sarsoo/fmframework/util/Scrobbler.java
Normal file
9
fmframework/src/sarsoo/fmframework/util/Scrobbler.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package sarsoo.fmframework.util;
|
||||||
|
|
||||||
|
import sarsoo.fmframework.music.Track;
|
||||||
|
|
||||||
|
public class Scrobbler {
|
||||||
|
public int scrobble(Track track) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user