mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Only use additional decimal places for coins when explicitly required
This commit is contained in:
parent
283e7f8c6a
commit
72f1e02271
@ -410,7 +410,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
||||
public void updateItem(final OfferListItem offerListItem, boolean empty) {
|
||||
super.updateItem(offerListItem, empty);
|
||||
if (offerListItem != null && !empty)
|
||||
setText(formatter.formatCoin(offerListItem.offer.getAmount()));
|
||||
setText(formatter.formatCoin(offerListItem.offer.getAmount(),4));
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
@ -418,29 +418,6 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
||||
}
|
||||
});
|
||||
|
||||
// Lets remove that as it is not really relevant and seems to be confusing to some users
|
||||
// accumulated
|
||||
/* TableColumn<OfferListItem, OfferListItem> accumulatedColumn = new AutoTooltipTableColumn<>(Res.get("shared.sumWithCur", Res.getBaseCurrencyCode()));
|
||||
accumulatedColumn.setMinWidth(100);
|
||||
accumulatedColumn.setSortable(false);
|
||||
accumulatedColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
|
||||
accumulatedColumn.setCellFactory(
|
||||
new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {
|
||||
@Override
|
||||
public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, OfferListItem> column) {
|
||||
return new TableCell<OfferListItem, OfferListItem>() {
|
||||
@Override
|
||||
public void updateItem(final OfferListItem offerListItem, boolean empty) {
|
||||
super.updateItem(offerListItem, empty);
|
||||
if (offerListItem != null && !empty)
|
||||
setText(formatter.formatRoundedDoubleWithPrecision(offerListItem.accumulated, 4));
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
*/
|
||||
tableView.getColumns().add(volumeColumn);
|
||||
tableView.getColumns().add(amountColumn);
|
||||
tableView.getColumns().add(priceColumn);
|
||||
|
@ -81,9 +81,21 @@ public class BSFormatter {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String formatCoin(Coin coin) {
|
||||
return formatCoin(coin, -1);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String formatCoin(Coin coin, int decimalPlaces) {
|
||||
final int repetitions = decimalPlaces;
|
||||
|
||||
if (coin != null) {
|
||||
try {
|
||||
return coinFormat.noCode().minDecimals(4).repeatOptionalDecimals(1,4).format(coin).toString();
|
||||
if (decimalPlaces < 0) {
|
||||
return coinFormat.noCode().format(coin).toString();
|
||||
} else {
|
||||
final int decimals = decimalPlaces/repetitions;
|
||||
return coinFormat.noCode().minDecimals(repetitions).repeatOptionalDecimals(decimals, repetitions).format(coin).toString();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
log.warn("Exception at formatBtc: " + t.toString());
|
||||
return "";
|
||||
|
@ -90,7 +90,8 @@ public class BSFormatterTest {
|
||||
|
||||
@Test
|
||||
public void testFormatCoin() {
|
||||
assertEquals("1.0000", formatter.formatCoin(oneBitcoin));
|
||||
assertEquals("1.00", formatter.formatCoin(oneBitcoin));
|
||||
assertEquals("1.0000", formatter.formatCoin(oneBitcoin, 4));
|
||||
assertEquals("0.000001", formatter.formatCoin(make(a(Coin).but(with(satoshis, 100L)))));
|
||||
assertEquals("0.00000001", formatter.formatCoin(make(a(Coin).but(with(satoshis, 1L)))));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user