Class TLcyMapLayerControlFactory

java.lang.Object
com.luciad.lucy.map.TLcyMapLayerControlFactory
All Implemented Interfaces:
ILcyMapLayerControlFactory
Direct Known Subclasses:
TLcyMapOverviewLayerControlFactory

public class TLcyMapLayerControlFactory extends Object implements ILcyMapLayerControlFactory

Factory to create a TLcyMapLayerControl for a given TLcyMapComponent. It cannot create a layer control for other ILcyMapComponent implementations.

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.

This list of layers can be displayed as a linear list, where every layer in the user interface maps one on one with ILcdGXYView.layers(). This linear list is created by createComponent(int, TLcyMapLayerControl) with ID LAYER_LIST_COMPONENT.

The list of layers can also be displayed as a layer tree. In this case, every ILcdGXYLayerList that was added using ILcyMapComponent.insertGXYLayer(com.luciad.view.gxy.ILcdGXYLayer) is displayed as a tree node, which can recursively be expanded, modeling the structure of the added ILcdGXYLayerLists. The layers that were never added using the insertGXYLayer method, but that are part of ILcdGXYView.layers() are put at the top level of the tree.

This factory is typically used during the creation of a ILcyMapComponent. E.g. this factory can be set to a TLcyMapComponentFactory using TLcyMapComponentFactory.setMapLayerControlFactory(ILcyMapLayerControlFactory).

  • Field Details

  • Constructor Details

    • TLcyMapLayerControlFactory

      public TLcyMapLayerControlFactory()
      Creates a new layer control factory. One will have to set the ILcyLucyEnv before using this object.
    • TLcyMapLayerControlFactory

      public TLcyMapLayerControlFactory(ILcyLucyEnv aLucyEnv)
      Creates a new layer control factory with the given ILcyLucyEnv.
      Parameters:
      aLucyEnv - The lucy environment.
    • TLcyMapLayerControlFactory

      public TLcyMapLayerControlFactory(ILcyLucyEnv aLucyEnv, String aConfigSourceName)
      Creates a new layer control factory with the given ILcyLucyEnv and the properties of the config file aConfigSourceName.
      Parameters:
      aLucyEnv - The lucy environment.
      aConfigSourceName - The source name (e.g., file name) of the configuration file. See setConfigSourceName(String).
  • Method Details

    • getLucyEnv

      public ILcyLucyEnv getLucyEnv()
      Description copied from interface: ILcyMapLayerControlFactory
      Returns the associated lucy environment.
      Specified by:
      getLucyEnv in interface ILcyMapLayerControlFactory
      Returns:
      The associated lucy environment.
    • setLucyEnv

      public void setLucyEnv(ILcyLucyEnv aLucyEnv)
      Description copied from interface: ILcyMapLayerControlFactory
      Sets the lucy environment.
      Specified by:
      setLucyEnv in interface ILcyMapLayerControlFactory
      Parameters:
      aLucyEnv - The lucy environment.
      See Also:
    • getConfigSourceName

      public String getConfigSourceName()
      Description copied from interface: ILcyMapLayerControlFactory
      Returns the configuration source name. Default is null.
      Specified by:
      getConfigSourceName in interface ILcyMapLayerControlFactory
      Returns:
      the configuration source name.
      See Also:
    • setConfigSourceName

      public void setConfigSourceName(String aConfigSourceName)
      Description copied from interface: ILcyMapLayerControlFactory
      Sets the configuration source name. This configuration file can be used to allow to configure the behavior of this factory. Note that this is an optional property that can be left null.
      Specified by:
      setConfigSourceName in interface ILcyMapLayerControlFactory
      Parameters:
      aConfigSourceName - The source name (e.g. file name) of the configuration file.
      See Also:
    • createMapLayerControl

      public ILcyMapLayerControl createMapLayerControl(ILcyMapComponent aMapComponent)
      Creates a new TLcyMapLayerControl for the given map component. The given map component must be an instance of TLcyMapComponent.
      Specified by:
      createMapLayerControl in interface ILcyMapLayerControlFactory
      Parameters:
      aMapComponent - The TLcyMapComponent to create a layer control for.
      Returns:
      The newly created layer control.
    • createEmptyMapLayerControl

      protected TLcyMapLayerControl createEmptyMapLayerControl(TLcyMapComponent aMapComponent)
      Creates an empty layer control, without any content, buttons or panels.
      Parameters:
      aMapComponent - The map component to create the layer control for.
      Returns:
      The new layer control.
    • createAndSetLayout

      protected void createAndSetLayout(TLcyMapLayerControl aLayerControlSFCT)
      Creates and sets the layout to the given layer control.
      Parameters:
      aLayerControlSFCT - The layer control to set the layer to.
    • finalizeCreation

      protected void finalizeCreation(TLcyMapLayerControl aLayerControl)
      Method called to finalize the creation process. Can be used for clean up tasks etc.
      Parameters:
      aLayerControl - The map component under construction.
    • createAction

      protected ILcdAction createAction(int aID, TLcyMapLayerControl aLayerControl)
      Creates an action.
      Parameters:
      aID - An id defined in this class ending in ACTION.
      aLayerControl - The layer control to create the action for.
      Returns:
      The newly created action.
    • createActiveSettable

      protected ILcyActiveSettable createActiveSettable(int aID, TLcyMapLayerControl aLayerControl)
      Creates an active settable.
      Parameters:
      aID - An id defined in this class ending in ACTIVE_SETTABLE.
      aLayerControl - The layer control to create the active settable for.
      Returns:
      The newly created active settable.
    • createComponent

      protected Component createComponent(int aID, TLcyMapLayerControl aLayerControl)
      Creates a component.
      Parameters:
      aID - An id defined in this class ending in COMPONENT.
      aLayerControl - The layer control to create the active settable for.
      Returns:
      The newly created component.
    • createTree

      protected JTree createTree(int aID, TLcyMapLayerControl aMapLayerControl)
      Creates a JTree which will be used in the map layer control.
      Parameters:
      aID - must be LAYER_TREE_COMPONENT__TREE or LAYER_LIST_COMPONENT__TREE
      aMapLayerControl - the map layer control to create the tree for
      Returns:
      the JTree which will be used in the map layer control
    • createTreeModel

      protected TreeModel createTreeModel(int aID, TLcyMapLayerControl aMapLayerControl)
      Creates the TreeModel used by the JTree of the map layer control
      Parameters:
      aID - must be LAYER_TREE_COMPONENT__TREE_MODEL or LAYER_LIST_COMPONENT__TREE_MODEL
      aMapLayerControl - the map layer control
      Returns:
      the TreeModel used by the JTree of the map layer control
    • createTreeCellRenderer

      protected TreeCellRenderer createTreeCellRenderer(int aID, TLcyMapLayerControl aMapLayerControl)
      Creates the TreeCellRenderer used by the JTree of the map layer control
      Parameters:
      aID - must be LAYER_TREE_COMPONENT__TREE_CELL_RENDERER or LAYER_LIST_COMPONENT__TREE_CELL_RENDERER
      aMapLayerControl - the map layer control
      Returns:
      the TreeCellRenderer used by the JTree of the map layer control
    • createEnabledFilter

      protected ILcdFilter<ILcdGXYLayer> createEnabledFilter(int aID, ILcyMapLayerControl aLayerControl)

      Creates an ILcdFilter for the corresponding actions and active settables. 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 defaut implementation.

      Following example demonstrates how you could override this method:

      
      
       protected ILcdFilter<ILcdGXYLayer> createEnabledFilter( int aID, ILcyMapLayerControl aLayerControl ) {
          switch ( aID ){
      
            // create a filter that will disable the visibility checkbox for specific layers.
            case LAYER_VISIBLE_ACTIVE_SETTABLE_ENABLED_FILTER:
              TLcyCompositeAndFilter<ILcdGXYLayer> my_filter = new TLcyCompositeAndFilter<ILcdGXYLayer>();
              // Make sure we use the filter created by the super implementation.
              // This filter will never be null.
              my_filter.addFilter( super.createEnabledFilter( aID, aLayerControl ) );
      
              // do not accept layers that have a model with a MyModelDescriptor as modeldescriptor.
              my_filter.addFilter( new ILcdFilter<ILcdGXYLayer>(){
                public boolean accept( ILcdGXYLayer aLayer ){
                  return !( aLayer.getModel().getModelDescriptor() instanceof MyModelDescriptor );
                }
              } );
              return my_filter;
      
            default:
              return super.createEnabledFilter( aID, aLayerControl );
          }
        }
       

      Parameters:
      aID - The ID indicating for which action or active settable the filter applies. It is an ID defined in this class ending in *_ENABLED_FILTER.
      aLayerControl - The layer control for which to create the filter.
      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.
    • insertComponentInActionBar

      protected void insertComponentInActionBar(int aID, Component aComponent, TLcyMapLayerControl aMapLayerControl)

      Inserts the given component in the regular action bar (see TLcyMapLayerControl.getActionBar()) of the given map layer control. Note that this action bar must be an ILcyToolBar for this method to be able to insert the component.

      Parameters:
      aID - The ID that was used to create the component. Must be DELETE_COMPONENT. Subclasses may choose to accept extra ID's.
      aComponent - The component that should be inserted. May be null.
      aMapLayerControl - The map layer control in whose action bar the component should be inserted. This is never null.
    • insertComponentInOrderBar

      protected void insertComponentInOrderBar(int aID, Component aComponent, TLcyMapLayerControl aMapLayerControl)

      Inserts the given component in the order action bar (see TLcyMapLayerControl.getOrderActionBar()) of the given map layer control. Note that this action bar must be an ILcyToolBar for this method to be able to insert the component.

      Parameters:
      aID - The ID that was used to create the component. Must be DELETE_COMPONENT. Subclasses may choose to accept extra ID's.
      aComponent - The component that should be inserted. May be null.
      aMapLayerControl - The map layer control in whose order action bar the component should be inserted. This is never null.
    • insertComponent

      protected void insertComponent(int aID, Component aComponent, TLcyMapLayerControl aLayerControlSFCT)
      Inserts the given component into the given layer control.
      Parameters:
      aID - The id that was used to create aComponent (must end with COMPONENT).
      aComponent - The component to insert.
      aLayerControlSFCT - The layer control to insert the component into.
    • createActionBar

      protected ILcyActionBar createActionBar(TLcyMapLayerControl aLayerControl)
      Creates an empty action bar.
      Parameters:
      aLayerControl - The layer control to create the action bar for.
      Returns:
      The newly created action bar.
    • createActionBar

      protected ILcyActionBar createActionBar(int aID, TLcyMapLayerControl aLayerControl)
      Creates an empty action bar.
      Parameters:
      aID - The ID of the action bar. Should be one of ACTION_BAR or ORDER_ACTION_BAR. Subclasses may choose to accept extra ID's.
      aLayerControl - The layer control for which to create the action bar. This is never null.
      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.
    • createPopupMenu

      protected ILcyPopupMenu createPopupMenu(int aID, TLcyMapLayerControl aLayerControl)
      Creates an empty popup menu.
      Parameters:
      aID - The ID of the requested popup menu. Should be POPUP_ACTION_BAR. Subclasses can choose to accept extra ID's.
      aLayerControl - The layer control for which to create the popup menu.
      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.
    • insertActionBar

      protected void insertActionBar(ILcyActionBar aActionBar, TLcyMapLayerControl aLayerControlSFCT)

      Insert the given action bar into the given layer control.

      Note that this method is here primarily for backwards compatibility reasons. Instead of overriding this method, you should override insertActionBar(int, com.luciad.lucy.gui.ILcyActionBar, com.luciad.lucy.map.TLcyMapLayerControl) which was added in a later release.

      Parameters:
      aActionBar - The action bar to insert.
      aLayerControlSFCT - The layer control to insert the action bar into.
    • insertActionBar

      protected void insertActionBar(int aID, ILcyActionBar aActionBar, TLcyMapLayerControl aLayerControlSFCT)

      Inserts the given action bar into the given layer control.

      In case the ID is ACTION_BAR, this method delegates the insertion to the insertActionBar(com.luciad.lucy.gui.ILcyActionBar, TLcyMapLayerControl) method for backwards compatibility reasons. Note that subclasses may choose not to do this.

      Parameters:
      aID - The ID of the given action bar. Should be one of ACTION_BAR or ORDER_ACTION_BAR. Subclasses may choose to accept extra ID's.
      aActionBar - The action bar to insert. This may be null.
      aLayerControlSFCT - The layer control to insert the action bar into. This is never null.
    • insertAction

      protected void insertAction(int aID, ILcdAction aAction, TLcyMapLayerControl aLayerControlSFCT)
      Inserts the given action into the action bar, order bar and popup menu of the given layer control. It does this by delegating to the insertActionIn... methods.
      Parameters:
      aID - The id that was used to create the action. Must be one of the constants defined in this class that ends with _ACTION. Subclasses may choose to accept extra ID's.
      aAction - The action to insert. This may be null.
      aLayerControlSFCT - The layer control to insert the action into. This is never null
      See Also:
    • insertActionInActionBar

      protected void insertActionInActionBar(int aID, ILcdAction aAction, TLcyMapLayerControl aLayerControlSFCT)
      Inserts the given action into the regular action bar of the given layer control.
      Parameters:
      aID - The ID that was used to create the action. Must be one of the constants defined in this class that ends with _ACTION. Subclasses may choose to accept extra ID's.
      aAction - The action to insert. This may be null.
      aLayerControlSFCT - The layer control in whose action bar the action should be inserted. This is never null.
    • insertActionInOrderBar

      protected void insertActionInOrderBar(int aID, ILcdAction aAction, TLcyMapLayerControl aLayerControlSFCT)
      Inserts the given action into the order action bar of the given layer control.
      Parameters:
      aID - The ID that was used to create the action. Must be one of the constants defined in this class that ends with _ACTION. Subclasses may choose to accept extra ID's.
      aAction - The action to insert. This may be null.
      aLayerControlSFCT - The layer control in whose order bar the action should be inserted. This is never null.
    • insertActionInPopupMenu

      protected void insertActionInPopupMenu(int aID, ILcdAction aAction, TLcyMapLayerControl aLayerControlSFCT)
      Inserts the given action into the popup menu of the given layer control.
      Parameters:
      aID - The ID that was used to create the action. Must be one of the constants defined in this class that ends with _ACTION. Subclasses may choose to accept extra ID's.
      aAction - The action to insert. This may be null.
      aLayerControlSFCT - The layer control in whose popup menu the action should be inserted. This is never null.
    • insertActiveSettable

      protected void insertActiveSettable(int aID, ILcyActiveSettable aActiveSettable, TLcyMapLayerControl aLayerControlSFCT)
      Inserts the given active settable into the action bar, order bar and popup menu of the given layer control. It does this by delegating to the insertActiveSettableIn... methods
      Parameters:
      aID - The id that was used to create the active settable (must end with ACTIVE_SETTABLE).
      aActiveSettable - The active settable to insert.
      aLayerControlSFCT - The layer control to insert the active settable into.
      See Also:
    • insertActiveSettableInActionBar

      protected void insertActiveSettableInActionBar(int aID, ILcyActiveSettable aActiveSettable, TLcyMapLayerControl aLayerControlSFCT)
      Inserts the given active settable into the regular action bar of the given layer control.
      Parameters:
      aID - The ID that was used to create the active settable. Must be one of the constants defined in this class that ends with _ACTIVE_SETTABLE. Subclasses may choose to accept extra ID's.
      aActiveSettable - The active settable to insert. This may be null.
      aLayerControlSFCT - The layer control in whose action bar the active settable should be inserted. This is never null.
    • insertActiveSettableInOrderBar

      protected void insertActiveSettableInOrderBar(int aID, ILcyActiveSettable aActiveSettable, TLcyMapLayerControl aLayerControlSFCT)
      Inserts the given active settable into the order action bar of the given layer control.
      Parameters:
      aID - The ID that was used to create the active settable. Must be one of the constants defined in this class that ends with _ACTIVE_SETTABLE. Subclasses may choose to accept extra ID's.
      aActiveSettable - The active settable to insert. This may be null.
      aLayerControlSFCT - The layer control in whose order bar the active settable should be inserted. This is never null.
    • insertActiveSettableInPopupMenu

      protected void insertActiveSettableInPopupMenu(int aID, ILcyActiveSettable aActiveSettable, TLcyMapLayerControl aLayerControlSFCT)
      Inserts the given active settable into the popup menu of the given layer control.
      Parameters:
      aID - The ID that was used to create the active settable. Must be one of the constants defined in this class that ends with _ACTIVE_SETTABLE. Subclasses may choose to accept extra ID's.
      aActiveSettable - The active settable to insert. This may be null.
      aLayerControlSFCT - The layer control in whose popup menu the active settable should be inserted. This is never null.