Class ChartElement

java.lang.Object
com.codename1.presentation.SlideElement
com.codename1.presentation.ChartElement

public final class ChartElement extends SlideElement

A chart on a slide: its data -- categories, named series of values, colors -- and its kind. It is drawn by com.codename1.ui.chart.Chart, so a slide's chart looks like and animates like any other chart in the application, and toChart gives the live, interactive component for a slide show that wants one.

PPTX charts (c:chartSpace) and ODF charts are read into this model; a kind or option the model lacks falls back to the nearest kind.

  • Field Details

  • Constructor Details

    • ChartElement

      public ChartElement(String id, String kind, float x, float y, float width, float height, String[] categories, String[] seriesNames, double[][] values)

      A chart.

      Parameters
      • id: the id

      • kind: one of the kind constants

      • x: left edge in points

      • y: top edge

      • width: width

      • height: height

      • categories: the category labels

      • seriesNames: one name per series

      • values: one row of values per series, one value per category

    • ChartElement

      public ChartElement(String id, String name, String kind, float x, float y, float width, float height, float rotation, String title, boolean stacked, boolean legend, String[] categories, String[] seriesNames, double[][] values, int[] colors)

      A chart with every property.

      Parameters
      • id: the id

      • name: a name, or null

      • kind: one of the kind constants

      • x: left edge

      • y: top edge

      • width: width

      • height: height

      • rotation: degrees clockwise

      • title: the title, or null

      • stacked: whether series stack

      • legend: whether a legend shows

      • categories: the category labels

      • seriesNames: the series names

      • values: one row per series

      • colors: one 0xRRGGBB per series, or null for the chart theme's

  • Method Details

    • xValues

      public double[] xValues()

      The x values of a scatter chart: its categories read as numbers, as PPTX's xVal and ODF's x range hold them, or 1, 2, 3... where a category is not a number.

      Returns

      one x value per category

    • categoryCount

      public int categoryCount()

      The number of categories.

      Returns

      the count

    • category

      public String category(int i)

      A category label.

      Parameters
      • i: the index
      Returns

      the label

    • seriesCount

      public int seriesCount()

      The number of series.

      Returns

      the count

    • seriesName

      public String seriesName(int i)

      A series name.

      Parameters
      • i: the series
      Returns

      the name

    • values

      public double[] values(int i)

      A copy of one series' values.

      Parameters
      • i: the series
      Returns

      the values

    • seriesColor

      public int seriesColor(int i)

      The color of a series, or -1 when the chart theme picks it.

      Parameters
      • i: the series
      Returns

      0xRRGGBB or -1

    • withData

      public ChartElement withData(String[] cats, String[] names, double[][] data)

      This chart with other data.

      Parameters
      • cats: categories

      • names: series names

      • data: one row per series

      Returns

      the chart

    • withKind

      public ChartElement withKind(String value)

      This chart as another kind.

      Parameters
      • value: one of the kind constants
      Returns

      the chart

    • withTitle

      public ChartElement withTitle(String value)

      This chart with a title.

      Parameters
      • value: the title, or null
      Returns

      the chart

    • withStacked

      public ChartElement withStacked(boolean value)

      This chart stacked or side by side.

      Parameters
      • value: true to stack
      Returns

      the chart

    • withColors

      public ChartElement withColors(int[] value)

      This chart with series colors.

      Parameters
      • value: 0xRRGGBB per series, or null
      Returns

      the chart

    • toChart

      public Chart toChart()

      A live Chart component showing this data. Each call makes a new one; a slide show places it over the slide so the audience gets tooltips and the entrance animation.

      Returns

      the chart

    • withTransform

      public SlideElement withTransform(float nx, float ny, float nw, float nh, float rot, boolean fh, boolean fv)
      Description copied from class: SlideElement

      This element moved, resized, rotated or flipped.

      Parameters
      • x: left edge

      • y: top edge

      • width: width

      • height: height

      • rotation: degrees clockwise

      • flipH: mirrored horizontally

      • flipV: mirrored vertically

      Returns

      the changed element

      Specified by:
      withTransform in class SlideElement
    • withId

      public SlideElement withId(String value)
      Description copied from class: SlideElement

      This element with another id, for copies.

      Parameters
      • value: the id
      Returns

      the element

      Specified by:
      withId in class SlideElement
    • plainText

      public String plainText()
      Description copied from class: SlideElement

      The text of the element for search, outlines and screen readers.

      Returns

      the text, empty when there is none

      Overrides:
      plainText in class SlideElement
    • equals

      public boolean equals(Object o)
      Description copied from class: Object
      Indicates whether some other object is "equal to" this one. The equals method implements an equivalence relation: It is reflexive: for any reference value x, x.equals(x) should return true. It is symmetric: for any reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true. It is consistent: for any reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the object is modified. For any non-null reference value x, x.equals(null) should return false. The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any reference values x and y, this method returns true if and only if x and y refer to the same object (x==y has the value true).
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Description copied from class: Object
      Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable. The general contract of hashCode is: Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result. It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables. As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
      Overrides:
      hashCode in class Object