Class Primitive

java.lang.Object
nl.colorize.multimedialib.stage.Primitive
All Implemented Interfaces:
StageNode, StageNode2D

public class Primitive extends Object implements StageNode2D
Draws a graphical primitive to the screen. The on-screen position of the primitive is determined by both the coordinates in the original shape and by the primitive's position.

Primitives have a stroke property, but its value is only used if the instance describes an outline shape. The stroke property has no effect for filled shapes.

  • Constructor Details

    • Primitive

      public Primitive(Shape shape, ColorRGB color)
    • Primitive

      public Primitive(Shape shape, ColorRGB color, float alpha)
  • Method Details

    • getStageBounds

      public Rect getStageBounds()
      Description copied from interface: StageNode2D
      Returns the bounding box currently occopied by this node, relative to the stage. This method uses StageNode2D.getGlobalTransform().
      Specified by:
      getStageBounds in interface StageNode2D
    • animate

      public void animate(Timer sceneTime)
      Description copied from interface: StageNode
      Called by the renderer at the end of frame updates, while rendering the stage. animationTimer contains the elapsed time since the currently active scene was started. This allows animations to display correctly, without the need to update every single node during each frame update.
      Specified by:
      animate in interface StageNode
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • fromRect

      public static Primitive fromRect(float width, float height, ColorRGB color)
    • fromRect

      public static Primitive fromRect(float width, float height, ColorRGB color, float alpha)
    • fromCircle

      public static Primitive fromCircle(float radius, ColorRGB color)
    • fromCircle

      public static Primitive fromCircle(float radius, ColorRGB color, float alpha)
    • getParent

      public Container getParent()
      Description copied from interface: StageNode
      Returns this node's parent node. Returns null if thos node does not have a parent, or if this is the root node.
      Specified by:
      getParent in interface StageNode
      Specified by:
      getParent in interface StageNode2D
    • getTransform

      public Transform getTransform()
      Description copied from interface: StageNode2D
      Returns this node's local transform, which is interpreted relative to its parent node. The local transform can be modified by application code to modify how and where the node is displayed.
      Specified by:
      getTransform in interface StageNode2D
    • getGlobalTransform

      public Transform getGlobalTransform()
      Description copied from interface: StageNode2D
      Returns this node's global transform, which is interpreted relative to the stage. The global transform is updated by the renderer when drawing the stage at the end of frame updates. Recalculating the global transform is relatively expensive, and is therefore only done once per frame. This means that any changes made to a node's local transform since the last frame update may not yet been reflected in the current state of its global transform.
      Specified by:
      getGlobalTransform in interface StageNode2D
    • getShape

      public Shape getShape()
    • getColor

      public ColorRGB getColor()
    • getStroke

      public float getStroke()
    • setShape

      public void setShape(Shape shape)
    • setColor

      public void setColor(ColorRGB color)
    • setStroke

      public void setStroke(float stroke)
    • setParent

      protected void setParent(Container parent)