ResourceNode
class ResourceNode
Extends: Node
Package: dev.joid.lib.ui.node.impl.resource · Module: core · Source: ResourceNode.java
Draws an image resource in its bounds, tinted by a color, with an optional image that fades in on hover.
Description
Section titled “Description”The node waits for its resource: it draws its skeleton until the image is loaded. Without a declared size it takes the size of the image; with one declared size, it keeps the ratio of the image on the other axis. A resource that fails to load takes 64 × 64 design pixels when no size is declared, and draws a magenta and black checkerboard there in dev mode, nothing in production.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
ResourceNode | create(double x, double y) factory | Creates an image node at x, y that takes the size of its image. |
ResourceNode | create(double x, double y, double width, double height) factory | Creates an image node with a declared size; a size of 0 on an axis follows the ratio of the image. |
| ResourceNode(double x, double y, double width, double height) protected | Called by a subclass with the same arguments as create. |
Properties
Section titled “Properties”| Property | Type | Default | Summary |
|---|---|---|---|
| resource signal | Resource | null | The image to draw. |
| hoveredResource signal | Resource | null | Image that fades in over the first one while the node is hovered; null keeps the image on hover. |
| color signal | Color | Color.WHITE | Tint multiplied with the image; white draws the image as it is. |
| hoveredColor signal | Color | none, the tint stays the same on hover | Tint while the node is hovered, reached with the hover progress; null keeps the tint. |
| linear signal | boolean | the filtering of the resource | If true, the image is smoothed when scaled; if false, its pixels stay sharp; null keeps the filtering of the resource. |
| stretch signal | StretchType | StretchType.STRETCH | How the image fills the bounds when their ratio differs from the ratio of the image. |
Inherited from Node (24)
x · y · width · height · position · anchor · anchorX · anchorY · aspectRatio · zindex · zlevel · skeleton · visible · enabled · interactive · cursor · hoverDuration · hoverEquation · hover · overflow · scrollSpeed · scrollbar · label · draggable
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
Resource | getFilteredResource() | The resource drawn for resource, a copy with the filtering of linear when it is set. |
Resource | getFilteredHoveredResource() | The resource drawn for hoveredResource, a copy with the filtering of linear when it is set. |
For subclasses
Section titled “For subclasses”| Returns | Signature | Summary |
|---|---|---|
void | update() hook | Measures the image on every frame, so that the node takes its size as soon as it loads. |
void | draw(double mouseX, double mouseY) hook | Draws the image, tinted, then the hovered image faded by the hover progress. |
Inherited from Node (128)
load · render · renderHover · updateScroll · updateScrollX · updateScrollY · append · attach · body · clearChildren · getChild · getChildren · getNodeListAt · getParent · isAttached · getAbsoluteX · getAbsoluteY · getAbsoluteDefaultX · getAbsoluteDefaultY · toDrawX · toDrawY · w · h · dw · dh · mw · mh · aw · ah · ax · ay · getDefaultWidth · getDefaultHeight · removeHover · clearHover · refreshHover · getResolvedCursor · hoverValue · getHoverAnimator · isHovered · handleMousePressed · handleMouseReleased · handleMouseDragged · handleMouseScroll · handleCharTyped · handleKeyPressed · handleKeyReleased · getLastClickTime · getLastClickButton · getLastKey · getLastKeyTime · scrollX · scrollY · scrollTo · beforeScroll · hasOverflowX · hasOverflowY · getOverflowArea · getScrollX · getScrollY · getTargetScrollX · getTargetScrollY · getMaxScrollX · getMaxScrollY · isScrollEndX · isScrollEndY · startDragging · stopDragging · beforeDragStart · beforeDragDrop · isDragging · getDragX · getDragY · isDragged · getDragSource · getDraggedNode · getStartDragX · getStartDragY · getTargetDragX · getTargetDragY · effect · removeEffect · clearEffects · hasEffect · getEffect · layer · clearLayers · animate · removeAnimator · wait · watch · hasListener · isVisibleProperty · isMounted · getIndex · getUi · getHierarchy · getMappedIndex · getTaskList · getShortcutList · toJson · toString · getEventBus · getBodyConsumer · getDefaultX · getDefaultY · getLayoutX · getLayoutY · getShiftX · getShiftY · isStepping · getLastCodepoint · getLoadCount · getRenderTime · remove · self · copy · useStore · addTask · removeTask · addShortcut · removeShortcut · layoutPosition · layoutSize · fit · move · beforeMove · hoverColor
Events
Section titled “Events”Inherited from Node (21)
onUpdate · onDetach · onInit · onRender · onDraw · onMount · onHoverStart · onHover · onHoverEnd · onScroll · onScrollToEnd · onScrollEndReached · onDragStart · onDrag · onDragDrop · onDragSnap · onMove · onChildAppend · onClick · onAnimate · onWatch
Creation details
Section titled “Creation details”create
Section titled “create”ResourceNode create(double x, double y) factory
Creates an image node at x, y that takes the size of its image.
ResourceNode create(double x, double y, double width, double height) factory
Creates an image node with a declared size; a size of 0 on an axis follows the ratio of the image.
ResourceNode
Section titled “ResourceNode”ResourceNode(double x, double y, double width, double height) protected
Called by a subclass with the same arguments as create.
Property details
Section titled “Property details”resource
Section titled “resource”this resource(Resource resource)fluentthis resource(Supplier<Resource> resource)fluent signalResource getResource()
Default: null
The image to draw.
Throws an IllegalStateException when the node is attached without one.
hoveredResource
Section titled “hoveredResource”this hoveredResource(Resource hoveredResource)fluentthis hoveredResource(Supplier<Resource> hoveredResource)fluent signalResource getHoveredResource()
Default: null
Image that fades in over the first one while the node is hovered; null keeps the image on hover.
this color(Color color)fluentthis color(Supplier<Color> color)fluent signalColor getColor()
Default: Color.WHITE
Tint multiplied with the image; white draws the image as it is.
hoveredColor
Section titled “hoveredColor”this hoveredColor(Color hoveredColor)fluentthis hoveredColor(Supplier<Color> hoveredColor)fluent signalColor getHoveredColor()
Default: none, the tint stays the same on hover
Tint while the node is hovered, reached with the hover progress; null keeps the tint.
linear
Section titled “linear”this linear(boolean linear)fluentthis linear(Supplier<Boolean> linear)fluent signalBoolean getLinear()
Default: the filtering of the resource
If true, the image is smoothed when scaled; if false, its pixels stay sharp; null keeps the filtering of the resource.
stretch
Section titled “stretch”this stretch(StretchType stretch)fluentthis stretch(Supplier<StretchType> stretch)fluent signalStretchType getStretch()
Default: StretchType.STRETCH
How the image fills the bounds when their ratio differs from the ratio of the image.
Method details
Section titled “Method details”getFilteredResource
Section titled “getFilteredResource”Resource getFilteredResource()
The resource drawn for resource, a copy with the filtering of linear when it is set.
getFilteredHoveredResource
Section titled “getFilteredHoveredResource”Resource getFilteredHoveredResource()
The resource drawn for hoveredResource, a copy with the filtering of linear when it is set.
update
Section titled “update”void update() hook
Measures the image on every frame, so that the node takes its size as soon as it loads.
void draw(double mouseX, double mouseY) hook
Draws the image, tinted, then the hovered image faded by the hover progress.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
