Fluency Widgets
A Fluency Widget is a basic building block of Fluency Application. It can receive Events from user or from other widgets at the same time emit Events. A Fluency Widget can be visual or not visual.
Visual widgets
Visual Fluency widget uses the Swing's GUI componet to render itself on the screen. In other words each visual Fluency Widget has a JComponent which it uses for its appearance on the screen.
All the widgets in Fluency like SimpleButton, SimpleTextField etc. are derived from the main widget class Widget.
Widget (abstract base class) ---- SimpleButton (derived class)
The Widget class , has a container that contains all the Swing's GUI components (JComponent) for displaying the widget on the screen. This container is an instance of UsefulJPanel (which is the sub class of JPanel).
JPanel(base class) ------- UsefulJPanel (derived class)
Widget(has a) -------- UsefulJPanel
All the visual component of the Widget are added to UsefulJPanel. Widget class has function called addVisualComponent(final Component) which adds the visual component to its container. (see Widget.java)
Ex. SimpleButton uses JButton as its visual component. (see SimpleButton.java)
Note: UsefulJPanel is used in many places.
Non-Visual widgets
Non-Visual Fluency widgets do not have any visual component and hence when the Fluency runs in the engine mode , we cannot see the widget on screen.
How widgets are loaded?
There are two modes in Fluency:
a.Editor mode: where the user adds the widgets and connects them.
b.Engine mode: when the user tries to run the Fluency application by clicking the Engine plugin.
In the editor mode the user adds new widgets or connects them. When the user adds the widgets the instances of the widgets added are stored in FluencyModel object. (see FleuncyModel.java). So basically FluencyModel object contains all the widgets and their connections. FluencyModel , in other words contains a graph of connected objects. This graph is serialized into XML string using the toXML() function.
The sequence of how the Fluency Application is loaded can be given as follows:
FluencyEditorFrame — (xml format of the fluency model) — EnginePlugin — (xml string) — FluencyLoader
Widgets as Island.
In Fluency Widgets are treated as Island. A Fluency application containing a group of connected widgets can thus be considered as a group of connected Islands. Communication between the Islands are done using Ships.
We can map Events to Ships and Event objects to Cargo.
All the Fluency widgets which can generate events (originating from itself) has an ActionListener which captures the Swing Event and translates it to Fluency Events. For example, in SimpleButton widget , we have ActionListener attached to its visual Component i.e. JButton. When the button is clicked , Ship is placed in the Output Dock of the "clicked" harbor.