Add coloring of decimal places with zero at the end of a number

This commit is contained in:
Christoph Atteneder 2018-02-16 16:55:56 +01:00
parent 022fbb53af
commit 578ab069d8
No known key found for this signature in database
GPG Key ID: CD5DC1C529CDFD3B
3 changed files with 35 additions and 2 deletions

View File

@ -177,6 +177,11 @@ bg color of non edit textFields: fafafa
.warning {
-fx-text-fill: -bs-yellow;
}
.zero-decimals {
-fx-fill: -bs-light-grey;
}
/* Other UI Elements */
.separator {

View File

@ -0,0 +1,22 @@
package io.bisq.gui.components;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.scene.text.TextFlow;
public class ColoredDecimalPlacesWithZerosText extends TextFlow {
public ColoredDecimalPlacesWithZerosText(String number) {
super();
String placesBeforeZero = number.split("0*$")[0];
String zeroDecimalPlaces = number.substring(placesBeforeZero.length());
Text first = new Text(placesBeforeZero);
Text last = new Text(zeroDecimalPlaces);
last.getStyleClass().add("zero-decimals");
setTextAlignment(TextAlignment.CENTER);
setPrefHeight(20);
getChildren().addAll(first, last);
}
}

View File

@ -29,6 +29,7 @@ import io.bisq.gui.common.view.FxmlView;
import io.bisq.gui.components.AutoTooltipButton;
import io.bisq.gui.components.AutoTooltipLabel;
import io.bisq.gui.components.AutoTooltipTableColumn;
import io.bisq.gui.components.ColoredDecimalPlacesWithZerosText;
import io.bisq.gui.main.MainView;
import io.bisq.gui.main.offer.BuyOfferView;
import io.bisq.gui.main.offer.SellOfferView;
@ -54,6 +55,10 @@ import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.scene.text.TextFlow;
import javafx.util.Callback;
import javafx.util.StringConverter;
import org.fxmisc.easybind.EasyBind;
@ -410,8 +415,9 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
@Override
public void updateItem(final OfferListItem offerListItem, boolean empty) {
super.updateItem(offerListItem, empty);
if (offerListItem != null && !empty)
setText(formatter.formatCoin(offerListItem.offer.getAmount(),4));
if (offerListItem != null && !empty) {
setGraphic(new ColoredDecimalPlacesWithZerosText(formatter.formatCoin(offerListItem.offer.getAmount(), 4)));
}
else
setText("");
}