Added OOP approach to some boilerplate code currently implemented

@DieGurke,as I don't want to interfere with your branch at all, I only
added the absolute minimum that should be mergeable without conflict.
I leave the rest of the implementation (usage in ChatScene, ChatControl
and referencing in FXML) up to you.
There's no way in hell I'll risk your wrath...
This commit is contained in:
delvh 2020-07-30 20:46:28 +02:00
parent 9234e23fae
commit 98ebb321ce
3 changed files with 77 additions and 0 deletions

View File

@ -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.
* <p>
* Project: <strong>envoy-client</strong><br>
* File: <strong>ProfilePicImageView.java</strong><br>
* Created: <strong>30.07.2020</strong><br>
*
* @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);
}
}

View File

@ -0,0 +1,14 @@
/**
* This package stores custom components for use in JavaFX.
* These components are also expected to be used via FXML.
* <p>
* Project: <strong>envoy-client</strong><br>
* File: <strong>package-info.java</strong><br>
* Created: <strong>30.07.2020</strong><br>
*
* @author Leon Hofmeister
* @author Maximilian K&auml;fer
* @author Kai S. K. Engelbart
* @since Envoy Client v0.2-beta
*/
package envoy.client.ui.custom;

View File

@ -20,4 +20,5 @@ module envoy {
opens envoy.client.ui to javafx.graphics, javafx.fxml; opens envoy.client.ui to javafx.graphics, javafx.fxml;
opens envoy.client.ui.controller 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;
} }