Class ChartTheme
java.lang.Object
com.codename1.ui.chart.ChartTheme
Colours a chart is painted with. The default palette is the Okabe-Ito set, chosen so
neighbouring series stay distinguishable for the common forms of colour blindness, and
a dark variant is picked automatically when the device is in dark mode.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyUIIDs(UIManager ui) Applies colours a theme sets on the chart's part UIIDs: the foreground ofChartAxiscolours axis labels and lines,ChartGridthe grid lines,ChartLegendthe legend text, and the background and foreground ofChartTooltipthe tooltip.static ChartThemeThe theme for the device's current appearance.static ChartThemeA theme matching a component style: light text means a dark background, whatever the device setting says, so an application with its own dark theme gets light labels.intAxis lines and tick marks.intGrid lines.intThe legend text colour; the secondary text colour unlessChartLegendorsetLegendTextColorsets one.intFalling candles, negative waterfall steps.intRising candles, positive waterfall steps.intAxis tick labels and the legend.intgetSeriesColor(int index) The colour assigned to the series atindex, cycling through the palette.intLabels and titles.intTooltip fill.intTooltip text.booleanisDark()True for a theme meant for a dark background.setAxisColor(int c) Sets the axis line colour.setGridColor(int c) Sets the grid colour.setLegendTextColor(int c) Sets the legend text colour.setNegativeColor(int c) Sets the falling colour.setPalette(int... colors) Replaces the series palette.setPositiveColor(int c) Sets the rising colour.setSecondaryTextColor(int c) Sets the tick label colour.setTextColor(int c) Sets the label colour.setTooltipBackground(int c) Sets the tooltip fill.setTooltipText(int c) Sets the tooltip text colour.inttint(int rgb, float amount) A tint ofrgbfor nested levels: lighter on a light theme, darker on a dark one.
-
Constructor Details
-
ChartTheme
public ChartTheme(boolean dark) Creates the light or dark default theme.
Parameters
dark: true for colours suited to a dark background
-
-
Method Details
-
createDefault
The theme for the device's current appearance. -
fromStyle
A theme matching a component style: light text means a dark background, whatever the device setting says, so an application with its own dark theme gets light labels.
Parameters
style: the chart's style; its foreground colour becomes the label colour
Returns
the derived theme
-
applyUIIDs
Applies colours a theme sets on the chart's part UIIDs: the foreground of
ChartAxiscolours axis labels and lines,ChartGridthe grid lines,ChartLegendthe legend text, and the background and foreground ofChartTooltipthe tooltip. A UIID the theme leaves out keeps the palette's colour.Parameters
ui: the UI manager to read the styles from
Returns
this theme
-
getLegendTextColor
public int getLegendTextColor()The legend text colour; the secondary text colour unlessChartLegendorsetLegendTextColorsets one. -
setLegendTextColor
Sets the legend text colour.
Parameters
c: an RGB colour
Returns
this theme
-
isDark
public boolean isDark()True for a theme meant for a dark background. -
tint
public int tint(int rgb, float amount) A tint of
rgbfor nested levels: lighter on a light theme, darker on a dark one.Parameters
-
rgb: the base colour -
amount: 0 for the colour itself, towards 1 for the background
Returns
the tint
-
-
getSeriesColor
public int getSeriesColor(int index) The colour assigned to the series atindex, cycling through the palette. -
setPalette
Replaces the series palette. -
getTextColor
public int getTextColor()Labels and titles. -
setTextColor
Sets the label colour. -
getSecondaryTextColor
public int getSecondaryTextColor()Axis tick labels and the legend. -
setSecondaryTextColor
Sets the tick label colour. -
getGridColor
public int getGridColor()Grid lines. -
setGridColor
Sets the grid colour. -
getAxisColor
public int getAxisColor()Axis lines and tick marks. -
setAxisColor
Sets the axis line colour. -
getTooltipBackground
public int getTooltipBackground()Tooltip fill. -
setTooltipBackground
Sets the tooltip fill. -
getTooltipText
public int getTooltipText()Tooltip text. -
setTooltipText
Sets the tooltip text colour. -
getPositiveColor
public int getPositiveColor()Rising candles, positive waterfall steps. -
setPositiveColor
Sets the rising colour. -
getNegativeColor
public int getNegativeColor()Falling candles, negative waterfall steps. -
setNegativeColor
Sets the falling colour.
-