public class JHC
+extends javax.swing.JComponent
+javax.swing.JComponent.AccessibleJComponent
java.awt.Component.BaselineResizeBehavior
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description | +
---|
JHC()
+Creates a new instance
+ |
+
Modifier and Type | +Method and Description | +
---|---|
void |
+setBackground(java.awt.Color bg)
+Sets the background color
+ |
+
void |
+setData(JHCData data,
+ JHCConfiguration config)
+Updates the data displayed by this control
+ |
+
void |
+setFont(java.awt.Font font)
+Sets the font
+ |
+
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, 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, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
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
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, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
public void setData(JHCData data, + JHCConfiguration config)+
data
- config
- public void setFont(java.awt.Font font)+
setFont
in class javax.swing.JComponent
public void setBackground(java.awt.Color bg)+
setBackground
in class javax.swing.JComponent
public class JHCConfiguration
+extends java.lang.Object
+Constructor and Description | +
---|
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
public JHCConfiguration(java.lang.String xLabel, + java.lang.String yLabel, + int maximalWidth, + int maximalHeight, + JHCGradient gradient)+
xLabel
- the x labelyLabel
- the y labelmaximalWidth
- the maximal widthmaximalHeight
- the maximal heightgradient
- the gradientpublic JHCConfiguration(java.lang.String xLabel, + java.lang.String yLabel, + int maximalWidth, + int maximalHeight, + JHCGradient gradient, + JHCLayout layout)+
xLabel
- the x labelyLabel
- the y labelmaximalSize
- the maximal sizegradient
- the gradientlayout
- the layoutpublic JHCConfiguration(java.lang.String xLabel, + java.lang.String yLabel, + JHCGradient gradient)+
xLabel
- the x labelyLabel
- the y labelgradient
- the gradientpublic JHCConfiguration(java.lang.String xLabel, + java.lang.String yLabel, + JHCGradient gradient, + JHCLayout layout)+
xLabel
- the x labelyLabel
- the y labelgradient
- the gradientlayout
- the layoutpublic abstract class JHCData
+extends java.lang.Object
+Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+create(char[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(char[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+create(double[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(double[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+create(float[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(float[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+create(int[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(int[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+create(JHCDataProvider provider)
+Creates the.
+ |
+
static JHCData |
+create(long[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(long[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
abstract JHCHeatmap |
+getHeatmap(int width,
+ int height)
+Gets the heat.
+ |
+
abstract int |
+getHeight()
+Gets the original height of the data
+ |
+
abstract int |
+getWidth()
+Gets the original width of the data
+ |
+
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public static JHCData create(double[][] data)+
data
- the datapublic static JHCData create(double[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(double[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(char[][] data)+
data
- the datapublic static JHCData create(char[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(char[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(int[][] data)+
data
- the datapublic static JHCData create(int[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(int[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(long[][] data)+
data
- the datapublic static JHCData create(long[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(long[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(float[][] data)+
data
- the datapublic static JHCData create(float[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(float[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(JHCDataProvider provider)+
provider
- the providerpublic abstract JHCHeatmap getHeatmap(int width, + int height)+
width
- the widthheight
- the heightpublic abstract int getWidth()+
public abstract int getHeight()+
public static enum JHCDataProvider.Orientation +extends java.lang.Enum<JHCDataProvider.Orientation>+
Enum Constant and Description | +
---|
COLUMN |
+
ROW |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCDataProvider.Orientation |
+valueOf(java.lang.String name)
+Returns the enum constant of this type with the specified name.
+ |
+
static JHCDataProvider.Orientation[] |
+values()
+Returns an array containing the constants of this enum type, in
+the order they are declared.
+ |
+
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
getClass, notify, notifyAll, wait, wait, wait
public static final JHCDataProvider.Orientation ROW+
public static final JHCDataProvider.Orientation COLUMN+
public static JHCDataProvider.Orientation[] values()+
+for (JHCDataProvider.Orientation c : JHCDataProvider.Orientation.values()) + System.out.println(c); +
public static JHCDataProvider.Orientation valueOf(java.lang.String name)+
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant
+with the specified namejava.lang.NullPointerException
- if the argument is nullpublic interface JHCDataProvider
+Modifier and Type | +Interface and Description | +
---|---|
static class |
+JHCDataProvider.Orientation
+Data orientation
+ |
+
Modifier and Type | +Method and Description | +
---|---|
double |
+get(int x,
+ int y)
+Returns the.
+ |
+
int |
+getHeight()
+Gets the height.
+ |
+
JHCDataProvider.Orientation |
+getOrientation()
+Gets the orientation.
+ |
+
int |
+getWidth()
+Gets the width.
+ |
+
JHCScale<?> |
+getXScale()
+Gets the x labels.
+ |
+
JHCScale<?> |
+getYScale()
+Gets the y labels.
+ |
+
double get(int x, + int y)+
x
- the xy
- the yint getHeight()+
int getWidth()+
JHCDataProvider.Orientation getOrientation()+
JHCScale<?> getXScale()+
JHCScale<?> getYScale()+
public class JHCGradient
+extends java.lang.Object
+Modifier and Type | +Field and Description | +
---|---|
static JHCGradient |
+GRADIENT_BLACKBODY
+BLACK, RED, YELLOW, WHITE, LIGHT_BLUE
+ |
+
static JHCGradient |
+GRADIENT_BLUERED
+BRIGHT_BLUE, PURPLE, BRIGHT_RED
+ |
+
static JHCGradient |
+GRADIENT_EARTH
+BLUE, GREEN, YELLOW, BROWN, TAN, WHITE
+ |
+
static JHCGradient |
+GRADIENT_ELECTRIC
+BLACK, PURPLE, ORANGE, YELLOW, TAN, WHITE
+ |
+
static JHCGradient |
+GRADIENT_GRAYS
+BLACK, LIGHT_GRAY
+ |
+
static JHCGradient |
+GRADIENT_GRAYSCALE
+BLACK, GRAY, WHITE
+ |
+
static JHCGradient |
+GRADIENT_GREENS
+DARK_GREEN, LIGHT_GREEN
+ |
+
static JHCGradient |
+GRADIENT_HEAT
+BLUE, CYAN, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+GRADIENT_HOT
+TAN, YELLOW, RED, BLACK
+ |
+
static JHCGradient |
+GRADIENT_JET
+BLUE, LIGHT_BLUE, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+GRADIENT_PICNIC
+BLUE, LIGHT_BLUE, WHITE, PINK
+ |
+
static JHCGradient |
+GRADIENT_PORTLAND
+BLUE, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+GRADIENT_RDBU
+BLUE, RED
+ |
+
static JHCGradient |
+GRADIENT_YIGNBN
+WHITE, GREEN
+ |
+
static JHCGradient |
+GRADIENT_YIORRD
+RED, ORANGE, GOLD, TAN, WHITE
+ |
+
Constructor and Description | +
---|
JHCGradient(java.awt.Color[] _colors)
+Instantiates a new gradient.
+ |
+
JHCGradient(java.awt.Color[] _colors,
+ int steps)
+Instantiates a new gradient.
+ |
+
public static final JHCGradient GRADIENT_GRAYSCALE+
public static final JHCGradient GRADIENT_HEAT+
public static final JHCGradient GRADIENT_GRAYS+
public static final JHCGradient GRADIENT_YIGNBN+
public static final JHCGradient GRADIENT_GREENS+
public static final JHCGradient GRADIENT_YIORRD+
public static final JHCGradient GRADIENT_BLUERED+
public static final JHCGradient GRADIENT_RDBU+
public static final JHCGradient GRADIENT_PICNIC+
public static final JHCGradient GRADIENT_PORTLAND+
public static final JHCGradient GRADIENT_JET+
public static final JHCGradient GRADIENT_HOT+
public static final JHCGradient GRADIENT_BLACKBODY+
public static final JHCGradient GRADIENT_EARTH+
public static final JHCGradient GRADIENT_ELECTRIC+
public JHCGradient(java.awt.Color[] _colors)+
_colors
- the _colorspublic JHCGradient(java.awt.Color[] _colors, + int steps)+
_colors
- the _colorssteps
- the stepspublic static interface JHCHeatmap.Point
+public abstract class JHCHeatmap
+extends java.lang.Object
+Modifier and Type | +Class and Description | +
---|---|
static interface |
+JHCHeatmap.Point
+This interface represents a point in the heatmap.
+ |
+
Constructor and Description | +
---|
JHCHeatmap() |
+
Modifier and Type | +Method and Description | +
---|---|
abstract int |
+getHeight()
+Gets the height.
+ |
+
abstract double |
+getMax()
+Gets the max.
+ |
+
abstract double |
+getMin()
+Gets the min.
+ |
+
abstract int |
+getWidth()
+Gets the width.
+ |
+
abstract java.lang.String |
+getXLabel(int index)
+Gets the x label.
+ |
+
abstract java.lang.String |
+getYLabel(int index)
+Gets the y label.
+ |
+
abstract java.util.Iterator<JHCHeatmap.Point> |
+iterator()
+Iterator.
+ |
+
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public abstract int getHeight()+
public abstract double getMax()+
public abstract double getMin()+
public abstract int getWidth()+
public abstract java.lang.String getXLabel(int index)+
index
- the indexpublic abstract java.lang.String getYLabel(int index)+
index
- the indexpublic abstract java.util.Iterator<JHCHeatmap.Point> iterator()+
public class JHCLayout
+extends java.lang.Object
+Constructor and Description | +
---|
JHCLayout()
+Instantiates a new layout.
+ |
+
JHCLayout(boolean xTickRotate,
+ int xTickSpace,
+ boolean yTickRotate,
+ int yTickSpace)
+Instantiates a new layout.
+ |
+
JHCLayout(int legendWidth,
+ int largeTickLength,
+ int smallTickLength)
+Instantiates a new layout.
+ |
+
JHCLayout(int legendWidth,
+ int largeTickLength,
+ int smallTickLength,
+ boolean xTickRotate,
+ int xTickSpace,
+ boolean yTickRotate,
+ int yTickSpace)
+Instantiates a new layout.
+ |
+
JHCLayout(int offsetLeft,
+ int offsetRight,
+ int offsetTop,
+ int offsetBottom,
+ int offsetCenter)
+Instantiates a new layout.
+ |
+
JHCLayout(int offsetLeft,
+ int offsetRight,
+ int offsetTop,
+ int offsetBottom,
+ int offsetCenter,
+ boolean xTickRotate,
+ int xTickSpace,
+ boolean yTickRotate,
+ int yTickSpace)
+Instantiates a new layout.
+ |
+
JHCLayout(int offsetLeft,
+ int offsetRight,
+ int offsetTop,
+ int offsetBottom,
+ int offsetCenter,
+ int minimalTextWidth,
+ int legendWidth,
+ int largeTickLength,
+ int smallTickLength,
+ int textOffset)
+Instantiates a new layout.
+ |
+
JHCLayout(int offsetLeft,
+ int offsetRight,
+ int offsetTop,
+ int offsetBottom,
+ int offsetCenter,
+ int minimalTextWidth,
+ int legendWidth,
+ int largeTickLength,
+ int smallTickLength,
+ int textOffset,
+ boolean xTickRotate,
+ int xTickSpace,
+ boolean yTickRotate,
+ int yTickSpace)
+Instantiates a new layout.
+ |
+
public JHCLayout()+
public JHCLayout(boolean xTickRotate, + int xTickSpace, + boolean yTickRotate, + int yTickSpace)+
xTickRotate
- the x tick rotatexTickSpace
- the x tick spaceyTickRotate
- the y tick rotateyTickSpace
- the y tick spacepublic JHCLayout(int legendWidth, + int largeTickLength, + int smallTickLength)+
legendWidth
- the legend widthlargeTickLength
- the large tick lengthsmallTickLength
- the small tick lengthpublic JHCLayout(int legendWidth, + int largeTickLength, + int smallTickLength, + boolean xTickRotate, + int xTickSpace, + boolean yTickRotate, + int yTickSpace)+
legendWidth
- the legend widthlargeTickLength
- the large tick lengthsmallTickLength
- the small tick lengthxTickRotate
- the x tick rotatexTickSpace
- the x tick spaceyTickRotate
- the y tick rotateyTickSpace
- the y tick spacepublic JHCLayout(int offsetLeft, + int offsetRight, + int offsetTop, + int offsetBottom, + int offsetCenter)+
offsetLeft
- the offset leftoffsetRight
- the offset rightoffsetTop
- the offset topoffsetBottom
- the offset bottomoffsetCenter
- the offset centerpublic JHCLayout(int offsetLeft, + int offsetRight, + int offsetTop, + int offsetBottom, + int offsetCenter, + boolean xTickRotate, + int xTickSpace, + boolean yTickRotate, + int yTickSpace)+
offsetLeft
- the offset leftoffsetRight
- the offset rightoffsetTop
- the offset topoffsetBottom
- the offset bottomoffsetCenter
- the offset centerxTickRotate
- the x tick rotatexTickSpace
- the x tick spaceyTickRotate
- the y tick rotateyTickSpace
- the y tick spacepublic JHCLayout(int offsetLeft, + int offsetRight, + int offsetTop, + int offsetBottom, + int offsetCenter, + int minimalTextWidth, + int legendWidth, + int largeTickLength, + int smallTickLength, + int textOffset)+
offsetLeft
- the offset leftoffsetRight
- the offset rightoffsetTop
- the offset topoffsetBottom
- the offset bottomoffsetCenter
- the offset centerminimalTextWidth
- the minimal text widthlegendWidth
- the legend widthlargeTickLength
- the large tick lengthsmallTickLength
- the small tick lengthtextOffset
- the text offsetpublic JHCLayout(int offsetLeft, + int offsetRight, + int offsetTop, + int offsetBottom, + int offsetCenter, + int minimalTextWidth, + int legendWidth, + int largeTickLength, + int smallTickLength, + int textOffset, + boolean xTickRotate, + int xTickSpace, + boolean yTickRotate, + int yTickSpace)+
offsetLeft
- the offset leftoffsetRight
- the offset rightoffsetTop
- the offset topoffsetBottom
- the offset bottomoffsetCenter
- the offset centerminimalTextWidth
- the minimal text widthlegendWidth
- the legend widthlargeTickLength
- the large tick lengthsmallTickLength
- the small tick lengthtextOffset
- the text offsetxTickRotate
- the x tick rotatexTickSpace
- the x tick spaceyTickRotate
- the y tick rotateyTickSpace
- the y tick spaceJHCScale.Date, JHCScale.Decimal, JHCScale.Integer, JHCScale.String
Constructor and Description | +
---|
JHCScale.Date(java.util.Date from,
+ java.util.Date to)
+Instantiates a new scale date.
+ |
+
JHCScale.Date(java.util.Date from,
+ java.util.Date to,
+ java.text.DateFormat format)
+Instantiates a new scale date.
+ |
+
public JHCScale.Date(java.util.Date from, + java.util.Date to)+
from
- the fromto
- the topublic JHCScale.Date(java.util.Date from, + java.util.Date to, + java.text.DateFormat format)+
from
- the fromto
- the toformat
- the formatJHCScale.Date, JHCScale.Decimal, JHCScale.Integer, JHCScale.String
Constructor and Description | +
---|
JHCScale.Decimal(double from,
+ double to)
+Instantiates a new scale decimal.
+ |
+
JHCScale.Decimal(double from,
+ double to,
+ java.text.DecimalFormat format)
+Instantiates a new scale decimal.
+ |
+
public JHCScale.Decimal(double from, + double to)+
from
- the fromto
- the topublic JHCScale.Decimal(double from, + double to, + java.text.DecimalFormat format)+
from
- the fromto
- the toformat
- the formatJHCScale.Date, JHCScale.Decimal, JHCScale.Integer, JHCScale.String
Constructor and Description | +
---|
JHCScale.Integer(int from,
+ int to)
+Instantiates a new scale integer.
+ |
+
JHCScale.Date, JHCScale.Decimal, JHCScale.Integer, JHCScale.String
Constructor and Description | +
---|
JHCScale.String(java.lang.String[] values)
+Instantiates a new scale string.
+ |
+
T
- the generic typepublic abstract class JHCScale<T>
+extends java.lang.Object
+Modifier and Type | +Class and Description | +
---|---|
static class |
+JHCScale.Date
+This class implements a data/time scale
+ |
+
static class |
+JHCScale.Decimal
+This class implements a decimal scale
+ |
+
static class |
+JHCScale.Integer
+This class implements an integer scale
+ |
+
static class |
+JHCScale.String
+This class implements a string scale
+ |
+
Modifier and Type | +Method and Description | +
---|---|
void |
+JHC.setData(JHCData data,
+ JHCConfiguration config)
+Updates the data displayed by this control
+ |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+JHCData.create(char[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(double[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(float[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(int[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(JHCDataProvider provider)
+Creates the.
+ |
+
static JHCData |
+JHCData.create(long[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
void |
+JHC.setData(JHCData data,
+ JHCConfiguration config)
+Updates the data displayed by this control
+ |
+
Modifier and Type | +Method and Description | +
---|---|
JHCDataProvider.Orientation |
+JHCDataProvider.getOrientation()
+Gets the orientation.
+ |
+
static JHCDataProvider.Orientation |
+JHCDataProvider.Orientation.valueOf(java.lang.String name)
+Returns the enum constant of this type with the specified name.
+ |
+
static JHCDataProvider.Orientation[] |
+JHCDataProvider.Orientation.values()
+Returns an array containing the constants of this enum type, in
+the order they are declared.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+JHCData.create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+JHCData.create(JHCDataProvider provider)
+Creates the.
+ |
+
Modifier and Type | +Field and Description | +
---|---|
static JHCGradient |
+JHCGradient.GRADIENT_BLACKBODY
+BLACK, RED, YELLOW, WHITE, LIGHT_BLUE
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_BLUERED
+BRIGHT_BLUE, PURPLE, BRIGHT_RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_EARTH
+BLUE, GREEN, YELLOW, BROWN, TAN, WHITE
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_ELECTRIC
+BLACK, PURPLE, ORANGE, YELLOW, TAN, WHITE
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_GRAYS
+BLACK, LIGHT_GRAY
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_GRAYSCALE
+BLACK, GRAY, WHITE
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_GREENS
+DARK_GREEN, LIGHT_GREEN
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_HEAT
+BLUE, CYAN, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_HOT
+TAN, YELLOW, RED, BLACK
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_JET
+BLUE, LIGHT_BLUE, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_PICNIC
+BLUE, LIGHT_BLUE, WHITE, PINK
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_PORTLAND
+BLUE, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_RDBU
+BLUE, RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_YIGNBN
+WHITE, GREEN
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_YIORRD
+RED, ORANGE, GOLD, TAN, WHITE
+ |
+
Constructor and Description | +
---|
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
abstract java.util.Iterator<JHCHeatmap.Point> |
+JHCHeatmap.iterator()
+Iterator.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
abstract JHCHeatmap |
+JHCData.getHeatmap(int width,
+ int height)
+Gets the heat.
+ |
+
Constructor and Description | +
---|
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
Modifier and Type | +Class and Description | +
---|---|
static class |
+JHCScale.Date
+This class implements a data/time scale
+ |
+
static class |
+JHCScale.Decimal
+This class implements a decimal scale
+ |
+
static class |
+JHCScale.Integer
+This class implements an integer scale
+ |
+
static class |
+JHCScale.String
+This class implements a string scale
+ |
+
Modifier and Type | +Method and Description | +
---|---|
JHCScale<?> |
+JHCDataProvider.getXScale()
+Gets the x labels.
+ |
+
JHCScale<?> |
+JHCDataProvider.getYScale()
+Gets the y labels.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+JHCData.create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
Interface | +Description | +
---|---|
JHCDataProvider | +
+ This interface can be implemented to convert data into a representation suitable for the widget
+ |
+
JHCHeatmap.Point | +
+ This interface represents a point in the heatmap.
+ |
+
Class | +Description | +
---|---|
JHC | +
+ This class provides a heatmap control for AWT
+ |
+
JHCConfiguration | +
+ This class allows to configure how the heatmap is displayed.
+ |
+
JHCData | +
+ This class defines the abstract base type for data that can be handled by the widget/control.
+ |
+
JHCGradient | +
+ The class implements gradients for the heatmap.
+ |
+
JHCHeatmap | +
+ This abstract class represents a (potentially scaled) heatmap that has been retrieved from an instance of JHCData
+ |
+
JHCLayout | +
+ This class represents the layout that is to be used when displaying the heatmap
+ |
+
JHCScale<T> | +
+ This class provides an abstract type for scales
+ |
+
JHCScale.Date | +
+ This class implements a data/time scale
+ |
+
JHCScale.Decimal | +
+ This class implements a decimal scale
+ |
+
JHCScale.Integer | +
+ This class implements an integer scale
+ |
+
JHCScale.String | +
+ This class implements a string scale
+ |
+
Enum | +Description | +
---|---|
JHCDataProvider.Orientation | +
+ Data orientation
+ |
+
Class and Description | +
---|
JHCConfiguration
+ This class allows to configure how the heatmap is displayed.
+ |
+
JHCData
+ This class defines the abstract base type for data that can be handled by the widget/control.
+ |
+
JHCDataProvider
+ This interface can be implemented to convert data into a representation suitable for the widget
+ |
+
JHCDataProvider.Orientation
+ Data orientation
+ |
+
JHCGradient
+ The class implements gradients for the heatmap.
+ |
+
JHCHeatmap
+ This abstract class represents a (potentially scaled) heatmap that has been retrieved from an instance of JHCData
+ |
+
JHCHeatmap.Point
+ This interface represents a point in the heatmap.
+ |
+
JHCLayout
+ This class represents the layout that is to be used when displaying the heatmap
+ |
+
JHCScale
+ This class provides an abstract type for scales
+ |
+
Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+Each annotation type has its own separate page with the following sections:
+Each enum has its own separate page with the following sections:
+Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object
. The interfaces do not inherit from java.lang.Object
.
The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+These links take you to the next or previous class, interface, package, or related page.
+These links show and hide the HTML frames. All pages are available with or without frames.
+The All Classes link shows all classes and interfaces except non-static nested types.
+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
+The Constant Field Values page lists the static final fields and their values.
+de.linearbits.jhc._JHC jhc+
public class JHC
+extends javax.swing.JComponent
+javax.swing.JComponent.AccessibleJComponent
java.awt.Component.BaselineResizeBehavior
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description | +
---|
JHC()
+Creates a new instance
+ |
+
Modifier and Type | +Method and Description | +
---|---|
void |
+setBackground(java.awt.Color bg)
+Sets the background color
+ |
+
void |
+setData(JHCData data,
+ JHCConfiguration config)
+Updates the data displayed by this control
+ |
+
void |
+setFont(java.awt.Font font)
+Sets the font
+ |
+
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, 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, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
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
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, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
public void setData(JHCData data, + JHCConfiguration config)+
data
- config
- public void setFont(java.awt.Font font)+
setFont
in class javax.swing.JComponent
public void setBackground(java.awt.Color bg)+
setBackground
in class javax.swing.JComponent
public class JHCConfiguration
+extends java.lang.Object
+Constructor and Description | +
---|
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
public JHCConfiguration(java.lang.String xLabel, + java.lang.String yLabel, + int maximalWidth, + int maximalHeight, + JHCGradient gradient)+
xLabel
- the x labelyLabel
- the y labelmaximalWidth
- the maximal widthmaximalHeight
- the maximal heightgradient
- the gradientpublic JHCConfiguration(java.lang.String xLabel, + java.lang.String yLabel, + int maximalWidth, + int maximalHeight, + JHCGradient gradient, + JHCLayout layout)+
xLabel
- the x labelyLabel
- the y labelmaximalSize
- the maximal sizegradient
- the gradientlayout
- the layoutpublic JHCConfiguration(java.lang.String xLabel, + java.lang.String yLabel, + JHCGradient gradient)+
xLabel
- the x labelyLabel
- the y labelgradient
- the gradientpublic JHCConfiguration(java.lang.String xLabel, + java.lang.String yLabel, + JHCGradient gradient, + JHCLayout layout)+
xLabel
- the x labelyLabel
- the y labelgradient
- the gradientlayout
- the layoutpublic abstract class JHCData
+extends java.lang.Object
+Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+create(char[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(char[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+create(double[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(double[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+create(float[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(float[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+create(int[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(int[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+create(JHCDataProvider provider)
+Creates the.
+ |
+
static JHCData |
+create(long[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(long[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
abstract JHCHeatmap |
+getHeatmap(int width,
+ int height)
+Gets the heat.
+ |
+
abstract int |
+getHeight()
+Gets the original height of the data
+ |
+
abstract int |
+getWidth()
+Gets the original width of the data
+ |
+
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public static JHCData create(double[][] data)+
data
- the datapublic static JHCData create(double[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(double[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(char[][] data)+
data
- the datapublic static JHCData create(char[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(char[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(int[][] data)+
data
- the datapublic static JHCData create(int[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(int[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(long[][] data)+
data
- the datapublic static JHCData create(long[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(long[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(float[][] data)+
data
- the datapublic static JHCData create(float[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(float[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(JHCDataProvider provider)+
provider
- the providerpublic abstract JHCHeatmap getHeatmap(int width, + int height)+
width
- the widthheight
- the heightpublic abstract int getWidth()+
public abstract int getHeight()+
public static enum JHCDataProvider.Orientation +extends java.lang.Enum<JHCDataProvider.Orientation>+
Enum Constant and Description | +
---|
COLUMN |
+
ROW |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCDataProvider.Orientation |
+valueOf(java.lang.String name)
+Returns the enum constant of this type with the specified name.
+ |
+
static JHCDataProvider.Orientation[] |
+values()
+Returns an array containing the constants of this enum type, in
+the order they are declared.
+ |
+
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
getClass, notify, notifyAll, wait, wait, wait
public static final JHCDataProvider.Orientation ROW+
public static final JHCDataProvider.Orientation COLUMN+
public static JHCDataProvider.Orientation[] values()+
+for (JHCDataProvider.Orientation c : JHCDataProvider.Orientation.values()) + System.out.println(c); +
public static JHCDataProvider.Orientation valueOf(java.lang.String name)+
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant
+with the specified namejava.lang.NullPointerException
- if the argument is nullpublic interface JHCDataProvider
+Modifier and Type | +Interface and Description | +
---|---|
static class |
+JHCDataProvider.Orientation
+Data orientation
+ |
+
Modifier and Type | +Method and Description | +
---|---|
double |
+get(int x,
+ int y)
+Returns the.
+ |
+
int |
+getHeight()
+Gets the height.
+ |
+
JHCDataProvider.Orientation |
+getOrientation()
+Gets the orientation.
+ |
+
int |
+getWidth()
+Gets the width.
+ |
+
JHCScale<?> |
+getXScale()
+Gets the x labels.
+ |
+
JHCScale<?> |
+getYScale()
+Gets the y labels.
+ |
+
double get(int x, + int y)+
x
- the xy
- the yint getHeight()+
int getWidth()+
JHCDataProvider.Orientation getOrientation()+
JHCScale<?> getXScale()+
JHCScale<?> getYScale()+
public class JHCGradient
+extends java.lang.Object
+Modifier and Type | +Field and Description | +
---|---|
static JHCGradient |
+GRADIENT_BLACKBODY
+BLACK, RED, YELLOW, WHITE, LIGHT_BLUE
+ |
+
static JHCGradient |
+GRADIENT_BLUERED
+BRIGHT_BLUE, PURPLE, BRIGHT_RED
+ |
+
static JHCGradient |
+GRADIENT_EARTH
+BLUE, GREEN, YELLOW, BROWN, TAN, WHITE
+ |
+
static JHCGradient |
+GRADIENT_ELECTRIC
+BLACK, PURPLE, ORANGE, YELLOW, TAN, WHITE
+ |
+
static JHCGradient |
+GRADIENT_GRAYS
+BLACK, LIGHT_GRAY
+ |
+
static JHCGradient |
+GRADIENT_GRAYSCALE
+BLACK, GRAY, WHITE
+ |
+
static JHCGradient |
+GRADIENT_GREENS
+DARK_GREEN, LIGHT_GREEN
+ |
+
static JHCGradient |
+GRADIENT_HEAT
+BLUE, CYAN, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+GRADIENT_HOT
+TAN, YELLOW, RED, BLACK
+ |
+
static JHCGradient |
+GRADIENT_JET
+BLUE, LIGHT_BLUE, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+GRADIENT_PICNIC
+BLUE, LIGHT_BLUE, WHITE, PINK
+ |
+
static JHCGradient |
+GRADIENT_PORTLAND
+BLUE, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+GRADIENT_RDBU
+BLUE, RED
+ |
+
static JHCGradient |
+GRADIENT_YIGNBN
+WHITE, GREEN
+ |
+
static JHCGradient |
+GRADIENT_YIORRD
+RED, ORANGE, GOLD, TAN, WHITE
+ |
+
Constructor and Description | +
---|
JHCGradient(java.awt.Color[] _colors)
+Instantiates a new gradient.
+ |
+
JHCGradient(java.awt.Color[] _colors,
+ int steps)
+Instantiates a new gradient.
+ |
+
public static final JHCGradient GRADIENT_GRAYSCALE+
public static final JHCGradient GRADIENT_HEAT+
public static final JHCGradient GRADIENT_GRAYS+
public static final JHCGradient GRADIENT_YIGNBN+
public static final JHCGradient GRADIENT_GREENS+
public static final JHCGradient GRADIENT_YIORRD+
public static final JHCGradient GRADIENT_BLUERED+
public static final JHCGradient GRADIENT_RDBU+
public static final JHCGradient GRADIENT_PICNIC+
public static final JHCGradient GRADIENT_PORTLAND+
public static final JHCGradient GRADIENT_JET+
public static final JHCGradient GRADIENT_HOT+
public static final JHCGradient GRADIENT_BLACKBODY+
public static final JHCGradient GRADIENT_EARTH+
public static final JHCGradient GRADIENT_ELECTRIC+
public JHCGradient(java.awt.Color[] _colors)+
_colors
- the _colorspublic JHCGradient(java.awt.Color[] _colors, + int steps)+
_colors
- the _colorssteps
- the stepspublic static interface JHCHeatmap.Point
+public abstract class JHCHeatmap
+extends java.lang.Object
+Modifier and Type | +Class and Description | +
---|---|
static interface |
+JHCHeatmap.Point
+This interface represents a point in the heatmap.
+ |
+
Constructor and Description | +
---|
JHCHeatmap() |
+
Modifier and Type | +Method and Description | +
---|---|
abstract int |
+getHeight()
+Gets the height.
+ |
+
abstract double |
+getMax()
+Gets the max.
+ |
+
abstract double |
+getMin()
+Gets the min.
+ |
+
abstract int |
+getWidth()
+Gets the width.
+ |
+
abstract java.lang.String |
+getXLabel(int index)
+Gets the x label.
+ |
+
abstract java.lang.String |
+getYLabel(int index)
+Gets the y label.
+ |
+
abstract java.util.Iterator<JHCHeatmap.Point> |
+iterator()
+Iterator.
+ |
+
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public abstract int getHeight()+
public abstract double getMax()+
public abstract double getMin()+
public abstract int getWidth()+
public abstract java.lang.String getXLabel(int index)+
index
- the indexpublic abstract java.lang.String getYLabel(int index)+
index
- the indexpublic abstract java.util.Iterator<JHCHeatmap.Point> iterator()+
public class JHCLayout
+extends java.lang.Object
+Constructor and Description | +
---|
JHCLayout()
+Instantiates a new layout.
+ |
+
JHCLayout(boolean xTickRotate,
+ int xTickSpace,
+ boolean yTickRotate,
+ int yTickSpace)
+Instantiates a new layout.
+ |
+
JHCLayout(int legendWidth,
+ int largeTickLength,
+ int smallTickLength)
+Instantiates a new layout.
+ |
+
JHCLayout(int legendWidth,
+ int largeTickLength,
+ int smallTickLength,
+ boolean xTickRotate,
+ int xTickSpace,
+ boolean yTickRotate,
+ int yTickSpace)
+Instantiates a new layout.
+ |
+
JHCLayout(int offsetLeft,
+ int offsetRight,
+ int offsetTop,
+ int offsetBottom,
+ int offsetCenter)
+Instantiates a new layout.
+ |
+
JHCLayout(int offsetLeft,
+ int offsetRight,
+ int offsetTop,
+ int offsetBottom,
+ int offsetCenter,
+ boolean xTickRotate,
+ int xTickSpace,
+ boolean yTickRotate,
+ int yTickSpace)
+Instantiates a new layout.
+ |
+
JHCLayout(int offsetLeft,
+ int offsetRight,
+ int offsetTop,
+ int offsetBottom,
+ int offsetCenter,
+ int minimalTextWidth,
+ int legendWidth,
+ int largeTickLength,
+ int smallTickLength,
+ int textOffset)
+Instantiates a new layout.
+ |
+
JHCLayout(int offsetLeft,
+ int offsetRight,
+ int offsetTop,
+ int offsetBottom,
+ int offsetCenter,
+ int minimalTextWidth,
+ int legendWidth,
+ int largeTickLength,
+ int smallTickLength,
+ int textOffset,
+ boolean xTickRotate,
+ int xTickSpace,
+ boolean yTickRotate,
+ int yTickSpace)
+Instantiates a new layout.
+ |
+
public JHCLayout()+
public JHCLayout(boolean xTickRotate, + int xTickSpace, + boolean yTickRotate, + int yTickSpace)+
xTickRotate
- the x tick rotatexTickSpace
- the x tick spaceyTickRotate
- the y tick rotateyTickSpace
- the y tick spacepublic JHCLayout(int legendWidth, + int largeTickLength, + int smallTickLength)+
legendWidth
- the legend widthlargeTickLength
- the large tick lengthsmallTickLength
- the small tick lengthpublic JHCLayout(int legendWidth, + int largeTickLength, + int smallTickLength, + boolean xTickRotate, + int xTickSpace, + boolean yTickRotate, + int yTickSpace)+
legendWidth
- the legend widthlargeTickLength
- the large tick lengthsmallTickLength
- the small tick lengthxTickRotate
- the x tick rotatexTickSpace
- the x tick spaceyTickRotate
- the y tick rotateyTickSpace
- the y tick spacepublic JHCLayout(int offsetLeft, + int offsetRight, + int offsetTop, + int offsetBottom, + int offsetCenter)+
offsetLeft
- the offset leftoffsetRight
- the offset rightoffsetTop
- the offset topoffsetBottom
- the offset bottomoffsetCenter
- the offset centerpublic JHCLayout(int offsetLeft, + int offsetRight, + int offsetTop, + int offsetBottom, + int offsetCenter, + boolean xTickRotate, + int xTickSpace, + boolean yTickRotate, + int yTickSpace)+
offsetLeft
- the offset leftoffsetRight
- the offset rightoffsetTop
- the offset topoffsetBottom
- the offset bottomoffsetCenter
- the offset centerxTickRotate
- the x tick rotatexTickSpace
- the x tick spaceyTickRotate
- the y tick rotateyTickSpace
- the y tick spacepublic JHCLayout(int offsetLeft, + int offsetRight, + int offsetTop, + int offsetBottom, + int offsetCenter, + int minimalTextWidth, + int legendWidth, + int largeTickLength, + int smallTickLength, + int textOffset)+
offsetLeft
- the offset leftoffsetRight
- the offset rightoffsetTop
- the offset topoffsetBottom
- the offset bottomoffsetCenter
- the offset centerminimalTextWidth
- the minimal text widthlegendWidth
- the legend widthlargeTickLength
- the large tick lengthsmallTickLength
- the small tick lengthtextOffset
- the text offsetpublic JHCLayout(int offsetLeft, + int offsetRight, + int offsetTop, + int offsetBottom, + int offsetCenter, + int minimalTextWidth, + int legendWidth, + int largeTickLength, + int smallTickLength, + int textOffset, + boolean xTickRotate, + int xTickSpace, + boolean yTickRotate, + int yTickSpace)+
offsetLeft
- the offset leftoffsetRight
- the offset rightoffsetTop
- the offset topoffsetBottom
- the offset bottomoffsetCenter
- the offset centerminimalTextWidth
- the minimal text widthlegendWidth
- the legend widthlargeTickLength
- the large tick lengthsmallTickLength
- the small tick lengthtextOffset
- the text offsetxTickRotate
- the x tick rotatexTickSpace
- the x tick spaceyTickRotate
- the y tick rotateyTickSpace
- the y tick spaceJHCScale.Date, JHCScale.Decimal, JHCScale.Integer, JHCScale.String
Constructor and Description | +
---|
JHCScale.Date(java.util.Date from,
+ java.util.Date to)
+Instantiates a new scale date.
+ |
+
JHCScale.Date(java.util.Date from,
+ java.util.Date to,
+ java.text.DateFormat format)
+Instantiates a new scale date.
+ |
+
public JHCScale.Date(java.util.Date from, + java.util.Date to)+
from
- the fromto
- the topublic JHCScale.Date(java.util.Date from, + java.util.Date to, + java.text.DateFormat format)+
from
- the fromto
- the toformat
- the formatJHCScale.Date, JHCScale.Decimal, JHCScale.Integer, JHCScale.String
Constructor and Description | +
---|
JHCScale.Decimal(double from,
+ double to)
+Instantiates a new scale decimal.
+ |
+
JHCScale.Decimal(double from,
+ double to,
+ java.text.DecimalFormat format)
+Instantiates a new scale decimal.
+ |
+
public JHCScale.Decimal(double from, + double to)+
from
- the fromto
- the topublic JHCScale.Decimal(double from, + double to, + java.text.DecimalFormat format)+
from
- the fromto
- the toformat
- the formatJHCScale.Date, JHCScale.Decimal, JHCScale.Integer, JHCScale.String
Constructor and Description | +
---|
JHCScale.Integer(int from,
+ int to)
+Instantiates a new scale integer.
+ |
+
JHCScale.Date, JHCScale.Decimal, JHCScale.Integer, JHCScale.String
Constructor and Description | +
---|
JHCScale.String(java.lang.String[] values)
+Instantiates a new scale string.
+ |
+
T
- the generic typepublic abstract class JHCScale<T>
+extends java.lang.Object
+Modifier and Type | +Class and Description | +
---|---|
static class |
+JHCScale.Date
+This class implements a data/time scale
+ |
+
static class |
+JHCScale.Decimal
+This class implements a decimal scale
+ |
+
static class |
+JHCScale.Integer
+This class implements an integer scale
+ |
+
static class |
+JHCScale.String
+This class implements a string scale
+ |
+
Modifier and Type | +Method and Description | +
---|---|
void |
+JHC.setData(JHCData data,
+ JHCConfiguration config)
+Updates the data displayed by this control
+ |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+JHCData.create(char[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(double[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(float[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(int[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(JHCDataProvider provider)
+Creates the.
+ |
+
static JHCData |
+JHCData.create(long[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
void |
+JHC.setData(JHCData data,
+ JHCConfiguration config)
+Updates the data displayed by this control
+ |
+
Modifier and Type | +Method and Description | +
---|---|
JHCDataProvider.Orientation |
+JHCDataProvider.getOrientation()
+Gets the orientation.
+ |
+
static JHCDataProvider.Orientation |
+JHCDataProvider.Orientation.valueOf(java.lang.String name)
+Returns the enum constant of this type with the specified name.
+ |
+
static JHCDataProvider.Orientation[] |
+JHCDataProvider.Orientation.values()
+Returns an array containing the constants of this enum type, in
+the order they are declared.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+JHCData.create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+JHCData.create(JHCDataProvider provider)
+Creates the.
+ |
+
Modifier and Type | +Field and Description | +
---|---|
static JHCGradient |
+JHCGradient.GRADIENT_BLACKBODY
+BLACK, RED, YELLOW, WHITE, LIGHT_BLUE
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_BLUERED
+BRIGHT_BLUE, PURPLE, BRIGHT_RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_EARTH
+BLUE, GREEN, YELLOW, BROWN, TAN, WHITE
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_ELECTRIC
+BLACK, PURPLE, ORANGE, YELLOW, TAN, WHITE
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_GRAYS
+BLACK, LIGHT_GRAY
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_GRAYSCALE
+BLACK, GRAY, WHITE
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_GREENS
+DARK_GREEN, LIGHT_GREEN
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_HEAT
+BLUE, CYAN, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_HOT
+TAN, YELLOW, RED, BLACK
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_JET
+BLUE, LIGHT_BLUE, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_PICNIC
+BLUE, LIGHT_BLUE, WHITE, PINK
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_PORTLAND
+BLUE, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_RDBU
+BLUE, RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_YIGNBN
+WHITE, GREEN
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_YIORRD
+RED, ORANGE, GOLD, TAN, WHITE
+ |
+
Constructor and Description | +
---|
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
abstract java.util.Iterator<JHCHeatmap.Point> |
+JHCHeatmap.iterator()
+Iterator.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
abstract JHCHeatmap |
+JHCData.getHeatmap(int width,
+ int height)
+Gets the heat.
+ |
+
Constructor and Description | +
---|
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
Modifier and Type | +Class and Description | +
---|---|
static class |
+JHCScale.Date
+This class implements a data/time scale
+ |
+
static class |
+JHCScale.Decimal
+This class implements a decimal scale
+ |
+
static class |
+JHCScale.Integer
+This class implements an integer scale
+ |
+
static class |
+JHCScale.String
+This class implements a string scale
+ |
+
Modifier and Type | +Method and Description | +
---|---|
JHCScale<?> |
+JHCDataProvider.getXScale()
+Gets the x labels.
+ |
+
JHCScale<?> |
+JHCDataProvider.getYScale()
+Gets the y labels.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+JHCData.create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
See: Description
+Interface | +Description | +
---|---|
JHCDataProvider | +
+ This interface can be implemented to convert data into a representation suitable for the widget
+ |
+
JHCHeatmap.Point | +
+ This interface represents a point in the heatmap.
+ |
+
Class | +Description | +
---|---|
JHC | +
+ This class provides a heatmap control for Swing
+ |
+
JHCConfiguration | +
+ This class allows to configure how the heatmap is displayed.
+ |
+
JHCData | +
+ This class defines the abstract base type for data that can be handled by the widget/control.
+ |
+
JHCGradient | +
+ The class implements gradients for the heatmap.
+ |
+
JHCHeatmap | +
+ This abstract class represents a (potentially scaled) heatmap that has been retrieved from an instance of JHCData
+ |
+
JHCLayout | +
+ This class represents the layout that is to be used when displaying the heatmap
+ |
+
JHCScale<T> | +
+ This class provides an abstract type for scales
+ |
+
JHCScale.Date | +
+ This class implements a data/time scale
+ |
+
JHCScale.Decimal | +
+ This class implements a decimal scale
+ |
+
JHCScale.Integer | +
+ This class implements an integer scale
+ |
+
JHCScale.String | +
+ This class implements a string scale
+ |
+
Enum | +Description | +
---|---|
JHCDataProvider.Orientation | +
+ Data orientation
+ |
+
Class and Description | +
---|
JHCConfiguration
+ This class allows to configure how the heatmap is displayed.
+ |
+
JHCData
+ This class defines the abstract base type for data that can be handled by the widget/control.
+ |
+
JHCDataProvider
+ This interface can be implemented to convert data into a representation suitable for the widget
+ |
+
JHCDataProvider.Orientation
+ Data orientation
+ |
+
JHCGradient
+ The class implements gradients for the heatmap.
+ |
+
JHCHeatmap
+ This abstract class represents a (potentially scaled) heatmap that has been retrieved from an instance of JHCData
+ |
+
JHCHeatmap.Point
+ This interface represents a point in the heatmap.
+ |
+
JHCLayout
+ This class represents the layout that is to be used when displaying the heatmap
+ |
+
JHCScale
+ This class provides an abstract type for scales
+ |
+
Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+Each annotation type has its own separate page with the following sections:
+Each enum has its own separate page with the following sections:
+Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object
. The interfaces do not inherit from java.lang.Object
.
The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+These links take you to the next or previous class, interface, package, or related page.
+These links show and hide the HTML frames. All pages are available with or without frames.
+The All Classes link shows all classes and interfaces except non-static nested types.
+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
+The Constant Field Values page lists the static final fields and their values.
+de.linearbits.jhc._JHC jhc+
public class JHC
+extends java.lang.Object
+Constructor and Description | +
---|
JHC(org.eclipse.swt.widgets.Composite parent,
+ int style)
+Creates a new instance
+ |
+
Modifier and Type | +Method and Description | +
---|---|
org.eclipse.swt.graphics.Color |
+getBackground()
+Returns the background color
+ |
+
org.eclipse.swt.graphics.Font |
+getFont()
+Returns the font
+ |
+
void |
+setBackground(org.eclipse.swt.graphics.Color arg0)
+Sets the background color
+ |
+
void |
+setData(JHCData data,
+ JHCConfiguration config)
+Sets the data to be displayed by this widget
+ |
+
void |
+setFont(org.eclipse.swt.graphics.Font arg0)
+Sets the font
+ |
+
void |
+setLayoutData(java.lang.Object arg0)
+Sets the layout data
+ |
+
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public JHC(org.eclipse.swt.widgets.Composite parent, + int style)+
parent
- the parentstyle
- the stylepublic org.eclipse.swt.graphics.Color getBackground()+
public org.eclipse.swt.graphics.Font getFont()+
public void setBackground(org.eclipse.swt.graphics.Color arg0)+
arg0
- public void setData(JHCData data, + JHCConfiguration config)+
data
- config
- public void setFont(org.eclipse.swt.graphics.Font arg0)+
arg0
- public void setLayoutData(java.lang.Object arg0)+
arg0
- public class JHCConfiguration
+extends java.lang.Object
+Constructor and Description | +
---|
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
public JHCConfiguration(java.lang.String xLabel, + java.lang.String yLabel, + int maximalWidth, + int maximalHeight, + JHCGradient gradient)+
xLabel
- the x labelyLabel
- the y labelmaximalWidth
- the maximal widthmaximalHeight
- the maximal heightgradient
- the gradientpublic JHCConfiguration(java.lang.String xLabel, + java.lang.String yLabel, + int maximalWidth, + int maximalHeight, + JHCGradient gradient, + JHCLayout layout)+
xLabel
- the x labelyLabel
- the y labelmaximalSize
- the maximal sizegradient
- the gradientlayout
- the layoutpublic JHCConfiguration(java.lang.String xLabel, + java.lang.String yLabel, + JHCGradient gradient)+
xLabel
- the x labelyLabel
- the y labelgradient
- the gradientpublic JHCConfiguration(java.lang.String xLabel, + java.lang.String yLabel, + JHCGradient gradient, + JHCLayout layout)+
xLabel
- the x labelyLabel
- the y labelgradient
- the gradientlayout
- the layoutpublic abstract class JHCData
+extends java.lang.Object
+Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+create(char[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(char[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+create(double[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(double[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+create(float[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(float[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+create(int[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(int[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+create(JHCDataProvider provider)
+Creates the.
+ |
+
static JHCData |
+create(long[][] data)
+Creates a data object.
+ |
+
static JHCData |
+create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+create(long[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
abstract JHCHeatmap |
+getHeatmap(int width,
+ int height)
+Gets the heat.
+ |
+
abstract int |
+getHeight()
+Gets the original height of the data
+ |
+
abstract int |
+getWidth()
+Gets the original width of the data
+ |
+
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public static JHCData create(double[][] data)+
data
- the datapublic static JHCData create(double[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(double[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(char[][] data)+
data
- the datapublic static JHCData create(char[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(char[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(int[][] data)+
data
- the datapublic static JHCData create(int[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(int[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(long[][] data)+
data
- the datapublic static JHCData create(long[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(long[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(float[][] data)+
data
- the datapublic static JHCData create(float[][] data, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataxScale
- the x scaleyScale
- the y scalepublic static JHCData create(float[][] data, + JHCDataProvider.Orientation orientation, + JHCScale<?> xScale, + JHCScale<?> yScale)+
data
- the dataorientation
- the orientationxScale
- the x scaleyScale
- the y scalepublic static JHCData create(JHCDataProvider provider)+
provider
- the providerpublic abstract JHCHeatmap getHeatmap(int width, + int height)+
width
- the widthheight
- the heightpublic abstract int getWidth()+
public abstract int getHeight()+
public static enum JHCDataProvider.Orientation +extends java.lang.Enum<JHCDataProvider.Orientation>+
Enum Constant and Description | +
---|
COLUMN |
+
ROW |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCDataProvider.Orientation |
+valueOf(java.lang.String name)
+Returns the enum constant of this type with the specified name.
+ |
+
static JHCDataProvider.Orientation[] |
+values()
+Returns an array containing the constants of this enum type, in
+the order they are declared.
+ |
+
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
getClass, notify, notifyAll, wait, wait, wait
public static final JHCDataProvider.Orientation ROW+
public static final JHCDataProvider.Orientation COLUMN+
public static JHCDataProvider.Orientation[] values()+
+for (JHCDataProvider.Orientation c : JHCDataProvider.Orientation.values()) + System.out.println(c); +
public static JHCDataProvider.Orientation valueOf(java.lang.String name)+
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant
+with the specified namejava.lang.NullPointerException
- if the argument is nullpublic interface JHCDataProvider
+Modifier and Type | +Interface and Description | +
---|---|
static class |
+JHCDataProvider.Orientation
+Data orientation
+ |
+
Modifier and Type | +Method and Description | +
---|---|
double |
+get(int x,
+ int y)
+Returns the.
+ |
+
int |
+getHeight()
+Gets the height.
+ |
+
JHCDataProvider.Orientation |
+getOrientation()
+Gets the orientation.
+ |
+
int |
+getWidth()
+Gets the width.
+ |
+
JHCScale<?> |
+getXScale()
+Gets the x labels.
+ |
+
JHCScale<?> |
+getYScale()
+Gets the y labels.
+ |
+
double get(int x, + int y)+
x
- the xy
- the yint getHeight()+
int getWidth()+
JHCDataProvider.Orientation getOrientation()+
JHCScale<?> getXScale()+
JHCScale<?> getYScale()+
public class JHCGradient
+extends java.lang.Object
+Modifier and Type | +Field and Description | +
---|---|
static JHCGradient |
+GRADIENT_BLACKBODY
+BLACK, RED, YELLOW, WHITE, LIGHT_BLUE
+ |
+
static JHCGradient |
+GRADIENT_BLUERED
+BRIGHT_BLUE, PURPLE, BRIGHT_RED
+ |
+
static JHCGradient |
+GRADIENT_EARTH
+BLUE, GREEN, YELLOW, BROWN, TAN, WHITE
+ |
+
static JHCGradient |
+GRADIENT_ELECTRIC
+BLACK, PURPLE, ORANGE, YELLOW, TAN, WHITE
+ |
+
static JHCGradient |
+GRADIENT_GRAYS
+BLACK, LIGHT_GRAY
+ |
+
static JHCGradient |
+GRADIENT_GRAYSCALE
+BLACK, GRAY, WHITE
+ |
+
static JHCGradient |
+GRADIENT_GREENS
+DARK_GREEN, LIGHT_GREEN
+ |
+
static JHCGradient |
+GRADIENT_HEAT
+BLUE, CYAN, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+GRADIENT_HOT
+TAN, YELLOW, RED, BLACK
+ |
+
static JHCGradient |
+GRADIENT_JET
+BLUE, LIGHT_BLUE, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+GRADIENT_PICNIC
+BLUE, LIGHT_BLUE, WHITE, PINK
+ |
+
static JHCGradient |
+GRADIENT_PORTLAND
+BLUE, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+GRADIENT_RDBU
+BLUE, RED
+ |
+
static JHCGradient |
+GRADIENT_YIGNBN
+WHITE, GREEN
+ |
+
static JHCGradient |
+GRADIENT_YIORRD
+RED, ORANGE, GOLD, TAN, WHITE
+ |
+
Constructor and Description | +
---|
JHCGradient(java.awt.Color[] _colors)
+Instantiates a new gradient.
+ |
+
JHCGradient(java.awt.Color[] _colors,
+ int steps)
+Instantiates a new gradient.
+ |
+
public static final JHCGradient GRADIENT_GRAYSCALE+
public static final JHCGradient GRADIENT_HEAT+
public static final JHCGradient GRADIENT_GRAYS+
public static final JHCGradient GRADIENT_YIGNBN+
public static final JHCGradient GRADIENT_GREENS+
public static final JHCGradient GRADIENT_YIORRD+
public static final JHCGradient GRADIENT_BLUERED+
public static final JHCGradient GRADIENT_RDBU+
public static final JHCGradient GRADIENT_PICNIC+
public static final JHCGradient GRADIENT_PORTLAND+
public static final JHCGradient GRADIENT_JET+
public static final JHCGradient GRADIENT_HOT+
public static final JHCGradient GRADIENT_BLACKBODY+
public static final JHCGradient GRADIENT_EARTH+
public static final JHCGradient GRADIENT_ELECTRIC+
public JHCGradient(java.awt.Color[] _colors)+
_colors
- the _colorspublic JHCGradient(java.awt.Color[] _colors, + int steps)+
_colors
- the _colorssteps
- the stepspublic static interface JHCHeatmap.Point
+public abstract class JHCHeatmap
+extends java.lang.Object
+Modifier and Type | +Class and Description | +
---|---|
static interface |
+JHCHeatmap.Point
+This interface represents a point in the heatmap.
+ |
+
Constructor and Description | +
---|
JHCHeatmap() |
+
Modifier and Type | +Method and Description | +
---|---|
abstract int |
+getHeight()
+Gets the height.
+ |
+
abstract double |
+getMax()
+Gets the max.
+ |
+
abstract double |
+getMin()
+Gets the min.
+ |
+
abstract int |
+getWidth()
+Gets the width.
+ |
+
abstract java.lang.String |
+getXLabel(int index)
+Gets the x label.
+ |
+
abstract java.lang.String |
+getYLabel(int index)
+Gets the y label.
+ |
+
abstract java.util.Iterator<JHCHeatmap.Point> |
+iterator()
+Iterator.
+ |
+
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public abstract int getHeight()+
public abstract double getMax()+
public abstract double getMin()+
public abstract int getWidth()+
public abstract java.lang.String getXLabel(int index)+
index
- the indexpublic abstract java.lang.String getYLabel(int index)+
index
- the indexpublic abstract java.util.Iterator<JHCHeatmap.Point> iterator()+
public class JHCLayout
+extends java.lang.Object
+Constructor and Description | +
---|
JHCLayout()
+Instantiates a new layout.
+ |
+
JHCLayout(boolean xTickRotate,
+ int xTickSpace,
+ boolean yTickRotate,
+ int yTickSpace)
+Instantiates a new layout.
+ |
+
JHCLayout(int legendWidth,
+ int largeTickLength,
+ int smallTickLength)
+Instantiates a new layout.
+ |
+
JHCLayout(int legendWidth,
+ int largeTickLength,
+ int smallTickLength,
+ boolean xTickRotate,
+ int xTickSpace,
+ boolean yTickRotate,
+ int yTickSpace)
+Instantiates a new layout.
+ |
+
JHCLayout(int offsetLeft,
+ int offsetRight,
+ int offsetTop,
+ int offsetBottom,
+ int offsetCenter)
+Instantiates a new layout.
+ |
+
JHCLayout(int offsetLeft,
+ int offsetRight,
+ int offsetTop,
+ int offsetBottom,
+ int offsetCenter,
+ boolean xTickRotate,
+ int xTickSpace,
+ boolean yTickRotate,
+ int yTickSpace)
+Instantiates a new layout.
+ |
+
JHCLayout(int offsetLeft,
+ int offsetRight,
+ int offsetTop,
+ int offsetBottom,
+ int offsetCenter,
+ int minimalTextWidth,
+ int legendWidth,
+ int largeTickLength,
+ int smallTickLength,
+ int textOffset)
+Instantiates a new layout.
+ |
+
JHCLayout(int offsetLeft,
+ int offsetRight,
+ int offsetTop,
+ int offsetBottom,
+ int offsetCenter,
+ int minimalTextWidth,
+ int legendWidth,
+ int largeTickLength,
+ int smallTickLength,
+ int textOffset,
+ boolean xTickRotate,
+ int xTickSpace,
+ boolean yTickRotate,
+ int yTickSpace)
+Instantiates a new layout.
+ |
+
public JHCLayout()+
public JHCLayout(boolean xTickRotate, + int xTickSpace, + boolean yTickRotate, + int yTickSpace)+
xTickRotate
- the x tick rotatexTickSpace
- the x tick spaceyTickRotate
- the y tick rotateyTickSpace
- the y tick spacepublic JHCLayout(int legendWidth, + int largeTickLength, + int smallTickLength)+
legendWidth
- the legend widthlargeTickLength
- the large tick lengthsmallTickLength
- the small tick lengthpublic JHCLayout(int legendWidth, + int largeTickLength, + int smallTickLength, + boolean xTickRotate, + int xTickSpace, + boolean yTickRotate, + int yTickSpace)+
legendWidth
- the legend widthlargeTickLength
- the large tick lengthsmallTickLength
- the small tick lengthxTickRotate
- the x tick rotatexTickSpace
- the x tick spaceyTickRotate
- the y tick rotateyTickSpace
- the y tick spacepublic JHCLayout(int offsetLeft, + int offsetRight, + int offsetTop, + int offsetBottom, + int offsetCenter)+
offsetLeft
- the offset leftoffsetRight
- the offset rightoffsetTop
- the offset topoffsetBottom
- the offset bottomoffsetCenter
- the offset centerpublic JHCLayout(int offsetLeft, + int offsetRight, + int offsetTop, + int offsetBottom, + int offsetCenter, + boolean xTickRotate, + int xTickSpace, + boolean yTickRotate, + int yTickSpace)+
offsetLeft
- the offset leftoffsetRight
- the offset rightoffsetTop
- the offset topoffsetBottom
- the offset bottomoffsetCenter
- the offset centerxTickRotate
- the x tick rotatexTickSpace
- the x tick spaceyTickRotate
- the y tick rotateyTickSpace
- the y tick spacepublic JHCLayout(int offsetLeft, + int offsetRight, + int offsetTop, + int offsetBottom, + int offsetCenter, + int minimalTextWidth, + int legendWidth, + int largeTickLength, + int smallTickLength, + int textOffset)+
offsetLeft
- the offset leftoffsetRight
- the offset rightoffsetTop
- the offset topoffsetBottom
- the offset bottomoffsetCenter
- the offset centerminimalTextWidth
- the minimal text widthlegendWidth
- the legend widthlargeTickLength
- the large tick lengthsmallTickLength
- the small tick lengthtextOffset
- the text offsetpublic JHCLayout(int offsetLeft, + int offsetRight, + int offsetTop, + int offsetBottom, + int offsetCenter, + int minimalTextWidth, + int legendWidth, + int largeTickLength, + int smallTickLength, + int textOffset, + boolean xTickRotate, + int xTickSpace, + boolean yTickRotate, + int yTickSpace)+
offsetLeft
- the offset leftoffsetRight
- the offset rightoffsetTop
- the offset topoffsetBottom
- the offset bottomoffsetCenter
- the offset centerminimalTextWidth
- the minimal text widthlegendWidth
- the legend widthlargeTickLength
- the large tick lengthsmallTickLength
- the small tick lengthtextOffset
- the text offsetxTickRotate
- the x tick rotatexTickSpace
- the x tick spaceyTickRotate
- the y tick rotateyTickSpace
- the y tick spaceJHCScale.Date, JHCScale.Decimal, JHCScale.Integer, JHCScale.String
Constructor and Description | +
---|
JHCScale.Date(java.util.Date from,
+ java.util.Date to)
+Instantiates a new scale date.
+ |
+
JHCScale.Date(java.util.Date from,
+ java.util.Date to,
+ java.text.DateFormat format)
+Instantiates a new scale date.
+ |
+
public JHCScale.Date(java.util.Date from, + java.util.Date to)+
from
- the fromto
- the topublic JHCScale.Date(java.util.Date from, + java.util.Date to, + java.text.DateFormat format)+
from
- the fromto
- the toformat
- the formatJHCScale.Date, JHCScale.Decimal, JHCScale.Integer, JHCScale.String
Constructor and Description | +
---|
JHCScale.Decimal(double from,
+ double to)
+Instantiates a new scale decimal.
+ |
+
JHCScale.Decimal(double from,
+ double to,
+ java.text.DecimalFormat format)
+Instantiates a new scale decimal.
+ |
+
public JHCScale.Decimal(double from, + double to)+
from
- the fromto
- the topublic JHCScale.Decimal(double from, + double to, + java.text.DecimalFormat format)+
from
- the fromto
- the toformat
- the formatJHCScale.Date, JHCScale.Decimal, JHCScale.Integer, JHCScale.String
Constructor and Description | +
---|
JHCScale.Integer(int from,
+ int to)
+Instantiates a new scale integer.
+ |
+
JHCScale.Date, JHCScale.Decimal, JHCScale.Integer, JHCScale.String
Constructor and Description | +
---|
JHCScale.String(java.lang.String[] values)
+Instantiates a new scale string.
+ |
+
T
- the generic typepublic abstract class JHCScale<T>
+extends java.lang.Object
+Modifier and Type | +Class and Description | +
---|---|
static class |
+JHCScale.Date
+This class implements a data/time scale
+ |
+
static class |
+JHCScale.Decimal
+This class implements a decimal scale
+ |
+
static class |
+JHCScale.Integer
+This class implements an integer scale
+ |
+
static class |
+JHCScale.String
+This class implements a string scale
+ |
+
Modifier and Type | +Method and Description | +
---|---|
void |
+JHC.setData(JHCData data,
+ JHCConfiguration config)
+Sets the data to be displayed by this widget
+ |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+JHCData.create(char[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(double[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(float[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(int[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(JHCDataProvider provider)
+Creates the.
+ |
+
static JHCData |
+JHCData.create(long[][] data)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
void |
+JHC.setData(JHCData data,
+ JHCConfiguration config)
+Sets the data to be displayed by this widget
+ |
+
Modifier and Type | +Method and Description | +
---|---|
JHCDataProvider.Orientation |
+JHCDataProvider.getOrientation()
+Gets the orientation.
+ |
+
static JHCDataProvider.Orientation |
+JHCDataProvider.Orientation.valueOf(java.lang.String name)
+Returns the enum constant of this type with the specified name.
+ |
+
static JHCDataProvider.Orientation[] |
+JHCDataProvider.Orientation.values()
+Returns an array containing the constants of this enum type, in
+the order they are declared.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+JHCData.create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+JHCData.create(JHCDataProvider provider)
+Creates the.
+ |
+
Modifier and Type | +Field and Description | +
---|---|
static JHCGradient |
+JHCGradient.GRADIENT_BLACKBODY
+BLACK, RED, YELLOW, WHITE, LIGHT_BLUE
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_BLUERED
+BRIGHT_BLUE, PURPLE, BRIGHT_RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_EARTH
+BLUE, GREEN, YELLOW, BROWN, TAN, WHITE
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_ELECTRIC
+BLACK, PURPLE, ORANGE, YELLOW, TAN, WHITE
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_GRAYS
+BLACK, LIGHT_GRAY
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_GRAYSCALE
+BLACK, GRAY, WHITE
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_GREENS
+DARK_GREEN, LIGHT_GREEN
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_HEAT
+BLUE, CYAN, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_HOT
+TAN, YELLOW, RED, BLACK
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_JET
+BLUE, LIGHT_BLUE, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_PICNIC
+BLUE, LIGHT_BLUE, WHITE, PINK
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_PORTLAND
+BLUE, GREEN, YELLOW, ORANGE, RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_RDBU
+BLUE, RED
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_YIGNBN
+WHITE, GREEN
+ |
+
static JHCGradient |
+JHCGradient.GRADIENT_YIORRD
+RED, ORANGE, GOLD, TAN, WHITE
+ |
+
Constructor and Description | +
---|
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
abstract java.util.Iterator<JHCHeatmap.Point> |
+JHCHeatmap.iterator()
+Iterator.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
abstract JHCHeatmap |
+JHCData.getHeatmap(int width,
+ int height)
+Gets the heat.
+ |
+
Constructor and Description | +
---|
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ int maximalWidth,
+ int maximalHeight,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
JHCConfiguration(java.lang.String xLabel,
+ java.lang.String yLabel,
+ JHCGradient gradient,
+ JHCLayout layout)
+Instantiates a new configuration.
+ |
+
Modifier and Type | +Class and Description | +
---|---|
static class |
+JHCScale.Date
+This class implements a data/time scale
+ |
+
static class |
+JHCScale.Decimal
+This class implements a decimal scale
+ |
+
static class |
+JHCScale.Integer
+This class implements an integer scale
+ |
+
static class |
+JHCScale.String
+This class implements a string scale
+ |
+
Modifier and Type | +Method and Description | +
---|---|
JHCScale<?> |
+JHCDataProvider.getXScale()
+Gets the x labels.
+ |
+
JHCScale<?> |
+JHCDataProvider.getYScale()
+Gets the y labels.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
static JHCData |
+JHCData.create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(char[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(double[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(float[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(int[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCDataProvider.Orientation orientation,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
static JHCData |
+JHCData.create(long[][] data,
+ JHCScale<?> xScale,
+ JHCScale<?> yScale)
+Creates a data object.
+ |
+
Interface | +Description | +
---|---|
JHCDataProvider | +
+ This interface can be implemented to convert data into a representation suitable for the widget
+ |
+
JHCHeatmap.Point | +
+ This interface represents a point in the heatmap.
+ |
+
Class | +Description | +
---|---|
JHC | +
+ This class implements a heatmap widget for SWT
+ |
+
JHCConfiguration | +
+ This class allows to configure how the heatmap is displayed.
+ |
+
JHCData | +
+ This class defines the abstract base type for data that can be handled by the widget/control.
+ |
+
JHCGradient | +
+ The class implements gradients for the heatmap.
+ |
+
JHCHeatmap | +
+ This abstract class represents a (potentially scaled) heatmap that has been retrieved from an instance of JHCData
+ |
+
JHCLayout | +
+ This class represents the layout that is to be used when displaying the heatmap
+ |
+
JHCScale<T> | +
+ This class provides an abstract type for scales
+ |
+
JHCScale.Date | +
+ This class implements a data/time scale
+ |
+
JHCScale.Decimal | +
+ This class implements a decimal scale
+ |
+
JHCScale.Integer | +
+ This class implements an integer scale
+ |
+
JHCScale.String | +
+ This class implements a string scale
+ |
+
Enum | +Description | +
---|---|
JHCDataProvider.Orientation | +
+ Data orientation
+ |
+
Class and Description | +
---|
JHCConfiguration
+ This class allows to configure how the heatmap is displayed.
+ |
+
JHCData
+ This class defines the abstract base type for data that can be handled by the widget/control.
+ |
+
JHCDataProvider
+ This interface can be implemented to convert data into a representation suitable for the widget
+ |
+
JHCDataProvider.Orientation
+ Data orientation
+ |
+
JHCGradient
+ The class implements gradients for the heatmap.
+ |
+
JHCHeatmap
+ This abstract class represents a (potentially scaled) heatmap that has been retrieved from an instance of JHCData
+ |
+
JHCHeatmap.Point
+ This interface represents a point in the heatmap.
+ |
+
JHCLayout
+ This class represents the layout that is to be used when displaying the heatmap
+ |
+
JHCScale
+ This class provides an abstract type for scales
+ |
+
Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+Each annotation type has its own separate page with the following sections:
+Each enum has its own separate page with the following sections:
+Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object
. The interfaces do not inherit from java.lang.Object
.
The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+These links take you to the next or previous class, interface, package, or related page.
+These links show and hide the HTML frames. All pages are available with or without frames.
+The All Classes link shows all classes and interfaces except non-static nested types.
+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
+The Constant Field Values page lists the static final fields and their values.
+addCanvasListener method. When
+ * the canvas event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author Fabian Prasser
+ */
+ interface CanvasListener {
+
+ /**
+ * Resized.
+ */
+ public void resized();
+
+ /**
+ * Shown.
+ */
+ public void shown();
+ }
+
+
+ /**
+ * Gets the background.
+ *
+ * @return the background
+ */
+ public V getBackground();
+
+ /**
+ * Gets the foreground.
+ *
+ * @return the foreground
+ */
+ public V getForeground();
+
+ /**
+ * Gets the black.
+ *
+ * @return the black
+ */
+ public V getBlack();
+
+ /**
+ * Gets the canvas size.
+ *
+ * @return the canvas size
+ */
+ public abstract Dimension getCanvasSize();
+
+ /**
+ * Gets the extents.
+ *
+ * @return the extents
+ */
+ public abstract Dimension getExtents();
+
+ /**
+ * Gets the font.
+ *
+ * @return the font
+ */
+ public U getFont();
+
+ /**
+ * Gets the gray.
+ *
+ * @return the gray
+ */
+ public V getGray();
+
+ /**
+ * Sets the heatmap.
+ *
+ * @param heatmap the new heatmap
+ */
+ public abstract void setHeatmap(RenderedHeatmap> heatmap);
+
+ /**
+ * Sets the listener.
+ *
+ * @param listener the new listener
+ */
+ public void setListener(CanvasListener listener);
+}
diff --git a/src/main/de/linearbits/jhc/Dimension.java b/src/main/de/linearbits/jhc/Dimension.java
new file mode 100644
index 0000000..bdd33b4
--- /dev/null
+++ b/src/main/de/linearbits/jhc/Dimension.java
@@ -0,0 +1,83 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+/**
+ * This class implements a dimension [width, height]
+ *
+ * @author Fabian Prasser
+ */
+class Dimension {
+
+ /** The height. */
+ public final int height;
+
+ /** The width. */
+ public final int width;
+
+ /**
+ * Instantiates a new dimension.
+ *
+ * @param width the width
+ * @param height the height
+ */
+ public Dimension(int width, int height) {
+ this.width = width;
+ this.height = height;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (getClass() != obj.getClass()) return false;
+ Dimension other = (Dimension) obj;
+ if (height != other.height) return false;
+ if (width != other.width) return false;
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + height;
+ result = prime * result + width;
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "Dimension [" + width + ", " + height + "]";
+ }
+}
diff --git a/src/main/de/linearbits/jhc/Graphics.java b/src/main/de/linearbits/jhc/Graphics.java
new file mode 100644
index 0000000..93d393e
--- /dev/null
+++ b/src/main/de/linearbits/jhc/Graphics.java
@@ -0,0 +1,204 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+/**
+ * This interface describes a generic graphics objects
+ *
+ * @author Fabian Prasser
+ *
+ * @param the generic type of Image
+ * @param the generic type of Color
+ */
+interface Graphics {
+
+ /** The Constant POSTFIX. */
+ public static final String POSTFIX = "...";
+
+ /**
+ * Disable antialiasing.
+ */
+ public void disableAntialiasing();
+
+ /**
+ * Disable interpolation.
+ */
+ public void disableInterpolation();
+
+ /**
+ * Draw image.
+ *
+ * @param image the image
+ * @param x the x
+ * @param y the y
+ * @param width the width
+ * @param height the height
+ */
+ public void drawImage(T image, int x, int y, int width, int height);
+
+ /**
+ * Draw legend.
+ *
+ * @param gradient the gradient
+ * @return the t
+ */
+ public T drawLegend(JHCGradient gradient);
+
+ /**
+ * Draw line.
+ *
+ * @param x1 the x1
+ * @param y1 the y1
+ * @param x2 the x2
+ * @param y2 the y2
+ */
+ public void drawLine(int x1, int y1, int x2, int y2);
+
+ /**
+ * Draw rectangle.
+ *
+ * @param x the x
+ * @param y the y
+ * @param width the width
+ * @param height the height
+ */
+ public void drawRectangle(int x, int y, int width, int height);
+
+ /**
+ * Draw rectangle filled.
+ *
+ * @param x the x
+ * @param y the y
+ * @param width the width
+ * @param height the height
+ */
+ public void drawRectangleFilled(int x, int y, int width, int height);
+
+ /**
+ * Draw string above horizontally centered.
+ *
+ * @param string the string
+ * @param x the x
+ * @param y the y
+ * @param width the width
+ */
+ public void drawStringAboveHorizontallyCentered(String string, int x, int y, int width);
+
+ /**
+ * Draw string below horizontally centered.
+ *
+ * @param string the string
+ * @param x the x
+ * @param y the y
+ * @param width the width
+ */
+ public void drawStringBelowHorizontallyCentered(String string, int x, int y, int width);
+
+ /**
+ * Draw string vertically centered left aligned.
+ *
+ * @param string the string
+ * @param x the x
+ * @param y the y
+ * @param width the width
+ * @param height the height
+ */
+ public void drawStringVerticallyCenteredLeftAligned(String string, int x, int y, int width, int height);
+
+ /**
+ * Enable antialiasing.
+ */
+ public void enableAntialiasing();
+
+ /**
+ * Enable interpolation.
+ */
+ public void enableInterpolation();
+
+ /**
+ * Gets the text height.
+ *
+ * @param string the string
+ * @return the text height
+ */
+ public int getTextHeight(String string);
+
+ /**
+ * Gets the text width.
+ *
+ * @param string the string
+ * @return the text width
+ */
+ public int getTextWidth(String string);
+
+ /**
+ * Inits the.
+ */
+ public void init();
+
+ /**
+ * Reset antialiasing.
+ */
+ public void resetAntialiasing();
+
+ /**
+ * Reset clipping.
+ */
+ public void resetClipping();
+
+ /**
+ * Reset interpolation.
+ */
+ public void resetInterpolation();
+
+ /**
+ * Reset rotation.
+ */
+ public void resetRotation();
+
+ /**
+ * Sets the background.
+ *
+ * @param color the new background
+ */
+ public void setBackground(U color);
+
+ /**
+ * Sets the foreground.
+ *
+ * @param color the new foreground
+ */
+ public void setForeground(U color);
+
+ /**
+ * Sets the rotation.
+ *
+ * @param degrees the new rotation
+ */
+ public void setRotation(int degrees);
+
+ /**
+ * Draws the given string centered in the given rectangle
+ * @param string
+ * @param i
+ * @param j
+ * @param width
+ * @param height
+ */
+ public void drawStringCentered(String string, int i, int j, int width, int height);
+}
diff --git a/src/main/de/linearbits/jhc/JHCConfiguration.java b/src/main/de/linearbits/jhc/JHCConfiguration.java
new file mode 100644
index 0000000..e0c27d2
--- /dev/null
+++ b/src/main/de/linearbits/jhc/JHCConfiguration.java
@@ -0,0 +1,143 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+/**
+ * This class allows to configure how the heatmap is displayed.
+ *
+ * @author Fabian Prasser
+ */
+public class JHCConfiguration {
+
+ /** The gradient. */
+ private final JHCGradient gradient;
+
+ /** The layout. */
+ private final JHCLayout layout;
+
+ /** The maximal size. */
+ private final Dimension maximalSize;
+
+ /** The x label. */
+ private final String xLabel;
+
+ /** The y label. */
+ private final String yLabel;
+
+ /**
+ * Instantiates a new configuration.
+ *
+ * @param xLabel the x label
+ * @param yLabel the y label
+ * @param maximalWidth the maximal width
+ * @param maximalHeight the maximal height
+ * @param gradient the gradient
+ */
+ public JHCConfiguration(String xLabel, String yLabel, int maximalWidth, int maximalHeight, JHCGradient gradient) {
+ this(xLabel, yLabel, maximalWidth, maximalHeight, gradient, null);
+ }
+
+ /**
+ * Instantiates a new configuration.
+ *
+ * @param xLabel the x label
+ * @param yLabel the y label
+ * @param maximalSize the maximal size
+ * @param gradient the gradient
+ * @param layout the layout
+ */
+ public JHCConfiguration(String xLabel, String yLabel, int maximalWidth, int maximalHeight, JHCGradient gradient, JHCLayout layout) {
+ this.maximalSize = new Dimension(maximalWidth, maximalHeight);
+ this.gradient = gradient;
+ this.xLabel = xLabel;
+ this.yLabel = yLabel;
+ if (layout == null) {
+ this.layout = new JHCLayout();
+ } else {
+ this.layout = layout;
+ }
+ }
+
+ /**
+ * Instantiates a new configuration.
+ *
+ * @param xLabel the x label
+ * @param yLabel the y label
+ * @param gradient the gradient
+ */
+ public JHCConfiguration(String xLabel, String yLabel, JHCGradient gradient) {
+ this(xLabel, yLabel, Integer.MAX_VALUE, Integer.MAX_VALUE, gradient, null);
+ }
+
+ /**
+ * Instantiates a new configuration.
+ *
+ * @param xLabel the x label
+ * @param yLabel the y label
+ * @param gradient the gradient
+ * @param layout the layout
+ */
+ public JHCConfiguration(String xLabel, String yLabel, JHCGradient gradient, JHCLayout layout) {
+ this(xLabel, yLabel, Integer.MAX_VALUE, Integer.MAX_VALUE, gradient, layout);
+ }
+
+ /**
+ * Gets the gradient.
+ *
+ * @return the gradient
+ */
+ protected JHCGradient getGradient() {
+ return gradient;
+ }
+
+ /**
+ * Gets the layout.
+ *
+ * @return the layout
+ */
+ protected JHCLayout getLayout() {
+ return layout;
+ }
+
+ /**
+ * Gets the maximal size.
+ *
+ * @return the maximal size
+ */
+ protected Dimension getMaximalSize() {
+ return maximalSize;
+ }
+
+ /**
+ * Gets the x label.
+ *
+ * @return the x label
+ */
+ protected String getXLabel() {
+ return xLabel;
+ }
+
+ /**
+ * Gets the y label.
+ *
+ * @return the y label
+ */
+ protected String getYLabel() {
+ return yLabel;
+ }
+}
diff --git a/src/main/de/linearbits/jhc/JHCData.java b/src/main/de/linearbits/jhc/JHCData.java
new file mode 100644
index 0000000..c92690b
--- /dev/null
+++ b/src/main/de/linearbits/jhc/JHCData.java
@@ -0,0 +1,237 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import de.linearbits.jhc.JHCDataProvider.Orientation;
+
+/**
+ * This class defines the abstract base type for data that can be handled by the widget/control. Moreover, it offers
+ * static methods for deriving instances for typical data representations, e.g., arrays. Extend this class, if you want to
+ * encapsule potentially long-running processes that compute the heatmap
+ *
+ * @author Fabian Prasser
+ */
+public abstract class JHCData {
+
+ /**
+ * Creates a data object. Assumes a row-oriented layout.
+ *
+ * @param data the data
+ * @return the data
+ */
+ public static JHCData create(double[][] data) {
+ return new ProviderData(new ProviderDoubleArray(data, Orientation.ROW, null, null));
+ }
+
+ /**
+ * Creates a data object. Assumes a row-oriented layout.
+ *
+ * @param data the data
+ * @param xScale the x scale
+ * @param yScale the y scale
+ * @return the data
+ */
+ public static JHCData create(double[][] data, JHCScale> xScale, JHCScale> yScale) {
+ return new ProviderData(new ProviderDoubleArray(data, Orientation.ROW, xScale, yScale));
+ }
+
+ /**
+ * Creates a data object
+ *
+ * @param data the data
+ * @param orientation the orientation
+ * @param xScale the x scale
+ * @param yScale the y scale
+ * @return the data
+ */
+ public static JHCData create(double[][] data, Orientation orientation, JHCScale> xScale, JHCScale> yScale) {
+ return new ProviderData(new ProviderDoubleArray(data, orientation, xScale, yScale));
+ }
+
+ /**
+ * Creates a data object. Assumes a row-oriented layout.
+ *
+ * @param data the data
+ * @return the data
+ */
+ public static JHCData create(char[][] data) {
+ return new ProviderData(new ProviderCharArray(data, Orientation.ROW, null, null));
+ }
+
+ /**
+ * Creates a data object. Assumes a row-oriented layout.
+ *
+ * @param data the data
+ * @param xScale the x scale
+ * @param yScale the y scale
+ * @return the data
+ */
+ public static JHCData create(char[][] data, JHCScale> xScale, JHCScale> yScale) {
+ return new ProviderData(new ProviderCharArray(data, Orientation.ROW, xScale, yScale));
+ }
+
+ /**
+ * Creates a data object
+ *
+ * @param data the data
+ * @param orientation the orientation
+ * @param xScale the x scale
+ * @param yScale the y scale
+ * @return the data
+ */
+ public static JHCData create(char[][] data, Orientation orientation, JHCScale> xScale, JHCScale> yScale) {
+ return new ProviderData(new ProviderCharArray(data, orientation, xScale, yScale));
+ }
+
+ /**
+ * Creates a data object. Assumes a row-oriented layout.
+ *
+ * @param data the data
+ * @return the data
+ */
+ public static JHCData create(int[][] data) {
+ return new ProviderData(new ProviderIntegerArray(data, Orientation.ROW, null, null));
+ }
+
+ /**
+ * Creates a data object. Assumes a row-oriented layout.
+ *
+ * @param data the data
+ * @param xScale the x scale
+ * @param yScale the y scale
+ * @return the data
+ */
+ public static JHCData create(int[][] data, JHCScale> xScale, JHCScale> yScale) {
+ return new ProviderData(new ProviderIntegerArray(data, Orientation.ROW, xScale, yScale));
+ }
+
+ /**
+ * Creates a data object
+ *
+ * @param data the data
+ * @param orientation the orientation
+ * @param xScale the x scale
+ * @param yScale the y scale
+ * @return the data
+ */
+ public static JHCData create(int[][] data, Orientation orientation, JHCScale> xScale, JHCScale> yScale) {
+ return new ProviderData(new ProviderIntegerArray(data, orientation, xScale, yScale));
+ }
+
+ /**
+ * Creates a data object. Assumes a row-oriented layout.
+ *
+ * @param data the data
+ * @return the data
+ */
+ public static JHCData create(long[][] data) {
+ return new ProviderData(new ProviderLongArray(data, Orientation.ROW, null, null));
+ }
+
+ /**
+ * Creates a data object. Assumes a row-oriented layout.
+ *
+ * @param data the data
+ * @param xScale the x scale
+ * @param yScale the y scale
+ * @return the data
+ */
+ public static JHCData create(long[][] data, JHCScale> xScale, JHCScale> yScale) {
+ return new ProviderData(new ProviderLongArray(data, Orientation.ROW, xScale, yScale));
+ }
+
+ /**
+ * Creates a data object
+ *
+ * @param data the data
+ * @param orientation the orientation
+ * @param xScale the x scale
+ * @param yScale the y scale
+ * @return the data
+ */
+ public static JHCData create(long[][] data, Orientation orientation, JHCScale> xScale, JHCScale> yScale) {
+ return new ProviderData(new ProviderLongArray(data, orientation, xScale, yScale));
+ }
+
+ /**
+ * Creates a data object. Assumes a row-oriented layout.
+ *
+ * @param data the data
+ * @return the data
+ */
+ public static JHCData create(float[][] data) {
+ return new ProviderData(new ProviderFloatArray(data, Orientation.ROW, null, null));
+ }
+
+ /**
+ * Creates a data object. Assumes a row-oriented layout.
+ *
+ * @param data the data
+ * @param xScale the x scale
+ * @param yScale the y scale
+ * @return the data
+ */
+ public static JHCData create(float[][] data, JHCScale> xScale, JHCScale> yScale) {
+ return new ProviderData(new ProviderFloatArray(data, Orientation.ROW, xScale, yScale));
+ }
+
+ /**
+ * Creates a data object
+ *
+ * @param data the data
+ * @param orientation the orientation
+ * @param xScale the x scale
+ * @param yScale the y scale
+ * @return the data
+ */
+ public static JHCData create(float[][] data, Orientation orientation, JHCScale> xScale, JHCScale> yScale) {
+ return new ProviderData(new ProviderFloatArray(data, orientation, xScale, yScale));
+ }
+ /**
+ * Creates the.
+ *
+ * @param provider the provider
+ * @return the data
+ */
+ public static JHCData create(JHCDataProvider provider) {
+ return new ProviderData(provider);
+ }
+
+ /**
+ * Gets the heat.
+ *
+ * @param width the width
+ * @param height the height
+ * @return the heat
+ */
+ public abstract JHCHeatmap getHeatmap(int width, int height);
+
+ /**
+ * Gets the original width of the data
+ *
+ * @return the width
+ */
+ public abstract int getWidth();
+
+ /**
+ * Gets the original height of the data
+ *
+ * @return the height
+ */
+ public abstract int getHeight();
+}
diff --git a/src/main/de/linearbits/jhc/JHCDataProvider.java b/src/main/de/linearbits/jhc/JHCDataProvider.java
new file mode 100644
index 0000000..8723295
--- /dev/null
+++ b/src/main/de/linearbits/jhc/JHCDataProvider.java
@@ -0,0 +1,82 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+
+/**
+ * This interface can be implemented to convert data into a representation suitable for the widget
+ *
+ * @author Fabian Prasser
+ */
+public interface JHCDataProvider {
+
+ /**
+ * Data orientation
+ *
+ * @author Fabian Prasser
+ */
+ public static enum Orientation {
+ ROW,
+ COLUMN
+ }
+
+ /**
+ * Returns the.
+ *
+ * @param x the x
+ * @param y the y
+ * @return the double
+ */
+ public abstract double get(int x, int y);
+
+ /**
+ * Gets the height.
+ *
+ * @return the height
+ */
+ public abstract int getHeight();
+
+ /**
+ * Gets the width.
+ *
+ * @return the width
+ */
+ public abstract int getWidth();
+
+ /**
+ * Gets the orientation.
+ *
+ * @return the orientation
+ */
+ public abstract Orientation getOrientation();
+
+
+ /**
+ * Gets the x labels.
+ *
+ * @return the x scale
+ */
+ public abstract JHCScale> getXScale();
+
+ /**
+ * Gets the y labels.
+ *
+ * @return the y scale
+ */
+ public abstract JHCScale> getYScale();
+}
diff --git a/src/main/de/linearbits/jhc/JHCGradient.java b/src/main/de/linearbits/jhc/JHCGradient.java
new file mode 100644
index 0000000..f8cffd4
--- /dev/null
+++ b/src/main/de/linearbits/jhc/JHCGradient.java
@@ -0,0 +1,167 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.LinearGradientPaint;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+
+/**
+ * The class implements gradients for the heatmap. Some predefined gradients are
+ * inspired by plotly (https://github.com/plotly).
+ *
+ * @author Fabian Prasser
+ */
+public class JHCGradient {
+
+ /** BLACK, GRAY, WHITE */
+ public static final JHCGradient GRADIENT_GRAYSCALE = new JHCGradient(new Color[]
+ { Color.BLACK, Color.GRAY, Color.WHITE });
+
+ /** BLUE, CYAN, GREEN, YELLOW, ORANGE, RED */
+ public static final JHCGradient GRADIENT_HEAT = new JHCGradient(new Color[]
+ { Color.BLUE, Color.CYAN, Color.GREEN, Color.YELLOW, Color.ORANGE, Color.RED });
+
+ /** BLACK, LIGHT_GRAY*/
+ public static final JHCGradient GRADIENT_GRAYS = new JHCGradient(new Color[]
+ {Color.BLACK, Color.LIGHT_GRAY});
+
+ /** WHITE, GREEN */
+ public static final JHCGradient GRADIENT_YIGNBN = new JHCGradient(new Color[]
+ {Color.WHITE, Color.GREEN});
+
+ /** DARK_GREEN, LIGHT_GREEN */
+ public static final JHCGradient GRADIENT_GREENS = new JHCGradient(new Color[]
+ {Color.decode("#013220"), Color.decode("#90ee90")});
+
+ /** RED, ORANGE, GOLD, TAN, WHITE*/
+ public static final JHCGradient GRADIENT_YIORRD = new JHCGradient(new Color[]
+ {Color.RED, Color.ORANGE, Color.decode("#ffd700"), Color.decode("#d2b48c"), Color.WHITE});
+
+ /** BRIGHT_BLUE, PURPLE, BRIGHT_RED*/
+ public static final JHCGradient GRADIENT_BLUERED = new JHCGradient(new Color[]
+ {Color.decode("#00a1c2"), Color.decode("#800080"), Color.decode("#be0032")});
+
+ /** BLUE, RED*/
+ public static final JHCGradient GRADIENT_RDBU = new JHCGradient(new Color[]
+ {Color.BLUE, Color.RED});
+
+ /** BLUE, LIGHT_BLUE, WHITE, PINK*/
+ public static final JHCGradient GRADIENT_PICNIC = new JHCGradient(new Color[]
+ {Color.BLUE, Color.decode("#add8e6"), Color.WHITE, Color.PINK});
+
+ /** BLUE, GREEN, YELLOW, ORANGE, RED*/
+ public static final JHCGradient GRADIENT_PORTLAND = new JHCGradient(new Color[]
+ {Color.BLUE, Color.GREEN, Color.YELLOW, Color.ORANGE, Color.RED});
+
+ /** BLUE, LIGHT_BLUE, GREEN, YELLOW, ORANGE, RED*/
+ public static final JHCGradient GRADIENT_JET = new JHCGradient(new Color[]
+ {Color.BLUE, Color.decode("#add8e6"), Color.GREEN, Color.YELLOW, Color.ORANGE, Color.RED});
+
+ /** TAN, YELLOW, RED, BLACK*/
+ public static final JHCGradient GRADIENT_HOT = new JHCGradient(new Color[]
+ {Color.decode("#d2b48c"), Color.YELLOW, Color.RED, Color.BLACK});
+
+ /** BLACK, RED, YELLOW, WHITE, LIGHT_BLUE*/
+ public static final JHCGradient GRADIENT_BLACKBODY = new JHCGradient(new Color[]
+ {Color.BLACK, Color.RED, Color.YELLOW, Color.WHITE, Color.decode("#add8e6")});
+
+ /** BLUE, GREEN, YELLOW, BROWN, TAN, WHITE*/
+ public static final JHCGradient GRADIENT_EARTH = new JHCGradient(new Color[]
+ {Color.BLUE, Color.GREEN, Color.YELLOW, Color.decode("#a52a2a"), Color.decode("#d2b48c"), Color.WHITE});
+
+ /** BLACK, PURPLE, ORANGE, YELLOW, TAN, WHITE*/
+ public static final JHCGradient GRADIENT_ELECTRIC = new JHCGradient(new Color[]
+ {Color.BLACK, Color.decode("#800080"), Color.ORANGE, Color.YELLOW, Color.decode("#d2b48c"), Color.WHITE});
+
+ /** The colors. */
+ private int[] colors;
+
+ /**
+ * Instantiates a new gradient.
+ *
+ * @param _colors the _colors
+ */
+ public JHCGradient(Color[] _colors) {
+ this(_colors, 100);
+ }
+
+ /**
+ * Instantiates a new gradient.
+ *
+ * @param _colors the _colors
+ * @param steps the steps
+ */
+ public JHCGradient(Color[] _colors, int steps) {
+ this.colors = getGradient(_colors, steps);
+ }
+
+ /**
+ * Gets the color.
+ *
+ * @param heat the heat
+ * @return the color
+ */
+ protected int getColor(int heat) {
+ return colors[heat];
+ }
+
+ /**
+ * Gets the steps.
+ *
+ * @return the steps
+ */
+ protected int getSteps() {
+ return colors.length;
+ }
+
+ /**
+ * Gets the gradient.
+ *
+ * @param colors the colors
+ * @param steps the steps
+ * @return the gradient
+ */
+ private int[] getGradient(Color[] colors, int steps) {
+
+ // Draw the gradient to a buffered image
+ Point2D start = new Point2D.Float(0, 0);
+ Point2D end = new Point2D.Float(1, steps);
+ float[] dist = new float[colors.length];
+ for (int i = 0; i < dist.length; i++) {
+ dist[i] = (1.0f / dist.length) * i;
+ }
+ LinearGradientPaint p = new LinearGradientPaint(start, end, dist, colors);
+ BufferedImage legend = new BufferedImage(1, steps, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2d = (Graphics2D) legend.getGraphics();
+ g2d.setPaint(p);
+ g2d.drawRect(0, 0, 1, steps);
+ g2d.dispose();
+
+ // Convert to color array
+ int[] result = new int[steps];
+ for (int y = 0; y < steps; y++) {
+ result[y] = legend.getRGB(0, y);
+ }
+
+ // Return
+ return result;
+ }
+}
diff --git a/src/main/de/linearbits/jhc/JHCHeatmap.java b/src/main/de/linearbits/jhc/JHCHeatmap.java
new file mode 100644
index 0000000..35cd635
--- /dev/null
+++ b/src/main/de/linearbits/jhc/JHCHeatmap.java
@@ -0,0 +1,109 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import java.util.Iterator;
+
+/**
+ * This abstract class represents a (potentially scaled) heatmap that has been retrieved from an instance of JHCData
+ *
+ * @author Fabian Prasser
+ */
+public abstract class JHCHeatmap {
+
+ /**
+ * This interface represents a point in the heatmap. It is defined by indices on the x- and y-axis where each
+ * index corresponds to the according entry in the current scale.
+ *
+ * @author Fabian Prasser
+ */
+ public static interface Point {
+
+ /**
+ * Gets the value.
+ *
+ * @return the value
+ */
+ public abstract double getValue();
+
+ /**
+ * Gets the x.
+ *
+ * @return the x
+ */
+ public abstract int getX();
+
+ /**
+ * Gets the y.
+ *
+ * @return the y
+ */
+ public abstract int getY();
+ }
+
+ /**
+ * Gets the height.
+ *
+ * @return the height
+ */
+ public abstract int getHeight();
+
+ /**
+ * Gets the max.
+ *
+ * @return the max
+ */
+ public abstract double getMax();
+
+ /**
+ * Gets the min.
+ *
+ * @return the min
+ */
+ public abstract double getMin();
+
+ /**
+ * Gets the width.
+ *
+ * @return the width
+ */
+ public abstract int getWidth();
+
+ /**
+ * Gets the x label.
+ *
+ * @param index the index
+ * @return the x label
+ */
+ public abstract String getXLabel(int index);
+
+ /**
+ * Gets the y label.
+ *
+ * @param index the index
+ * @return the y label
+ */
+ public abstract String getYLabel(int index);
+
+ /**
+ * Iterator.
+ *
+ * @return the iterator
+ */
+ public abstract Iterator iterator();
+}
diff --git a/src/main/de/linearbits/jhc/JHCLayout.java b/src/main/de/linearbits/jhc/JHCLayout.java
new file mode 100644
index 0000000..5f34711
--- /dev/null
+++ b/src/main/de/linearbits/jhc/JHCLayout.java
@@ -0,0 +1,756 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+/**
+ * This class represents the layout that is to be used when displaying the heatmap
+ *
+ * @author Fabian Prasser
+ */
+public class JHCLayout {
+
+ /** The Constant MINIMAL_HEATMAP_SIZE. */
+ private static final int MINIMAL_HEATMAP_SIZE = 10;
+
+ /** The Constant DEFAULT_LARGE_TICK_LENGTH. */
+ private static final int DEFAULT_LARGE_TICK_LENGTH = 5;
+
+ /** The Constant DEFAULT_LEGEND_WIDTH. */
+ private static final int DEFAULT_LEGEND_WIDTH = 30;
+
+ /** The Constant DEFAULT_OFFSET_CENTER_RIGHT_TOP. */
+ private static final int DEFAULT_OFFSET_CENTER_RIGHT_TOP = 30;
+
+ /** The Constant DEFAULT_OFFSET_LEFT_BOTTOM. */
+ private static final int DEFAULT_OFFSET_LEFT_BOTTOM = 5;
+
+ /** The Constant DEFAULT_SMALL_TICK_LENGTH. */
+ private static final int DEFAULT_SMALL_TICK_LENGTH = 3;
+
+ /** The Constant DEFAULT_TEXT_OFFSET. */
+ private static final int DEFAULT_TEXT_OFFSET = 5;
+
+ /** The Constant DEFAULT_TICK_SPACE. */
+ private static final int DEFAULT_TICK_SPACE = 20;
+
+ /** The bottom offset. */
+ private final int bottomOffset;
+
+ /** The center offset. */
+ private final int centerOffset;
+
+ /** The large tick length. */
+ private final int largeTickLength;
+
+ /** The left offset. */
+ private final int leftOffset;
+
+ /** The legend width. */
+ private final int legendWidth;
+
+ /** The right offset. */
+ private final int rightOffset;
+
+ /** The small tick length. */
+ private final int smallTickLength;
+
+ /** The text offset. */
+ private final int textOffset;
+
+ /** The top offset. */
+ private final int topOffset;
+
+ /** The x tick rotate. */
+ private final boolean xTickRotate;
+
+ /** The x tick space. */
+ private final int xTickSpace;
+
+ /** The y tick rotate. */
+ private final boolean yTickRotate;
+
+ /** The y tick space. */
+ private final int yTickSpace;
+
+ /**
+ * Instantiates a new layout.
+ */
+ public JHCLayout() {
+ this.leftOffset = DEFAULT_OFFSET_LEFT_BOTTOM;
+ this.rightOffset = DEFAULT_OFFSET_CENTER_RIGHT_TOP;
+ this.topOffset = DEFAULT_OFFSET_CENTER_RIGHT_TOP;
+ this.bottomOffset = DEFAULT_OFFSET_LEFT_BOTTOM;
+ this.centerOffset = DEFAULT_OFFSET_CENTER_RIGHT_TOP;
+ this.legendWidth = DEFAULT_LEGEND_WIDTH;
+ this.largeTickLength = DEFAULT_LARGE_TICK_LENGTH;
+ this.smallTickLength = DEFAULT_SMALL_TICK_LENGTH;
+ this.textOffset = DEFAULT_TEXT_OFFSET;
+ this.xTickRotate = false;
+ this.yTickRotate = false;
+ this.xTickSpace = DEFAULT_TICK_SPACE;
+ this.yTickSpace = DEFAULT_TICK_SPACE;
+ this.check();
+ }
+
+ /**
+ * Instantiates a new layout.
+ *
+ * @param xTickRotate the x tick rotate
+ * @param xTickSpace the x tick space
+ * @param yTickRotate the y tick rotate
+ * @param yTickSpace the y tick space
+ */
+ public JHCLayout(boolean xTickRotate, int xTickSpace, boolean yTickRotate, int yTickSpace) {
+ this.leftOffset = DEFAULT_OFFSET_LEFT_BOTTOM;
+ this.rightOffset = DEFAULT_OFFSET_CENTER_RIGHT_TOP;
+ this.topOffset = DEFAULT_OFFSET_CENTER_RIGHT_TOP;
+ this.bottomOffset = DEFAULT_OFFSET_LEFT_BOTTOM;
+ this.centerOffset = DEFAULT_OFFSET_CENTER_RIGHT_TOP;
+ this.legendWidth = DEFAULT_LEGEND_WIDTH;
+ this.largeTickLength = DEFAULT_LARGE_TICK_LENGTH;
+ this.smallTickLength = DEFAULT_SMALL_TICK_LENGTH;
+ this.textOffset = DEFAULT_TEXT_OFFSET;
+ this.xTickRotate = xTickRotate;
+ this.yTickRotate = yTickRotate;
+ this.xTickSpace = xTickSpace;
+ this.yTickSpace = yTickSpace;
+ this.check();
+ }
+
+ /**
+ * Instantiates a new layout.
+ *
+ * @param legendWidth the legend width
+ * @param largeTickLength the large tick length
+ * @param smallTickLength the small tick length
+ */
+ public JHCLayout(int legendWidth, int largeTickLength, int smallTickLength) {
+ this.leftOffset = DEFAULT_OFFSET_LEFT_BOTTOM;
+ this.rightOffset = DEFAULT_OFFSET_CENTER_RIGHT_TOP;
+ this.topOffset = DEFAULT_OFFSET_CENTER_RIGHT_TOP;
+ this.bottomOffset = DEFAULT_OFFSET_LEFT_BOTTOM;
+ this.centerOffset = DEFAULT_OFFSET_CENTER_RIGHT_TOP;
+ this.legendWidth = legendWidth;
+ this.smallTickLength = smallTickLength;
+ this.largeTickLength = largeTickLength;
+ this.textOffset = DEFAULT_TEXT_OFFSET;
+ this.xTickRotate = false;
+ this.yTickRotate = false;
+ this.xTickSpace = DEFAULT_TICK_SPACE;
+ this.yTickSpace = DEFAULT_TICK_SPACE;
+ this.check();
+ }
+
+ /**
+ * Instantiates a new layout.
+ *
+ * @param legendWidth the legend width
+ * @param largeTickLength the large tick length
+ * @param smallTickLength the small tick length
+ * @param xTickRotate the x tick rotate
+ * @param xTickSpace the x tick space
+ * @param yTickRotate the y tick rotate
+ * @param yTickSpace the y tick space
+ */
+ public JHCLayout(int legendWidth, int largeTickLength, int smallTickLength, boolean xTickRotate, int xTickSpace, boolean yTickRotate, int yTickSpace) {
+ this.leftOffset = DEFAULT_OFFSET_LEFT_BOTTOM;
+ this.rightOffset = DEFAULT_OFFSET_CENTER_RIGHT_TOP;
+ this.topOffset = DEFAULT_OFFSET_CENTER_RIGHT_TOP;
+ this.bottomOffset = DEFAULT_OFFSET_LEFT_BOTTOM;
+ this.centerOffset = DEFAULT_OFFSET_CENTER_RIGHT_TOP;
+ this.legendWidth = legendWidth;
+ this.smallTickLength = smallTickLength;
+ this.largeTickLength = largeTickLength;
+ this.textOffset = DEFAULT_TEXT_OFFSET;
+ this.xTickRotate = xTickRotate;
+ this.yTickRotate = yTickRotate;
+ this.xTickSpace = xTickSpace;
+ this.yTickSpace = yTickSpace;
+ this.check();
+ }
+
+ /**
+ * Instantiates a new layout.
+ *
+ * @param offsetLeft the offset left
+ * @param offsetRight the offset right
+ * @param offsetTop the offset top
+ * @param offsetBottom the offset bottom
+ * @param offsetCenter the offset center
+ */
+ public JHCLayout(int offsetLeft, int offsetRight, int offsetTop, int offsetBottom, int offsetCenter) {
+ this.leftOffset = offsetLeft;
+ this.rightOffset = offsetRight;
+ this.topOffset = offsetTop;
+ this.bottomOffset = offsetBottom;
+ this.centerOffset = offsetCenter;
+ this.legendWidth = DEFAULT_LEGEND_WIDTH;
+ this.largeTickLength = DEFAULT_LARGE_TICK_LENGTH;
+ this.smallTickLength = DEFAULT_SMALL_TICK_LENGTH;
+ this.textOffset = DEFAULT_TEXT_OFFSET;
+ this.xTickRotate = false;
+ this.yTickRotate = false;
+ this.xTickSpace = DEFAULT_TICK_SPACE;
+ this.yTickSpace = DEFAULT_TICK_SPACE;
+ this.check();
+ }
+
+ /**
+ * Instantiates a new layout.
+ *
+ * @param offsetLeft the offset left
+ * @param offsetRight the offset right
+ * @param offsetTop the offset top
+ * @param offsetBottom the offset bottom
+ * @param offsetCenter the offset center
+ * @param xTickRotate the x tick rotate
+ * @param xTickSpace the x tick space
+ * @param yTickRotate the y tick rotate
+ * @param yTickSpace the y tick space
+ */
+ public JHCLayout(int offsetLeft, int offsetRight, int offsetTop, int offsetBottom, int offsetCenter, boolean xTickRotate, int xTickSpace, boolean yTickRotate, int yTickSpace) {
+ this.leftOffset = offsetLeft;
+ this.rightOffset = offsetRight;
+ this.topOffset = offsetTop;
+ this.bottomOffset = offsetBottom;
+ this.centerOffset = offsetCenter;
+ this.legendWidth = DEFAULT_LEGEND_WIDTH;
+ this.largeTickLength = DEFAULT_LARGE_TICK_LENGTH;
+ this.smallTickLength = DEFAULT_SMALL_TICK_LENGTH;
+ this.textOffset = DEFAULT_TEXT_OFFSET;
+ this.xTickRotate = xTickRotate;
+ this.yTickRotate = yTickRotate;
+ this.xTickSpace = xTickSpace;
+ this.yTickSpace = yTickSpace;
+ this.check();
+ }
+
+ /**
+ * Instantiates a new layout.
+ *
+ * @param offsetLeft the offset left
+ * @param offsetRight the offset right
+ * @param offsetTop the offset top
+ * @param offsetBottom the offset bottom
+ * @param offsetCenter the offset center
+ * @param minimalTextWidth the minimal text width
+ * @param legendWidth the legend width
+ * @param largeTickLength the large tick length
+ * @param smallTickLength the small tick length
+ * @param textOffset the text offset
+ */
+ public JHCLayout(int offsetLeft, int offsetRight, int offsetTop, int offsetBottom, int offsetCenter, int minimalTextWidth, int legendWidth, int largeTickLength, int smallTickLength, int textOffset) {
+ this.leftOffset = offsetLeft;
+ this.rightOffset = offsetRight;
+ this.topOffset = offsetTop;
+ this.bottomOffset = offsetBottom;
+ this.centerOffset = offsetCenter;
+ this.legendWidth = legendWidth;
+ this.smallTickLength = smallTickLength;
+ this.largeTickLength = largeTickLength;
+ this.textOffset = textOffset;
+ this.xTickRotate = false;
+ this.yTickRotate = false;
+ this.xTickSpace = DEFAULT_TICK_SPACE;
+ this.yTickSpace = DEFAULT_TICK_SPACE;
+ this.check();
+ }
+
+ /**
+ * Instantiates a new layout.
+ *
+ * @param offsetLeft the offset left
+ * @param offsetRight the offset right
+ * @param offsetTop the offset top
+ * @param offsetBottom the offset bottom
+ * @param offsetCenter the offset center
+ * @param minimalTextWidth the minimal text width
+ * @param legendWidth the legend width
+ * @param largeTickLength the large tick length
+ * @param smallTickLength the small tick length
+ * @param textOffset the text offset
+ * @param xTickRotate the x tick rotate
+ * @param xTickSpace the x tick space
+ * @param yTickRotate the y tick rotate
+ * @param yTickSpace the y tick space
+ */
+ public JHCLayout(int offsetLeft, int offsetRight, int offsetTop, int offsetBottom, int offsetCenter, int minimalTextWidth, int legendWidth, int largeTickLength, int smallTickLength, int textOffset, boolean xTickRotate, int xTickSpace, boolean yTickRotate, int yTickSpace) {
+ this.leftOffset = offsetLeft;
+ this.rightOffset = offsetRight;
+ this.topOffset = offsetTop;
+ this.bottomOffset = offsetBottom;
+ this.centerOffset = offsetCenter;
+ this.legendWidth = legendWidth;
+ this.smallTickLength = smallTickLength;
+ this.largeTickLength = largeTickLength;
+ this.textOffset = textOffset;
+ this.xTickRotate = xTickRotate;
+ this.yTickRotate = yTickRotate;
+ this.xTickSpace = xTickSpace;
+ this.yTickSpace = yTickSpace;
+ this.check();
+ }
+
+ /**
+ * Gets the rendered layout.
+ *
+ * @param config the config
+ * @param canvas the canvas
+ * @param data the data
+ * @return the rendered layout
+ */
+ protected RenderedLayout getRenderedLayout(JHCConfiguration config, Canvas, ?, ?> canvas, JHCData data) {
+ return getRenderedLayout(config, canvas, canvas.getCanvasSize(), new Dimension(data.getWidth(), data.getHeight()));
+ }
+
+ /**
+ * Gets the rendered layout.
+ *
+ * @param config the config
+ * @param canvas the canvas
+ * @param size the size
+ * @param heatmap the heatmap
+ * @return the rendered layout
+ */
+ protected RenderedLayout getRenderedLayout(JHCConfiguration config, Canvas, ?, ?> canvas, Dimension size, RenderedHeatmap> heatmap) {
+ return getRenderedLayout(config, canvas, size, new Dimension(heatmap.getWidth(), heatmap.getHeight()));
+ }
+
+ /**
+ * Check.
+ */
+ private void check() {
+ check("leftOffset", leftOffset);
+ check("rightOffset", rightOffset);
+ check("topOffset", topOffset);
+ check("bottomOffset", bottomOffset);
+ check("centerOffset", centerOffset);
+ check("legendWidth", legendWidth);
+ check("largeTickLength", largeTickLength);
+ check("smallTickLength", smallTickLength);
+ check("textOffset", textOffset);
+ check("xTickSpace", xTickSpace);
+ check("yTickSpace", yTickSpace);
+ }
+
+ /**
+ * Check.
+ *
+ * @param parameter the parameter
+ * @param value the value
+ */
+ private void check(String parameter, int value) {
+ if (value <= 0) {
+ throw new IllegalArgumentException("Parameter '" + parameter + "' must be larger than zero");
+ }
+ }
+
+ /**
+ * Gets the rendered layout.
+ *
+ * @param config the config
+ * @param canvas the canvas
+ * @param canvasSize the canvas size
+ * @param dataSize the data size
+ * @return the rendered layout
+ */
+ private RenderedLayout getRenderedLayout(JHCConfiguration config, Canvas, ?, ?> canvas, Dimension canvasSize, Dimension dataSize) {
+
+ // Text Layout
+ int postfixHeight = canvas.getExtents().height;
+ int textOffset = getTextOffset();
+ int minimalTextWidth = canvas.getExtents().width;
+ int minimalTextHeight = canvas.getExtents().height;
+ int labelOffsetTemp = 2 * textOffset + postfixHeight;
+
+ // Size of heatmap
+ int x = getLeftOffset() + labelOffsetTemp;
+ int y = getTopOffset();
+ int width = canvasSize.width - x - getCenterOffset() - getRightOffset() - getLegendWidth();
+ int height = canvasSize.height - y - getBottomOffset() - labelOffsetTemp;
+
+ if (width <= 0 || height <= 0) {
+
+ // Return
+ return new RenderedLayout(this, x, y, 0, 0, 0, 0, textOffset, 0, 0, false, false, false, 0, false, 0);
+ }
+
+ // Compute heatmap size in pixels
+ Dimension maxSize = config.getMaximalSize();
+ int heatWidth = dataSize.width;
+ int heatHeight = dataSize.height;
+ if (maxSize != null && heatWidth > maxSize.width) heatWidth = maxSize.width;
+ if (maxSize != null && heatHeight > maxSize.height) heatHeight = maxSize.height;
+ if (heatWidth > width) heatWidth = width;
+ if (heatHeight > height) heatHeight = height;
+
+ // Labels
+ boolean drawXTicks = true;
+ boolean drawYTicks = true;
+
+ // Show both ticks
+ if (isLayoutCanShowBothTicks(width, height, heatWidth, heatHeight,
+ minimalTextHeight, minimalTextWidth, postfixHeight, textOffset)) {
+
+ if (this.isXTickRotate() && this.isYTickRotate()) {
+ width -= this.getYTickSpace();
+ x+= this.getYTickSpace();
+
+ height -= this.getXTickSpace();
+ } else if (!this.isXTickRotate() && this.isYTickRotate()) {
+ width -= this.getYTickSpace();
+ x += this.getYTickSpace();
+
+ height -= postfixHeight + textOffset;
+ } else if (this.isXTickRotate() && !this.isYTickRotate()) {
+ width -= postfixHeight + textOffset;
+ x+= postfixHeight + textOffset;
+
+ height -= this.getXTickSpace();
+ } else if (!this.isXTickRotate() && !this.isYTickRotate()) {
+ width -= postfixHeight + textOffset;
+ x+= postfixHeight + textOffset;
+
+ height -= postfixHeight + textOffset;
+ }
+
+ drawXTicks = true;
+ drawYTicks = true;
+
+ // Show y ticks
+ } else if (isLayoutCanShowYTicks(width, height, heatWidth, heatHeight,
+ minimalTextHeight, minimalTextWidth, postfixHeight, textOffset)) {
+
+ if (this.isYTickRotate()) {
+ width -= this.getYTickSpace();
+ x += this.getYTickSpace();
+
+ } else if (!this.isYTickRotate()) {
+ width -= postfixHeight + textOffset;
+ x += postfixHeight + textOffset;
+ }
+
+ drawXTicks = false;
+ drawYTicks = true;
+
+ // Show x ticks
+ } else if (isLayoutCanShowXTicks(width, height, heatWidth, heatHeight,
+ minimalTextHeight, minimalTextWidth, postfixHeight, textOffset)) {
+
+ if (this.isXTickRotate()) {
+ height -= this.getXTickSpace();
+
+ } else if (!this.isXTickRotate()) {
+ height -= postfixHeight + textOffset;
+ }
+
+ drawXTicks = true;
+ drawYTicks = false;
+
+ // Show no ticks
+ } else {
+ drawXTicks = false;
+ drawYTicks = false;
+ }
+
+ // Ticks
+ double xTickOffset = (double) width / (double) heatWidth;
+ double yTickOffset = (double) height / (double) heatHeight;
+
+ // Return
+ return new RenderedLayout(this, x, y, width, height, heatWidth, heatHeight, textOffset, xTickOffset, yTickOffset, drawXTicks, drawYTicks, isXTickRotate(), getXTickSpace(), isYTickRotate(), getYTickSpace());
+ }
+
+ /**
+ * Layouting
+ * @param width
+ * @param height
+ * @param heatWidth
+ * @param heatHeight
+ * @param minimalTextHeight
+ * @param minimalTextWidth
+ * @param postfixHeight
+ * @param textOffset
+ * @return
+ */
+ private boolean isLayoutCanShowBothTicks(double width, double height, double heatWidth, double heatHeight,
+ int minimalTextHeight, int minimalTextWidth, int postfixHeight, int textOffset) {
+
+ if (this.isXTickRotate() && this.isYTickRotate()) {
+
+ width -= this.getYTickSpace();
+ height -= this.getXTickSpace();
+
+ if (width < MINIMAL_HEATMAP_SIZE || height < MINIMAL_HEATMAP_SIZE) {
+ return false;
+ }
+
+ if (height / heatHeight >= minimalTextHeight &&
+ width / heatWidth >= minimalTextHeight) {
+ return true;
+ }
+
+ } else if (!this.isXTickRotate() && this.isYTickRotate()) {
+
+ width -= this.getYTickSpace();
+ height -= postfixHeight + textOffset;
+
+ if (width < MINIMAL_HEATMAP_SIZE || height < MINIMAL_HEATMAP_SIZE) {
+ return false;
+ }
+
+ if (height / heatHeight >= minimalTextHeight &&
+ width / heatWidth >= minimalTextWidth) {
+ return true;
+ }
+
+ } else if (this.isXTickRotate() && !this.isYTickRotate()) {
+
+ width -= postfixHeight + textOffset;
+ height -= this.getXTickSpace();
+
+ if (width < MINIMAL_HEATMAP_SIZE || height < MINIMAL_HEATMAP_SIZE) {
+ return false;
+ }
+
+ if (height / heatHeight >= minimalTextWidth &&
+ width / heatWidth >= minimalTextHeight) {
+ return true;
+ }
+
+ } else if (!this.isXTickRotate() && !this.isYTickRotate()) {
+
+ width -= postfixHeight + textOffset;
+ height -= postfixHeight + textOffset;
+
+ if (width < MINIMAL_HEATMAP_SIZE || height < MINIMAL_HEATMAP_SIZE) {
+ return false;
+ }
+
+ if (height / heatHeight >= minimalTextWidth &&
+ width / heatWidth >= minimalTextWidth) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Layouting
+ * @param width
+ * @param height
+ * @param heatWidth
+ * @param heatHeight
+ * @param minimalTextHeight
+ * @param minimalTextWidth
+ * @param postfixHeight
+ * @param textOffset
+ * @return
+ */
+ private boolean isLayoutCanShowXTicks(double width, double height, double heatWidth, double heatHeight,
+ int minimalTextHeight, int minimalTextWidth, int postfixHeight, int textOffset) {
+
+ if (this.isXTickRotate()) {
+
+ height -= this.getXTickSpace();
+
+ if (width < MINIMAL_HEATMAP_SIZE || height < MINIMAL_HEATMAP_SIZE) {
+ return false;
+ }
+
+ if (width / heatWidth >= minimalTextHeight) {
+ return true;
+ }
+
+ } else if (!this.isXTickRotate()) {
+
+ height -= postfixHeight + textOffset;
+
+ if (width < MINIMAL_HEATMAP_SIZE || height < MINIMAL_HEATMAP_SIZE) {
+ return false;
+ }
+
+ if (width / heatWidth >= minimalTextWidth) {
+ return true;
+ }
+
+ }
+ return false;
+ }
+
+ /**
+ * Layouting
+ * @param width
+ * @param height
+ * @param heatWidth
+ * @param heatHeight
+ * @param minimalTextHeight
+ * @param minimalTextWidth
+ * @param postfixHeight
+ * @param textOffset
+ * @return
+ */
+ private boolean isLayoutCanShowYTicks(double width, double height, double heatWidth, double heatHeight,
+ int minimalTextHeight, int minimalTextWidth, int postfixHeight, int textOffset) {
+
+ if (this.isYTickRotate()) {
+
+ width -= this.getYTickSpace();
+
+ if (width < MINIMAL_HEATMAP_SIZE || height < MINIMAL_HEATMAP_SIZE) {
+ return false;
+ }
+
+ if (height / heatHeight >= minimalTextHeight) {
+ return true;
+ }
+
+ } else if (!this.isYTickRotate()) {
+
+ width -= postfixHeight + textOffset;
+
+ if (width < MINIMAL_HEATMAP_SIZE || height < MINIMAL_HEATMAP_SIZE) {
+ return false;
+ }
+
+ if (height / heatHeight >= minimalTextWidth) {
+ return true;
+ }
+
+ }
+ return false;
+ }
+
+ /**
+ * Gets the bottom offset.
+ *
+ * @return the bottom offset
+ */
+ protected int getBottomOffset() {
+ return bottomOffset;
+ }
+
+ /**
+ * Gets the center offset.
+ *
+ * @return the center offset
+ */
+ protected int getCenterOffset() {
+ return centerOffset;
+ }
+
+ /**
+ * Gets the large tick length.
+ *
+ * @return the large tick length
+ */
+ protected int getLargeTickLength() {
+ return largeTickLength;
+ }
+
+ /**
+ * Gets the left offset.
+ *
+ * @return the left offset
+ */
+ protected int getLeftOffset() {
+ return leftOffset;
+ }
+
+ /**
+ * Gets the legend width.
+ *
+ * @return the legend width
+ */
+ protected int getLegendWidth() {
+ return legendWidth;
+ }
+
+ /**
+ * Gets the right offset.
+ *
+ * @return the right offset
+ */
+ protected int getRightOffset() {
+ return rightOffset;
+ }
+
+ /**
+ * Gets the small tick length.
+ *
+ * @return the small tick length
+ */
+ protected int getSmallTickLength() {
+ return smallTickLength;
+ }
+
+ /**
+ * Gets the text offset.
+ *
+ * @return the text offset
+ */
+ protected int getTextOffset() {
+ return textOffset;
+ }
+
+ /**
+ * Gets the top offset.
+ *
+ * @return the top offset
+ */
+ protected int getTopOffset() {
+ return topOffset;
+ }
+
+ /**
+ * Gets the x tick space.
+ *
+ * @return the x tick space
+ */
+ protected int getXTickSpace() {
+ return xTickSpace;
+ }
+
+ /**
+ * Gets the y tick space.
+ *
+ * @return the y tick space
+ */
+ protected int getYTickSpace() {
+ return yTickSpace;
+ }
+
+ /**
+ * Checks if is x tick rotate.
+ *
+ * @return true, if is x tick rotate
+ */
+ protected boolean isXTickRotate() {
+ return xTickRotate;
+ }
+
+ /**
+ * Checks if is y tick rotate.
+ *
+ * @return true, if is y tick rotate
+ */
+ protected boolean isYTickRotate() {
+ return yTickRotate;
+ }
+}
diff --git a/src/main/de/linearbits/jhc/JHCScale.java b/src/main/de/linearbits/jhc/JHCScale.java
new file mode 100644
index 0000000..6842923
--- /dev/null
+++ b/src/main/de/linearbits/jhc/JHCScale.java
@@ -0,0 +1,538 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import java.text.DateFormat;
+import java.text.DecimalFormat;
+
+/**
+ * This class provides an abstract type for scales
+ *
+ * @author Fabian Prasser
+ *
+ * @param the generic type
+ */
+public abstract class JHCScale {
+
+ /**
+ * Adjust.
+ *
+ * @param length the length
+ * @return the scale
+ */
+ protected abstract JHCScale adjust(int length);
+
+ /**
+ * Check.
+ *
+ * @param length the length
+ */
+ protected abstract void check(int length);
+
+ /**
+ * Gets the label at.
+ *
+ * @param index the index
+ * @return the label at
+ */
+ protected abstract java.lang.String getLabelAt(int index);
+
+ /**
+ * This class implements a data/time scale
+ *
+ * @author Fabian Prasser
+ */
+ public static class Date extends JHCScale {
+
+ /** The format. */
+ private final DateFormat format;
+
+ /** The from. */
+ private final java.util.Date from;
+
+ /** The length. */
+ private final int length;
+
+ /** The to. */
+ private final java.util.Date to;
+
+ /**
+ * Instantiates a new scale date.
+ *
+ * @param from the from
+ * @param to the to
+ */
+ public Date(java.util.Date from, java.util.Date to) {
+ this(from, to, null);
+ }
+
+ /**
+ * Instantiates a new scale date.
+ *
+ * @param from the from
+ * @param to the to
+ * @param format the format
+ */
+ public Date(java.util.Date from, java.util.Date to, DateFormat format) {
+ this.from = from;
+ this.to = to;
+ this.length = 1;
+ this.format = format;
+
+ if (from.getTime() > to.getTime()) {
+ throw new IllegalArgumentException("Lower bound must be <= upper bound");
+ }
+ }
+
+ /**
+ * Instantiates a new scale date.
+ *
+ * @param format the format
+ * @param from the from
+ * @param to the to
+ * @param length the length
+ */
+ private Date(DateFormat format, java.util.Date from, java.util.Date to, int length) {
+ this.from = from;
+ this.to = to;
+ this.length = length;
+ this.format = format;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Scale#adjust(int)
+ */
+ @Override
+ protected JHCScale adjust(int length) {
+ return new Date(format, from, to, length);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Scale#check(int)
+ */
+ @Override
+ protected void check(int length) {
+
+ long from = this.from.getTime();
+ long to = this.to.getTime();
+
+ if (to - from + 1 < length) {
+ throw new IllegalArgumentException("Scale does not provide enough ticks for data of given length");
+ }
+ }
+
+ /**
+ * Gets the from.
+ *
+ * @return the from
+ */
+ protected java.util.Date getFrom() {
+ return from;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Scale#getLabelAt(int)
+ */
+ @Override
+ protected java.lang.String getLabelAt(int index) {
+ if (index >= length) {
+ throw new IllegalArgumentException("Label index (" + index + ") out of range [0, " + length + "[");
+ } else {
+ double offset = (double) (to.getTime() - from.getTime()) / (double) length;
+ long lower = (long) (from.getTime() + index * offset);
+ long upper = (long) (from.getTime() + (index + 1) * offset);
+ if (format == null) {
+ return "[" + new java.util.Date(lower) + ", " + new java.util.Date(upper) + "[";
+ } else {
+ return "[" + format.format(new java.util.Date(lower)) + ", " + format.format(new java.util.Date(upper)) + "[";
+ }
+ }
+ }
+
+ /**
+ * Gets the to.
+ *
+ * @return the to
+ */
+ protected java.util.Date getTo() {
+ return to;
+ }
+ }
+
+ /**
+ * This class implements a decimal scale
+ *
+ * @author Fabian Prasser
+ */
+ public static class Decimal extends JHCScale {
+
+ /** The format. */
+ private final DecimalFormat format;
+
+ /** The from. */
+ private final double from;
+
+ /** The length. */
+ private final int length;
+
+ /** The to. */
+ private final double to;
+
+ /**
+ * Instantiates a new scale decimal.
+ *
+ * @param from the from
+ * @param to the to
+ */
+ public Decimal(double from, double to) {
+ this(from, to, null);
+ }
+
+ /**
+ * Instantiates a new scale decimal.
+ *
+ * @param from the from
+ * @param to the to
+ * @param format the format
+ */
+ public Decimal(double from, double to, DecimalFormat format) {
+ this.from = from;
+ this.to = to;
+ this.length = 1;
+ this.format = format;
+
+ if (from > to) {
+ throw new IllegalArgumentException("Lower bound must be <= upper bound");
+ }
+ }
+
+ /**
+ * Instantiates a new scale decimal.
+ *
+ * @param format the format
+ * @param from the from
+ * @param to the to
+ * @param length the length
+ */
+ private Decimal(DecimalFormat format, double from, double to, int length) {
+ this.from = from;
+ this.to = to;
+ this.length = length;
+ this.format = format;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Scale#adjust(int)
+ */
+ @Override
+ protected JHCScale adjust(int length) {
+ return new Decimal(format, from, to, length);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Scale#check(int)
+ */
+ @Override
+ protected void check(int length) {
+ // Nothing to do
+ }
+
+ /**
+ * Gets the from.
+ *
+ * @return the from
+ */
+ protected double getFrom() {
+ return from;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Scale#getLabelAt(int)
+ */
+ @Override
+ protected java.lang.String getLabelAt(int index) {
+ if (index >= length) {
+ throw new IllegalArgumentException("Label index (" + index + ") out of range [0, " + length + "[");
+ } else {
+ double offset = (to - from) / length;
+ int lower = (int) (from + index * offset);
+ int upper = (int) (from + (index + 1) * offset);
+ if (format == null) {
+ return "[" + lower + ", " + upper + "[";
+ } else {
+ return "[" + format.format(lower) + ", " + format.format(upper) + "[";
+ }
+ }
+ }
+
+ /**
+ * Gets the to.
+ *
+ * @return the to
+ */
+ protected double getTo() {
+ return to;
+ }
+ }
+
+ /**
+ * This class implements an integer scale
+ *
+ * @author Fabian Prasser
+ */
+ public static class Integer extends JHCScale {
+
+ /** The from. */
+ private final int from;
+
+ /** The length. */
+ private final int length;
+
+ /** The to. */
+ private final int to;
+
+ /**
+ * Instantiates a new scale integer.
+ *
+ * @param from the from
+ * @param to the to
+ */
+ public Integer(int from, int to) {
+ this.from = from;
+ this.to = to;
+ this.length = 1;
+
+ if (from > to) {
+ throw new IllegalArgumentException("Lower bound must be <= upper bound");
+ }
+ }
+
+ /**
+ * Instantiates a new scale integer.
+ *
+ * @param from the from
+ * @param to the to
+ * @param length the length
+ */
+ private Integer(int from, int to, int length) {
+ this.from = from;
+ this.to = to;
+ this.length = length;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Scale#adjust(int)
+ */
+ @Override
+ protected Integer adjust(int length) {
+ return new Integer(from, to, length);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Scale#check(int)
+ */
+ @Override
+ protected void check(int length) {
+ if (to - from + 1 < length) {
+ throw new IllegalArgumentException("Scale does not provide enough ticks for data of given length");
+ }
+ }
+
+ /**
+ * Gets the from.
+ *
+ * @return the from
+ */
+ protected int getFrom() {
+ return from;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Scale#getLabelAt(int)
+ */
+ @Override
+ protected java.lang.String getLabelAt(int index) {
+ if (index >= length) {
+ throw new IllegalArgumentException("Label index (" + index + ") out of range [0, " + length + "[");
+ } else {
+ double offset = (double) (to - from) / (double) length;
+ int lower = (int) (from + index * offset);
+ int upper = (int) (from + (index + 1) * offset);
+ return "[" + lower + ", " + upper + "[";
+ }
+ }
+
+ /**
+ * Gets the to.
+ *
+ * @return the to
+ */
+ protected int getTo() {
+ return to;
+ }
+ }
+
+ /**
+ * This class implements a string scale
+ *
+ * @author Fabian Prasser
+ */
+ public static class String extends JHCScale {
+
+ /** The values. */
+ private final java.lang.String[] values;
+
+ /**
+ * Instantiates a new scale string.
+ *
+ * @param values the values
+ */
+ public String(java.lang.String[] values) {
+ this.values = values;
+ if (values == null || values.length == 0) {
+ throw new IllegalArgumentException("Labels must not be empty");
+ }
+ }
+
+ /**
+ * Instantiates a new scale string.
+ *
+ * @param values the values
+ * @param length the length
+ */
+ private String(java.lang.String[] values, int length) {
+ this.values = adjust(length, values);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Scale#adjust(int)
+ */
+ @Override
+ protected JHCScale adjust(int length) {
+ return new String(values, length);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Scale#check(int)
+ */
+ @Override
+ protected void check(int length) {
+ if (length != values.length) {
+ throw new IllegalArgumentException("Number of labels must match data length");
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Scale#getLabelAt(int)
+ */
+ @Override
+ protected java.lang.String getLabelAt(int index) {
+ if (index >= values.length) {
+ throw new IllegalArgumentException("Label index (" + index + ") out of range [0, " + values.length + "[");
+ } else {
+ return values[index];
+ }
+ }
+
+ /**
+ * Gets the values.
+ *
+ * @return the values
+ */
+ protected java.lang.String[] getValues() {
+ return this.values;
+ }
+
+ /**
+ * Adjust.
+ *
+ * @param target the target
+ * @param source the source
+ * @param index the index
+ * @return the int
+ */
+ protected int adjust(int target, int source, int index) {
+ index = (int) Math.round((double) target / (double) source * index);
+ return index < target ? index : target - 1;
+ }
+
+ /**
+ * Adjust.
+ *
+ * @param target the target
+ * @param source the source
+ * @return the string[]
+ */
+ protected java.lang.String[] adjust(int target, java.lang.String[] source) {
+
+ if (source == null) {
+ return null;
+ }
+
+ if (target == source.length) {
+ return source;
+ }
+
+ StringBuilder[] buffers = new StringBuilder[target];
+
+ for (int x = 0; x < target; x++) {
+ buffers[x] = new StringBuilder("{");
+ }
+
+ for (int x = 0; x < source.length; x++) {
+ int index = adjust(target, source.length, x);
+ if (buffers[index].length() == 1) {
+ buffers[index].append(source[x]);
+ } else {
+ buffers[index].append(", ").append(source[x]);
+ }
+ }
+
+ java.lang.String[] result = new java.lang.String[target];
+
+ for (int x = 0; x < target; x++) {
+ result[x] = buffers[x].append("}").toString();
+ }
+ return result;
+ }
+ }
+}
diff --git a/src/main/de/linearbits/jhc/Painter.java b/src/main/de/linearbits/jhc/Painter.java
new file mode 100644
index 0000000..3961d06
--- /dev/null
+++ b/src/main/de/linearbits/jhc/Painter.java
@@ -0,0 +1,323 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+/**
+ * This class paints the heatmap via a generic graphics object
+ *
+ * @author Fabian Prasser
+ *
+ * @param the generic type
+ * @param the generic type
+ * @param the value type
+ */
+class Painter {
+
+ /** The canvas. */
+ private final Canvas canvas;
+
+ /** The gradient. */
+ private JHCGradient gradient;
+
+ /** The insets. */
+ private Rectangle heatmapPosition = null;
+
+ /** The position of the legend. */
+ private Rectangle legendPosition = null;
+
+ /** The legend. */
+ private T legend;
+
+ /**
+ * Instantiates a new painter.
+ *
+ * @param canvas the canvas
+ */
+ protected Painter(Canvas canvas) {
+ this.canvas = canvas;
+ }
+
+ /**
+ * Gets the insets.
+ *
+ * @return the heatmap position
+ */
+ protected Rectangle getHeatmapPosition() {
+ return heatmapPosition;
+ }
+
+ /**
+ * Gets the legend position.
+ *
+ * @return the legend position
+ */
+ protected Rectangle getLegendPosition() {
+ return legendPosition;
+ }
+ /**
+ * Paint.
+ *
+ * @param graphics the graphics
+ * @param heatmap the heatmap
+ * @param size the size
+ */
+ protected void paint(Graphics graphics, RenderedHeatmap heatmap, Dimension size) {
+
+ if (heatmap == null ||
+ heatmap == RenderedHeatmap.NO_DATA ||
+ heatmap == RenderedHeatmap.TOO_SMALL) {
+
+ graphics.init();
+
+ // Clear
+ graphics.setBackground(canvas.getBackground());
+ graphics.drawRectangleFilled(0, 0, size.width, size.height);
+ graphics.setForeground(canvas.getForeground());
+
+ String message = "No data";
+ if (heatmap == RenderedHeatmap.TOO_SMALL) {
+ message = "No space";
+ }
+ graphics.drawStringCentered(message, 0, 0, size.width, size.height);
+
+ // Return
+ return;
+ }
+
+
+ // Layout
+ JHCConfiguration config = heatmap.getConfig();
+ RenderedLayout layout = config.getLayout().getRenderedLayout(config, canvas, size, heatmap);
+
+ graphics.init();
+
+ // Prepare legend
+ if (legend == null || config.getGradient() != gradient) {
+ if (legend != null) {
+ disposeLegend(this.legend);
+ }
+ this.legend = graphics.drawLegend(config.getGradient());
+ this.gradient = config.getGradient();
+ }
+
+ int width = layout.getWidth();
+ int height = layout.getHeight();
+ int x = layout.getX();
+ int y = layout.getY();
+ int textOffset = layout.getTextOffset();
+ double xTickOffset = layout.getxTickOffset();
+ double yTickOffset = layout.getyTickOffset();
+ boolean drawXTicks = layout.isDrawXTicks();
+ boolean drawYTicks = layout.isDrawYTicks();
+ boolean xTicksRotate = layout.isXTicksRotate();
+ boolean yTicksRotate = layout.isYTicksRotate();
+ int xTicksSpace = layout.getXTicksSpace();
+ int yTicksSpace = layout.getYTicksSpace();
+
+ if (width <= 0 || height <= 0) {
+
+ // Clear
+ graphics.setBackground(canvas.getBackground());
+ graphics.drawRectangleFilled(0, 0, size.width, size.height);
+ heatmapPosition = null;
+
+ // Return
+ return;
+ }
+
+ // Offsets and ticks
+ int xAxisLabelOffset = y + height + textOffset;
+ int yAxisLabelOffset = x - textOffset;
+ int smallTickLength = layout.getSmallTickLength();
+ int largeTickLength = layout.getLargeTickLength();
+ xTickOffset = xTickOffset >= 2 ? xTickOffset : 2;
+ yTickOffset = yTickOffset >= 2 ? yTickOffset : 2;
+
+ // Legend
+ int centerOffset = layout.getCenterOffset();
+ int legendWidth = layout.getLegendWidth();
+ double legendTicksOffset = (double) height / (double) gradient.getSteps();
+ legendTicksOffset = legendTicksOffset >= 2 ? legendTicksOffset : 2;
+
+ // Clear
+ graphics.setBackground(canvas.getBackground());
+ graphics.drawRectangleFilled(0, 0, size.width, size.height);
+
+ // Heatmap
+ graphics.disableAntialiasing();
+ graphics.disableInterpolation();
+ graphics.drawImage(heatmap.getImage(), x, y, width, height);
+ graphics.resetAntialiasing();
+ graphics.resetInterpolation();
+
+ // Small X-ticks
+ if (xTickOffset >= 2) {
+ graphics.setForeground(canvas.getGray());
+ double xTickPosition = x;
+ for (int i = 0; i < heatmap.getWidth(); i++) {
+ int xTickPositionAsInt = (int) Math.round(xTickPosition);
+ xTickPositionAsInt = xTickPositionAsInt < x + width ? xTickPositionAsInt : x + width;
+ graphics.drawLine(xTickPositionAsInt, y + height, xTickPositionAsInt, y + height + smallTickLength);
+ graphics.drawLine(xTickPositionAsInt, y, xTickPositionAsInt, y - smallTickLength);
+ xTickPosition += xTickOffset;
+ }
+ }
+
+ // X-tick labels
+ if (drawXTicks) {
+
+ if (!xTicksRotate) {
+ graphics.setForeground(canvas.getForeground());
+ double xTickPosition = x;
+ int xTickWidth = (int) xTickOffset;
+ for (int i = 0; i < heatmap.getWidth(); i++) {
+ int xTickPositionAsInt = (int) Math.round(xTickPosition);
+ graphics.drawStringBelowHorizontallyCentered(heatmap.getXLabel(i), xTickPositionAsInt, y + height + textOffset, xTickWidth);
+ xTickPosition += xTickOffset;
+ }
+ graphics.resetClipping();
+ xAxisLabelOffset += textOffset + graphics.getTextHeight(config.getXLabel());
+ } else {
+
+ graphics.setRotation(-90);
+ double xTickPosition = x;
+ graphics.setForeground(canvas.getForeground());
+ int xTickWidth = (int) xTickOffset;
+ for (int i = 0; i < heatmap.getWidth(); i++) {
+
+ int xTickPositionAsInt = (int) Math.round(xTickPosition);
+ String label = heatmap.getXLabel(i);
+ int offset = Math.min(xTicksSpace, graphics.getTextWidth(label));
+ graphics.drawStringVerticallyCenteredLeftAligned(label, -(y + height + textOffset + offset), xTickPositionAsInt, xTicksSpace, xTickWidth);
+ xTickPosition += xTickOffset;
+ }
+ graphics.resetRotation();
+ graphics.resetClipping();
+ xAxisLabelOffset += xTicksSpace;
+ }
+ }
+
+ // Small Y-ticks
+ if (yTickOffset >= 2) {
+ double yTickPosition = y + height;
+ graphics.setForeground(canvas.getGray());
+ for (int i = 0; i < heatmap.getHeight(); i++) {
+ int yTickPositionAsInt = (int) Math.round(yTickPosition);
+ yTickPositionAsInt = yTickPositionAsInt >= y ? yTickPositionAsInt : y;
+ graphics.drawLine(x, yTickPositionAsInt, x - smallTickLength, yTickPositionAsInt);
+ graphics.drawLine(x + width, yTickPositionAsInt, x + width + smallTickLength, yTickPositionAsInt);
+ yTickPosition -= yTickOffset;
+ }
+ }
+
+ // Y-tick labels
+ if (drawYTicks) {
+
+ if (!yTicksRotate) {
+ graphics.setRotation(-90);
+ double yTickPosition = y + height;
+ graphics.setForeground(canvas.getForeground());
+ int yTickWidth = (int) yTickOffset;
+ for (int i = 0; i < heatmap.getHeight(); i++) {
+ int yTickPositionAsInt = (int) Math.round(yTickPosition);
+ graphics.drawStringAboveHorizontallyCentered(heatmap.getYLabel(i), -yTickPositionAsInt, x - textOffset, yTickWidth);
+ yTickPosition -= yTickOffset;
+ }
+ graphics.resetRotation();
+ graphics.resetClipping();
+ yAxisLabelOffset -= textOffset + graphics.getTextHeight(config.getYLabel());
+ } else {
+
+ double yTickPosition = y + height - yTickOffset;
+ int yTickX = x - textOffset - yTicksSpace;
+ graphics.setForeground(canvas.getForeground());
+ for (int i = 0; i < heatmap.getHeight(); i++) {
+ int yTickPositionAsInt = (int) Math.round(yTickPosition);
+ String label = heatmap.getYLabel(i);
+ int offset = yTicksSpace - Math.min(yTicksSpace, graphics.getTextWidth(label));
+ graphics.drawStringVerticallyCenteredLeftAligned(heatmap.getYLabel(i), yTickX + offset, yTickPositionAsInt, yTicksSpace, (int) yTickOffset);
+ yTickPosition -= yTickOffset;
+ }
+ graphics.resetClipping();
+ yAxisLabelOffset -= yTicksSpace;
+ }
+ }
+
+ // Large ticks
+ graphics.setForeground(canvas.getBlack());
+ graphics.drawLine(x, y - largeTickLength, x, y + height + largeTickLength);
+ graphics.drawLine(x + width, y - largeTickLength, x + width, y + height + largeTickLength);
+ graphics.drawLine(x - largeTickLength, y, x + width + largeTickLength, y);
+ graphics.drawLine(x - largeTickLength, y + height, x + width + largeTickLength, y + height);
+
+ // Legend ticks
+ int legendX = x + width + centerOffset;
+ double legendTicksPosition = y;
+ graphics.setForeground(canvas.getGray());
+ for (int i = 0; i < gradient.getSteps(); i++) {
+ int position = (int) Math.round(legendTicksPosition);
+ position = position <= y + height ? position : y + height;
+ graphics.drawLine(legendX - smallTickLength, position, legendX + legendWidth + smallTickLength, position);
+ legendTicksPosition += legendTicksOffset;
+ }
+
+ // Legend
+ graphics.enableAntialiasing();
+ graphics.enableInterpolation();
+
+ graphics.drawImage(legend, legendX, y, legendWidth, height);
+ graphics.resetAntialiasing();
+ graphics.resetInterpolation();
+
+ // Legend border
+ graphics.setForeground(canvas.getBlack());
+ graphics.drawLine(legendX, y - largeTickLength, legendX, y + height + largeTickLength);
+ graphics.drawLine(legendX + legendWidth, y - largeTickLength, legendX + legendWidth, y + height + largeTickLength);
+ graphics.drawLine(legendX - largeTickLength, y, legendX + legendWidth + largeTickLength, y);
+ graphics.drawLine(legendX - largeTickLength, y + height, legendX + legendWidth + largeTickLength, y + height);
+
+ // Legend labels
+ graphics.setForeground(canvas.getForeground());
+ graphics.drawStringAboveHorizontallyCentered("Max", legendX, y - textOffset, legendWidth);
+ graphics.drawStringBelowHorizontallyCentered("Min", legendX + 1, y + height + textOffset, legendWidth);
+ graphics.resetClipping();
+
+ // X-axis label
+ graphics.drawStringBelowHorizontallyCentered(config.getXLabel(), x, xAxisLabelOffset, width);
+
+ // Y-axis label
+ graphics.setRotation(-90);
+ graphics.drawStringAboveHorizontallyCentered(config.getYLabel(), -(y + height), yAxisLabelOffset, height);
+ graphics.resetRotation();
+ graphics.resetClipping();
+
+ // Store insets
+ heatmapPosition = new Rectangle(x, y, width, height);
+ legendPosition = new Rectangle(legendX, y, legendWidth, height);
+ }
+
+ protected void disposeLegend(T legend) {
+ // Overwritten by SWT version
+ }
+
+ protected void dispose(){
+ if (legend != null) {
+ disposeLegend(legend);
+ }
+ }
+}
diff --git a/src/main/de/linearbits/jhc/Pixels.java b/src/main/de/linearbits/jhc/Pixels.java
new file mode 100644
index 0000000..d3335b5
--- /dev/null
+++ b/src/main/de/linearbits/jhc/Pixels.java
@@ -0,0 +1,56 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+/**
+ * This interface describes an array of pixels
+ *
+ * @author Fabian Prasser
+ *
+ * @param the generic type
+ */
+interface Pixels {
+
+ /**
+ * Gets the image.
+ *
+ * @return the image
+ */
+ public abstract T getImage();
+
+ /**
+ * Gets the size.
+ *
+ * @return the size
+ */
+ public abstract Dimension getSize();
+
+ /**
+ * Sets the.
+ *
+ * @param x the x
+ * @param y the y
+ * @param val the val
+ */
+ public abstract void set(int x, int y, int val);
+
+ /**
+ * Update.
+ */
+ public abstract void update();
+}
diff --git a/src/main/de/linearbits/jhc/ProviderCharArray.java b/src/main/de/linearbits/jhc/ProviderCharArray.java
new file mode 100644
index 0000000..9ebb6b1
--- /dev/null
+++ b/src/main/de/linearbits/jhc/ProviderCharArray.java
@@ -0,0 +1,149 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+/**
+ * This class implements a data provider based on char arrays
+ *
+ * @author Fabian Prasser
+ */
+class ProviderCharArray implements JHCDataProvider{
+
+ /** The orientation*/
+ private final Orientation orientation;
+ /** The array*/
+ private final char[][] array;
+ /** Scale*/
+ private final JHCScale> xScale;
+ /** Scale*/
+ private final JHCScale> yScale;
+
+ /**
+ * Creates a new instance
+ * @param array
+ * @param orientation
+ */
+ protected ProviderCharArray(char[][] array, Orientation orientation){
+ this(array, orientation, null, null);
+ }
+
+ /**
+ * Creates a new instance
+ * @param array
+ * @param orientation
+ * @param xScale
+ * @param yScale
+ */
+ protected ProviderCharArray(char[][] array, Orientation orientation, JHCScale> xScale, JHCScale> yScale){
+
+ if (array == null || array.length == 0 || array[0] == null || array[0].length ==0){
+ throw new IllegalArgumentException("Array must not be empty");
+ }
+
+ int length = -1;
+ for (char[] row : array) {
+ if (row == null || row.length == 0){
+ throw new IllegalArgumentException("Array must not be empty");
+ }
+ if (length == -1) {
+ length = row.length;
+ } else if (length != row.length) {
+ throw new IllegalArgumentException("All rows must have equal length");
+ }
+ }
+
+ if (orientation == null) {
+ throw new IllegalArgumentException("Orientation must not be null");
+ }
+
+ this.xScale = xScale;
+ this.yScale = yScale;
+ this.array = array;
+ this.orientation = orientation;
+ }
+
+ /**
+ * Returns the.
+ *
+ * @param x the x
+ * @param y the y
+ * @return the double
+ */
+ public double get(int x, int y) {
+ switch (orientation){
+ case ROW:
+ return array[y][x];
+ case COLUMN:
+ return array[x][y];
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the height.
+ *
+ * @return the height
+ */
+ public int getHeight() {
+ switch (orientation){
+ case ROW:
+ return array.length;
+ case COLUMN:
+ return array[0].length;
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the width.
+ *
+ * @return the width
+ */
+ public int getWidth() {
+ switch (orientation){
+ case ROW:
+ return array[0].length;
+ case COLUMN:
+ return array.length;
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the x labels.
+ *
+ * @return the x scale
+ */
+ public JHCScale> getXScale() {
+ return xScale;
+ }
+
+ /**
+ * Gets the y labels.
+ *
+ * @return the y scale
+ */
+ public JHCScale> getYScale() {
+ return yScale;
+ }
+
+ @Override
+ public Orientation getOrientation() {
+ return orientation;
+ }
+}
diff --git a/src/main/de/linearbits/jhc/ProviderData.java b/src/main/de/linearbits/jhc/ProviderData.java
new file mode 100644
index 0000000..4f8e257
--- /dev/null
+++ b/src/main/de/linearbits/jhc/ProviderData.java
@@ -0,0 +1,494 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import java.util.Iterator;
+
+import de.linearbits.jhc.JHCDataProvider.Orientation;
+import de.linearbits.jhc.JHCHeatmap.Point;
+
+/**
+ * This class implements JHC data based on a given data provider
+ *
+ * @author Fabian Prasser
+ */
+class ProviderData extends JHCData {
+
+ /**
+ * The Class HeatPointProvider.
+ */
+ protected class ProviderDataPoint implements Point {
+
+ /** The x */
+ protected int x;
+
+ /** The y */
+ protected int y;
+
+ /** The value*/
+ protected double value;
+
+ @Override
+ public double getValue() {
+ return value;
+ }
+
+ @Override
+ public int getX() {
+ return x;
+ }
+
+ @Override
+ public int getY() {
+ return y;
+ }
+ }
+
+ /** The x labels. */
+ protected final JHCScale> xScale;
+
+ /** The y labels. */
+ protected final JHCScale> yScale;
+
+ /** The orientation*/
+ private final Orientation orientation;
+
+ /** The provider*/
+ private final JHCDataProvider provider;
+
+ /** The min*/
+ private double min = Double.MAX_VALUE;
+
+ /** The min*/
+ private double max = Double.MIN_VALUE;
+
+ /**
+ * Instantiates a new data provider.
+ *
+ * @param provider the provider
+ */
+ protected ProviderData(JHCDataProvider provider) {
+
+ // Check
+ if (provider == null) {
+ throw new IllegalArgumentException("Data must not be null");
+ }
+ if (provider.getWidth() == 0 || provider.getHeight() == 0) {
+ throw new IllegalArgumentException("Data must not be empty");
+ }
+
+ // Init
+ this.xScale = provider.getXScale();
+ this.yScale = provider.getYScale();
+ this.orientation = provider.getOrientation();
+ this.provider = provider;
+
+ if (xScale != null) {
+ xScale.check(provider.getWidth());
+ }
+ if (yScale != null) {
+ yScale.check(provider.getHeight());
+ }
+ }
+
+ /**
+ * Check if all required values have been computed
+ */
+ private void ensureMinMaxAvailable() {
+ if (min==Double.MAX_VALUE && max==Double.MIN_VALUE) {
+
+ switch (orientation){
+ case COLUMN:
+ for (int x = 0; x < provider.getWidth(); x++) {
+ for (int y = 0; y < provider.getHeight(); y++) {
+ double value = provider.get(x, y);
+ min = Math.min(min, value);
+ max = Math.max(max, value);
+ }
+ }
+ break;
+ case ROW:
+ for (int y = 0; y < provider.getHeight(); y++) {
+ for (int x = 0; x < provider.getWidth(); x++) {
+ double value = provider.get(x, y);
+ min = Math.min(min, value);
+ max = Math.max(max, value);
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Data#getHeat(int, int)
+ */
+ @Override
+ public JHCHeatmap getHeatmap(int width, int height) {
+
+ int originalWidth = provider.getWidth();
+ int originalHeight = provider.getHeight();
+
+ // Check bounds
+ if (width > originalWidth) width = originalWidth;
+ if (height > originalHeight) height = originalHeight;
+
+ // Scale the scale
+ JHCScale> xScale = this.xScale != null ? this.xScale.adjust(width) : null;
+ JHCScale> yScale = this.yScale != null ? this.yScale.adjust(height) : null;
+
+ // Check if no need to scale
+ if (width == originalWidth && height == originalHeight) {
+ ensureMinMaxAvailable();
+ ProviderDataPoint point = new ProviderDataPoint();
+ return getHeatmap(point, provider, min, max, xScale, yScale);
+ }
+
+ // Create maps
+ int[] xMap = createMap(width, originalWidth);
+ int[] yMap = createMap(height, originalHeight);
+
+ // Create entry set
+ double[][] frequencies = new double[height][width];
+ int[][] counts = new int[height][width];
+ for (int y = 0; y < height; y++) {
+ frequencies[y] = new double[width];
+ counts[y] = new int[width];
+ }
+
+ if (min == Double.MAX_VALUE && max == Double.MIN_VALUE) {
+
+ switch (orientation){
+ case COLUMN:
+ for (int x = 0; x < provider.getWidth(); x++) {
+ int xIndex = xMap[x];
+ for (int y = 0; y < provider.getHeight(); y++) {
+ int yIndex = yMap[y];
+ double value = provider.get(x,y);
+ frequencies[yIndex][xIndex] += value;
+ counts[yIndex][xIndex]++;
+ max = Math.max(max, value);
+ min = Math.min(min, value);
+ }
+ }
+ break;
+ case ROW:
+ for (int y = 0; y < provider.getHeight(); y++) {
+ int yIndex = yMap[y];
+ for (int x = 0; x < provider.getWidth(); x++) {
+ int xIndex = xMap[x];
+ double value = provider.get(x,y);
+ frequencies[yIndex][xIndex] += value;
+ counts[yIndex][xIndex]++;
+ max = Math.max(max, value);
+ min = Math.min(min, value);
+ }
+ }
+ break;
+ }
+ } else {
+
+ switch (orientation){
+ case COLUMN:
+ for (int x = 0; x < provider.getWidth(); x++) {
+ int xIndex = xMap[x];
+ for (int y = 0; y < provider.getHeight(); y++) {
+ int yIndex = yMap[y];
+ frequencies[yIndex][xIndex] += provider.get(x,y);
+ counts[yIndex][xIndex]++;
+ }
+ }
+ break;
+ case ROW:
+ for (int y = 0; y < provider.getHeight(); y++) {
+ int yIndex = yMap[y];
+ for (int x = 0; x < provider.getWidth(); x++) {
+ int xIndex = xMap[x];
+ frequencies[yIndex][xIndex] += provider.get(x,y);
+ counts[yIndex][xIndex]++;
+ }
+ }
+ break;
+ }
+
+ }
+
+ // Aggregate
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ frequencies[y][x] = frequencies[y][x] / counts[y][x];
+ }
+ }
+
+ // Return
+ ProviderDataPoint point = new ProviderDataPoint();
+ return getHeatmap(point, width, height, originalWidth, originalHeight, frequencies, min, max, xScale, yScale);
+ }
+
+ @Override
+ public int getWidth() {
+ return provider.getWidth();
+ }
+
+ @Override
+ public int getHeight() {
+ return provider.getHeight();
+ }
+
+ /**
+ * Creates the index.
+ *
+ * @param target the target
+ * @param source the source
+ * @param index the index
+ * @return the int
+ */
+ private int createIndex(int target, int source, int index) {
+ index = (int) Math.round((double) target / (double) source * index);
+ return index < target ? index : target - 1;
+ }
+
+ /**
+ * Creates the map.
+ *
+ * @param target the target
+ * @param source the source
+ * @return the int[]
+ */
+ protected int[] createMap(int target, int source) {
+ int[] result = new int[source];
+ if (source != target) {
+ for (int x = 0; x < source; x++) {
+ result[x] = createIndex(target, source, x);
+ }
+ } else {
+ for (int x = 0; x < source; x++) {
+ result[x] = x;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Gets the heat.
+ *
+ * @param point the point
+ * @param width the width
+ * @param height the height
+ * @param originalWidth the original width
+ * @param originalHeight the original height
+ * @param max the max
+ * @param xScale the x scale
+ * @param yScale the y scale
+ * @return the heat
+ */
+ protected JHCHeatmap getHeatmap(final ProviderDataPoint point, final int width, final int height, final int originalWidth, final int originalHeight, final double[][] data, final double min, final double max, final JHCScale> xScale, final JHCScale> yScale) {
+
+ // Create iterator
+ final Iterator iterator = new Iterator() {
+
+ int x = 0;
+ int y = 0;
+
+ @Override
+ public boolean hasNext() {
+ return y < height;
+ }
+
+ @Override
+ public Point next() {
+
+ point.x = x;
+ point.y = y;
+ point.value = data[y][x];
+
+ x++;
+ if (x == width) {
+ x = 0;
+ y++;
+ }
+
+ return point;
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+
+ // Return heat
+ return new JHCHeatmap() {
+
+ @Override
+ public int getHeight() {
+ return height;
+ }
+
+ @Override
+ public double getMin() {
+ return min;
+ }
+
+ @Override
+ public double getMax() {
+ return max;
+ }
+
+ @Override
+ public int getWidth() {
+ return width;
+ }
+
+ @Override
+ public String getXLabel(int index) {
+ if (xScale == null) {
+ if (originalWidth != width) {
+ int lower = (int) ((double) index / (double) width * originalWidth);
+ int upper = (int) ((double) (index + 1) / (double) width * originalWidth);
+ if (upper > originalWidth) upper = originalWidth;
+ return "[" + lower + ", " + upper + "[";
+
+ } else {
+ return String.valueOf(index);
+ }
+ } else return xScale.getLabelAt(index);
+ }
+
+ @Override
+ public String getYLabel(int index) {
+ if (yScale == null) {
+ if (originalHeight != height) {
+ int lower = (int) ((double) index / (double) height * originalHeight);
+ int upper = (int) ((double) (index + 1) / (double) height * originalHeight);
+ if (upper > originalHeight) upper = originalHeight;
+ return "[" + lower + ", " + upper + "[";
+
+ } else {
+ return String.valueOf(index);
+ }
+ } else return yScale.getLabelAt(index);
+ }
+
+ @Override
+ public Iterator iterator() {
+ return iterator;
+ }
+ };
+ }
+
+ /**
+ * Gets the heat for an unscaled version of the provider's data
+ *
+ * @param point the point
+ * @param provider the provider
+ * @param min the min
+ * @param max the max
+ * @param xScale the x scale
+ * @param yScale the y scale
+ * @return the heat
+ */
+ protected JHCHeatmap getHeatmap(final ProviderDataPoint point, final JHCDataProvider provider, final double min, final double max, final JHCScale> xScale, final JHCScale> yScale) {
+
+
+ final int width = provider.getWidth();
+ final int height = provider.getHeight();
+
+ // Create iterator
+ final Iterator iterator = new Iterator() {
+
+ int x = 0;
+ int y = 0;
+
+ @Override
+ public boolean hasNext() {
+ return y < height;
+ }
+
+ @Override
+ public Point next() {
+
+ point.x = x;
+ point.y = y;
+ point.value = provider.get(x, y);
+
+ x++;
+ if (x == width) {
+ x = 0;
+ y++;
+ }
+
+ return point;
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+
+ // Return heat
+ return new JHCHeatmap() {
+
+ @Override
+ public int getHeight() {
+ return height;
+ }
+
+ @Override
+ public double getMin() {
+ return min;
+ }
+
+ @Override
+ public double getMax() {
+ return max;
+ }
+
+ @Override
+ public int getWidth() {
+ return width;
+ }
+
+ @Override
+ public String getXLabel(int index) {
+ if (xScale == null) {
+ return String.valueOf(index);
+ } else {
+ return xScale.getLabelAt(index);
+ }
+ }
+
+ @Override
+ public String getYLabel(int index) {
+ if (yScale == null) {
+ return String.valueOf(index);
+ } else {
+ return yScale.getLabelAt(index);
+ }
+ }
+
+ @Override
+ public Iterator iterator() {
+ return iterator;
+ }
+ };
+ }
+}
diff --git a/src/main/de/linearbits/jhc/ProviderDoubleArray.java b/src/main/de/linearbits/jhc/ProviderDoubleArray.java
new file mode 100644
index 0000000..ca3a822
--- /dev/null
+++ b/src/main/de/linearbits/jhc/ProviderDoubleArray.java
@@ -0,0 +1,158 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+
+/**
+ * This class implements a data provider based on double arrays
+ *
+ * @author Fabian Prasser
+ */
+class ProviderDoubleArray implements JHCDataProvider{
+
+ /** Orientation*/
+ private final Orientation orientation;
+ /** Array*/
+ private final double[][] array;
+ /** Scale*/
+ private final JHCScale> xScale;
+ /** Scale*/
+ private final JHCScale> yScale;
+
+ /**
+ * Creates a new instance
+ * @param array
+ */
+ protected ProviderDoubleArray(double[][] array){
+ this(array, Orientation.ROW, null, null);
+ }
+
+ /**
+ * Creates a new instance
+ * @param array
+ * @param orientation
+ */
+ protected ProviderDoubleArray(double[][] array, Orientation orientation){
+ this(array, orientation, null, null);
+ }
+
+ /**
+ * Creates a new instance
+ * @param array
+ * @param orientation
+ * @param xScale
+ * @param yScale
+ */
+ protected ProviderDoubleArray(double[][] array, Orientation orientation, JHCScale> xScale, JHCScale> yScale){
+
+ if (array == null || array.length == 0 || array[0] == null || array[0].length ==0){
+ throw new IllegalArgumentException("Array must not be empty");
+ }
+
+ int length = -1;
+ for (double[] row : array) {
+ if (row == null || row.length == 0){
+ throw new IllegalArgumentException("Array must not be empty");
+ }
+ if (length == -1) {
+ length = row.length;
+ } else if (length != row.length) {
+ throw new IllegalArgumentException("All rows must have equal length");
+ }
+ }
+
+ if (orientation == null) {
+ throw new IllegalArgumentException("Orientation must not be null");
+ }
+
+ this.xScale = xScale;
+ this.yScale = yScale;
+ this.array = array;
+ this.orientation = orientation;
+ }
+
+ /**
+ * Returns the.
+ *
+ * @param x the x
+ * @param y the y
+ * @return the double
+ */
+ public double get(int x, int y) {
+ switch (orientation){
+ case ROW:
+ return array[y][x];
+ case COLUMN:
+ return array[x][y];
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the height.
+ *
+ * @return the height
+ */
+ public int getHeight() {
+ switch (orientation){
+ case ROW:
+ return array.length;
+ case COLUMN:
+ return array[0].length;
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the width.
+ *
+ * @return the width
+ */
+ public int getWidth() {
+ switch (orientation){
+ case ROW:
+ return array[0].length;
+ case COLUMN:
+ return array.length;
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the x labels.
+ *
+ * @return the x scale
+ */
+ public JHCScale> getXScale() {
+ return xScale;
+ }
+
+ /**
+ * Gets the y labels.
+ *
+ * @return the y scale
+ */
+ public JHCScale> getYScale() {
+ return yScale;
+ }
+
+ @Override
+ public Orientation getOrientation() {
+ return orientation;
+ }
+}
diff --git a/src/main/de/linearbits/jhc/ProviderFloatArray.java b/src/main/de/linearbits/jhc/ProviderFloatArray.java
new file mode 100644
index 0000000..210b3f4
--- /dev/null
+++ b/src/main/de/linearbits/jhc/ProviderFloatArray.java
@@ -0,0 +1,157 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+/**
+ * This class implements a data provider based on float arrays
+ *
+ * @author Fabian Prasser
+ */
+class ProviderFloatArray implements JHCDataProvider{
+
+ /** Orientation*/
+ private final Orientation orientation;
+ /** Array*/
+ private final float[][] array;
+ /** Scale*/
+ private final JHCScale> xScale;
+ /** Scale*/
+ private final JHCScale> yScale;
+
+ /**
+ * Creates a new instance
+ * @param array
+ */
+ protected ProviderFloatArray(float[][] array){
+ this(array, Orientation.ROW, null, null);
+ }
+
+ /**
+ * Creates a new instance
+ * @param array
+ * @param orientation
+ */
+ protected ProviderFloatArray(float[][] array, Orientation orientation){
+ this(array, orientation, null, null);
+ }
+
+ /**
+ * Creates a new instance
+ * @param array
+ * @param orientation
+ * @param xScale
+ * @param yScale
+ */
+ protected ProviderFloatArray(float[][] array, Orientation orientation, JHCScale> xScale, JHCScale> yScale){
+
+ if (array == null || array.length == 0 || array[0] == null || array[0].length ==0){
+ throw new IllegalArgumentException("Array must not be empty");
+ }
+
+ int length = -1;
+ for (float[] row : array) {
+ if (row == null || row.length == 0){
+ throw new IllegalArgumentException("Array must not be empty");
+ }
+ if (length == -1) {
+ length = row.length;
+ } else if (length != row.length) {
+ throw new IllegalArgumentException("All rows must have equal length");
+ }
+ }
+
+ if (orientation == null) {
+ throw new IllegalArgumentException("Orientation must not be null");
+ }
+
+ this.xScale = xScale;
+ this.yScale = yScale;
+ this.array = array;
+ this.orientation = orientation;
+ }
+
+ /**
+ * Returns the.
+ *
+ * @param x the x
+ * @param y the y
+ * @return the double
+ */
+ public double get(int x, int y) {
+ switch (orientation){
+ case ROW:
+ return array[y][x];
+ case COLUMN:
+ return array[x][y];
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the height.
+ *
+ * @return the height
+ */
+ public int getHeight() {
+ switch (orientation){
+ case ROW:
+ return array.length;
+ case COLUMN:
+ return array[0].length;
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the width.
+ *
+ * @return the width
+ */
+ public int getWidth() {
+ switch (orientation){
+ case ROW:
+ return array[0].length;
+ case COLUMN:
+ return array.length;
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the x labels.
+ *
+ * @return the x scale
+ */
+ public JHCScale> getXScale() {
+ return xScale;
+ }
+
+ /**
+ * Gets the y labels.
+ *
+ * @return the y scale
+ */
+ public JHCScale> getYScale() {
+ return yScale;
+ }
+
+ @Override
+ public Orientation getOrientation() {
+ return orientation;
+ }
+}
diff --git a/src/main/de/linearbits/jhc/ProviderIntegerArray.java b/src/main/de/linearbits/jhc/ProviderIntegerArray.java
new file mode 100644
index 0000000..0040be5
--- /dev/null
+++ b/src/main/de/linearbits/jhc/ProviderIntegerArray.java
@@ -0,0 +1,157 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+/**
+ * This class implements a data provider based on integer arrays
+ *
+ * @author Fabian Prasser
+ */
+class ProviderIntegerArray implements JHCDataProvider{
+
+ /** Orientation*/
+ private final Orientation orientation;
+ /** Array*/
+ private final int[][] array;
+ /** Scale*/
+ private final JHCScale> xScale;
+ /** Scale*/
+ private final JHCScale> yScale;
+
+ /**
+ * Creates a new instance
+ * @param array
+ */
+ protected ProviderIntegerArray(int[][] array){
+ this(array, Orientation.ROW, null, null);
+ }
+
+ /**
+ * Creates a new instance
+ * @param array
+ * @param orientation
+ */
+ protected ProviderIntegerArray(int[][] array, Orientation orientation){
+ this(array, orientation, null, null);
+ }
+
+ /**
+ * Creates a new instance
+ * @param array
+ * @param orientation
+ * @param xScale
+ * @param yScale
+ */
+ protected ProviderIntegerArray(int[][] array, Orientation orientation, JHCScale> xScale, JHCScale> yScale){
+
+ if (array == null || array.length == 0 || array[0] == null || array[0].length ==0){
+ throw new IllegalArgumentException("Array must not be empty");
+ }
+
+ int length = -1;
+ for (int[] row : array) {
+ if (row == null || row.length == 0){
+ throw new IllegalArgumentException("Array must not be empty");
+ }
+ if (length == -1) {
+ length = row.length;
+ } else if (length != row.length) {
+ throw new IllegalArgumentException("All rows must have equal length");
+ }
+ }
+
+ if (orientation == null) {
+ throw new IllegalArgumentException("Orientation must not be null");
+ }
+
+ this.xScale = xScale;
+ this.yScale = yScale;
+ this.array = array;
+ this.orientation = orientation;
+ }
+
+ /**
+ * Returns the.
+ *
+ * @param x the x
+ * @param y the y
+ * @return the double
+ */
+ public double get(int x, int y) {
+ switch (orientation){
+ case ROW:
+ return array[y][x];
+ case COLUMN:
+ return array[x][y];
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the height.
+ *
+ * @return the height
+ */
+ public int getHeight() {
+ switch (orientation){
+ case ROW:
+ return array.length;
+ case COLUMN:
+ return array[0].length;
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the width.
+ *
+ * @return the width
+ */
+ public int getWidth() {
+ switch (orientation){
+ case ROW:
+ return array[0].length;
+ case COLUMN:
+ return array.length;
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the x labels.
+ *
+ * @return the x scale
+ */
+ public JHCScale> getXScale() {
+ return xScale;
+ }
+
+ /**
+ * Gets the y labels.
+ *
+ * @return the y scale
+ */
+ public JHCScale> getYScale() {
+ return yScale;
+ }
+
+ @Override
+ public Orientation getOrientation() {
+ return orientation;
+ }
+}
diff --git a/src/main/de/linearbits/jhc/ProviderLongArray.java b/src/main/de/linearbits/jhc/ProviderLongArray.java
new file mode 100644
index 0000000..572441a
--- /dev/null
+++ b/src/main/de/linearbits/jhc/ProviderLongArray.java
@@ -0,0 +1,157 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+/**
+ * This class implements a data provider based on long arrays
+ *
+ * @author Fabian Prasser
+ */
+class ProviderLongArray implements JHCDataProvider{
+
+ /** Orientation*/
+ private final Orientation orientation;
+ /** Array*/
+ private final long[][] array;
+ /** Scale*/
+ private final JHCScale> xScale;
+ /** Scale*/
+ private final JHCScale> yScale;
+
+ /**
+ * Creates a new instance
+ * @param array
+ */
+ protected ProviderLongArray(long[][] array){
+ this(array, Orientation.ROW, null, null);
+ }
+
+ /**
+ * Creates a new instance
+ * @param array
+ * @param orientation
+ */
+ protected ProviderLongArray(long[][] array, Orientation orientation){
+ this(array, orientation, null, null);
+ }
+
+ /**
+ * Creates a new instance
+ * @param array
+ * @param orientation
+ * @param xScale
+ * @param yScale
+ */
+ protected ProviderLongArray(long[][] array, Orientation orientation, JHCScale> xScale, JHCScale> yScale){
+
+ if (array == null || array.length == 0 || array[0] == null || array[0].length ==0){
+ throw new IllegalArgumentException("Array must not be empty");
+ }
+
+ int length = -1;
+ for (long[] row : array) {
+ if (row == null || row.length == 0){
+ throw new IllegalArgumentException("Array must not be empty");
+ }
+ if (length == -1) {
+ length = row.length;
+ } else if (length != row.length) {
+ throw new IllegalArgumentException("All rows must have equal length");
+ }
+ }
+
+ if (orientation == null) {
+ throw new IllegalArgumentException("Orientation must not be null");
+ }
+
+ this.xScale = xScale;
+ this.yScale = yScale;
+ this.array = array;
+ this.orientation = orientation;
+ }
+
+ /**
+ * Returns the.
+ *
+ * @param x the x
+ * @param y the y
+ * @return the double
+ */
+ public double get(int x, int y) {
+ switch (orientation){
+ case ROW:
+ return array[y][x];
+ case COLUMN:
+ return array[x][y];
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the height.
+ *
+ * @return the height
+ */
+ public int getHeight() {
+ switch (orientation){
+ case ROW:
+ return array.length;
+ case COLUMN:
+ return array[0].length;
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the width.
+ *
+ * @return the width
+ */
+ public int getWidth() {
+ switch (orientation){
+ case ROW:
+ return array[0].length;
+ case COLUMN:
+ return array.length;
+ }
+ throw new IllegalStateException("Unknown array orientation");
+ }
+
+ /**
+ * Gets the x labels.
+ *
+ * @return the x scale
+ */
+ public JHCScale> getXScale() {
+ return xScale;
+ }
+
+ /**
+ * Gets the y labels.
+ *
+ * @return the y scale
+ */
+ public JHCScale> getYScale() {
+ return yScale;
+ }
+
+ @Override
+ public Orientation getOrientation() {
+ return orientation;
+ }
+}
diff --git a/src/main/de/linearbits/jhc/Rectangle.java b/src/main/de/linearbits/jhc/Rectangle.java
new file mode 100644
index 0000000..1eb608b
--- /dev/null
+++ b/src/main/de/linearbits/jhc/Rectangle.java
@@ -0,0 +1,73 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+/**
+ * This class implements a rectangle
+ *
+ * @author Fabian Prasser
+ */
+class Rectangle {
+
+ /** The height. */
+ public final int height;
+
+ /** The width. */
+ public final int width;
+
+ /** The x. */
+ public final int x;
+
+ /** The y. */
+ public final int y;
+
+ /**
+ * Instantiates a new rectangle.
+ */
+ protected Rectangle() {
+ this.x = 0;
+ this.y = 0;
+ this.width = 0;
+ this.height = 0;
+ }
+
+ /**
+ * Instantiates a new rectangle.
+ *
+ * @param x the x
+ * @param y the y
+ * @param width the width
+ * @param height the height
+ */
+ protected Rectangle(int x, int y, int width, int height) {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "Rectangle [x=" + x + ", y=" + y + ", width=" + width + ", height=" + height + "]";
+ }
+}
diff --git a/src/main/de/linearbits/jhc/RenderedHeatmap.java b/src/main/de/linearbits/jhc/RenderedHeatmap.java
new file mode 100644
index 0000000..5a6e9d1
--- /dev/null
+++ b/src/main/de/linearbits/jhc/RenderedHeatmap.java
@@ -0,0 +1,149 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+/**
+ * This class represents a heatmap that has been rendered to an image
+ *
+ * @author Fabian Prasser
+ *
+ * @param the generic type
+ */
+class RenderedHeatmap {
+
+ @SuppressWarnings("rawtypes")
+ protected static final RenderedHeatmap> NO_DATA = new RenderedHeatmap();
+ @SuppressWarnings("rawtypes")
+ protected static final RenderedHeatmap> TOO_SMALL = new RenderedHeatmap();
+
+ /** The config. */
+ private final JHCConfiguration config;
+
+ /** The heat. */
+ private final JHCHeatmap heat;
+
+ /** The height. */
+ private final int height;
+
+ /** The image. */
+ private final T image;
+
+ /** The width. */
+ private final int width;
+
+ /**
+ * Creates a new instance
+ *
+ * @param image the image
+ * @param heat the heat
+ * @param config the config
+ */
+ protected RenderedHeatmap(T image, JHCHeatmap heat, JHCConfiguration config) {
+ this.image = image;
+ this.heat = heat;
+ this.config = config;
+ this.width = heat.getWidth();
+ this.height = heat.getHeight();
+ }
+
+ /**
+ * For special instances
+ */
+ private RenderedHeatmap() {
+ this.image = null;
+ this.heat = null;
+ this.config = null;
+ this.width = 0;
+ this.height = 0;
+ }
+
+ /**
+ * Gets the config.
+ *
+ * @return the config
+ */
+ protected JHCConfiguration getConfig() {
+ return config;
+ }
+
+ /**
+ * Gets the height.
+ *
+ * @return the height
+ */
+ protected int getHeight() {
+ return height;
+ }
+
+ /**
+ * Gets the image.
+ *
+ * @return the image
+ */
+ protected T getImage() {
+ return image;
+ }
+
+ /**
+ * Gets the width.
+ *
+ * @return the width
+ */
+ protected int getWidth() {
+ return width;
+ }
+
+ /**
+ * Gets the x label.
+ *
+ * @param index the index
+ * @return the x label
+ */
+ protected String getXLabel(int index) {
+ if (heat == null) return null;
+ else return heat.getXLabel(index);
+ }
+
+ /**
+ * Gets the y label.
+ *
+ * @param index the index
+ * @return the y label
+ */
+ protected String getYLabel(int index) {
+ if (heat == null) return null;
+ else return heat.getYLabel(index);
+ }
+
+ /**
+ * Returns the min
+ * @return
+ */
+ protected double getMin(){
+ if (heat == null) return 0;
+ else return heat.getMin();
+ }
+
+ /**
+ * Returns the max
+ */
+ protected double getMax() {
+ if (heat == null) return 0;
+ else return heat.getMax();
+ }
+}
diff --git a/src/main/de/linearbits/jhc/RenderedLayout.java b/src/main/de/linearbits/jhc/RenderedLayout.java
new file mode 100644
index 0000000..3215333
--- /dev/null
+++ b/src/main/de/linearbits/jhc/RenderedLayout.java
@@ -0,0 +1,285 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General protected License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 protected License for more details.
+ *
+ * You should have received a copy of the GNU General protected License
+ * along with this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+/**
+ * This class represents a layout that has been rendered in a concrete context
+ *
+ * @author Fabian Prasser
+ */
+class RenderedLayout {
+
+ /** The draw x ticks. */
+ private final boolean drawXTicks;
+
+ /** The draw y labels. */
+ private final boolean drawYTicks;
+
+ /** The heat height. */
+ private final int heatHeight;
+
+ /** The heat width. */
+ private final int heatWidth;
+
+ /** The height. */
+ private final int height;
+
+ /** The layout. */
+ private final JHCLayout layout;
+
+ /** The text offset. */
+ private final int textOffset;
+
+ /** The width. */
+ private final int width;
+
+ /** The x. */
+ private final int x;
+
+ /** The x labels rotate. */
+ private final boolean rotateXTicks;
+
+ /** The x labels rotate space. */
+ private final int xTicksSpace;
+
+ /** The x tick offset. */
+ private final double xTicksOffset;
+
+ /** The y. */
+ private final int y;
+
+ /** The y labels rotate. */
+ private final boolean rotateYTicks;
+
+ /** The y labels rotate space. */
+ private final int yTicksSpace;
+
+ /** The y tick offset. */
+ private final double yTicksOffset;
+
+ /**
+ * Instantiates a new layout rendered.
+ *
+ * @param layout the layout
+ * @param x the x
+ * @param y the y
+ * @param width the width
+ * @param height the height
+ * @param heatWidth the heat width
+ * @param heatHeight the heat height
+ * @param textOffset the text offset
+ * @param xTickOffset the x tick offset
+ * @param yTickOffset the y tick offset
+ * @param drawXTicks the draw x labels
+ * @param drawYTicks the draw y labels
+ * @param rotateXTicks the x labels rotate
+ * @param xTicksSpace the x labels rotate space
+ * @param rotateYTicks the y labels rotate
+ * @param yTicksSpace the y labels rotate space
+ */
+ protected RenderedLayout(JHCLayout layout, int x, int y, int width, int height, int heatWidth, int heatHeight, int textOffset, double xTickOffset, double yTickOffset, boolean drawXTicks, boolean drawYTicks, boolean rotateXTicks, int xTicksSpace, boolean rotateYTicks, int yTicksSpace) {
+
+ this.layout = layout;
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ this.textOffset = textOffset;
+ this.xTicksOffset = xTickOffset;
+ this.yTicksOffset = yTickOffset;
+ this.drawXTicks = drawXTicks;
+ this.drawYTicks = drawYTicks;
+ this.heatHeight = heatHeight;
+ this.heatWidth = heatWidth;
+ this.rotateXTicks = rotateXTicks;
+ this.xTicksSpace = xTicksSpace;
+ this.rotateYTicks = rotateYTicks;
+ this.yTicksSpace = yTicksSpace;
+ }
+
+ /**
+ * Gets the center offset.
+ *
+ * @return the center offset
+ */
+ protected int getCenterOffset() {
+ return layout.getCenterOffset();
+ }
+
+ /**
+ * Gets the heat height.
+ *
+ * @return the heat height
+ */
+ protected int getHeatHeight() {
+ return heatHeight;
+ }
+
+ /**
+ * Gets the heat width.
+ *
+ * @return the heat width
+ */
+ protected int getHeatWidth() {
+ return heatWidth;
+ }
+
+ /**
+ * Gets the height.
+ *
+ * @return the height
+ */
+ protected int getHeight() {
+ return height;
+ }
+
+ /**
+ * Gets the large tick length.
+ *
+ * @return the large tick length
+ */
+ protected int getLargeTickLength() {
+ return layout.getLargeTickLength();
+ }
+
+ /**
+ * Gets the legend width.
+ *
+ * @return the legend width
+ */
+ protected int getLegendWidth() {
+ return layout.getLegendWidth();
+ }
+
+ /**
+ * Gets the small tick length.
+ *
+ * @return the small tick length
+ */
+ protected int getSmallTickLength() {
+ return layout.getSmallTickLength();
+ }
+
+ /**
+ * Gets the text offset.
+ *
+ * @return the text offset
+ */
+ protected int getTextOffset() {
+ return textOffset;
+ }
+
+ /**
+ * Gets the width.
+ *
+ * @return the width
+ */
+ protected int getWidth() {
+ return width;
+ }
+
+ /**
+ * Gets the x.
+ *
+ * @return the x
+ */
+ protected int getX() {
+ return x;
+ }
+
+ /**
+ * Gets the x labels rotate space.
+ *
+ * @return the x labels rotate space
+ */
+ protected int getXTicksSpace() {
+ return xTicksSpace;
+ }
+
+ /**
+ * Gets the x tick offset.
+ *
+ * @return the x tick offset
+ */
+ protected double getxTickOffset() {
+ return xTicksOffset;
+ }
+
+ /**
+ * Gets the y.
+ *
+ * @return the y
+ */
+ protected int getY() {
+ return y;
+ }
+
+ /**
+ * Gets the y labels rotate space.
+ *
+ * @return the y labels rotate space
+ */
+ protected int getYTicksSpace() {
+ return yTicksSpace;
+ }
+
+ /**
+ * Gets the y tick offset.
+ *
+ * @return the y tick offset
+ */
+ protected double getyTickOffset() {
+ return yTicksOffset;
+ }
+
+ /**
+ * Checks if is draw x labels.
+ *
+ * @return true, if is draw x labels
+ */
+ protected boolean isDrawXTicks() {
+ return drawXTicks;
+ }
+
+ /**
+ * Checks if is draw y labels.
+ *
+ * @return true, if is draw y labels
+ */
+ protected boolean isDrawYTicks() {
+ return drawYTicks;
+ }
+
+ /**
+ * Checks if is x labels rotate.
+ *
+ * @return true, if is x labels rotate
+ */
+ protected boolean isXTicksRotate() {
+ return rotateXTicks;
+ }
+
+ /**
+ * Checks if is y labels rotate.
+ *
+ * @return true, if is y labels rotate
+ */
+ protected boolean isYTicksRotate() {
+ return rotateYTicks;
+ }
+}
diff --git a/src/main/de/linearbits/jhc/Renderer.java b/src/main/de/linearbits/jhc/Renderer.java
new file mode 100644
index 0000000..e797361
--- /dev/null
+++ b/src/main/de/linearbits/jhc/Renderer.java
@@ -0,0 +1,206 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import java.util.Iterator;
+
+import de.linearbits.jhc.JHCHeatmap.Point;
+
+/**
+ * This class controls the asynchronous rendering process
+ *
+ * @author Fabian Prasser
+ *
+ * @param the generic type
+ */
+abstract class Renderer {
+
+ /** Resize delay */
+ public static final int WAKEUP_DELAY = 100;
+
+ /** Resize delay */
+ public static final int RENDERING_DELAY = 500;
+
+ /**
+ * A job to be run by the renderer
+ * @author Fabian Prasser
+ *
+ */
+ private class Job {
+
+ /** Timestamp*/
+ public final long timestamp = System.currentTimeMillis();
+ /** Data*/
+ public final JHCData data;
+ /** Config*/
+ public final JHCConfiguration config;
+
+ /**
+ * Creates a new instance
+ *
+ * @param data
+ * @param config
+ */
+ public Job(JHCData data, JHCConfiguration config) {
+ this.data = data;
+ this.config = config;
+ }
+ }
+
+ /** The canvas. */
+ private Canvas, ?, ?> canvas;
+
+ /** The jhc. */
+ private _JHC jhc;
+
+ /** The next job */
+ private Job next = null;
+
+ /**
+ * Adds a new job
+ * @param data
+ * @param config
+ */
+ private void addJob(JHCData data, JHCConfiguration config){
+ synchronized(this) {
+ this.next = new Job(data, config);
+ }
+ }
+
+ /**
+ * Returns the current job, if any
+ * @return
+ */
+ private Job getJob(){
+ synchronized(this) {
+ if (this.next != null && System.currentTimeMillis() - this.next.timestamp >= RENDERING_DELAY) {
+ Job result = this.next;
+ this.next = null;
+ return result;
+ } else {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Processes the given job
+ * @param job
+ */
+ private void processJob(Job job){
+
+ if (job.data == null) {
+ jhc.setHeatmap(RenderedHeatmap.NO_DATA);
+ return;
+ }
+
+ RenderedLayout layout = job.config.getLayout().getRenderedLayout(job.config, canvas, job.data);
+
+ if (layout.getHeatWidth() == 0 || layout.getHeatHeight() == 0) {
+ jhc.setHeatmap(RenderedHeatmap.TOO_SMALL);
+ return;
+ }
+
+ JHCHeatmap heat = job.data.getHeatmap(layout.getHeatWidth(), layout.getHeatHeight());
+ Pixels pixels = getPixels(heat, job.config);
+ double max = heat.getMax();
+ double min = heat.getMin();
+
+ Iterator iter = heat.iterator();
+ while (iter.hasNext()) {
+ Point point = iter.next();
+ int color = getColor(job.config, point.getValue(), min, max);
+ int x = point.getX();
+ int y = point.getY();
+ if (x<0 || y<0 || x>=heat.getWidth() || y>=heat.getHeight()) {
+ throw new IllegalStateException("Point coordinates ("+x+", "+y+") out of range ("+heat.getWidth()+", "+heat.getHeight()+")");
+ }
+ pixels.set(point.getX(), point.getY(), color);
+ }
+
+ pixels.update();
+
+ RenderedHeatmap rendered = new RenderedHeatmap(pixels.getImage(), heat, job.config);
+ jhc.setHeatmap(rendered);
+ }
+
+ /**
+ * Instantiates a new renderer.
+ *
+ * @param jhc the jhc
+ * @param canvas the canvas
+ */
+ protected Renderer(_JHC jhc, Canvas, ?, ?> canvas) {
+
+ // Init
+ this.jhc = jhc;
+ this.canvas = canvas;
+
+ // Create rendering thread
+ Runnable r = new Runnable() {
+ public void run(){
+ while (true) {
+ try {
+ Thread.sleep(WAKEUP_DELAY);
+ } catch (InterruptedException e) {
+ /** Ignore*/
+ }
+ Job job = getJob();
+ if (job != null) {
+ processJob(job);
+ }
+ }
+ }
+ };
+ Thread t = new Thread(r);
+ t.setDaemon(true);
+ t.start();
+ }
+
+ /**
+ * Render.
+ *
+ * @param data the data
+ * @param config the config
+ */
+ protected void render(JHCData data, JHCConfiguration config) {
+ this.addJob(data, config);
+ }
+
+ /**
+ * Gets the color.
+ *
+ * @param config the config
+ * @param value the value
+ * @param max the max
+ * @return the color
+ */
+ protected int getColor(JHCConfiguration config, double value, double min, double max) {
+ int index = (int) Math.round((value - min) / (max - min) * (config.getGradient().getSteps() - 1));
+ return config.getGradient().getColor(index);
+ }
+
+ /**
+ * Gets the pixels.
+ *
+ * @param heat the heat
+ * @param config the config
+ * @return the pixels
+ */
+ protected abstract Pixels getPixels(JHCHeatmap heat, JHCConfiguration config);
+}
diff --git a/src/main/de/linearbits/jhc/ToolTip.java b/src/main/de/linearbits/jhc/ToolTip.java
new file mode 100644
index 0000000..a028357
--- /dev/null
+++ b/src/main/de/linearbits/jhc/ToolTip.java
@@ -0,0 +1,69 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+/**
+ * This class provides helper methods for displaying tooltips
+ *
+ * @author Fabian Prasser
+ */
+class ToolTip {
+
+ /**
+ * Gets the tool tip.
+ *
+ * @param heatmap the heatmap
+ * @param painter the painter
+ * @param x the x
+ * @param y the y
+ * @return the tool tip
+ */
+ public static String getToolTip(RenderedHeatmap> heatmap, Painter, ?, ?> painter, int sx, int sy, boolean html) {
+ Rectangle heatmapPosition = painter.getHeatmapPosition();
+ if (heatmapPosition != null) {
+ int x = sx - heatmapPosition.x;
+ int y = heatmapPosition.height - (sy - heatmapPosition.y);
+ if (x >= 0 && y >= 0 && x < heatmapPosition.width && y < heatmapPosition.height) {
+ int dX = (int) ((double) x / (double) heatmapPosition.width * heatmap.getWidth());
+ int dY = (int) ((double) y / (double) heatmapPosition.height * heatmap.getHeight());
+ StringBuilder b = new StringBuilder();
+ if (html) b.append("");
+ b.append("x=").append(heatmap.getXLabel(dX));
+ if (html) b.append("
");
+ else b.append("\n");
+ b.append("y=").append(heatmap.getYLabel(dY));
+ if (html) b.append("");
+ return b.toString();
+ }
+ }
+ Rectangle legendPosition = painter.getLegendPosition();
+ if (legendPosition != null) {
+ int x = sx - legendPosition.x;
+ int y = legendPosition.height - (sy - legendPosition.y);
+ if (x >= 0 && y >= 0 && x < legendPosition.width && y < legendPosition.height) {
+ double dY = ((double) y / (double) legendPosition.height) * (heatmap.getMax() - heatmap.getMin()) + heatmap.getMin();
+ StringBuilder b = new StringBuilder();
+ if (html) b.append("");
+ b.append(dY);
+ if (html) b.append("");
+ return b.toString();
+ }
+ }
+ return null;
+ }
+}
diff --git a/src/swing/de/linearbits/examples/ExamplesSwing.java b/src/swing/de/linearbits/examples/ExamplesSwing.java
new file mode 100644
index 0000000..1ed4f89
--- /dev/null
+++ b/src/swing/de/linearbits/examples/ExamplesSwing.java
@@ -0,0 +1,45 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.examples;
+
+import de.linearbits.examples.ExampleData;
+import de.linearbits.examples.Examples;
+
+/**
+ * This class implements examples for swing
+ *
+ * @author Fabian Prasser
+ */
+class ExamplesSwing extends ExampleData {
+
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
+ public static void main(String[] args) {
+
+ Examples.example1(new WindowSwing());
+ Examples.example2(new WindowSwing());
+ Examples.example3(new WindowSwing());
+ Examples.example4(new WindowSwing());
+ Examples.example5(new WindowSwing());
+ Examples.example6(new WindowSwing());
+ Examples.example7(new WindowSwing());
+ }
+}
diff --git a/src/swing/de/linearbits/examples/WindowSwing.java b/src/swing/de/linearbits/examples/WindowSwing.java
new file mode 100644
index 0000000..a713a5d
--- /dev/null
+++ b/src/swing/de/linearbits/examples/WindowSwing.java
@@ -0,0 +1,66 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.examples;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Font;
+
+import javax.swing.JFrame;
+
+import de.linearbits.jhc.JHC;
+import de.linearbits.jhc.JHCConfiguration;
+import de.linearbits.jhc.JHCData;
+
+/**
+ * This class implements a window for Swing
+ *
+ * @author Fabian Prasser
+ */
+class WindowSwing extends JFrame implements Window {
+
+ /** The Constant serialVersionUID. */
+ private static final long serialVersionUID = -6498074114197249215L;
+
+ /** The panel. */
+ private JHC panel;
+
+ /**
+ * Instantiates a new window swing.
+ */
+ protected WindowSwing() {
+
+ this.setTitle("Swing");
+ this.setSize(200, 200);
+ this.setLayout(new BorderLayout());
+ this.panel = new JHC();
+ this.add(panel, BorderLayout.CENTER);
+ this.panel.setFont(this.panel.getFont().deriveFont(12f));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.examples.Window#open(de.linearbits.jhc.Data, de.linearbits.jhc.Configuration)
+ */
+ @Override
+ public void open(JHCData data, JHCConfiguration config) {
+ panel.setData(data, config);
+ this.setVisible(true);
+ }
+}
diff --git a/src/swing/de/linearbits/jhc/CanvasSwing.java b/src/swing/de/linearbits/jhc/CanvasSwing.java
new file mode 100644
index 0000000..831bbd0
--- /dev/null
+++ b/src/swing/de/linearbits/jhc/CanvasSwing.java
@@ -0,0 +1,170 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.event.MouseMotionAdapter;
+
+import javax.swing.JComponent;
+
+/**
+ * This class implements a canvas for swing
+ *
+ * @author Fabian Prasser
+ */
+class CanvasSwing extends JComponent implements Canvas {
+
+ /** The Constant serialVersionUID. */
+ private static final long serialVersionUID = -3788402111642606157L;
+
+ /** The black. */
+ private Color black;
+
+ /** The gray. */
+ private Color gray;
+
+ /** The heatmap. */
+ private RenderedHeatmap heatmap = null;
+
+ /** The listener. */
+ private CanvasListener listener = null;
+
+ /** The painter. */
+ private final Painter painter = new Painter(this);
+
+ /** The text extents. */
+ private Dimension textExtents = null;
+
+ /**
+ * Creates a new instance
+ */
+ protected CanvasSwing() {
+
+ this.black = new Color(0, 0, 0);
+ this.gray = new Color(128, 128, 128);
+
+ this.addComponentListener(new ComponentAdapter() {
+
+ @Override
+ public void componentResized(ComponentEvent e) {
+ if (listener != null) listener.resized();
+ }
+
+ @Override
+ public void componentShown(ComponentEvent e) {
+ if (listener != null) listener.shown();
+ }
+ });
+
+ this.addMouseMotionListener(new MouseMotionAdapter() {
+
+ @Override
+ public void mouseMoved(java.awt.event.MouseEvent e) {
+ if (heatmap != null && painter != null) {
+ String text = ToolTip.getToolTip(heatmap, painter, e.getX(), e.getY(), true);
+ CanvasSwing.this.setToolTipText(text);
+ } else {
+ CanvasSwing.this.setToolTipText(null);
+ }
+ }
+ });
+
+ this.setDoubleBuffered(true);
+ }
+
+ @Override
+ public Color getBlack() {
+ return black;
+ }
+
+ @Override
+ public Dimension getCanvasSize() {
+ return new Dimension(getWidth(), getHeight());
+ }
+
+ @Override
+ public Dimension getExtents() {
+ if (textExtents == null) {
+ textExtents = getTextExtents();
+ }
+ return textExtents;
+ }
+
+ @Override
+ public Color getGray() {
+ return gray;
+ }
+
+ @Override
+ public void setFont(Font font) {
+ super.setFont(font);
+ textExtents = getTextExtents();
+ if (listener != null) listener.resized();
+ }
+
+ @Override
+ public void setForeground(Color fg) {
+ super.setForeground(fg);
+ if (listener != null) listener.resized();
+ }
+
+ @Override
+ public void setBackground(Color bg) {
+ super.setBackground(bg);
+ if (listener != null) listener.resized();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void setHeatmap(RenderedHeatmap> heatmap) {
+ this.heatmap = (RenderedHeatmap)heatmap;
+ this.repaint();
+ }
+
+ @Override
+ public void setListener(CanvasListener listener) {
+ this.listener = listener;
+ }
+
+ /**
+ * Gets the text extents.
+ *
+ * @return the text extents
+ */
+ private Dimension getTextExtents() {
+ FontMetrics metrics = this.getFontMetrics(this.getFont());
+ int height = metrics.getHeight();
+ int width = 2 * metrics.stringWidth(de.linearbits.jhc.Graphics.POSTFIX);
+ return new Dimension(width, height);
+ }
+
+ @Override
+ protected void paintComponent(Graphics g) {
+ if (painter != null) {
+ GraphicsJava2D graphics = new GraphicsJava2D(this, (Graphics2D) g);
+ painter.paint(graphics, heatmap, this.getCanvasSize());
+ }
+ }
+}
diff --git a/src/swing/de/linearbits/jhc/JHC.java b/src/swing/de/linearbits/jhc/JHC.java
new file mode 100644
index 0000000..f2d1be3
--- /dev/null
+++ b/src/swing/de/linearbits/jhc/JHC.java
@@ -0,0 +1,66 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Font;
+
+import javax.swing.JComponent;
+
+/**
+ * This class provides a heatmap control for Swing
+ * @author Fabian Prasser
+ */
+public class JHC extends JComponent {
+
+ /** SUID */
+ private static final long serialVersionUID = -2953032744074537804L;
+
+ /** The real widget*/
+ private _JHC jhc = new _JHC();
+
+ /** Creates a new instance*/
+ public JHC(){
+ this.setLayout(new BorderLayout());
+ this.add(jhc, BorderLayout.CENTER);
+ }
+
+ /**
+ * Updates the data displayed by this control
+ * @param data
+ * @param config
+ */
+ public void setData(JHCData data, JHCConfiguration config) {
+ jhc.setData(data, config);
+ }
+
+ /**
+ * Sets the font
+ */
+ public void setFont(Font font) {
+ jhc.setFont(font);
+ }
+
+ /**
+ * Sets the background color
+ */
+ public void setBackground(Color bg) {
+ jhc.setBackground(bg);
+ }
+}
diff --git a/src/swing/de/linearbits/jhc/_JHC.java b/src/swing/de/linearbits/jhc/_JHC.java
new file mode 100644
index 0000000..453e686
--- /dev/null
+++ b/src/swing/de/linearbits/jhc/_JHC.java
@@ -0,0 +1,80 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import java.awt.Image;
+
+/**
+ * This class implements JHC for Swing
+ *
+ * @author Fabian Prasser
+ */
+class _JHC extends CanvasSwing {
+
+ /** The Constant serialVersionUID. */
+ private static final long serialVersionUID = 6100042540949178860L;
+
+ /** The config. */
+ private volatile JHCConfiguration config = null;
+
+ /** The data. */
+ private volatile JHCData data = null;
+
+ /** The renderer. */
+ private volatile Renderer renderer = new RendererJava2D(this, this);
+
+ /**
+ * Creates a new instance
+ */
+ protected _JHC() {
+ super.setListener(new CanvasListener(){
+ @Override
+ public void resized() {
+ _JHC.this.resized();
+ }
+
+ @Override
+ public void shown() {
+ _JHC.this.shown();
+ }
+ });
+ }
+
+ /*
+ * @see de.linearbits.jhc.CanvasListener#resized()
+ */
+ private void resized() {
+ this.renderer.render(data, config);
+ }
+
+ /*
+ * @see de.linearbits.jhc.CanvasListener#shown()
+ */
+ private void shown() {
+ this.renderer.render(data, config);
+ }
+
+ /**
+ * Sets the data to be rendered
+ */
+ protected void setData(JHCData data, JHCConfiguration config) {
+ this.data = data;
+ this.config = config;
+ this.renderer.render(data, config);
+ }
+}
diff --git a/src/swing/de/linearbits/jhc/package-info.java b/src/swing/de/linearbits/jhc/package-info.java
new file mode 100644
index 0000000..d2b01a9
--- /dev/null
+++ b/src/swing/de/linearbits/jhc/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+
+/**
+ * This package provides a heatmap control for Swing
+ *
+ * @author Fabian Prasser
+ */
+package de.linearbits.jhc;
\ No newline at end of file
diff --git a/src/swt/de/linearbits/examples/ExamplesSWT.java b/src/swt/de/linearbits/examples/ExamplesSWT.java
new file mode 100644
index 0000000..2ad9839
--- /dev/null
+++ b/src/swt/de/linearbits/examples/ExamplesSWT.java
@@ -0,0 +1,42 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.examples;
+
+/**
+ * This class implements examples for SWT
+ *
+ * @author Fabian Prasser
+ */
+class ExamplesSWT extends ExampleData {
+
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
+ public static void main(String[] args) {
+
+ Examples.example1(new WindowSWT());
+ Examples.example2(new WindowSWT());
+ Examples.example3(new WindowSWT());
+ Examples.example4(new WindowSWT());
+ Examples.example5(new WindowSWT());
+ Examples.example6(new WindowSWT());
+ Examples.example7(new WindowSWT());
+ }
+}
diff --git a/src/swt/de/linearbits/examples/WindowSWT.java b/src/swt/de/linearbits/examples/WindowSWT.java
new file mode 100644
index 0000000..35ef23a
--- /dev/null
+++ b/src/swt/de/linearbits/examples/WindowSWT.java
@@ -0,0 +1,82 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.examples;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import de.linearbits.jhc.JHC;
+import de.linearbits.jhc.JHCConfiguration;
+import de.linearbits.jhc.JHCData;
+
+/**
+ * This class implements a window for SWT
+ *
+ * @author Fabian Prasser
+ */
+class WindowSWT implements Window {
+
+ /** The display. */
+ private Display display;
+
+ /** The panel. */
+ private JHC jhc;
+
+ /** The shell. */
+ private Shell shell;
+
+ @Override
+ public void open(JHCData data, JHCConfiguration config) {
+
+ this.display = new Display();
+ this.shell = new Shell(display);
+ shell.setText("SWT");
+ shell.setSize(200, 200);
+
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 1;
+ shell.setLayout(gridLayout);
+
+ jhc = new JHC(shell, SWT.NONE);
+ GridData gridData = new GridData();
+ gridData.grabExcessVerticalSpace = true;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ jhc.setLayoutData(gridData);
+ jhc.setData(data, config);
+
+ // Update some settings
+ FontData[] fd = jhc.getFont().getFontData();
+ fd[0].setHeight(8);
+ jhc.setFont(new Font(Display.getCurrent(), fd[0]));
+
+ // Enter event loop
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/src/swt/de/linearbits/jhc/CanvasSWT.java b/src/swt/de/linearbits/jhc/CanvasSWT.java
new file mode 100644
index 0000000..4957fd0
--- /dev/null
+++ b/src/swt/de/linearbits/jhc/CanvasSWT.java
@@ -0,0 +1,217 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This class implements a canvas for SWT
+ *
+ * @author Fabian Prasser
+ */
+class CanvasSWT extends org.eclipse.swt.widgets.Canvas implements Canvas {
+
+ /** The Constant SHOWN_DELAY. */
+ private static final int SHOWN_DELAY = 200;
+
+ /** The black. */
+ private Color black;
+
+ /** The gray. */
+ private Color gray;
+
+ /** The heatmap. */
+ private RenderedHeatmap heatmap = null;
+
+ /** The listener. */
+ private CanvasListener listener = null;
+
+ /** The painter. */
+ private final Painter painter;
+
+ /** The size. */
+ private Point size = null;
+
+ /** The text extents. */
+ private Dimension textExtents = null;
+
+ /**
+ * Creates a new instance
+ *
+ * @param parent the parent
+ * @param style the style
+ */
+ protected CanvasSWT(Composite parent, int style) {
+
+ super(parent, style | SWT.DOUBLE_BUFFERED);
+
+ this.black = new Color(getDisplay(), 0, 0, 0);
+ this.gray = new Color(getDisplay(), 128, 128, 128);
+
+ this.textExtents = getTextExtents();
+
+ this.setCanvasSize(getSize());
+ this.painter = new PainterSWT(this);
+ this.addDisposeListener(new DisposeListener() {
+ @Override
+ public void widgetDisposed(DisposeEvent arg0) {
+ painter.dispose();
+ black.dispose();
+ gray.dispose();
+ }
+ });
+
+ this.addControlListener(new ControlAdapter() {
+ @Override
+ public void controlResized(ControlEvent arg0) {
+ setCanvasSize(getSize());
+ if (listener != null) listener.resized();
+ }
+ });
+
+ // Simulate shown event
+ this.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent arg0) {
+ removePaintListener(this);
+ getDisplay().timerExec(SHOWN_DELAY, new Runnable() {
+ @Override
+ public void run() {
+ if (listener != null) listener.shown();
+ }
+ });
+ }
+ });
+
+ // Paint the component
+ this.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent arg0) {
+ if (painter != null) {
+ Dimension size = getCanvasSize();
+ GraphicsSWT graphics = new GraphicsSWT(CanvasSWT.this, arg0.gc);
+ painter.paint(graphics, heatmap, size);
+ }
+ }
+ });
+
+ this.addMouseMoveListener(new MouseMoveListener() {
+ @Override
+ public void mouseMove(MouseEvent arg0) {
+ if (heatmap != null && painter != null) {
+ String text = ToolTip.getToolTip(heatmap, painter, arg0.x, arg0.y, false);
+ CanvasSWT.this.setToolTipText(text);
+ } else {
+ CanvasSWT.this.setToolTipText(null);
+ }
+ }
+ });
+ }
+
+ @Override
+ public Color getBlack() {
+ return black;
+ }
+
+ @Override
+ public Dimension getCanvasSize() {
+ return new Dimension(size.x, size.y);
+ }
+
+ @Override
+ public Dimension getExtents() {
+ return this.textExtents;
+ }
+
+ @Override
+ public Color getGray() {
+ return gray;
+ }
+
+ @Override
+ public void setFont(Font arg0) {
+ super.setFont(arg0);
+ textExtents = getTextExtents();
+ if (listener != null) listener.resized();
+ }
+
+ @Override
+ public void setForeground(Color fg) {
+ super.setForeground(fg);
+ if (listener != null) listener.resized();
+ }
+
+ @Override
+ public void setBackground(Color bg) {
+ super.setBackground(bg);
+ if (listener != null) listener.resized();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void setHeatmap(RenderedHeatmap> heatmap) {
+ this.heatmap = (RenderedHeatmap)heatmap;
+ if (this.isDisposed()) return;
+ getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (!CanvasSWT.this.isDisposed()) redraw();
+ }
+ });
+ }
+
+ @Override
+ public void setListener(CanvasListener listener) {
+ this.listener = listener;
+ }
+
+ /**
+ * Gets the text extents.
+ *
+ * @return the text extents
+ */
+ private Dimension getTextExtents() {
+ GC gc = new GC(this);
+ int width = 2 * gc.textExtent(Graphics.POSTFIX).x;
+ int height = gc.textExtent(Graphics.POSTFIX).y;
+ return new Dimension(width, height);
+ }
+
+ /**
+ * Sets the canvas size.
+ *
+ * @param size the new canvas size
+ */
+ private void setCanvasSize(Point size) {
+ this.size = size;
+ }
+}
diff --git a/src/swt/de/linearbits/jhc/GraphicsSWT.java b/src/swt/de/linearbits/jhc/GraphicsSWT.java
new file mode 100644
index 0000000..7bea0ec
--- /dev/null
+++ b/src/swt/de/linearbits/jhc/GraphicsSWT.java
@@ -0,0 +1,335 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Transform;
+
+/**
+ * This class implements graphics operations for SWT
+ *
+ * @author Fabian Prasser
+ */
+class GraphicsSWT implements Graphics {
+
+ /** The antialias. */
+ private int antialias;
+
+ /** The canvas. */
+ private CanvasSWT canvas;
+
+ /** The gc. */
+ private GC gc;
+
+ /** The interpolation. */
+ private int interpolation;
+
+ /**
+ * Creates a new instance
+ *
+ * @param canvas the canvas
+ * @param gc the gc
+ */
+ protected GraphicsSWT(CanvasSWT canvas, GC gc) {
+ this.canvas = canvas;
+ this.gc = gc;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#disableAntialiasing()
+ */
+ @Override
+ public void disableAntialiasing() {
+ gc.setAntialias(SWT.OFF);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#disableInterpolation()
+ */
+ @Override
+ public void disableInterpolation() {
+ gc.setInterpolation(SWT.NONE);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#drawImage(java.lang.Object, int, int, int, int)
+ */
+ @Override
+ public void drawImage(Image image, int x, int y, int width, int height) {
+ org.eclipse.swt.graphics.Rectangle bounds = image.getBounds();
+ gc.drawImage(image, 0, 0, bounds.width, bounds.height, x, y, width, height);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#drawLegend(de.linearbits.jhc.Gradient)
+ */
+ @Override
+ public Image drawLegend(JHCGradient gradient) {
+ PixelsSWT pixels = new PixelsSWT(new Dimension(1, gradient.getSteps()), canvas.getDisplay(), gradient.getColor(0));
+ for (int i = 0; i < gradient.getSteps(); i++) {
+ pixels.set(0, i, gradient.getColor(i));
+ }
+ pixels.update();
+ return pixels.getImage();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#drawLine(int, int, int, int)
+ */
+ @Override
+ public void drawLine(int x1, int y1, int x2, int y2) {
+ gc.drawLine(x1, y1, x2, y2);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#drawRectangle(int, int, int, int)
+ */
+ @Override
+ public void drawRectangle(int x, int y, int width, int height) {
+ gc.drawRectangle(x, y, width, height);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#drawRectangleFilled(int, int, int, int)
+ */
+ @Override
+ public void drawRectangleFilled(int x, int y, int width, int height) {
+ gc.fillRectangle(x, y, width, height);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#drawStringAboveHorizontallyCentered(java.lang.String, int, int, int)
+ */
+ @Override
+ public void drawStringAboveHorizontallyCentered(String string, int x, int y, int width) {
+
+ Point extent = gc.textExtent(string);
+ int yy = y - extent.y;
+ if (width >= extent.x) {
+ gc.setClipping(x, yy, width, extent.y);
+ int xx = x + (width - extent.x) / 2;
+ gc.drawText(string, xx, yy, true);
+ } else {
+ int postfixWidth = gc.textExtent(POSTFIX).x;
+ gc.setClipping(x, yy, width - postfixWidth, extent.y);
+ gc.drawText(string, x, yy, true);
+ gc.setClipping(x + width - postfixWidth, yy, postfixWidth, extent.y);
+ gc.drawText(POSTFIX, x + width - postfixWidth, yy, true);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#drawStringBelowHorizontallyCentered(java.lang.String, int, int, int)
+ */
+ @Override
+ public void drawStringBelowHorizontallyCentered(String string, int x, int y, int width) {
+ Point extent = gc.textExtent(string);
+ int descent = gc.getFontMetrics().getDescent();
+ if (width >= extent.x) {
+ gc.setClipping(x, y + descent, width, extent.y);
+ int xx = x + (width - extent.x) / 2;
+ gc.drawText(string, xx, y + descent, true);
+ } else {
+ int postfixWidth = gc.textExtent(POSTFIX).x;
+ gc.setClipping(x, y + descent, width - postfixWidth, extent.y);
+ gc.drawText(string, x, y + descent, true);
+ gc.setClipping(x + width - postfixWidth, y + descent, postfixWidth, extent.y);
+ gc.drawText(POSTFIX, x + width - postfixWidth, y + descent, true);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#drawStringVerticallyCenteredLeftAligned(java.lang.String, int, int, int, int)
+ */
+ @Override
+ public void drawStringVerticallyCenteredLeftAligned(String string, int x, int y, int width, int height) {
+
+ Point extent = gc.textExtent(string);
+ int yy = y + height / 2 - extent.y / 2;
+
+ if (width >= extent.x) {
+ gc.setClipping(x, yy, width, extent.y);
+ gc.drawText(string, x, yy, true);
+ } else {
+ int postfixWidth = gc.textExtent(POSTFIX).x;
+ gc.setClipping(x, yy, width - postfixWidth, extent.y);
+ gc.drawText(string, x, yy, true);
+ gc.setClipping(x + width - postfixWidth, yy, postfixWidth, extent.y);
+ gc.drawText(POSTFIX, x + width - postfixWidth, yy, true);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#enableAntialiasing()
+ */
+ @Override
+ public void enableAntialiasing() {
+ gc.setAntialias(SWT.ON);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#enableInterpolation()
+ */
+ @Override
+ public void enableInterpolation() {
+ gc.setInterpolation(SWT.HIGH);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#getTextHeight(java.lang.String)
+ */
+ @Override
+ public int getTextHeight(String string) {
+ return gc.textExtent(string).y;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#getTextWidth(java.lang.String)
+ */
+ @Override
+ public int getTextWidth(String string) {
+ return gc.textExtent(string).x;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#init()
+ */
+ @Override
+ public void init() {
+ gc.setFont(canvas.getFont());
+ antialias = gc.getAntialias();
+ interpolation = gc.getInterpolation();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#resetAntialiasing()
+ */
+ @Override
+ public void resetAntialiasing() {
+ gc.setAntialias(antialias);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#resetClipping()
+ */
+ @Override
+ public void resetClipping() {
+ org.eclipse.swt.graphics.Rectangle bounds = canvas.getBounds();
+ gc.setClipping(0, 0, bounds.width, bounds.height);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#resetInterpolation()
+ */
+ @Override
+ public void resetInterpolation() {
+ gc.setInterpolation(interpolation);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#resetRotation()
+ */
+ @Override
+ public void resetRotation() {
+ gc.setTransform(null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#setBackground(java.lang.Object)
+ */
+ @Override
+ public void setBackground(Color color) {
+ gc.setBackground(color);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#setForeground(java.lang.Object)
+ */
+ @Override
+ public void setForeground(Color color) {
+ gc.setForeground(color);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Graphics#setRotation(int)
+ */
+ @Override
+ public void setRotation(int degrees) {
+ Transform tr = new Transform(canvas.getDisplay());
+ tr.rotate(degrees);
+ gc.setTransform(tr);
+ }
+
+ @Override
+ public void drawStringCentered(String string, int x, int y, int width, int height) {
+
+ Point extent = gc.textExtent(string);
+ int yy = y + (height - extent.y) / 2;
+ int xx = x + (width - extent.x) / 2;
+ gc.setClipping(xx, yy, extent.x, extent.y);
+ gc.drawText(string, xx, yy, true);
+ }
+}
diff --git a/src/swt/de/linearbits/jhc/JHC.java b/src/swt/de/linearbits/jhc/JHC.java
new file mode 100644
index 0000000..e52eb49
--- /dev/null
+++ b/src/swt/de/linearbits/jhc/JHC.java
@@ -0,0 +1,102 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This class implements a heatmap widget for SWT
+ *
+ * @author Fabian Prasser
+ */
+public class JHC {
+
+ /**
+ * Checks the style
+ *
+ * @param style
+ */
+ private static int checkStyle(int style) {
+ return style;
+ }
+
+ /** The real jhc*/
+ private _JHC jhc;
+
+ /**
+ * Creates a new instance
+ *
+ * @param parent the parent
+ * @param style the style
+ */
+ public JHC(Composite parent, int style) {
+ this.jhc = new _JHC(parent, checkStyle(style) | SWT.DOUBLE_BUFFERED);
+ }
+
+ /**
+ * Returns the background color
+ * @return
+ */
+ public Color getBackground() {
+ return jhc.getBackground();
+ }
+
+ /**
+ * Returns the font
+ * @return
+ */
+ public Font getFont() {
+ return jhc.getFont();
+ }
+
+ /**
+ * Sets the background color
+ * @param arg0
+ */
+ public void setBackground(Color arg0) {
+ jhc.setBackground(arg0);
+ }
+
+ /**
+ * Sets the data to be displayed by this widget
+ * @param data
+ * @param config
+ */
+ public void setData(JHCData data, JHCConfiguration config) {
+ jhc.setData(data, config);
+ }
+
+ /**
+ * Sets the font
+ * @param arg0
+ */
+ public void setFont(Font arg0) {
+ jhc.setFont(arg0);
+ }
+
+ /**
+ * Sets the layout data
+ * @param arg0
+ */
+ public void setLayoutData(Object arg0) {
+ jhc.setLayoutData(arg0);
+ }
+}
diff --git a/src/swt/de/linearbits/jhc/PainterSWT.java b/src/swt/de/linearbits/jhc/PainterSWT.java
new file mode 100644
index 0000000..8359dc8
--- /dev/null
+++ b/src/swt/de/linearbits/jhc/PainterSWT.java
@@ -0,0 +1,53 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This class implements a painter for SWT. The only difference to the standard painter is that
+ * the legend is disposed proberly
+ *
+ * @author Fabian Prasser
+ *
+ * @param
+ * @param
+ * @param
+ */
+class PainterSWT extends Painter {
+
+ /**
+ * Creates a new instance
+ * @param canvas
+ */
+ protected PainterSWT(Canvas canvas) {
+ super(canvas);
+ }
+
+ @Override
+ protected void disposeLegend(T legend) {
+
+ if (legend != null) {
+ if (legend instanceof Image) {
+ if (!((Image) legend).isDisposed()) {
+ ((Image) legend).dispose();
+ }
+ }
+ }
+ }
+}
diff --git a/src/swt/de/linearbits/jhc/PixelsSWT.java b/src/swt/de/linearbits/jhc/PixelsSWT.java
new file mode 100644
index 0000000..47624bb
--- /dev/null
+++ b/src/swt/de/linearbits/jhc/PixelsSWT.java
@@ -0,0 +1,114 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.PaletteData;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * This class implements Pixels for SWT
+ *
+ * @author Fabian Prasser
+ */
+class PixelsSWT implements Pixels {
+
+ /** The buffer. */
+ private byte[] buffer;
+
+ /** The display. */
+ private final Display display;
+
+ /** The image. */
+ private Image image;
+
+ /** The size. */
+ private final Dimension size;
+
+ /** The source. */
+ private ImageData source;
+
+ /**
+ * Creates a new instance
+ *
+ * @param size the size
+ * @param display the display
+ * @param initialColor the initial color
+ */
+ protected PixelsSWT(Dimension size, Display display, int initialColor) {
+
+ // Init
+ this.size = size;
+ this.display = display;
+
+ // Create buffer
+ this.buffer = new byte[size.height * size.width * 4];
+ this.source = new ImageData(size.width, size.height, 32, new PaletteData(0x00ff0000, 0x0000ff00, 0x000000ff), 1, buffer);
+
+ // TODO: Potentially inefficient
+ if (initialColor != 0) {
+ for (int y = 0; y < size.height; y++) {
+ for (int x = 0; x < size.width; x++) {
+ set(x, y, initialColor);
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Pixels#getImage()
+ */
+ @Override
+ public Image getImage() {
+ return image;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Pixels#getSize()
+ */
+ @Override
+ public Dimension getSize() {
+ return size;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Pixels#set(int, int, int)
+ */
+ @Override
+ public void set(int x, int y, int val) {
+ source.setPixel(x, size.height - 1 - y, val);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Pixels#update()
+ */
+ @Override
+ public void update() {
+ if (this.image != null) this.image.dispose();
+ this.image = new Image(display, source);
+ }
+}
diff --git a/src/swt/de/linearbits/jhc/RendererSWT.java b/src/swt/de/linearbits/jhc/RendererSWT.java
new file mode 100644
index 0000000..41bfb8f
--- /dev/null
+++ b/src/swt/de/linearbits/jhc/RendererSWT.java
@@ -0,0 +1,57 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * This class implements a renderer for SWT
+ *
+ * @author Fabian Prasser
+ */
+class RendererSWT extends Renderer {
+
+ /** The display. */
+ private final Display display;
+
+ /**
+ * Creates a new instance
+ *
+ * @param jhc the jhc
+ * @param canvas the canvas
+ */
+ protected RendererSWT(_JHC jhc, Canvas canvas) {
+ super(jhc, canvas);
+ this.display = jhc.getDisplay();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see de.linearbits.jhc.Renderer#getPixels(de.linearbits.jhc.Heat, de.linearbits.jhc.Configuration)
+ */
+ @Override
+ protected Pixels getPixels(JHCHeatmap heat, JHCConfiguration config) {
+ int initialColor = config.getGradient().getColor(0);
+ return new PixelsSWT(new Dimension(heat.getWidth(), heat.getHeight()), display, initialColor);
+ }
+}
diff --git a/src/swt/de/linearbits/jhc/_JHC.java b/src/swt/de/linearbits/jhc/_JHC.java
new file mode 100644
index 0000000..b9cb224
--- /dev/null
+++ b/src/swt/de/linearbits/jhc/_JHC.java
@@ -0,0 +1,87 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+package de.linearbits.jhc;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This class implements JHC for SWT
+ *
+ * @author Fabian Prasser
+ */
+class _JHC extends CanvasSWT {
+
+ /** Resize delay */
+ public static final int RESIZE_DELAY = 500;
+
+ /** The config. */
+ private volatile JHCConfiguration config = null;
+
+ /** The data. */
+ private volatile JHCData data = null;
+
+ /** The renderer. */
+ private volatile Renderer renderer = new RendererSWT(this, this);
+
+
+ /**
+ * Creates a new instance
+ *
+ * @param parent the parent
+ * @param style the style
+ */
+ _JHC(Composite parent, int style) {
+ super(parent, style);
+ super.setListener(new CanvasListener(){
+ @Override
+ public void resized() {
+ _JHC.this.resized();
+ }
+
+ @Override
+ public void shown() {
+ _JHC.this.shown();
+ }
+ });
+ }
+
+ /*
+ * @see de.linearbits.jhc.CanvasListener#resized()
+ */
+ private void resized() {
+ this.renderer.render(data, config);
+ }
+
+ /*
+ * @see de.linearbits.jhc.CanvasListener#shown()
+ */
+ private void shown() {
+ this.renderer.render(data, config);
+ }
+
+ /**
+ * Sets new data to render
+ */
+ protected void setData(JHCData data, JHCConfiguration config) {
+ checkWidget();
+ this.data = data;
+ this.config = config;
+ this.renderer.render(data, config);
+ }
+}
diff --git a/src/swt/de/linearbits/jhc/package-info.java b/src/swt/de/linearbits/jhc/package-info.java
new file mode 100644
index 0000000..3ddefdd
--- /dev/null
+++ b/src/swt/de/linearbits/jhc/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * JHC - Java Heatmap Control
+ * Copyright (C) 2014 Fabian Prasser
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program. If not, see .
+ */
+
+/**
+ * This package provides a heatmap widget for SWT
+ *
+ * @author Fabian Prasser
+ */
+package de.linearbits.jhc;
\ No newline at end of file