Class ALcyGUIFactory<T>

java.lang.Object
com.luciad.lucy.gui.ALcyGUIFactory<T>
Direct Known Subclasses:
ALcyDrawingToolBarFactory, TLcyContourGUIFactory, TLcyExtremePointGUIFactory, TLcyHypsometryGUIFactory, TLcyKML22GUIFactory, TLcyLOSCoverageGUIFactory, TLcyLspMapComponentFactory, TLcyLspMapLayerControlFactory, TLcyViewshedGUIFactory, TLcyVisibilityGUIFactory

public abstract class ALcyGUIFactory<T> extends Object

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:

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 Details

    • ALcyGUIFactory

      protected ALcyGUIFactory(ILcyLucyEnv aLucyEnv, int[] aActionIDs, int[] aActiveSettableIDs, int[] aComponentIDs, int[] aPanelIDs)
      Creates a new ALcyGUIFactory.
      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 new ALcyGUIFactory.
      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

      public ILcyLucyEnv getLucyEnv()
      Returns the ILcyLucyEnv.
      Returns:
      the ILcyLucyEnv.
    • createGUI

      public T createGUI(ALcyProperties aProperties)
      This function
      1. calls setup, which creates all sub-parts such as actions, components and panels.
      2. calls createGUIContent, which creates the content of the panel by laying out all panels created in the previous step.
      3. 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 returned Component visible in for example an ILcyApplicationPane 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).
    • setup

      protected void setup(ALcyProperties aProperties)

      This functions creates all the components for the user interface, in a certain order. It

      1. creates all actions using createAction with all given action ID's (see getActionIDs()) and insert them in all configured action bars using TLcyActionBarUtil.insertInConfiguredActionBars(com.luciad.gui.ILcdAction, Object, TLcyActionBarManager, com.luciad.lucy.util.properties.ALcyProperties) with the specified properties. The context is determined by calling getActionContext(int, com.luciad.lucy.util.properties.ALcyProperties).
        Only actions where the ID_KEY is specified will be inserted (see TLcyActionBarUtil.ID_KEY).
      2. creates all active settables createActiveSettable with all given active settable ID's (see getActiveSettableIDs() and insert them in all configured action bars using TLcyActionBarUtil.insertInConfiguredActionBars(ILcyActiveSettable, Object, TLcyActionBarManager, com.luciad.lucy.util.properties.ALcyProperties) with the specified properties. The context is determined by calling getActiveSettableContext(int, com.luciad.lucy.util.properties.ALcyProperties).
        Only active settables where the ID_KEY is specified will be inserted (see TLcyActionBarUtil.ID_KEY).
      3. creates all components using createComponent(int, com.luciad.lucy.util.properties.ALcyProperties) with all given component ID's (see getComponentIDs() ).
      4. creates all panels using createPanel(int, com.luciad.lucy.util.properties.ALcyProperties) with all given panel ID's (see getPanelIDs() ).

      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 use getComponent(int) to retrieve its sub components, and the createComponent(int, com.luciad.lucy.util.properties.ALcyProperties) method can use getAction(int) and getActiveSettable(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.
    • createGUIContent

      protected abstract T createGUIContent(ALcyProperties aProperties)

      Retrieves all panels and lays them out in a java.awt.Component. Therefore, this method uses getPanel(int) with all ID's that end in PANEL, and lays out those components in for example a javax.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

      protected void cleanup(ALcyProperties aProperties)

      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

      protected abstract ILcdAction createAction(int aActionID, ALcyProperties aProperties)

      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 with ACTION.
      aProperties - a properties object that can be used to tune the behavior of this factory.
      Returns:
      the newly created ILcdAction, or null.
      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 with ACTIVE_SETTABLE.
      aProperties - a properties object that can be used to tune the behavior of this factory.
      Returns:
      the newly created ILcyActiveSettable, or null.
    • createComponent

      protected abstract Component createComponent(int aComponentID, ALcyProperties aProperties)

      Creates a widget for the given ID. It is safe to use the getAction(int) and getActiveSettable(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 with COMPONENT.
      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

      protected abstract Component createPanel(int aPanelID, ALcyProperties aProperties)

      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 with PANEL.
      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

      protected ILcdAction getAction(int aActionID)

      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 in ACTION.
      Returns:
      the ILcdAction for the given ID.
    • getActiveSettable

      protected ILcyActiveSettable getActiveSettable(int aActiveSettableID)

      Returns the ILcyActiveSettable for the given ID.

      Please refer to createGUIContent to know when this method can be used.

      Parameters:
      aActiveSettableID - the id describing which ILcyActiveSettable to return. This is normally a constant that ends in ACTIVE_SETTABLE.
      Returns:
      the ILcyActiveSettable for the given ID.
    • getComponent

      protected Component getComponent(int aComponentID)

      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 with COMPONENT.
      Returns:
      the java.awt.Component for the given ID.
    • getPanel

      protected Component getPanel(int aPanelID)

      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 with PANEL.
      Returns:
      the panel as a java.awt.Component for the given ID.
    • getActionIDs

      protected ILcdIntList 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

      protected ILcdIntList 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

      protected ILcdIntList 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

      protected ILcdIntList 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

      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.

      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 ID aActionID 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

      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.

      All active settables are inserted in the action bars by TLcyActionBarUtil#insertInConfiguredActionBars. This method specifies the context for which the active settable with ID aActiveSettableID is inserted.

      By default this method returns null.

      Parameters:
      aActiveSettableID - the ID of the active settable
      aProperties - 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 the isDeactivatePossible parameter for the active settable with ID aActiveSettableID is inserted.

      Parameters:
      aActiveSettableID - the ID of the active settable
      aProperties - 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: