Class TLcdColorMapCustomizer
- All Implemented Interfaces:
ImageObserver,MenuContainer,Customizer,Serializable,Accessible
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).

- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAction that adds a level to theTLcdColorMap.static final intBottom to top orientation.static final intAction that toggles gradient of theTLcdColorMap, seeTLcdColorMap.isGradient().static final intLeft to right orientation.static final intAction that toggles between linear scale or not.static final intConstant that represents the main panel, containing the color bar and the arrows.static final intConstant that represents the panel containing the master transparency slider, seeTLcdColorMap.setMasterOpacity(int).static final intAction that removes the selected level from theTLcdColorMap.static final intAction that reverts the coloring to the one specified bysetDefaultColorMap(com.luciad.util.TLcdColorMap).static final intRight to left orientation.static final intAction that sets all the levels of theTLcdColorMapat once.static final intConstant that represents the tool bar panel.static final intTop to bottom orientation.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new color map customizer with BOTTOM_TO_TOP orientation.TLcdColorMapCustomizer(int aOrientation) Creates a new color map customizer. -
Method Summary
Modifier and TypeMethodDescriptionprotected ILcdActioncreateAction(int aActionID) Creates anILcdActionfor the given ID.protected ComponentRetrieves all panels and lays them out in ajava.awt.Component.protected ComponentcreatePanel(int aPanelID) Creates a panel for the given ID.protected voideditColor(int aColorIndex) Edits the color at the given index, and updates the setTLcdColorMapif needed.protected ILcdActiongetAction(int aActionID) Returns theILcdActionfor the given ID.Returns theTLcdColorMapthat was set usingsetObject.Returns the default color map.Returns the level format.Returns theTLcdColorMapthat was set usingsetObject.protected ComponentgetPanel(int aPanelID) Returns the panel as ajava.awt.Componentfor the given ID.Returns the parent component.Returns the translator.Returns the visible interval of the color bar.booleanReturns true if the gradient toggle button is available in the user interface.booleanReturnstrueif linear scale is activated,falseotherwise.booleanModifies the visibility of the master transparency panel.voidsetDefaultColorMap(TLcdColorMap aDefaultColorMap) Sets the default color map.voidsetEnabled(boolean enabled) voidsetGradientToggleable(boolean aGradientToggleable) Sets if the gradient toggle button should be available.voidsetLevelFormat(Format aLevelFormat) Sets the level format.voidsetLinearScale(boolean aLinearScale) Sets the linear scale property.voidsetMasterTransparencyVisible(boolean aMasterTransparency) Changes the visibility of the master transparency panel.voidSets theTLcdColorMapto edit.voidsetParentComponent(Component aParentComponent) Sets the parent component.voidsetTranslator(ILcdStringTranslator aTranslator) Sets the translator.voidsetVisibleInterval(ILcdInterval aVisibleInterval) Sets the visible interval of the color bar.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.beans.Customizer
addPropertyChangeListener, removePropertyChangeListener
-
Field Details
-
LEFT_TO_RIGHT
public static final int LEFT_TO_RIGHTLeft to right orientation.- See Also:
-
RIGHT_TO_LEFT
public static final int RIGHT_TO_LEFTRight to left orientation.- See Also:
-
BOTTOM_TO_TOP
public static final int BOTTOM_TO_TOPBottom to top orientation.- See Also:
-
TOP_TO_BOTTOM
public static final int TOP_TO_BOTTOMTop to bottom orientation.- See Also:
-
ADD_LEVEL_ACTION
public static final int ADD_LEVEL_ACTIONAction that adds a level to theTLcdColorMap.- See Also:
-
REMOVE_LEVEL_ACTION
public static final int REMOVE_LEVEL_ACTIONAction that removes the selected level from theTLcdColorMap.- See Also:
-
SET_LEVELS_ACTION
public static final int SET_LEVELS_ACTIONAction that sets all the levels of theTLcdColorMapat once.- See Also:
-
GRADIENT_TOGGLE_ACTION
public static final int GRADIENT_TOGGLE_ACTIONAction that toggles gradient of theTLcdColorMap, seeTLcdColorMap.isGradient().- See Also:
-
LINEAR_SCALE_TOGGLE_ACTION
public static final int LINEAR_SCALE_TOGGLE_ACTIONAction that toggles between linear scale or not. SeeisLinearScale().- See Also:
-
REVERT_TO_DEFAULT_ACTION
public static final int REVERT_TO_DEFAULT_ACTIONAction that reverts the coloring to the one specified bysetDefaultColorMap(com.luciad.util.TLcdColorMap). The button is only visible if the default color map is notnull.- See Also:
-
TOOL_BAR_PANEL
public static final int TOOL_BAR_PANELConstant that represents the tool bar panel.- See Also:
-
MAIN_PANEL
public static final int MAIN_PANELConstant that represents the main panel, containing the color bar and the arrows.- See Also:
-
MASTER_TRANSPARENCY_PANEL
public static final int MASTER_TRANSPARENCY_PANELConstant that represents the panel containing the master transparency slider, seeTLcdColorMap.setMasterOpacity(int).- See Also:
-
-
Constructor Details
-
TLcdColorMapCustomizer
public TLcdColorMapCustomizer()Creates a new color map customizer with BOTTOM_TO_TOP orientation. One still has usesetObjectbefore the customizer can be used. -
TLcdColorMapCustomizer
public TLcdColorMapCustomizer(int aOrientation) Creates a new color map customizer. One still has to usesetObjectbefore 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
Returns the
ILcdActionfor the given ID.Please refer to
createGUIContentto 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
ILcdActionfor the given ID.
-
createAction
Creates an
ILcdActionfor the given ID.- Parameters:
aActionID- the ID describing which action to create. This is normally a constant that ends withACTION.- Returns:
- the newly created
ILcdAction, ornull.
-
getPanel
Returns the panel as a
java.awt.Componentfor the given ID.Please refer to
createGUIContentto 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.Componentfor the given ID.
-
createPanel
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 withPANEL.- Returns:
- the newly created
java.awt.Component, or null.
-
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:
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
Returns the parent component.- Returns:
- the parent component.
- See Also:
-
setParentComponent
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:
trueif linear scale is activated,falseotherwise.
-
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:
If
false, the pixel distance between all levels is equal, regardless their level values:
When using non-linear scale, the visible interval is ignored.
The default value is non-linear.
- Parameters:
aLinearScale-trueif linear scale is activated,falseotherwise.
-
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
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 setTLcdColorMapand that the min of aVisbibleInterval is smaller than the max. The visible interval is ignored whenisLinearScale()returnsfalse, 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:
-
getLevelFormat
Returns the level format.- Returns:
- the level format.
- See Also:
-
setLevelFormat
Sets the level format. ThisFormatis 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
Formatneeds to acceptNumberobjects in its format methods. It should as well returnNumberinstances in its parse methods.- Parameters:
aLevelFormat- The new format for formatting and parsing level values.- See Also:
-
getTranslator
Returns the translator.- Returns:
- the translator.
- See Also:
-
setTranslator
Sets the translator. TheILcdStringTranslatoraTranslator can be used to translate text. Note that the String object can contain '{0}'-like parameters. Please refer tojava.text.MessageFormatfor 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"
- 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:
trueif the master transparency panel is visible,falseotherwise.- 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-trueto make the master transparency visible,falseto hide it.- See Also:
-
getDefaultColorMap
Returns the default color map. Note: it might be a different instance than the one set usingsetDefaultColorMap(com.luciad.util.TLcdColorMap).- Returns:
- the default color map.
-
setDefaultColorMap
Sets the default color map. If different fromnull, a button becomes available that allows the user to revert to the default coloring. Default value isnull.- Parameters:
aDefaultColorMap- The default color map.
-
getColorMap
Returns theTLcdColorMapthat was set usingsetObject.- Returns:
- the
TLcdColorMapthat was set usingsetObject. - See Also:
-
getObject
Returns theTLcdColorMapthat was set usingsetObject.- Returns:
- the
TLcdColorMapthat was set usingsetObject. - See Also:
-
setObject
Sets theTLcdColorMapto edit.- Specified by:
setObjectin interfaceCustomizer- Parameters:
aBean- TheTLcdColorMapto edit.- Throws:
IllegalArgumentException- If aBean is not an instance ofTLcdColorMap.- See Also:
-
editColor
protected void editColor(int aColorIndex) Edits the color at the given index, and updates the setTLcdColorMapif 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:
setEnabledin classJComponent
-