This is probably trivial for many of you, but I’m a bit stuck as to how to proceed. My ultimate goal with this is to have a collection of 2-6 round buttons that all appear equal distance apart on an oval path. When the user clicks on one button, it rotates to the front (while scaling larger) as the other buttons rotate with it along the orbital looking path.
The following code will find equidistant points along a circle, but how do you do this if you have an oval like this?:
ellipse = new Ellipse2D.Float(0, 0, 400, 50);
/******************************************************************/
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
public class Main {
private static List findPoints(int x, int y, int r, int n) {
List listOfPoints = new ArrayList();
for (int i=0; i<n; i++) {
listOfPoints.add(
new Point(
(int)(x+r*Math.cos(Math.PI*i/n-Math.PI/2)),
(int)(y+r*Math.sin(Math.PI*i/n-Math.PI/2))));
}
return listOfPoints;
}
public static void main(String[] args){
System.out.println(findPoints(0, 0, 1, 4));
}
}