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,76 +43,64 @@ import javafx.scene.layout.*;
import javafx.concurrent.*;
import javafx.application.Platform;
import javafx.scene.paint.Color;
public class ControllerMain {
@FXML
private Label labelStatsScrobblesToday;
@FXML
private Label labelStatsUsername;
@FXML
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()));
public void initialize() {
Reference.setUserName("sarsoo");
refresh();
}
TrackTab tab = new TrackTab(Getter.getLastTrack());
public void refresh() {
final CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(new Runnable() {
@Override
public void run() {
try {
Service<Void> service = new Service<Void>() {
@Override
protected Task<Void> createTask() {
return new Task<Void>() {
@Override
protected Void call() throws Exception {
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
labelStatsScrobblesToday.setText(scrobblesToday);
labelStatsUsername.setText(Reference.getUserName());
labelStatsScrobblesTotal.setText(scrobbles);
String scrobblesToday = numberFormat.format(Getter.getScrobblesToday(Reference.getUserName()));
String scrobbles = numberFormat.format(Getter.getScrobbles(Reference.getUserName()));
addTab(tab);
TrackTab tab = new TrackTab(Getter.getLastTrack());
refreshPieCharts();
updateTagMenu();
final CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(new Runnable() {
@Override
public void run() {
try {
} finally {
latch.countDown();
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();
});
latch.await();
// Keep with the background work
return null;
}
};
}
};
service.start();
}
}
private ArrayList<Tag> tags;
public void updateTagMenu() {
public void refreshTagMenu() {
tags = Getter.getUserTags(Reference.getUserName());
Collections.sort(tags);
@ -122,7 +110,6 @@ public class ControllerMain {
String name = tags.get(counter).getName().toLowerCase();
// System.out.println(name);
MenuItem item = new MenuItem(name);
@ -139,8 +126,8 @@ public class ControllerMain {
@Override
protected Void call() throws Exception {
FMObjListTab tab = new FMObjListTab(Getter
.getUserTag(Reference.getUserName(), name));
FMObjListTab tab = new FMObjListTab(
Getter.getUserTag(Reference.getUserName(), name));
final CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(new Runnable() {
@ -168,18 +155,145 @@ public class ControllerMain {
}
}
public void updateGenrePieChart() {
String[] names = { "rock", "rap", "classic rock", "pop punk", "electronic", "metal", "grime", "classic rap",
"indie", "jazz", "blues", "core" };
public void refreshPieCharts() {
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));
pieChartGenres = new PieChart(pieChartData);
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");
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
protected void handleLookupAlbum(ActionEvent event) throws IOException {
Service<Void> service = new Service<Void>() {
@ -217,6 +331,7 @@ public class ControllerMain {
}
@FXML
protected void handleLookupArtist(ActionEvent event) throws IOException {
Service<Void> service = new Service<Void>() {
@ -251,10 +366,9 @@ public class ControllerMain {
}
};
service.start();
// tabPane.getTabs().add(new ArtistTab(Getter.getArtist()));
}
@FXML
protected void handleLookupTrack(ActionEvent event) throws IOException {
@ -292,6 +406,66 @@ public class ControllerMain {
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();
@ -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
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
private PieChart pieChartRap;
@ -465,146 +511,6 @@ public class ControllerMain {
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
protected void handleCreateList(ActionEvent event) {
try {
Tab tab = new FMObjListTab();
addTab(tab);
} catch (IOException e) {
e.printStackTrace();
}
}
private StackPane stackViewGenres;
}

View File

@ -28,36 +28,60 @@
<RowConstraints maxHeight="37.0" minHeight="10.0" prefHeight="35.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label fx:id="labelAlbumName" alignment="CENTER" styleClass="titleLabel" text="Album Name" wrapText="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
<font>
<Font name="System Bold" size="18.0" />
</font>
</Label>
<Label fx:id="labelArtistName" alignment="CENTER" styleClass="subLabel" text="Artist Name" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
<font>
<Font size="13.0" />
</font>
</Label>
<Label fx:id="labelUserScrobbles" alignment="CENTER" styleClass="normalLabel" text="User Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER">
<font>
<Font size="13.0" />
</font>
</Label>
<Label fx:id="labelRatio" alignment="CENTER" styleClass="normalLabel" text="Ratio" GridPane.halignment="CENTER" GridPane.rowIndex="3">
<font>
<Font size="13.0" />
</font>
</Label>
<Label fx:id="labelTotalListeners" alignment="CENTER" styleClass="normalLabel" text="Total Listeners" GridPane.halignment="CENTER" GridPane.rowIndex="4">
<font>
<Font size="13.0" />
</font>
</Label>
<Label fx:id="labelTotalScrobbles" alignment="CENTER" styleClass="normalLabel" text="Total Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="5">
<font>
<Font size="13.0" />
</font>
</Label>
<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 name="System Bold" size="18.0" />
</font>
</Label>
</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 size="13.0" />
</font>
</Label>
</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 size="13.0" />
</font>
</Label>
</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 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>
</GridPane>
</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">
<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>
<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>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
@ -20,38 +20,58 @@
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="115.0" minHeight="10.0" prefHeight="94.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="49.0" minHeight="10.0" prefHeight="33.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="213.0" minHeight="10.0" prefHeight="213.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="39.0" minHeight="10.0" prefHeight="34.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="37.0" minHeight="10.0" prefHeight="35.0" vgrow="SOMETIMES" />
</rowConstraints>
<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">
<font>
<Font name="System Bold" size="18.0" />
</font>
</Label>
<Label fx:id="labelUserScrobbles" alignment="CENTER" styleClass="normalLabel" text="User Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
<font>
<Font size="13.0" />
</font>
</Label>
<Label fx:id="labelRatio" alignment="CENTER" styleClass="normalLabel" text="Ratio" GridPane.halignment="CENTER" GridPane.rowIndex="2">
<font>
<Font size="13.0" />
</font>
</Label>
<Label fx:id="labelTotalListeners" alignment="CENTER" styleClass="normalLabel" text="Total Listeners" GridPane.halignment="CENTER" GridPane.rowIndex="3">
<font>
<Font size="13.0" />
</font>
</Label>
<Label fx:id="labelTotalScrobbles" alignment="CENTER" styleClass="normalLabel" text="Total Scrobbles" GridPane.halignment="CENTER" GridPane.rowIndex="4">
<font>
<Font size="13.0" />
</font>
</Label>
<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 name="System Bold" size="18.0" />
</font>
</Label>
</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 size="13.0" />
</font>
</Label>
</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 size="13.0" />
</font>
</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>
</GridPane>
</children>

View File

@ -29,7 +29,7 @@
<RowConstraints maxHeight="37.0" minHeight="10.0" prefHeight="35.0" vgrow="SOMETIMES" />
</rowConstraints>
<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 name="System Bold" size="18.0" />
</font>

View File

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

View File

@ -87,7 +87,7 @@ public class Album extends FMObj {
}
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() {
return name;
return "Artist: " + name;
}
@Override

View File

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

View File

@ -91,7 +91,9 @@ public class Track extends FMObj {
}
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 static Album parseAlbum(Document doc) {
if(Reference.isVerbose())
System.out.println("-parseAlbum");
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
String name = doc.getElementsByTagName("name").item(0).getTextContent();
String artist = doc.getElementsByTagName("artist").item(0).getTextContent();
@ -58,7 +61,6 @@ public class Parser {
NodeList wikiContents = wikiNode.getChildNodes();
String date = null;
// String summary = null;
String content = null;
int counter;
@ -67,32 +69,31 @@ public class Parser {
node = wikiContents.item(counter);
if (node.getNodeName().equals("published")) {
// System.out.println(node.getNodeName() + 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")) {
// System.out.println(node.getNodeName() + node.getTextContent());
content = node.getTextContent();
}
}
if (date != null && content != null)
// System.out.println("wiki init");
wiki = new Wiki(date, null, content);
}
Album album = new Album(name, url, mbid, artistObj, listeners, playCount, userPlayCount, wiki);
if(Reference.isVerbose())
System.out.println(album);
return album;
}
return null;
}
public static Artist parseArtist(Document doc) {
if(Reference.isVerbose())
System.out.println("-parseArtist");
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
String name = doc.getElementsByTagName("name").item(0).getTextContent();
String mbid = null;
@ -167,12 +168,19 @@ public class Parser {
}
Artist artist = new Artist(name, url, mbid, listeners, playCount, userPlayCount, wiki);
if(Reference.isVerbose())
System.out.println(artist);
return artist;
}
return null;
}
public static Track parseTrack(Document doc) {
if(Reference.isVerbose())
System.out.println("-parseTrack");
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
String name = " ";
try {
@ -246,6 +254,10 @@ public class Parser {
}
Track track = new Track(name, url, mbid, artistObj, listeners, playCount, userPlayCount, wiki);
if(Reference.isVerbose())
System.out.println(track);
return track;
} else {
return null;
@ -254,6 +266,8 @@ public class Parser {
}
public static Track parseLastTrack(Document doc) {
if(Reference.isVerbose())
System.out.println("-parseLastTrack");
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
String name = doc.getElementsByTagName("name").item(0).getTextContent();
@ -268,6 +282,9 @@ public class Parser {
track.setAlbum(album);
if(Reference.isVerbose())
System.out.println(track);
return track;
}
@ -276,6 +293,9 @@ public class Parser {
}
public static ArrayList<Tag> parseUserTags(Document doc) {
if(Reference.isVerbose())
System.out.println("-parseUserTags");
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
NodeList objList = doc.getElementsByTagName("tag");
@ -298,6 +318,9 @@ public class Parser {
Tag tag = new Tag(name, url);
if(Reference.isVerbose())
System.out.println(tag);
// System.out.println(name + " " + url);
list.add(tag);
}
@ -308,6 +331,9 @@ public class Parser {
}
public static FMObjList parseUserTagList(Document doc) {
if(Reference.isVerbose())
System.out.println("-parseUserTagList");
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
NodeList objList = doc.getElementsByTagName("artist");
@ -329,6 +355,9 @@ public class Parser {
// System.out.println(obj.getTextContent());
Artist artist = Artist.getArtist(name, Reference.getUserName());
if(Reference.isVerbose())
System.out.println(artist);
// System.out.println(artist);
list.add(artist);
}
@ -339,6 +368,9 @@ public class Parser {
}
public static FMObjList parseArtistTracks(Document doc) {
if(Reference.isVerbose())
System.out.println("-parseArtistTracks");
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
NodeList objList = doc.getElementsByTagName("track");
@ -367,6 +399,9 @@ public class Parser {
// System.out.println(artist);
Track track = Track.getTrack(name, artist, Reference.getUserName());
if(Reference.isVerbose())
System.out.println(track);
list.add(track);
}
return list;

View File

@ -15,6 +15,8 @@ import sarsoo.fmframework.parser.Parser;
public class Getter {
public static Track getLastTrack() {
if(Reference.isVerbose())
System.out.println("--getLastTrack");
String url = URLBuilder.getLastTrackUrl(Reference.getUserName());
// TestCall.test(url);
@ -25,6 +27,8 @@ public class Getter {
// System.out.println(doc.getDocumentElement().getAttribute("status"));
Parser.stripSpace(doc.getDocumentElement());
Track track = Parser.parseLastTrack(doc);
if(Reference.isVerbose())
System.out.println(track);
// return null;
return track;
}
@ -33,17 +37,25 @@ public class Getter {
}
public static int getScrobbles(String username) {
if(Reference.isVerbose())
System.out.println("--getScrobbles");
String url = URLBuilder.getUserInfoUrl(username);
Document doc = Network.getResponse(url);
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
String scrobbles = doc.getElementsByTagName("playcount").item(0).getTextContent();
if (scrobbles != null)
if(Reference.isVerbose())
System.out.println(scrobbles);
return Integer.parseInt(scrobbles);
}
return 0;
}
public static int getScrobblesToday(String username) {
if(Reference.isVerbose())
System.out.println("--getScrobblesToday");
String url = URLBuilder.getTodayScrobbles(username);
Document doc = Network.getResponse(url);
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
@ -51,23 +63,32 @@ public class Getter {
NamedNodeMap var = node.getAttributes();
// System.out.println(var.getNamedItem("total").getNodeValue());
// if (scrobbles != null)
if(Reference.isVerbose())
System.out.println(var.getNamedItem("total").getNodeValue());
return Integer.parseInt(var.getNamedItem("total").getNodeValue());
}
return 0;
}
public static FMObjList getUserTag(String username, String tag) {
if(Reference.isVerbose())
System.out.println("--getUserTag");
String url = URLBuilder.getUserPersonalTags(username, tag);
Document doc = Network.getResponse(url);
if (doc != null) {
int pages = Integer.valueOf(
doc.getFirstChild().getFirstChild().getAttributes().getNamedItem("totalPages").getNodeValue());
if(Reference.isVerbose())
System.out.println("pages: " + pages);
FMObjList list = Parser.parseUserTagList(doc);
list.setGroupName(tag);
// System.out.println(pages);
if(Reference.isVerbose())
System.out.println("name: " + tag);
if (pages > 1) {
int counter;
for (counter = 2; counter <= pages; counter++) {
@ -80,6 +101,7 @@ public class Getter {
}
}
}
return list;
}
@ -104,6 +126,9 @@ public class Getter {
// return list;
// }
if(Reference.isVerbose())
System.out.println("--getArtistTracks");
FMObjList totalList = new FMObjList();
FMObjList list = new FMObjList();
@ -125,6 +150,9 @@ public class Getter {
}
public static ArrayList<Tag> getUserTags(String username) {
if(Reference.isVerbose())
System.out.println("--getUserTags");
String url = URLBuilder.getUserTopTags(username);
Document doc = Network.getResponse(url);
if (doc != null) {

View File

@ -7,6 +7,7 @@ import sarsoo.fmframework.music.Artist;
public class Reference {
private static String userName;
private static boolean isVerbose = true;
private static boolean isHeadless = true;
public static String getUserName() {
@ -17,7 +18,7 @@ public class Reference {
userName = userNameIn;
}
public static boolean getIsHeadless() {
public static boolean isHeadless() {
return isHeadless;
}
@ -136,4 +137,12 @@ public class Reference {
return emoTrio;
}
public static boolean isVerbose() {
return isVerbose;
}
public static void setVerbose(boolean isVerbose) {
Reference.isVerbose = isVerbose;
}
}