Package totalcross.ui.chart
Class ChartData
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.Container
-
- totalcross.ui.chart.ChartData
-
public class ChartData extends Container
The ChartData class represents a table with data that would be displayed in the chart. Here's a sample:double[] xAxis = new double[0]; double[] pressureyAxis = new double[0]; Series pressureSeries = new Series("Pression", xAxis, pressureyAxis, Color.BLUE); int cols = 24, rows = 5; XYChart chart = new XYChart(); chart.showHGrids = chart.showVGrids = true; // Shows grids. chart.showTitle = true; // Shows title. chart.showYValues = true; // Shows the Y axis values. chart.yDecimalPlaces = 0; // No decimal places. chart.setXAxis(0, 240, 24); // The X axis is time in minutes. It has an interval of 5 minutes and a maximum of 2 hours. chart.setYAxis(0, 240, 24); // The Y axis is different for each graph. chart.snapToTop = chart.snapToBottom = true; String[][] data = new String[rows][cols]; String[] tit = new String[rows]; for (int r = 0; r < rows; r++) { tit[r] = "row "+(r+1); for (int c = 0; c < cols; c++) data[r][c] = "999"; } ChartData cd1 = new ChartData(chart, tit, data); cd1.lineColor = Color.BLACK; cd1.setFont(font.adjustedBy(-2)); cd1.snapToTop = true; ChartData cd2 = new ChartData(chart, data); cd2.lineColor = Color.BLACK; cd2.setFont(font.adjustedBy(-2)); cd2.snapToBottom = true; add(cd1,LEFT,TOP+25,FILL,PREFERRED); add(cd2,LEFT,BOTTOM-25,FILL,PREFERRED); add(chart,LEFT,AFTER,FILL,FIT,cd1); cd2.bringToFront(); cd1.bringToFront(); chart.showLines = false; chart.yValuesSize = fm.stringWidth("99999"); chart.series.addElement(pressureSeries); // setup the xy chart pressureSeries.xValues = new double[]{10,20,30,40,50}; pressureSeries.yValues = new double[]{10,20,30,40,35}; try { pressureSeries.dot = Resources.radioBkg.getNormalInstance(fmH,fmH,-1); } catch (ImageException e) { MessageBox.showException(e, true); } cd2.reposition();- Since:
- TotalCross 2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classChartData.ChartDataRow-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
Fields Modifier and Type Field Description protected ChartchartintfillColor2intlineColorintpreferredCellHeightThe height of the cell when using PREFERRED, defined as a % of the control's font height.intselectedColintselectedRowbooleansnapToBottombooleansnapToTopinttitleBackColorinttitleForeColorintuse2ndColorEveryXColumns-
Fields inherited from class totalcross.ui.Container
alwaysEraseBackground, BACKGROUND_CYLINDRIC_SHADED, BACKGROUND_SHADED, BACKGROUND_SHADED_INV, BACKGROUND_SOLID, backgroundStyle, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_ROUNDED, BORDER_SIMPLE, BORDER_TOP, borderColor, borderRadius, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, lastX, lastY, npback, numChildren, started, tabOrder, tail, TRANSITION_TIME
-
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 ChartData(Chart chart)Constructs an empty ChartData.ChartData(Chart chart, ChartData.ChartDataRow[] data)Constructs a ChartData with the given data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLine(int pos, ChartData.ChartDataRow row)Adds a new row.Properties.ValuegetCell(int col, int row)intgetPreferredHeight()Returns the preferred height of this control.ChartData.ChartDataRowgetRow(int row)Properties.ValuegetSelectedCell()ChartData.ChartDataRowgetSelectedRow()voidonEvent(Event e)Called to process key, pen, control and other posted events.voidonPaint(Graphics g)Draws the border (if any).voidremoveLine(int pos)voidremoveLine(java.lang.String title)voidreposition()Reposition this control, calling again setRect with the original parameters.voidsetCell(Properties.Value value, int col, int row)-
Methods inherited from class totalcross.ui.Container
add, add, add, add, add, broadcastEvent, clear, fillBackground, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderRadius, getBorderStyle, getChildren, getChildrenCount, getClientRect, getClientRect, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, initUI, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onColorsChanged, onRemove, onSwapFinished, paintChildren, remove, removeAll, resize, resizeHeight, resizeWidth, setBorderRadius, setBorderStyle, setEnabled, setFocusTraversable, setHighlighting, setInsets, setPressColor, setPressed, swapToTopmostWindow
-
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, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, 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, onFontChanged, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
-
-
-
-
Field Detail
-
chart
protected Chart chart
-
lineColor
public int lineColor
-
fillColor2
public int fillColor2
-
titleForeColor
public int titleForeColor
-
titleBackColor
public int titleBackColor
-
selectedCol
public int selectedCol
-
selectedRow
public int selectedRow
-
snapToTop
public boolean snapToTop
-
snapToBottom
public boolean snapToBottom
-
use2ndColorEveryXColumns
public int use2ndColorEveryXColumns
-
preferredCellHeight
public int preferredCellHeight
The height of the cell when using PREFERRED, defined as a % of the control's font height. Default value is 100(%).
-
-
Constructor Detail
-
ChartData
public ChartData(Chart chart)
Constructs an empty ChartData.
-
ChartData
public ChartData(Chart chart, ChartData.ChartDataRow[] data)
Constructs a ChartData with the given data.- Parameters:
data- The values to be displayed in the format [rows][cols]
-
-
Method Detail
-
onPaint
public void onPaint(Graphics g)
Description copied from class:ContainerDraws the border (if any). If you override this method, be sure to callsuper.onPaint(g);, or the border will not be drawn.
-
onEvent
public void onEvent(Event e)
Description copied from class:ControlCalled to process key, pen, control and other posted events.
-
reposition
public void reposition()
Description copied from class:ControlReposition this control, calling again setRect with the original parameters.- Overrides:
repositionin classControl
-
getPreferredHeight
public int getPreferredHeight()
Description copied from class:ControlReturns the preferred height of this control.- Overrides:
getPreferredHeightin classControl
-
getSelectedCell
public Properties.Value getSelectedCell()
-
getCell
public Properties.Value getCell(int col, int row)
-
setCell
public void setCell(Properties.Value value, int col, int row)
-
getRow
public ChartData.ChartDataRow getRow(int row)
-
getSelectedRow
public ChartData.ChartDataRow getSelectedRow()
-
addLine
public void addLine(int pos, ChartData.ChartDataRow row)Adds a new row. Pass -1 to add at the end
-
removeLine
public void removeLine(int pos)
-
removeLine
public void removeLine(java.lang.String title)
-
-