|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
HeatMap
public class HeatMap
Title: HeatMap
Description: HeatMap is a JPanel that displays a 2-dimensional array of data using a selected color gradient scheme.
For specifying data, the first index into the double[][] array is the x- coordinate, and the second index is the y-coordinate.
There are a number of defined gradient types (look at the static fields), but you can create any gradient you like by using either of the following functions:
heatMap.updateGradient(heatMap.createMultiGradient(new Color[] {Color.red, Color.white, Color.blue}, 256));
By default, the graph title, axis titles, and axis tick marks are not displayed. Be sure to set the appropriate title before enabling them.
Copyright: Copyright (c) 2007, 2008
HeatMap is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
HeatMap is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with HeatMap; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
static java.awt.Color[] |
GRADIENT_BLACK_TO_WHITE
Produces a gradient from black (low) to white (high) |
static java.awt.Color[] |
GRADIENT_BLUE_TO_RED
Produces a gradient from blue (low) to red (high) |
static java.awt.Color[] |
GRADIENT_GREEN_YELLOW_ORANGE_RED
Produces a gradient through green, yellow, orange, red |
static java.awt.Color[] |
GRADIENT_HEAT
Produces a different gradient for hot things (black, brown, orange, white) |
static java.awt.Color[] |
GRADIENT_HOT
Produces a gradient for hot things (black, red, orange, yellow, white) |
static java.awt.Color[] |
GRADIENT_MAROON_TO_GOLD
Produces a gradient using the University of Minnesota's school colors, from maroon (low) to gold (high) |
static java.awt.Color[] |
GRADIENT_RAINBOW
Produces a gradient through the rainbow: violet, blue, green, yellow, orange, red |
static java.awt.Color[] |
GRADIENT_RED_TO_GREEN
Produces a gradient from red (low) to green (high) |
static java.awt.Color[] |
GRADIENT_ROY
Produces a gradient through red, orange, yellow |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, 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 |
---|
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 | |
---|---|
HeatMap(double[][] data,
java.awt.Color[] colors)
|
Method Summary | |
---|---|
static java.awt.Color[] |
createGradient(java.awt.Color one,
java.awt.Color two,
int numSteps)
Creates an array of Color objects for use as a gradient, using a linear interpolation between the two specified colors. |
static java.awt.Color[] |
createMultiGradient(java.awt.Color[] colors,
int numSteps)
Creates an array of Color objects for use as a gradient, using an array of Color objects. |
static double[][] |
generatePyramidData(int dimension)
This function generates an appropriate data array for display. |
static double[][] |
generateSinCosData(int dimension)
This function generates an appropriate data array for display. |
void |
paintComponent(java.awt.Graphics g)
The overridden painting method, now optimized to simply draw the data plot to the screen, letting the drawImage method do the resizing. |
void |
setColorBackground(java.awt.Color bg)
Updates the background color. |
void |
setColorForeground(java.awt.Color fg)
Updates the foreground color. |
void |
setCoordinateBounds(double xMin,
double xMax,
double yMin,
double yMax)
Specify the coordinate bounds for the map. |
void |
setDrawLegend(boolean drawLegend)
Updates the state of the legend. |
void |
setDrawTitle(boolean drawTitle)
Updates the state of the title. |
void |
setDrawXAxisTitle(boolean drawXAxisTitle)
Updates the state of the X-Axis Title. |
void |
setDrawXTicks(boolean drawXTicks)
Updates the state of the X-Axis ticks. |
void |
setDrawYAxisTitle(boolean drawYAxisTitle)
Updates the state of the Y-Axis Title. |
void |
setDrawYTicks(boolean drawYTicks)
Updates the state of the Y-Axis ticks. |
void |
setTitle(java.lang.String title)
Updates the title. |
void |
setXAxisTitle(java.lang.String xAxisTitle)
Updates the X-Axis title. |
void |
setXCoordinateBounds(double xMin,
double xMax)
Specify the coordinate bounds for the X-range. |
void |
setXMaxCoordinateBounds(double xMax)
Specify the coordinate bounds for the X Max. |
void |
setXMinCoordinateBounds(double xMin)
Specify the coordinate bounds for the X Min. |
void |
setYAxisTitle(java.lang.String yAxisTitle)
Updates the Y-Axis title. |
void |
setYCoordinateBounds(double yMin,
double yMax)
Specify the coordinate bounds for the Y-range. |
void |
setYMaxCoordinateBounds(double yMax)
Specify the coordinate bounds for the Y Max. |
void |
setYMinCoordinateBounds(double yMin)
Specify the coordinate bounds for the Y Min. |
void |
updateData(double[][] data)
Updates the data display, calls drawData() to do the expensive re-drawing of the data plot, and then calls repaint(). |
void |
updateGradient(java.awt.Color[] colors)
Updates the gradient used to display the data. |
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, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, setEnabled, 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, transferFocusBackward, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.awt.Color[] GRADIENT_MAROON_TO_GOLD
public static final java.awt.Color[] GRADIENT_BLUE_TO_RED
public static final java.awt.Color[] GRADIENT_BLACK_TO_WHITE
public static final java.awt.Color[] GRADIENT_RED_TO_GREEN
public static final java.awt.Color[] GRADIENT_GREEN_YELLOW_ORANGE_RED
public static final java.awt.Color[] GRADIENT_RAINBOW
public static final java.awt.Color[] GRADIENT_HOT
public static final java.awt.Color[] GRADIENT_HEAT
public static final java.awt.Color[] GRADIENT_ROY
Constructor Detail |
---|
public HeatMap(double[][] data, java.awt.Color[] colors)
data
- The data to display, must be a complete array (non-ragged)colors
- A variable of the type Color[]. See also createMultiGradient(java.awt.Color[], int)
and createGradient(java.awt.Color, java.awt.Color, int)
.Method Detail |
---|
public void setCoordinateBounds(double xMin, double xMax, double yMin, double yMax)
xMin
- The lower bound of x-values, used for axis labelsxMax
- The upper bound of x-values, used for axis labelspublic void setXCoordinateBounds(double xMin, double xMax)
xMin
- The lower bound of x-values, used for axis labelsxMax
- The upper bound of x-values, used for axis labelspublic void setXMinCoordinateBounds(double xMin)
xMin
- The lower bound of x-values, used for axis labelspublic void setXMaxCoordinateBounds(double xMax)
xMax
- The upper bound of x-values, used for axis labelspublic void setYCoordinateBounds(double yMin, double yMax)
yMin
- The lower bound of y-values, used for axis labelsyMax
- The upper bound of y-values, used for axis labelspublic void setYMinCoordinateBounds(double yMin)
yMin
- The lower bound of Y-values, used for axis labelspublic void setYMaxCoordinateBounds(double yMax)
yMax
- The upper bound of y-values, used for axis labelspublic void setTitle(java.lang.String title)
title
- The new titlepublic void setDrawTitle(boolean drawTitle)
drawTitle
- Specifies if the title should be drawnpublic void setXAxisTitle(java.lang.String xAxisTitle)
xAxisTitle
- The new X-Axis titlepublic void setDrawXAxisTitle(boolean drawXAxisTitle)
drawXAxisTitle
- Specifies if the X-Axis title should be drawnpublic void setYAxisTitle(java.lang.String yAxisTitle)
yAxisTitle
- The new Y-Axis titlepublic void setDrawYAxisTitle(boolean drawYAxisTitle)
drawYAxisTitle
- Specifies if the Y-Axis title should be drawnpublic void setDrawLegend(boolean drawLegend)
drawLegend
- Specifies if the legend should be drawnpublic void setDrawXTicks(boolean drawXTicks)
drawXTicks
- Specifies if the X-Axis ticks should be drawnpublic void setDrawYTicks(boolean drawYTicks)
drawYTicks
- Specifies if the Y-Axis ticks should be drawnpublic void setColorForeground(java.awt.Color fg)
fg
- Specifies the desired foreground colorpublic void setColorBackground(java.awt.Color bg)
bg
- Specifies the desired background colorpublic void updateGradient(java.awt.Color[] colors)
colors
- A variable of type Color[]public static java.awt.Color[] createGradient(java.awt.Color one, java.awt.Color two, int numSteps)
one
- Color used for the bottom of the gradienttwo
- Color used for the top of the gradientnumSteps
- The number of steps in the gradient. 250 is a good number.public static java.awt.Color[] createMultiGradient(java.awt.Color[] colors, int numSteps)
colors
- An array of Color objects used for the gradient. The Color at index 0 will be the lowest color.numSteps
- The number of steps in the gradient. 250 is a good number.public static double[][] generateSinCosData(int dimension)
dimension
- Size of each side of the returned array
public static double[][] generatePyramidData(int dimension)
dimension
- Size of each side of the returned array
public void updateData(double[][] data)
data
- The data to display, must be a complete array (non-ragged)public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |