package tt.edu.sbcs.planets;

import java.awt.*;
import java.awt.geom.Ellipse2D;

/**
 * Parametric equation for a circle:
 * x = cx + r * cos(a)
 * y = cy + r * sin(a)
 */
public class Planet {
    private double distance;
    private double size;
    private double angle;
    double x;
    double y;
    Paint paint;

    public Planet(){
        this(100);
    }
    public Planet(double distance){
        this(distance, 10);
    }
    public Planet(double distance, double size){
        this(distance, size, 0);
    }
    public Planet(double distance, double size, double angle){
        this.setDistance(distance);
        this.setSize(size);
        this.setAngle(angle);
        setPosition();
        paint = new LinearGradientPaint((float)x, (float)y, (float)(x + size), (float)(y + size), new float[]{0.1f, 0.9f}, new Color[]{Color.WHITE, new Color((float)Math.random(), (float)Math.random(), (float)Math.random())});
    }

    public void setPosition(){
        double cx = PlanetFrame.WIDTH / 2;
        double cy = PlanetFrame.HEIGHT / 2;
        x = cx + getDistance() * Math.cos(getAngle());
        y = cy + getDistance() * Math.sin(getAngle());
    }

    public void move(){
        setAngle(getAngle() + 1);
        setPosition();
    }

    public void draw(Graphics2D g2){
        g2.setPaint(paint);
        g2.fill(new Ellipse2D.Double(x, y, size, size));
    }

    public double getDistance() {
        return distance;
    }

    public void setDistance(double distance) {
        this.distance = distance;
    }

    public double getSize() {
        return size;
    }

    public void setSize(double size) {
        this.size = size;
    }

    public double getAngle() {
        return angle;
    }

    public void setAngle(double angle) {
        this.angle = angle;
    }

    public String toString(){
        return String.format("Position=(%.2f, %.2f);Size=%.2f", x, y, size);
    }
}

@@ -770,16 +770,30 @@
 ntPaint(
+%0D%0A            
 (float)x
@@ -842,16 +842,30 @@
  size), 
+%0D%0A            
 new floa
@@ -885,64 +885,158 @@
 f%7D, 
-new Color%5B%5D%7BColor.WHITE, new Color((float)Math.random(),
+%0D%0A            new Color%5B%5D%7B%0D%0A                Color.WHITE, %0D%0A                new Color(%0D%0A                    (float)Math.random(), %0D%0A                   
  (fl
@@ -1054,16 +1054,38 @@
 ndom(), 
+%0D%0A                    
 (float)M
@@ -1096,16 +1096,34 @@
 random()
+%0D%0A                
 )%7D);%0D%0A  

Format long lines