Skip to content

Commit 4bedf75

Browse files
committed
use stackpane for currency icons
1 parent 1e756a3 commit 4bedf75

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

desktop/src/main/java/haveno/desktop/util/GUIUtil.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,10 @@ protected void updateItem(CurrencyListItem item, boolean empty) {
350350
default:
351351

352352
// use icon if available
353-
ImageView currencyIcon = getCurrencyIcon(code);
353+
StackPane currencyIcon = getCurrencyIcon(code);
354354
if (currencyIcon != null) {
355355
label1.setText("");
356-
StackPane iconWrapper = new StackPane(currencyIcon); // TODO: icon must be wrapped in StackPane for reliable rendering on linux
357-
label1.setGraphic(iconWrapper);
356+
label1.setGraphic(currencyIcon);
358357
}
359358

360359
if (preferences.isSortMarketCurrenciesNumerically() && item.numTrades > 0) {
@@ -461,11 +460,10 @@ protected void updateItem(TradeCurrency item, boolean empty) {
461460
default:
462461

463462
// use icon if available
464-
ImageView currencyIcon = getCurrencyIcon(code);
463+
StackPane currencyIcon = getCurrencyIcon(code);
465464
if (currencyIcon != null) {
466465
label1.setText("");
467-
StackPane iconWrapper = new StackPane(currencyIcon); // TODO: icon must be wrapped in StackPane for reliable rendering on linux
468-
label1.setGraphic(iconWrapper);
466+
label1.setGraphic(currencyIcon);
469467
}
470468

471469
boolean isCrypto = CurrencyUtil.isCryptoCurrency(code);
@@ -506,11 +504,10 @@ protected void updateItem(TradeCurrency item, boolean empty) {
506504
label2.getStyleClass().add("currency-label");
507505

508506
// use icon if available
509-
ImageView currencyIcon = getCurrencyIcon(item.getCode());
507+
StackPane currencyIcon = getCurrencyIcon(item.getCode());
510508
if (currencyIcon != null) {
511509
label1.setText("");
512-
StackPane iconWrapper = new StackPane(currencyIcon); // TODO: icon must be wrapped in StackPane for reliable rendering on linux
513-
label1.setGraphic(iconWrapper);
510+
label1.setGraphic(currencyIcon);
514511
}
515512

516513
box.getChildren().addAll(label1, label2);
@@ -1283,11 +1280,11 @@ private static <T> void updateEdgeColumnStyleClasses(TableView<T> tableView) {
12831280
return contentColumns;
12841281
}
12851282

1286-
public static ImageView getCurrencyIcon(String currencyCode) {
1287-
return getCurrencyIcon(currencyCode, 24);
1283+
private static ImageView getCurrencyImageView(String currencyCode) {
1284+
return getCurrencyImageView(currencyCode, 24);
12881285
}
12891286

1290-
public static ImageView getCurrencyIcon(String currencyCode, double size) {
1287+
private static ImageView getCurrencyImageView(String currencyCode, double size) {
12911288
if (currencyCode == null) return null;
12921289
String imageId = getImageId(currencyCode);
12931290
if (imageId == null) return null;
@@ -1300,19 +1297,24 @@ public static ImageView getCurrencyIcon(String currencyCode, double size) {
13001297
return iconView;
13011298
}
13021299

1300+
public static StackPane getCurrencyIcon(String currencyCode) {
1301+
return new StackPane(getCurrencyImageView(currencyCode));
1302+
}
1303+
1304+
public static StackPane getCurrencyIcon(String currencyCode, double size) {
1305+
return new StackPane(getCurrencyImageView(currencyCode, size));
1306+
}
1307+
13031308
public static StackPane getCurrencyIconWithBorder(String currencyCode) {
13041309
return getCurrencyIconWithBorder(currencyCode, 25, 1);
13051310
}
13061311

13071312
public static StackPane getCurrencyIconWithBorder(String currencyCode, double size, double borderWidth) {
13081313
if (currencyCode == null) return null;
13091314

1310-
ImageView icon = getCurrencyIcon(currencyCode, size);
1315+
ImageView icon = getCurrencyImageView(currencyCode, size);
13111316
icon.setFitWidth(size - 2 * borderWidth);
13121317
icon.setFitHeight(size - 2 * borderWidth);
1313-
icon.setPreserveRatio(true);
1314-
icon.setSmooth(true);
1315-
icon.setCache(true);
13161318

13171319
StackPane circleWrapper = new StackPane(icon);
13181320
circleWrapper.setPrefSize(size, size);

0 commit comments

Comments
 (0)