mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-20 01:26:52 -04:00
Added Graph to statistics window
This commit is contained in:
committed by
Sebastian Stenzel
parent
f61e955945
commit
05154cf6aa
@@ -1,5 +1,12 @@
|
||||
package org.cryptomator.ui.vaultstatistics;
|
||||
|
||||
import javafx.beans.property.LongProperty;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.ReadOnlyObjectProperty;
|
||||
import javafx.beans.property.SimpleLongProperty;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.chart.LineChart;
|
||||
import javafx.scene.chart.XYChart;
|
||||
import javafx.stage.Stage;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
@@ -10,11 +17,55 @@ import javax.inject.Inject;
|
||||
public class VaultStatisticsController implements FxController {
|
||||
|
||||
private final Stage window;
|
||||
private final Vault vault;
|
||||
private final ReadOnlyObjectProperty<Vault> vault;
|
||||
@FXML
|
||||
private LineChart<Double, Double> lineGraph;
|
||||
private final LongProperty currentReadData;
|
||||
private final LongProperty currentWriteData;
|
||||
private final XYChart.Series<Double, Double> readData;
|
||||
private final XYChart.Series<Double, Double> writeData;
|
||||
private long timeAtStartOfTracking;
|
||||
|
||||
@Inject
|
||||
public VaultStatisticsController(@VaultStatisticsWindow Stage window, @VaultStatisticsWindow Vault vault) {
|
||||
public VaultStatisticsController(@VaultStatisticsWindow Stage window, ObjectProperty<Vault> vault) {
|
||||
this.window = window;
|
||||
this.vault = vault;
|
||||
|
||||
readData = new XYChart.Series<>();
|
||||
readData.setName("Read Data"); // For Legend
|
||||
//TODO Add Name to strings.properties
|
||||
writeData = new XYChart.Series<>();
|
||||
writeData.setName("Write Data");
|
||||
//TODO Add Name to strings.properties
|
||||
|
||||
|
||||
currentReadData = new SimpleLongProperty();
|
||||
currentReadData.bind(getVault().getStats().bytesPerSecondReadProperty());
|
||||
currentReadData.addListener((observable, oldValue, newValue) -> updateReadWriteData());
|
||||
|
||||
currentWriteData = new SimpleLongProperty();
|
||||
currentWriteData.bind(getVault().getStats().bytesPerSecondWrittenProperty());
|
||||
currentWriteData.addListener((observable, oldValue, newValue) -> updateReadWriteData());
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
window.setTitle(window.getTitle() + " - " + vault.get().getDisplayableName());
|
||||
}
|
||||
|
||||
public Vault getVault() {
|
||||
return vault.get();
|
||||
}
|
||||
|
||||
private void updateReadWriteData() {
|
||||
//So the graphs start at x = 0
|
||||
if (timeAtStartOfTracking == 0) {
|
||||
timeAtStartOfTracking = System.currentTimeMillis();
|
||||
}
|
||||
readData.getData().add(new XYChart.Data<Double, Double>((System.currentTimeMillis() - timeAtStartOfTracking) / 1000.0, ((getVault().getStats().bytesPerSecondReadProperty().get()) / 1024.0)));
|
||||
writeData.getData().add(new XYChart.Data<Double, Double>((System.currentTimeMillis() - timeAtStartOfTracking) / 1000.0, ((getVault().getStats().bytesPerSecondWrittenProperty().get()) / 1024.0)));
|
||||
lineGraph.getData().addAll(writeData, readData);
|
||||
//TODO
|
||||
//Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Duplicate series added
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ abstract class VaultStatisticsModule {
|
||||
@VaultStatisticsScoped
|
||||
static Stage provideStage(StageFactory factory, @MainWindow Stage owner, ResourceBundle resourceBundle) {
|
||||
Stage stage = factory.create();
|
||||
stage.setTitle(resourceBundle.getString("removeVault.title"));
|
||||
stage.setTitle(resourceBundle.getString("vaultstatistics.title"));
|
||||
stage.setResizable(false);
|
||||
stage.initModality(Modality.APPLICATION_MODAL);
|
||||
stage.initModality(Modality.NONE);
|
||||
stage.initOwner(owner);
|
||||
return stage;
|
||||
}
|
||||
|
||||
@@ -868,3 +868,37 @@
|
||||
-fx-background-color: PROGRESS_BAR_BG;
|
||||
-fx-background-radius: 4px;
|
||||
}
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Vault Statistics *
|
||||
* *
|
||||
******************************************************************************/
|
||||
.chart-plot-background {
|
||||
-fx-background-color: #F7F7F7;
|
||||
}
|
||||
.chart-vertical-grid-lines {
|
||||
-fx-stroke: #49B04A;
|
||||
}
|
||||
.chart-horizontal-grid-lines {
|
||||
-fx-stroke: #49B04A;
|
||||
}
|
||||
.chart-alternative-row-fill {
|
||||
-fx-fill: #E1E1E1;
|
||||
-fx-stroke: transparent;
|
||||
-fx-stroke-width: 0;
|
||||
}
|
||||
.default-color0.chart-series-line { -fx-stroke: #2D4D2E; }
|
||||
.default-color1.chart-series-line { -fx-stroke: #66CC68 ; }
|
||||
|
||||
.chart-legend {
|
||||
-fx-background-color: transparent;
|
||||
-fx-padding: 20px;
|
||||
}
|
||||
|
||||
.chart-legend-item-symbol{
|
||||
-fx-background-radius: 0;
|
||||
}
|
||||
|
||||
.chart-legend-item{
|
||||
-fx-text-fill: #191970;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.chart.LineChart?>
|
||||
<?import javafx.scene.chart.NumberAxis?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.Cursor?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import org.cryptomator.ui.controls.ThrougputLabel?>
|
||||
@@ -20,4 +23,19 @@
|
||||
<ThrougputLabel styleClass="label-small,label-muted" alignment="CENTER_RIGHT" minWidth="60" idleFormat="%main.vaultDetail.throughput.idle" kibsFormat="%main.vaultDetail.throughput.kbps"
|
||||
mibsFormat="%main.vaultDetail.throughput.mbps" bytesPerSecond="${controller.vault.stats.bytesPerSecondWritten}"/>
|
||||
</HBox>
|
||||
|
||||
<LineChart
|
||||
styleClass="chart-plot-background, chart-vertical-grid-lines, chart-horizontal-grid-lines, chart-alternative-row-fill, default-color0.chart-series-line, default-color1.chart-series-line, default-color2.chart-series-line, chart-legend, chart-legend-item-symbol, chart-legend-item"
|
||||
fx:id="lineGraph" createSymbols="true" legendVisible="true" prefHeight="372.0" prefWidth="423.0" visible="true" animated="false" horizontalGridLinesVisible="true" verticalGridLinesVisible="true"
|
||||
title="%vaultstatistics.throughputTitle">
|
||||
<xAxis>
|
||||
<NumberAxis autoRanging="true" lowerBound="0" side="BOTTOM" tickUnit="1" upperBound="10" label="%vaultstatistics.xAxisTimeLabel"/>
|
||||
</xAxis>
|
||||
<yAxis>
|
||||
<NumberAxis autoRanging="true" lowerBound="0" side="LEFT" tickUnit="1024" upperBound="100" label="%vaultstatistics.yAxisTimeLabel"/>
|
||||
</yAxis>
|
||||
<cursor>
|
||||
<Cursor fx:constant="DEFAULT"/>
|
||||
</cursor>
|
||||
</LineChart>
|
||||
</VBox>
|
||||
|
||||
@@ -160,6 +160,12 @@ preferences.donationKey.getDonationKey=Get a donation key
|
||||
## About
|
||||
preferences.about=About
|
||||
|
||||
# Vault Statistics
|
||||
vaultstatistics.title=Vault Statistics
|
||||
vaultstatistics.xAxisTimeLabel=Seconds
|
||||
vaultstatistics.yAxisTimeLabel=Throughput in KiB
|
||||
vaultstatistics.throughputTitle=Read and Writes
|
||||
|
||||
# Main Window
|
||||
main.closeBtn.tooltip=Close
|
||||
main.minimizeBtn.tooltip=Minimize
|
||||
|
||||
Reference in New Issue
Block a user