63 lines
1.4 KiB
Java
63 lines
1.4 KiB
Java
|
|
package ecoparasite.svg.elements;
|
||
|
|
|
||
|
|
import ecoparasite.svg.Coordonnees;
|
||
|
|
|
||
|
|
public class Text extends Element {
|
||
|
|
|
||
|
|
private String text;
|
||
|
|
private String color;
|
||
|
|
private int size;
|
||
|
|
|
||
|
|
public Text(Coordonnees coordonnees, String text, String color, int size) {
|
||
|
|
super(coordonnees);
|
||
|
|
this.text = text;
|
||
|
|
this.color = color;
|
||
|
|
this.size = size;
|
||
|
|
}
|
||
|
|
|
||
|
|
public Text(Coordonnees coordonnees, String text) {
|
||
|
|
super(coordonnees);
|
||
|
|
this.text = text;
|
||
|
|
this.color = ElementsFactory.COLOR_BLACK;
|
||
|
|
this.size = ElementsFactory.AXES_TEXT_SIZE;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getText() {
|
||
|
|
return text;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setText(String text) {
|
||
|
|
this.text = text;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getColor() {
|
||
|
|
return color;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setColor(String color) {
|
||
|
|
this.color = color;
|
||
|
|
}
|
||
|
|
|
||
|
|
public int getSize() {
|
||
|
|
return size;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setSize(int size) {
|
||
|
|
this.size = size;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public String toSVG() {
|
||
|
|
StringBuilder svg = new StringBuilder();
|
||
|
|
svg.append("<text ");
|
||
|
|
|
||
|
|
String params = String.format( "x=\"%d\" y=\"%d\" fill=\"%s\" font-size=\"%s\"", coordonnees.getX(), coordonnees.getY(), color, size);
|
||
|
|
svg.append(params);
|
||
|
|
svg.append(" >");
|
||
|
|
svg.append( this.text );
|
||
|
|
svg.append("</text>");
|
||
|
|
return svg.toString();
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|