50 lines
1.1 KiB
Java
50 lines
1.1 KiB
Java
|
|
package ecoparasite.svg.elements;
|
||
|
|
|
||
|
|
import ecoparasite.svg.Coordonnees;
|
||
|
|
|
||
|
|
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( "r=\"%d\" cx=\"%d\" cy=\"%d\" fill=\"%s\"", this.rayon, this.coordonnees.getX(), this.coordonnees.getY(), this.color);
|
||
|
|
svg.append( str );
|
||
|
|
svg.append(" />");
|
||
|
|
|
||
|
|
return svg.toString();
|
||
|
|
}
|
||
|
|
}
|