use of bisq.desktop.components.ColoredDecimalPlacesWithZerosText in project bisq-desktop by bisq-network.
the class OfferBookView method getAmountColumn.
// /////////////////////////////////////////////////////////////////////////////////////////
// Table
// /////////////////////////////////////////////////////////////////////////////////////////
private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> getAmountColumn() {
AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> column = new AutoTooltipTableColumn<>(Res.get("shared.BTCMinMax"), Res.get("shared.amountHelp"));
column.setMinWidth(100);
column.getStyleClass().add("number-column");
column.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
column.setCellFactory(new Callback<TableColumn<OfferBookListItem, OfferBookListItem>, TableCell<OfferBookListItem, OfferBookListItem>>() {
@Override
public TableCell<OfferBookListItem, OfferBookListItem> call(TableColumn<OfferBookListItem, OfferBookListItem> column) {
return new TableCell<OfferBookListItem, OfferBookListItem>() {
@Override
public void updateItem(final OfferBookListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty)
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getAmount(item), GUIUtil.AMOUNT_DECIMALS_WITH_ZEROS));
else
setGraphic(null);
}
};
}
});
return column;
}
use of bisq.desktop.components.ColoredDecimalPlacesWithZerosText in project bisq-desktop by bisq-network.
the class OfferBookView method getVolumeColumn.
private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> getVolumeColumn() {
AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> column = new AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem>("") {
{
setMinWidth(125);
}
};
column.getStyleClass().add("number-column");
column.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
column.setCellFactory(new Callback<TableColumn<OfferBookListItem, OfferBookListItem>, TableCell<OfferBookListItem, OfferBookListItem>>() {
@Override
public TableCell<OfferBookListItem, OfferBookListItem> call(TableColumn<OfferBookListItem, OfferBookListItem> column) {
return new TableCell<OfferBookListItem, OfferBookListItem>() {
private OfferBookListItem offerBookListItem;
final ChangeListener<Number> listener = new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if (offerBookListItem != null && offerBookListItem.getOffer().getVolume() != null) {
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getVolume(offerBookListItem), model.getNumberOfDecimalsForVolume(offerBookListItem)));
model.priceFeedService.updateCounterProperty().removeListener(listener);
}
}
};
@Override
public void updateItem(final OfferBookListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
if (item.getOffer().getPrice() == null) {
this.offerBookListItem = item;
model.priceFeedService.updateCounterProperty().addListener(listener);
setText(Res.get("shared.na"));
setGraphic(null);
} else {
setText("");
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getVolume(item), model.getNumberOfDecimalsForVolume(item)));
}
} else {
if (listener != null)
model.priceFeedService.updateCounterProperty().removeListener(listener);
this.offerBookListItem = null;
setText("");
setGraphic(null);
}
}
};
}
});
return column;
}
use of bisq.desktop.components.ColoredDecimalPlacesWithZerosText in project bisq-desktop by bisq-network.
the class OfferBookChartView method getOfferTable.
private Tuple4<TableView<OfferListItem>, VBox, Button, Label> getOfferTable(OfferPayload.Direction direction) {
TableView<OfferListItem> tableView = new TableView<>();
tableView.setMinHeight(initialOfferTableViewHeight);
tableView.setPrefHeight(121);
tableView.setMinWidth(480);
tableView.getStyleClass().add("offer-table");
// price
TableColumn<OfferListItem, OfferListItem> priceColumn = new TableColumn<>();
priceColumn.textProperty().bind(priceColumnLabel);
priceColumn.setMinWidth(115);
priceColumn.setMaxWidth(115);
priceColumn.setSortable(false);
priceColumn.getStyleClass().add("number-column");
priceColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
priceColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {
@Override
public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, OfferListItem> column) {
return new TableCell<OfferListItem, OfferListItem>() {
private Offer offer;
final ChangeListener<Number> listener = new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if (offer != null && offer.getPrice() != null) {
setText("");
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getPrice(offer), model.getZeroDecimalsForPrice(offer)));
model.priceFeedService.updateCounterProperty().removeListener(listener);
}
}
};
@Override
public void updateItem(final OfferListItem offerListItem, boolean empty) {
super.updateItem(offerListItem, empty);
if (offerListItem != null && !empty) {
final Offer offer = offerListItem.offer;
if (offer.getPrice() == null) {
this.offer = offer;
model.priceFeedService.updateCounterProperty().addListener(listener);
setText(Res.get("shared.na"));
} else {
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getPrice(offer), model.getZeroDecimalsForPrice(offer)));
}
} else {
if (listener != null)
model.priceFeedService.updateCounterProperty().removeListener(listener);
this.offer = null;
setText("");
setGraphic(null);
}
}
};
}
});
// volume
TableColumn<OfferListItem, OfferListItem> volumeColumn = new TableColumn<>();
volumeColumn.setMinWidth(115);
volumeColumn.setSortable(false);
volumeColumn.textProperty().bind(volumeColumnLabel);
volumeColumn.getStyleClass().add("number-column");
volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
volumeColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {
@Override
public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, OfferListItem> column) {
return new TableCell<OfferListItem, OfferListItem>() {
private Offer offer;
final ChangeListener<Number> listener = new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if (offer != null && offer.getPrice() != null) {
setText("");
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getVolume(offer), model.getMaxNumberOfPriceZeroDecimalsToColorize(offer)));
model.priceFeedService.updateCounterProperty().removeListener(listener);
}
}
};
@Override
public void updateItem(final OfferListItem offerListItem, boolean empty) {
super.updateItem(offerListItem, empty);
if (offerListItem != null && !empty) {
this.offer = offerListItem.offer;
if (offer.getPrice() == null) {
this.offer = offerListItem.offer;
model.priceFeedService.updateCounterProperty().addListener(listener);
setText(Res.get("shared.na"));
} else {
setText("");
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getVolume(offer), model.getMaxNumberOfPriceZeroDecimalsToColorize(offer)));
}
} else {
if (listener != null)
model.priceFeedService.updateCounterProperty().removeListener(listener);
this.offer = null;
setText("");
setGraphic(null);
}
}
};
}
});
// amount
TableColumn<OfferListItem, OfferListItem> amountColumn = new AutoTooltipTableColumn<>(Res.get("shared.amountWithCur", Res.getBaseCurrencyCode()));
amountColumn.setMinWidth(115);
amountColumn.setSortable(false);
amountColumn.getStyleClass().add("number-column");
amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
amountColumn.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) {
setGraphic(new ColoredDecimalPlacesWithZerosText(formatter.formatCoin(offerListItem.offer.getAmount(), 4), GUIUtil.AMOUNT_DECIMALS_WITH_ZEROS));
} else {
setGraphic(null);
}
}
};
}
});
tableView.getColumns().add(volumeColumn);
tableView.getColumns().add(amountColumn);
tableView.getColumns().add(priceColumn);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.multipleOffers")));
placeholder.setWrapText(true);
tableView.setPlaceholder(placeholder);
Label titleLabel = new AutoTooltipLabel();
titleLabel.getStyleClass().add("table-title");
UserThread.execute(() -> titleLabel.prefWidthProperty().bind(tableView.widthProperty()));
boolean isSellOffer = direction == OfferPayload.Direction.SELL;
Button button = new AutoTooltipButton();
ImageView iconView = new ImageView();
iconView.setId(isSellOffer ? "image-buy-white" : "image-sell-white");
button.setGraphic(iconView);
button.setGraphicTextGap(10);
button.setText(isSellOffer ? Res.get("market.offerBook.buy") : Res.get("market.offerBook.sell"));
button.setMinHeight(40);
button.setId(isSellOffer ? "buy-button-big" : "sell-button-big");
button.setOnAction(e -> {
if (isSellOffer) {
model.preferences.setBuyScreenCurrencyCode(model.getCurrencyCode());
// noinspection unchecked
navigation.navigateTo(MainView.class, BuyOfferView.class);
} else {
model.preferences.setSellScreenCurrencyCode(model.getCurrencyCode());
// noinspection unchecked
navigation.navigateTo(MainView.class, SellOfferView.class);
}
});
VBox vBox = new VBox();
vBox.setSpacing(10);
vBox.setFillWidth(true);
vBox.setMinHeight(190);
vBox.setVgrow(tableView, Priority.ALWAYS);
vBox.getChildren().addAll(titleLabel, tableView, button);
button.prefWidthProperty().bind(vBox.widthProperty());
return new Tuple4<>(tableView, vBox, button, titleLabel);
}
use of bisq.desktop.components.ColoredDecimalPlacesWithZerosText in project bisq-desktop by bisq-network.
the class SpreadView method getTotalAmountColumn.
private TableColumn<SpreadItem, SpreadItem> getTotalAmountColumn() {
TableColumn<SpreadItem, SpreadItem> column = new TableColumn<SpreadItem, SpreadItem>() {
{
setMinWidth(140);
}
};
column.getStyleClass().add("number-column");
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
column.setCellFactory(new Callback<TableColumn<SpreadItem, SpreadItem>, TableCell<SpreadItem, SpreadItem>>() {
@Override
public TableCell<SpreadItem, SpreadItem> call(TableColumn<SpreadItem, SpreadItem> column) {
return new TableCell<SpreadItem, SpreadItem>() {
@Override
public void updateItem(final SpreadItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty)
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getAmount(item.totalAmount), GUIUtil.AMOUNT_DECIMALS_WITH_ZEROS));
else {
setText("");
setGraphic(null);
}
}
};
}
});
return column;
}
use of bisq.desktop.components.ColoredDecimalPlacesWithZerosText in project bisq-desktop by bisq-network.
the class TradesChartsView method createTable.
// /////////////////////////////////////////////////////////////////////////////////////////
// Table
// /////////////////////////////////////////////////////////////////////////////////////////
private void createTable() {
tableView = new TableView<>();
tableView.setMinHeight(140);
tableView.setPrefHeight(140);
VBox.setVgrow(tableView, Priority.ALWAYS);
// date
TableColumn<TradeStatistics2, TradeStatistics2> dateColumn = new AutoTooltipTableColumn<TradeStatistics2, TradeStatistics2>(Res.get("shared.dateTime")) {
{
setMinWidth(240);
setMaxWidth(240);
}
};
dateColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
dateColumn.setCellFactory(new Callback<TableColumn<TradeStatistics2, TradeStatistics2>, TableCell<TradeStatistics2, TradeStatistics2>>() {
@Override
public TableCell<TradeStatistics2, TradeStatistics2> call(TableColumn<TradeStatistics2, TradeStatistics2> column) {
return new TableCell<TradeStatistics2, TradeStatistics2>() {
@Override
public void updateItem(final TradeStatistics2 item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(formatter.formatDateTime(item.getTradeDate()));
else
setText("");
}
};
}
});
dateColumn.setComparator((o1, o2) -> o1.getTradeDate().compareTo(o2.getTradeDate()));
tableView.getColumns().add(dateColumn);
// market
marketColumn = new AutoTooltipTableColumn<TradeStatistics2, TradeStatistics2>(Res.get("shared.market")) {
{
setMinWidth(130);
setMaxWidth(130);
}
};
marketColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
marketColumn.setCellFactory(new Callback<TableColumn<TradeStatistics2, TradeStatistics2>, TableCell<TradeStatistics2, TradeStatistics2>>() {
@Override
public TableCell<TradeStatistics2, TradeStatistics2> call(TableColumn<TradeStatistics2, TradeStatistics2> column) {
return new TableCell<TradeStatistics2, TradeStatistics2>() {
@Override
public void updateItem(final TradeStatistics2 item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(formatter.getCurrencyPair(item.getCurrencyCode()));
else
setText("");
}
};
}
});
marketColumn.setComparator((o1, o2) -> o1.getTradeDate().compareTo(o2.getTradeDate()));
tableView.getColumns().add(marketColumn);
// price
priceColumn = new TableColumn<>();
priceColumn.getStyleClass().add("number-column");
priceColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
priceColumn.setCellFactory(new Callback<TableColumn<TradeStatistics2, TradeStatistics2>, TableCell<TradeStatistics2, TradeStatistics2>>() {
@Override
public TableCell<TradeStatistics2, TradeStatistics2> call(TableColumn<TradeStatistics2, TradeStatistics2> column) {
return new TableCell<TradeStatistics2, TradeStatistics2>() {
@Override
public void updateItem(final TradeStatistics2 item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(formatter.formatPrice(item.getTradePrice()));
else
setText("");
}
};
}
});
priceColumn.setComparator((o1, o2) -> o1.getTradePrice().compareTo(o2.getTradePrice()));
tableView.getColumns().add(priceColumn);
// amount
TableColumn<TradeStatistics2, TradeStatistics2> amountColumn = new AutoTooltipTableColumn<>(Res.get("shared.amountWithCur", Res.getBaseCurrencyCode()));
amountColumn.getStyleClass().add("number-column");
amountColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
amountColumn.setCellFactory(new Callback<TableColumn<TradeStatistics2, TradeStatistics2>, TableCell<TradeStatistics2, TradeStatistics2>>() {
@Override
public TableCell<TradeStatistics2, TradeStatistics2> call(TableColumn<TradeStatistics2, TradeStatistics2> column) {
return new TableCell<TradeStatistics2, TradeStatistics2>() {
@Override
public void updateItem(final TradeStatistics2 item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setGraphic(new ColoredDecimalPlacesWithZerosText(formatter.formatCoin(item.getTradeAmount(), 4), GUIUtil.AMOUNT_DECIMALS_WITH_ZEROS));
else
setText("");
}
};
}
});
amountColumn.setComparator((o1, o2) -> o1.getTradeAmount().compareTo(o2.getTradeAmount()));
tableView.getColumns().add(amountColumn);
// volume
volumeColumn = new TableColumn<>();
volumeColumn.getStyleClass().add("number-column");
volumeColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
volumeColumn.setCellFactory(new Callback<TableColumn<TradeStatistics2, TradeStatistics2>, TableCell<TradeStatistics2, TradeStatistics2>>() {
@Override
public TableCell<TradeStatistics2, TradeStatistics2> call(TableColumn<TradeStatistics2, TradeStatistics2> column) {
return new TableCell<TradeStatistics2, TradeStatistics2>() {
@Override
public void updateItem(final TradeStatistics2 item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(model.showAllTradeCurrenciesProperty.get() ? formatter.formatVolumeWithCode(item.getTradeVolume()) : formatter.formatVolume(item.getTradeVolume()));
else
setText("");
}
};
}
});
volumeColumn.setComparator((o1, o2) -> {
final Volume tradeVolume1 = o1.getTradeVolume();
final Volume tradeVolume2 = o2.getTradeVolume();
return tradeVolume1 != null && tradeVolume2 != null ? tradeVolume1.compareTo(tradeVolume2) : 0;
});
tableView.getColumns().add(volumeColumn);
// paymentMethod
TableColumn<TradeStatistics2, TradeStatistics2> paymentMethodColumn = new AutoTooltipTableColumn<>(Res.get("shared.paymentMethod"));
paymentMethodColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
paymentMethodColumn.setCellFactory(new Callback<TableColumn<TradeStatistics2, TradeStatistics2>, TableCell<TradeStatistics2, TradeStatistics2>>() {
@Override
public TableCell<TradeStatistics2, TradeStatistics2> call(TableColumn<TradeStatistics2, TradeStatistics2> column) {
return new TableCell<TradeStatistics2, TradeStatistics2>() {
@Override
public void updateItem(final TradeStatistics2 item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(getPaymentMethodLabel(item));
else
setText("");
}
};
}
});
paymentMethodColumn.setComparator((o1, o2) -> getPaymentMethodLabel(o1).compareTo(getPaymentMethodLabel(o2)));
tableView.getColumns().add(paymentMethodColumn);
// direction
TableColumn<TradeStatistics2, TradeStatistics2> directionColumn = new AutoTooltipTableColumn<>(Res.get("shared.offerType"));
directionColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
directionColumn.setCellFactory(new Callback<TableColumn<TradeStatistics2, TradeStatistics2>, TableCell<TradeStatistics2, TradeStatistics2>>() {
@Override
public TableCell<TradeStatistics2, TradeStatistics2> call(TableColumn<TradeStatistics2, TradeStatistics2> column) {
return new TableCell<TradeStatistics2, TradeStatistics2>() {
@Override
public void updateItem(final TradeStatistics2 item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(getDirectionLabel(item));
else
setText("");
}
};
}
});
directionColumn.setComparator((o1, o2) -> getDirectionLabel(o1).compareTo(getDirectionLabel(o2)));
tableView.getColumns().add(directionColumn);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noData"));
placeholder.setWrapText(true);
tableView.setPlaceholder(placeholder);
dateColumn.setSortType(TableColumn.SortType.DESCENDING);
tableView.getSortOrder().add(dateColumn);
}
Aggregations