maincontroller layout change, added verbose

This commit is contained in:
aj 2018-04-24 00:40:24 -07:00
parent 1e77421d1b
commit db825e6813
12 changed files with 614 additions and 598 deletions

View File

@ -43,94 +43,81 @@ 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 @FXML
private Label labelStatsScrobblesToday; public void initialize() {
Reference.setUserName("sarsoo");
refresh();
}
@FXML
private Label labelStatsUsername;
@FXML public void refresh() {
private Label labelStatsScrobblesTotal;
@FXML
private PieChart pieChartGenres;
@FXML
private TabPane tabPane;
@FXML
public void initialize() {
Reference.setUserName("sarsoo");
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()));
TrackTab tab = new TrackTab(Getter.getLastTrack());
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);
addTab(tab);
refreshPieCharts();
updateTagMenu();
} finally {
latch.countDown();
}
}
});
latch.await();
// Keep with the background work
return null;
}
};
}
};
service.start();
}
private ArrayList<Tag> tags; Service<Void> service = new Service<Void>() {
public void updateTagMenu() { @Override
protected Task<Void> createTask() {
return new Task<Void>() {
@Override
protected Void call() throws Exception {
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
String scrobblesToday = numberFormat.format(Getter.getScrobblesToday(Reference.getUserName()));
String scrobbles = numberFormat.format(Getter.getScrobbles(Reference.getUserName()));
TrackTab tab = new TrackTab(Getter.getLastTrack());
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);
addTab(tab);
// refreshPieCharts();
refreshTagMenu();
} finally {
latch.countDown();
}
}
});
latch.await();
// Keep with the background work
return null;
}
};
}
};
service.start();
}
public void refreshTagMenu() {
tags = Getter.getUserTags(Reference.getUserName()); tags = Getter.getUserTags(Reference.getUserName());
Collections.sort(tags); Collections.sort(tags);
int counter; int counter;
for (counter = 0; counter < tags.size(); counter++) { for (counter = 0; counter < tags.size(); counter++) {
String name = tags.get(counter).getName().toLowerCase(); String name = tags.get(counter).getName().toLowerCase();
// System.out.println(name); // System.out.println(name);
MenuItem item = new MenuItem(name); MenuItem item = new MenuItem(name);
item.setOnAction(new EventHandler<ActionEvent>() { item.setOnAction(new EventHandler<ActionEvent>() {
@Override @Override
public void handle(ActionEvent e) { public void handle(ActionEvent e) {
// TAG ITEM HANDLER SERVICE // TAG ITEM HANDLER SERVICE
Service<Void> service = new Service<Void>() { Service<Void> service = new Service<Void>() {
@Override @Override
@ -138,10 +125,10 @@ public class ControllerMain {
return new Task<Void>() { return new Task<Void>() {
@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() {
@Override @Override
@ -163,270 +150,118 @@ public class ControllerMain {
service.start(); service.start();
} }
}); });
menuTag.getItems().add(item); menuTag.getItems().add(item);
} }
} }
public void updateGenrePieChart() {
String[] names = { "rock", "rap", "classic rock", "pop punk", "electronic", "metal", "grime", "classic rap", public void refreshPieCharts() {
"indie", "jazz", "blues", "core" };
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(
new PieChart.Data("rock", 5), new PieChart.Data("rock", 5), new PieChart.Data("rock", 5));
pieChartGenres = new PieChart(pieChartData);
}
@FXML
protected void handleLookupAlbum(ActionEvent event) throws IOException {
Service<Void> service = new Service<Void>() { Service<Void> service = new Service<Void>() {
@Override @Override
protected Task<Void> createTask() { protected Task<Void> createTask() {
return new Task<Void>() { return new Task<Void>() {
@Override @Override
protected Void call() throws Exception { protected Void call() throws Exception {
Album album = sarsoo.fmframework.jframe.Getter.getAlbum(); int total = Getter.getScrobbles(Reference.getUserName());
if (album != null) { FMObjList rap = Getter.getUserTag(Reference.getUserName(), "rap");
AlbumTab tab = new AlbumTab(album); FMObjList classicRap = Getter.getUserTag(Reference.getUserName(), "classic rap");
FMObjList grime = Getter.getUserTag(Reference.getUserName(), "grime");
final CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(new Runnable() { FMObjList classicRock = Getter.getUserTag(Reference.getUserName(), "classic rock");
@Override FMObjList popPunk = Getter.getUserTag(Reference.getUserName(), "pop punk");
public void run() { FMObjList electronic = Getter.getUserTag(Reference.getUserName(), "electronic");
try { FMObjList metal = Getter.getUserTag(Reference.getUserName(), "metal");
tabPane.getTabs().add(tab); FMObjList indie = Getter.getUserTag(Reference.getUserName(), "indie");
} finally { FMObjList rock = Getter.getUserTag(Reference.getUserName(), "rock");
latch.countDown(); 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");
latch.await(); FMObjList soulFunk = Getter.getUserTag(Reference.getUserName(), "soulfunk");
}
// Keep with the background work int rapTotal = rap.getTotalUserScrobbles() - classicRap.getTotalUserScrobbles()
return null; - grime.getTotalUserScrobbles();
}
}; ObservableList<PieChart.Data> rapData = FXCollections.observableArrayList(
} new PieChart.Data("rap", rapTotal),
}; new PieChart.Data("classic rap", classicRap.getTotalUserScrobbles()),
service.start(); new PieChart.Data("grime", grime.getTotalUserScrobbles()));
} Collections.sort(rapData, new Comparator<PieChart.Data>() {
@FXML @Override
protected void handleLookupArtist(ActionEvent event) throws IOException { public int compare(Data arg0, Data arg1) {
Service<Void> service = new Service<Void>() { return (int) (arg1.getPieValue() - arg0.getPieValue());
@Override }
protected Task<Void> createTask() { });
return new Task<Void>() {
@Override int other = total - rap.getTotalUserScrobbles();
protected Void call() throws Exception {
ObservableList<PieChart.Data> rapTotalData = FXCollections.observableArrayList(
Artist artist = sarsoo.fmframework.jframe.Getter.getArtist(); new PieChart.Data("rap", rapTotal),
new PieChart.Data("classic rap", classicRap.getTotalUserScrobbles()),
if (artist != null) { new PieChart.Data("grime", grime.getTotalUserScrobbles()));
ArtistTab tab = new ArtistTab(artist);
Collections.sort(rapTotalData, new Comparator<PieChart.Data>() {
final CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(new Runnable() { @Override
@Override public int compare(Data arg0, Data arg1) {
public void run() { return (int) (arg1.getPieValue() - arg0.getPieValue());
try { }
tabPane.getTabs().add(tab); });
} finally {
latch.countDown(); rapTotalData.add(new PieChart.Data("other", other));
}
} int totalOther = total - rap.getTotalUserScrobbles() - classicRock.getTotalUserScrobbles()
}); - popPunk.getTotalUserScrobbles() - electronic.getTotalUserScrobbles()
latch.await(); - metal.getTotalUserScrobbles() - indie.getTotalUserScrobbles()
} - rock.getTotalUserScrobbles() - jazz.getTotalUserScrobbles()
// Keep with the background work - blues.getTotalUserScrobbles() - core.getTotalUserScrobbles()
return null; - 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()),
service.start(); new PieChart.Data("grime", grime.getTotalUserScrobbles()),
// tabPane.getTabs().add(new ArtistTab(Getter.getArtist())); new PieChart.Data("classic rock", classicRock.getTotalUserScrobbles()),
} new PieChart.Data("pop punk", popPunk.getTotalUserScrobbles()),
new PieChart.Data("electronic", electronic.getTotalUserScrobbles()),
@FXML new PieChart.Data("metal", metal.getTotalUserScrobbles()),
protected void handleLookupTrack(ActionEvent event) throws IOException { new PieChart.Data("indie", indie.getTotalUserScrobbles()),
new PieChart.Data("rock", rock.getTotalUserScrobbles()),
Service<Void> service = new Service<Void>() { new PieChart.Data("jazz", jazz.getTotalUserScrobbles()),
@Override new PieChart.Data("blues", blues.getTotalUserScrobbles()),
protected Task<Void> createTask() { new PieChart.Data("core", core.getTotalUserScrobbles()),
return new Task<Void>() { new PieChart.Data("soulfunk", soulFunk.getTotalUserScrobbles()),
@Override new PieChart.Data("rnb", rnb.getTotalUserScrobbles()));
protected Void call() throws Exception {
Collections.sort(genreData, new Comparator<PieChart.Data>() {
Track track = sarsoo.fmframework.jframe.Getter.getTrack();
@Override
if (track != null) { public int compare(Data arg0, Data arg1) {
TrackTab tab = new TrackTab(track); return (int) (arg1.getPieValue() - arg0.getPieValue());
}
final CountDownLatch latch = new CountDownLatch(1); });
Platform.runLater(new Runnable() {
@Override
public void run() { genreData.add(new PieChart.Data("other", totalOther));
try {
tabPane.getTabs().add(tab);
} finally {
latch.countDown();
}
}
});
latch.await();
}
// Keep with the background work
return null;
}
};
}
};
service.start();
}
@FXML
protected void handleScrobble(ActionEvent event) throws IOException {
Album album = sarsoo.fmframework.jframe.Getter.getAlbum();
if (album != null) {
Track track = sarsoo.fmframework.jframe.Getter.getTrack(album);
}
}
@FXML
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); final CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(new Runnable() { Platform.runLater(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
pieChartRap.setData(rapData);
labelStatsScrobblesToday.setText(scrobblesToday);
labelStatsUsername.setText(Reference.getUserName()); pieChartRapTotal.setData(rapTotalData);
labelStatsScrobblesTotal.setText(scrobbles);
pieChartGenres.setData(genreData);
// refreshPieCharts();
menuTag.getItems().clear(); accordionCharts.setExpandedPane(titledPaneGenres);
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 { } finally {
latch.countDown(); latch.countDown();
} }
@ -445,10 +280,221 @@ public class ControllerMain {
public void addTab(Tab tab) { public void addTab(Tab tab) {
tabPane.getTabs().add(tab); tabPane.getTabs().add(tab);
SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel(); SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel();
selectionModel.select(tab); selectionModel.select(tab);
} }
@FXML
protected void handleKeyShortcut(KeyEvent event) throws IOException {
if (event.getCode() == KeyCode.F5) {
refresh();
}
}
@FXML
protected void handleLookupAlbum(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 {
Album album = sarsoo.fmframework.jframe.Getter.getAlbum();
if (album != null) {
AlbumTab tab = new AlbumTab(album);
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 handleLookupArtist(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 {
Artist artist = sarsoo.fmframework.jframe.Getter.getArtist();
if (artist != null) {
ArtistTab tab = new ArtistTab(artist);
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 handleLookupTrack(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 = sarsoo.fmframework.jframe.Getter.getTrack();
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 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
protected void handleScrobble(ActionEvent event) throws IOException {
Album album = sarsoo.fmframework.jframe.Getter.getAlbum();
if (album != null) {
Track track = sarsoo.fmframework.jframe.Getter.getTrack(album);
}
}
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
private Menu menuTag;
@FXML @FXML
private PieChart pieChartRap; private PieChart pieChartRap;
@ -463,148 +509,8 @@ public class ControllerMain {
@FXML @FXML
private TitledPane titledPaneRap; 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 {
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 @FXML
protected void handleCreateList(ActionEvent event) { private StackPane stackViewGenres;
try {
Tab tab = new FMObjListTab();
addTab(tab);
} catch (IOException e) {
e.printStackTrace();
}
}
} }

View File

@ -28,36 +28,60 @@
<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>
<font> <children>
<Font name="System Bold" size="18.0" /> <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>
</Label> <Font name="System Bold" size="18.0" />
<Label fx:id="labelArtistName" alignment="CENTER" styleClass="subLabel" text="Artist Name" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER"> </font>
<font> </Label>
<Font size="13.0" /> </children>
</font> </AnchorPane>
</Label> <AnchorPane GridPane.rowIndex="1">
<Label fx:id="labelUserScrobbles" alignment="CENTER" styleClass="normalLabel" text="User Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER"> <children>
<font> <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 size="13.0" /> <font>
</font> <Font size="13.0" />
</Label> </font>
<Label fx:id="labelRatio" alignment="CENTER" styleClass="normalLabel" text="Ratio" GridPane.halignment="CENTER" GridPane.rowIndex="3"> </Label>
<font> </children>
<Font size="13.0" /> </AnchorPane>
</font> <AnchorPane GridPane.rowIndex="2">
</Label> <children>
<Label fx:id="labelTotalListeners" alignment="CENTER" styleClass="normalLabel" text="Total Listeners" GridPane.halignment="CENTER" GridPane.rowIndex="4"> <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="labelTotalScrobbles" alignment="CENTER" styleClass="normalLabel" text="Total Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="5"> </children>
<font> </AnchorPane>
<Font size="13.0" /> <AnchorPane GridPane.rowIndex="3">
</font> <children>
</Label> <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 size="13.0" />
</font>
</Label>
</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 size="13.0" />
</font>
</Label>
</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 size="13.0" />
</font>
</Label>
</children>
</AnchorPane>
</children> </children>
</GridPane> </GridPane>
</children> </children>

View File

@ -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,38 +20,58 @@
<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>
<font> <children>
<Font name="System Bold" size="18.0" /> <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>
</Label> <Font name="System Bold" size="18.0" />
<Label fx:id="labelUserScrobbles" alignment="CENTER" styleClass="normalLabel" text="User Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER"> </font>
<font> </Label>
<Font size="13.0" /> </children>
</font> </AnchorPane>
</Label> <AnchorPane GridPane.rowIndex="1">
<Label fx:id="labelRatio" alignment="CENTER" styleClass="normalLabel" text="Ratio" GridPane.halignment="CENTER" GridPane.rowIndex="2"> <children>
<font> <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 size="13.0" /> <font>
</font> <Font size="13.0" />
</Label> </font>
<Label fx:id="labelTotalListeners" alignment="CENTER" styleClass="normalLabel" text="Total Listeners" GridPane.halignment="CENTER" GridPane.rowIndex="3"> </Label>
<font> </children>
<Font size="13.0" /> </AnchorPane>
</font> <AnchorPane GridPane.rowIndex="2">
</Label> <children>
<Label fx:id="labelTotalScrobbles" alignment="CENTER" styleClass="normalLabel" text="Total Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="4"> <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>
</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 size="13.0" />
</font>
</Label>
</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 size="13.0" />
</font>
</Label>
</children>
</AnchorPane>
</children> </children>
</GridPane> </GridPane>
</children> </children>

View File

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

View File

@ -21,6 +21,7 @@
<Menu fx:id="menuUtil" mnemonicParsing="false" text="util"> <Menu fx:id="menuUtil" mnemonicParsing="false" text="util">
<items> <items>
<MenuItem fx:id="menuItemScrobble" mnemonicParsing="false" onAction="#handleScrobble" text="scrobble" /> <MenuItem fx:id="menuItemScrobble" mnemonicParsing="false" onAction="#handleScrobble" text="scrobble" />
<MenuItem fx:id="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>
@ -48,60 +49,51 @@
<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>
<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"> <BorderPane prefHeight="354.0" prefWidth="211.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items> <center>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" /> <Accordion fx:id="accordionCharts" prefHeight="325.0" prefWidth="222.0" BorderPane.alignment="CENTER">
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0"> <panes>
<children> <TitledPane fx:id="titledPaneGenres" animated="false" text="genres">
<BorderPane prefHeight="354.0" prefWidth="211.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <content>
<center> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<Accordion fx:id="accordionCharts" prefHeight="325.0" prefWidth="222.0" BorderPane.alignment="CENTER"> <children>
<panes> <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" />
<TitledPane fx:id="titledPaneGenres" animated="false" text="genres"> </children>
<content> </AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"> </content>
<children> </TitledPane>
<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" /> <TitledPane fx:id="titledPaneRap" animated="false" text="rap">
</children> <content>
</AnchorPane> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
</content> <children>
</TitledPane> <GridPane prefHeight="303.0" prefWidth="209.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<TitledPane fx:id="titledPaneRap" animated="false" text="rap"> <columnConstraints>
<content> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"> </columnConstraints>
<children> <rowConstraints>
<GridPane prefHeight="303.0" prefWidth="209.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<columnConstraints> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> </rowConstraints>
</columnConstraints> <children>
<rowConstraints> <PieChart fx:id="pieChartRapTotal" prefHeight="274.0" prefWidth="220.0" styleClass="pieChart" stylesheets="@../styles/mainPane.css" title="total" GridPane.rowIndex="1" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <PieChart fx:id="pieChartRap" styleClass="pieChart" stylesheets="@../styles/mainPane.css" title="rap" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> </children>
</rowConstraints> </GridPane>
<children> </children>
<PieChart fx:id="pieChartRapTotal" prefHeight="274.0" prefWidth="220.0" styleClass="pieChart" stylesheets="@../styles/mainPane.css" title="total" GridPane.rowIndex="1" /> </AnchorPane>
<PieChart fx:id="pieChartRap" styleClass="pieChart" stylesheets="@../styles/mainPane.css" title="rap" /> </content>
</children> </TitledPane>
</GridPane> </panes>
</children> </Accordion>
</AnchorPane> </center>
</content> <bottom>
</TitledPane> <ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
</panes> <items>
</Accordion> <Button fx:id="buttonPieChartRefresh" mnemonicParsing="false" onAction="#handleRefreshPieChart" text="refresh" />
</center> </items>
<bottom> </ToolBar>
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER"> </bottom>
<items> </BorderPane>
<Button fx:id="buttonPieChartRefresh" mnemonicParsing="false" onAction="#handleRefreshPieChart" text="refresh" />
</items>
</ToolBar>
</bottom>
</BorderPane>
</children>
</AnchorPane>
</items>
</SplitPane>
</children> </children>
</AnchorPane> </AnchorPane>
</content> </content>

View File

@ -87,7 +87,7 @@ public class Album extends FMObj {
} }
public String toString() { public String toString() {
return name + " - " + artist.getName(); return "Album: " + name + " - " + artist.getName();
} }

View File

@ -78,7 +78,7 @@ public class Artist extends FMObj {
} }
public String toString() { public String toString() {
return name; return "Artist: " + name;
} }
@Override @Override

View File

@ -40,7 +40,7 @@ public class Tag implements Comparable<Tag>{
} }
public String toString() { public String toString() {
return name; return "Tag: " + name;
} }
@Override @Override

View File

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

View File

@ -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,36 +69,35 @@ 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;
NodeList mbidNodeList = doc.getElementsByTagName("mbid"); NodeList mbidNodeList = doc.getElementsByTagName("mbid");
if (mbidNodeList.item(0) != null) { if (mbidNodeList.item(0) != null) {
mbid = doc.getElementsByTagName("mbid").item(0).getTextContent(); mbid = doc.getElementsByTagName("mbid").item(0).getTextContent();
@ -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();
@ -267,7 +281,10 @@ public class Parser {
Album album = Album.getAlbum(albumName, artistName, Reference.getUserName()); Album album = Album.getAlbum(albumName, artistName, Reference.getUserName());
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");
@ -297,6 +317,9 @@ public class Parser {
// System.out.println(obj.getTextContent()); // System.out.println(obj.getTextContent());
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");
@ -328,6 +354,9 @@ public class Parser {
// System.out.println(name + "."); // System.out.println(name + ".");
// 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");
@ -366,7 +398,10 @@ public class Parser {
// System.out.println(counter); // System.out.println(counter);
// 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;

View File

@ -15,7 +15,9 @@ 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);
Document doc = Network.getResponse(url); Document doc = Network.getResponse(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) {

View File

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