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.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Action that adds a level to theTLcdColorMap
.static final int
Bottom to top orientation.static final int
Action that toggles gradient of theTLcdColorMap
, seeTLcdColorMap.isGradient()
.static final int
Left to right orientation.static final int
Action that toggles between linear scale or not.static final int
Constant that represents the main panel, containing the color bar and the arrows.static final int
Constant that represents the panel containing the master transparency slider, seeTLcdColorMap.setMasterOpacity(int)
.static final int
Action that removes the selected level from theTLcdColorMap
.static final int
Action that reverts the coloring to the one specified bysetDefaultColorMap(com.luciad.util.TLcdColorMap)
.static final int
Right to left orientation.static final int
Action that sets all the levels of theTLcdColorMap
at once.static final int
Constant that represents the tool bar panel.static final int
Top 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_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
ConstructorDescriptionCreates a new color map customizer with BOTTOM_TO_TOP orientation.TLcdColorMapCustomizer
(int aOrientation) Creates a new color map customizer. -
Method Summary
Modifier and TypeMethodDescriptionprotected ILcdAction
createAction
(int aActionID) Creates anILcdAction
for the given ID.protected Component
Retrieves all panels and lays them out in ajava.awt.Component
.protected Component
createPanel
(int aPanelID) Creates a panel for the given ID.protected void
editColor
(int aColorIndex) Edits the color at the given index, and updates the setTLcdColorMap
if needed.protected ILcdAction
getAction
(int aActionID) Returns theILcdAction
for the given ID.Returns theTLcdColorMap
that was set usingsetObject
.Returns the default color map.Returns the level format.Returns theTLcdColorMap
that was set usingsetObject
.protected Component
getPanel
(int aPanelID) Returns the panel as ajava.awt.Component
for the given ID.Returns the parent component.Returns the translator.Returns the visible interval of the color bar.boolean
Returns true if the gradient toggle button is available in the user interface.boolean
Returnstrue
if linear scale is activated,false
otherwise.boolean
Modifies the visibility of the master transparency panel.void
setDefaultColorMap
(TLcdColorMap aDefaultColorMap) Sets the default color map.void
setEnabled
(boolean enabled) void
setGradientToggleable
(boolean aGradientToggleable) Sets if the gradient toggle button should be available.void
setLevelFormat
(Format aLevelFormat) Sets the level format.void
setLinearScale
(boolean aLinearScale) Sets the linear scale property.void
setMasterTransparencyVisible
(boolean aMasterTransparency) Changes the visibility of the master transparency panel.void
Sets theTLcdColorMap
to edit.void
setParentComponent
(Component aParentComponent) Sets the parent component.void
setTranslator
(ILcdStringTranslator aTranslator) Sets the translator.void
setVisibleInterval
(ILcdInterval aVisibleInterval) Sets the visible interval of the color bar.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods 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, update
Methods 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, validateTree
Methods 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, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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 theTLcdColorMap
at 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 usesetObject
before the customizer can be used. -
TLcdColorMapCustomizer
public TLcdColorMapCustomizer(int aOrientation) Creates a new color map customizer. One still has to usesetObject
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
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 inACTION
.- Returns:
- the
ILcdAction
for the given ID.
-
createAction
Creates an
ILcdAction
for 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.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 withPANEL
.- Returns:
- the panel as a
java.awt.Component
for 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:
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: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
-true
if linear scale is activated,false
otherwise.
-
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 setTLcdColorMap
and 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. ThisFormat
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 acceptNumber
objects in its format methods. It should as well returnNumber
instances 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. TheILcdStringTranslator
aTranslator can be used to translate text. Note that the String object can contain '{0}'-like parameters. Please refer tojava.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"
- 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
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 theTLcdColorMap
that was set usingsetObject
.- Returns:
- the
TLcdColorMap
that was set usingsetObject
. - See Also:
-
getObject
Returns theTLcdColorMap
that was set usingsetObject
.- Returns:
- the
TLcdColorMap
that was set usingsetObject
. - See Also:
-
setObject
Sets theTLcdColorMap
to edit.- Specified by:
setObject
in interfaceCustomizer
- Parameters:
aBean
- TheTLcdColorMap
to 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 setTLcdColorMap
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 classJComponent
-