在JChart2D中,系列中的点可以用小圆圈或通过点绘制的线绘制。我需要引起用户对某些特定点的注意。
如何用填充的圆圈或其他某种符号标记偶尔的点。
垂直条形画家提供的,似乎将整个图表更改为垂直条形图(在它发生的位置,也“追溯”到旧点)。我不要那个。我只需要使单点看起来特别,例如,X = 5处的点。
Chart2D chart = new Chart2D();
ITrace2D myTrace = new Trace2DLtd(100);
myTrace.setColor(Color.RED);
myTrace.setTracePainter(new TracePainterDisc()); // circle; not filled
chart.addTrace(myTrace);
JFrame frame = new JFrame(Constants.graphTitle);
frame.getContentPane().add(chart);
frame.setSize(200, 200);
frame.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
);
frame.setVisible(true);
List<Point> list = Helper.makeList();
for (Point p: list)
{
if (p.x != 5)
myTrace.addPoint(p.x, p.y);
else
{
// MAKE THIS POINT LOOK DIFFERENT, BUT HOW?
myTrace.addPoint(p.x, p.y);
}
}
}
}
答案 0 :(得分:1)
用以下代码替换相关代码:
PointPainterDisc icon = new PointPainterDisc();
icon.setDiscSize(20); // make it bigger than the others
icon.setColorFill(Color.BLUE); // choose a color not used by the others
TracePoint2D point = new TracePoint2D(p.x, p.y);
point.addAdditionalPointPainter(icon);
myTrace.addPoint(point);