Class ALcyGUIFactory<T>
- Direct Known Subclasses:
ALcyDrawingToolBarFactory
,TLcyContourGUIFactory
,TLcyExtremePointGUIFactory
,TLcyHypsometryGUIFactory
,TLcyKML22GUIFactory
,TLcyLOSCoverageGUIFactory
,TLcyLspMapComponentFactory
,TLcyLspMapLayerControlFactory
,TLcyViewshedGUIFactory
,TLcyVisibilityGUIFactory
Abstract factory for the creation of a GUI panel. This factory was designed so that it is easy to modify small parts of the creation process. By overriding certain methods, parts can be removed, changed or added.
The entry point createGUI
does:
setup
- create all actions using
createAction
and insert them in all configured action bars usingTLcyActionBarUtil.insertInConfiguredActionBars(com.luciad.gui.ILcdAction, Object, TLcyActionBarManager, com.luciad.lucy.util.properties.ALcyProperties)
. The context is determined by callinggetActionContext(int, com.luciad.lucy.util.properties.ALcyProperties)
. - create all active settables
createActiveSettable
and insert them in all configured action bars usingTLcyActionBarUtil.insertInConfiguredActionBars(ILcyActiveSettable, Object, TLcyActionBarManager, com.luciad.lucy.util.properties.ALcyProperties)
. The context is determined by callinggetActiveSettableContext(int, com.luciad.lucy.util.properties.ALcyProperties)
. - create all components using
createComponent
- create all panels using
createPanel
createGUIContent
- creates the resulting GUI. It does so using the created panels and laying them out
cleanup
Note that as soon as any of the actions etc. are created, they can be retrieved using the
matching get
method. For example while creating panels, the created components can
be used to do so.
Note that ID's are used. This is because there are different types of, for example, panels
that can be created. All possible ID's that can be passed to the createPanel
method should all end with the same suffix "PANEL". The same thing goes for
"COMPONENT" (createComponent
, getComponent
), "ACTIVE_SETTABLE" (createActiveSettable
, getActiveSettable
) and "ACTION" (createAction
, getAction
). Duplicate IDs are not allowed. Customer code should
use ID's above 10000.
If sub-classes would like to specify which ID's are to be used, they can do so using the
constructor or by simply adding to the existing list of ID's (e.g. see getActionIDs()
).
- Since:
- 8.1
-
Constructor Summary
ModifierConstructorDescriptionprotected
ALcyGUIFactory
(ILcyLucyEnv aLucyEnv, int[] aActionIDs, int[] aActiveSettableIDs, int[] aComponentIDs, int[] aPanelIDs) Creates a newALcyGUIFactory
.protected
ALcyGUIFactory
(ILcyLucyEnv aLucyEnv, ILcdIntList aActionIDs, ILcdIntList aActiveSettableIDs, ILcdIntList aComponentIDs, ILcdIntList aPanelIDs) Creates a newALcyGUIFactory
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
cleanup
(ALcyProperties aProperties) Performs cleanup operations, such as nullifying fields that are no longer needed.protected abstract ILcdAction
createAction
(int aActionID, ALcyProperties aProperties) Creates anILcdAction
for the given ID.protected abstract ILcyActiveSettable
createActiveSettable
(int aActiveSettableID, ALcyProperties aProperties) Creates anILcyActiveSettable
for the given ID.protected abstract Component
createComponent
(int aComponentID, ALcyProperties aProperties) Creates a widget for the given ID.createGUI
(ALcyProperties aProperties) This function callssetup
, which creates all sub-parts such as actions, components and panels.protected abstract T
createGUIContent
(ALcyProperties aProperties) Retrieves all panels and lays them out in ajava.awt.Component
.protected abstract Component
createPanel
(int aPanelID, ALcyProperties aProperties) Creates a panel for the given ID.protected ILcdAction
getAction
(int aActionID) Returns theILcdAction
for the given ID.protected Object
getActionContext
(int aActionID, ALcyProperties aProperties) Returns the context of the action bars in which the action with the specified ID should be inserted.protected ILcdIntList
Returns the list with all action IDs.protected ILcyActiveSettable
getActiveSettable
(int aActiveSettableID) Returns theILcyActiveSettable
for the given ID.protected Object
getActiveSettableContext
(int aActiveSettableID, ALcyProperties aProperties) Returns the context of the action bars in which the active settable with the specified ID should be inserted.protected ILcdIntList
Returns the list with all active settable IDs.protected Component
getComponent
(int aComponentID) Returns thejava.awt.Component
for the given ID.protected ILcdIntList
Returns the list with all component IDs.Returns theILcyLucyEnv
.protected Component
getPanel
(int aPanelID) Returns the panel as ajava.awt.Component
for the given ID.protected ILcdIntList
Returns the list with all panel IDs.protected boolean
isActiveSettableDeactivatePossible
(int aActiveSettableID, ALcyProperties aProperties) Returns whether the active settable can be deactivated or not through the action bar in which it is inserted.protected void
setup
(ALcyProperties aProperties) This functions creates all the components for the user interface, in a certain order.
-
Constructor Details
-
ALcyGUIFactory
protected ALcyGUIFactory(ILcyLucyEnv aLucyEnv, int[] aActionIDs, int[] aActiveSettableIDs, int[] aComponentIDs, int[] aPanelIDs) Creates a newALcyGUIFactory
.- Parameters:
aLucyEnv
- The Lucy environment.aActionIDs
- All action ID's.aActiveSettableIDs
- All active settable ID's.aComponentIDs
- All component ID's.aPanelIDs
- All panel ID's.
-
ALcyGUIFactory
protected ALcyGUIFactory(ILcyLucyEnv aLucyEnv, ILcdIntList aActionIDs, ILcdIntList aActiveSettableIDs, ILcdIntList aComponentIDs, ILcdIntList aPanelIDs) Creates a newALcyGUIFactory
.- Parameters:
aLucyEnv
- The Lucy environment.aActionIDs
- All action ID's.aActiveSettableIDs
- All active settable ID's.aComponentIDs
- All component ID's.aPanelIDs
- All panel ID's.
-
-
Method Details
-
getLucyEnv
Returns theILcyLucyEnv
.- Returns:
- the
ILcyLucyEnv
.
-
createGUI
This function- calls
setup
, which creates all sub-parts such as actions, components and panels. - calls
createGUIContent
, which creates the content of the panel by laying out all panels created in the previous step. - calls
cleanup
to perform some cleanup tasks.
The
Component
created in the second step is returned. It is up to the user of this factory to make the returnedComponent
visible in for example anILcyApplicationPane
or a dialog.Warning: There is normally no need to override this method, instead overwrite one of the three methods that it calls. Also note that it is possible that this method is called an a worker thread. If you override it, be sure to call the super function and to invoke any Swing or other EDT dependent code on the EDT thread.
- Parameters:
aProperties
- a properties object that can be used to tune the behavior of this factory.- Returns:
- the GUI, as created by
createGUIContent(com.luciad.lucy.util.properties.ALcyProperties)
.
- calls
-
setup
This functions creates all the components for the user interface, in a certain order. It
- creates all actions using
createAction
with all given action ID's (seegetActionIDs()
) and insert them in all configured action bars usingTLcyActionBarUtil.insertInConfiguredActionBars(com.luciad.gui.ILcdAction, Object, TLcyActionBarManager, com.luciad.lucy.util.properties.ALcyProperties)
with the specified properties. The context is determined by callinggetActionContext(int, com.luciad.lucy.util.properties.ALcyProperties)
.
Only actions where the ID_KEY is specified will be inserted (seeTLcyActionBarUtil.ID_KEY
). - creates all active settables
createActiveSettable
with all given active settable ID's (seegetActiveSettableIDs()
and insert them in all configured action bars usingTLcyActionBarUtil.insertInConfiguredActionBars(ILcyActiveSettable, Object, TLcyActionBarManager, com.luciad.lucy.util.properties.ALcyProperties)
with the specified properties. The context is determined by callinggetActiveSettableContext(int, com.luciad.lucy.util.properties.ALcyProperties)
.
Only active settables where the ID_KEY is specified will be inserted (seeTLcyActionBarUtil.ID_KEY
). - creates all components using
createComponent(int, com.luciad.lucy.util.properties.ALcyProperties)
with all given component ID's (seegetComponentIDs()
). - creates all panels using
createPanel(int, com.luciad.lucy.util.properties.ALcyProperties)
with all given panel ID's (seegetPanelIDs()
).
Note that because of this order, panels can be composed of components, and components can use the active settables and actions. So the
createPanel(int, com.luciad.lucy.util.properties.ALcyProperties)
method can usegetComponent(int)
to retrieve its sub components, and thecreateComponent(int, com.luciad.lucy.util.properties.ALcyProperties)
method can usegetAction(int)
andgetActiveSettable(int)
to retrieve needed actions and active settables.Warning: It is possible that this method is called on a worker thread. When overriding this method, care should be taken to ensure that all code that should be run on the EDT thread (Swing code etc...) is invoked using for example
TLcdAWTUtil.invokeAndWait(java.lang.Runnable)
. Also, don't override this method without calling the super function.- Parameters:
aProperties
- a properties object that can be used to tune the behavior of this factory.
- creates all actions using
-
createGUIContent
Retrieves all panels and lays them out in a
java.awt.Component
. Therefore, this method usesgetPanel(int)
with all ID's that end inPANEL
, and lays out those components in for example ajavax.swing.JPanel
.This function should be overridden when the global layout of the panel needs to be changed, for example when the main panels need to be rearranged, or when a new panel needs to be added.
An example implementation could be:
public Component createGUIContent( ALcyProperties aProperties ) { JPanel content = new JPanel( new BorderLayout() ); Component somePanel = getPanel( SOME_PANEL ); if ( somePanel != null ) content.add( somePanel, BorderLayout.NORTH ); Component otherPanel = getPanel( OTHER_PANEL ); if ( otherPanel != null ) content.add( otherPanel, BorderLayout.CENTER ); return content; }
- Parameters:
aProperties
- a properties object that can be used to tune the behavior of this factory.- Returns:
- the component containing all panels, layed out appropriately.
-
cleanup
Performs cleanup operations, such as nullifying fields that are no longer needed.
Warning: Should not be overridden without calling the super function.
- Parameters:
aProperties
- a properties object that can be used to tune the behavior of this factory.
-
createAction
Creates an
ILcdAction
for the given ID.Note: if the action should be inserted in the configured action bars, the ID_KEY of the returned action must be set (see
TLcyActionBarUtil.ID_KEY
).- Parameters:
aActionID
- the ID describing which action to create. This is normally a constant that ends withACTION
.aProperties
- a properties object that can be used to tune the behavior of this factory.- Returns:
- the newly created
ILcdAction
, ornull
. - See Also:
-
createActiveSettable
protected abstract ILcyActiveSettable createActiveSettable(int aActiveSettableID, ALcyProperties aProperties) Creates an
ILcyActiveSettable
for the given ID.Note: if the active settable should be inserted in the configured action bars, the ID_KEY of the returned active settable must be set (see
TLcyActionBarUtil.ID_KEY
).- Parameters:
aActiveSettableID
- the ID describing which active settable to create. This is normally a constant that ends withACTIVE_SETTABLE
.aProperties
- a properties object that can be used to tune the behavior of this factory.- Returns:
- the newly created
ILcyActiveSettable
, ornull
.
-
createComponent
Creates a widget for the given ID. It is safe to use the
getAction(int)
andgetActiveSettable(int)
methods in this method, to build widgets that use an action or active settable.These widgets might interact with the given properties object, to retrieve or store some state. Such a widget could for example be a check box whose 'selected' state is synchronized with some property.
- Parameters:
aComponentID
- the ID describing which component to create. This is normally a constant that ends withCOMPONENT
.aProperties
- a properties object that can be used to tune the behavior of this factory. state.- Returns:
- the newly created
java.awt.Component
, or null.
-
createPanel
Creates a panel for the given ID. It is safe to use
getComponent(int)
in this method, to build panels that are composed of components.An example implementation could be:
protected Component createPanel( int aPanelID, ALcyProperties aProperties ) { if ( aPanelID == SOME_PANEL ) { JPanel content = new JPanel( new BorderLayout() ); Component someComponent = getComponent( SOME_COMPONENT ); if ( someComponent != null ) content.add( someComponent, BorderLayout.NORTH ); Component otherComponent = getComponent( OTHER_COMPONENT ); if ( otherComponent != null ) content.add( otherComponent, BorderLayout.CENTER ); return content; } else if ( aPanelID == ... ) { ... } }
- Parameters:
aPanelID
- the ID describing which panel to create. This is normally a constant that ends withPANEL
.aProperties
- a properties object that can be used to tune the behavior of this factory.- Returns:
- the newly created
java.awt.Component
, or null.
-
getAction
Returns the
ILcdAction
for the given ID.Please refer to
createGUIContent
to know when this method can be used.- Parameters:
aActionID
- The id describing which action to return. This is normally a constant that ends inACTION
.- Returns:
- the
ILcdAction
for the given ID.
-
getActiveSettable
Returns the
ILcyActiveSettable
for the given ID.Please refer to
createGUIContent
to know when this method can be used.- Parameters:
aActiveSettableID
- the id describing whichILcyActiveSettable
to return. This is normally a constant that ends inACTIVE_SETTABLE
.- Returns:
- the
ILcyActiveSettable
for the given ID.
-
getComponent
Returns the
java.awt.Component
for the given ID.Please refer to
createGUIContent
to know when this method can be used.- Parameters:
aComponentID
- the id describing which component to return. This is normally a constant that ends withCOMPONENT
.- Returns:
- the
java.awt.Component
for the given ID.
-
getPanel
Returns the panel as a
java.awt.Component
for the given ID.Please refer to
createGUIContent
to know when this method can be used.- Parameters:
aPanelID
- the ID describing which panel to return. This is normally a constant that ends withPANEL
.- Returns:
- the panel as a
java.awt.Component
for the given ID.
-
getActionIDs
Returns the list with all action IDs.
By default, this list only contains the IDs passed in the constructor. Adding and/or removing action IDs to/from this factory is achieved by altering this list.
Warning: do not alter the list when the factory is creating the GUI. Only modify it before or after the
createGUI(com.luciad.lucy.util.properties.ALcyProperties)
method.- Returns:
- a list with the action IDs
-
getActiveSettableIDs
Returns the list with all active settable IDs.
By default, this list only contains the IDs passed in the constructor. Adding and/or removing active settable IDs to/from this factory is achieved by altering this list.
Warning: do not alter the list when the factory is creating the GUI. Only modify it before or after the
createGUI(com.luciad.lucy.util.properties.ALcyProperties)
method.- Returns:
- a list with the active settable IDs
-
getComponentIDs
Returns the list with all component IDs.
By default, this list only contains the IDs passed in the constructor. Adding and/or removing component IDs to/from this factory is achieved by altering this list.
Warning: do not alter the list when the factory is creating the GUI. Only modify it before or after the
createGUI(com.luciad.lucy.util.properties.ALcyProperties)
method.- Returns:
- a list with the component IDs
-
getPanelIDs
Returns the list with all panel IDs.
By default, this list only contains the IDs passed in the constructor. Adding and/or removing panel IDs to/from this factory is achieved by altering this list.
Warning: do not alter the list when the factory is creating the GUI. Only modify it before or after the
createGUI(com.luciad.lucy.util.properties.ALcyProperties)
method.- Returns:
- a list with the panel IDs
-
getActionContext
Returns the context of the action bars in which the action with the specified ID should be inserted.
All actions are inserted in the action bars by
TLcyActionBarUtil.insertInConfiguredActionBars(com.luciad.gui.ILcdAction, Object, com.luciad.lucy.gui.TLcyActionBarManager, com.luciad.lucy.util.properties.ALcyProperties)
. This method specifies the context for which the action with IDaActionID
is inserted.By default this method returns
null
.- Parameters:
aActionID
- the ID of the action.aProperties
- The properties. Can be used to tune the behavior of this factory.- Returns:
- the context of the action with the specified ID
-
getActiveSettableContext
Returns the context of the action bars in which the active settable with the specified ID should be inserted.
All active settables are inserted in the action bars by
TLcyActionBarUtil#insertInConfiguredActionBars
. This method specifies the context for which the active settable with IDaActiveSettableID
is inserted.By default this method returns
null
.- Parameters:
aActiveSettableID
- the ID of the active settableaProperties
- The properties. Can be used to tune the behavior of this factory.- Returns:
- the context of the active settable with the specified ID.
-
isActiveSettableDeactivatePossible
protected boolean isActiveSettableDeactivatePossible(int aActiveSettableID, ALcyProperties aProperties) Returns whether the active settable can be deactivated or not through the action bar in which it is inserted.
All active settables are inserted in the action bars by
TLcyActionBarUtil#insertInConfiguredActionBars
. This method specifies the value of theisDeactivatePossible
parameter for the active settable with IDaActiveSettableID
is inserted.- Parameters:
aActiveSettableID
- the ID of the active settableaProperties
- The properties. Can be used to tune the behavior of this factory- Returns:
true
when the active settable can be deactivated through the action bar,false
otherwise- See Also:
-