use of javafx.collections.transformation.SortedList in project bitsquare by bitsquare.
the class TradesChartsView method activate.
@Override
protected void activate() {
// root.getParent() is null at initialize
tabPaneSelectionModel = GUIUtil.getParentOfType(root, TabPane.class).getSelectionModel();
selectedTabIndexListener = (observable, oldValue, newValue) -> model.setSelectedTabIndex((int) newValue);
model.setSelectedTabIndex(tabPaneSelectionModel.getSelectedIndex());
tabPaneSelectionModel.selectedIndexProperty().addListener(selectedTabIndexListener);
currencyComboBox.setItems(model.getCurrencyListItems());
currencyComboBox.setVisibleRowCount(25);
if (model.showAllTradeCurrenciesProperty.get())
currencyComboBox.getSelectionModel().select(0);
else if (model.getSelectedCurrencyListItem().isPresent())
currencyComboBox.getSelectionModel().select(model.getSelectedCurrencyListItem().get());
currencyComboBox.setOnAction(e -> {
CurrencyListItem selectedItem = currencyComboBox.getSelectionModel().getSelectedItem();
if (selectedItem != null)
model.onSetTradeCurrency(selectedItem.tradeCurrency);
});
toggleGroup.getToggles().get(model.tickUnit.ordinal()).setSelected(true);
model.priceItems.addListener(itemsChangeListener);
toggleGroup.selectedToggleProperty().addListener(timeUnitChangeListener);
priceAxisY.widthProperty().addListener(priceAxisYWidthListener);
volumeAxisY.widthProperty().addListener(volumeAxisYWidthListener);
model.tradeStatisticsByCurrency.addListener(tradeStatisticsByCurrencyListener);
priceAxisY.labelProperty().bind(priceColumnLabel);
priceColumn.textProperty().bind(priceColumnLabel);
currencySelectionBinding = EasyBind.combine(model.showAllTradeCurrenciesProperty, model.selectedTradeCurrencyProperty, (showAll, selectedTradeCurrency) -> {
priceChart.setVisible(!showAll);
priceChart.setManaged(!showAll);
priceColumn.setSortable(!showAll);
if (showAll) {
volumeColumn.setText("Amount");
priceColumnLabel.set("Price");
if (!tableView.getColumns().contains(marketColumn))
tableView.getColumns().add(1, marketColumn);
} else {
priceSeries.setName(selectedTradeCurrency.getName());
String code = selectedTradeCurrency.getCode();
volumeColumn.setText("Amount in " + code);
priceColumnLabel.set(formatter.getPriceWithCurrencyCode(code));
if (tableView.getColumns().contains(marketColumn))
tableView.getColumns().remove(marketColumn);
}
return null;
});
currencySelectionSubscriber = currencySelectionBinding.subscribe((observable, oldValue, newValue) -> {
});
sortedList = new SortedList<>(model.tradeStatisticsByCurrency);
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
tableView.setItems(sortedList);
priceChart.setAnimated(model.preferences.getUseAnimations());
volumeChart.setAnimated(model.preferences.getUseAnimations());
priceAxisX.setTickLabelFormatter(getTimeAxisStringConverter());
volumeAxisX.setTickLabelFormatter(getTimeAxisStringConverter());
nrOfTradeStatisticsLabel.setText("Trades: " + model.tradeStatisticsByCurrency.size());
UserThread.runAfter(this::updateChartData, 100, TimeUnit.MILLISECONDS);
}
Aggregations