public class Rating
extends javafx.scene.control.Control
partial ratings (i.e. not whole numbers and
dependent upon where the user clicks in the control) and
updating the rating on hover. Read on for
more examples!
To create a Rating control that looks like this is simple:
final Rating rating = new Rating();
This creates a default horizontal rating control.
One of the features of the Rating control is that it doesn't just allow for 'integer' ratings: it also allows for the user to click anywhere within the rating area to set a 'float' rating. This is hard to describe, but easy to show in a picture:
In essence, in the screenshot above, the user clicked roughly in the
middle of the third star. This results in a rating of approximately 2.44.
To enable partial ratings, simply do the
following when instantiating the Rating control:
final Rating rating = new Rating();
rating.setPartialRating(true);
So far all of the Rating controls demonstrated above have
required the user to click on the stars to register their rating. This may not
be the preferred user interaction - often times the preferred approach is to
simply allow for the rating to be registered by the user hovering their mouse
over the rating stars. This mode is also supported by the Rating control,
using the update on hover property, as such:
final Rating rating = new Rating();
rating.setUpdateOnHover(true);
It is also allowable to have a Rating control that both updates on hover and allows for partial values: the 'golden fill' of the default graphics will automatically follow the users mouse as they move it along the Rating scale. To enable this, just set both properties to true.
| Type | Property | Description |
|---|---|---|
javafx.beans.property.IntegerProperty |
max |
The maximum-allowed rating value.
|
javafx.beans.property.ObjectProperty<javafx.geometry.Orientation> |
orientation |
The
Orientation of the Rating - this can either be
horizontal or vertical. |
javafx.beans.property.BooleanProperty |
partialRating |
If true this allows for users to set a rating as a floating point value.
|
javafx.beans.property.DoubleProperty |
rating |
The current rating value of the Rating control.
|
javafx.beans.property.BooleanProperty |
updateOnHover |
If true this allows for the
rating property to
be updated simply by the user hovering their mouse over the control. |
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible| Constructor | Description |
|---|---|
Rating() |
Creates a default instance with a minimum rating of 0 and a maximum
rating of 5.
|
Rating(int max) |
Creates a default instance with a minimum rating of 0 and a maximum rating
as provided by the argument.
|
Rating(int max,
int rating) |
Creates a Rating instance with a minimum rating of 0, a maximum rating
as provided by the
max argument, and a current rating as provided
by the rating argument. |
| Modifier and Type | Method | Description |
|---|---|---|
protected javafx.scene.control.Skin<?> |
createDefaultSkin() |
|
int |
getMax() |
Gets the value of the property max.
|
javafx.geometry.Orientation |
getOrientation() |
Gets the value of the property orientation.
|
double |
getRating() |
Gets the value of the property rating.
|
boolean |
isPartialRating() |
Gets the value of the property partialRating.
|
boolean |
isUpdateOnHover() |
Gets the value of the property updateOnHover.
|
javafx.beans.property.IntegerProperty |
maxProperty() |
The maximum-allowed rating value.
|
javafx.beans.property.ObjectProperty<javafx.geometry.Orientation> |
orientationProperty() |
The
Orientation of the Rating - this can either be
horizontal or vertical. |
javafx.beans.property.BooleanProperty |
partialRatingProperty() |
If true this allows for users to set a rating as a floating point value.
|
javafx.beans.property.DoubleProperty |
ratingProperty() |
The current rating value of the Rating control.
|
void |
setMax(int value) |
Sets the value of the property max.
|
void |
setOrientation(javafx.geometry.Orientation value) |
Sets the value of the property orientation.
|
void |
setPartialRating(boolean value) |
Sets the value of the property partialRating.
|
void |
setRating(double value) |
Sets the value of the property rating.
|
void |
setUpdateOnHover(boolean value) |
Sets the value of the property updateOnHover.
|
javafx.beans.property.BooleanProperty |
updateOnHoverProperty() |
If true this allows for the
rating property to
be updated simply by the user hovering their mouse over the control. |
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getClassCssMetaData, getContextMenu, getControlCssMetaData, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, layoutChildren, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinProperty, tooltipPropertyaccessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visiblePropertyclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBoundsbackgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthPropertypublic final javafx.beans.property.DoubleProperty ratingProperty
getRating(),
setRating(double)public final javafx.beans.property.IntegerProperty maxProperty
getMax(),
setMax(int)public final javafx.beans.property.ObjectProperty<javafx.geometry.Orientation> orientationProperty
Orientation of the Rating - this can either be
horizontal or vertical.Orientation.HORIZONTALgetOrientation(),
setOrientation(Orientation)public final javafx.beans.property.BooleanProperty partialRatingProperty
isPartialRating(),
setPartialRating(boolean)public final javafx.beans.property.BooleanProperty updateOnHoverProperty
rating property to
be updated simply by the user hovering their mouse over the control. If
false the user is required to click on their preferred rating to register
the new rating with this control.isUpdateOnHover(),
setUpdateOnHover(boolean)public Rating()
public Rating(int max)
max - The maximum allowed rating value.public Rating(int max,
int rating)
max argument, and a current rating as provided
by the rating argument.max - The maximum allowed rating value.rating - The current rating.protected javafx.scene.control.Skin<?> createDefaultSkin()
createDefaultSkin in class javafx.scene.control.Controlpublic final javafx.beans.property.DoubleProperty ratingProperty()
getRating(),
setRating(double)public final void setRating(double value)
public final double getRating()
public final javafx.beans.property.IntegerProperty maxProperty()
getMax(),
setMax(int)public final void setMax(int value)
public final int getMax()
public final javafx.beans.property.ObjectProperty<javafx.geometry.Orientation> orientationProperty()
Orientation of the Rating - this can either be
horizontal or vertical.Orientation.HORIZONTALgetOrientation(),
setOrientation(Orientation)public final void setOrientation(javafx.geometry.Orientation value)
Orientation of the Rating - this can either be
horizontal or vertical.Orientation.HORIZONTALpublic final javafx.geometry.Orientation getOrientation()
Orientation of the Rating - this can either be
horizontal or vertical.Orientation.HORIZONTALpublic final javafx.beans.property.BooleanProperty partialRatingProperty()
isPartialRating(),
setPartialRating(boolean)public final void setPartialRating(boolean value)
public final boolean isPartialRating()
public final javafx.beans.property.BooleanProperty updateOnHoverProperty()
rating property to
be updated simply by the user hovering their mouse over the control. If
false the user is required to click on their preferred rating to register
the new rating with this control.isUpdateOnHover(),
setUpdateOnHover(boolean)public final void setUpdateOnHover(boolean value)
rating property to
be updated simply by the user hovering their mouse over the control. If
false the user is required to click on their preferred rating to register
the new rating with this control.public final boolean isUpdateOnHover()
rating property to
be updated simply by the user hovering their mouse over the control. If
false the user is required to click on their preferred rating to register
the new rating with this control.