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:

  1. create*( int aID, ALcyProperties aProperties ): create the element with the specified ID. This method may return null for certain IDs. Override this method if you want to customize a particular user interface element.

  2. get*( int aID ): returns the element with the specified ID.

The whole user interface is created through the createGUI( ALcyProperties ) method, which:

  1. Calls the setup( ALcyProperties ) method. This method calls the create* 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 the create* methods are called is important. The order is specified in the Javadoc of the setup( ALcyProperties ) method. For example, in the createPanel( int, ALcyProperties ) method, you can re-use the previously created actions through the getAction( int ) method, because the setup( ALcyProperties ) method calls createAction( int, ALcyProperties ) before calling createPanel( int, ALcyProperties ).

  2. Calls the createGUIContent( ALcyProperties ) method, responsible for joining the parts into one user interface.

  3. Restores the factory to its initial state by calling cleanup( ALcyProperties ).