Skip to content

Commit

Permalink
Added javadocs.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemmermann committed Nov 18, 2024
1 parent e01d35d commit 4801a1a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 9 deletions.
5 changes: 5 additions & 0 deletions gemsfx/src/main/java/com/dlsc/gemsfx/AvatarView.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ public AvatarView(String initials) {
setInitials(initials);
}

/**
* Constructs a new avatar view with the given image.
*
* @param image the image to show
*/
public AvatarView(Image image) {
this();
setImage(image);
Expand Down
52 changes: 43 additions & 9 deletions gemsfx/src/main/java/com/dlsc/gemsfx/BeforeAfterView.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,22 @@
import java.util.List;
import java.util.Objects;


/**
* A view capable of managing / displaying two nodes in such a way that the user can show more
* or less of each node at the same time. This is very useful to display before and after scenarios.
*/
public class BeforeAfterView extends Control {

private static final Orientation DEFAULT_ORIENTATION = Orientation.HORIZONTAL;
private static final PseudoClass PSEUDO_CLASS_HORIZONTAL = PseudoClass.getPseudoClass("horizontal");
private static final PseudoClass PSEUDO_CLASS_VERTICAL = PseudoClass.getPseudoClass("vertical");

/**
* Constructs a new view. the two nodes have to be set or bound later.
*
* @see #beforeProperty()
* @see #afterProperty()
*/
public BeforeAfterView() {
getStyleClass().add("before-after-view");

Expand All @@ -53,17 +62,24 @@ public BeforeAfterView() {
updatePseudoClass();
}

private void updatePseudoClass() {
pseudoClassStateChanged(PSEUDO_CLASS_HORIZONTAL, getOrientation().equals(Orientation.HORIZONTAL));
pseudoClassStateChanged(PSEUDO_CLASS_VERTICAL, getOrientation().equals(Orientation.VERTICAL));
}

/**
* Constructs a new view with the given before and after nodes.
*
* @param beforeNode the node showing the "before" state
* @param afterNode the node showing the "after" state
*/
public BeforeAfterView(Node beforeNode, Node afterNode) {
this();
setBefore(beforeNode);
setAfter(afterNode);
}

/**
* Constructs a new view with the given before and after images.
*
* @param beforeImage a "before" image that will be wrapped in an image view
* @param afterImage an "after" image that will be wrapped in an image view
*/
public BeforeAfterView(Image beforeImage, Image afterImage) {
this(new ImageView(beforeImage), new ImageView(afterImage));
}
Expand All @@ -73,6 +89,11 @@ protected Skin<?> createDefaultSkin() {
return new BeforeAfterViewSkin(this);
}

private void updatePseudoClass() {
pseudoClassStateChanged(PSEUDO_CLASS_HORIZONTAL, getOrientation().equals(Orientation.HORIZONTAL));
pseudoClassStateChanged(PSEUDO_CLASS_VERTICAL, getOrientation().equals(Orientation.VERTICAL));
}

@Override
public String getUserAgentStylesheet() {
return Objects.requireNonNull(BeforeAfterView.class.getResource("before-after-view.css")).toExternalForm();
Expand All @@ -84,6 +105,11 @@ public final double getDividerPosition() {
return dividerPosition.get();
}

/**
* Stores the position of the divider within the value range of zero to 1.
*
* @return the divider position
*/
public final DoubleProperty dividerPositionProperty() {
return dividerPosition;
}
Expand All @@ -92,7 +118,6 @@ public final void setDividerPosition(double dividerPosition) {
this.dividerPosition.set(dividerPosition);
}


private final ObjectProperty<Node> before = new SimpleObjectProperty<>(this, "before", new Label("Before"){
{
setPrefSize(600, 400);
Expand All @@ -104,6 +129,11 @@ public final Node getBefore() {
return before.get();
}

/**
* Stores the node used for displaying the "before" state.
*
* @return the node used to visualize "before"
*/
public final ObjectProperty<Node> beforeProperty() {
return before;
}
Expand All @@ -124,6 +154,11 @@ public final Node getAfter() {
return after.get();
}

/**
* Stores the node used for displaying the "after" state.
*
* @return the node used to visualize "after"
*/
public final ObjectProperty<Node> afterProperty() {
return after;
}
Expand All @@ -139,7 +174,7 @@ public final Orientation getOrientation() {
}

/**
* Sets the orientation of the before-after view.
* Sets the orientation of the before / after view.
* <p>
* Default value is {@link Orientation#HORIZONTAL}
*
Expand Down Expand Up @@ -209,5 +244,4 @@ public StyleableProperty<Orientation> getStyleableProperty(BeforeAfterView view)
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
return BeforeAfterView.StyleableProperties.STYLEABLES;
}

}

0 comments on commit 4801a1a

Please sign in to comment.