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