You typically use a factory to create user interface panels in Lucy. Such a factory allows you to customize the panel by overriding
only small parts of the creation process. The abstract base class of those factories is the ALcyGUIFactory
, which is discussed in more detail below.
In most cases, a user interface consists of multiple small user interface elements. By creating the user interfaces through
a factory, you don’t need to re-implement the whole user interface if you only want to customize a small part. Each user interface
element has a create
method that you can override.
Furthermore, the creation and joining of the different elements happens in two distinct steps: first every element is created, and afterwards they are joined together. This mechanism allows you to customize the creation of an element while it is still inserted in the correct place of the user interface.
Associated with each element is a unique ID. It is used throughout the factory to identify the element. All those IDs are passed to the factory during the construction.
The main methods of ALcyGUIFactory
are:
-
create*( int aID, ALcyProperties aProperties )
: create the element with the specified ID. This method may returnnull
for certain IDs. Override this method if you want to customize a particular user interface element. -
get*( int aID )
: returns the element with the specified ID.
The whole user interface is created through the createGUI( ALcyProperties )
method, which:
-
Calls the
setup( ALcyProperties )
method. This method calls thecreate*
method for every known ID and stores the result. Once the element corresponding to a certain ID is created, it becomes available through its getter. As a result, the order in which thecreate*
methods are called is important. The order is specified in the Javadoc of thesetup( ALcyProperties )
method. For example, in thecreatePanel( int, ALcyProperties )
method, you can re-use the previously created actions through thegetAction( int )
method, because thesetup( ALcyProperties )
method callscreateAction( int, ALcyProperties )
before callingcreatePanel( int, ALcyProperties )
. -
Calls the
createGUIContent( ALcyProperties )
method, responsible for joining the parts into one user interface. -
Restores the factory to its initial state by calling
cleanup( ALcyProperties )
.