问题
I am adding an annotation to my plot, but I can't work out how to change the colour or line width (stroke) of this. I've read through the documentation as best as I can but I'm out of ideas. Can anyone help?
Shape shape = new Ellipse2D.Double(circleXValue - radius, circleYValue - radius, radius + radius, radius + radius);
XYShapeAnnotation annotation = new XYShapeAnnotation(shape);
// ??
plot.addAnnotation(annotation);
回答1:
You're using this constructor:
public XYShapeAnnotation(java.awt.Shape shape)
You may want to use one of these constructors that specify additional parameters:
public XYShapeAnnotation(
java.awt.Shape shape,
java.awt.Stroke stroke,
java.awt.Paint outlinePaint)
public XYShapeAnnotation(
java.awt.Shape shape,
java.awt.Stroke stroke,
java.awt.Paint outlinePaint,
java.awt.Paint fillPaint)
回答2:
You can find related examples using XYShapeAnnotation here and here.


来源:https://stackoverflow.com/questions/11748533/change-colour-line-width-of-an-annotation-in-jfreechart