Class ChartElement
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringFilled areas under lines.static final StringHorizontal bars.static final StringVertical bars (OOXML's column chart).static final StringA pie with a hole.final StringThe kind, one of the constants.final booleanTrue when a legend is shown.static final StringLines.static final StringA pie of the first series.static final StringA radar (spider) chart.static final StringPoints: the categories, read as numbers, are x and every series is y; seexValues().final booleanTrue when bars or areas of different series stack.final StringThe title, or null. -
Constructor Summary
ConstructorsConstructorDescriptionChartElement(String id, String kind, float x, float y, float width, float height, String[] categories, String[] seriesNames, double[][] values) A chart.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. -
Method Summary
Modifier and TypeMethodDescriptioncategory(int i) A category label.intThe number of categories.booleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for the object.The text of the element for search, outlines and screen readers.intseriesColor(int i) The color of a series, or -1 when the chart theme picks it.intThe number of series.seriesName(int i) A series name.toChart()A liveChartcomponent showing this data.double[]values(int i) A copy of one series' values.withColors(int[] value) This chart with series colors.This chart with other data.This element with another id, for copies.This chart as another kind.withStacked(boolean value) This chart stacked or side by side.This chart with a title.withTransform(float nx, float ny, float nw, float nh, float rot, boolean fh, boolean fv) This element moved, resized, rotated or flipped.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...Methods inherited from class SlideElement
contains, frameHash, sameFrame, withBounds, withRotation
-
Field Details
-
COLUMN
-
BAR
-
LINE
-
AREA
-
PIE
-
DOUGHNUT
-
SCATTER
-
RADAR
-
kind
The kind, one of the constants. -
title
The title, or null. -
stacked
public final boolean stackedTrue when bars or areas of different series stack. -
legend
public final boolean legendTrue when a legend is shown.
-
-
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
A category label.
Parameters
i: the index
Returns
the label
-
seriesCount
public int seriesCount()The number of series.
Returns
the count
-
seriesName
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
This chart with other data.
Parameters
-
cats: categories -
names: series names -
data: one row per series
Returns
the chart
-
-
withKind
This chart as another kind.
Parameters
value: one of the kind constants
Returns
the chart
-
withTitle
This chart with a title.
Parameters
value: the title, or null
Returns
the chart
-
withStacked
This chart stacked or side by side.
Parameters
value: true to stack
Returns
the chart
-
withColors
This chart with series colors.
Parameters
value: 0xRRGGBB per series, or null
Returns
the chart
-
toChart
A live
Chartcomponent 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:SlideElementThis 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:
withTransformin classSlideElement
-
-
withId
Description copied from class:SlideElementThis element with another id, for copies.
Parameters
value: the id
Returns
the element
- Specified by:
withIdin classSlideElement
-
plainText
Description copied from class:SlideElementThe text of the element for search, outlines and screen readers.
Returns
the text, empty when there is none
- Overrides:
plainTextin classSlideElement
-
equals
Description copied from class:ObjectIndicates 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). -
hashCode
public int hashCode()Description copied from class:ObjectReturns 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.)
-