0

Please help me to solve 2 problems with drawing a circle:

1) I want to make a perfect circle. Width == Height but it still draws an ellipse:

generated image

If you try to rotate this image you'll see what i mean:

rotated image

How can i get a perfect circle?

2) Image size: 300x300 px. Distances between edges of image and circle are different:

Top: 9 px. Bottom: 8 px. Left: 11 px. Right: 12 px.

I want to get same distances betwen every edge and circle for example: Top == Bottom == Left == Right == 10 px.

How can i do this?

Here is my code:

public Circle(String title) 
{
chart = ChartFactory.createScatterPlot(""/*title*/, "", "", new XYSeriesCollection());

chart.setBorderVisible(false);
chart.removeLegend();

XYPlot plot = ((XYPlot)chart.getPlot());

plot.setBackgroundPaint(Color.WHITE);
plot.setOutlineVisible(false);

double range = 1.45f;

plot.getRangeAxis().setRange(-range, range);
plot.getRangeAxis().setTickLabelsVisible(false);
plot.getRangeAxis().setTickMarksVisible(false);
plot.getRangeAxis().setAxisLineVisible(false);
plot.getRangeAxis().setLowerMargin(0.0f);
plot.getRangeAxis().setUpperMargin(0.0f);

plot.getDomainAxis().setRange(-range, range);
plot.getDomainAxis().setTickLabelsVisible(false);
plot.getDomainAxis().setTickMarksVisible(false);
plot.getDomainAxis().setAxisLineVisible(false);
plot.getDomainAxis().setLowerMargin(0.0f);
plot.getDomainAxis().setUpperMargin(0.0f);

double outRad = range - 0.01f;

Ellipse2D outercircle = new Ellipse2D.Double(0.0f - outRad, 0.0f - outRad, outRad * 2.0f, outRad * 2.0f);

plot.addAnnotation(new XYShapeAnnotation(outercircle, new BasicStroke(2.0f), Color.BLACK));
}

Thanks.

cupuyc
  • 51
  • 1
  • 1
  • 7

0 Answers0