From 9cabc21cae2f55f940dfa7fe0b2c5603eb6d877e Mon Sep 17 00:00:00 2001 From: 0xboobface <0xboobface@gmail.com> Date: Sun, 25 Nov 2018 15:57:13 +0100 Subject: [PATCH] Don't show images in DEV mode --- .../ui/controls/SearchPopoverTreeList.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/client/src/main/java/ctbrec/ui/controls/SearchPopoverTreeList.java b/client/src/main/java/ctbrec/ui/controls/SearchPopoverTreeList.java index 722cca72..206a3855 100644 --- a/client/src/main/java/ctbrec/ui/controls/SearchPopoverTreeList.java +++ b/client/src/main/java/ctbrec/ui/controls/SearchPopoverTreeList.java @@ -31,6 +31,8 @@ */ package ctbrec.ui.controls; +import java.net.URL; +import java.util.Objects; import java.util.Optional; import org.slf4j.Logger; @@ -53,6 +55,7 @@ import javafx.scene.control.Skin; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.MouseEvent; +import javafx.scene.shape.Rectangle; /** * Popover page that displays a list of samples and sample categories for a given SampleCategory. @@ -161,8 +164,13 @@ public class SearchPopoverTreeList extends PopoverTreeList implements Pop getStyleClass().remove("highlight"); title.getStyleClass().remove("highlight"); }); + + Rectangle clip = new Rectangle(thumbSize, thumbSize); + clip.setArcWidth(20); + clip.arcHeightProperty().bind(clip.arcWidthProperty()); thumb.setFitWidth(thumbSize); thumb.setFitHeight(thumbSize); + thumb.setClip(clip); follow = new Button("Follow"); follow.setOnAction((evt) -> { @@ -223,9 +231,15 @@ public class SearchPopoverTreeList extends PopoverTreeList implements Pop title.setVisible(true); title.setText(model.getName()); this.model = model; - String previewUrl = Optional.ofNullable(model.getPreview()).orElse(getClass().getResource("/anonymous.png").toString()); - Image img = new Image(previewUrl, true); - thumb.setImage(img); + URL anonymousPng = getClass().getResource("/anonymous.png"); + String previewUrl = Optional.ofNullable(model.getPreview()).orElse(anonymousPng.toString()); + if(!Objects.equals(System.getenv("CTBREC_DEV"), "1")) { + Image img = new Image(previewUrl, true); + thumb.setImage(img); + } else { + Image img = new Image(anonymousPng.toString(), true); + thumb.setImage(img); + } } }