Search code examples
javajfreechartshapes

Java Shape Utilities


How to set such kind of points - small circles? I know we should set render and ShapeUtilies:

render.setSeriesShape(NumberOfSerie, ShapeUtilities.[something here]);

what should i write to get this circles? Documentation is here.

enter image description here


Solution

  • The ShapeUtilities class has some methods to create shapes that aren't provided by default in Java2D. For circles though, you can just use:

    Ellipse2D circle = new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0);
    

    The circle here is centered on (0, 0) - JFreeChart relies on that because it will translate the position of the shape to (x, y) when drawing the chart.