Class Monitor

java.lang.Object
org.openpatch.scratch.internal.Monitor

public final class Monitor extends Object
A variable monitor, drawn like Scratch's: a light box with the variable's name and its value in an orange pill. The value is asked for every frame, so the monitor always shows what the variable holds right now.

Nothing outside the library should use this; stages and sprites show them with showVariable(...).

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final float
    Height of one monitor, gap included: where the next one starts.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Monitor(String label, Supplier<?> value)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    draw(processing.core.PGraphics g, float x, float y)
    Draws the monitor with its top left corner at (x, y) in the buffer's coordinates.
    The monitor's text.
    The current value as the monitor shows it.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • HEIGHT

      public static final float HEIGHT
      Height of one monitor, gap included: where the next one starts.
      See Also:
  • Constructor Details

    • Monitor

      public Monitor(String label, Supplier<?> value)
      Parameters:
      label - what the monitor says, for example "Cat: score"
      value - asked for the value every frame
  • Method Details

    • getLabel

      public String getLabel()
      The monitor's text.
    • getText

      public String getText()
      The current value as the monitor shows it.
    • draw

      public void draw(processing.core.PGraphics g, float x, float y)
      Draws the monitor with its top left corner at (x, y) in the buffer's coordinates.