Java源码示例:org.achartengine.model.XYSeries
示例1
protected void drawChartValuesText(Canvas canvas, XYSeries xyseries, SimpleSeriesRenderer simpleseriesrenderer, Paint paint, List list, int i, int j)
{
if (list.size() > 1)
{
float f1 = ((Float)list.get(0)).floatValue();
float f2 = ((Float)list.get(1)).floatValue();
int l = 0;
while (l < list.size())
{
if (l == 2)
{
if (Math.abs(((Float)list.get(2)).floatValue() - ((Float)list.get(0)).floatValue()) > (float)simpleseriesrenderer.getDisplayChartValuesDistance() || Math.abs(((Float)list.get(3)).floatValue() - ((Float)list.get(1)).floatValue()) > (float)simpleseriesrenderer.getDisplayChartValuesDistance())
{
drawText(canvas, getLabel(simpleseriesrenderer.getChartValuesFormat(), xyseries.getY(j)), ((Float)list.get(0)).floatValue(), ((Float)list.get(1)).floatValue() - simpleseriesrenderer.getChartValuesSpacing(), paint, 0.0F);
drawText(canvas, getLabel(simpleseriesrenderer.getChartValuesFormat(), xyseries.getY(j + 1)), ((Float)list.get(2)).floatValue(), ((Float)list.get(3)).floatValue() - simpleseriesrenderer.getChartValuesSpacing(), paint, 0.0F);
f1 = ((Float)list.get(2)).floatValue();
f2 = ((Float)list.get(3)).floatValue();
}
} else
if (l > 2 && (Math.abs(((Float)list.get(l)).floatValue() - f1) > (float)simpleseriesrenderer.getDisplayChartValuesDistance() || Math.abs(((Float)list.get(l + 1)).floatValue() - f2) > (float)simpleseriesrenderer.getDisplayChartValuesDistance()))
{
drawText(canvas, getLabel(simpleseriesrenderer.getChartValuesFormat(), xyseries.getY(j + l / 2)), ((Float)list.get(l)).floatValue(), ((Float)list.get(l + 1)).floatValue() - simpleseriesrenderer.getChartValuesSpacing(), paint, 0.0F);
f1 = ((Float)list.get(l)).floatValue();
f2 = ((Float)list.get(l + 1)).floatValue();
}
l += 2;
}
} else
{
for (int k = 0; k < list.size(); k += 2)
{
drawText(canvas, getLabel(simpleseriesrenderer.getChartValuesFormat(), xyseries.getY(j + k / 2)), ((Float)list.get(k)).floatValue(), ((Float)list.get(k + 1)).floatValue() - simpleseriesrenderer.getChartValuesSpacing(), paint, 0.0F);
}
}
}
示例2
protected void drawChartValuesText(Canvas canvas, XYSeries xyseries, SimpleSeriesRenderer simpleseriesrenderer, Paint paint, List list, int i, int j)
{
int k = mDataset.getSeriesCount();
float f = getHalfDiffX(list, list.size(), k);
byte byte0 = 0;
if (j > 0)
{
byte0 = 2;
}
for (int l = byte0; l < list.size(); l += 4)
{
int i1 = j + l / 2;
float f1 = ((Float)list.get(l)).floatValue();
if (mType == BarChart.Type.DEFAULT)
{
f1 += f * (float)(i * 2) - f * ((float)k - 1.5F);
}
if (!isNullValue(xyseries.getY(i1 + 1)) && list.size() > l + 3)
{
drawText(canvas, getLabel(simpleseriesrenderer.getChartValuesFormat(), xyseries.getY(i1 + 1)), f1, ((Float)list.get(l + 3)).floatValue() - simpleseriesrenderer.getChartValuesSpacing(), paint, 0.0F);
}
if (!isNullValue(xyseries.getY(i1)) && list.size() > l + 1)
{
drawText(canvas, getLabel(simpleseriesrenderer.getChartValuesFormat(), xyseries.getY(i1)), f1, (((Float)list.get(l + 1)).floatValue() + simpleseriesrenderer.getChartValuesTextSize() + simpleseriesrenderer.getChartValuesSpacing()) - 3F, paint, 0.0F);
}
}
}
示例3
protected void drawSeries(XYSeries xyseries, Canvas canvas, Paint paint, List list, SimpleSeriesRenderer simpleseriesrenderer, float f, int i,
org.achartengine.renderer.XYMultipleSeriesRenderer.Orientation orientation, int j)
{
a[i].setScreenR(getScreenR());
a[i].setCalcRange(getCalcRange(mDataset.getSeriesAt(i).getScaleNumber()), 0);
a[i].drawSeries(xyseries, canvas, paint, list, simpleseriesrenderer, f, 0, orientation, j);
}
示例4
protected void drawChartValuesText(Canvas canvas, XYSeries xyseries, SimpleSeriesRenderer simpleseriesrenderer, Paint paint, List list, int i, int j)
{
int k = mDataset.getSeriesCount();
int l = list.size();
float f = getHalfDiffX(list, l, k);
int i1 = 0;
while (i1 < l)
{
double d = xyseries.getY(j + i1 / 2);
if (!isNullValue(d))
{
float f1 = ((Float)list.get(i1)).floatValue();
if (mType == Type.DEFAULT)
{
f1 += f * (float)(i * 2) - f * ((float)k - 1.5F);
}
if (d >= 0.0D)
{
drawText(canvas, getLabel(simpleseriesrenderer.getChartValuesFormat(), d), f1, ((Float)list.get(i1 + 1)).floatValue() - simpleseriesrenderer.getChartValuesSpacing(), paint, 0.0F);
} else
{
drawText(canvas, getLabel(simpleseriesrenderer.getChartValuesFormat(), d), f1, (((Float)list.get(i1 + 1)).floatValue() + simpleseriesrenderer.getChartValuesTextSize() + simpleseriesrenderer.getChartValuesSpacing()) - 3F, paint, 0.0F);
}
}
i1 += 2;
}
}
示例5
@Override
public void pvChanged(PvChangeEvent event)
{
// handle data item updates
if (allowDataUpdates)
{
IndexedProcessVar pv = (IndexedProcessVar) event.getSource();
XYSeries series = (XYSeries) pv.get(FID_DATA_SERIES);
if (series != null)
{
if (event.getValue() instanceof Number)
{
series.add(event.getTime(),
((Number) event.getValue()).doubleValue());
}
}
// send update to plugin handler
if (PluginManager.pluginHandler != null)
{
PluginManager.pluginHandler.sendDataUpdate(
pv.get(EcuDataPv.FID_MNEMONIC).toString(),
event.getValue().toString());
}
}
}
示例6
public void addXYSeries(XYMultipleSeriesDataset dataset, String[] titles, List<double[]> xValues,
List<double[]> yValues, int scale) {
int length = titles.length;
for (int i = 0; i < length; i++) {
XYSeries series = new XYSeries(titles[i], scale);
double[] xV = xValues.get(i);
double[] yV = yValues.get(i);
int seriesLength = xV.length;
for (int k = 0; k < seriesLength; k++) {
series.add(xV[k], yV[k]);
}
dataset.addSeries(series);
}
}
示例7
protected void drawSeries(XYSeries xyseries, Canvas canvas, Paint paint, List list, SimpleSeriesRenderer simpleseriesrenderer, float f1, int i,
org.achartengine.renderer.XYMultipleSeriesRenderer.Orientation orientation, int j)
{
BasicStroke basicstroke = simpleseriesrenderer.getStroke();
android.graphics.Paint.Cap cap = paint.getStrokeCap();
android.graphics.Paint.Join join = paint.getStrokeJoin();
float f2 = paint.getStrokeMiter();
PathEffect patheffect = paint.getPathEffect();
android.graphics.Paint.Style style = paint.getStyle();
if (basicstroke != null)
{
float af[] = basicstroke.getIntervals();
DashPathEffect dashpatheffect = null;
if (af != null)
{
dashpatheffect = new DashPathEffect(basicstroke.getIntervals(), basicstroke.getPhase());
}
a(basicstroke.getCap(), basicstroke.getJoin(), basicstroke.getMiter(), android.graphics.Paint.Style.FILL_AND_STROKE, dashpatheffect, paint);
}
drawSeries(canvas, paint, list, simpleseriesrenderer, f1, i, j);
if (isRenderPoints(simpleseriesrenderer))
{
ScatterChart scatterchart = getPointsChart();
if (scatterchart != null)
{
scatterchart.drawSeries(canvas, paint, list, simpleseriesrenderer, f1, i, j);
}
}
paint.setTextSize(simpleseriesrenderer.getChartValuesTextSize());
if (orientation == org.achartengine.renderer.XYMultipleSeriesRenderer.Orientation.HORIZONTAL)
{
paint.setTextAlign(android.graphics.Paint.Align.CENTER);
} else
{
paint.setTextAlign(android.graphics.Paint.Align.LEFT);
}
if (simpleseriesrenderer.isDisplayChartValues())
{
paint.setTextAlign(simpleseriesrenderer.getChartValuesTextAlign());
drawChartValuesText(canvas, xyseries, simpleseriesrenderer, paint, list, i, j);
}
if (basicstroke != null)
{
a(cap, join, f2, style, patheffect, paint);
}
}
示例8
protected List getXLabels(double d, double d1, int i)
{
ArrayList arraylist = new ArrayList();
if (!mRenderer.isXRoundedLabels())
{
if (mDataset.getSeriesCount() > 0)
{
XYSeries xyseries = mDataset.getSeriesAt(0);
int l = xyseries.getItemCount();
int i1 = 0;
int j1 = -1;
for (int k1 = 0; k1 < l; k1++)
{
double d7 = xyseries.getX(k1);
if (d > d7 || d7 > d1)
{
continue;
}
i1++;
if (j1 < 0)
{
j1 = k1;
}
}
if (i1 < i)
{
for (int j2 = j1; j2 < j1 + i1; j2++)
{
arraylist.add(Double.valueOf(xyseries.getX(j2)));
}
} else
{
float f = (float)i1 / (float)i;
int l1 = 0;
for (int i2 = 0; i2 < l && l1 < i; i2++)
{
double d6 = xyseries.getX(Math.round(f * (float)i2));
if (d <= d6 && d6 <= d1)
{
arraylist.add(Double.valueOf(d6));
l1++;
}
}
}
return arraylist;
} else
{
return super.getXLabels(d, d1, i);
}
}
if (b == null)
{
b = Double.valueOf(86400000D + (d - d % 86400000D) + (double)(1000 * (60 * (new Date(Math.round(d))).getTimezoneOffset())));
}
if (i > 25)
{
i = 25;
}
double d2 = (d1 - d) / (double)i;
if (d2 <= 0.0D)
{
return arraylist;
}
double d3 = 86400000D;
if (d2 <= 86400000D)
{
for (; d2 < d3 / 2D; d3 /= 2D) { }
} else
{
for (; d2 > d3; d3 *= 2D) { }
}
double d4 = b.doubleValue() - d3 * Math.floor((b.doubleValue() - d) / d3);
int j = 0;
double d5 = d4;
do
{
if (d5 >= d1)
{
break;
}
int k = j + 1;
if (j > i)
{
break;
}
arraylist.add(Double.valueOf(d5));
d5 += d3;
j = k;
} while (true);
return arraylist;
}
示例9
/**
* ��ʼ������
*/
@SuppressWarnings("deprecation")
private void initConfig() {
//����
context = getApplicationContext();
//������main�����ϵIJ��֣�������ͼ���������������
LinearLayout layout = (LinearLayout)findViewById(R.id.id_linearLayout_graph);
//������������������ϵ����е㣬��һ����ļ��ϣ�������Щ�㻭������
series = new XYSeries(title);
//����һ�����ݼ���ʵ����������ݼ�������������ͼ��
mDataset = new XYMultipleSeriesDataset();
//���㼯��ӵ�������ݼ���
mDataset.addSeries(series);
//���¶������ߵ���ʽ�����Եȵȵ����ã�renderer�൱��һ��������ͼ������Ⱦ�ľ��
int color = Color.GREEN;
PointStyle style = PointStyle.CIRCLE;
renderer = buildRenderer(color, style, true);
//���ú�ͼ�����ʽ
setChartSettings(renderer, "X", "Y", 0, 300, 4, 16, Color.WHITE, Color.WHITE);
//����ͼ��
chart = ChartFactory.getLineChartView(context, mDataset, renderer);
//��ͼ����ӵ�������ȥ
layout.addView(chart, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
//�����Handlerʵ������������Timerʵ������ɶ�ʱ����ͼ��Ĺ���
handler = new Handler() {
@Override
public void handleMessage(Message msg) {
//ˢ��ͼ��
updateChart();
super.handleMessage(msg);
}
};
task = new TimerTask() {
@Override
public void run() {
Message message = new Message();
message.what = 1;
handler.sendMessage(message);
}
};
timer.schedule(task, 1,20); //����
//��ȡSurfaceView�ؼ�
preview = (SurfaceView) findViewById(R.id.id_preview);
previewHolder = preview.getHolder();
previewHolder.addCallback(surfaceCallback);
previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mTV_Heart_Rate = (TextView) findViewById(R.id.id_tv_heart_rate);
mTV_Avg_Pixel_Values = (TextView) findViewById(R.id.id_tv_Avg_Pixel_Values);
mTV_pulse = (TextView) findViewById(R.id.id_tv_pulse);
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen");
}