From 94960567b57f1a25ab77c6bd452cb062d3a017af Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 24 Nov 2020 10:05:27 +0200 Subject: [PATCH] default to mempool.space, improve mempool size tooltip display --- .../control/MempoolSizeFeeRatesChart.java | 22 ++++++++++--------- .../sparrow/net/ElectrumServer.java | 3 ++- .../com/sparrowwallet/sparrow/wallet/send.css | 15 ------------- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/MempoolSizeFeeRatesChart.java b/src/main/java/com/sparrowwallet/sparrow/control/MempoolSizeFeeRatesChart.java index 7c224b20..4e9ddd32 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/MempoolSizeFeeRatesChart.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/MempoolSizeFeeRatesChart.java @@ -6,6 +6,7 @@ import com.sparrowwallet.sparrow.wallet.SendController; import javafx.application.Platform; import javafx.beans.NamedArg; import javafx.collections.FXCollections; +import javafx.geometry.Point2D; import javafx.scene.Cursor; import javafx.scene.Node; import javafx.scene.chart.*; @@ -63,16 +64,8 @@ public class MempoolSizeFeeRatesChart extends StackedAreaChart { categoryAxis.setAutoRanging(false); categoryAxis.setCategories(FXCollections.observableArrayList(categories.values())); categoryAxis.invalidateRange(new ArrayList<>(categories.values())); - categoryAxis.setGapStartAndEnd(false); categoryAxis.setTickLabelRotation(0); - categoryAxis.setOnMouseMoved(mouseEvent -> { - String category = categoryAxis.getValueForDisplay(mouseEvent.getX()); - if(category != null) { - Optional time = categories.entrySet().stream().filter(entry -> entry.getValue().equals(category)).map(entry -> dateFormatter.format(entry.getKey())).findFirst(); - time.ifPresent(s -> tooltip.setGraphic(new ChartTooltip(category, s, getData()))); - } - }); NumberAxis numberAxis = (NumberAxis)getYAxis(); numberAxis.setTickLabelFormatter(new StringConverter() { @@ -88,6 +81,15 @@ public class MempoolSizeFeeRatesChart extends StackedAreaChart { } }); + this.setOnMouseMoved(mouseEvent -> { + Point2D sceneCoords = this.localToScene(mouseEvent.getX(), mouseEvent.getY()); + String category = categoryAxis.getValueForDisplay(categoryAxis.sceneToLocal(sceneCoords).getX()); + if(category != null) { + Optional time = categories.entrySet().stream().filter(entry -> entry.getValue().equals(category)).map(entry -> dateFormatter.format(entry.getKey())).findFirst(); + time.ifPresent(s -> tooltip.setGraphic(new ChartTooltip(category, s, getData()))); + } + }); + long previousFeeRate = 0; for(Long feeRate : SendController.FEE_RATES_RANGE) { XYChart.Series series = new XYChart.Series<>(); @@ -161,7 +163,7 @@ public class MempoolSizeFeeRatesChart extends StackedAreaChart { public ChartTooltip(String category, String time, List> seriesList) { Label title = new Label("At " + time); HBox titleBox = new HBox(title); - title.getStyleClass().add("tooltip-title"); + title.setStyle("-fx-alignment: center; -fx-font-size: 12px; -fx-padding: 0 0 5 0;"); getChildren().add(titleBox); for(int i = seriesList.size() - 1; i >= 0; i--) { @@ -172,7 +174,7 @@ public class MempoolSizeFeeRatesChart extends StackedAreaChart { if(mvb >= 0.01) { Label label = new Label(series.getName() + ": " + String.format("%.2f", mvb) + " MvB"); Glyph circle = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.CIRCLE); - circle.getStyleClass().add("tooltip-series" + i); + circle.setStyle("-fx-text-fill: CHART_COLOR_" + (i+1)); label.setGraphic(circle); getChildren().add(label); } diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java index 60fe8833..1f91a015 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java @@ -606,7 +606,8 @@ public class ElectrumServer { } FeeRatesSource feeRatesSource = Config.get().getFeeRatesSource(); - if(feeRatesSource != null && Network.get().equals(Network.MAINNET)) { + feeRatesSource = (feeRatesSource == null ? FeeRatesSource.MEMPOOL_SPACE : feeRatesSource); + if(Network.get().equals(Network.MAINNET)) { targetBlocksFeeRatesSats.putAll(feeRatesSource.getBlockTargetFeeRates(targetBlocksFeeRatesSats)); } diff --git a/src/main/resources/com/sparrowwallet/sparrow/wallet/send.css b/src/main/resources/com/sparrowwallet/sparrow/wallet/send.css index ce43389c..f65a1bac 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/wallet/send.css +++ b/src/main/resources/com/sparrowwallet/sparrow/wallet/send.css @@ -108,18 +108,3 @@ #transactionDiagram .utxo-label:hover .button .label .text { -fx-fill: -fx-text-base-color; } - -.tooltip-title { - -fx-alignment: center; - -fx-font-size: 12px; - -fx-padding: 0 0 5 0; -} - -.tooltip-series0 { -fx-text-fill: CHART_COLOR_1; } -.tooltip-series1 { -fx-text-fill: CHART_COLOR_2; } -.tooltip-series2 { -fx-text-fill: CHART_COLOR_3; } -.tooltip-series3 { -fx-text-fill: CHART_COLOR_4; } -.tooltip-series4 { -fx-text-fill: CHART_COLOR_5; } -.tooltip-series5 { -fx-text-fill: CHART_COLOR_6; } -.tooltip-series6 { -fx-text-fill: CHART_COLOR_7; } -.tooltip-series7 { -fx-text-fill: CHART_COLOR_8; } \ No newline at end of file