Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checkbox to hide extreme offers in chart #2884

Merged
merged 4 commits into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ shared.oneOffer=offer
shared.multipleOffers=offers
shared.Offer=Offer
shared.openOffers=open offers
shared.hideExtremes=Hide extremes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the translation as well

shared.trade=trade
shared.trades=trades
shared.openTrades=open trades
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import javafx.scene.control.TableView;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
Expand Down Expand Up @@ -146,14 +147,20 @@ public OfferBookChartView(OfferBookChartViewModel model, Navigation navigation,
public void initialize() {
createListener();

// Header with currency combobox and checkbox to show extreme values
GridPane topGrid = new GridPane();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also remove the additional GridPane again, so we don't use more containers as necessary.


// Currency combobox
final Tuple3<VBox, Label, ComboBox<CurrencyListItem>> currencyComboBoxTuple = addTopLabelComboBox(Res.get("shared.currency"),
Res.get("list.currency.select"), 0);
this.currencyComboBox = currencyComboBoxTuple.third;
this.currencyComboBox.setButtonCell(GUIUtil.getCurrencyListItemButtonCell(Res.get("shared.oneOffer"),
Res.get("shared.multipleOffers"), model.preferences));
this.currencyComboBox.setCellFactory(GUIUtil.getCurrencyListItemCellFactory(Res.get("shared.oneOffer"),
Res.get("shared.multipleOffers"), model.preferences));
topGrid.getChildren().add(currencyComboBoxTuple.first);

// Chart
createChart();

VBox.setMargin(chartPane, new Insets(0, 0, 5, 0));
Expand All @@ -179,8 +186,7 @@ public void initialize() {
tupleSell.second.setUserData(OfferPayload.Direction.SELL.name());
bottomHBox.getChildren().addAll(tupleBuy.second, tupleSell.second);


root.getChildren().addAll(currencyComboBoxTuple.first, chartPane, bottomHBox);
root.getChildren().addAll(topGrid, chartPane, bottomHBox);
}

@Override
Expand Down Expand Up @@ -215,6 +221,7 @@ protected void activate() {
volumeColumnLabel.set(Res.get("shared.amountWithCur", code));
xAxis.setTickLabelFormatter(new StringConverter<>() {
int cryptoPrecision = 3;

@Override
public String toString(Number object) {
final double doubleValue = (double) object;
Expand Down Expand Up @@ -374,18 +381,21 @@ private void updateChartData() {
final Supplier<Optional<? extends XYChart.Data>> optionalMinSupplier = () ->
Optional.of(new XYChart.Data<>(Double.MIN_VALUE, Double.MIN_VALUE));

// Hide buy offers that are more than a factor 5 higher than the lowest buy offer
final Optional<XYChart.Data> buyMaxOptional = model.getBuyData().stream()
.filter(o -> (double) o.getXValue() < (double) buyMinOptional.get().getXValue() * 3)
.max(Comparator.comparingDouble(o -> (double) o.getXValue()))
.or(optionalMinSupplier);

final Optional<XYChart.Data> sellMinOptional = model.getSellData().stream()
.min(Comparator.comparingDouble(o -> (double) o.getXValue()))
.or(optionalMaxSupplier);

final Optional<XYChart.Data> sellMaxOptional = model.getSellData().stream()
.max(Comparator.comparingDouble(o -> (double) o.getXValue()))
.or(optionalMinSupplier);

final Optional<XYChart.Data> sellMinOptional = model.getSellData().stream()
.filter(o -> (double) o.getXValue() > (double) sellMaxOptional.get().getXValue() / 3)
.min(Comparator.comparingDouble(o -> (double) o.getXValue()))
.or(optionalMaxSupplier);

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());

Expand Down
5 changes: 5 additions & 0 deletions desktop/src/main/java/bisq/desktop/util/FormBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -745,9 +745,14 @@ public static CheckBox addCheckBox(GridPane gridPane, int rowIndex, String check
}

public static CheckBox addCheckBox(GridPane gridPane, int rowIndex, String checkBoxTitle, double top) {
return addCheckBox(gridPane, rowIndex, 0, checkBoxTitle, 0);
}

public static CheckBox addCheckBox(GridPane gridPane, int rowIndex, int colIndex, String checkBoxTitle, double top) {
CheckBox checkBox = new AutoTooltipCheckBox(checkBoxTitle);
GridPane.setMargin(checkBox, new Insets(top, 0, 0, 0));
GridPane.setRowIndex(checkBox, rowIndex);
GridPane.setColumnIndex(checkBox, colIndex);
gridPane.getChildren().add(checkBox);
return checkBox;
}
Expand Down