0
我试图绘制多边形与AndroidPlot
库。
我成功地绘制四点,但它仅消耗3多边形的边。 (它不关闭多边形)
应填充多边形。我怎样才能做到这一点?如何用androidPlot库绘制多边形?
谢谢!
编辑:
我先画一个点,然后多边形,因为我有显示,如果该点将在多边形内部。
private XYPlot plot;
plot = (XYPlot) findViewById(R.id.graph);
seriesPointFormat = new LineAndPointFormatter(
null, // line color
Color.rgb(5, 100, 150), // point color
null, // fill color
new PointLabelFormatter());
float[] xTol = intent.getExtras().getFloatArray("tolerancesX");
float[] yTol = intent.getExtras().getFloatArray("tolerancesY");
Float[] xTolerances = new Float[xTol.length];
Float[] yTolerances = new Float[yTol.length];
for(int i = 0; i< xTol.length; i++)
xTolerances[i] = xTol[i];
for(int i = 0; i< yTol.length; i++)
yTolerances[i] = yTol[i];
//Example
x=0.35f;
y=0.65f;
//Turn the above arrays into XYSeries':
XYSeries seriesPoint = new SimpleXYSeries(
Arrays.asList(x),
Arrays.asList(y),
"point"); // Set the display title of the series
plot.getGraphWidget().setDomainValueFormat(new DecimalFormat("##.###"));
// add a new series' to the xyplot:
plot.addSeries(seriesPoint, seriesPointFormat);
XYSeries seriesPolygon = new SimpleXYSeries(
Arrays.asList(xTolerances),
Arrays.asList(yTolerances),
"Polygon");
LineAndPointFormatter seriesPolygonFormat = new LineAndPointFormatter(
Color.rgb(500, 0, 0), // line color
Color.rgb(500, 100, 0), // point color
null,
new PointLabelFormatter());
seriesPolygonFormat.getLinePaint().setStrokeWidth(2);
plot.addSeries(seriesPolygon, seriesPolygonFormat);
为了帮助别人理解你的问题,请张贴的代码样本,所有日志(例如logcat的)或某物的输出,表现出[最小的,完整的,和可核查的示例](http://stackoverflow.com/帮助/ mcve)你的问题。 –