visad.util
Class BaseRGBMap
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- visad.util.ColorMap
-
- visad.util.BaseRGBMap
-
- All Implemented Interfaces:
- java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, ControlListener
public class BaseRGBMap extends ColorMap implements ControlListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
An extensible RGB colormap with no interpolation between the internally stored values. Click and drag with the left mouse button to draw the color curves. Click with the right or middle mouse button to alternate between the color curves.- Since:
- Visad Utility Library, 0.5
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field and Description static intDEFAULT_RESOLUTIONdefault resolutionstatic booleanUSE_COLOR_CURSORSchange this to true to use color cursors-
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor and Description BaseRGBMap(BaseColorControl ctl)Construct a colormap from the specified control.BaseRGBMap(boolean hasAlpha)Construct a BaseRGBMap with the default resolutionBaseRGBMap(float[][] vals)Construct a colormap initialized with the supplied tuplesBaseRGBMap(float[][] vals, boolean hasAlpha)Deprecated.hasAlpha isn't really necessary.BaseRGBMap(int resolution, boolean hasAlpha)Construct a colormap with the specified resolution
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidcontrolChanged(ControlEvent evt)If the color data in theControlassociated with this widget'sControlhas changed, update the data in theColorMap.float[][]getColorMap()Get the color map (as an array of float tuples.intgetMapDimension()Get the dimension of the mapintgetMapResolution()Get the resolution of the mapjava.awt.DimensiongetPreferredSize()Return the preferred size of this map, taking into account the resolution.float[]getRGBTuple(float value)Implementation of the abstract function in ColorMap WARNING: This is a really slow way to get a color, so don't use it inside a loop.float[][]getRGBTuples(float startVal, float endVal, int num)Implementation of the abstract function in ColorMap WARNING: This is a really slow way to get a color, so don't use it inside a loop.float[]getTuple(float value)Returns the tuple at a floating point value val WARNING: This is a really slow way to get a color, so don't use it inside a loop.float[][]getTuples(float firstVal, float lastVal, int num)Returns the tuple at a floating point value valvoidmouseClicked(java.awt.event.MouseEvent evt)Present to implement MouseListener, currently ignoredvoidmouseDragged(java.awt.event.MouseEvent evt)Updates the associated ControlvoidmouseEntered(java.awt.event.MouseEvent evt)MouseListener, currently ignoredvoidmouseExited(java.awt.event.MouseEvent evt)MouseListener method, currently ignoredvoidmouseMoved(java.awt.event.MouseEvent evt)MouseMovementListener method, currently ignoredvoidmousePressed(java.awt.event.MouseEvent evt)Updates the associated ControlvoidmouseReleased(java.awt.event.MouseEvent evt)Listens for releases of the right mouse button, and changes the active colorvoidpaint(java.awt.Graphics g)Repaints the entire JPanelvoidsetPreferredSize(java.awt.Dimension pref)Override the widget's calculation for the preferred size of this map.voidsetValues(float[][] newVal)Sets the values of the internal array after the map has been created.voidupdate(java.awt.Graphics g)Repaints the modified areas of the JPanel-
Methods inherited from class visad.util.ColorMap
addColorChangeListener, getColor, getColors, removeColorChangeListener
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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
-
-
-
-
Field Detail
-
USE_COLOR_CURSORS
public static boolean USE_COLOR_CURSORS
change this to true to use color cursors
-
DEFAULT_RESOLUTION
public static final int DEFAULT_RESOLUTION
default resolution- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BaseRGBMap
public BaseRGBMap(boolean hasAlpha) throws java.rmi.RemoteException, VisADExceptionConstruct a BaseRGBMap with the default resolution- Parameters:
hasAlpha- set to true is this map has an alpha component- Throws:
java.rmi.RemoteExceptionVisADException
-
BaseRGBMap
public BaseRGBMap(int resolution, boolean hasAlpha) throws java.rmi.RemoteException, VisADExceptionConstruct a colormap with the specified resolution- Parameters:
resolution- the length of the arrayhasAlpha- set to true is this map has an alpha component- Throws:
java.rmi.RemoteExceptionVisADException
-
BaseRGBMap
public BaseRGBMap(float[][] vals, boolean hasAlpha) throws java.rmi.RemoteException, VisADExceptionDeprecated. hasAlpha isn't really necessary.Construct a colormap initialized with the supplied tuples- Parameters:
vals- the tuples used to initialize the colormaphasAlpha- true if the colormap should have an ALPHA component.- Throws:
java.rmi.RemoteExceptionVisADException
-
BaseRGBMap
public BaseRGBMap(float[][] vals) throws java.rmi.RemoteException, VisADExceptionConstruct a colormap initialized with the supplied tuples- Parameters:
vals- the tuples used to initialize the colormap See setValues() for constraints on the vals array.- Throws:
java.rmi.RemoteExceptionVisADException
-
BaseRGBMap
public BaseRGBMap(BaseColorControl ctl)
Construct a colormap from the specified control.- Parameters:
ctl- control to use as data source
-
-
Method Detail
-
setValues
public void setValues(float[][] newVal) throws java.rmi.RemoteException, VisADExceptionSets the values of the internal array after the map has been created. The table should be float[resolution][dimension] where dimension is either 3 (for an RGB table) or 4 (if the table also has an alpha component) and resolution is the number of colors in the table, which must be greater than 4.- Parameters:
newVal- the color tuples used to initialize the map.- Throws:
java.rmi.RemoteExceptionVisADException
-
getMapResolution
public int getMapResolution()
Get the resolution of the map- Specified by:
getMapResolutionin classColorMap- Returns:
- the number of colors in the map.
-
getMapDimension
public int getMapDimension()
Get the dimension of the map- Specified by:
getMapDimensionin classColorMap- Returns:
- either 3 or 4
-
getColorMap
public float[][] getColorMap()
Get the color map (as an array of float tuples.- Specified by:
getColorMapin classColorMap- Returns:
- a copy of the color map
-
getTuples
public float[][] getTuples(float firstVal, float lastVal, int num)Returns the tuple at a floating point value val
-
getTuple
public float[] getTuple(float value)
Returns the tuple at a floating point value val WARNING: This is a really slow way to get a color, so don't use it inside a loop.
-
getRGBTuples
public float[][] getRGBTuples(float startVal, float endVal, int num)Implementation of the abstract function in ColorMap WARNING: This is a really slow way to get a color, so don't use it inside a loop.- Specified by:
getRGBTuplesin classColorMap- Parameters:
startVal- the first value to translateendVal- the last value to translatenum- the number of values (including the two endpoints) to be returned.
-
getRGBTuple
public float[] getRGBTuple(float value)
Implementation of the abstract function in ColorMap WARNING: This is a really slow way to get a color, so don't use it inside a loop.- Specified by:
getRGBTuplein classColorMap- Parameters:
value- a floating point number between 0 and 1- Returns:
- an RGB tuple of floating point numbers in the range 0 to 1
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent evt)
Present to implement MouseListener, currently ignored- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener- Parameters:
evt- ignored
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent evt)
MouseListener, currently ignored- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener- Parameters:
evt- ignored
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent evt)
MouseListener method, currently ignored- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener- Parameters:
evt- ignored
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent evt)
Updates the associated Control- Specified by:
mousePressedin interfacejava.awt.event.MouseListener- Parameters:
evt- the mouse press event
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent evt)
Listens for releases of the right mouse button, and changes the active color- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener- Parameters:
evt- the release event
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent evt)
Updates the associated Control- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener- Parameters:
evt- the drag event
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent evt)
MouseMovementListener method, currently ignored- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener- Parameters:
evt- ignored
-
paint
public void paint(java.awt.Graphics g)
Repaints the entire JPanel- Overrides:
paintin classjavax.swing.JComponent- Parameters:
g- The Graphics to update.
-
update
public void update(java.awt.Graphics g)
Repaints the modified areas of the JPanel- Overrides:
updatein classjavax.swing.JComponent- Parameters:
g- The Graphics to update.
-
getPreferredSize
public java.awt.Dimension getPreferredSize()
Return the preferred size of this map, taking into account the resolution.- Overrides:
getPreferredSizein classjavax.swing.JComponent- Returns:
- preferred size.
-
setPreferredSize
public void setPreferredSize(java.awt.Dimension pref)
Override the widget's calculation for the preferred size of this map.- Overrides:
setPreferredSizein classjavax.swing.JComponent- Parameters:
pref- preferred size.
-
controlChanged
public void controlChanged(ControlEvent evt) throws java.rmi.RemoteException, VisADException
If the color data in theControlassociated with this widget'sControlhas changed, update the data in theColorMap.- Specified by:
controlChangedin interfaceControlListener- Parameters:
evt- Data from the changedControl.- Throws:
java.rmi.RemoteExceptionVisADException
-
-
DMelt 3.0 © DataMelt by jWork.ORG