Class FloatPost

java.lang.Object
eu.bandm.sig.adlib2.lib.FloatPost
All Implemented Interfaces:
AbstractSignalSource, CompilableDataFlow, FloatSignalSource, FloatSupplier

public class FloatPost extends Object implements FloatSignalSource
Central class to realize control values which can come from different sources and flow to different consumers. In practice, the following situations must be freely combinable:
  • programmatic, spurious setting by imperative code
  • clocked read of some signal source
  • irregular, but predictable setting by a kind of sequencer
  • spontaneous GUI input by slider / checkbox / textinput
  • Midi input (key, ctrl, etc.)
  • other external sensors
The current value may flow into:
  • continuous output as a signal source
  • programmatic/event like reaction in case of change
  • GUI visualization of current value
  • visualization plot of recent history
  • protocol of changes, either discrete or continuously sampled
The domain can be
  • some scalar domain like float or int
  • boolean
  • (seldom: text)
  • some PRODUCT of these
  • (seldom: a CO-product)
  • Field Details

    • name

      protected final String name
    • value

      protected float value
    • lastSource

      protected Object lastSource
    • min

      protected final float min
    • max

      protected final float max
    • epsilon

      protected final float epsilon
    • unit

      protected final String unit
    • listeners

      protected Set<Consumer<FloatPost>> listeners
    • APPEARANCE_HORIZONTAL

      public static final int APPEARANCE_HORIZONTAL
      See Also:
    • APPEARANCE_VERTICAL

      public static final int APPEARANCE_VERTICAL
      See Also:
    • SLIDER_MAX

      public static final int SLIDER_MAX
      Get GUI representation.
        APPEARANCE_VERTICAL   APPEARANCE_HORIZONTAL
        +-----+     +-----------------------------------------+
        |name |     | name                         [...] unit |
        | =   |     | |----------[XXX]---------------------|  |
        | |300|     |  -120                            300    |
        | |   |     +-----------------------------------------+
        | |   |
        |[XX] |
        | |   |
        | |   |
        | |   |
        | |   |
        | |   |
        | |   |
        | |   |
        | |-120
        | =   |
        |     |
        |[.]Hz|
        +-----+
      See Also:
  • Constructor Details

    • FloatPost

      public FloatPost(String name, String unit, float min, float max, float epsilon)
    • FloatPost

      public FloatPost(String name, String unit, float min, float max, float epsilon, float initValue)
  • Method Details

    • getAsFloat

      public float getAsFloat()
      Description copied from interface: FloatSignalSource
      Returns the current value of this signal source.

      The value may be either computed on demand, or retrieved from storage.

      Implementations of this method should have no side effect.

      Specified by:
      getAsFloat in interface FloatSignalSource
      Specified by:
      getAsFloat in interface FloatSupplier
      Returns:
      the current value of this signal source
    • write

      public Process write(FloatSignalSource v)
    • setValue

      public void setValue(float value)
      Called from outside.
    • setValue

      protected void setValue(float value, @Opt @Opt Object source)
      Parameters:
      source - the agent which initiates this particular change of the value. It is excluded from the listeners which are notified aboth this particular change.
    • addListener

      public void addListener(Consumer<FloatPost> pl)
    • view2model

      protected float view2model(int view)
    • model2view

      protected int model2view(float model)