?? line.java
字號:
package com.mc.svg.shape.basicshape;
import java.awt.Color;
import java.awt.Point;
import org.w3c.dom.Document;
import com.mc.svg.GenColor;
import com.mc.svg.SVGCanvas;
import com.mc.svg.shape.AbstractShape;
import com.mc.svg.shape.supershape.Node;
public class Line extends AbstractShape {
public Line(Document doc) {
this.doc = doc;
root = doc.createElementNS(SVGCanvas.svgNS, "line");
}
public Line(Document doc,Point point1, Point point2) {
this.doc = doc;
root = doc.createElementNS(SVGCanvas.svgNS, "line");
setBeginPoint(point1);
setEndPoint(point2);
}
public Line(Node node1, Node node2) {
this.doc = node1.getDocument();
root = doc.createElementNS(SVGCanvas.svgNS, "line");
Point point1 = new Point();
point1.x = node1.getX();
point1.y = node1.getY();
setBeginPoint(point1);
Point point2 = new Point();
point2.x = node2.getX();
point2.y = node2.getY();
setEndPoint(point2);
}
public void setBeginPoint(Point point) {
root.setAttributeNS(null, "x1", point.x + "");
root.setAttributeNS(null, "y1", point.y + "");
}
public void setEndPoint(Point point) {
root.setAttributeNS(null, "x2", point.x + "");
root.setAttributeNS(null, "y2", point.y + "");
}
public void setLineColor(Color color) {
String linecol = GenColor.genColor(color);
root.setAttributeNS(null,"stroke", linecol);
}
public void setLineWidth(int width){
root.setAttributeNS(null,"stroke-width",width+"");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -