Skip to content

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.

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.

ReturnsSignatureSummary
ResourceNodecreate(double x, double y) factoryCreates an image node at x, y that takes the size of its image.
ResourceNodecreate(double x, double y, double width, double height) factoryCreates 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) protectedCalled by a subclass with the same arguments as create.

PropertyTypeDefaultSummary
resource signalResourcenullThe image to draw.
hoveredResource signalResourcenullImage that fades in over the first one while the node is hovered; null keeps the image on hover.
color signalColorColor.WHITETint multiplied with the image; white draws the image as it is.
hoveredColor signalColornone, the tint stays the same on hoverTint while the node is hovered, reached with the hover progress; null keeps the tint.
linear signalbooleanthe filtering of the resourceIf true, the image is smoothed when scaled; if false, its pixels stay sharp; null keeps the filtering of the resource.
stretch signalStretchTypeStretchType.STRETCHHow 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

ReturnsSignatureSummary
ResourcegetFilteredResource()The resource drawn for resource, a copy with the filtering of linear when it is set.
ResourcegetFilteredHoveredResource()The resource drawn for hoveredResource, a copy with the filtering of linear when it is set.
ReturnsSignatureSummary
voidupdate() hookMeasures the image on every frame, so that the node takes its size as soon as it loads.
voiddraw(double mouseX, double mouseY) hookDraws 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

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

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.

  • this resource(Resource resource) fluent
  • this resource(Supplier<Resource> resource) fluent signal
  • Resource getResource()

Default: null

The image to draw. Throws an IllegalStateException when the node is attached without one.

  • this hoveredResource(Resource hoveredResource) fluent
  • this hoveredResource(Supplier<Resource> hoveredResource) fluent signal
  • Resource 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) fluent
  • this color(Supplier<Color> color) fluent signal
  • Color getColor()

Default: Color.WHITE

Tint multiplied with the image; white draws the image as it is.

  • this hoveredColor(Color hoveredColor) fluent
  • this hoveredColor(Supplier<Color> hoveredColor) fluent signal
  • Color 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.

  • this linear(boolean linear) fluent
  • this linear(Supplier<Boolean> linear) fluent signal
  • Boolean 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.

  • this stretch(StretchType stretch) fluent
  • this stretch(Supplier<StretchType> stretch) fluent signal
  • StretchType getStretch()

Default: StretchType.STRETCH

How the image fills the bounds when their ratio differs from the ratio of the image.

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.

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

Report a problem with this page