Skip to content

Draw2DElement.Builder ​

com.jsmacrosce.jsmacros.client.api.classes.render.components.Draw2DElement.Builder

Since1.8.4

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 ​

new Draw2DElement.Builder(IDraw2D<?> parent, Draw2D draw2D)#
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 on
  • draw2D: the overlay to nest

Methods ​

getHeight ​

getHeight(): intSince1.8.4#
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 ​

getRotation(): floatSince1.8.4#
Returns the configured rotation in degrees; builder values are not normalized.
Returns: the current rotation

getScale ​

getScale(): floatSince1.8.4#
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 ​

getWidth(): intSince1.8.4#
Returns: the current width from the dimension supplier

getX ​

getX(): intSince1.8.4#
Returns: the horizontal position

getY ​

getY(): intSince1.8.4#
Returns: the vertical position

getZIndex ​

getZIndex(): intSince1.8.4#
Returns the configured ordering value; lower values draw first.
Returns: the ordering value

height ​

height(int height): Draw2DElement.BuilderSince1.8.4#
Sets the height; negative values are rejected.

Parameters:

  • height: the height
Returns: self for chaining.

isRotatingCenter ​

isRotatingCenter(): booleanSince1.8.4#
Returns whether rotation is about the element's center.
Returns: true if rotation is about the center

moveTo ​

moveTo(int x, int y): Draw2DElement.Builder#
Sets the element's position without changing its size.

Parameters:

  • x: the new x position
  • y: the new y position
Returns: self for chaining.

pos ​

pos(int x, int y): Draw2DElement.BuilderSince1.8.4#
Sets both position coordinates.

Parameters:

  • x: the x position
  • y: the y position
Returns: self for chaining.

rotateCenter ​

rotateCenter(boolean rotateCenter): Draw2DElement.BuilderSince1.8.4#
Sets whether rotation is about the element's center rather than its positioned corner.

Parameters:

  • rotateCenter: true to rotate about the center
Returns: this builder

rotation ​

rotation(double rotation): Draw2DElement.BuilderSince1.8.4#
Sets the rotation in degrees. The value is narrowed to float without normalization.

Parameters:

  • rotation: the rotation in degrees
Returns: this builder

scale ​

scale(double scale): Draw2DElement.BuilderSince1.8.4#
Sets the scale applied to the nested overlay. The value is narrowed to float.

Parameters:

  • scale: the scale
Returns: this builder

size ​

size(int width, int height): Draw2DElement.BuilderSince1.8.4#
Sets both dimensions; negative values are rejected by the corresponding setters.

Parameters:

  • width: the width
  • height: the height
Returns: this builder

width ​

width(int width): Draw2DElement.BuilderSince1.8.4#
Sets the width; negative values are rejected.

Parameters:

  • width: the width
Returns: self for chaining.

x ​

x(int x): Draw2DElement.BuilderSince1.8.4#
Sets the horizontal position.

Parameters:

  • x: the x position
Returns: self for chaining.

y ​

y(int y): Draw2DElement.BuilderSince1.8.4#
Sets the vertical position.

Parameters:

  • y: the y position
Returns: self for chaining.

zIndex ​

zIndex(int zIndex): Draw2DElement.BuilderSince1.8.4#
Sets the ordering value used relative to other elements; lower values draw first.

Parameters:

  • zIndex: the ordering value
Returns: this builder