diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 1d134691339..fb06971842d 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2056,7 +2056,7 @@ dao.factsAndFigures.menuItem.transactions=BSQ Transactions dao.factsAndFigures.dashboard.marketPrice=Market data dao.factsAndFigures.dashboard.price=Latest BSQ/BTC trade price (in Bisq) dao.factsAndFigures.dashboard.avgPrice90=90 days average BSQ/BTC trade price -dao.factsAndFigures.dashboard.medianPrice90=90 days median BSQ/BTC trade price +dao.factsAndFigures.dashboard.avgPrice30=30 days average BSQ/BTC trade price dao.factsAndFigures.dashboard.marketCap=Market capitalisation (based on trade price) dao.factsAndFigures.dashboard.availableAmount=Total available BSQ diff --git a/desktop/src/main/java/bisq/desktop/bisq.css b/desktop/src/main/java/bisq/desktop/bisq.css index 53723ba3548..2ee2cd1ed15 100644 --- a/desktop/src/main/java/bisq/desktop/bisq.css +++ b/desktop/src/main/java/bisq/desktop/bisq.css @@ -1298,7 +1298,7 @@ textfield */ #address-text-field:hover { -fx-text-fill: -bs-text-color; } - + /* Account setup */ #wizard-item-background-deactivated { -fx-body-color: linear-gradient(to bottom, -bs-content-background-gray, -bs-color-gray-aaa); @@ -1990,6 +1990,16 @@ textfield */ -fx-fill: -bs-rd-green; } +.price-trend-up { + -fx-text-fill: -bs-color-primary; + -fx-padding: 2 0 0 0; +} + +.price-trend-down { + -fx-text-fill: -bs-red; + -fx-padding: 2 0 0 0; +} + /******************************************************************************************************************** * * * Notifications * diff --git a/desktop/src/main/java/bisq/desktop/components/TextFieldWithIcon.java b/desktop/src/main/java/bisq/desktop/components/TextFieldWithIcon.java index 2b98efd7747..97e237c831c 100644 --- a/desktop/src/main/java/bisq/desktop/components/TextFieldWithIcon.java +++ b/desktop/src/main/java/bisq/desktop/components/TextFieldWithIcon.java @@ -38,6 +38,7 @@ public class TextFieldWithIcon extends AnchorPane { public static final Logger log = LoggerFactory.getLogger(TextFieldWithIcon.class); @Getter private final Label iconLabel; + @Getter private final TextField textField; private final Label dummyTextField; diff --git a/desktop/src/main/java/bisq/desktop/main/dao/economy/dashboard/BsqDashboardView.java b/desktop/src/main/java/bisq/desktop/main/dao/economy/dashboard/BsqDashboardView.java index 34b21b7cffd..0f55bd8c5ce 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/economy/dashboard/BsqDashboardView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/economy/dashboard/BsqDashboardView.java @@ -19,6 +19,7 @@ import bisq.desktop.common.view.ActivatableView; import bisq.desktop.common.view.FxmlView; +import bisq.desktop.components.TextFieldWithIcon; import bisq.desktop.util.FormBuilder; import bisq.desktop.util.GUIUtil; @@ -36,13 +37,14 @@ import bisq.core.util.BsqFormatter; import bisq.common.util.MathUtils; -import bisq.common.util.Tuple2; import bisq.common.util.Tuple3; import org.bitcoinj.core.Coin; import javax.inject.Inject; +import de.jensd.fx.fontawesome.AwesomeIcon; + import javafx.scene.chart.AreaChart; import javafx.scene.chart.NumberAxis; import javafx.scene.chart.XYChart; @@ -57,6 +59,8 @@ import javafx.beans.value.ChangeListener; +import javafx.collections.ObservableList; + import javafx.util.StringConverter; import java.time.LocalDate; @@ -83,6 +87,7 @@ import static bisq.desktop.util.FormBuilder.addLabelWithSubText; import static bisq.desktop.util.FormBuilder.addTopLabelReadOnlyTextField; +import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithIcon; @FxmlView @@ -102,7 +107,8 @@ public class BsqDashboardView extends ActivatableView implements private AreaChart bsqPriceChart; private XYChart.Series seriesBSQPrice; - private TextField avgPrice90TextField, medianPrice90TextField, marketCapTextField, availableAmountTextField; + private TextField avgPrice90TextField, marketCapTextField, availableAmountTextField; + private TextFieldWithIcon avgPrice30TextField; private Label marketPriceLabel; private Coin availableAmount; @@ -136,13 +142,13 @@ public void initialize() { priceChangeListener = (observable, oldValue, newValue) -> { updatePrice(); - updateAverageAndMedianPrice(); + updateAveragePriceFields(); }; } private void createKPIs() { - Tuple3 marketPriceBox = addLabelWithSubText(root, gridRow++, "0.004000 BSQ/BTC", "Latest BSQ/BTC trade price (in Bisq)"); + Tuple3 marketPriceBox = addLabelWithSubText(root, gridRow++, "", ""); marketPriceLabel = marketPriceBox.first; marketPriceLabel.getStyleClass().add("dao-kpi-big"); @@ -151,15 +157,15 @@ private void createKPIs() { avgPrice90TextField = addTopLabelReadOnlyTextField(root, ++gridRow, Res.get("dao.factsAndFigures.dashboard.avgPrice90")).second; - medianPrice90TextField = addTopLabelReadOnlyTextField(root, gridRow, 1, - Res.get("dao.factsAndFigures.dashboard.medianPrice90")).second; + avgPrice30TextField = addTopLabelTextFieldWithIcon(root, gridRow, 1, + Res.get("dao.factsAndFigures.dashboard.avgPrice30"), -15).second; + AnchorPane.setRightAnchor(avgPrice30TextField.getIconLabel(), 10d); marketCapTextField = addTopLabelReadOnlyTextField(root, ++gridRow, Res.get("dao.factsAndFigures.dashboard.marketCap")).second; availableAmountTextField = FormBuilder.addTopLabelReadOnlyTextField(root, gridRow, 1, Res.get("dao.factsAndFigures.dashboard.availableAmount")).second; - } @@ -171,7 +177,7 @@ protected void activate() { updateWithBsqBlockChainData(); updatePrice(); updateChartData(); - updateAverageAndMedianPrice(); + updateAveragePriceFields(); } @@ -243,7 +249,7 @@ public Number fromString(String string) { bsqPriceChart.setLegendVisible(false); bsqPriceChart.setAnimated(false); bsqPriceChart.setId("charts-dao"); - bsqPriceChart.setMinHeight(335); + bsqPriceChart.setMinHeight(320); bsqPriceChart.setPrefHeight(bsqPriceChart.getMinHeight()); bsqPriceChart.setCreateSymbols(true); bsqPriceChart.setPadding(new Insets(0)); @@ -329,27 +335,45 @@ private void updatePrice() { } } - private void updateAverageAndMedianPrice() { - Date past90 = getPastDate(90); + private void updateAveragePriceFields() { + long average90 = updateAveragePriceField(avgPrice90TextField, 90); + long average30 = updateAveragePriceField(avgPrice30TextField.getTextField(), 30); + boolean trendUp = average30 > average90; + boolean trendDown = average30 < average90; + + Label iconLabel = avgPrice30TextField.getIconLabel(); + ObservableList styleClass = iconLabel.getStyleClass(); + if (trendUp) { + avgPrice30TextField.setVisible(true); + avgPrice30TextField.setIcon(AwesomeIcon.CIRCLE_ARROW_UP); + styleClass.remove("price-trend-down"); + styleClass.add("price-trend-up"); + } else if (trendDown) { + avgPrice30TextField.setVisible(true); + avgPrice30TextField.setIcon(AwesomeIcon.CIRCLE_ARROW_DOWN); + styleClass.remove("price-trend-up"); + styleClass.add("price-trend-down"); + } else { + iconLabel.setVisible(false); + } + } + + private long updateAveragePriceField(TextField textField, int days) { + Date past90 = getPastDate(days); List bsqTradePast90Days = tradeStatisticsManager.getObservableTradeStatisticsSet().stream() .filter(e -> e.getCurrencyCode().equals("BSQ")) .filter(e -> e.getTradeDate().after(past90)) .collect(Collectors.toList()); - Tuple2 averageAndMedian = getAverageAndMedian(bsqTradePast90Days); + long average = getAverage(bsqTradePast90Days); Coin oneBsq = Coin.valueOf(100); - - Price avgPrice = Price.valueOf("BSQ", averageAndMedian.first); + Price avgPrice = Price.valueOf("BSQ", average); String avg = bsqFormatter.formatPrice(avgPrice); - String bsqInUsdAvg = GUIUtil.getBsqInUsd(avgPrice, oneBsq, priceFeedService, bsqFormatter); - avgPrice90TextField.setText(avg + " BSQ/BTC (" + "1 BSQ = " + bsqInUsdAvg + ")"); - - Price medianPrice = Price.valueOf("BSQ", averageAndMedian.second); - String median = bsqFormatter.formatPrice(medianPrice); - String bsqInUsdMedian = GUIUtil.getBsqInUsd(medianPrice, oneBsq, priceFeedService, bsqFormatter); - medianPrice90TextField.setText(median + " BSQ/BTC (" + "1 BSQ = " + bsqInUsdMedian + ")"); + String bsqInUsdAvg = average > 0 ? GUIUtil.getBsqInUsd(avgPrice, oneBsq, priceFeedService, bsqFormatter) : Res.get("shared.na"); + textField.setText(avg + " BSQ/BTC (" + "1 BSQ = " + bsqInUsdAvg + ")"); + return average; } - private Tuple2 getAverageAndMedian(List list) { + private long getAverage(List list) { long accumulatedVolume = 0; long accumulatedAmount = 0; List tradePrices = new ArrayList<>(list.size()); @@ -366,11 +390,10 @@ private Tuple2 getAverageAndMedian(List list) { long averagePrice; Long[] prices = new Long[tradePrices.size()]; tradePrices.toArray(prices); - long medianPrice = MathUtils.getMedian(prices); double accumulatedAmountAsDouble = MathUtils.scaleUpByPowerOf10((double) accumulatedAmount, Altcoin.SMALLEST_UNIT_EXPONENT); - averagePrice = MathUtils.roundDoubleToLong(accumulatedAmountAsDouble / (double) accumulatedVolume); + averagePrice = accumulatedVolume > 0 ? MathUtils.roundDoubleToLong(accumulatedAmountAsDouble / (double) accumulatedVolume) : 0; - return new Tuple2<>(averagePrice, medianPrice); + return averagePrice; } private Date getPastDate(int days) { diff --git a/desktop/src/main/java/bisq/desktop/util/FormBuilder.java b/desktop/src/main/java/bisq/desktop/util/FormBuilder.java index eb986df318d..ab623d07e44 100644 --- a/desktop/src/main/java/bisq/desktop/util/FormBuilder.java +++ b/desktop/src/main/java/bisq/desktop/util/FormBuilder.java @@ -23,6 +23,7 @@ import bisq.desktop.components.AutoTooltipLabel; import bisq.desktop.components.AutoTooltipRadioButton; import bisq.desktop.components.AutoTooltipSlideToggleButton; +import bisq.desktop.components.AutocompleteComboBox; import bisq.desktop.components.BalanceTextField; import bisq.desktop.components.BisqTextArea; import bisq.desktop.components.BisqTextField; @@ -34,7 +35,6 @@ import bisq.desktop.components.InfoTextField; import bisq.desktop.components.InputTextField; import bisq.desktop.components.PasswordTextField; -import bisq.desktop.components.AutocompleteComboBox; import bisq.desktop.components.TextFieldWithCopyIcon; import bisq.desktop.components.TextFieldWithIcon; import bisq.desktop.components.TitledGroupBg; @@ -101,19 +101,32 @@ public static TitledGroupBg addTitledGroupBg(GridPane gridPane, int rowIndex, in return addTitledGroupBg(gridPane, rowIndex, rowSpan, title, 0); } - public static TitledGroupBg addTitledGroupBg(GridPane gridPane, int rowIndex, int columnIndex, int rowSpan, String title) { + public static TitledGroupBg addTitledGroupBg(GridPane gridPane, + int rowIndex, + int columnIndex, + int rowSpan, + String title) { TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, rowIndex, rowSpan, title, 0); GridPane.setColumnIndex(titledGroupBg, columnIndex); return titledGroupBg; } - public static TitledGroupBg addTitledGroupBg(GridPane gridPane, int rowIndex, int columnIndex, int rowSpan, String title, double top) { + public static TitledGroupBg addTitledGroupBg(GridPane gridPane, + int rowIndex, + int columnIndex, + int rowSpan, + String title, + double top) { TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, rowIndex, rowSpan, title, top); GridPane.setColumnIndex(titledGroupBg, columnIndex); return titledGroupBg; } - public static TitledGroupBg addTitledGroupBg(GridPane gridPane, int rowIndex, int rowSpan, String title, double top) { + public static TitledGroupBg addTitledGroupBg(GridPane gridPane, + int rowIndex, + int rowSpan, + String title, + double top) { TitledGroupBg titledGroupBg = new TitledGroupBg(); titledGroupBg.setText(title); titledGroupBg.prefWidthProperty().bind(gridPane.widthProperty()); @@ -145,11 +158,18 @@ public static Label addLabel(GridPane gridPane, int rowIndex, String title, doub // Label + Subtext /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple3 addLabelWithSubText(GridPane gridPane, int rowIndex, String title, String description) { + public static Tuple3 addLabelWithSubText(GridPane gridPane, + int rowIndex, + String title, + String description) { return addLabelWithSubText(gridPane, rowIndex, title, description, 0); } - public static Tuple3 addLabelWithSubText(GridPane gridPane, int rowIndex, String title, String description, double top) { + public static Tuple3 addLabelWithSubText(GridPane gridPane, + int rowIndex, + String title, + String description, + double top) { Label label = new AutoTooltipLabel(title); Label subText = new AutoTooltipLabel(description); @@ -200,37 +220,61 @@ public static Label addMultilineLabel(GridPane gridPane, int rowIndex, String te // Label + TextField /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple3 addTopLabelReadOnlyTextField(GridPane gridPane, int rowIndex, String title) { + public static Tuple3 addTopLabelReadOnlyTextField(GridPane gridPane, + int rowIndex, + String title) { return addTopLabelTextField(gridPane, rowIndex, title, "", -15); } - public static Tuple3 addTopLabelReadOnlyTextField(GridPane gridPane, int rowIndex, int columnIndex, String title) { + public static Tuple3 addTopLabelReadOnlyTextField(GridPane gridPane, + int rowIndex, + int columnIndex, + String title) { Tuple3 tuple = addTopLabelTextField(gridPane, rowIndex, title, "", -15); GridPane.setColumnIndex(tuple.third, columnIndex); return tuple; } - public static Tuple3 addTopLabelReadOnlyTextField(GridPane gridPane, int rowIndex, String title, double top) { + public static Tuple3 addTopLabelReadOnlyTextField(GridPane gridPane, + int rowIndex, + String title, + double top) { return addTopLabelTextField(gridPane, rowIndex, title, "", top - 15); } - public static Tuple3 addTopLabelReadOnlyTextField(GridPane gridPane, int rowIndex, String title, String value) { + public static Tuple3 addTopLabelReadOnlyTextField(GridPane gridPane, + int rowIndex, + String title, + String value) { return addTopLabelReadOnlyTextField(gridPane, rowIndex, title, value, 0); } - public static Tuple3 addTopLabelReadOnlyTextField(GridPane gridPane, int rowIndex, int columnIndex, String title, String value, double top) { + public static Tuple3 addTopLabelReadOnlyTextField(GridPane gridPane, + int rowIndex, + int columnIndex, + String title, + String value, + double top) { Tuple3 tuple = addTopLabelTextField(gridPane, rowIndex, title, value, top - 15); GridPane.setColumnIndex(tuple.third, columnIndex); return tuple; } - public static Tuple3 addTopLabelReadOnlyTextField(GridPane gridPane, int rowIndex, int columnIndex, String title, double top) { + public static Tuple3 addTopLabelReadOnlyTextField(GridPane gridPane, + int rowIndex, + int columnIndex, + String title, + double top) { Tuple3 tuple = addTopLabelTextField(gridPane, rowIndex, title, "", top - 15); GridPane.setColumnIndex(tuple.third, columnIndex); return tuple; } - public static Tuple3 addTopLabelReadOnlyTextField(GridPane gridPane, int rowIndex, String title, String value, double top) { + public static Tuple3 addTopLabelReadOnlyTextField(GridPane gridPane, + int rowIndex, + String title, + String value, + double top) { return addTopLabelTextField(gridPane, rowIndex, title, value, top - 15); } @@ -238,30 +282,50 @@ public static Tuple3 addTopLabelTextField(GridPane gridP return addTopLabelTextField(gridPane, rowIndex, title, "", 0); } - public static Tuple3 addCompactTopLabelTextField(GridPane gridPane, int rowIndex, String title, String value) { + public static Tuple3 addCompactTopLabelTextField(GridPane gridPane, + int rowIndex, + String title, + String value) { return addTopLabelTextField(gridPane, rowIndex, title, value, -Layout.FLOATING_LABEL_DISTANCE); } - public static Tuple3 addCompactTopLabelTextField(GridPane gridPane, int rowIndex, int colIndex, - String title, String value) { + public static Tuple3 addCompactTopLabelTextField(GridPane gridPane, + int rowIndex, + int colIndex, + String title, + String value) { final Tuple3 labelTextFieldVBoxTuple3 = addTopLabelTextField(gridPane, rowIndex, title, value, -Layout.FLOATING_LABEL_DISTANCE); GridPane.setColumnIndex(labelTextFieldVBoxTuple3.third, colIndex); return labelTextFieldVBoxTuple3; } - public static Tuple3 addCompactTopLabelTextField(GridPane gridPane, int rowIndex, String title, String value, double top) { + public static Tuple3 addCompactTopLabelTextField(GridPane gridPane, + int rowIndex, + String title, + String value, + double top) { return addTopLabelTextField(gridPane, rowIndex, title, value, top - Layout.FLOATING_LABEL_DISTANCE); } - public static Tuple3 addTopLabelTextField(GridPane gridPane, int rowIndex, String title, String value) { + public static Tuple3 addTopLabelTextField(GridPane gridPane, + int rowIndex, + String title, + String value) { return addTopLabelTextField(gridPane, rowIndex, title, value, 0); } - public static Tuple3 addTopLabelTextField(GridPane gridPane, int rowIndex, String title, double top) { + public static Tuple3 addTopLabelTextField(GridPane gridPane, + int rowIndex, + String title, + double top) { return addTopLabelTextField(gridPane, rowIndex, title, "", top); } - public static Tuple3 addTopLabelTextField(GridPane gridPane, int rowIndex, String title, String value, double top) { + public static Tuple3 addTopLabelTextField(GridPane gridPane, + int rowIndex, + String title, + String value, + double top) { TextField textField = new BisqTextField(value); textField.setEditable(false); textField.setFocusTraversable(false); @@ -278,11 +342,18 @@ public static Tuple3 addTopLabelTextField(GridPane gridP // Confirmation Fields /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple2 addConfirmationLabelLabel(GridPane gridPane, int rowIndex, String title1, String title2) { + public static Tuple2 addConfirmationLabelLabel(GridPane gridPane, + int rowIndex, + String title1, + String title2) { return addConfirmationLabelLabel(gridPane, rowIndex, title1, title2, 0); } - public static Tuple2 addConfirmationLabelLabel(GridPane gridPane, int rowIndex, String title1, String title2, double top) { + public static Tuple2 addConfirmationLabelLabel(GridPane gridPane, + int rowIndex, + String title1, + String title2, + double top) { Label label1 = addLabel(gridPane, rowIndex, title1); label1.getStyleClass().add("confirmation-label"); Label label2 = addLabel(gridPane, rowIndex, title2); @@ -295,7 +366,11 @@ public static Tuple2 addConfirmationLabelLabel(GridPane gridPane, return new Tuple2<>(label1, label2); } - public static Tuple2 addConfirmationLabelTextArea(GridPane gridPane, int rowIndex, String title1, String title2, double top) { + public static Tuple2 addConfirmationLabelTextArea(GridPane gridPane, + int rowIndex, + String title1, + String title2, + double top) { Label label = addLabel(gridPane, rowIndex, title1); label.getStyleClass().add("confirmation-label"); @@ -315,14 +390,24 @@ public static Tuple2 addConfirmationLabelTextArea(GridPane grid // Label + TextFieldWithIcon /////////////////////////////////////////////////////////////////////////////////////////// + public static Tuple2 addTopLabelTextFieldWithIcon(GridPane gridPane, + int rowIndex, + String title, + double top) { + return addTopLabelTextFieldWithIcon(gridPane, rowIndex, 0, title, top); + } - public static Tuple2 addTopLabelTextFieldWithIcon(GridPane gridPane, int rowIndex, String title, double top) { + public static Tuple2 addTopLabelTextFieldWithIcon(GridPane gridPane, + int rowIndex, + int columnIndex, + String title, + double top) { TextFieldWithIcon textFieldWithIcon = new TextFieldWithIcon(); textFieldWithIcon.setMouseTransparent(true); textFieldWithIcon.setFocusTraversable(false); - return new Tuple2<>(addTopLabelWithVBox(gridPane, rowIndex, title, textFieldWithIcon, top).first, textFieldWithIcon); + return new Tuple2<>(addTopLabelWithVBox(gridPane, rowIndex, columnIndex, title, textFieldWithIcon, top).first, textFieldWithIcon); } @@ -335,7 +420,11 @@ public static HyperlinkWithIcon addHyperlinkWithIcon(GridPane gridPane, int rowI return addHyperlinkWithIcon(gridPane, rowIndex, title, url, 0); } - public static HyperlinkWithIcon addHyperlinkWithIcon(GridPane gridPane, int rowIndex, String title, String url, double top) { + public static HyperlinkWithIcon addHyperlinkWithIcon(GridPane gridPane, + int rowIndex, + String title, + String url, + double top) { HyperlinkWithIcon hyperlinkWithIcon = new HyperlinkWithIcon(title, MaterialDesignIcon.LINK); hyperlinkWithIcon.setOnAction(e -> GUIUtil.openWebPage(url)); GridPane.setRowIndex(hyperlinkWithIcon, rowIndex); @@ -432,23 +521,41 @@ public static TextArea addTextArea(GridPane gridPane, int rowIndex, String promp // Label + TextArea /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple2 addCompactTopLabelTextArea(GridPane gridPane, int rowIndex, String title, String prompt) { + public static Tuple2 addCompactTopLabelTextArea(GridPane gridPane, + int rowIndex, + String title, + String prompt) { return addTopLabelTextArea(gridPane, rowIndex, title, prompt, -Layout.FLOATING_LABEL_DISTANCE); } - public static Tuple2 addCompactTopLabelTextArea(GridPane gridPane, int rowIndex, int colIndex, String title, String prompt) { + public static Tuple2 addCompactTopLabelTextArea(GridPane gridPane, + int rowIndex, + int colIndex, + String title, + String prompt) { return addTopLabelTextArea(gridPane, rowIndex, colIndex, title, prompt, -Layout.FLOATING_LABEL_DISTANCE); } - public static Tuple2 addTopLabelTextArea(GridPane gridPane, int rowIndex, String title, String prompt) { + public static Tuple2 addTopLabelTextArea(GridPane gridPane, + int rowIndex, + String title, + String prompt) { return addTopLabelTextArea(gridPane, rowIndex, title, prompt, 0); } - public static Tuple2 addTopLabelTextArea(GridPane gridPane, int rowIndex, int colIndex, String title, String prompt) { + public static Tuple2 addTopLabelTextArea(GridPane gridPane, + int rowIndex, + int colIndex, + String title, + String prompt) { return addTopLabelTextArea(gridPane, rowIndex, colIndex, title, prompt, 0); } - public static Tuple2 addTopLabelTextArea(GridPane gridPane, int rowIndex, String title, String prompt, double top) { + public static Tuple2 addTopLabelTextArea(GridPane gridPane, + int rowIndex, + String title, + String prompt, + double top) { return addTopLabelTextArea(gridPane, rowIndex, 0, title, prompt, top); } @@ -471,7 +578,10 @@ public static Tuple2 addTopLabelTextArea(GridPane gridPane, int // Label + DatePicker /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple2 addTopLabelDatePicker(GridPane gridPane, int rowIndex, String title, double top) { + public static Tuple2 addTopLabelDatePicker(GridPane gridPane, + int rowIndex, + String title, + double top) { DatePicker datePicker = new JFXDatePicker(); final Tuple2 topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, datePicker, top); @@ -485,11 +595,18 @@ public static Tuple2 addTopLabelDatePicker(GridPane gridPane, /////////////////////////////////////////////////////////////////////////////////////////// @SuppressWarnings("UnusedReturnValue") - public static Tuple2 addLabelTxIdTextField(GridPane gridPane, int rowIndex, String title, String value) { + public static Tuple2 addLabelTxIdTextField(GridPane gridPane, + int rowIndex, + String title, + String value) { return addLabelTxIdTextField(gridPane, rowIndex, title, value, 0); } - public static Tuple2 addLabelTxIdTextField(GridPane gridPane, int rowIndex, String title, String value, double top) { + public static Tuple2 addLabelTxIdTextField(GridPane gridPane, + int rowIndex, + String title, + String value, + double top) { Label label = addLabel(gridPane, rowIndex, title, top); label.getStyleClass().add("confirmation-label"); GridPane.setHalignment(label, HPos.LEFT); @@ -530,18 +647,26 @@ public static InputTextField addInputTextField(GridPane gridPane, int rowIndex, // Label + InputTextField /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple2 addTopLabelInputTextField(GridPane gridPane, int rowIndex, String title) { + public static Tuple2 addTopLabelInputTextField(GridPane gridPane, + int rowIndex, + String title) { return addTopLabelInputTextField(gridPane, rowIndex, title, 0); } - public static Tuple2 addTopLabelInputTextField(GridPane gridPane, int rowIndex, String title, double top) { + public static Tuple2 addTopLabelInputTextField(GridPane gridPane, + int rowIndex, + String title, + double top) { final Tuple3 topLabelWithVBox = addTopLabelInputTextFieldWithVBox(gridPane, rowIndex, title, top); return new Tuple2<>(topLabelWithVBox.first, topLabelWithVBox.second); } - public static Tuple3 addTopLabelInputTextFieldWithVBox(GridPane gridPane, int rowIndex, String title, double top) { + public static Tuple3 addTopLabelInputTextFieldWithVBox(GridPane gridPane, + int rowIndex, + String title, + double top) { InputTextField inputTextField = new InputTextField(); @@ -555,11 +680,16 @@ public static Tuple3 addTopLabelInputTextFieldWithV // Label + InfoInputTextField /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple2 addTopLabelInfoInputTextField(GridPane gridPane, int rowIndex, String title) { + public static Tuple2 addTopLabelInfoInputTextField(GridPane gridPane, + int rowIndex, + String title) { return addTopLabelInfoInputTextField(gridPane, rowIndex, title, 0); } - public static Tuple2 addTopLabelInfoInputTextField(GridPane gridPane, int rowIndex, String title, double top) { + public static Tuple2 addTopLabelInfoInputTextField(GridPane gridPane, + int rowIndex, + String title, + double top) { InfoInputTextField inputTextField = new InfoInputTextField(); @@ -594,7 +724,10 @@ public static PasswordTextField addPasswordTextField(GridPane gridPane, int rowI // Label + InputTextField + CheckBox /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple3 addTopLabelInputTextFieldSlideToggleButton(GridPane gridPane, int rowIndex, String title, String toggleButtonTitle) { + public static Tuple3 addTopLabelInputTextFieldSlideToggleButton(GridPane gridPane, + int rowIndex, + String title, + String toggleButtonTitle) { InputTextField inputTextField = new InputTextField(); ToggleButton toggleButton = new JFXToggleButton(); @@ -613,7 +746,10 @@ public static Tuple3 addTopLabelInputTextFi // Label + InputTextField + Button /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple3 addTopLabelInputTextFieldButton(GridPane gridPane, int rowIndex, String title, String buttonTitle) { + public static Tuple3 addTopLabelInputTextFieldButton(GridPane gridPane, + int rowIndex, + String title, + String buttonTitle) { InputTextField inputTextField = new InputTextField(); Button button = new AutoTooltipButton(buttonTitle); button.setDefaultButton(true); @@ -633,11 +769,18 @@ public static Tuple3 addTopLabelInputTextFieldBut // Label + TextField + Button /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple3 addTopLabelTextFieldButton(GridPane gridPane, int rowIndex, String title, String buttonTitle) { + public static Tuple3 addTopLabelTextFieldButton(GridPane gridPane, + int rowIndex, + String title, + String buttonTitle) { return addTopLabelTextFieldButton(gridPane, rowIndex, title, buttonTitle, 0); } - public static Tuple3 addTopLabelTextFieldButton(GridPane gridPane, int rowIndex, String title, String buttonTitle, double top) { + public static Tuple3 addTopLabelTextFieldButton(GridPane gridPane, + int rowIndex, + String title, + String buttonTitle, + double top) { TextField textField = new BisqTextField(); textField.setEditable(false); @@ -661,7 +804,10 @@ public static Tuple3 addTopLabelTextFieldButton(GridPa // Label + InputTextField + Label + InputTextField /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple2 addInputTextFieldInputTextField(GridPane gridPane, int rowIndex, String title1, String title2) { + public static Tuple2 addInputTextFieldInputTextField(GridPane gridPane, + int rowIndex, + String title1, + String title2) { InputTextField inputTextField1 = new InputTextField(); inputTextField1.setPromptText(title1); @@ -686,7 +832,10 @@ public static Tuple2 addInputTextFieldInputTextF // Label + TextField + Label + TextField /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple4 addCompactTopLabelTextFieldTopLabelTextField(GridPane gridPane, int rowIndex, String title1, String title2) { + public static Tuple4 addCompactTopLabelTextFieldTopLabelTextField(GridPane gridPane, + int rowIndex, + String title1, + String title2) { TextField textField1 = new BisqTextField(); textField1.setEditable(false); textField1.setMouseTransparent(true); @@ -715,11 +864,18 @@ public static Tuple4 addCompactTopLabelTextF // Button + CheckBox /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple2 addButtonCheckBox(GridPane gridPane, int rowIndex, String buttonTitle, String checkBoxTitle) { + public static Tuple2 addButtonCheckBox(GridPane gridPane, + int rowIndex, + String buttonTitle, + String checkBoxTitle) { return addButtonCheckBox(gridPane, rowIndex, buttonTitle, checkBoxTitle, 0); } - public static Tuple2 addButtonCheckBox(GridPane gridPane, int rowIndex, String buttonTitle, String checkBoxTitle, double top) { + public static Tuple2 addButtonCheckBox(GridPane gridPane, + int rowIndex, + String buttonTitle, + String checkBoxTitle, + double top) { Button button = new AutoTooltipButton(buttonTitle); button.setDefaultButton(true); CheckBox checkBox = new AutoTooltipCheckBox(checkBoxTitle); @@ -748,7 +904,11 @@ public static CheckBox addCheckBox(GridPane gridPane, int rowIndex, String check return addCheckBox(gridPane, rowIndex, 0, checkBoxTitle, 0); } - public static CheckBox addCheckBox(GridPane gridPane, int rowIndex, int colIndex, String checkBoxTitle, double top) { + public static CheckBox addCheckBox(GridPane gridPane, + int rowIndex, + int colIndex, + String checkBoxTitle, + double top) { CheckBox checkBox = new AutoTooltipCheckBox(checkBoxTitle); GridPane.setMargin(checkBox, new Insets(top, 0, 0, 0)); GridPane.setRowIndex(checkBox, rowIndex); @@ -886,7 +1046,11 @@ public static ComboBox addComboBox(GridPane gridPane, int rowIndex, int t // Label + ComboBox /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple2> addTopLabelComboBox(GridPane gridPane, int rowIndex, String title, String prompt, int top) { + public static Tuple2> addTopLabelComboBox(GridPane gridPane, + int rowIndex, + String title, + String prompt, + int top) { final Tuple3> tuple3 = addTopLabelComboBox(title, prompt, 0); final VBox vBox = tuple3.first; @@ -917,7 +1081,8 @@ public static Tuple3> addTopLabelAutoco return addTopLabelAutocompleteComboBox(title, 0); } - public static Tuple3> addTopLabelAutocompleteComboBox(String title, int top) { + public static Tuple3> addTopLabelAutocompleteComboBox(String title, + int top) { Label label = getTopLabel(title); VBox vBox = getTopLabelVBox(top); @@ -944,15 +1109,26 @@ private static Label getTopLabel(String title) { return label; } + public static Tuple2 addTopLabelWithVBox(GridPane gridPane, + int rowIndex, + String title, + Node node, + double top) { + return addTopLabelWithVBox(gridPane, rowIndex, 0, title, node, top); + } + @NotNull - public static Tuple2 addTopLabelWithVBox(GridPane gridPane, int rowIndex, - String title, Node node, + public static Tuple2 addTopLabelWithVBox(GridPane gridPane, + int rowIndex, + int columnIndex, + String title, + Node node, double top) { final Tuple2 topLabelWithVBox = getTopLabelWithVBox(title, node); VBox vBox = topLabelWithVBox.second; GridPane.setRowIndex(vBox, rowIndex); - GridPane.setColumnIndex(vBox, 0); + GridPane.setColumnIndex(vBox, columnIndex); GridPane.setMargin(vBox, new Insets(top + Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0)); gridPane.getChildren().add(vBox); @@ -1002,7 +1178,10 @@ public static ComboBox addComboBox(GridPane gridPane, int rowIndex, Strin // Label + AutocompleteComboBox /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple2> addLabelAutocompleteComboBox(GridPane gridPane, int rowIndex, String title, double top) { + public static Tuple2> addLabelAutocompleteComboBox(GridPane gridPane, + int rowIndex, + String title, + double top) { AutocompleteComboBox comboBox = new AutocompleteComboBox<>(); final Tuple2 labelVBoxTuple2 = addTopLabelWithVBox(gridPane, rowIndex, title, comboBox, top); return new Tuple2<>(labelVBoxTuple2.first, comboBox); @@ -1013,11 +1192,16 @@ public static Tuple2> addLabelAutocompleteComboBox(GridPa // Label + ComboBox + ComboBox /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple3, ComboBox> addTopLabelComboBoxComboBox(GridPane gridPane, int rowIndex, String title) { + public static Tuple3, ComboBox> addTopLabelComboBoxComboBox(GridPane gridPane, + int rowIndex, + String title) { return addTopLabelComboBoxComboBox(gridPane, rowIndex, title, 0); } - public static Tuple3, ComboBox> addTopLabelComboBoxComboBox(GridPane gridPane, int rowIndex, String title, double top) { + public static Tuple3, ComboBox> addTopLabelComboBoxComboBox(GridPane gridPane, + int rowIndex, + String title, + double top) { HBox hBox = new HBox(); hBox.setSpacing(10); @@ -1147,11 +1331,18 @@ public static Tuple3, TextField> addLabelComboBoxLabel(Gr // Label + TxIdTextField /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple2 addLabelTxIdTextField(GridPane gridPane, int rowIndex, int columnIndex, String title) { + public static Tuple2 addLabelTxIdTextField(GridPane gridPane, + int rowIndex, + int columnIndex, + String title) { return addLabelTxIdTextField(gridPane, rowIndex, columnIndex, title, 0); } - public static Tuple2 addLabelTxIdTextField(GridPane gridPane, int rowIndex, int columnIndex, String title, double top) { + public static Tuple2 addLabelTxIdTextField(GridPane gridPane, + int rowIndex, + int columnIndex, + String title, + double top) { Label label = addLabel(gridPane, rowIndex, title, top); TxIdTextField txIdTextField = new TxIdTextField(); @@ -1164,7 +1355,10 @@ public static Tuple2 addLabelTxIdTextField(GridPane gridPa } - public static Tuple3 addTopLabelTxIdTextField(GridPane gridPane, int rowIndex, String title, double top) { + public static Tuple3 addTopLabelTxIdTextField(GridPane gridPane, + int rowIndex, + String title, + double top) { TxIdTextField textField = new TxIdTextField(); textField.setFocusTraversable(false); @@ -1181,31 +1375,58 @@ public static Tuple3 addTopLabelTxIdTextField(GridPa // Label + TextFieldWithCopyIcon /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple2 addCompactTopLabelTextFieldWithCopyIcon(GridPane gridPane, int rowIndex, String title, String value) { + public static Tuple2 addCompactTopLabelTextFieldWithCopyIcon(GridPane gridPane, + int rowIndex, + String title, + String value) { return addTopLabelTextFieldWithCopyIcon(gridPane, rowIndex, title, value, -Layout.FLOATING_LABEL_DISTANCE); } - public static Tuple2 addCompactTopLabelTextFieldWithCopyIcon(GridPane gridPane, int rowIndex, int colIndex, String title, String value, double top) { + public static Tuple2 addCompactTopLabelTextFieldWithCopyIcon(GridPane gridPane, + int rowIndex, + int colIndex, + String title, + String value, + double top) { return addTopLabelTextFieldWithCopyIcon(gridPane, rowIndex, colIndex, title, value, top - Layout.FLOATING_LABEL_DISTANCE); } - public static Tuple2 addCompactTopLabelTextFieldWithCopyIcon(GridPane gridPane, int rowIndex, int colIndex, String title) { + public static Tuple2 addCompactTopLabelTextFieldWithCopyIcon(GridPane gridPane, + int rowIndex, + int colIndex, + String title) { return addTopLabelTextFieldWithCopyIcon(gridPane, rowIndex, colIndex, title, "", -Layout.FLOATING_LABEL_DISTANCE); } - public static Tuple2 addCompactTopLabelTextFieldWithCopyIcon(GridPane gridPane, int rowIndex, int colIndex, String title, String value) { + public static Tuple2 addCompactTopLabelTextFieldWithCopyIcon(GridPane gridPane, + int rowIndex, + int colIndex, + String title, + String value) { return addTopLabelTextFieldWithCopyIcon(gridPane, rowIndex, colIndex, title, value, -Layout.FLOATING_LABEL_DISTANCE); } - public static Tuple2 addTopLabelTextFieldWithCopyIcon(GridPane gridPane, int rowIndex, String title, String value) { + public static Tuple2 addTopLabelTextFieldWithCopyIcon(GridPane gridPane, + int rowIndex, + String title, + String value) { return addTopLabelTextFieldWithCopyIcon(gridPane, rowIndex, title, value, 0); } - public static Tuple2 addTopLabelTextFieldWithCopyIcon(GridPane gridPane, int rowIndex, String title, String value, double top) { + public static Tuple2 addTopLabelTextFieldWithCopyIcon(GridPane gridPane, + int rowIndex, + String title, + String value, + double top) { return addTopLabelTextFieldWithCopyIcon(gridPane, rowIndex, title, value, top, null); } - public static Tuple2 addTopLabelTextFieldWithCopyIcon(GridPane gridPane, int rowIndex, String title, String value, double top, String styleClass) { + public static Tuple2 addTopLabelTextFieldWithCopyIcon(GridPane gridPane, + int rowIndex, + String title, + String value, + double top, + String styleClass) { TextFieldWithCopyIcon textFieldWithCopyIcon = new TextFieldWithCopyIcon(styleClass); textFieldWithCopyIcon.setText(value); @@ -1214,7 +1435,12 @@ public static Tuple2 addTopLabelTextFieldWithCopyI return new Tuple2<>(topLabelWithVBox.first, textFieldWithCopyIcon); } - public static Tuple2 addTopLabelTextFieldWithCopyIcon(GridPane gridPane, int rowIndex, int colIndex, String title, String value, double top) { + public static Tuple2 addTopLabelTextFieldWithCopyIcon(GridPane gridPane, + int rowIndex, + int colIndex, + String title, + String value, + double top) { TextFieldWithCopyIcon textFieldWithCopyIcon = new TextFieldWithCopyIcon(); textFieldWithCopyIcon.setText(value); @@ -1226,11 +1452,18 @@ public static Tuple2 addTopLabelTextFieldWithCopyI return new Tuple2<>(topLabelWithVBox.first, textFieldWithCopyIcon); } - public static Tuple2 addConfirmationLabelTextFieldWithCopyIcon(GridPane gridPane, int rowIndex, String title, String value) { + public static Tuple2 addConfirmationLabelTextFieldWithCopyIcon(GridPane gridPane, + int rowIndex, + String title, + String value) { return addConfirmationLabelTextFieldWithCopyIcon(gridPane, rowIndex, title, value, 0); } - public static Tuple2 addConfirmationLabelTextFieldWithCopyIcon(GridPane gridPane, int rowIndex, String title, String value, double top) { + public static Tuple2 addConfirmationLabelTextFieldWithCopyIcon(GridPane gridPane, + int rowIndex, + String title, + String value, + double top) { Label label = addLabel(gridPane, rowIndex, title, top); label.getStyleClass().add("confirmation-label"); GridPane.setHalignment(label, HPos.LEFT); @@ -1285,8 +1518,11 @@ public static FundsTextField addFundsTextfield(GridPane gridPane, int rowIndex, // Label + InfoTextField /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple3 addTopLabelInfoTextField(GridPane gridPane, int rowIndex, String labelText, - String fieldText, double top) { + public static Tuple3 addTopLabelInfoTextField(GridPane gridPane, + int rowIndex, + String labelText, + String fieldText, + double top) { InfoTextField infoTextField = new InfoTextField(); infoTextField.setText(fieldText); @@ -1299,11 +1535,16 @@ public static Tuple3 addTopLabelInfoTextField(GridPa // Label + BsqAddressTextField /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple3 addLabelBsqAddressTextField(GridPane gridPane, int rowIndex, String title) { + public static Tuple3 addLabelBsqAddressTextField(GridPane gridPane, + int rowIndex, + String title) { return addLabelBsqAddressTextField(gridPane, rowIndex, title, 0); } - public static Tuple3 addLabelBsqAddressTextField(GridPane gridPane, int rowIndex, String title, double top) { + public static Tuple3 addLabelBsqAddressTextField(GridPane gridPane, + int rowIndex, + String title, + double top) { BsqAddressTextField addressTextField = new BsqAddressTextField(); addressTextField.setFocusTraversable(false); @@ -1334,11 +1575,18 @@ public static BalanceTextField addBalanceTextField(GridPane gridPane, int rowInd // Label + Button /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple2 addTopLabelButton(GridPane gridPane, int rowIndex, String labelText, String buttonTitle) { + public static Tuple2 addTopLabelButton(GridPane gridPane, + int rowIndex, + String labelText, + String buttonTitle) { return addTopLabelButton(gridPane, rowIndex, labelText, buttonTitle, 0); } - public static Tuple2 addTopLabelButton(GridPane gridPane, int rowIndex, String labelText, String buttonTitle, double top) { + public static Tuple2 addTopLabelButton(GridPane gridPane, + int rowIndex, + String labelText, + String buttonTitle, + double top) { Button button = new AutoTooltipButton(buttonTitle); button.setDefaultButton(true); @@ -1347,7 +1595,11 @@ public static Tuple2 addTopLabelButton(GridPane gridPane, int row return new Tuple2<>(topLabelWithVBox.first, button); } - public static Tuple2 addConfirmationLabelButton(GridPane gridPane, int rowIndex, String labelText, String buttonTitle, double top) { + public static Tuple2 addConfirmationLabelButton(GridPane gridPane, + int rowIndex, + String labelText, + String buttonTitle, + double top) { Label label = addLabel(gridPane, rowIndex, labelText); label.getStyleClass().add("confirmation-label"); @@ -1370,7 +1622,12 @@ public static Tuple2 addConfirmationLabelButton(GridPane gridPane // Label + Button + Button /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple3 addTopLabel2Buttons(GridPane gridPane, int rowIndex, String labelText, String title1, String title2, double top) { + public static Tuple3 addTopLabel2Buttons(GridPane gridPane, + int rowIndex, + String labelText, + String title1, + String title2, + double top) { HBox hBox = new HBox(); hBox.setSpacing(10); @@ -1571,7 +1828,8 @@ public static Tuple4 addButtonBusyAnimationL public static Tuple4 addButtonBusyAnimationLabel(GridPane gridPane, int rowIndex, - int colIndex, String buttonTitle, + int colIndex, + String buttonTitle, double top) { HBox hBox = new HBox(); hBox.setSpacing(10); @@ -1671,11 +1929,16 @@ public static Tuple2 getTradeInputBox(Pane amountValueBox, String d // Label + List /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple3, VBox> addTopLabelListView(GridPane gridPane, int rowIndex, String title) { + public static Tuple3, VBox> addTopLabelListView(GridPane gridPane, + int rowIndex, + String title) { return addTopLabelListView(gridPane, rowIndex, title, 0); } - public static Tuple3, VBox> addTopLabelListView(GridPane gridPane, int rowIndex, String title, double top) { + public static Tuple3, VBox> addTopLabelListView(GridPane gridPane, + int rowIndex, + String title, + double top) { ListView listView = new ListView<>(); final Tuple2 topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, listView, top); @@ -1686,7 +1949,10 @@ public static Tuple3, VBox> addTopLabelListView(GridPane // Label + FlowPane /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple2 addTopLabelFlowPane(GridPane gridPane, int rowIndex, String title, double top) { + public static Tuple2 addTopLabelFlowPane(GridPane gridPane, + int rowIndex, + String title, + double top) { FlowPane flowPane = new FlowPane(); flowPane.setPadding(new Insets(10, 10, 10, 10)); flowPane.setVgap(10); @@ -1785,7 +2051,10 @@ public static TableView addTableViewWithHeader(GridPane gridPane, int row return addTableViewWithHeader(gridPane, rowIndex, headerText, 0, null); } - public static TableView addTableViewWithHeader(GridPane gridPane, int rowIndex, String headerText, String groupStyle) { + public static TableView addTableViewWithHeader(GridPane gridPane, + int rowIndex, + String headerText, + String groupStyle) { return addTableViewWithHeader(gridPane, rowIndex, headerText, 0, groupStyle); } @@ -1793,7 +2062,11 @@ public static TableView addTableViewWithHeader(GridPane gridPane, int row return addTableViewWithHeader(gridPane, rowIndex, headerText, top, null); } - public static TableView addTableViewWithHeader(GridPane gridPane, int rowIndex, String headerText, int top, String groupStyle) { + public static TableView addTableViewWithHeader(GridPane gridPane, + int rowIndex, + String headerText, + int top, + String groupStyle) { TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, rowIndex, 1, headerText, top); if (groupStyle != null) titledGroupBg.getStyleClass().add(groupStyle);