Class TLcdColorMapCustomizer

All Implemented Interfaces:
ImageObserver, MenuContainer, Customizer, Serializable, Accessible

public class TLcdColorMapCustomizer extends JPanel implements Customizer
Customizer for a TLcdColorMap object. It has a color bar showing the current coloring of the TLcdColorMap and arrows indicating the levels. The arrows can be dragged with the mouse to a new level. The levels can also be changed using a text field. The visible range (part of the total range defined by TLcdColorMap.getLevelInterval()) can be modified by editing the minimum and maximum texts. Levels and be added/removed by pressing the plus/min button. All levels can be set at once as well, and there is a button to toggle the gradient mode of the TLcdColorMap. The right-most button toggles the linear scale mode. The colors can be modified by clicking on the little color buttons, or by clicking on the color bar. When the focus is on an arrow, the next and previous arrow can be selected using the arrow keys.

A TLcdColorMap object must be set before adding this component to some parent container. It is valid to set a new TLcdColorMap object after this Customizer has been made visible.

The levels are formatted using a Format which can be changed using setLevelFormat(java.text.Format).

Strings are internationalized using a ILcdStringTranslator, which can be changed using setTranslator(com.luciad.util.ILcdStringTranslator).

Colors are visually modified using the protected editColor method. This method can be overridden to modify the color chooser functionality.

The layout can be adapted using createGUIContent() and createPanel(int). The actions in the tool bar can be modified or removed using createAction(int).

Some quick tuning of the UI is possible using setGradientToggleable(boolean), setMasterTransparencyVisible(boolean) and setDefaultColorMap(com.luciad.util.TLcdColorMap).

Screenshot

