Package no.uib.jsparklines.renderers
Class JSparklinesArrayListBarChartTableCellRenderer
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
no.uib.jsparklines.renderers.JSparklinesArrayListBarChartTableCellRenderer
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,SwingConstants
,TableCellRenderer
public class JSparklinesArrayListBarChartTableCellRenderer extends JLabel implements TableCellRenderer
Table cell renderer displaying JSparklines plots consisting of numbers as a
stacked bar chart. Supported input: ArrrayListDataPoints objects. Other
object types are rendered using the DefaultTableCellRenderer.
- Author:
- Harald Barsnes
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType
List of supported value display options.Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
-
Constructor Summary
Constructors Constructor Description JSparklinesArrayListBarChartTableCellRenderer(org.jfree.chart.plot.PlotOrientation plotOrientation, Double maxValue, ArrayList<Color> colors, boolean showFirstNumber)
Deprecated.use the constructor with the ValueDisplayType insteadJSparklinesArrayListBarChartTableCellRenderer(org.jfree.chart.plot.PlotOrientation plotOrientation, Double maxValue, ArrayList<Color> colors, Color fillColor, boolean showFirstNumber)
Deprecated.use the constructor with the ValueDisplayType insteadJSparklinesArrayListBarChartTableCellRenderer(org.jfree.chart.plot.PlotOrientation plotOrientation, Double maxValue, ArrayList<Color> colors, Color fillColor, JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType valueDisplayType)
Creates a new JSparkLinesTableCellRenderer.JSparklinesArrayListBarChartTableCellRenderer(org.jfree.chart.plot.PlotOrientation plotOrientation, Double maxValue, ArrayList<Color> colors, JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType valueDisplayType)
Creates a new JSparkLinesTableCellRenderer. -
Method Summary
Modifier and Type Method Description void
addReferenceArea(String label, double start, double end, Color areaColor, float alpha)
Add a reference area.void
addReferenceArea(ReferenceArea referenceArea)
Add a reference area.void
addReferenceLine(String label, double value, float lineWidth, Color lineColor)
Add a reference line at a given data value.void
addReferenceLine(ReferenceLine referenceLine)
Add a reference line at a given data value.HashMap<String,ReferenceArea>
getAllReferenceAreas()
Returns all the references areas as a hashmap, with the labels as the keys.HashMap<String,ReferenceLine>
getAllReferenceLines()
Returns all the references lines as a hashmap, with the labels as the keys.org.jfree.chart.ChartPanel
getChartPanel()
Returns a reference to the chart panel.ArrayList<Color>
getColors()
Get the colors used for the chart.double
getMaxValue()
Returns the maximum value.org.jfree.chart.plot.PlotOrientation
getPlotOrientation()
Get the current plot orientation.Component
getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
void
removeAllReferenceAreas()
Removes all the reference areas.void
removeAllReferenceLines()
Removes all the reference lines.void
removeReferenceArea(String label)
Removes the reference area with the given label.void
removeReferenceLine(String label)
Removes the reference line with the given label.void
setBackgroundColor(Color color)
Set the background color.void
setColors(ArrayList<Color> colors)
Set the colors used for the chart.void
setMaxValue(double maxValue)
Set the maximum value.void
setPlotOrientation(org.jfree.chart.plot.PlotOrientation plotOrientation)
Set the plot orientation.void
setValueDisplayType(JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType valueDisplayType)
Set the current value display type.void
showFirstNumber(boolean showFirstNumber)
Deprecated.use the ValueDisplayType enum insteadvoid
showNumberAndChart(boolean showNumberAndChart, int widthOfLabel)
If true the number will be shown together with the bar chart in the cell.void
showNumberAndChart(boolean showNumberAndChart, int widthOfLabel, Font font, int horizontalAlignement)
If true the number will be shown together with the bar chart in the cell.void
showNumberAndChart(boolean showNumberAndChart, int widthOfLabel, Font font, int horizontalAlignement, DecimalFormat numberFormat)
If true the number will be shown together with the bar chart in the cell.void
showNumberAndChart(boolean showNumberAndChart, int widthOfLabel, DecimalFormat numberFormat)
If true the number will be shown together with the bar chart in the cell.void
showNumbers(boolean showNumbers)
Set if the underlying numbers or the bar charts are to be shown.Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
JSparklinesArrayListBarChartTableCellRenderer
public JSparklinesArrayListBarChartTableCellRenderer(org.jfree.chart.plot.PlotOrientation plotOrientation, Double maxValue, ArrayList<Color> colors, JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType valueDisplayType)Creates a new JSparkLinesTableCellRenderer.- Parameters:
plotOrientation
- the orientation of the plotmaxValue
- the maximum value to be plotted, used to make sure that all plots in the same column has the same maximum value and are thus comparablecolors
- the colors to use for the plotvalueDisplayType
- the value to display in the table
-
JSparklinesArrayListBarChartTableCellRenderer
public JSparklinesArrayListBarChartTableCellRenderer(org.jfree.chart.plot.PlotOrientation plotOrientation, Double maxValue, ArrayList<Color> colors, Color fillColor, JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType valueDisplayType)Creates a new JSparkLinesTableCellRenderer.- Parameters:
plotOrientation
- the orientation of the plotmaxValue
- the maximum value to be plotted, used to make sure that all plots in the same column has the same maximum value and are thus comparablecolors
- the colors to use for the plotfillColor
- the color used to fill the rest of the chart up to the max value (set to null if no filling should be used)valueDisplayType
- the value to display in the table
-
JSparklinesArrayListBarChartTableCellRenderer
@Deprecated public JSparklinesArrayListBarChartTableCellRenderer(org.jfree.chart.plot.PlotOrientation plotOrientation, Double maxValue, ArrayList<Color> colors, boolean showFirstNumber)Deprecated.use the constructor with the ValueDisplayType insteadCreates a new JSparkLinesTableCellRenderer.- Parameters:
plotOrientation
- the orientation of the plotmaxValue
- the maximum value to be plotted, used to make sure that all plots in the same column has the same maximum value and are thus comparablecolors
- the colors to use for the plotshowFirstNumber
- if true, the first value is shown when showing the values, false shows the sum
-
JSparklinesArrayListBarChartTableCellRenderer
@Deprecated public JSparklinesArrayListBarChartTableCellRenderer(org.jfree.chart.plot.PlotOrientation plotOrientation, Double maxValue, ArrayList<Color> colors, Color fillColor, boolean showFirstNumber)Deprecated.use the constructor with the ValueDisplayType insteadCreates a new JSparkLinesTableCellRenderer.- Parameters:
plotOrientation
- the orientation of the plotmaxValue
- the maximum value to be plotted, used to make sure that all plots in the same column has the same maximum value and are thus comparablecolors
- the colors to use for the plotfillColor
- the color used to fill the rest of the chart up to the max value (set to null if no filling should be used)showFirstNumber
- if true, the first value is shown when showing the values, false shows the sum
-
-
Method Details
-
showNumberAndChart
public void showNumberAndChart(boolean showNumberAndChart, int widthOfLabel)If true the number will be shown together with the bar chart in the cell. False only display the chart.- Parameters:
showNumberAndChart
- if true the number and the chart is shown in the cellwidthOfLabel
- the width used to display the label containing the number
-
showNumberAndChart
public void showNumberAndChart(boolean showNumberAndChart, int widthOfLabel, DecimalFormat numberFormat)If true the number will be shown together with the bar chart in the cell. False only display the chart.- Parameters:
showNumberAndChart
- if true the number and the chart is shown in the cellwidthOfLabel
- the width used to display the label containing the numbernumberFormat
- the decimal format to use when showing the numbers
-
showNumberAndChart
public void showNumberAndChart(boolean showNumberAndChart, int widthOfLabel, Font font, int horizontalAlignement)If true the number will be shown together with the bar chart in the cell. False only display the chart.- Parameters:
showNumberAndChart
- if true the number and the chart is shown in the cellwidthOfLabel
- the width used to display the label containing the numberfont
- the font to use for the labelhorizontalAlignement
- the horizontal alignment of the text in the label: one of the following constants defined in SwingConstants: LEFT, CENTER, RIGHT, LEADING or TRAILING.
-
showNumberAndChart
public void showNumberAndChart(boolean showNumberAndChart, int widthOfLabel, Font font, int horizontalAlignement, DecimalFormat numberFormat)If true the number will be shown together with the bar chart in the cell. False only display the chart.- Parameters:
showNumberAndChart
- if true the number and the chart is shown in the cellwidthOfLabel
- the width used to display the label containing the numberfont
- the font to use for the labelhorizontalAlignement
- the horizontal alignment of the text in the label: one of the following constants defined in SwingConstants: LEFT, CENTER, RIGHT, LEADING or TRAILING.numberFormat
- the decimal format to use when showing the numbers
-
showNumbers
public void showNumbers(boolean showNumbers)Set if the underlying numbers or the bar charts are to be shown.- Parameters:
showNumbers
- if true the underlying numbers are shown
-
showFirstNumber
Deprecated.use the ValueDisplayType enum insteadIf true, the first number is shown as the value. Otherwise the total value is shown.- Parameters:
showFirstNumber
- the showFirstNumber to set
-
setValueDisplayType
public void setValueDisplayType(JSparklinesArrayListBarChartTableCellRenderer.ValueDisplayType valueDisplayType)Set the current value display type.- Parameters:
valueDisplayType
- the value display type
-
getTableCellRendererComponent
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)- Specified by:
getTableCellRendererComponent
in interfaceTableCellRenderer
-
addReferenceLine
Add a reference line at a given data value.- Parameters:
label
- the label for the referencevalue
- the reference line valuelineWidth
- the line width, has to non-negativelineColor
- the line color
-
addReferenceLine
Add a reference line at a given data value.- Parameters:
referenceLine
- the reference line
-
removeReferenceLine
Removes the reference line with the given label. Does nothing if no reference with the given label is found.- Parameters:
label
- the reference to remove
-
removeAllReferenceLines
public void removeAllReferenceLines()Removes all the reference lines. -
getAllReferenceLines
Returns all the references lines as a hashmap, with the labels as the keys.- Returns:
- hashmap of all reference lines
-
addReferenceArea
Add a reference area.- Parameters:
label
- the label for the reference areastart
- the start of the reference areaend
- the end of the reference areaareaColor
- the color of the reference areaalpha
- the alpha level of the reference area, range: 0.0 to 1.0
-
addReferenceArea
Add a reference area.- Parameters:
referenceArea
- the reference area
-
removeReferenceArea
Removes the reference area with the given label. Does nothing if no reference with the given label is found.- Parameters:
label
- the reference to remove
-
removeAllReferenceAreas
public void removeAllReferenceAreas()Removes all the reference areas. -
getAllReferenceAreas
Returns all the references areas as a hashmap, with the labels as the keys.- Returns:
- hashmap of all reference areas
-
setMaxValue
public void setMaxValue(double maxValue)Set the maximum value.- Parameters:
maxValue
- the maximum value
-
getColors
Get the colors used for the chart.- Returns:
- the color used for the chart
-
setColors
Set the colors used for the chart.- Parameters:
colors
- the colors to set
-
getPlotOrientation
public org.jfree.chart.plot.PlotOrientation getPlotOrientation()Get the current plot orientation.- Returns:
- the current plot orientation
-
setPlotOrientation
public void setPlotOrientation(org.jfree.chart.plot.PlotOrientation plotOrientation)Set the plot orientation.- Parameters:
plotOrientation
- the new plot orientation
-
getChartPanel
public org.jfree.chart.ChartPanel getChartPanel()Returns a reference to the chart panel.- Returns:
- the chart panel.
-
setBackgroundColor
Set the background color. If not set the background color of the given row will be used.- Parameters:
color
- the new background color
-
getMaxValue
public double getMaxValue()Returns the maximum value.- Returns:
- the maxValue
-