Class ChartTheme

java.lang.Object
com.codename1.ui.chart.ChartTheme

public class ChartTheme extends Object
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 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

      public static ChartTheme createDefault()
      The theme for the device's current appearance.
    • fromStyle

      public static ChartTheme fromStyle(Style style)

      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

      public ChartTheme applyUIIDs(UIManager ui)

      Applies colours a theme sets on the chart's part UIIDs: the foreground of ChartAxis colours axis labels and lines, ChartGrid the grid lines, ChartLegend the legend text, and the background and foreground of ChartTooltip the 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 unless ChartLegend or setLegendTextColor sets one.
    • setLegendTextColor

      public ChartTheme setLegendTextColor(int c)

      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 rgb for 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 at index, cycling through the palette.
    • setPalette

      public ChartTheme setPalette(int... colors)
      Replaces the series palette.
    • getTextColor

      public int getTextColor()
      Labels and titles.
    • setTextColor

      public ChartTheme setTextColor(int c)
      Sets the label colour.
    • getSecondaryTextColor

      public int getSecondaryTextColor()
      Axis tick labels and the legend.
    • setSecondaryTextColor

      public ChartTheme setSecondaryTextColor(int c)
      Sets the tick label colour.
    • getGridColor

      public int getGridColor()
      Grid lines.
    • setGridColor

      public ChartTheme setGridColor(int c)
      Sets the grid colour.
    • getAxisColor

      public int getAxisColor()
      Axis lines and tick marks.
    • setAxisColor

      public ChartTheme setAxisColor(int c)
      Sets the axis line colour.
    • getTooltipBackground

      public int getTooltipBackground()
      Tooltip fill.
    • setTooltipBackground

      public ChartTheme setTooltipBackground(int c)
      Sets the tooltip fill.
    • getTooltipText

      public int getTooltipText()
      Tooltip text.
    • setTooltipText

      public ChartTheme setTooltipText(int c)
      Sets the tooltip text colour.
    • getPositiveColor

      public int getPositiveColor()
      Rising candles, positive waterfall steps.
    • setPositiveColor

      public ChartTheme setPositiveColor(int c)
      Sets the rising colour.
    • getNegativeColor

      public int getNegativeColor()
      Falling candles, negative waterfall steps.
    • setNegativeColor

      public ChartTheme setNegativeColor(int c)
      Sets the falling colour.