Record Class ComponentSnapshot
- Record Components:
component- the live component this snapshot was taken of; never nullvisible- whether the component was visibleenabled- whether the component was enabledhovered- whether the pointer was over the component, and not over a descendantpressed- whether a mouse button was held down that went down on the componentfocused- whether the component had keyboard focus; always false for one that is notFocusablemargin- the component's margin; never nullminWidth- the component's minimum widthmaxWidth- the component's maximum widthminHeight- the component's minimum heightmaxHeight- the component's maximum heighthorizontalAlignment- the component's horizontal alignment; never nullverticalAlignment- the component's vertical alignment; never nullbounds- the component's bounds, in the host's coordinates; never nulldesiredWidth- the component's desired widthdesiredHeight- the component's desired heightstate- what the component's kind records about itself, or null if it records nothing
component() returns, to see what the event changed. Input events and
requests carry them, as SnapshotEvents.
A snapshot covers only the component itself. A container's snapshot holds the container's own state and nothing about its children; each child that was captured has a snapshot of its own.
Each field holds what the component's getter of the same name returned when the snapshot was taken, or for
hover, press and focus, what the component's own code would have read.
state() holds what the component's kind adds, such as a text box's text and caret: the built-in controls
and panels record a nested State type (for example
TextBox.State), and a
CustomComponent records whatever its snapshotState hook
returns.
Snapshots are immutable and stay valid after the event is delivered, unlike the event itself. They hold a reference to the live component, so keeping one keeps the component reachable.
-
Constructor Summary
ConstructorsConstructorDescriptionComponentSnapshot(Component<?> component, boolean visible, boolean enabled, boolean hovered, boolean pressed, boolean focused, Insets margin, float minWidth, float maxWidth, float minHeight, float maxHeight, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, Rect bounds, float desiredWidth, float desiredHeight, Object state) Checks the fields that must not be null. -
Method Summary
Modifier and TypeMethodDescriptionbounds()Returns the value of theboundsrecord component.Component<?> Returns the value of thecomponentrecord component.floatReturns the value of thedesiredHeightrecord component.floatReturns the value of thedesiredWidthrecord component.booleanenabled()Returns the value of theenabledrecord component.final booleanIndicates whether some other object is "equal to" this one.booleanfocused()Returns the value of thefocusedrecord component.final inthashCode()Returns a hash code value for this object.Returns the value of thehorizontalAlignmentrecord component.booleanhovered()Returns the value of thehoveredrecord component.margin()Returns the value of themarginrecord component.floatReturns the value of themaxHeightrecord component.floatmaxWidth()Returns the value of themaxWidthrecord component.floatReturns the value of theminHeightrecord component.floatminWidth()Returns the value of theminWidthrecord component.booleanpressed()Returns the value of thepressedrecord component.state()Returns the value of thestaterecord component.<S> Optional<S> Returnsstate()as a given type.final StringtoString()Returns a string representation of this record class.Returns the value of theverticalAlignmentrecord component.booleanvisible()Returns the value of thevisiblerecord component.
-
Constructor Details
-
ComponentSnapshot
public ComponentSnapshot(Component<?> component, boolean visible, boolean enabled, boolean hovered, boolean pressed, boolean focused, Insets margin, float minWidth, float maxWidth, float minHeight, float maxHeight, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, Rect bounds, float desiredWidth, float desiredHeight, Object state) Checks the fields that must not be null.
-
-
Method Details
-
state
Returnsstate()as a given type.event.snapshot().state(TextBox.State.class).ifPresent(before -> ...);- Type Parameters:
S- the state type- Parameters:
type- the class the state is expected to be- Returns:
- the state, or empty if there is none or it is not an instance of
type
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
component
-
visible
-
enabled
-
hovered
-
pressed
-
focused
-
margin
-
minWidth
-
maxWidth
-
minHeight
-
maxHeight
-
horizontalAlignment
Returns the value of thehorizontalAlignmentrecord component.- Returns:
- the value of the
horizontalAlignmentrecord component
-
verticalAlignment
Returns the value of theverticalAlignmentrecord component.- Returns:
- the value of the
verticalAlignmentrecord component
-
bounds
-
desiredWidth
public float desiredWidth()Returns the value of thedesiredWidthrecord component.- Returns:
- the value of the
desiredWidthrecord component
-
desiredHeight
public float desiredHeight()Returns the value of thedesiredHeightrecord component.- Returns:
- the value of the
desiredHeightrecord component
-
state
-