added cumulative check box

This commit is contained in:
aj 2019-05-23 11:21:54 +01:00
parent c35be3b731
commit 4ff50048e0
3 changed files with 33 additions and 19 deletions

View File

@ -13,6 +13,7 @@ import javafx.scene.chart.AreaChart;
import javafx.scene.chart.XYChart; import javafx.scene.chart.XYChart;
import javafx.scene.chart.XYChart.Data; import javafx.scene.chart.XYChart.Data;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.SplitPane; import javafx.scene.control.SplitPane;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
@ -35,23 +36,26 @@ public class ScrobblesViewPaneController {
@FXML @FXML
private AreaChart<String, Integer> areaChart; private AreaChart<String, Integer> areaChart;
@FXML @FXML
private Button buttonTracks; private Button buttonTracks;
@FXML @FXML
private Button buttonAlbums; private Button buttonAlbums;
@FXML @FXML
private Button buttonTracksAlbums; private Button buttonTracksAlbums;
@FXML
private CheckBox checkBoxCumulative;
private FMObj obj; private FMObj obj;
private LocalDate firstDate; private LocalDate firstDate;
@FXML @FXML
public void initialize() { public void initialize() {
buttonTracks.setDisable(true); buttonTracks.setDisable(true);
buttonAlbums.setDisable(true); buttonAlbums.setDisable(true);
buttonTracksAlbums.setDisable(true); buttonTracksAlbums.setDisable(true);
@ -148,7 +152,7 @@ public class ScrobblesViewPaneController {
refreshGraph(toShow); refreshGraph(toShow);
} }
public void graphShowAlbums() { public void graphShowAlbums() {
ArrayList<FMObjCalendarWrapper> list = new ArrayList<>(); ArrayList<FMObjCalendarWrapper> list = new ArrayList<>();
@ -251,7 +255,12 @@ public class ScrobblesViewPaneController {
for (MonthScrobbles month : calendar.getMonthScrobbles()) { for (MonthScrobbles month : calendar.getMonthScrobbles()) {
cumulative += month.getCount(); cumulative += month.getCount();
series.getData().add(new Data<String, Integer>(month.toString(), cumulative));
if (checkBoxCumulative.isSelected()) {
series.getData().add(new Data<String, Integer>(month.toString(), cumulative));
}else {
series.getData().add(new Data<String, Integer>(month.toString(), month.getCount()));
}
} }
areaChart.getData().add(series); areaChart.getData().add(series);
@ -259,37 +268,37 @@ public class ScrobblesViewPaneController {
} }
} }
@FXML @FXML
private void handleShowTracks() { private void handleShowTracks() {
buttonTracks.setDisable(true); buttonTracks.setDisable(true);
buttonAlbums.setDisable(false); buttonAlbums.setDisable(false);
buttonTracksAlbums.setDisable(false); buttonTracksAlbums.setDisable(false);
graphShowTracks(); graphShowTracks();
} }
@FXML @FXML
private void handleShowAlbums() { private void handleShowAlbums() {
buttonTracks.setDisable(false); buttonTracks.setDisable(false);
buttonAlbums.setDisable(true); buttonAlbums.setDisable(true);
buttonTracksAlbums.setDisable(false); buttonTracksAlbums.setDisable(false);
graphShowAlbums(); graphShowAlbums();
} }
@FXML @FXML
private void handleShowTracksByAlbums() { private void handleShowTracksByAlbums() {
buttonTracks.setDisable(false); buttonTracks.setDisable(false);
buttonAlbums.setDisable(false); buttonAlbums.setDisable(false);
buttonTracksAlbums.setDisable(true); buttonTracksAlbums.setDisable(true);
graphShowTracksByAlbum(); graphShowTracksByAlbum();
} }
} }

View File

@ -105,6 +105,10 @@
-fx-background-color: #4D4D4D; -fx-background-color: #4D4D4D;
} }
.check-box {
-fx-text-fill: white;
}
.label { .label {
-fx-text-fill: white; -fx-text-fill: white;
} }

View File

@ -8,7 +8,7 @@
<?import javafx.scene.paint.*?> <?import javafx.scene.paint.*?>
<?import javafx.scene.text.*?> <?import javafx.scene.text.*?>
<AnchorPane prefHeight="386.0" prefWidth="512.0" stylesheets="@../styles/mainPane.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sarsoo.fmframework.fx.controller.ScrobblesViewPaneController"> <AnchorPane prefHeight="508.0" prefWidth="783.0" stylesheets="@../styles/mainPane.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sarsoo.fmframework.fx.controller.ScrobblesViewPaneController">
<children> <children>
<SplitPane fx:id="splitPane" dividerPositions="0.4909819639278557" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <SplitPane fx:id="splitPane" dividerPositions="0.4909819639278557" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items> <items>
@ -43,6 +43,7 @@
<Button fx:id="buttonTracks" mnemonicParsing="false" onAction="#handleShowTracks" text="tracks" /> <Button fx:id="buttonTracks" mnemonicParsing="false" onAction="#handleShowTracks" text="tracks" />
<Button fx:id="buttonAlbums" mnemonicParsing="false" onAction="#handleShowAlbums" text="albums" /> <Button fx:id="buttonAlbums" mnemonicParsing="false" onAction="#handleShowAlbums" text="albums" />
<Button fx:id="buttonTracksAlbums" mnemonicParsing="false" onAction="#handleShowTracksByAlbums" text="tracks &amp; albums" /> <Button fx:id="buttonTracksAlbums" mnemonicParsing="false" onAction="#handleShowTracksByAlbums" text="tracks &amp; albums" />
<CheckBox fx:id="checkBoxCumulative" mnemonicParsing="false" selected="true" text="cumulative" />
</items> </items>
</ToolBar> </ToolBar>
</bottom> </bottom>