20 import javax.swing.JFrame;
22 import ca.uqac.lif.cep.Connector;
23 import ca.uqac.lif.cep.functions.ApplyFunction;
24 import ca.uqac.lif.cep.mtnp.DrawPlot;
25 import ca.uqac.lif.cep.mtnp.UpdateTableArray;
26 import ca.uqac.lif.cep.tmf.CountDecimate;
27 import ca.uqac.lif.cep.tmf.Window;
28 import ca.uqac.lif.cep.widgets.ListenerSource;
29 import ca.uqac.lif.cep.widgets.MouseCoordinates;
30 import ca.uqac.lif.mtnp.plot.gnuplot.HeatMap;
31 import ca.uqac.lif.mtnp.table.FrequencyTable;
56 protected static int WIDTH = 320;
63 public static void main(String[] args)
throws InterruptedException
67 JFrame mouse_playground =
new JFrame();
68 mouse_playground.setSize(WIDTH, HEIGHT);
69 mouse_playground.setTitle(
"Mouse playground");
70 mouse_playground.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
71 ListenerSource listener =
new ListenerSource();
72 mouse_playground.addMouseMotionListener(listener);
73 mouse_playground.setVisible(
true);
76 ApplyFunction coords =
new ApplyFunction(MouseCoordinates.instance);
77 Connector.connect(listener, coords);
81 UpdateTableArray update_table =
new UpdateTableArray(
82 new FrequencyTable(0, WIDTH, 10, 0, HEIGHT, 10, 1d));
85 Window window =
new Window(update_table, 100);
86 Connector.connect(coords, window);
91 CountDecimate decimate =
new CountDecimate(20);
92 Connector.connect(window, decimate);
95 HeatMap plot =
new HeatMap();
96 plot.setTitle(
"Heat map");
97 DrawPlot draw =
new DrawPlot(plot);
98 Connector.connect(decimate, draw);
100 frame.
getFrame().setLocationRelativeTo(null);
101 Connector.connect(draw, frame);
102 System.out.println(
"Move your mouse in the window called \"Mouse playground\".");
103 System.out.println(
"The heatmap will appear in the other window.");
104 System.out.println(
"Press Ctrl+C or close the window to end.");
static int HEIGHT
The height of the mouse playground.
JFrame getFrame()
Gets the frame associated to the object.
Displays the trail of the mouse pointer inside a heat map.
Receives a byte array as an input, and shows it in a Swing window as a picture.
static int WIDTH
The width of the mouse playground.