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)
.
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static int |
ADD_LEVEL_ACTION
Action that adds a level to the
TLcdColorMap . |
static int |
BOTTOM_TO_TOP
Bottom to top orientation.
|
static int |
GRADIENT_TOGGLE_ACTION
Action that toggles gradient of the
TLcdColorMap , see
TLcdColorMap.isGradient() . |
static int |
LEFT_TO_RIGHT
Left to right orientation.
|
static int |
LINEAR_SCALE_TOGGLE_ACTION
Action that toggles between linear scale or not.
|
static int |
MAIN_PANEL
Constant that represents the main panel, containing the color bar and the arrows.
|
static int |
MASTER_TRANSPARENCY_PANEL
Constant that represents the panel containing the master transparency slider, see
TLcdColorMap.setMasterOpacity(int) . |
static int |
REMOVE_LEVEL_ACTION
Action that removes the selected level from the
TLcdColorMap . |
static int |
REVERT_TO_DEFAULT_ACTION
Action that reverts the coloring to the one specified by
setDefaultColorMap(com.luciad.util.TLcdColorMap) . |
static int |
RIGHT_TO_LEFT
Right to left orientation.
|
static int |
SET_LEVELS_ACTION
Action that sets all the levels of the
TLcdColorMap at once. |
static int |
TOOL_BAR_PANEL
Constant that represents the tool bar panel.
|
static int |
TOP_TO_BOTTOM
Top to bottom orientation.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
TLcdColorMapCustomizer()
Creates a new color map customizer with BOTTOM_TO_TOP orientation.
|
TLcdColorMapCustomizer(int aOrientation)
Creates a new color map customizer.
|
Modifier and Type | Method and Description |
---|---|
protected ILcdAction |
createAction(int aActionID)
Creates an
ILcdAction for the given ID. |
protected Component |
createGUIContent()
Retrieves all panels and lays them out in a
java.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 set
TLcdColorMap if needed. |
protected ILcdAction |
getAction(int aActionID)
Returns the
ILcdAction for the given ID. |
TLcdColorMap |
getColorMap()
Returns the
TLcdColorMap that was set using setObject . |
TLcdColorMap |
getDefaultColorMap()
Returns the default color map.
|
Format |
getLevelFormat()
Returns the level format.
|
Object |
getObject()
Returns the
TLcdColorMap that was set using setObject . |
protected Component |
getPanel(int aPanelID)
Returns the panel as a
java.awt.Component for the given ID. |
Component |
getParentComponent()
Returns the parent component.
|
ILcdStringTranslator |
getTranslator()
Returns the translator.
|
ILcdInterval |
getVisibleInterval()
Returns the visible interval of the color bar.
|
boolean |
isGradientToggleable()
Returns true if the gradient toggle button is available in the user
interface.
|
boolean |
isLinearScale()
Returns
true if linear scale is activated, false otherwise. |
boolean |
isMasterTransparencyVisible()
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 |
setObject(Object aBean)
Sets the
TLcdColorMap 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.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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
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
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, getPeer, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addPropertyChangeListener, removePropertyChangeListener
public static final int LEFT_TO_RIGHT
TLcdColorMapCustomizer(int)
,
Constant Field Valuespublic static final int RIGHT_TO_LEFT
TLcdColorMapCustomizer(int)
,
Constant Field Valuespublic static final int BOTTOM_TO_TOP
TLcdColorMapCustomizer(int)
,
Constant Field Valuespublic static final int TOP_TO_BOTTOM
TLcdColorMapCustomizer(int)
,
Constant Field Valuespublic static final int ADD_LEVEL_ACTION
TLcdColorMap
.createAction(int)
,
Constant Field Valuespublic static final int REMOVE_LEVEL_ACTION
TLcdColorMap
.createAction(int)
,
Constant Field Valuespublic static final int SET_LEVELS_ACTION
TLcdColorMap
at once.createAction(int)
,
Constant Field Valuespublic static final int GRADIENT_TOGGLE_ACTION
TLcdColorMap
, see
TLcdColorMap.isGradient()
.createAction(int)
,
Constant Field Valuespublic static final int LINEAR_SCALE_TOGGLE_ACTION
isLinearScale()
.createAction(int)
,
Constant Field Valuespublic static final int REVERT_TO_DEFAULT_ACTION
setDefaultColorMap(com.luciad.util.TLcdColorMap)
.
The button is only visible if the default color map is not null
.createAction(int)
,
Constant Field Valuespublic static final int TOOL_BAR_PANEL
createPanel(int)
,
Constant Field Valuespublic static final int MAIN_PANEL
createPanel(int)
,
Constant Field Valuespublic static final int MASTER_TRANSPARENCY_PANEL
TLcdColorMap.setMasterOpacity(int)
.createPanel(int)
,
Constant Field Valuespublic TLcdColorMapCustomizer()
setObject
before the customizer can be used.public TLcdColorMapCustomizer(int aOrientation)
setObject
before the customizer can be used.aOrientation
- The orientation for the customizer: LEFT_TO_RIGHT,
RIGHT_TO_LEFT, BOTTOM_TO_TOP or TOP_TO_BOTTOM.protected ILcdAction getAction(int aActionID)
Returns the ILcdAction
for the given ID.
Please refer to createGUIContent
to know when this method can be used.
aActionID
- The id describing which action to return. This is normally a constant that
ends in ACTION
.ILcdAction
for the given ID.protected ILcdAction createAction(int aActionID)
Creates an ILcdAction
for the given ID.
aActionID
- the ID describing which action to create. This is normally a constant that
ends with ACTION
.ILcdAction
, or null
.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.
aPanelID
- the ID describing which panel to return. This is normally a constant that ends
with PANEL
.java.awt.Component
for the given ID.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 );
}
}
aPanelID
- the ID describing which panel to create. This is normally a constant that
ends with PANEL
.java.awt.Component
, or null.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;
}
public Component getParentComponent()
getParentComponent()
public void setParentComponent(Component aParentComponent)
aParentComponent
- The parent component to set.getParentComponent()
public boolean isLinearScale()
true
if linear scale is activated, false
otherwise.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.
aLinearScale
- true
if linear scale is activated, false
otherwise.public ILcdInterval getVisibleInterval()
setVisibleInterval(com.luciad.util.ILcdInterval)
public void setVisibleInterval(ILcdInterval aVisibleInterval)
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.aVisibleInterval
- The visible interval. The aVisibleInterval
must not be modified after it is passed to this method.getVisibleIntervalInternal()
public Format getLevelFormat()
setLevelFormat(java.text.Format)
public void setLevelFormat(Format aLevelFormat)
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.
aLevelFormat
- The new format for formatting and parsing level values.getLevelFormat()
public ILcdStringTranslator getTranslator()
setTranslator(com.luciad.util.ILcdStringTranslator)
public void setTranslator(ILcdStringTranslator aTranslator)
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:
aTranslator
- The translator to set.public boolean isGradientToggleable()
setGradientToggleable(boolean)
public void setGradientToggleable(boolean aGradientToggleable)
aGradientToggleable
- True if the gradient toggle button should be
available in the user interface, false otherwise.IllegalStateException:
- if a custom TOOL_BAR_PANEL
was created in
createPanel(int)
, or if the gradient action was removed by returning null from
createAction(int)
for GRADIENT_TOGGLE_ACTION
.isGradientToggleable()
public boolean isMasterTransparencyVisible()
true
if the master transparency panel is visible, false
otherwise.MASTER_TRANSPARENCY_PANEL
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.
aMasterTransparency
- true
to make the master transparency visible,
false
to hide it.MASTER_TRANSPARENCY_PANEL
public TLcdColorMap getDefaultColorMap()
setDefaultColorMap(com.luciad.util.TLcdColorMap)
.public void setDefaultColorMap(TLcdColorMap aDefaultColorMap)
null
, a button becomes available
that allows the user to revert to the default coloring. Default value is null
.aDefaultColorMap
- The default color map.public TLcdColorMap getColorMap()
TLcdColorMap
that was set using setObject
.TLcdColorMap
that was set using setObject
.setObject(Object)
public Object getObject()
TLcdColorMap
that was set using setObject
.TLcdColorMap
that was set using setObject
.setObject(Object)
public void setObject(Object aBean)
TLcdColorMap
to edit.setObject
in interface Customizer
aBean
- The TLcdColorMap
to edit.IllegalArgumentException
- If aBean is not an instance of TLcdColorMap
.getObject()
,
getColorMap()
protected void editColor(int aColorIndex)
TLcdColorMap
if needed.This implementation shows up an enhanced JColorChooser in a dialog.
aColorIndex
- The index of the color to edit.getColorMap()
public void setEnabled(boolean enabled)
setEnabled
in class JComponent