Draw2DElement.Builder
com.jsmacrosce.jsmacros.client.api.classes.render.components.Draw2DElement.Builder
Builds a nested overlay element with configurable position, dimensions, scale, rotation, and draw order.
Dimensions initially follow the parent overlay; position defaults to (0, 0),
scale to 1, rotation to 0, and rotation center to the element center.
The nested overlay reads the builder's dimension suppliers, then follows the built element's dimensions after construction. A child overlay has only one pair of dimension suppliers, so do not use it for multiple independently sized wrappers.
Nested type declared in Draw2DElement.
Constructors
new Draw2DElement.Builder
Creates a builder that nests
draw2D in parent. Dimensions initially follow the parent; the child overlay follows the builder's dimensions and then the built element's dimensions.Parameters:
parent: the overlay this element is going ondraw2D: the overlay to nest
Methods
getHeight
Returns the builder's current height, read from its dimension supplier.
Returns: the current height
getParentHeight
getParentHeight(): int#Returns the height of the overlay used to create this builder, which parent-relative alignment uses as its reference.
Returns: the height of the parent
getParentWidth
getParentWidth(): int#Returns the width of the overlay used to create this builder, which parent-relative alignment uses as its reference.
Returns: the width of the parent
getRotation
Returns the configured rotation in degrees; builder values are not normalized.
Returns: the current rotation
getScale
Returns the scale applied to the nested overlay.
Returns: the current scale
getScaledHeight
getScaledHeight(): int#Returns the height multiplied by the builder's scale and converted to an integer by Java's cast (truncation toward zero).
Returns: the scaled height
getScaledLeft
getScaledLeft(): int#Returns the element's x position; scaling does not change this position.
Returns: the position of the scaled element's left side
getScaledTop
getScaledTop(): int#Returns the element's y position; scaling does not change this position.
Returns: the position of the scaled element's top side
getScaledWidth
getScaledWidth(): int#Returns the width multiplied by the builder's scale and converted to an integer by Java's cast (truncation toward zero).
Returns: the scaled width
getWidth
Returns: the current width from the dimension supplier
getX
Returns: the horizontal position
getY
Returns: the vertical position
getZIndex
Returns the configured ordering value; lower values draw first.
Returns: the ordering value
height
Sets the height; negative values are rejected.
Parameters:
height: the height
Returns: self for chaining.
isRotatingCenter
Returns whether rotation is about the element's center.
Returns:
true if rotation is about the centermoveTo
moveTo(int x, int y): Draw2DElement.Builder#Sets the element's position without changing its size.
Parameters:
x: the new x positiony: the new y position
Returns: self for chaining.
pos
Sets both position coordinates.
Parameters:
x: the x positiony: the y position
Returns: self for chaining.
rotateCenter
Sets whether rotation is about the element's center rather than its positioned corner.
Parameters:
rotateCenter:trueto rotate about the center
Returns: this builder
rotation
Sets the rotation in degrees. The value is narrowed to
float without normalization.Parameters:
rotation: the rotation in degrees
Returns: this builder
scale
Sets the scale applied to the nested overlay. The value is narrowed to
float.Parameters:
scale: the scale
Returns: this builder
size
Sets both dimensions; negative values are rejected by the corresponding setters.
Parameters:
width: the widthheight: the height
Returns: this builder
width
Sets the width; negative values are rejected.
Parameters:
width: the width
Returns: self for chaining.
x
Sets the horizontal position.
Parameters:
x: the x position
Returns: self for chaining.
y
Sets the vertical position.
Parameters:
y: the y position
Returns: self for chaining.
zIndex
Sets the ordering value used relative to other elements; lower values draw first.
Parameters:
zIndex: the ordering value
Returns: this builder