Begin SVG.
This commit is contained in:
49
src/ecoparasite/svg/elements/Circle.java
Normal file
49
src/ecoparasite/svg/elements/Circle.java
Normal file
@@ -0,0 +1,49 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user