See Also:
  • Field Details

  • Constructor Details

    • TLcdColorMapCustomizer

      public TLcdColorMapCustomizer()
      Creates a new color map customizer with BOTTOM_TO_TOP orientation. One still has use setObject before the customizer can be used.
    • TLcdColorMapCustomizer

      public TLcdColorMapCustomizer(int aOrientation)
      Creates a new color map customizer. One still has to use setObject before the customizer can be used.
      Parameters:
      aOrientation - The orientation for the customizer: LEFT_TO_RIGHT, RIGHT_TO_LEFT, BOTTOM_TO_TOP or TOP_TO_BOTTOM.
  • Method Details

    • 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.
    • createAction

      protected ILcdAction createAction(int aActionID)

      Creates an ILcdAction for the given ID.

      Parameters:
      aActionID - the ID describing which action to create. This is normally a constant that ends with ACTION.
      Returns:
      the newly created ILcdAction, or null.
    • 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.
    • createPanel

      protected Component createPanel(int aPanelID)

      Creates a panel for the given ID. It is safe to use getAction(int) in this method, to build panels that are composed of actions.

      An example implementation could be:

      
       protected Component createPanel( int aPanelID ) {
         if ( aPanelID == TOOL_BAR_PANEL ) {
           JToolBar toolBar = new JToolBar();
           toolBar.setFloatable( false );
      
           // Add existing action
           ILcdAction action = getAction( ADD_LEVEL_ACTION );
           if ( action != null ) toolBar.add( new TLcdSWAction( action ) );
      
           ILcdAction toggle = getAction( GRADIENT_TOGGLE_ACTION );
           if ( toggle != null ) toolBar.add( new JToggleButton( new TLcdSWAction( toggle ) ) );
      
           // Add custom action
           ILcdAction myAction = new ALcdAction( "My Action" ) {
             public void actionPerformed( ActionEvent e ) {
               TLcdColorMap colorMap = getColorMap();
               //Change colorMap: be sure to respect its documentation !!
             }
           };
           toolBar.add( new TLcdSWAction( myAction ) );
           return toolBar;
         }
         else {
           return super.createPanel( aPanelID );
         }
       }
       

      Parameters:
      aPanelID - the ID describing which panel to create. This is normally a constant that ends with PANEL.
      Returns:
      the newly created java.awt.Component, or null.
    • createGUIContent

      protected Component createGUIContent()

      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:

      
       protected Component createGUIContent() {
         JPanel panel = new JPanel();
         panel.setLayout( new BoxLayout( panel, BoxLayout.Y_AXIS ) );
      
         Component toolBar = getPanel( TOOL_BAR_PANEL );
         if ( toolBar != null ) panel.add( toolBar );
      
         Component main = getPanel( MAIN_PANEL );
         if ( main != null ) panel.add( main );
      
         return panel;
       }
       

      Returns:
      the component containing all panels, layed out appropriately.
    • getParentComponent

      public Component getParentComponent()
      Returns the parent component.
      Returns:
      the parent component.
      See Also:
    • setParentComponent

      public void setParentComponent(Component aParentComponent)
      Sets the parent component. This parent component is used to have a parent for popping up dialogs. If no parent component is specified (default), the parent window of 'this' will be used.
      Parameters:
      aParentComponent - The parent component to set.
      See Also:
    • isLinearScale

      public boolean isLinearScale()
      Returns true if linear scale is activated, false otherwise. See also setLinearScale(boolean).
      Returns:
      true if linear scale is activated, false otherwise.
    • setLinearScale

      public void setLinearScale(boolean aLinearScale)

      Sets the linear scale property. If true, the levels of the color map are plotted on a linear scale:

      Linear scale

      If false, the pixel distance between all levels is equal, regardless their level values:

      Non linear scale

      When using non-linear scale, the visible interval is ignored.

      The default value is non-linear.

      Parameters:
      aLinearScale - true if linear scale is activated, false otherwise.
    • getVisibleInterval

      public ILcdInterval getVisibleInterval()
      Returns the visible interval of the color bar. The returned interval must not be modified.
      Returns:
      the visible interval of the color bar.
      See Also:
    • setVisibleInterval

      public void setVisibleInterval(ILcdInterval aVisibleInterval)
      Sets the visible interval of the color bar. It is the responsibility of the user of this method to make sure that the visible interval is within the level interval of the set TLcdColorMap and that the min of aVisbibleInterval is smaller than the max. The visible interval is ignored when isLinearScale() returns false, in that case the whole interval of the color map is visible.
      Parameters:
      aVisibleInterval - The visible interval. The aVisibleInterval must not be modified after it is passed to this method.
      See Also:
      • getVisibleIntervalInternal()
    • getLevelFormat

      public Format getLevelFormat()
      Returns the level format.
      Returns:
      the level format.
      See Also:
    • setLevelFormat

      public void setLevelFormat(Format aLevelFormat)
      Sets the level format. This Format is used to format and parse the levels displayed and entered by the user. You can use this format to represent the levels in some specific unit, or to make conversions from the levels to a human readable value.

      The Format needs to accept Number objects in its format methods. It should as well return Number instances in its parse methods.

      Parameters:
      aLevelFormat - The new format for formatting and parsing level values.
      See Also:
    • getTranslator

      public ILcdStringTranslator getTranslator()
      Returns the translator.
      Returns:
      the translator.
      See Also:
    • setTranslator

      public void setTranslator(ILcdStringTranslator aTranslator)
      Sets the translator. The ILcdStringTranslator aTranslator can be used to translate text. Note that the String object can contain '{0}'-like parameters. Please refer to java.text.MessageFormat for more information.

      The list of strings given to this translator are:

      • "Choose Color"
      • "Add a level"
      • "Remove selected level"
      • "Set all levels ..."
      • "Enter levels"
      • "Minimum must be smaller than maximum"
      • "Could not parse one or more values"
      • "Minimum"
      • "Maximum"
      • "Delta"
      • "OK"
      • "Cancel"
      • "Gradient toggle"
      • "Minimum must be larger than {0}"
      • "Maximum must be smaller than {0}"
      • "Delta must be larger than {0}"
      • "Linear scale toggle"
      • "Master transparency"
      • "Revert to default coloring"
      Please be aware that this list of strings can change between versions of LuciadLightspeed.
      Parameters:
      aTranslator - The translator to set.
    • isGradientToggleable

      public boolean isGradientToggleable()
      Returns true if the gradient toggle button is available in the user interface.
      Returns:
      true if the gradient toggle button is available in the user interface.
      See Also:
    • setGradientToggleable

      public void setGradientToggleable(boolean aGradientToggleable)
      Sets if the gradient toggle button should be available.
      Parameters:
      aGradientToggleable - True if the gradient toggle button should be available in the user interface, false otherwise.
      See Also:
    • isMasterTransparencyVisible

      public boolean isMasterTransparencyVisible()
      Modifies the visibility of the master transparency panel.
      Returns:
      true if the master transparency panel is visible, false otherwise.
      See Also:
    • setMasterTransparencyVisible

      public void setMasterTransparencyVisible(boolean aMasterTransparency)

      Changes the visibility of the master transparency panel.

      Note that when the master transparency panel is replaced or removed using createPanel(int), this setter has no effect.

      Parameters:
      aMasterTransparency - true to make the master transparency visible, false to hide it.
      See Also:
    • getDefaultColorMap

      public TLcdColorMap getDefaultColorMap()
      Returns the default color map. Note: it might be a different instance than the one set using setDefaultColorMap(com.luciad.util.TLcdColorMap).
      Returns:
      the default color map.
    • setDefaultColorMap

      public void setDefaultColorMap(TLcdColorMap aDefaultColorMap)
      Sets the default color map. If different from null, a button becomes available that allows the user to revert to the default coloring. Default value is null.
      Parameters:
      aDefaultColorMap - The default color map.
    • getColorMap

      public TLcdColorMap getColorMap()
      Returns the TLcdColorMap that was set using setObject.
      Returns:
      the TLcdColorMap that was set using setObject.
      See Also:
    • getObject

      public Object getObject()
      Returns the TLcdColorMap that was set using setObject.
      Returns:
      the TLcdColorMap that was set using setObject.
      See Also:
    • setObject

      public void setObject(Object aBean)
      Sets the TLcdColorMap to edit.
      Specified by:
      setObject in interface Customizer
      Parameters:
      aBean - The TLcdColorMap to edit.
      Throws:
      IllegalArgumentException - If aBean is not an instance of TLcdColorMap.
      See Also:
    • editColor

      protected void editColor(int aColorIndex)
      Edits the color at the given index, and updates the set TLcdColorMap if needed.

      This implementation shows up an enhanced JColorChooser in a dialog.

      Parameters:
      aColorIndex - The index of the color to edit.
      See Also:
    • setEnabled

      public void setEnabled(boolean enabled)
      Overrides:
      setEnabled in class JComponent