Ina
Ina

Reputation: 4470

Change colour & line width of an Annotation in JFreeChart

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);

Upvotes: 1

Views: 1719

Answers (2)

trashgod
trashgod

Reputation: 205775

You can find related examples using XYShapeAnnotation here and here.

image 1

image 2

Upvotes: 3

James C
James C

Reputation: 514

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)

Upvotes: 3

Related Questions