From 1846c5c14ce84cd3926e418dc71e4c02cdb61b59 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Tue, 16 Jun 2020 15:05:24 +0200 Subject: [PATCH] formatting --- .../org/cryptomator/ui/controls/ThrougputLabel.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/controls/ThrougputLabel.java b/main/ui/src/main/java/org/cryptomator/ui/controls/ThrougputLabel.java index b07cf9b6f..a21e6d916 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controls/ThrougputLabel.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controls/ThrougputLabel.java @@ -10,8 +10,8 @@ import javafx.scene.control.Label; public class ThrougputLabel extends Label { - private static final long kibsThreshold = 1l << 7; // 0.128 kiB/s - private static final long mibsThreshold = 1l << 19; // 0.512 MiB/s + private static final long KIBS_THRESHOLD = 1l << 7; // 0.128 kiB/s + private static final long MIBS_THRESHOLD = 1l << 19; // 0.512 MiB/s private final StringProperty idleFormat = new SimpleStringProperty("-"); private final StringProperty kibsFormat = new SimpleStringProperty("%.3f"); @@ -22,18 +22,17 @@ public class ThrougputLabel extends Label { textProperty().bind(createStringBinding()); } - protected StringBinding createStringBinding() { return Bindings.createStringBinding(this::updateText, kibsFormat, mibsFormat, bytesPerSecond); } private String updateText() { long bps = bytesPerSecond.get(); - if (bps > mibsThreshold) { - double mibs = ((double) bytesPerSecond.get()) / 1024.0 / 1024.0; + if (bps > MIBS_THRESHOLD) { + double mibs = ((double) bps) / 1024.0 / 1024.0; return String.format(mibsFormat.get(), mibs); - } else if (bps > kibsThreshold) { - double kibs = ((double) bytesPerSecond.get()) / 1024.0; + } else if (bps > KIBS_THRESHOLD) { + double kibs = ((double) bps) / 1024.0; return String.format(kibsFormat.get(), kibs); } else { return String.format(idleFormat.get(), bps);