Class TurretSketchDefinition.Builder

java.lang.Object
org.horizon36596.simloop.viz.TurretSketchDefinition.Builder
Enclosing class:
TurretSketchDefinition

public static final class TurretSketchDefinition.Builder extends Object
Step-by-step builder. Everything is required except the background colour and the joints above the yaw; build() fails loudly rather than defaulting anything that would change what is drawn.
  • Method Details

    • yaw

      The yaw: a point on its axis and the joint itself.
      Parameters:
      pivotInches - a point on the yaw axis, robot frame, inches
      yawJoint - the yaw joint; its rotation axis must be vertical
      Returns:
      this builder
    • canvasSizeInches

      public TurretSketchDefinition.Builder canvasSizeInches(double widthInches, double heightInches)
      The canvas the chain above the turret is drawn on. It must hold that chain at full reach, measured from the turret, and be at least twice its furthest horizontal reach (the MechanismSketch canvas-origin rule).
      Parameters:
      widthInches - canvas width in inches
      heightInches - canvas height in inches
      Returns:
      this builder
    • backgroundColorHex

      public TurretSketchDefinition.Builder backgroundColorHex(String backgroundColorHex)
      Canvas background. Defaults to black.
      Parameters:
      backgroundColorHex - the colour as "#RRGGBB"
      Returns:
      this builder
    • addJoint

      Append a joint riding on the turret, stated in the robot frame at yaw zero. The first one mounts on the yaw joint's tip, and each later one on the tip of the one before.
      Parameters:
      joint - the joint; its name must be unique within this mechanism, and differ from the yaw's
      Returns:
      this builder
    • build

      public TurretSketchDefinition build()
      Validates the turret-specific rules and produces the definition. The joints above the yaw are validated again, in the turret's own plane, when TurretSketch builds their drawing.
      Returns:
      the definition, ready to hand to TurretSketch
      Throws:
      IllegalArgumentException - if the yaw or its pivot is missing, the yaw axis is not vertical, nothing points sideways to say which way the turret faces, the canvas size or colour is invalid, or two joints share a name.