77 lines
1.9 KiB
Java
77 lines
1.9 KiB
Java
|
|
package ecoparasite.svg.elements;
|
||
|
|
|
||
|
|
import ecoparasite.svg.Coordonnees;
|
||
|
|
|
||
|
|
public class Line extends Element {
|
||
|
|
|
||
|
|
private Coordonnees coordonneesB;
|
||
|
|
private String color;
|
||
|
|
private int lineWidth;
|
||
|
|
|
||
|
|
public Line(Coordonnees coordonneesA, Coordonnees coordonneesB, String color, int lineWidth) {
|
||
|
|
super(coordonneesA);
|
||
|
|
this.coordonneesB = coordonneesB;
|
||
|
|
this.color = color;
|
||
|
|
this.lineWidth = lineWidth;
|
||
|
|
}
|
||
|
|
|
||
|
|
public Line(Coordonnees coordonneesA, Coordonnees coordonneesB) {
|
||
|
|
super(coordonneesA);
|
||
|
|
this.coordonneesB = coordonneesB;
|
||
|
|
this.color = ElementsFactory.COLOR_RED;
|
||
|
|
this.lineWidth = 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
public Coordonnees getCoordonneesA() {
|
||
|
|
return coordonnees;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setCoordonneesA(Coordonnees coordonnees) {
|
||
|
|
this.coordonnees = coordonnees;
|
||
|
|
}
|
||
|
|
|
||
|
|
public Coordonnees getCoordonneesB() {
|
||
|
|
return coordonneesB;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setCoordonneesB(Coordonnees coordonnees) {
|
||
|
|
this.coordonneesB = coordonnees;
|
||
|
|
}
|
||
|
|
|
||
|
|
public String getColor() {
|
||
|
|
return color;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setColor(String color) {
|
||
|
|
this.color = color;
|
||
|
|
}
|
||
|
|
|
||
|
|
public int getLineWidth() {
|
||
|
|
return lineWidth;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void setLineWidth(int lineWidth) {
|
||
|
|
this.lineWidth = lineWidth;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public String toSVG() {
|
||
|
|
StringBuilder svg = new StringBuilder();
|
||
|
|
svg.append("<line ");
|
||
|
|
|
||
|
|
String params = String.format( "x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" style=\"stroke:%s;stroke-width:%d\"",
|
||
|
|
this.coordonnees.getX(),
|
||
|
|
this.coordonnees.getY(),
|
||
|
|
this.coordonneesB.getX(),
|
||
|
|
this.coordonneesB.getY(),
|
||
|
|
this.color,
|
||
|
|
this.lineWidth
|
||
|
|
);
|
||
|
|
svg.append(params);
|
||
|
|
svg.append( "/>" );
|
||
|
|
|
||
|
|
return svg.toString();
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|