Class TLcyLspMapLayerControlFactory

java.lang.Object
com.luciad.lucy.gui.ALcyGUIFactory<TLcyLspMapLayerControl>
com.luciad.lucy.map.lightspeed.TLcyLspMapLayerControlFactory

public class TLcyLspMapLayerControlFactory extends ALcyGUIFactory<TLcyLspMapLayerControl>

Factory to create a TLcyLspMapLayerControl for a given TLcyLspMapComponent. It cannot create a layer control for other ILcyGenericMapComponent implementations.

It uses the concept of an ALcyGUIFactory, allowing the users of this class to modify almost every part of the creation process.

The layer control is composed of a list of layers, and several ILcyActionBar instances that contain actions to move and delete the selected layer(s) and to change their properties.

Since:
2012.0
  • Field Details

  • Constructor Details

    • TLcyLspMapLayerControlFactory

      public TLcyLspMapLayerControlFactory(ILcyLucyEnv aLucyEnv)

      Creates a new layer control factory for the specified ILcyLucyEnv.

      It will create all the default actions, active settables, ... of which the IDs can be found as static fields on this class.

      Parameters:
      aLucyEnv - the Lucy backend.
  • Method Details

    • setup

      protected void setup(ALcyProperties aProperties)

      This method overrides the default behavior of the setup method. It will create all the components in a certain order. It will

      1. create the empty map layer control using createEmptyMapLayerControl(com.luciad.lucy.util.properties.ALcyProperties).
      2. create the pop up menu using createPopupMenu(com.luciad.lucy.util.properties.ALcyProperties).
      3. create all the action bars using createActionBar(int, com.luciad.lucy.util.properties.ALcyProperties) with all given action bar ids (see getActionBarIDs()).
      4. create all active settable enabled filters using createActiveSettableEnabledFilter(int, com.luciad.lucy.util.properties.ALcyProperties) with all given active settable filter ids (see getActiveSettableEnabledFilterIDs() ).
      5. create all action enabled filters using createActionEnabledFilter(int, com.luciad.lucy.util.properties.ALcyProperties) with all given action filter ids (see getActionEnabledFilterIDs() ).
      6. create all the tree models using createTreeModel(int, com.luciad.lucy.util.properties.ALcyProperties) with all given tree model ids (see getTreeModelIDs()).
      7. create all the tree cell renderers using createTreeCellRenderer(int, com.luciad.lucy.util.properties.ALcyProperties) with all given tree cell renderer ids (see getTreeCellRendererIDs() ).
      8. create all the trees using createTree(int, com.luciad.lucy.util.properties.ALcyProperties) with all given tree ids (see getTreeIDs() ).
      9. create all actions, active settables, components and panels using ALcyGUIFactory.setup(com.luciad.lucy.util.properties.ALcyProperties).
      10. create all transfer handlers using createTransferHandler(int, com.luciad.lucy.util.properties.ALcyProperties) with all given transfer handler ids (see getTransferHandlerIDs()).

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

      Overrides:
      setup in class ALcyGUIFactory<TLcyLspMapLayerControl>
      Parameters:
      aProperties - a properties object that can be used to tune the behavior of this factory.
    • cleanup

      protected void cleanup(ALcyProperties aProperties)
      Description copied from class: ALcyGUIFactory

      Performs cleanup operations, such as nullifying fields that are no longer needed.

      Warning: Should not be overridden without calling the super function.

      Overrides:
      cleanup in class ALcyGUIFactory<TLcyLspMapLayerControl>
      Parameters:
      aProperties - a properties object that can be used to tune the behavior of this factory.
    • getActionContext

      protected Object getActionContext(int aActionID, ALcyProperties aProperties)
      Description copied from class: ALcyGUIFactory

      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.

      Overrides:
      getActionContext in class ALcyGUIFactory<TLcyLspMapLayerControl>
      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)
      Description copied from class: ALcyGUIFactory

      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.

      Overrides:
      getActiveSettableContext in class ALcyGUIFactory<TLcyLspMapLayerControl>
      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.
    • createGUIContent

      protected TLcyLspMapLayerControl createGUIContent(ALcyProperties aProperties)
      Description copied from class: ALcyGUIFactory

      Retrieves all panels and lays them out in a java.awt.Component. Therefore, this method uses ALcyGUIFactory.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;
        }
       

      Specified by:
      createGUIContent in class ALcyGUIFactory<TLcyLspMapLayerControl>
      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.
    • createEmptyMapLayerControl

      protected TLcyLspMapLayerControl createEmptyMapLayerControl(ALcyProperties aProperties)

      Creates an empty layer control, without any content, buttons or panels.

      Parameters:
      aProperties - a properties object that can be used to tune the behavior of this factory.
      Returns:
      the new layer control. Must not be null.
    • createPopupMenu

      protected ILcyPopupMenu createPopupMenu(ALcyProperties aProperties)

      Creates an empty popup menu.

      Parameters:
      aProperties - a properties object that can be used to tune the behavior of this factory.
      Returns:
      the empty popup menu. By default this is not null, but subclasses may choose to return null if they want to remove the popup menu from the layer control.
    • getPopupMenu

      protected ILcyPopupMenu getPopupMenu()

      Returns the created ILcyPopupMenu.

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

      Returns:
      the created ILcyPopupMenu, or null.
    • createActionBar

      protected ILcyActionBar createActionBar(int aActionBarID, ALcyProperties aProperties)

      Creates an empty action bar.

      Parameters:
      aActionBarID - The ID of the action bar. It is typically a constant ending in ACTION_BAR
      aProperties - a properties object that can be used to tune the behavior of this factory.
      Returns:
      the empty action bar. By default this is not null, but subclasses may choose to return null if they want to remove the specified action bar from the layer control.
    • getActionBar

      protected ILcyActionBar getActionBar(int aActionBarID)

      Returns the ILcyActionBar for the given ID.

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

      Parameters:
      aActionBarID - The id describing which ILcyActionBar to return. This is normally a constant that ends in ACTION_BAR.
      Returns:
      the ILcyActionBar for the given ID.
    • getActionBarIDs

      protected ILcdIntList getActionBarIDs()

      Returns the list with all action bar IDs.

      By default, this list only contains the IDs defined in this class. Adding and/or removing action bar 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 ALcyGUIFactory.createGUI(com.luciad.lucy.util.properties.ALcyProperties) method.

      Returns:
      a list with the action bar IDs
    • createActiveSettableEnabledFilter

      protected ILcdFilter<ILspLayer> createActiveSettableEnabledFilter(int aFilterID, ALcyProperties aProperties)

      Creates an ILcdFilter for the corresponding active settable. If the filter does not accept a layer passed as argument to the ILcdFilter.accept(Object) method ( ie. returns false), the corresponding user interface element will be disabled when that layer is selected.

      This default implementation will always return an ILcdFilter that is not null. It is good practice to combine this filter with your filter by using an ALcyCompositeFilter to which you add your filter and the filter returned by this default implementation.

      Following example demonstrates how you could override this method:

      
      
        protected ILcdFilter<ILspLayer> createActiveSettableEnabledFilter(
            int aFilterID, ALcyProperties aProperties ) {
      
          switch ( aFilterID ){
            // create a filter that will disable the layer selectable button for specific layers.
            case LAYER_SELECTABLE_ACTIVE_SETTABLE_ENABLED_FILTER:
              TLcyCompositeAndFilter<ILspLayer> my_filter = new TLcyCompositeAndFilter<ILspLayer>();
              // Make sure we use the filter created by the super implementation.
              // This filter will never be null.
              my_filter.addFilter( super.createActiveSettableEnabledFilter( aFilterID, aProperties ) );
      
              // do not accept layers that have a model with a MyModelDescriptor as model descriptor.
              my_filter.addFilter( new ILcdFilter<ILspLayer>(){
              public boolean accept( ILspLayer aLayer ){
                return !( aLayer.getModel().getModelDescriptor() instanceof MyModelDescriptor );
              }
            } );
            return my_filter;
      
            default:
              return super.createActiveSettableEnabledFilter( aFilterID, aProperties );
          }
        }
       

      Parameters:
      aFilterID - the ID indicating for which active settable the filter applies. It is typically an ID ending in ACTIVE_SETTABLE_ENABLED_FILTER.
      aProperties - a properties object that can be used to tune the behavior of this factory.
      Returns:
      an ILcdFilter that determines for which layers the corresponding active settable will be enabled in the user interface. The default implementation never returns null, but subclasses can and may return null;
    • getActiveSettableEnabledFilter

      protected ILcdFilter<ILspLayer> getActiveSettableEnabledFilter(int aFilterID)

      Returns the ILcdFilter for the given ID.

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

      Parameters:
      aFilterID - the id describing which ILcdFilter to return. This is usually a constant that ends in ACTIVE_SETTABLE_ENABLED_FILTER.
      Returns:
      the ILcdFilter for the given ID.
    • getActiveSettableEnabledFilterIDs

      protected ILcdIntList getActiveSettableEnabledFilterIDs()

      Returns the list with all enabled active settable filter IDs.

      By default, this list only contains the IDs defined in this class. Adding and/or removing enabled active settable filter 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 ALcyGUIFactory.createGUI(com.luciad.lucy.util.properties.ALcyProperties) method.

      Returns:
      a list with the enabled active settable filter IDs
    • createActionEnabledFilter

      protected ILcdFilter<ILspLayer> createActionEnabledFilter(int aFilterID, ALcyProperties aProperties)

      Creates an ILcdFilter for the corresponding action. If the filter does not accept a layer passed as argument to the ILcdFilter.accept(Object) method ( ie. returns false), the corresponding user interface element will be disabled when that layer is selected.

      This default implementation will always return an ILcdFilter that is not null. It is good practice to combine this filter with your filter by using an ALcyCompositeFilter to which you add your filter and the filter returned by this default implementation.

      Following example demonstrates how you could override this method:

      
      
       protected ILcdFilter<ILspLayer> createActionEnabledFilter( int aFilterID, ALcyProperties
       aProperties ) {
       switch ( aFilterID ){
       // create a filter that will disable the fit action for specific layers.
       case FIT_TO_LAYER_ACTION_ENABLED_FILTER:
       TLcyCompositeAndFilter<ILspLayer> my_filter = new TLcyCompositeAndFilter<ILspLayer>();
       // Make sure we use the filter created by the super implementation.
       // This filter will never be null.
       my_filter.addFilter( super.createActionEnabledFilter( aFilterID, aProperties ) );
      
       // do not accept layers that have a model with a MyModelDescriptor as modeldescriptor.
       my_filter.addFilter( new ILcdFilter<ILspLayer>(){
       public boolean accept( ILspLayer aLayer ){
       return !( aLayer.getModel().getModelDescriptor() instanceof MyModelDescriptor );
       } );
       return my_filter;
      
       default:
       return super.createActionEnabledFilter( aFilterID, aProperties );
       }
       }
       

      Parameters:
      aFilterID - the ID indicating for which action the filter applies. It is typically an ID ending in ACTION_ENABLED_FILTER.
      aProperties - a properties object that can be used to tune the behavior of this factory.
      Returns:
      an ILcdFilter that determines for which layers the corresponding action will be enabled in the user interface. The default implementation never returns null, but subclasses can and may return null;
    • getActionEnabledFilter

      protected ILcdFilter<ILspLayer> getActionEnabledFilter(int aFilterID)

      Returns the ILcdFilter for the given ID.

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

      Parameters:
      aFilterID - the id describing which ILcdFilter to return. This is normally a constant that ends in ACTION_ENABLED_FILTER.
      Returns:
      the ILcdFilter for the given ID.
    • getActionEnabledFilterIDs

      protected ILcdIntList getActionEnabledFilterIDs()

      Returns the list with all enabled action filter IDs.

      By default, this list only contains the IDs defined in this class. Adding and/or removing enabled action filter 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 ALcyGUIFactory.createGUI(com.luciad.lucy.util.properties.ALcyProperties) method.

      Returns:
      a list with the enabled action filter IDs
    • createTreeModel

      protected TreeModel createTreeModel(int aTreeModelID, ALcyProperties aProperties)
      Creates the tree model corresponding to the ID aTreeModelID. May return null.
      Parameters:
      aTreeModelID - the ID of the tree model. This is typically a constant ending in TREE_MODEL.
      aProperties - a properties object that can be used to tune the behavior of this factory.
      Returns:
      the tree model corresponding to the ID aTreeModelID. May be null.
    • getTreeModel

      protected TreeModel getTreeModel(int aTreeModelID)

      Returns the TreeModel for the given ID.

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

      Parameters:
      aTreeModelID - the id describing which TreeModel to return. This is usually a constant that ends in TREE_MODEL.
      Returns:
      the TreeModel for the given ID.
    • getTreeModelIDs

      protected ILcdIntList getTreeModelIDs()

      Returns the list with all tree model IDs.

      By default, this list only contains the IDs defined in this class. Adding and/or removing tree model 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 ALcyGUIFactory.createGUI(com.luciad.lucy.util.properties.ALcyProperties) method.

      Returns:
      a list with the tree model IDs
    • createTreeCellRenderer

      protected TreeCellRenderer createTreeCellRenderer(int aTreeCellRendererID, ALcyProperties aProperties)
      Creates the tree cell renderer corresponding to the ID aTreeCellRendererID. May return null.
      Parameters:
      aTreeCellRendererID - the ID of the tree cell renderer. This is typically a constant ending in TREE_CELL_RENDERER.
      aProperties - a properties object that can be used to tune the behavior of this factory.
      Returns:
      the tree cell renderer corresponding to the ID aTreeCellRendererID. May be null.
    • getTreeCellRenderer

      protected TreeCellRenderer getTreeCellRenderer(int aTreeCellRendererID)

      Returns the TreeCellRenderer for the given ID.

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

      Parameters:
      aTreeCellRendererID - the id describing which TreeCellRenderer to return. This is normally a constant that ends in TREE_CELL_RENDERER.
      Returns:
      the TreeCellRenderer for the given ID.
    • getTreeCellRendererIDs

      protected ILcdIntList getTreeCellRendererIDs()

      Returns the list with all tree cell renderer IDs.

      By default, this list only contains the IDs defined in this class. Adding and/or removing tree cell renderer 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 ALcyGUIFactory.createGUI(com.luciad.lucy.util.properties.ALcyProperties) method.

      Returns:
      a list with the tree cell renderer IDs
    • createTree

      protected JTree createTree(int aTreeID, ALcyProperties aProperties)
      Creates the tree corresponding to the ID aTreeID. May return null.
      Parameters:
      aTreeID - the ID of the tree. This is typically a constant ending in TREE.
      aProperties - a properties object that can be used to tune the behavior of this factory.
      Returns:
      the tree corresponding to the ID aTreeID. May be null.
    • getTree

      protected JTree getTree(int aTreeID)

      Returns the JTree for the given ID.

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

      Parameters:
      aTreeID - the id describing which JTree to return. This is normally a constant that ends in TREE.
      Returns:
      the JTree for the given ID.
    • getTreeIDs

      protected ILcdIntList getTreeIDs()

      Returns the list with all tree IDs.

      By default, this list only contains the IDs defined in this class. Adding and/or removing tree 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 ALcyGUIFactory.createGUI(com.luciad.lucy.util.properties.ALcyProperties) method.

      Returns:
      a list with the tree IDs
    • createAction

      protected ILcdAction createAction(int aActionID, ALcyProperties aProperties)
      Description copied from class: ALcyGUIFactory

      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).

      Specified by:
      createAction in class ALcyGUIFactory<TLcyLspMapLayerControl>
      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 ILcyActiveSettable createActiveSettable(int aActiveSettableID, ALcyProperties aProperties)
      Description copied from class: ALcyGUIFactory

      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).

      Specified by:
      createActiveSettable in class ALcyGUIFactory<TLcyLspMapLayerControl>
      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 Component createComponent(int aComponentID, ALcyProperties aProperties)
      Description copied from class: ALcyGUIFactory

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

      Specified by:
      createComponent in class ALcyGUIFactory<TLcyLspMapLayerControl>
      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 Component createPanel(int aPanelID, ALcyProperties aProperties)
      Description copied from class: ALcyGUIFactory

      Creates a panel for the given ID. It is safe to use ALcyGUIFactory.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 == ... ) {
           ...
         }
       }
       

      Specified by:
      createPanel in class ALcyGUIFactory<TLcyLspMapLayerControl>
      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.
    • createTransferHandler

      protected TransferHandler createTransferHandler(int aTransferHandlerID, ALcyProperties aProperties)
      Creates a TransferHandler for the given ID.
      Parameters:
      aTransferHandlerID - the ID describing which transfer handler to create. This is normally a constant that ends with TRANSFER_HANDLER.
      aProperties - a properties object that can be used to tune the behavior of this factory.
      Returns:
      the newly created TransferHandler, or null.
    • getTransferHandler

      protected TransferHandler getTransferHandler(int aTransferHandlerID)

      Returns the TransferHandler for the given ID.

      Please refer to setup(com.luciad.lucy.util.properties.ALcyProperties) to know when this method can be used.

      Parameters:
      aTransferHandlerID - the id describing which transfer handler to return. This is normally a constant that ends in TRANSFER_HANDLER.
      Returns:
      the TransferHandler for the given ID.
    • getTransferHandlerIDs

      protected ILcdIntList getTransferHandlerIDs()

      Returns the list with all transfer handler IDs.

      By default, this list only contains the IDs defined in this class. Adding and/or removing transfer handler 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 ALcyGUIFactory.createGUI(com.luciad.lucy.util.properties.ALcyProperties) method.

      Returns:
      a list with the transfer handler IDs
    • getMapLayerControl

      protected TLcyLspMapLayerControl getMapLayerControl()

      Returns the map layer control under construction.

      Returns:
      the map layer control under construction. Must not be null.
    • getMapComponent

      protected ILcyLspMapComponent getMapComponent(ALcyProperties aProperties)

      Convenience method to retrieve the map component from aProperties. The map component should be stored with key MAP_COMPONENT_PROPERTY_NAME.

      An exception is thrown when the map component could not be retrieved from the properties.

      Parameters:
      aProperties - the properties containing the map component.
      Returns:
      the map component stored in the properties. Will not be null.