The front-end of Lucy is the part that starts Lucy, creates the general user interface and loads the add-ons. Lucy is delivered
with one such front-end,
TLcyMain, which can create two kinds of user interfaces: one with dockable frames or one with tabbed panes. It puts those in a
JFrame that it creates itself. This article describes how to completely replace the front-end application by a custom implementation,
offering unlimited flexibility over the main class, the user interface, whether to use tabbed panes, how many tabbed panes
to use, where to put them, add-on loading, position of the frame, number of frames, and so on. It also allows you to integrate
Lucy within an existing application.
To create a custom front-end application, you must:
Create a main class
Create a pluggable user interface
TLcyTabbedPaneLucyEnvFactory: a pluggable user interface is available based on tabbed panes, but the developer can create and organize the
Load all the add-ons: either by instantiating and plugging the add-ons manually, or by delegating the work to the
The front-end can provide the Lucy back-end with a top level component. This is useful when you are integrating Lucy with an existing application: you can add the top-level component of that application to Lucy so that other add-ons can use this component, to find the parent frame when displaying dialogs, for instance.
These samples demonstrate how to create a custom front-end application:
samples.lucy.frontend.mapcentric.Main: a front-end focusing on the map.
samples.lucy.frontend.dockableframes.Main: a flexible frontend based on the JIDE docking framework.
samples.lucy.frontend.tabbedpanes.Main: a front-end based on
samples.lucy.frontend.internalframes.Main: a front-end based on
All these samples sub-class
AFrontend, which contains all common functionality such as the general initialization and the loading of the add-ons.
AFrontend takes care of the general initialization of Lucy. It creates the parts of the user interface that are necessary in all front-ends:
the main window, the menu bar, the splash screen, the status bar, and so on. It makes sure that all these components are connected
It is up to the sub-classes of
AFrontend to implement the specific user interface. They create this user interface in the implementation of the
initGUI methods. In the
createLucyEnv, they create the
ILcyLucyEnv back-end with its
ILcyApplicationPaneFactory. In the
initGUI method, they arrange all visual components in the main frame of the front-end.
The main menu bar is created and — in contrast to the status bar — also inserted in the main frame by
AFrontend itself. This menu bar is initialized with a comparator for group descriptors to make sure that the menu items are ordered
Apart from the general user interface,
AFrontend also takes care of the add-on loading. When the
ILcyLucyEnv has been initialized, the add-ons are loaded by the
loadAddOnsHardCoded method. You load the add-ons by explicitly instantiating the add-ons and adding them to the
ILcyLucyEnv through the
plugAddOn method. Note that a second
loadAddOnsFromFile method is available that shows how to load the add-ons from an XML file using the
This sample demonstrates how to create a front-end that focuses on the map. To construct such a map-focused front-end, the sample uses the following components and techniques:
The most important menu items and tools are inserted in the regular toolbar of the map and an extra toolbar on the side of the map. This extra toolbar is created by the front-end. The contents of these toolbars are specified by the various add-on configuration files.
Tabs that can both select and collapse panels. This allows users to focus on the map. They will only allocate space for a tab when they actually need it.
ALcyFormatBarinstances are displayed in the tool bar on the left by the
SideBarFormatBarAddOn. If you have an add-on that creates its own
ALcyFormatBar, it will not be visible by default. You need to add it in the configuration file of the
Small, collapsible panels that float on the map.
Collapsible panels at the bottom. A custom split pane remembers the size of each panel when it is collapsed, so that it can be restored in the same size.
A horizontal time slider layout that provides a compact way to preview and simulate time-based content. This is done by extending the
ILcyApplicationPaneFactoryinstance set up by the front-end that ensures that all panels end up in the correct location.
The sample feature set serves as a straightforward example. Add or remove add-ons as you see fit, change configuration files, and add custom panes to match your requirements. To keep the application user interface simple, the sample supports only one map. If a second one is added, the sample throws an exception.
DockableFrameFrontendMain creates a user interface in which the user can completely re-arrange all the application panes. For that purpose, it uses
the JIDE docking framework. The docking behavior of this sample is exactly the same as that of the
DOCKING_MODE mode of the default front-end,
createLucyEnv method of this sample creates a
ILcyLucyEnv through the
ILcyApplicationPaneFactory implementation required by this factory is the
DockableFrameAppPane as the matching implementation of
ILcyApplicationPane. When one of the
createApplicationPane methods of the
DockableFrameAppPaneFactory is called, it creates a
DockableFrameAppPane, which is a sub-class of the
DockableFrame class of the JIDE docking framework. This application pane is then added to the
DockingManager, the central concept in the JIDE docking framework. By adding this dockable frame to the
DockingManager, you show it in the user interface, and the user can re-arrange the application panes with his mouse.
DockableWorkspaceCodecDelegate class provides the workspace support for this front-end sample. It makes the JIDE docking framework store the locations of
all the dockable frames, so that the user interface can be restored later on. The other classes in the sample are there to
configure the behavior of the JIDE docking framework to create a nice user experience.
The user interface is composed in the
initGUI method. Through the default Swing methods, the status bar is added to the bottom of the main frame and the dockable holder
of the JIDE docking framework is added to the center of the frame. This dockable holder is the area where all the dockable
frames of the JIDE docking framework can be arranged and re-arranged.
TabbedPanesFrontendMain creates a user interface with tabbed panes, similar to the
createLucyEnv method creates a
ILcyLucyEnv through the
TLcyTabbedPaneLucyEnvFactory. This factory provides a ready-made pluggable user interface, where only the required
JPanel instances or
JTabbedPane instances are passed to the factory. Next to that, a
TLcyMenuBar is passed to the factory. This menu bar was created by
After the loading of the add-ons, the user interface is put together in the
initGUI method. The panels that were passed to the
TLcyTabbedPaneLucyEnvFactory are added to the center of the frame through Swing. Because you have control over the actual tabbed panes and containers
that are put together, it is possible to spread the tabs over two different frames, for instance, or to integrate Lucy in
the user interface of an existing application.
InternalFramesFrontendMain creates a user interface based on internal frames. Similar to the
DockableFrameFrontendMain sample, it uses the
TLcyLucyEnvFactory to create the
ILcyLucyEnv instance. The implementation for
ILcyApplicationPaneFactory in this sample is the
InternalFrameAppPane as matching implementation of
ILcyApplicationPane. They are based on the Swing classes
JInternalFrame. The class
WorkspaceCodecDelegate provides workspace support so that all internal frames re-appear at their stored location when a workspace is loaded.