2026-04-08 14:47:42 +02:00
|
|
|
package ecoparasite.svg.elements;
|
|
|
|
|
|
|
|
|
|
import ecoparasite.svg.Coordonnees;
|
|
|
|
|
|
2026-04-27 12:56:24 +02:00
|
|
|
import java.util.Locale;
|
|
|
|
|
|
2026-04-08 14:47:42 +02:00
|
|
|
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 ");
|
|
|
|
|
|
2026-04-27 12:56:24 +02:00
|
|
|
String params = String.format(Locale.US,"x=\"%f\" y=\"%f\" fill=\"%s\" font-size=\"%s\"", coordonnees.getX(), coordonnees.getY(), color, size);
|
2026-04-08 14:47:42 +02:00
|
|
|
svg.append(params);
|
|
|
|
|
svg.append(" >");
|
|
|
|
|
svg.append( this.text );
|
|
|
|
|
svg.append("</text>");
|
|
|
|
|
return svg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|