我想将mealltvalue的值输入getItemShape()方法。 mealltvalue来自JSON对象,即它来自数据库。使用这个mealltvalue我必须使用if和else循环检查条件。
String mealsltvalue = jsonObject.getString("mealslot");
final XYPlot xyplot = (XYPlot)chart.getPlot();
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true,true)
{
Shape ellipse = new Ellipse2D.Double(-3.0,-3.0,8.0,8.0);
Shape upTriangle = ShapeUtilities.createUpTriangle(4.0f);
public Shape getItemShape(int row, int column)
{
Double value = (Double)xyplot.getDataset(0).getY(row,column);
if (mealsltvalue .equalsIgnoreCase("Before Meal"))
{
return ellipse;
}
else
{
return upTriangle;
}
}
};
xyplot.setRenderer(renderer);