package ecoparasite.svg.elements;

import ecoparasite.svg.Coordonnees;

import java.util.Locale;

public class Circle extends Element {

    private int rayon;
    private String color;

    public Circle(Coordonnees coordonnees, int rayon, String color) {
        super(coordonnees);
        this.rayon = rayon;
        this.color = color;
    }

    public Circle(Coordonnees coordonnees, int rayon) {
        super(coordonnees);
        this.rayon = rayon;
        this.color = ElementsFactory.COLOR_RED;
    }

    public int getRayon() {
        return rayon;
    }

    public void setRayon(int rayon) {
        this.rayon = rayon;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    @Override
    public String toSVG() {
        StringBuilder svg = new StringBuilder();
        svg.append("<circle ");

        String str = String.format(Locale.US, "r=\"%d\" cx=\"%f\" cy=\"%f\" fill=\"%s\"", this.rayon, this.coordonnees.getX(), this.coordonnees.getY(), this.color);
        svg.append( str );
        svg.append(" />");

        return svg.toString();
    }
}
