mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Improve resizing of buy and sell tables
This commit is contained in:
parent
852a1df70f
commit
cb3fa50f22
1 changed files with 15 additions and 9 deletions
|
@ -90,6 +90,7 @@ import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import static bisq.desktop.util.FormBuilder.addTopLabelComboBox;
|
import static bisq.desktop.util.FormBuilder.addTopLabelComboBox;
|
||||||
import static bisq.desktop.util.Layout.INITIAL_WINDOW_HEIGHT;
|
import static bisq.desktop.util.Layout.INITIAL_WINDOW_HEIGHT;
|
||||||
|
@ -118,18 +119,17 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
||||||
private HBox bottomHBox;
|
private HBox bottomHBox;
|
||||||
private ListChangeListener<OfferBookListItem> changeListener;
|
private ListChangeListener<OfferBookListItem> changeListener;
|
||||||
private ListChangeListener<CurrencyListItem> currencyListItemsListener;
|
private ListChangeListener<CurrencyListItem> currencyListItemsListener;
|
||||||
private final double initialOfferTableViewHeight = 109;
|
private final double initialOfferTableViewHeight = 121;
|
||||||
private final double pixelsPerOfferTableRow = (initialOfferTableViewHeight / 4.0) + 10.0; // initial visible row count=4
|
private final double pixelsPerOfferTableRow = (initialOfferTableViewHeight - 30) / 5.0; // initial visible row count=5, header height=30
|
||||||
private final Function<Double, Double> offerTableViewHeight = (screenSize) -> {
|
private final Function<Double, Double> offerTableViewHeight = (screenSize) -> {
|
||||||
int extraRows = screenSize <= INITIAL_WINDOW_HEIGHT ? 0 : (int) ((screenSize - INITIAL_WINDOW_HEIGHT) / pixelsPerOfferTableRow);
|
int extraRows = screenSize <= INITIAL_WINDOW_HEIGHT ? 0 : (int) ((screenSize - INITIAL_WINDOW_HEIGHT) / pixelsPerOfferTableRow);
|
||||||
return extraRows == 0 ? initialOfferTableViewHeight : Math.ceil(initialOfferTableViewHeight + (extraRows * pixelsPerOfferTableRow));
|
return extraRows == 0 ? initialOfferTableViewHeight : Math.ceil(initialOfferTableViewHeight + ((extraRows + 1) * pixelsPerOfferTableRow));
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor, lifecycle
|
// Constructor, lifecycle
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
|
||||||
@Inject
|
@Inject
|
||||||
public OfferBookChartView(OfferBookChartViewModel model, Navigation navigation, BSFormatter formatter,
|
public OfferBookChartView(OfferBookChartViewModel model, Navigation navigation, BSFormatter formatter,
|
||||||
@Named(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) {
|
@Named(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) {
|
||||||
|
@ -338,21 +338,27 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
||||||
seriesSell.getData().clear();
|
seriesSell.getData().clear();
|
||||||
areaChart.getData().clear();
|
areaChart.getData().clear();
|
||||||
|
|
||||||
|
final Supplier<Optional<? extends XYChart.Data>> optionalMaxSupplier = () ->
|
||||||
|
Optional.of(new XYChart.Data<>(Double.MAX_VALUE, Double.MAX_VALUE));
|
||||||
|
|
||||||
final Optional<XYChart.Data> buyMinOptional = model.getBuyData().stream()
|
final Optional<XYChart.Data> buyMinOptional = model.getBuyData().stream()
|
||||||
.min(Comparator.comparingDouble(o -> (double) o.getXValue()))
|
.min(Comparator.comparingDouble(o -> (double) o.getXValue()))
|
||||||
.or(() -> Optional.of(new XYChart.Data<>(Double.MAX_VALUE, Double.MAX_VALUE)));
|
.or(optionalMaxSupplier);
|
||||||
|
|
||||||
|
final Supplier<Optional<? extends XYChart.Data>> optionalMinSupplier = () ->
|
||||||
|
Optional.of(new XYChart.Data<>(Double.MIN_VALUE, Double.MIN_VALUE));
|
||||||
|
|
||||||
final Optional<XYChart.Data> buyMaxOptional = model.getBuyData().stream()
|
final Optional<XYChart.Data> buyMaxOptional = model.getBuyData().stream()
|
||||||
.max(Comparator.comparingDouble(o -> (double) o.getXValue()))
|
.max(Comparator.comparingDouble(o -> (double) o.getXValue()))
|
||||||
.or(() -> Optional.of(new XYChart.Data<>(Double.MIN_VALUE, Double.MIN_VALUE)));
|
.or(optionalMinSupplier);
|
||||||
|
|
||||||
final Optional<XYChart.Data> sellMinOptional = model.getSellData().stream()
|
final Optional<XYChart.Data> sellMinOptional = model.getSellData().stream()
|
||||||
.min(Comparator.comparingDouble(o -> (double) o.getXValue()))
|
.min(Comparator.comparingDouble(o -> (double) o.getXValue()))
|
||||||
.or(() -> Optional.of(new XYChart.Data<>(Double.MAX_VALUE, Double.MAX_VALUE)));
|
.or(optionalMaxSupplier);
|
||||||
|
|
||||||
final Optional<XYChart.Data> sellMaxOptional = model.getSellData().stream()
|
final Optional<XYChart.Data> sellMaxOptional = model.getSellData().stream()
|
||||||
.max(Comparator.comparingDouble(o -> (double) o.getXValue()))
|
.max(Comparator.comparingDouble(o -> (double) o.getXValue()))
|
||||||
.or(() -> Optional.of(new XYChart.Data<>(Double.MIN_VALUE, Double.MIN_VALUE)));
|
.or(optionalMinSupplier);
|
||||||
|
|
||||||
final double minValue = Double.min((double) buyMinOptional.get().getXValue(), (double) sellMinOptional.get().getXValue());
|
final double minValue = Double.min((double) buyMinOptional.get().getXValue(), (double) sellMinOptional.get().getXValue());
|
||||||
final double maxValue = Double.max((double) buyMaxOptional.get().getXValue(), (double) sellMaxOptional.get().getXValue());
|
final double maxValue = Double.max((double) buyMaxOptional.get().getXValue(), (double) sellMaxOptional.get().getXValue());
|
||||||
|
@ -376,7 +382,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
||||||
private Tuple4<TableView<OfferListItem>, VBox, Button, Label> getOfferTable(OfferPayload.Direction direction) {
|
private Tuple4<TableView<OfferListItem>, VBox, Button, Label> getOfferTable(OfferPayload.Direction direction) {
|
||||||
TableView<OfferListItem> tableView = new TableView<>();
|
TableView<OfferListItem> tableView = new TableView<>();
|
||||||
tableView.setMinHeight(initialOfferTableViewHeight);
|
tableView.setMinHeight(initialOfferTableViewHeight);
|
||||||
tableView.setPrefHeight(121);
|
tableView.setPrefHeight(initialOfferTableViewHeight);
|
||||||
tableView.setMinWidth(480);
|
tableView.setMinWidth(480);
|
||||||
tableView.getStyleClass().add("offer-table");
|
tableView.getStyleClass().add("offer-table");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue