diff --git a/client/src/main/java/envoy/client/ui/custom/ProfilePicImageView.java b/client/src/main/java/envoy/client/ui/custom/ProfilePicImageView.java new file mode 100644 index 0000000..89147d0 --- /dev/null +++ b/client/src/main/java/envoy/client/ui/custom/ProfilePicImageView.java @@ -0,0 +1,62 @@ +package envoy.client.ui.custom; + +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.shape.Rectangle; + +/** + * Displays the profile picture of a user using the superior method of OOP + * instead of boilerplate code. + *
+ * Project: envoy-client
+ * File: ProfilePicImageView.java
+ * Created: 30.07.2020
+ *
+ * @author Leon Hofmeister
+ * @since Envoy Client v0.2-beta
+ */
+public final class ProfilePicImageView extends ImageView {
+
+ /**
+ * Creates a new {@code ProfilePicImageView} without a default image.
+ *
+ * @since Envoy Client v0.2-beta
+ */
+ public ProfilePicImageView() { this(null); }
+
+ /**
+ * Creates a new {@code ProfilePicImageView}.
+ *
+ * @param image the image to display
+ * @since Envoy Client v0.2-beta
+ */
+ public ProfilePicImageView(Image image) { this(image, 40); }
+
+ /**
+ * Creates a new {@code ProfilePicImageView}.
+ *
+ * @param image the image to display
+ * @param sizeAndRounding the size and rounding for a circular
+ * {@code ProfilePicImageView}
+ * @since Envoy Client v0.2-beta
+ */
+ public ProfilePicImageView(Image image, double sizeAndRounding) { this(image, sizeAndRounding, sizeAndRounding); }
+
+ /**
+ * Creates a new {@code ProfilePicImageView}.
+ *
+ * @param image the image to display
+ * @param size the size of this {@code ProfilePicImageView}
+ * @param rounding how rounded this {@code ProfilePicImageView} should be
+ * @since Envoy Client v0.2-beta
+ */
+ public ProfilePicImageView(Image image, double size, double rounding) {
+ super(image);
+ final var clip = new Rectangle();
+ clip.setWidth(size);
+ clip.setHeight(size);
+ clip.setArcHeight(rounding);
+ clip.setArcWidth(rounding);
+ setClip(clip);
+ }
+}
diff --git a/client/src/main/java/envoy/client/ui/custom/package-info.java b/client/src/main/java/envoy/client/ui/custom/package-info.java
new file mode 100644
index 0000000..97a8f58
--- /dev/null
+++ b/client/src/main/java/envoy/client/ui/custom/package-info.java
@@ -0,0 +1,14 @@
+/**
+ * This package stores custom components for use in JavaFX.
+ * These components are also expected to be used via FXML.
+ *
+ * Project: envoy-client
+ * File: package-info.java
+ * Created: 30.07.2020
+ *
+ * @author Leon Hofmeister
+ * @author Maximilian Käfer
+ * @author Kai S. K. Engelbart
+ * @since Envoy Client v0.2-beta
+ */
+package envoy.client.ui.custom;
diff --git a/client/src/main/java/module-info.java b/client/src/main/java/module-info.java
index 1f0d0b1..2b39906 100644
--- a/client/src/main/java/module-info.java
+++ b/client/src/main/java/module-info.java
@@ -20,4 +20,5 @@ module envoy {
opens envoy.client.ui to javafx.graphics, javafx.fxml;
opens envoy.client.ui.controller to javafx.graphics, javafx.fxml;
+ opens envoy.client.ui.custom to javafx.graphics, javafx.fxml;
}