maincontroller layout change, added verbose
This commit is contained in:
parent
1e77421d1b
commit
db825e6813
@ -43,29 +43,18 @@ import javafx.scene.layout.*;
|
|||||||
|
|
||||||
import javafx.concurrent.*;
|
import javafx.concurrent.*;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
public class ControllerMain {
|
public class ControllerMain {
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label labelStatsScrobblesToday;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label labelStatsUsername;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label labelStatsScrobblesTotal;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private PieChart pieChartGenres;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private TabPane tabPane;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
Reference.setUserName("sarsoo");
|
Reference.setUserName("sarsoo");
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
|
||||||
|
public void refresh() {
|
||||||
|
|
||||||
Service<Void> service = new Service<Void>() {
|
Service<Void> service = new Service<Void>() {
|
||||||
@Override
|
@Override
|
||||||
@ -73,11 +62,11 @@ public class ControllerMain {
|
|||||||
return new Task<Void>() {
|
return new Task<Void>() {
|
||||||
@Override
|
@Override
|
||||||
protected Void call() throws Exception {
|
protected Void call() throws Exception {
|
||||||
|
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||||
|
|
||||||
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()));
|
||||||
|
|
||||||
|
|
||||||
TrackTab tab = new TrackTab(Getter.getLastTrack());
|
TrackTab tab = new TrackTab(Getter.getLastTrack());
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
@ -92,8 +81,8 @@ public class ControllerMain {
|
|||||||
|
|
||||||
addTab(tab);
|
addTab(tab);
|
||||||
|
|
||||||
refreshPieCharts();
|
// refreshPieCharts();
|
||||||
updateTagMenu();
|
refreshTagMenu();
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
@ -108,11 +97,10 @@ public class ControllerMain {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
service.start();
|
service.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<Tag> tags;
|
|
||||||
public void updateTagMenu() {
|
public void refreshTagMenu() {
|
||||||
tags = Getter.getUserTags(Reference.getUserName());
|
tags = Getter.getUserTags(Reference.getUserName());
|
||||||
|
|
||||||
Collections.sort(tags);
|
Collections.sort(tags);
|
||||||
@ -122,7 +110,6 @@ public class ControllerMain {
|
|||||||
|
|
||||||
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);
|
||||||
@ -139,8 +126,8 @@ public class ControllerMain {
|
|||||||
@Override
|
@Override
|
||||||
protected Void call() throws Exception {
|
protected Void call() throws Exception {
|
||||||
|
|
||||||
FMObjListTab tab = new FMObjListTab(Getter
|
FMObjListTab tab = new FMObjListTab(
|
||||||
.getUserTag(Reference.getUserName(), name));
|
Getter.getUserTag(Reference.getUserName(), name));
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
Platform.runLater(new Runnable() {
|
Platform.runLater(new Runnable() {
|
||||||
@ -168,17 +155,144 @@ public class ControllerMain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateGenrePieChart() {
|
|
||||||
|
|
||||||
String[] names = { "rock", "rap", "classic rock", "pop punk", "electronic", "metal", "grime", "classic rap",
|
public void refreshPieCharts() {
|
||||||
"indie", "jazz", "blues", "core" };
|
Service<Void> service = new Service<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Task<Void> createTask() {
|
||||||
|
return new Task<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void call() throws Exception {
|
||||||
|
|
||||||
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(
|
int total = Getter.getScrobbles(Reference.getUserName());
|
||||||
|
|
||||||
new PieChart.Data("rock", 5), new PieChart.Data("rock", 5), new PieChart.Data("rock", 5));
|
FMObjList rap = Getter.getUserTag(Reference.getUserName(), "rap");
|
||||||
pieChartGenres = new PieChart(pieChartData);
|
FMObjList classicRap = Getter.getUserTag(Reference.getUserName(), "classic rap");
|
||||||
|
FMObjList grime = Getter.getUserTag(Reference.getUserName(), "grime");
|
||||||
|
|
||||||
|
FMObjList classicRock = Getter.getUserTag(Reference.getUserName(), "classic rock");
|
||||||
|
FMObjList popPunk = Getter.getUserTag(Reference.getUserName(), "pop punk");
|
||||||
|
FMObjList electronic = Getter.getUserTag(Reference.getUserName(), "electronic");
|
||||||
|
FMObjList metal = Getter.getUserTag(Reference.getUserName(), "metal");
|
||||||
|
FMObjList indie = Getter.getUserTag(Reference.getUserName(), "indie");
|
||||||
|
FMObjList rock = Getter.getUserTag(Reference.getUserName(), "rock");
|
||||||
|
FMObjList jazz = Getter.getUserTag(Reference.getUserName(), "jazz");
|
||||||
|
FMObjList blues = Getter.getUserTag(Reference.getUserName(), "blues");
|
||||||
|
FMObjList core = Getter.getUserTag(Reference.getUserName(), "core");
|
||||||
|
FMObjList rnb = Getter.getUserTag(Reference.getUserName(), "rnb");
|
||||||
|
FMObjList soulFunk = Getter.getUserTag(Reference.getUserName(), "soulfunk");
|
||||||
|
|
||||||
|
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()));
|
||||||
|
|
||||||
|
Collections.sort(rapData, new Comparator<PieChart.Data>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(Data arg0, Data arg1) {
|
||||||
|
return (int) (arg1.getPieValue() - arg0.getPieValue());
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
int other = total - 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()));
|
||||||
|
|
||||||
|
Collections.sort(rapTotalData, new Comparator<PieChart.Data>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(Data arg0, Data arg1) {
|
||||||
|
return (int) (arg1.getPieValue() - arg0.getPieValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
rapTotalData.add(new PieChart.Data("other", other));
|
||||||
|
|
||||||
|
int totalOther = total - rap.getTotalUserScrobbles() - classicRock.getTotalUserScrobbles()
|
||||||
|
- popPunk.getTotalUserScrobbles() - electronic.getTotalUserScrobbles()
|
||||||
|
- metal.getTotalUserScrobbles() - indie.getTotalUserScrobbles()
|
||||||
|
- rock.getTotalUserScrobbles() - jazz.getTotalUserScrobbles()
|
||||||
|
- blues.getTotalUserScrobbles() - core.getTotalUserScrobbles()
|
||||||
|
- rnb.getTotalUserScrobbles();
|
||||||
|
|
||||||
|
ObservableList<PieChart.Data> genreData = FXCollections.observableArrayList(
|
||||||
|
new PieChart.Data(String.format("rap %.2f%%", rapTotal*100/total), rapTotal),
|
||||||
|
new PieChart.Data("classic rap", classicRap.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("grime", grime.getTotalUserScrobbles()),
|
||||||
|
|
||||||
|
new PieChart.Data("classic rock", classicRock.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("pop punk", popPunk.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("electronic", electronic.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("metal", metal.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("indie", indie.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("rock", rock.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("jazz", jazz.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("blues", blues.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("core", core.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("soulfunk", soulFunk.getTotalUserScrobbles()),
|
||||||
|
new PieChart.Data("rnb", rnb.getTotalUserScrobbles()));
|
||||||
|
|
||||||
|
Collections.sort(genreData, new Comparator<PieChart.Data>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(Data arg0, Data arg1) {
|
||||||
|
return (int) (arg1.getPieValue() - arg0.getPieValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
genreData.add(new PieChart.Data("other", totalOther));
|
||||||
|
|
||||||
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
Platform.runLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
pieChartRap.setData(rapData);
|
||||||
|
|
||||||
|
pieChartRapTotal.setData(rapTotalData);
|
||||||
|
|
||||||
|
pieChartGenres.setData(genreData);
|
||||||
|
|
||||||
|
accordionCharts.setExpandedPane(titledPaneGenres);
|
||||||
|
} finally {
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
latch.await();
|
||||||
|
// Keep with the background work
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
service.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTab(Tab tab) {
|
||||||
|
tabPane.getTabs().add(tab);
|
||||||
|
SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel();
|
||||||
|
|
||||||
|
selectionModel.select(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected void handleKeyShortcut(KeyEvent event) throws IOException {
|
||||||
|
|
||||||
|
if (event.getCode() == KeyCode.F5) {
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
protected void handleLookupAlbum(ActionEvent event) throws IOException {
|
protected void handleLookupAlbum(ActionEvent event) throws IOException {
|
||||||
@ -217,6 +331,7 @@ public class ControllerMain {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
protected void handleLookupArtist(ActionEvent event) throws IOException {
|
protected void handleLookupArtist(ActionEvent event) throws IOException {
|
||||||
Service<Void> service = new Service<Void>() {
|
Service<Void> service = new Service<Void>() {
|
||||||
@ -251,10 +366,9 @@ public class ControllerMain {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
service.start();
|
service.start();
|
||||||
|
|
||||||
// tabPane.getTabs().add(new ArtistTab(Getter.getArtist()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
protected void handleLookupTrack(ActionEvent event) throws IOException {
|
protected void handleLookupTrack(ActionEvent event) throws IOException {
|
||||||
|
|
||||||
@ -292,6 +406,66 @@ public class ControllerMain {
|
|||||||
service.start();
|
service.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected void handleCurrentTrack(ActionEvent event) throws IOException {
|
||||||
|
Service<Void> service = new Service<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Task<Void> createTask() {
|
||||||
|
return new Task<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void call() throws Exception {
|
||||||
|
|
||||||
|
Track track = Getter.getLastTrack();
|
||||||
|
|
||||||
|
if (track != null) {
|
||||||
|
TrackTab tab = new TrackTab(track);
|
||||||
|
|
||||||
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
Platform.runLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
tabPane.getTabs().add(tab);
|
||||||
|
} finally {
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
latch.await();
|
||||||
|
}
|
||||||
|
// Keep with the background work
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
service.start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected void handleRefreshPieChart(ActionEvent event) throws IOException {
|
||||||
|
|
||||||
|
refreshPieCharts();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected void handleCreateList(ActionEvent event) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
Tab tab = new FMObjListTab();
|
||||||
|
addTab(tab);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
protected void handleScrobble(ActionEvent event) throws IOException {
|
protected void handleScrobble(ActionEvent event) throws IOException {
|
||||||
Album album = sarsoo.fmframework.jframe.Getter.getAlbum();
|
Album album = sarsoo.fmframework.jframe.Getter.getAlbum();
|
||||||
@ -301,154 +475,26 @@ public class ControllerMain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ArrayList<Tag> tags;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label labelStatsScrobblesToday;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label labelStatsUsername;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label labelStatsScrobblesTotal;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private PieChart pieChartGenres;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TabPane tabPane;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Menu menuTag;
|
private Menu menuTag;
|
||||||
|
|
||||||
// @FXML
|
|
||||||
// protected void handleTagClick(ActionEvent event) throws IOException {
|
|
||||||
// // System.out.println("clicked");
|
|
||||||
//
|
|
||||||
// if (tags == null) {
|
|
||||||
// // System.out.println("list null");
|
|
||||||
//
|
|
||||||
// tags = Getter.getUserTags(Reference.getUserName());
|
|
||||||
//
|
|
||||||
// int counter;
|
|
||||||
// for (counter = 0; counter < tags.size(); counter++) {
|
|
||||||
//
|
|
||||||
// String name = tags.get(counter).getName().toLowerCase();
|
|
||||||
//
|
|
||||||
// // System.out.println(name);
|
|
||||||
//
|
|
||||||
// MenuItem item = new MenuItem(name);
|
|
||||||
//
|
|
||||||
// item.setOnAction(new EventHandler<ActionEvent>() {
|
|
||||||
// @Override
|
|
||||||
// public void handle(ActionEvent e) {
|
|
||||||
// try {
|
|
||||||
// FMObjListTab tab = new
|
|
||||||
// FMObjListTab(Getter.getUserTag(Reference.getUserName(), name));
|
|
||||||
//
|
|
||||||
// tabPane.getTabs().add(tab);
|
|
||||||
// System.out.println("tab added");
|
|
||||||
// } catch (IOException e1) {
|
|
||||||
// e1.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// menuTag.getItems().add(item);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
protected void handleKeyShortcut(KeyEvent event) throws IOException {
|
|
||||||
|
|
||||||
if (event.getCode() == KeyCode.F5) {
|
|
||||||
refresh();
|
|
||||||
// System.out.println("refreshed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh() {
|
|
||||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
|
||||||
|
|
||||||
Service<Void> service = new Service<Void>() {
|
|
||||||
@Override
|
|
||||||
protected Task<Void> createTask() {
|
|
||||||
return new Task<Void>() {
|
|
||||||
@Override
|
|
||||||
protected Void call() throws Exception {
|
|
||||||
|
|
||||||
String scrobblesToday = numberFormat.format(Getter.getScrobblesToday(Reference.getUserName()));
|
|
||||||
String scrobbles = numberFormat.format(Getter.getScrobbles(Reference.getUserName()));
|
|
||||||
tags = Getter.getUserTags(Reference.getUserName());
|
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
|
||||||
Platform.runLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
|
|
||||||
labelStatsScrobblesToday.setText(scrobblesToday);
|
|
||||||
labelStatsUsername.setText(Reference.getUserName());
|
|
||||||
labelStatsScrobblesTotal.setText(scrobbles);
|
|
||||||
|
|
||||||
// refreshPieCharts();
|
|
||||||
menuTag.getItems().clear();
|
|
||||||
|
|
||||||
int counter;
|
|
||||||
for (counter = 0; counter < tags.size(); counter++) {
|
|
||||||
|
|
||||||
String name = tags.get(counter).getName().toLowerCase();
|
|
||||||
|
|
||||||
// System.out.println(name);
|
|
||||||
|
|
||||||
MenuItem item = new MenuItem(name);
|
|
||||||
|
|
||||||
item.setOnAction(new EventHandler<ActionEvent>() {
|
|
||||||
@Override
|
|
||||||
public void handle(ActionEvent e) {
|
|
||||||
|
|
||||||
// TAG ITEM HANDLER SERVICE
|
|
||||||
Service<Void> service = new Service<Void>() {
|
|
||||||
@Override
|
|
||||||
protected Task<Void> createTask() {
|
|
||||||
return new Task<Void>() {
|
|
||||||
@Override
|
|
||||||
protected Void call() throws Exception {
|
|
||||||
|
|
||||||
FMObjListTab tab = new FMObjListTab(Getter
|
|
||||||
.getUserTag(Reference.getUserName(), name));
|
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
|
||||||
Platform.runLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
tabPane.getTabs().add(tab);
|
|
||||||
} finally {
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
latch.await();
|
|
||||||
// Keep with the background work
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
service.start();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
menuTag.getItems().add(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
latch.await();
|
|
||||||
// Keep with the background work
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
service.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addTab(Tab tab) {
|
|
||||||
tabPane.getTabs().add(tab);
|
|
||||||
SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel();
|
|
||||||
|
|
||||||
selectionModel.select(tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private PieChart pieChartRap;
|
private PieChart pieChartRap;
|
||||||
|
|
||||||
@ -465,146 +511,6 @@ public class ControllerMain {
|
|||||||
private TitledPane titledPaneRap;
|
private TitledPane titledPaneRap;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
protected void handleRefreshPieChart(ActionEvent event) throws IOException {
|
private StackPane stackViewGenres;
|
||||||
|
|
||||||
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 {
|
|
||||||
|
|
||||||
int total = Getter.getScrobbles(Reference.getUserName());
|
|
||||||
|
|
||||||
FMObjList rap = Getter.getUserTag(Reference.getUserName(), "rap");
|
|
||||||
FMObjList classicRap = Getter.getUserTag(Reference.getUserName(), "classic rap");
|
|
||||||
FMObjList grime = Getter.getUserTag(Reference.getUserName(), "grime");
|
|
||||||
|
|
||||||
FMObjList classicRock = Getter.getUserTag(Reference.getUserName(), "classic rock");
|
|
||||||
FMObjList popPunk = Getter.getUserTag(Reference.getUserName(), "pop punk");
|
|
||||||
FMObjList electronic = Getter.getUserTag(Reference.getUserName(), "electronic");
|
|
||||||
FMObjList metal = Getter.getUserTag(Reference.getUserName(), "metal");
|
|
||||||
FMObjList indie = Getter.getUserTag(Reference.getUserName(), "indie");
|
|
||||||
FMObjList rock = Getter.getUserTag(Reference.getUserName(), "rock");
|
|
||||||
FMObjList jazz = Getter.getUserTag(Reference.getUserName(), "jazz");
|
|
||||||
FMObjList blues = Getter.getUserTag(Reference.getUserName(), "blues");
|
|
||||||
FMObjList core = Getter.getUserTag(Reference.getUserName(), "core");
|
|
||||||
FMObjList rnb = Getter.getUserTag(Reference.getUserName(), "rnb");
|
|
||||||
|
|
||||||
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()));
|
|
||||||
|
|
||||||
Collections.sort(rapData, new Comparator<PieChart.Data>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(Data arg0, Data arg1) {
|
|
||||||
return (int) (arg1.getPieValue() - arg0.getPieValue());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
int other = total - 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()));
|
|
||||||
|
|
||||||
Collections.sort(rapTotalData, new Comparator<PieChart.Data>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(Data arg0, Data arg1) {
|
|
||||||
return (int) (arg1.getPieValue() - arg0.getPieValue());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
rapTotalData.add(new PieChart.Data("other", other));
|
|
||||||
|
|
||||||
int totalOther = total - rap.getTotalUserScrobbles()
|
|
||||||
- classicRock.getTotalUserScrobbles()
|
|
||||||
- popPunk.getTotalUserScrobbles()
|
|
||||||
- electronic.getTotalUserScrobbles()
|
|
||||||
- metal.getTotalUserScrobbles()
|
|
||||||
- indie.getTotalUserScrobbles()
|
|
||||||
- rock.getTotalUserScrobbles()
|
|
||||||
- jazz.getTotalUserScrobbles()
|
|
||||||
- blues.getTotalUserScrobbles()
|
|
||||||
- core.getTotalUserScrobbles()
|
|
||||||
- rnb.getTotalUserScrobbles();
|
|
||||||
|
|
||||||
ObservableList<PieChart.Data> genreData = FXCollections.observableArrayList(
|
|
||||||
new PieChart.Data("rap", rapTotal),
|
|
||||||
new PieChart.Data("classic rap", classicRap.getTotalUserScrobbles()),
|
|
||||||
new PieChart.Data("grime", grime.getTotalUserScrobbles()),
|
|
||||||
|
|
||||||
new PieChart.Data("classic rock", classicRock.getTotalUserScrobbles()),
|
|
||||||
new PieChart.Data("pop punk", popPunk.getTotalUserScrobbles()),
|
|
||||||
new PieChart.Data("electronic", electronic.getTotalUserScrobbles()),
|
|
||||||
new PieChart.Data("metal", metal.getTotalUserScrobbles()),
|
|
||||||
new PieChart.Data("indie", indie.getTotalUserScrobbles()),
|
|
||||||
new PieChart.Data("rock", rock.getTotalUserScrobbles()),
|
|
||||||
new PieChart.Data("jazz", jazz.getTotalUserScrobbles()),
|
|
||||||
new PieChart.Data("blues", blues.getTotalUserScrobbles()),
|
|
||||||
new PieChart.Data("core", core.getTotalUserScrobbles()),
|
|
||||||
new PieChart.Data("rnb", rnb.getTotalUserScrobbles()));
|
|
||||||
|
|
||||||
Collections.sort(genreData, new Comparator<PieChart.Data>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(Data arg0, Data arg1) {
|
|
||||||
return (int) (arg1.getPieValue() - arg0.getPieValue());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
genreData.add(new PieChart.Data("other", totalOther));
|
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
|
||||||
Platform.runLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
pieChartRap.setData(rapData);
|
|
||||||
|
|
||||||
pieChartRapTotal.setData(rapTotalData);
|
|
||||||
|
|
||||||
pieChartGenres.setData(genreData);
|
|
||||||
|
|
||||||
accordionCharts.setExpandedPane(titledPaneRap);
|
|
||||||
} finally {
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
latch.await();
|
|
||||||
// Keep with the background work
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
service.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
protected void handleCreateList(ActionEvent event) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
Tab tab = new FMObjListTab();
|
|
||||||
addTab(tab);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,37 +28,61 @@
|
|||||||
<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="titleLabel" text="Album Name" wrapText="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
|
<AnchorPane>
|
||||||
|
<children>
|
||||||
|
<Label fx:id="labelAlbumName" alignment="CENTER" styleClass="titleLabel" text="Album Name" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" 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="subLabel" text="Artist Name" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
<AnchorPane GridPane.rowIndex="1">
|
||||||
|
<children>
|
||||||
|
<Label fx:id="labelArtistName" alignment="CENTER" styleClass="subLabel" text="Artist Name" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" 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" styleClass="normalLabel" text="User Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER">
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
<AnchorPane GridPane.rowIndex="2">
|
||||||
|
<children>
|
||||||
|
<Label fx:id="labelUserScrobbles" alignment="CENTER" styleClass="normalLabel" text="User Scrobbles" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" 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" styleClass="normalLabel" text="Ratio" GridPane.halignment="CENTER" GridPane.rowIndex="3">
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
<AnchorPane GridPane.rowIndex="3">
|
||||||
|
<children>
|
||||||
|
<Label fx:id="labelRatio" alignment="CENTER" styleClass="normalLabel" text="Ratio" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" 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" styleClass="normalLabel" text="Total Listeners" GridPane.halignment="CENTER" GridPane.rowIndex="4">
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
<AnchorPane GridPane.rowIndex="4">
|
||||||
|
<children>
|
||||||
|
<Label fx:id="labelTotalListeners" alignment="CENTER" styleClass="normalLabel" text="Total Listeners" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" 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" styleClass="normalLabel" text="Total Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="5">
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
<AnchorPane GridPane.rowIndex="5">
|
||||||
|
<children>
|
||||||
|
<Label fx:id="labelTotalScrobbles" alignment="CENTER" styleClass="normalLabel" text="Total Scrobbles" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" GridPane.halignment="CENTER" GridPane.rowIndex="5">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
</Label>
|
</Label>
|
||||||
</children>
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
<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" stylesheets="@../styles/ObjPane.css" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<BorderPane fx:id="albumBorderPane" prefHeight="800.0" prefWidth="1000.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.6983967935871743" prefHeight="327.0" prefWidth="600.0" BorderPane.alignment="CENTER">
|
||||||
<items>
|
<items>
|
||||||
<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>
|
||||||
@ -20,39 +20,59 @@
|
|||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints maxHeight="115.0" minHeight="10.0" prefHeight="94.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="213.0" minHeight="10.0" prefHeight="213.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints maxHeight="49.0" minHeight="10.0" prefHeight="33.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="49.0" minHeight="0.0" prefHeight="0.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints maxHeight="43.0" minHeight="10.0" prefHeight="34.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="43.0" minHeight="10.0" prefHeight="34.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints maxHeight="39.0" minHeight="10.0" prefHeight="34.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="39.0" minHeight="10.0" prefHeight="34.0" vgrow="SOMETIMES" />
|
||||||
<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" prefHeight="165.0" prefWidth="296.0" styleClass="titleLabel" text="Artist Name" wrapText="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
|
<AnchorPane>
|
||||||
|
<children>
|
||||||
|
<Label fx:id="labelArtistName" alignment="CENTER" prefHeight="165.0" prefWidth="296.0" styleClass="titleLabel" text="Artist Name" wrapText="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" 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" styleClass="normalLabel" text="User Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
<AnchorPane GridPane.rowIndex="1">
|
||||||
|
<children>
|
||||||
|
<Label fx:id="labelUserScrobbles" alignment="CENTER" styleClass="normalLabel" text="User Scrobbles" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" 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" styleClass="normalLabel" text="Ratio" GridPane.halignment="CENTER" GridPane.rowIndex="2">
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
<AnchorPane GridPane.rowIndex="2">
|
||||||
|
<children>
|
||||||
|
<Label fx:id="labelRatio" alignment="CENTER" styleClass="normalLabel" text="Ratio" AnchorPane.bottomAnchor="8.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" 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" styleClass="normalLabel" text="Total Listeners" GridPane.halignment="CENTER" GridPane.rowIndex="3">
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
<AnchorPane GridPane.rowIndex="3">
|
||||||
|
<children>
|
||||||
|
<Label fx:id="labelTotalListeners" alignment="CENTER" styleClass="normalLabel" text="Total Listeners" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" 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" styleClass="normalLabel" text="Total Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="4">
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
<AnchorPane GridPane.rowIndex="4">
|
||||||
|
<children>
|
||||||
|
<Label fx:id="labelTotalScrobbles" alignment="CENTER" styleClass="normalLabel" text="Total Scrobbles" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" GridPane.halignment="CENTER" GridPane.rowIndex="4">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
</Label>
|
</Label>
|
||||||
</children>
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<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" styleClass="titleLabel" 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.hgrow="ALWAYS" GridPane.valignment="CENTER">
|
||||||
<font>
|
<font>
|
||||||
<Font name="System Bold" size="18.0" />
|
<Font name="System Bold" size="18.0" />
|
||||||
</font>
|
</font>
|
||||||
|
@ -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="menuItemCurrentTrack" mnemonicParsing="false" onAction="#handleCurrentTrack" text="current track" />
|
||||||
<MenuItem fx:id="menuItemCreateList" mnemonicParsing="false" onAction="#handleCreateList" text="create list" />
|
<MenuItem fx:id="menuItemCreateList" mnemonicParsing="false" onAction="#handleCreateList" text="create list" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
@ -47,11 +48,6 @@
|
|||||||
<Tab fx:id="tabHome" closable="false" text="home">
|
<Tab fx:id="tabHome" closable="false" text="home">
|
||||||
<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>
|
|
||||||
<SplitPane fx:id="splitPaneHome" dividerPositions="0.6237458193979933" prefHeight="327.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
|
||||||
<items>
|
|
||||||
<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>
|
||||||
<BorderPane prefHeight="354.0" prefWidth="211.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>
|
<center>
|
||||||
@ -61,7 +57,7 @@
|
|||||||
<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 fx:id="pieChartGenres" layoutX="-189.0" layoutY="-102.0" prefHeight="249.0" prefWidth="220.0" styleClass="pieChart" stylesheets="@../styles/mainPane.css" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
<PieChart fx:id="pieChartGenres" prefHeight="263.0" prefWidth="209.0" styleClass="pieChart" stylesheets="@../styles/mainPane.css" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</content>
|
</content>
|
||||||
@ -100,10 +96,6 @@
|
|||||||
</BorderPane>
|
</BorderPane>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</items>
|
|
||||||
</SplitPane>
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
||||||
</content>
|
</content>
|
||||||
</Tab>
|
</Tab>
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class Album extends FMObj {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name + " - " + artist.getName();
|
return "Album: " + name + " - " + artist.getName();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class Artist extends FMObj {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return "Artist: " + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,7 +40,7 @@ public class Tag implements Comparable<Tag>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return "Tag: " + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,7 +91,9 @@ public class Track extends FMObj {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name + " - " + artist.getName();
|
if(album != null)
|
||||||
|
return "Track: " + name + " - " + album.getName() + " - " + artist.getName();
|
||||||
|
return "Track: " + name + " - " + artist.getName();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,9 @@ import sarsoo.fmframework.util.Reference;
|
|||||||
public class Parser {
|
public class Parser {
|
||||||
|
|
||||||
public static Album parseAlbum(Document doc) {
|
public static Album parseAlbum(Document doc) {
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("-parseAlbum");
|
||||||
|
|
||||||
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();
|
||||||
String artist = doc.getElementsByTagName("artist").item(0).getTextContent();
|
String artist = doc.getElementsByTagName("artist").item(0).getTextContent();
|
||||||
@ -58,7 +61,6 @@ public class Parser {
|
|||||||
NodeList wikiContents = wikiNode.getChildNodes();
|
NodeList wikiContents = wikiNode.getChildNodes();
|
||||||
|
|
||||||
String date = null;
|
String date = null;
|
||||||
// String summary = null;
|
|
||||||
String content = null;
|
String content = null;
|
||||||
|
|
||||||
int counter;
|
int counter;
|
||||||
@ -67,32 +69,31 @@ public class Parser {
|
|||||||
node = wikiContents.item(counter);
|
node = wikiContents.item(counter);
|
||||||
|
|
||||||
if (node.getNodeName().equals("published")) {
|
if (node.getNodeName().equals("published")) {
|
||||||
// System.out.println(node.getNodeName() + node.getTextContent());
|
|
||||||
date = node.getTextContent();
|
date = node.getTextContent();
|
||||||
}
|
}
|
||||||
// if (node.getNodeName().equals("summary")) {
|
|
||||||
// System.out.println(node.getNodeName() + node.getTextContent());
|
|
||||||
// summary = node.getTextContent();
|
|
||||||
// }
|
|
||||||
if (node.getNodeName().equals("content")) {
|
if (node.getNodeName().equals("content")) {
|
||||||
// System.out.println(node.getNodeName() + node.getTextContent());
|
|
||||||
content = node.getTextContent();
|
content = node.getTextContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (date != null && content != null)
|
if (date != null && content != null)
|
||||||
// System.out.println("wiki init");
|
|
||||||
wiki = new Wiki(date, null, content);
|
wiki = new Wiki(date, null, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
Album album = new Album(name, url, mbid, artistObj, listeners, playCount, userPlayCount, wiki);
|
Album album = new Album(name, url, mbid, artistObj, listeners, playCount, userPlayCount, wiki);
|
||||||
|
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println(album);
|
||||||
|
|
||||||
return album;
|
return album;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Artist parseArtist(Document doc) {
|
public static Artist parseArtist(Document doc) {
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("-parseArtist");
|
||||||
|
|
||||||
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();
|
||||||
String mbid = null;
|
String mbid = null;
|
||||||
@ -167,12 +168,19 @@ public class Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Artist artist = new Artist(name, url, mbid, listeners, playCount, userPlayCount, wiki);
|
Artist artist = new Artist(name, url, mbid, listeners, playCount, userPlayCount, wiki);
|
||||||
|
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println(artist);
|
||||||
|
|
||||||
return artist;
|
return artist;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Track parseTrack(Document doc) {
|
public static Track parseTrack(Document doc) {
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("-parseTrack");
|
||||||
|
|
||||||
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
|
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
|
||||||
String name = " ";
|
String name = " ";
|
||||||
try {
|
try {
|
||||||
@ -246,6 +254,10 @@ public class Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Track track = new Track(name, url, mbid, artistObj, listeners, playCount, userPlayCount, wiki);
|
Track track = new Track(name, url, mbid, artistObj, listeners, playCount, userPlayCount, wiki);
|
||||||
|
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println(track);
|
||||||
|
|
||||||
return track;
|
return track;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@ -254,6 +266,8 @@ public class Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Track parseLastTrack(Document doc) {
|
public static Track parseLastTrack(Document doc) {
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("-parseLastTrack");
|
||||||
|
|
||||||
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();
|
||||||
@ -268,6 +282,9 @@ public class Parser {
|
|||||||
|
|
||||||
track.setAlbum(album);
|
track.setAlbum(album);
|
||||||
|
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println(track);
|
||||||
|
|
||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,6 +293,9 @@ public class Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<Tag> parseUserTags(Document doc) {
|
public static ArrayList<Tag> parseUserTags(Document doc) {
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("-parseUserTags");
|
||||||
|
|
||||||
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
|
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
|
||||||
NodeList objList = doc.getElementsByTagName("tag");
|
NodeList objList = doc.getElementsByTagName("tag");
|
||||||
|
|
||||||
@ -298,6 +318,9 @@ public class Parser {
|
|||||||
|
|
||||||
Tag tag = new Tag(name, url);
|
Tag tag = new Tag(name, url);
|
||||||
|
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println(tag);
|
||||||
|
|
||||||
// System.out.println(name + " " + url);
|
// System.out.println(name + " " + url);
|
||||||
list.add(tag);
|
list.add(tag);
|
||||||
}
|
}
|
||||||
@ -308,6 +331,9 @@ public class Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static FMObjList parseUserTagList(Document doc) {
|
public static FMObjList parseUserTagList(Document doc) {
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("-parseUserTagList");
|
||||||
|
|
||||||
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
|
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
|
||||||
NodeList objList = doc.getElementsByTagName("artist");
|
NodeList objList = doc.getElementsByTagName("artist");
|
||||||
|
|
||||||
@ -329,6 +355,9 @@ 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());
|
||||||
|
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println(artist);
|
||||||
|
|
||||||
// System.out.println(artist);
|
// System.out.println(artist);
|
||||||
list.add(artist);
|
list.add(artist);
|
||||||
}
|
}
|
||||||
@ -339,6 +368,9 @@ public class Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static FMObjList parseArtistTracks(Document doc) {
|
public static FMObjList parseArtistTracks(Document doc) {
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("-parseArtistTracks");
|
||||||
|
|
||||||
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
|
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
|
||||||
NodeList objList = doc.getElementsByTagName("track");
|
NodeList objList = doc.getElementsByTagName("track");
|
||||||
|
|
||||||
@ -367,6 +399,9 @@ public class Parser {
|
|||||||
// System.out.println(artist);
|
// System.out.println(artist);
|
||||||
Track track = Track.getTrack(name, artist, Reference.getUserName());
|
Track track = Track.getTrack(name, artist, Reference.getUserName());
|
||||||
|
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println(track);
|
||||||
|
|
||||||
list.add(track);
|
list.add(track);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
@ -15,6 +15,8 @@ import sarsoo.fmframework.parser.Parser;
|
|||||||
|
|
||||||
public class Getter {
|
public class Getter {
|
||||||
public static Track getLastTrack() {
|
public static Track getLastTrack() {
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("--getLastTrack");
|
||||||
|
|
||||||
String url = URLBuilder.getLastTrackUrl(Reference.getUserName());
|
String url = URLBuilder.getLastTrackUrl(Reference.getUserName());
|
||||||
// TestCall.test(url);
|
// TestCall.test(url);
|
||||||
@ -25,6 +27,8 @@ public class Getter {
|
|||||||
// System.out.println(doc.getDocumentElement().getAttribute("status"));
|
// System.out.println(doc.getDocumentElement().getAttribute("status"));
|
||||||
Parser.stripSpace(doc.getDocumentElement());
|
Parser.stripSpace(doc.getDocumentElement());
|
||||||
Track track = Parser.parseLastTrack(doc);
|
Track track = Parser.parseLastTrack(doc);
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println(track);
|
||||||
// return null;
|
// return null;
|
||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
@ -33,17 +37,25 @@ public class Getter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getScrobbles(String username) {
|
public static int getScrobbles(String username) {
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("--getScrobbles");
|
||||||
|
|
||||||
String url = URLBuilder.getUserInfoUrl(username);
|
String url = URLBuilder.getUserInfoUrl(username);
|
||||||
Document doc = Network.getResponse(url);
|
Document doc = Network.getResponse(url);
|
||||||
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
|
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
|
||||||
String scrobbles = doc.getElementsByTagName("playcount").item(0).getTextContent();
|
String scrobbles = doc.getElementsByTagName("playcount").item(0).getTextContent();
|
||||||
if (scrobbles != null)
|
if (scrobbles != null)
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println(scrobbles);
|
||||||
return Integer.parseInt(scrobbles);
|
return Integer.parseInt(scrobbles);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getScrobblesToday(String username) {
|
public static int getScrobblesToday(String username) {
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("--getScrobblesToday");
|
||||||
|
|
||||||
String url = URLBuilder.getTodayScrobbles(username);
|
String url = URLBuilder.getTodayScrobbles(username);
|
||||||
Document doc = Network.getResponse(url);
|
Document doc = Network.getResponse(url);
|
||||||
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
|
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
|
||||||
@ -51,23 +63,32 @@ public class Getter {
|
|||||||
NamedNodeMap var = node.getAttributes();
|
NamedNodeMap var = node.getAttributes();
|
||||||
// System.out.println(var.getNamedItem("total").getNodeValue());
|
// System.out.println(var.getNamedItem("total").getNodeValue());
|
||||||
// if (scrobbles != null)
|
// if (scrobbles != null)
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println(var.getNamedItem("total").getNodeValue());
|
||||||
return Integer.parseInt(var.getNamedItem("total").getNodeValue());
|
return Integer.parseInt(var.getNamedItem("total").getNodeValue());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FMObjList getUserTag(String username, String tag) {
|
public static FMObjList getUserTag(String username, String tag) {
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("--getUserTag");
|
||||||
|
|
||||||
String url = URLBuilder.getUserPersonalTags(username, tag);
|
String url = URLBuilder.getUserPersonalTags(username, tag);
|
||||||
Document doc = Network.getResponse(url);
|
Document doc = Network.getResponse(url);
|
||||||
|
|
||||||
if (doc != null) {
|
if (doc != null) {
|
||||||
int pages = Integer.valueOf(
|
int pages = Integer.valueOf(
|
||||||
doc.getFirstChild().getFirstChild().getAttributes().getNamedItem("totalPages").getNodeValue());
|
doc.getFirstChild().getFirstChild().getAttributes().getNamedItem("totalPages").getNodeValue());
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("pages: " + pages);
|
||||||
|
|
||||||
FMObjList list = Parser.parseUserTagList(doc);
|
FMObjList list = Parser.parseUserTagList(doc);
|
||||||
list.setGroupName(tag);
|
list.setGroupName(tag);
|
||||||
|
|
||||||
// System.out.println(pages);
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("name: " + tag);
|
||||||
|
|
||||||
if (pages > 1) {
|
if (pages > 1) {
|
||||||
int counter;
|
int counter;
|
||||||
for (counter = 2; counter <= pages; counter++) {
|
for (counter = 2; counter <= pages; counter++) {
|
||||||
@ -80,6 +101,7 @@ public class Getter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +126,9 @@ public class Getter {
|
|||||||
// return list;
|
// return list;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("--getArtistTracks");
|
||||||
|
|
||||||
FMObjList totalList = new FMObjList();
|
FMObjList totalList = new FMObjList();
|
||||||
FMObjList list = new FMObjList();
|
FMObjList list = new FMObjList();
|
||||||
|
|
||||||
@ -125,6 +150,9 @@ public class Getter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<Tag> getUserTags(String username) {
|
public static ArrayList<Tag> getUserTags(String username) {
|
||||||
|
if(Reference.isVerbose())
|
||||||
|
System.out.println("--getUserTags");
|
||||||
|
|
||||||
String url = URLBuilder.getUserTopTags(username);
|
String url = URLBuilder.getUserTopTags(username);
|
||||||
Document doc = Network.getResponse(url);
|
Document doc = Network.getResponse(url);
|
||||||
if (doc != null) {
|
if (doc != null) {
|
||||||
|
@ -7,6 +7,7 @@ import sarsoo.fmframework.music.Artist;
|
|||||||
|
|
||||||
public class Reference {
|
public class Reference {
|
||||||
private static String userName;
|
private static String userName;
|
||||||
|
private static boolean isVerbose = true;
|
||||||
private static boolean isHeadless = true;
|
private static boolean isHeadless = true;
|
||||||
|
|
||||||
public static String getUserName() {
|
public static String getUserName() {
|
||||||
@ -17,7 +18,7 @@ public class Reference {
|
|||||||
userName = userNameIn;
|
userName = userNameIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getIsHeadless() {
|
public static boolean isHeadless() {
|
||||||
return isHeadless;
|
return isHeadless;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,4 +137,12 @@ public class Reference {
|
|||||||
return emoTrio;
|
return emoTrio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isVerbose() {
|
||||||
|
return isVerbose;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setVerbose(boolean isVerbose) {
|
||||||
|
Reference.isVerbose = isVerbose;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user