diff --git a/core/src/main/java/bisq/core/util/VolumeUtil.java b/core/src/main/java/bisq/core/util/VolumeUtil.java index 4150aaa8758..769e2dc9eb4 100644 --- a/core/src/main/java/bisq/core/util/VolumeUtil.java +++ b/core/src/main/java/bisq/core/util/VolumeUtil.java @@ -17,17 +17,28 @@ package bisq.core.util; +import bisq.core.locale.Res; import bisq.core.monetary.Altcoin; import bisq.core.monetary.AltcoinExchangeRate; import bisq.core.monetary.Price; import bisq.core.monetary.Volume; +import bisq.core.offer.Offer; import org.bitcoinj.core.Coin; +import org.bitcoinj.core.Monetary; import org.bitcoinj.utils.ExchangeRate; import org.bitcoinj.utils.Fiat; +import org.bitcoinj.utils.MonetaryFormat; + +import java.text.DecimalFormat; +import java.text.NumberFormat; + +import java.util.Locale; public class VolumeUtil { + private static final MonetaryFormat FIAT_VOLUME_FORMAT = new MonetaryFormat().shift(0).minDecimals(0).repeatOptionalDecimals(0, 0); + public static Volume getRoundedFiatVolume(Volume volumeByAmount) { // We want to get rounded to 1 unit of the fiat currency, e.g. 1 EUR. return getAdjustedFiatVolume(volumeByAmount, 1); @@ -62,4 +73,76 @@ public static Volume getVolume(Coin amount, Price price) { return new Volume(new ExchangeRate((Fiat) price.getMonetary()).coinToFiat(amount)); } } + + + public static String formatVolume(Offer offer, Boolean decimalAligned, int maxNumberOfDigits) { + return formatVolume(offer, decimalAligned, maxNumberOfDigits, true); + } + + public static String formatVolume(Offer offer, Boolean decimalAligned, int maxNumberOfDigits, boolean showRange) { + String formattedVolume = offer.isRange() && showRange + ? formatVolume(offer.getMinVolume()) + FormattingUtils.RANGE_SEPARATOR + formatVolume(offer.getVolume()) + : formatVolume(offer.getVolume()); + + if (decimalAligned) { + formattedVolume = FormattingUtils.fillUpPlacesWithEmptyStrings(formattedVolume, maxNumberOfDigits); + } + return formattedVolume; + } + + public static String formatLargeFiat(double value, String currency) { + if (value <= 0) { + return "0"; + } + NumberFormat numberFormat = DecimalFormat.getInstance(Locale.US); + numberFormat.setGroupingUsed(true); + return numberFormat.format(value) + " " + currency; + } + + public static String formatLargeFiatWithUnitPostFix(double value, String currency) { + if (value <= 0) { + return "0"; + } + String[] units = new String[]{"", "K", "M", "B"}; + int digitGroups = (int) (Math.log10(value) / Math.log10(1000)); + return new DecimalFormat("#,##0.###") + .format(value / Math.pow(1000, digitGroups)) + units[digitGroups] + " " + currency; + } + + public static String formatVolume(Volume volume) { + return formatVolume(volume, FIAT_VOLUME_FORMAT, false); + } + + private static String formatVolume(Volume volume, MonetaryFormat fiatVolumeFormat, boolean appendCurrencyCode) { + if (volume != null) { + Monetary monetary = volume.getMonetary(); + if (monetary instanceof Fiat) + return FormattingUtils.formatFiat((Fiat) monetary, fiatVolumeFormat, appendCurrencyCode); + else + return FormattingUtils.formatAltcoinVolume((Altcoin) monetary, appendCurrencyCode); + } else { + return ""; + } + } + + public static String formatVolumeWithCode(Volume volume) { + return formatVolume(volume, true); + } + + public static String formatVolume(Volume volume, boolean appendCode) { + return formatVolume(volume, FIAT_VOLUME_FORMAT, appendCode); + } + + public static String formatAverageVolumeWithCode(Volume volume) { + return formatVolume(volume, FIAT_VOLUME_FORMAT.minDecimals(2), true); + } + + public static String formatVolumeLabel(String currencyCode) { + return formatVolumeLabel(currencyCode, ""); + } + + public static String formatVolumeLabel(String currencyCode, String postFix) { + return Res.get("formatter.formatVolumeLabel", + currencyCode, postFix); + } } diff --git a/desktop/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java b/desktop/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java index c35f668e4fa..15c52cde891 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java @@ -30,7 +30,6 @@ import bisq.desktop.main.overlays.windows.TxDetailsBsq; import bisq.desktop.main.overlays.windows.TxInputSelectionWindow; import bisq.desktop.main.overlays.windows.WalletPasswordWindow; -import bisq.desktop.util.DisplayUtils; import bisq.desktop.util.FormBuilder; import bisq.desktop.util.GUIUtil; import bisq.desktop.util.Layout; @@ -54,6 +53,7 @@ import bisq.core.user.Preferences; import bisq.core.util.FormattingUtils; import bisq.core.util.ParsingUtils; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.BsqFormatter; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.coin.CoinUtil; @@ -256,7 +256,7 @@ public void onUpdateBalances(Coin availableConfirmedBalance, } public void fillFromTradeData(Tuple2 tuple) { - amountInputTextField.setText(DisplayUtils.formatVolume(tuple.first)); + amountInputTextField.setText(VolumeUtil.formatVolume(tuple.first)); receiversAddressInputTextField.setText(tuple.second); } @@ -528,7 +528,7 @@ public void onFailure(TxBroadcastException exception) { private void doWithdraw(Transaction txWithBtcFee, TxType txType, TxBroadcaster.Callback callback) { if (btcWalletService.isEncrypted()) { UserThread.runAfter(() -> walletPasswordWindow.onAesKey(aesKey -> - sendFunds(txWithBtcFee, txType, callback)) + sendFunds(txWithBtcFee, txType, callback)) .show(), 300, TimeUnit.MILLISECONDS); } else { sendFunds(txWithBtcFee, txType, callback); diff --git a/desktop/src/main/java/bisq/desktop/main/market/MarketView.java b/desktop/src/main/java/bisq/desktop/main/market/MarketView.java index d868271f910..4aa94894f8e 100644 --- a/desktop/src/main/java/bisq/desktop/main/market/MarketView.java +++ b/desktop/src/main/java/bisq/desktop/main/market/MarketView.java @@ -39,6 +39,7 @@ import bisq.core.trade.statistics.TradeStatistics3; import bisq.core.trade.statistics.TradeStatistics3StorageService; import bisq.core.util.FormattingUtils; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.CoinFormatter; import bisq.common.util.Utilities; @@ -198,7 +199,7 @@ private String getAllTradesWithReferralId() { .append("Market: ").append(CurrencyUtil.getCurrencyPair(tradeStatistics3.getCurrency())).append("\n") .append("Price: ").append(FormattingUtils.formatPrice(tradeStatistics3.getTradePrice())).append("\n") .append("Amount: ").append(formatter.formatCoin(tradeStatistics3.getTradeAmount())).append("\n") - .append("Volume: ").append(DisplayUtils.formatVolume(tradeStatistics3.getTradeVolume())).append("\n") + .append("Volume: ").append(VolumeUtil.formatVolume(tradeStatistics3.getTradeVolume())).append("\n") .append("Payment method: ").append(Res.get(tradeStatistics3.getPaymentMethod())).append("\n") .append("ReferralID: ").append(tradeStatistics3.getExtraDataMap().get(OfferPayload.REFERRAL_ID)); return sb.toString(); diff --git a/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java b/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java index b1a1dedb9e4..e17ecd20214 100644 --- a/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java +++ b/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java @@ -39,6 +39,7 @@ import bisq.core.offer.Offer; import bisq.core.offer.OfferPayload; import bisq.core.util.FormattingUtils; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.CoinFormatter; import bisq.network.p2p.NodeAddress; @@ -88,11 +89,11 @@ import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; -import java.text.DecimalFormat; - import javafx.util.Callback; import javafx.util.StringConverter; +import java.text.DecimalFormat; + import java.util.List; import java.util.concurrent.TimeUnit; import java.util.function.Function; @@ -140,7 +141,9 @@ public class OfferBookChartView extends ActivatableViewAndModel> filterOutliersBuy(List> buy, boolean isCrypto) { List mnmx = isCrypto ? minMaxFilterRight(buy) : minMaxFilterLeft(buy); if (mnmx.get(0).doubleValue() == Double.MAX_VALUE || - mnmx.get(1).doubleValue() == Double.MIN_VALUE) { // no filtering + mnmx.get(1).doubleValue() == Double.MIN_VALUE) { // no filtering return buy; } // apply filtering @@ -408,7 +411,7 @@ List> filterOutliersBuy(List> filterOutliersSell(List> sell, boolean isCrypto) { List mnmx = isCrypto ? minMaxFilterLeft(sell) : minMaxFilterRight(sell); if (mnmx.get(0).doubleValue() == Double.MAX_VALUE || - mnmx.get(1).doubleValue() == Double.MIN_VALUE) { // no filtering + mnmx.get(1).doubleValue() == Double.MIN_VALUE) { // no filtering return sell; } // apply filtering @@ -417,43 +420,43 @@ List> filterOutliersSell(List minMaxFilterLeft(List> data) { double maxValue = data.stream() - .mapToDouble(o -> o.getXValue().doubleValue()) - .max() - .orElse(Double.MIN_VALUE); + .mapToDouble(o -> o.getXValue().doubleValue()) + .max() + .orElse(Double.MIN_VALUE); // Hide offers less than a div-factor of dataLimitFactor lower than the highest offer. double minValue = data.stream() - .mapToDouble(o -> o.getXValue().doubleValue()) - .filter(o -> o > maxValue / dataLimitFactor) - .min() - .orElse(Double.MAX_VALUE); + .mapToDouble(o -> o.getXValue().doubleValue()) + .filter(o -> o > maxValue / dataLimitFactor) + .min() + .orElse(Double.MAX_VALUE); return List.of(minValue, maxValue); } private List minMaxFilterRight(List> data) { double minValue = data.stream() - .mapToDouble(o -> o.getXValue().doubleValue()) - .min() - .orElse(Double.MAX_VALUE); + .mapToDouble(o -> o.getXValue().doubleValue()) + .min() + .orElse(Double.MAX_VALUE); // Hide offers a dataLimitFactor factor higher than the lowest offer double maxValue = data.stream() - .mapToDouble(o -> o.getXValue().doubleValue()) - .filter(o -> o < minValue * dataLimitFactor) - .max() - .orElse(Double.MIN_VALUE); + .mapToDouble(o -> o.getXValue().doubleValue()) + .filter(o -> o < minValue * dataLimitFactor) + .max() + .orElse(Double.MIN_VALUE); return List.of(minValue, maxValue); } private List> filterLeft(List> data, double maxValue) { return data.stream() - .filter(o -> o.getXValue().doubleValue() > maxValue / dataLimitFactor) - .collect(Collectors.toList()); + .filter(o -> o.getXValue().doubleValue() > maxValue / dataLimitFactor) + .collect(Collectors.toList()); } private List> filterRight(List> data, double minValue) { return data.stream() - .filter(o -> o.getXValue().doubleValue() < minValue * dataLimitFactor) - .collect(Collectors.toList()); + .filter(o -> o.getXValue().doubleValue() < minValue * dataLimitFactor) + .collect(Collectors.toList()); } private Tuple4, VBox, Button, Label> getOfferTable(OfferPayload.Direction direction) { @@ -479,7 +482,9 @@ public TableCell call(TableColumn listener = new ChangeListener<>() { @Override - public void changed(ObservableValue observable, Number oldValue, Number newValue) { + public void changed(ObservableValue observable, + Number oldValue, + Number newValue) { if (offer != null && offer.getPrice() != null) { setText(""); setGraphic(new ColoredDecimalPlacesWithZerosText(model.getPrice(offer), @@ -529,7 +534,9 @@ public TableCell call(TableColumn listener = new ChangeListener<>() { @Override - public void changed(ObservableValue observable, Number oldValue, Number newValue) { + public void changed(ObservableValue observable, + Number oldValue, + Number newValue) { if (offer != null && offer.getPrice() != null) { renderCellContentRange(); model.priceFeedService.updateCounterProperty().removeListener(listener); @@ -562,7 +569,7 @@ public void updateItem(final OfferListItem offerListItem, boolean empty) { * Should not be called for empty cells */ private void renderCellContentRange() { - String volumeRange = DisplayUtils.formatVolume(offer, true, 2); + String volumeRange = VolumeUtil.formatVolume(offer, true, 2); setText(""); setGraphic(new ColoredDecimalPlacesWithZerosText(volumeRange, @@ -711,8 +718,8 @@ private void layout() { if (buyOfferTableView.getHeight() != newTableViewHeight) { buyOfferTableView.setMinHeight(newTableViewHeight); sellOfferTableView.setMinHeight(newTableViewHeight); - } + } } - }, 100, TimeUnit.MILLISECONDS); - } + }, 100, TimeUnit.MILLISECONDS); + } } diff --git a/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartViewModel.java b/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartViewModel.java index faa02455736..68178818580 100644 --- a/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartViewModel.java @@ -38,6 +38,7 @@ import bisq.core.offer.OfferPayload; import bisq.core.provider.price.PriceFeedService; import bisq.core.user.Preferences; +import bisq.core.util.VolumeUtil; import com.google.inject.Inject; @@ -232,15 +233,20 @@ public ObservableList getCurrencyListItems() { } public Optional getSelectedCurrencyListItem() { - return currencyListItems.getObservableList().stream().filter(e -> e.tradeCurrency.equals(selectedTradeCurrencyProperty.get())).findAny(); + return currencyListItems.getObservableList().stream() + .filter(e -> e.tradeCurrency.equals(selectedTradeCurrencyProperty.get())).findAny(); } public int getMaxNumberOfPriceZeroDecimalsToColorize(Offer offer) { - return CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) ? GUIUtil.FIAT_DECIMALS_WITH_ZEROS : GUIUtil.ALTCOINS_DECIMALS_WITH_ZEROS; + return CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) + ? GUIUtil.FIAT_DECIMALS_WITH_ZEROS + : GUIUtil.ALTCOINS_DECIMALS_WITH_ZEROS; } public int getZeroDecimalsForPrice(Offer offer) { - return CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) ? GUIUtil.FIAT_PRICE_DECIMALS_WITH_ZEROS : GUIUtil.ALTCOINS_DECIMALS_WITH_ZEROS; + return CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) + ? GUIUtil.FIAT_PRICE_DECIMALS_WITH_ZEROS + : GUIUtil.ALTCOINS_DECIMALS_WITH_ZEROS; } public String getPrice(Offer offer) { @@ -248,7 +254,9 @@ public String getPrice(Offer offer) { } private String formatPrice(Offer offer, boolean decimalAligned) { - return DisplayUtils.formatPrice(offer.getPrice(), decimalAligned, offer.isBuyOffer() ? maxPlacesForBuyPrice.get() : maxPlacesForSellPrice.get()); + return DisplayUtils.formatPrice(offer.getPrice(), decimalAligned, offer.isBuyOffer() + ? maxPlacesForBuyPrice.get() + : maxPlacesForSellPrice.get()); } public String getVolume(Offer offer) { @@ -256,7 +264,10 @@ public String getVolume(Offer offer) { } private String formatVolume(Offer offer, boolean decimalAligned) { - return DisplayUtils.formatVolume(offer, decimalAligned, offer.isBuyOffer() ? maxPlacesForBuyVolume.get() : maxPlacesForSellVolume.get(), false); + return VolumeUtil.formatVolume(offer, + decimalAligned, + offer.isBuyOffer() ? maxPlacesForBuyVolume.get() : maxPlacesForSellVolume.get(), + false); } /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/desktop/src/main/java/bisq/desktop/main/market/trades/TradeStatistics3ListItem.java b/desktop/src/main/java/bisq/desktop/main/market/trades/TradeStatistics3ListItem.java index 234342d0727..f15fe7f4385 100644 --- a/desktop/src/main/java/bisq/desktop/main/market/trades/TradeStatistics3ListItem.java +++ b/desktop/src/main/java/bisq/desktop/main/market/trades/TradeStatistics3ListItem.java @@ -23,6 +23,7 @@ import bisq.core.locale.Res; import bisq.core.trade.statistics.TradeStatistics3; import bisq.core.util.FormattingUtils; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.CoinFormatter; import lombok.experimental.Delegate; @@ -73,8 +74,8 @@ public String getPriceString() { public String getVolumeString() { if (volumeString == null) { volumeString = tradeStatistics3 != null ? showAllTradeCurrencies ? - DisplayUtils.formatVolumeWithCode(tradeStatistics3.getTradeVolume()) : - DisplayUtils.formatVolume(tradeStatistics3.getTradeVolume()) + VolumeUtil.formatVolumeWithCode(tradeStatistics3.getTradeVolume()) : + VolumeUtil.formatVolume(tradeStatistics3.getTradeVolume()) : ""; } return volumeString; diff --git a/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsView.java b/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsView.java index 4c02dfab715..3c7d2501404 100644 --- a/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsView.java +++ b/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsView.java @@ -38,6 +38,7 @@ import bisq.core.user.CookieKey; import bisq.core.user.User; import bisq.core.util.FormattingUtils; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.CoinFormatter; import bisq.common.UserThread; @@ -570,7 +571,7 @@ private VolumeChart getVolumeChart(NumberAxis axisX, public String toString(Number volume) { return currency.equals("BTC") ? coinFormatter.formatCoin(Coin.valueOf(MathUtils.doubleToLong((double) volume))) : - DisplayUtils.formatLargeFiatWithUnitPostFix((double) volume, "USD"); + VolumeUtil.formatLargeFiatWithUnitPostFix((double) volume, "USD"); } @Override diff --git a/desktop/src/main/java/bisq/desktop/main/market/trades/charts/volume/VolumeBar.java b/desktop/src/main/java/bisq/desktop/main/market/trades/charts/volume/VolumeBar.java index b6637cce7c8..675c75dedc4 100644 --- a/desktop/src/main/java/bisq/desktop/main/market/trades/charts/volume/VolumeBar.java +++ b/desktop/src/main/java/bisq/desktop/main/market/trades/charts/volume/VolumeBar.java @@ -18,9 +18,9 @@ package bisq.desktop.main.market.trades.charts.volume; import bisq.desktop.main.market.trades.charts.CandleData; -import bisq.desktop.util.DisplayUtils; import bisq.core.locale.Res; +import bisq.core.util.VolumeUtil; import javafx.scene.Group; import javafx.scene.control.Tooltip; @@ -57,7 +57,7 @@ public void setSeriesAndDataStyleClasses(String seriesStyleClass, String dataSty public void update(double height, double candleWidth, CandleData candleData) { bar.resizeRelocate(-candleWidth / 2, 0, candleWidth, height); String volumeInBtc = volumeStringConverter.toString(candleData.accumulatedAmount); - String volumeInUsd = DisplayUtils.formatLargeFiat(candleData.volumeInUsd, "USD"); + String volumeInUsd = VolumeUtil.formatLargeFiat(candleData.volumeInUsd, "USD"); tooltip.setText(Res.get("market.trades.tooltip.volumeBar", volumeInBtc, volumeInUsd, candleData.numTrades, candleData.date)); } diff --git a/desktop/src/main/java/bisq/desktop/main/offer/FeeUtil.java b/desktop/src/main/java/bisq/desktop/main/offer/FeeUtil.java index 82f2363e5ed..92698c91baa 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/FeeUtil.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/FeeUtil.java @@ -23,6 +23,7 @@ import bisq.core.locale.Res; import bisq.core.monetary.Volume; import bisq.core.offer.OfferUtil; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.CoinFormatter; import bisq.common.app.DevEnv; @@ -65,9 +66,9 @@ public static String getTradeFeeWithFiatEquivalentAndPercentage(OfferUtil offerU " " + Res.get("guiUtil.ofTradeAmount"); } return offerUtil.getFeeInUserFiatCurrency(tradeFee, - isCurrencyForMakerFeeBtc, - formatter) - .map(DisplayUtils::formatAverageVolumeWithCode) + isCurrencyForMakerFeeBtc, + formatter) + .map(VolumeUtil::formatAverageVolumeWithCode) .map(feeInFiat -> Res.get("feeOptionWindow.btcFeeWithFiatAndPercentage", feeAsBtc, feeInFiat, percentage)) .orElseGet(() -> Res.get("feeOptionWindow.btcFeeWithPercentage", feeAsBtc, percentage)); } else { diff --git a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java index 952197daea1..04675d48b77 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java @@ -471,7 +471,7 @@ private void createListeners() { volumeListener = (ov, oldValue, newValue) -> { ignoreVolumeStringListener = true; if (newValue != null) - volume.set(DisplayUtils.formatVolume(newValue)); + volume.set(VolumeUtil.formatVolume(newValue)); else volume.set(""); @@ -758,7 +758,7 @@ public void onFocusOutMinAmountTextField(boolean oldValue, boolean newValue) { if (dataModel.getMinVolume().get() != null) { InputValidator.ValidationResult minVolumeResult = isVolumeInputValid( - DisplayUtils.formatVolume(dataModel.getMinVolume().get())); + VolumeUtil.formatVolume(dataModel.getMinVolume().get())); volumeValidationResult.set(minVolumeResult); @@ -883,7 +883,7 @@ void onFocusOutVolumeTextField(boolean oldValue, boolean newValue) { else if (CurrencyUtil.isFiatCurrency(tradeCurrencyCode.get())) volume = VolumeUtil.getRoundedFiatVolume(volume); - this.volume.set(DisplayUtils.formatVolume(volume)); + this.volume.set(VolumeUtil.formatVolume(volume)); } ignoreVolumeStringListener = false; @@ -1303,7 +1303,7 @@ void updateButtonDisableState() { dataModel.getPrice().get() != null && dataModel.getPrice().get().getValue() != 0 && isVolumeInputValid(volume.get()).isValid && - isVolumeInputValid(DisplayUtils.formatVolume(dataModel.getMinVolume().get())).isValid && + isVolumeInputValid(VolumeUtil.formatVolume(dataModel.getMinVolume().get())).isValid && dataModel.isMinAmountLessOrEqualAmount(); if (dataModel.useMarketBasedPrice.get() && dataModel.isMarketPriceAvailable()) { diff --git a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java index ce1dfa13c9f..ee78f2796b5 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java @@ -50,6 +50,7 @@ import bisq.core.user.Preferences; import bisq.core.user.User; import bisq.core.util.FormattingUtils; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.BsqFormatter; import bisq.core.util.coin.CoinFormatter; @@ -435,7 +436,7 @@ private String formatVolume(Offer offer, boolean decimalAligned) { if (offerVolume != null && minOfferVolume != null) { String postFix = showAllTradeCurrenciesProperty.get() ? " " + offer.getCurrencyCode() : ""; decimalAligned = decimalAligned && !showAllTradeCurrenciesProperty.get(); - return DisplayUtils.formatVolume(offer, decimalAligned, maxPlacesForVolume.get()) + postFix; + return VolumeUtil.formatVolume(offer, decimalAligned, maxPlacesForVolume.get()) + postFix; } else { return Res.get("shared.na"); } diff --git a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java index 6c13c24c236..6c8a9e76ebd 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java @@ -43,6 +43,7 @@ import bisq.core.provider.fee.FeeService; import bisq.core.trade.Trade; import bisq.core.util.FormattingUtils; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.BsqFormatter; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.coin.CoinUtil; @@ -475,7 +476,7 @@ private void updateButtonDisableState() { /////////////////////////////////////////////////////////////////////////////////////////// private void addBindings() { - volume.bind(createStringBinding(() -> DisplayUtils.formatVolume(dataModel.volume.get()), dataModel.volume)); + volume.bind(createStringBinding(() -> VolumeUtil.formatVolume(dataModel.volume.get()), dataModel.volume)); if (dataModel.getDirection() == OfferPayload.Direction.SELL) { volumeDescriptionLabel.set(Res.get("createOffer.amountPriceBox.buy.volumeDescription", dataModel.getCurrencyCode())); diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java index c34a16ae69a..836b69dc634 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ContractWindow.java @@ -39,6 +39,7 @@ import bisq.core.support.dispute.refund.RefundManager; import bisq.core.trade.Contract; import bisq.core.util.FormattingUtils; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.CoinFormatter; import bisq.network.p2p.NodeAddress; @@ -162,8 +163,10 @@ private void addContent() { FormattingUtils.formatPrice(contract.getTradePrice())); addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradeAmount"), formatter.formatCoinWithCode(contract.getTradeAmount())); - addConfirmationLabelLabel(gridPane, ++rowIndex, DisplayUtils.formatVolumeLabel(currencyCode, ":"), - DisplayUtils.formatVolumeWithCode(contract.getTradeVolume())); + addConfirmationLabelLabel(gridPane, + ++rowIndex, + VolumeUtil.formatVolumeLabel(currencyCode, ":"), + VolumeUtil.formatVolumeWithCode(contract.getTradeVolume())); String securityDeposit = Res.getWithColAndCap("shared.buyer") + " " + formatter.formatCoinWithCode(offer.getBuyerSecurityDeposit()) + @@ -172,28 +175,43 @@ private void addContent() { " " + formatter.formatCoinWithCode(offer.getSellerSecurityDeposit()); addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.securityDeposit"), securityDeposit); - addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("contractWindow.btcAddresses"), - contract.getBuyerPayoutAddressString() + " / " + - contract.getSellerPayoutAddressString()).second.setMouseTransparent(false); - addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("contractWindow.onions"), + addConfirmationLabelTextFieldWithCopyIcon(gridPane, + ++rowIndex, + Res.get("contractWindow.btcAddresses"), + contract.getBuyerPayoutAddressString() + " / " + contract.getSellerPayoutAddressString()).second.setMouseTransparent(false); + addConfirmationLabelTextFieldWithCopyIcon(gridPane, + ++rowIndex, + Res.get("contractWindow.onions"), contract.getBuyerNodeAddress().getFullAddress() + " / " + contract.getSellerNodeAddress().getFullAddress()); - addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("contractWindow.accountAge"), - getAccountAge(contract.getBuyerPaymentAccountPayload(), contract.getBuyerPubKeyRing(), offer.getCurrencyCode()) + " / " + - getAccountAge(contract.getSellerPaymentAccountPayload(), contract.getSellerPubKeyRing(), offer.getCurrencyCode())); + addConfirmationLabelTextFieldWithCopyIcon(gridPane, + ++rowIndex, + Res.get("contractWindow.accountAge"), + getAccountAge(contract.getBuyerPaymentAccountPayload(), + contract.getBuyerPubKeyRing(), + offer.getCurrencyCode()) + " / " + getAccountAge(contract.getSellerPaymentAccountPayload(), contract.getSellerPubKeyRing(), offer.getCurrencyCode())); DisputeManager> disputeManager = getDisputeManager(dispute); String nrOfDisputesAsBuyer = disputeManager != null ? disputeManager.getNrOfDisputes(true, contract) : ""; String nrOfDisputesAsSeller = disputeManager != null ? disputeManager.getNrOfDisputes(false, contract) : ""; - addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("contractWindow.numDisputes"), + addConfirmationLabelTextFieldWithCopyIcon(gridPane, + ++rowIndex, + Res.get("contractWindow.numDisputes"), nrOfDisputesAsBuyer + " / " + nrOfDisputesAsSeller); - - addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("shared.paymentDetails", Res.get("shared.buyer")), - contract.getBuyerPaymentAccountPayload() != null ? - contract.getBuyerPaymentAccountPayload().getPaymentDetails() : "NA").second.setMouseTransparent(false); - addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("shared.paymentDetails", Res.get("shared.seller")), - sellerPaymentAccountPayload != null ? - sellerPaymentAccountPayload.getPaymentDetails() : "NA").second.setMouseTransparent(false); + addConfirmationLabelTextFieldWithCopyIcon(gridPane, + ++rowIndex, + Res.get("shared.paymentDetails", Res.get("shared.buyer")), + contract.getBuyerPaymentAccountPayload() != null + ? contract.getBuyerPaymentAccountPayload().getPaymentDetails() + : "NA") + .second.setMouseTransparent(false); + addConfirmationLabelTextFieldWithCopyIcon(gridPane, + ++rowIndex, + Res.get("shared.paymentDetails", Res.get("shared.seller")), + sellerPaymentAccountPayload != null + ? sellerPaymentAccountPayload.getPaymentDetails() + : "NA") + .second.setMouseTransparent(false); String title = ""; String agentKeyBaseUserName = ""; @@ -232,7 +250,10 @@ private void addContent() { countries = CountryUtil.getCodesString(acceptedCountryCodes); tooltip = new Tooltip(CountryUtil.getNamesByCodesString(acceptedCountryCodes)); } - Label acceptedCountries = addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.acceptedTakerCountries"), countries).second; + Label acceptedCountries = addConfirmationLabelLabel(gridPane, + ++rowIndex, + Res.get("shared.acceptedTakerCountries"), + countries).second; if (tooltip != null) acceptedCountries.setTooltip(new Tooltip()); } @@ -242,7 +263,10 @@ private void addContent() { } else if (offer.getPaymentMethod().equals(PaymentMethod.SPECIFIC_BANKS)) { String value = Joiner.on(", ").join(acceptedBanks); Tooltip tooltip = new Tooltip(Res.get("shared.acceptedBanks") + value); - Label acceptedBanksTextField = addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.acceptedBanks"), value).second; + Label acceptedBanksTextField = addConfirmationLabelLabel(gridPane, + ++rowIndex, + Res.get("shared.acceptedBanks"), + value).second; acceptedBanksTextField.setMouseTransparent(false); acceptedBanksTextField.setTooltip(tooltip); } diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/DisputeSummaryWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/DisputeSummaryWindow.java index 61b46a394ff..91c2661d14e 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/DisputeSummaryWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/DisputeSummaryWindow.java @@ -50,6 +50,7 @@ import bisq.core.trade.TradeDataValidation; import bisq.core.util.FormattingUtils; import bisq.core.util.ParsingUtils; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.coin.CoinUtil; @@ -295,7 +296,7 @@ private void addInfoPane() { addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradePrice"), FormattingUtils.formatPrice(contract.getTradePrice())); addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradeVolume"), - DisplayUtils.formatVolumeWithCode(contract.getTradeVolume())); + VolumeUtil.formatVolumeWithCode(contract.getTradeVolume())); String securityDeposit = Res.getWithColAndCap("shared.buyer") + " " + formatter.formatCoinWithCode(contract.getOfferPayload().getBuyerSecurityDeposit()) + diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/OfferDetailsWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/OfferDetailsWindow.java index 64b0f9aa27e..531469bb172 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/OfferDetailsWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/OfferDetailsWindow.java @@ -28,7 +28,6 @@ import bisq.desktop.util.Layout; import bisq.core.btc.wallet.BtcWalletService; -import bisq.core.locale.BankUtil; import bisq.core.locale.CountryUtil; import bisq.core.locale.Res; import bisq.core.monetary.Price; @@ -39,6 +38,7 @@ import bisq.core.payment.payload.PaymentMethod; import bisq.core.user.User; import bisq.core.util.FormattingUtils; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.CoinFormatter; import bisq.common.crypto.KeyRing; @@ -208,20 +208,25 @@ private void addContent() { if (takeOfferHandlerOptional.isPresent()) { addConfirmationLabelLabel(gridPane, ++rowIndex, btcAmount + btcDirectionInfo, formatter.formatCoinWithCode(tradeAmount)); - addConfirmationLabelLabel(gridPane, ++rowIndex, DisplayUtils.formatVolumeLabel(currencyCode) + fiatDirectionInfo, - DisplayUtils.formatVolumeWithCode(offer.getVolumeByAmount(tradeAmount))); + addConfirmationLabelLabel(gridPane, + ++rowIndex, + VolumeUtil.formatVolumeLabel(currencyCode) + fiatDirectionInfo, + VolumeUtil.formatVolumeWithCode(offer.getVolumeByAmount(tradeAmount))); } else { addConfirmationLabelLabel(gridPane, ++rowIndex, btcAmount + btcDirectionInfo, formatter.formatCoinWithCode(offer.getAmount())); addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("offerDetailsWindow.minBtcAmount"), formatter.formatCoinWithCode(offer.getMinAmount())); - String volume = DisplayUtils.formatVolumeWithCode(offer.getVolume()); + String volume = VolumeUtil.formatVolumeWithCode(offer.getVolume()); String minVolume = ""; if (offer.getVolume() != null && offer.getMinVolume() != null && !offer.getVolume().equals(offer.getMinVolume())) - minVolume = " " + Res.get("offerDetailsWindow.min", DisplayUtils.formatVolumeWithCode(offer.getMinVolume())); - addConfirmationLabelLabel(gridPane, ++rowIndex, - DisplayUtils.formatVolumeLabel(currencyCode) + fiatDirectionInfo, volume + minVolume); + minVolume = " " + Res.get("offerDetailsWindow.min", + VolumeUtil.formatVolumeWithCode(offer.getMinVolume())); + addConfirmationLabelLabel(gridPane, + ++rowIndex, + VolumeUtil.formatVolumeLabel(currencyCode) + fiatDirectionInfo, + volume + minVolume); } String priceLabel = Res.get("shared.price"); diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/SwiftPaymentDetails.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/SwiftPaymentDetails.java index 18556ad9534..d652aa067cd 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/SwiftPaymentDetails.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/SwiftPaymentDetails.java @@ -18,14 +18,15 @@ package bisq.desktop.main.overlays.windows; import bisq.desktop.main.overlays.Overlay; -import bisq.desktop.util.DisplayUtils; import bisq.core.locale.CountryUtil; import bisq.core.locale.Res; import bisq.core.payment.payload.SwiftAccountPayload; import bisq.core.trade.Trade; +import bisq.core.util.VolumeUtil; import javafx.scene.control.Label; + import javafx.geometry.Insets; import java.util.ArrayList; @@ -72,7 +73,8 @@ private void addContent() { addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("payment.swift.headline")); gridPane.add(new Label(""), 0, ++rowIndex); // spacer - addLabelsAndCopy(Res.get("portfolio.pending.step2_buyer.amountToTransfer"), DisplayUtils.formatVolumeWithCode(trade.getTradeVolume())); + addLabelsAndCopy(Res.get("portfolio.pending.step2_buyer.amountToTransfer"), + VolumeUtil.formatVolumeWithCode(trade.getTradeVolume())); addLabelsAndCopy(Res.get(SWIFT_CODE + BANKPOSTFIX), payload.getBankSwiftCode()); addLabelsAndCopy(Res.get(SNAME + BANKPOSTFIX), payload.getBankName()); addLabelsAndCopy(Res.get(BRANCH + BANKPOSTFIX), payload.getBankBranch()); @@ -85,7 +87,8 @@ private void addContent() { addLabelsAndCopy(Res.get(SNAME + INTERMEDIARYPOSTFIX), payload.getIntermediaryName()); addLabelsAndCopy(Res.get(BRANCH + INTERMEDIARYPOSTFIX), payload.getIntermediaryBranch()); addLabelsAndCopy(Res.get(ADDRESS + INTERMEDIARYPOSTFIX), cleanString(payload.getIntermediaryAddress())); - addLabelsAndCopy(Res.get(COUNTRY + INTERMEDIARYPOSTFIX), CountryUtil.getNameAndCode(payload.getIntermediaryCountryCode())); + addLabelsAndCopy(Res.get(COUNTRY + INTERMEDIARYPOSTFIX), + CountryUtil.getNameAndCode(payload.getIntermediaryCountryCode())); } gridPane.add(new Label(""), 0, ++rowIndex); // spacer diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/TradeDetailsWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/TradeDetailsWindow.java index be2d1d34891..7c31f5f896a 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/TradeDetailsWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/TradeDetailsWindow.java @@ -39,6 +39,7 @@ import bisq.core.trade.TradeManager; import bisq.core.trade.txproof.AssetTxProofResult; import bisq.core.util.FormattingUtils; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.CoinFormatter; import bisq.network.p2p.NodeAddress; @@ -168,8 +169,8 @@ private void addContent() { addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.btcAmount") + btcDirectionInfo, formatter.formatCoinWithCode(trade.getTradeAmount())); addConfirmationLabelLabel(gridPane, ++rowIndex, - DisplayUtils.formatVolumeLabel(offer.getCurrencyCode()) + fiatDirectionInfo, - DisplayUtils.formatVolumeWithCode(trade.getTradeVolume())); + VolumeUtil.formatVolumeLabel(offer.getCurrencyCode()) + fiatDirectionInfo, + VolumeUtil.formatVolumeWithCode(trade.getTradeVolume())); addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradePrice"), FormattingUtils.formatPrice(trade.getTradePrice())); String paymentMethodText = Res.get(offer.getPaymentMethod().getId()); diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/closedtrades/ClosedTradesViewModel.java b/desktop/src/main/java/bisq/desktop/main/portfolio/closedtrades/ClosedTradesViewModel.java index 7bfe454bfdf..b782e65c8cb 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/closedtrades/ClosedTradesViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/closedtrades/ClosedTradesViewModel.java @@ -32,6 +32,7 @@ import bisq.core.trade.Tradable; import bisq.core.trade.Trade; import bisq.core.util.FormattingUtils; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.BsqFormatter; import bisq.core.util.coin.CoinFormatter; @@ -115,7 +116,7 @@ String getVolume(ClosedTradableListItem item, boolean appendCode) { } Trade trade = (Trade) item.getTradable(); - return DisplayUtils.formatVolume(trade.getTradeVolume(), appendCode); + return VolumeUtil.formatVolume(trade.getTradeVolume(), appendCode); } String getVolumeCurrency(ClosedTradableListItem item) { @@ -289,7 +290,7 @@ public String getTotalAmountWithVolume(Coin totalTradeAmount) { .map(volume -> { return Res.get("closedTradesSummaryWindow.totalAmount.value", btcFormatter.formatCoin(totalTradeAmount, true), - DisplayUtils.formatVolumeWithCode(volume)); + VolumeUtil.formatVolumeWithCode(volume)); }) .orElse(""); } @@ -305,7 +306,7 @@ public Map getTotalVolumeByCurrency() { } else { monetary = Fiat.valueOf(currencyCode, entry.getValue()); } - return DisplayUtils.formatVolumeWithCode(new Volume(monetary)); + return VolumeUtil.formatVolumeWithCode(new Volume(monetary)); } )); } diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesViewModel.java b/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesViewModel.java index cf24bb02e8c..7dc54823adb 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesViewModel.java @@ -24,6 +24,7 @@ import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; import bisq.core.util.FormattingUtils; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.CoinFormatter; import com.google.inject.Inject; @@ -37,7 +38,8 @@ class FailedTradesViewModel extends ActivatableWithDataModel accounts, persistenceManager.persistNow(() -> { persistenceManager.shutdown(); new Popup().feedback(Res.get("guiUtil.accountExport.savedToPath", - Paths.get(directory, fileName).toAbsolutePath())) + Paths.get(directory, fileName).toAbsolutePath())) .show(); }); } @@ -801,7 +802,7 @@ public static void showDaoNeedsResyncPopup(Navigation navigation) { .dontShowAgainId(key) .actionButtonTextWithGoTo("navigation.dao.networkMonitor") .onAction(() -> { - navigation.navigateTo(MainView.class, DaoView.class, MonitorView.class, DaoStateMonitorView.class); + navigation.navigateTo(MainView.class, DaoView.class, MonitorView.class, DaoStateMonitorView.class); }) .show(), 5, TimeUnit.SECONDS); } @@ -1172,7 +1173,7 @@ public static String getBsqInUsd(Price bsqPrice, Volume bsqAmountAsVolume = Volume.parse(bsqAmountAsString, "BSQ"); Coin requiredBtc = bsqPrice.getAmountByVolume(bsqAmountAsVolume); Volume volumeByAmount = usdPrice.getVolumeByAmount(requiredBtc); - return DisplayUtils.formatAverageVolumeWithCode(volumeByAmount); + return VolumeUtil.formatAverageVolumeWithCode(volumeByAmount); } public static MaterialDesignIcon getIconForSignState(AccountAgeWitnessService.SignState state) { diff --git a/desktop/src/test/java/bisq/desktop/util/DisplayUtilsTest.java b/desktop/src/test/java/bisq/desktop/util/DisplayUtilsTest.java index 632b49b82a0..3a233ce4ee8 100644 --- a/desktop/src/test/java/bisq/desktop/util/DisplayUtilsTest.java +++ b/desktop/src/test/java/bisq/desktop/util/DisplayUtilsTest.java @@ -4,8 +4,9 @@ import bisq.core.monetary.Volume; import bisq.core.offer.Offer; import bisq.core.offer.OfferPayload; -import bisq.core.util.coin.ImmutableCoinFormatter; +import bisq.core.util.VolumeUtil; import bisq.core.util.coin.CoinFormatter; +import bisq.core.util.coin.ImmutableCoinFormatter; import bisq.common.config.Config; @@ -49,9 +50,9 @@ public void testFormatAccountAge() { @Test public void testFormatVolume() { - assertEquals("1", DisplayUtils.formatVolume(make(btcUsdOffer), true, 4)); - assertEquals("100", DisplayUtils.formatVolume(make(usdVolume))); - assertEquals("1775", DisplayUtils.formatVolume(make(usdVolume.but(with(volumeString, "1774.62"))))); + assertEquals("1", VolumeUtil.formatVolume(make(btcUsdOffer), true, 4)); + assertEquals("100", VolumeUtil.formatVolume(make(usdVolume))); + assertEquals("1775", VolumeUtil.formatVolume(make(usdVolume.but(with(volumeString, "1774.62"))))); } @Test @@ -61,7 +62,7 @@ public void testFormatSameVolume() { when(offer.getMinVolume()).thenReturn(btc); when(offer.getVolume()).thenReturn(btc); - assertEquals("0.10000000", DisplayUtils.formatVolume(offer.getVolume())); + assertEquals("0.10000000", VolumeUtil.formatVolume(offer.getVolume())); } @Test @@ -73,7 +74,7 @@ public void testFormatDifferentVolume() { when(offer.getMinVolume()).thenReturn(btcMin); when(offer.getVolume()).thenReturn(btcMax); - assertEquals("0.10000000 - 0.25000000", DisplayUtils.formatVolume(offer, false, 0)); + assertEquals("0.10000000 - 0.25000000", VolumeUtil.formatVolume(offer, false, 0)); } @Test @@ -82,7 +83,7 @@ public void testFormatNullVolume() { when(offer.getMinVolume()).thenReturn(null); when(offer.getVolume()).thenReturn(null); - assertEquals("", DisplayUtils.formatVolume(offer.getVolume())); + assertEquals("", VolumeUtil.formatVolume(offer.getVolume())); } @Test