Package totalcross.ui.chart
Class Chart
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.chart.Chart
-
- Direct Known Subclasses:
ArcChart,ColumnChart,PieChart,PointLineChart
public class Chart extends Control
The base class of all chart class.- Since:
- TotalCross 1.0
- See Also:
ColumnChart,LineChart,PieChart,XYChart
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
Fields Modifier and Type Field Description intaxisBackColorColor used in the axis lines.intaxisForeColorColor used in the axis lines.intaxisTextColor used in the axis text (x,y values).InsetsborderThis chart's empty border dimensionsintcategoryMarkColorThe color for the category mark.intcategoryMarkIndexThe index where the category mark is shown.protected RectclientRectstatic intCOLOR1Sample gray color to be used in the chart, taken from here.static intCOLOR2Sample blue color to be used in the chart, taken from here.static intCOLOR3Sample orange color to be used in the chart, taken from here.static intCOLOR4Sample green color to be used in the chart, taken from here.static intCOLOR5Sample pink color to be used in the chart, taken from here.static intCOLOR6Sample brown color to be used in the chart, taken from here.static intCOLOR7Sample purple color to be used in the chart, taken from here.static intCOLOR8Sample yellow color to be used in the chart, taken from here.static intCOLOR9Sample red color to be used in the chart, taken from here.intcolumnWprotected booleandrawAxisFlag that indicates if the axis must be drawn.intfillColor2static intGRADIENT_DARKIndicates a dark gradient.static intGRADIENT_HORIZONTALIndicates a horizontal gradient.static intGRADIENT_INVERTIndicates to invert the gradient direction.static intGRADIENT_VERTICALIndicates a vertical gradient.static intIS_3DIndicates a 3D chart.intlegendPerspectivePerspective distance for the Legend.intlegendPositionThe position of the legend.intlegendTextColorThe text color for the legend.protected java.lang.String[]legendValuesValues that may be shown with the legend.booleanonlyShowCategoriesVectorseriesThe series that are currently added to this chartbooleanshowCategoriesFlag to indicate whether the categories must be paintedbooleanshowCategoriesOnTickFlag to indicate whether the categories must be painted on the next tick.
The fieldshowCategoriesmust also be set to true.
Special values for categories on tick: "|" - Paints a line using the axis fore color.booleanshowFirstYValueShows the first y value or not.booleanshowHGridsFlag to indicate whether the Y grids must be paintedbooleanshowLegendFlag to indicate whether the legend must be paintedjava.lang.BooleanshowTextBoxFlag to indicate whether the textbox must be paintedbooleanshowTitleFlag to indicate whether the title must be paintedbooleanshowVGridsFlag to indicate whether the X grids must be paintedbooleanshowYValuesFlag to indicate whether the y values must be paintedbooleansnapToBottomSet to true to let a ChartData be snapped at the bottom.booleansnapToTopSet to true to let a ChartData be snapped at the top.protected java.lang.StringtitleThis chart's titleinttypeThe chart type.static intUNSETintuse2ndColorEveryXColumnsprotected java.lang.String[]xAxisCategoriesThe categories of the X axis (may be null if X is a value axis)doublexAxisMaxValueThe value for the end of the X axisdoublexAxisMinValueThe value for the origin of the X axisintxAxisStepsThe number of subdivisions of the X axisintxAxisX1The relative screen position of the X axis originintxAxisX2The relative screen position of the X axis endintxDecimalPlacesThe number of decimal places to show the data of the X axis.protected doubleyAxisMaxValueThe value for the end of the Y axisprotected doubleyAxisMinValueThe value for the origin of the Y axisprotected intyAxisStepsThe number of subdivisions of the Y axisintyAxisY1The relative screen position of the Y axis originintyAxisY2The relative screen position of the Y axis endintyDecimalPlacesThe number of decimal places to show the data of the Y axis.intyValuesSizeDefines a value that will be used as the y-value width.-
Fields inherited from class totalcross.ui.Control
AFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, DP, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, floating, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, next, nextTabControl, npParts, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, prev, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, SETX_NOT_SET, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y
-
-
Constructor Summary
Constructors Constructor Description Chart()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleandraw(Graphics g)Draws the chart's basic features.protected voiddrawTextBox(Graphics g, int refX, int refY, java.lang.String text)Draws a box to display a text in the chart areaprotected voiddrawTextBox(Graphics g, int refX, int refY, java.lang.String text, int back)protected voidgetCustomInsets(Insets r)java.lang.StringgetTitle()intgetXValuePos(double value)Calculates the screen position of a value in the X axis according to its current minimum and maximum values.intgetYValuePos(double value)Calculates the screen position of a value in the Y axis according to its current minimum and maximum values.voidsetTitle(java.lang.String title)Sets this chart's titlevoidsetXAxis(double min, double max, int steps)Sets the X axis as a value axis given the minimum (its origin) and the maximum values to be usedvoidsetXAxis(java.lang.String[] categories)Sets the X axis as a category axisvoidsetYAxis(double min, double max, int steps)Sets the Y axis given the minimum (its origin) and the maximum values to be used-
Methods inherited from class totalcross.ui.Control
_onEvent, addEnabledStateListener, addFocusListener, addFontChangeHandler, addGridListener, addHandler, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addSizeChangeHandler, addTimer, addTimer, addTimerListener, addValueChangeHandler, addWindowListener, bringToFront, changeHighlighted, clear, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPreferredHeight, getPreferredWidth, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onBoundsChanged, onColorsChanged, onEvent, onFontChanged, onPaint, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setEnabled, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
-
-
-
-
Field Detail
-
COLOR1
public static final int COLOR1
Sample gray color to be used in the chart, taken from here.- See Also:
- Constant Field Values
-
COLOR2
public static final int COLOR2
Sample blue color to be used in the chart, taken from here.- See Also:
- Constant Field Values
-
COLOR3
public static final int COLOR3
Sample orange color to be used in the chart, taken from here.- See Also:
- Constant Field Values
-
COLOR4
public static final int COLOR4
Sample green color to be used in the chart, taken from here.- See Also:
- Constant Field Values
-
COLOR5
public static final int COLOR5
Sample pink color to be used in the chart, taken from here.- See Also:
- Constant Field Values
-
COLOR6
public static final int COLOR6
Sample brown color to be used in the chart, taken from here.- See Also:
- Constant Field Values
-
COLOR7
public static final int COLOR7
Sample purple color to be used in the chart, taken from here.- See Also:
- Constant Field Values
-
COLOR8
public static final int COLOR8
Sample yellow color to be used in the chart, taken from here.- See Also:
- Constant Field Values
-
COLOR9
public static final int COLOR9
Sample red color to be used in the chart, taken from here.- See Also:
- Constant Field Values
-
IS_3D
public static final int IS_3D
Indicates a 3D chart. Default is 2D.- See Also:
type, Constant Field Values
-
GRADIENT_HORIZONTAL
public static final int GRADIENT_HORIZONTAL
Indicates a horizontal gradient.- See Also:
type, Constant Field Values
-
GRADIENT_VERTICAL
public static final int GRADIENT_VERTICAL
Indicates a vertical gradient.- See Also:
type, Constant Field Values
-
GRADIENT_DARK
public static final int GRADIENT_DARK
Indicates a dark gradient. The default is a bright gradient.- See Also:
type, Constant Field Values
-
GRADIENT_INVERT
public static final int GRADIENT_INVERT
Indicates to invert the gradient direction.- See Also:
type, Constant Field Values
-
type
public int type
The chart type. The values can be OR'ed together. It applies to Column and Pie charts. For example:chart.type = Chart.IS_3D | Chart.GRADIENT_HORIZONTAL | Chart.GRADIENT_DARK;
- See Also:
IS_3D,GRADIENT_HORIZONTAL,GRADIENT_VERTICAL,GRADIENT_DARK,GRADIENT_INVERT
-
title
protected java.lang.String title
This chart's title
-
series
public Vector series
The series that are currently added to this chart
-
xAxisMinValue
public double xAxisMinValue
The value for the origin of the X axis
-
xAxisMaxValue
public double xAxisMaxValue
The value for the end of the X axis
-
xAxisSteps
public int xAxisSteps
The number of subdivisions of the X axis
-
xAxisCategories
protected java.lang.String[] xAxisCategories
The categories of the X axis (may be null if X is a value axis)
-
yAxisMinValue
protected double yAxisMinValue
The value for the origin of the Y axis
-
yAxisMaxValue
protected double yAxisMaxValue
The value for the end of the Y axis
-
yAxisSteps
protected int yAxisSteps
The number of subdivisions of the Y axis
-
xAxisX1
public int xAxisX1
The relative screen position of the X axis origin
-
xAxisX2
public int xAxisX2
The relative screen position of the X axis end
-
yAxisY1
public int yAxisY1
The relative screen position of the Y axis origin
-
yAxisY2
public int yAxisY2
The relative screen position of the Y axis end
-
border
public Insets border
This chart's empty border dimensions
-
showTitle
public boolean showTitle
Flag to indicate whether the title must be painted
-
showLegend
public boolean showLegend
Flag to indicate whether the legend must be painted
-
showCategories
public boolean showCategories
Flag to indicate whether the categories must be painted
-
showTextBox
public java.lang.Boolean showTextBox
Flag to indicate whether the textbox must be painted
-
showCategoriesOnTick
public boolean showCategoriesOnTick
Flag to indicate whether the categories must be painted on the next tick.
The fieldshowCategoriesmust also be set to true.
Special values for categories on tick:- "|" - Paints a line using the axis fore color.
- ":" - Paints a dotted line using the axis fore and back colors.
- See Also:
showCategories
-
categoryMarkIndex
public int categoryMarkIndex
The index where the category mark is shown.
-
categoryMarkColor
public int categoryMarkColor
The color for the category mark.
-
showYValues
public boolean showYValues
Flag to indicate whether the y values must be painted
-
showVGrids
public boolean showVGrids
Flag to indicate whether the X grids must be painted
-
showHGrids
public boolean showHGrids
Flag to indicate whether the Y grids must be painted
-
xDecimalPlaces
public int xDecimalPlaces
The number of decimal places to show the data of the X axis. Defaults to 3.
-
yDecimalPlaces
public int yDecimalPlaces
The number of decimal places to show the data of the Y axis. Defaults to 3.
-
legendPosition
public int legendPosition
The position of the legend. Can be one of: RIGHT (default), LEFT, TOP, BOTTOM.
-
legendPerspective
public int legendPerspective
Perspective distance for the Legend.
-
drawAxis
protected boolean drawAxis
Flag that indicates if the axis must be drawn. Defaults to true.
-
showFirstYValue
public boolean showFirstYValue
Shows the first y value or not.
-
axisForeColor
public int axisForeColor
Color used in the axis lines.
-
axisBackColor
public int axisBackColor
Color used in the axis lines.
-
axisText
public int axisText
Color used in the axis text (x,y values).
-
legendValues
protected java.lang.String[] legendValues
Values that may be shown with the legend.
-
clientRect
protected Rect clientRect
-
snapToBottom
public boolean snapToBottom
Set to true to let a ChartData be snapped at the bottom.
-
snapToTop
public boolean snapToTop
Set to true to let a ChartData be snapped at the top.
-
yValuesSize
public int yValuesSize
Defines a value that will be used as the y-value width.- Since:
- TotalCross 2.0
-
legendTextColor
public int legendTextColor
The text color for the legend.
-
fillColor2
public int fillColor2
-
use2ndColorEveryXColumns
public int use2ndColorEveryXColumns
-
onlyShowCategories
public boolean onlyShowCategories
-
columnW
public int columnW
-
UNSET
public static final int UNSET
- See Also:
- Constant Field Values
-
-
Method Detail
-
setTitle
public void setTitle(java.lang.String title)
Sets this chart's title- Parameters:
title- the new title
-
getTitle
public java.lang.String getTitle()
- Returns:
- this chart's title
-
setXAxis
public void setXAxis(double min, double max, int steps)Sets the X axis as a value axis given the minimum (its origin) and the maximum values to be used- Parameters:
min- the minimum value (the axis origin)max- the maximum value (the axis end)steps- the number of subdivisions of the axis
-
setXAxis
public void setXAxis(java.lang.String[] categories)
Sets the X axis as a category axis- Parameters:
categories- the categories' names
-
setYAxis
public void setYAxis(double min, double max, int steps)Sets the Y axis given the minimum (its origin) and the maximum values to be used- Parameters:
min- the minimum value (the axis origin)max- the maximum value (the axis end)steps- the number of subdivisions of the axis
-
getCustomInsets
protected void getCustomInsets(Insets r)
-
draw
protected boolean draw(Graphics g)
Draws the chart's basic features.- Parameters:
g- The graphics object.
-
drawTextBox
protected void drawTextBox(Graphics g, int refX, int refY, java.lang.String text)
Draws a box to display a text in the chart area- Parameters:
text- the text to be displayedrefX- the X position of the anchor pointrefY- the Y position of the anchor point
-
drawTextBox
protected void drawTextBox(Graphics g, int refX, int refY, java.lang.String text, int back)
-
getXValuePos
public int getXValuePos(double value)
Calculates the screen position of a value in the X axis according to its current minimum and maximum values. This method assumes that the X axis has the same dimensions that it assumed on the last call todraw- Parameters:
value- the value- Returns:
- the screen position of the value
- See Also:
draw(Graphics)
-
getYValuePos
public int getYValuePos(double value)
Calculates the screen position of a value in the Y axis according to its current minimum and maximum values. This method assumes that the Y axis has the same dimensions that it assumed on the last call todraw- Parameters:
value- the value- Returns:
- the screen position of the value
- See Also:
draw(Graphics)
-
-