use of com.codename1.charts.models.XYSeries in project CodenameOne by codenameone.
the class XYChart method drawSeries.
/**
* Draws the series.
*
* @param series the series
* @param canvas the canvas
* @param paint the paint object
* @param pointsList the points to be rendered
* @param seriesRenderer the series renderer
* @param yAxisValue the y axis value in pixels
* @param seriesIndex the series index
* @param or the orientation
* @param startIndex the start index of the rendering points
*/
protected void drawSeries(XYSeries series, Canvas canvas, Paint paint, List<Float> pointsList, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, Orientation or, int startIndex) {
BasicStroke stroke = seriesRenderer.getStroke();
int cap = paint.getStrokeCap();
int join = paint.getStrokeJoin();
float miter = paint.getStrokeMiter();
// PathEffect pathEffect = paint.getPathEffect();
Style style = paint.getStyle();
if (stroke != null) {
setStroke(stroke.getCap(), stroke.getJoin(), stroke.getMiter(), Style.FILL_AND_STROKE, paint);
}
// float[] points = MathHelper.getFloats(pointsList);
drawSeries(canvas, paint, pointsList, seriesRenderer, yAxisValue, seriesIndex, startIndex);
drawPoints(canvas, paint, pointsList, seriesRenderer, yAxisValue, seriesIndex, startIndex);
paint.setTextSize(seriesRenderer.getChartValuesTextSize());
if (or == Orientation.HORIZONTAL) {
paint.setTextAlign(Align.CENTER);
} else {
paint.setTextAlign(Align.LEFT);
}
if (seriesRenderer.isDisplayChartValues()) {
paint.setTextAlign(seriesRenderer.getChartValuesTextAlign());
drawChartValuesText(canvas, series, seriesRenderer, paint, pointsList, seriesIndex, startIndex);
}
if (stroke != null) {
setStroke(cap, join, miter, style, paint);
}
}
use of com.codename1.charts.models.XYSeries in project CodenameOne by codenameone.
the class BarChart method drawChartValuesText.
/**
* The graphical representation of the series values as text.
*
* @param canvas the canvas to paint to
* @param series the series to be painted
* @param renderer the series renderer
* @param paint the paint to be used for drawing
* @param points the array of points to be used for drawing the series
* @param seriesIndex the index of the series currently being drawn
* @param startIndex the start index of the rendering points
*/
protected void drawChartValuesText(Canvas canvas, XYSeries series, XYSeriesRenderer renderer, Paint paint, List<Float> points, int seriesIndex, int startIndex) {
int seriesNr = mDataset.getSeriesCount();
int length = points.size();
float halfDiffX = getHalfDiffX(points, length, seriesNr);
for (int i = 0; i < length; i += 2) {
int index = startIndex + i / 2;
double value = series.getY(index);
if (!isNullValue(value)) {
float x = points.get(i);
if (mType == Type.DEFAULT) {
x += seriesIndex * 2 * halfDiffX - (seriesNr - 1.5f) * halfDiffX;
}
if (value >= 0) {
drawText(canvas, getLabel(renderer.getChartValuesFormat(), value), x, points.get(i + 1) - renderer.getChartValuesSpacing(), paint, 0);
} else {
drawText(canvas, getLabel(renderer.getChartValuesFormat(), value), x, points.get(i + 1) + renderer.getChartValuesTextSize() + renderer.getChartValuesSpacing() - 3, paint, 0);
}
}
}
}
use of com.codename1.charts.models.XYSeries in project CodenameOne by codenameone.
the class XYMultiSeriesTransition method getBuffer.
/**
* Gets the buffer/cache for values. Values set in the buffer will be applied
* to the target dataset when the transition takes place.
* @return
*/
public XYMultipleSeriesDataset getBuffer() {
if (datasetCache == null) {
datasetCache = new XYMultipleSeriesDataset();
for (int i = 0; i < dataset.getSeriesCount(); i++) {
datasetCache.addSeries(new XYSeries(dataset.getSeriesAt(i).getTitle()));
}
seriesTransitions = new XYSeriesTransition[dataset.getSeries().length];
int tlen = seriesTransitions.length;
for (int i = 0; i < tlen; i++) {
seriesTransitions[i] = new XYSeriesTransition(getChart(), dataset.getSeriesAt(i));
seriesTransitions[i].setBuffer(datasetCache.getSeriesAt(i));
}
}
return datasetCache;
}
Aggregations