0
A
回答
0
(这个答案解决了绘制各个点的内圈的问题,如上图所示)
通常情况下,这将是一个2或3行工作,只需重新添加具有适当配置的LineAndPointFormatter实例的系列作品即可,但最近版本中存在一个错误,可能会阻止同一系列使用相同的渲染器,无论是否提供不同的格式器。 (将其固定在1.2.3发布)
如果你不为你的序列数据的完整副本,你仍然可以做到这一点很容易记:
XYSeries series2b = new SimpleXYSeries(
Arrays.asList(series2Numbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series2");
LineAndPointFormatter series2bFormat = new LineAndPointFormatter(null, Color.WHITE, null, null);
// this adjusts the size of the inner circle:
series2bFormat.getVertexPaint().setStrokeWidth(PixelUtils.dpToPix(7));
...
// make sure this line comes AFTER the addSeries call for the copied series:
plot.addSeries(series2b, series2bFormat);
上述实现的一个局限是,它会绘制一个复制的图例图标(在即将发布的1.2.3版本中也有提到)。避免重复的图标另一种方法是创建一个自定义LineAndPointRenderer与自定义LineAndPointFormatter沿延伸:
// a custom renderer to draw an second smaller circle for each rendered vertex
static class MyLineAndPointRenderer extends LineAndPointRenderer<MyLineAndPointFormatter> {
public MyLineAndPointRenderer(XYPlot plot) {
super(plot);
}
@Override
protected void renderPoints(Canvas canvas, RectF plotArea, XYSeries series, List<PointF> points,
LineAndPointFormatter formatter) {
// draw points as normal:
super.renderPoints(canvas, plotArea, series, points, formatter);
// now draw our inner vertices on top of the previously drawn vertices:
for (PointF p : points) {
Paint paint = ((MyLineAndPointFormatter) formatter).getInnerPointPaint();
canvas.drawPoint(p.x, p.y, paint);
}
}
}
// defines the format for our custom renderer:
static class MyLineAndPointFormatter extends LineAndPointFormatter {
Paint innerPointPaint = new Paint();
{
// setup innPointPaint to draw a white circle a little smaller than the
// typical circle drawn for each vertex:
innerPointPaint.setAntiAlias(true);
innerPointPaint.setStrokeCap(Paint.Cap.ROUND);
innerPointPaint.setColor(Color.WHITE);
innerPointPaint.setStrokeWidth(PixelUtils.dpToPix(7));
}
public MyLineAndPointFormatter(Context context, int xmlCfgId) {
super(context, xmlCfgId);
}
@Override
public Class<? extends SeriesRenderer> getRendererClass() {
return MyLineAndPointRenderer.class;
}
@Override
public SeriesRenderer getRendererInstance(XYPlot plot) {
return new MyLineAndPointRenderer(plot);
}
public Paint getInnerPointPaint() {
return innerPointPaint;
}
}
然后,将你的系列的情节时使用的,而不是LineAndPointFormatter以上:
MyLineAndPointFormatter series1Format =
new MyLineAndPointFormatter(this, R.xml.my_format);
虽然这最后一种方法是更多的代码,它也是最有效和可扩展的。
相关问题
- 1. Android自定义标签
- 2. Android自定义标签栏
- 3. 核心情节1.0:提供自定义标签的传奇
- 4. 自定义标签栏,详情查看
- 5. 自定义标签和cfimport
- 6. Android自定义标题与标签
- 7. android的自定义字体标签
- 8. Android中的自定义标签栏
- 9. 定义自定义标签
- 10. ColdFusion的使用自定义标签中自定义标签
- 11. 自定义标题栏和标签
- 12. Android自定义载体标签nullpointerexception
- 13. 自定义标签在开始和结束做一些事情
- 14. Android Chrome浏览器自定义标签可自定义
- 15. 下标在标签情节
- 16. 剑道treeview和自定义节点
- 17. getSafeHTML的自定义标签()
- 18. Doxygen的自定义标签
- 19. 显示表节标题的节标题和自定义视图
- 20. TreeView自定义节点
- 21. DjangoCMS NavigationNode - 自定义节点
- 22. 自定义Ext.Net TreeGrid节点?
- 23. Cytoscape.js - 自定义节点
- 24. Docusign自定义标签 - 配方标签
- 25. LWUIT标签:创建自定义标签
- 26. ACORD标准来定义一个自定义节点?
- 27. HTML5和CSS - 自定义标签?
- 28. CKEDITOR - 自定义标签和符号editorwindow
- 29. 自定义组件和标签顺序
- 30. 创建自定义标签
谢谢尼克,我会试试这个。 –
Nick,我尝试了第二种解决方案,但在MyLineAndPointFormatter super(context,xmlcfg)的构造函数中出错;同样在@override public SeriesRenderer doGetRendererInstance(XYPlot plot)中也出现“无法解析符号”{ return new MyLineAndPointRenderer(plot); }“方法不会覆盖超类的方法” –
道歉 - 当我写这个时,我在开发分支上。该方法的正确名称是'SeriesRenderer getRendererInstance(XYPlot plot)'。我已经更新了上面的代码来反映这一点。 – Nick