1

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);
Ina
  • 4,400
  • 6
  • 30
  • 44

2 Answers2

3

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)
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
James C
  • 464
  • 1
  • 4
  • 12
  • Edited to cite the API; the source is not needed for this. Please don't copy LGPL code fragments here; this site uses a different [license](http://blog.stackoverflow.com/2009/06/attribution-required/). – trashgod Aug 01 '12 at 00:50
  • Thanks trashgod - I'm a newbie around here so might take me a while to get up to speed with the rite way of doing things. – James C Aug 02 '12 at 03:20
3

You can find related examples using XYShapeAnnotation here and here.

image 1

image 2

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045