Code Examples
A repository of 155 code examples for BeepBeep
plots.UpdateTableStreamExample Class Reference

Update a table from two streams of numbers. More...

Static Public Member Functions

static void main (String[] args) throws InterruptedException
 

Detailed Description

Update a table from two streams of numbers.

This example generates dummy (x,y) pairs of numbers, accumulates them into a table, and prints the table made from these numbers.

Author
Sylvain Hallé Easy

Definition at line 37 of file UpdateTableStreamExample.java.

Member Function Documentation

◆ main()

static void plots.UpdateTableStreamExample.main ( String []  args) throws InterruptedException
static

We create two streams of numbers

Definition at line 40 of file UpdateTableStreamExample.java.

41  {
42  /// We create two streams of numbers
43  QueueSource src1 = new QueueSource().setEvents(1, 2, 3, 4, 5);
44  QueueSource src2 = new QueueSource().setEvents(2, 3, 5, 7, 4);
45 
46  /* These x-stream and y-stream are then pushed into an
47  * {@link UpdateTableStream} processor. We instantiate this processor,
48  * telling it to create an empty {@link Table} object with two
49  * columns, called "x" and "y". */
50  UpdateTable table = new UpdateTableStream("x", "y");
51 
52  /* This creates a processor with two input streams, one for the "x"
53  * values, and the other for the "y" values. Each pair of values from
54  * the x and y streams is used to append a new line to the (initially
55  * empty) table. We connect the two
56  * outputs of the random processor to these two inputs. */
57  Connector.connect(src1, OUTPUT, table, TOP);
58  Connector.connect(src2, OUTPUT, table, BOTTOM);
59 
60  /* We print the contents of the resulting table. */
61  Pump pump = new Pump();
62  Print print = new Print().setSeparator("\n");
63  Connector.connect(table, pump, print);
64 
65  /* Ready to start the pump! */
66  pump.turn(4);
67  ///
68  }

The documentation for this class was generated from the following file: