?? rectangle.java
字號:
package com.mc.svg.shape.basicshape;
import java.awt.Color;
import org.w3c.dom.Document;
import com.mc.svg.GenColor;
import com.mc.svg.SVGCanvas;
import com.mc.svg.shape.AbstractShape;
public class Rectangle extends AbstractShape {
public Rectangle(Document doc) {
this.doc = doc;
root = doc.createElementNS(SVGCanvas.svgNS, "rect");
}
public void setFillColor(Color color) {
String str = GenColor.genColor(color);
root.setAttributeNS(null, "fill", str);
}
public void setSize(int width, int height) {
root.setAttributeNS(null, "width", width + "");
root.setAttributeNS(null, "height", height + "");
}
public int getWidth() {
String widthStr = root.getAttribute("width");
int width = 0;
try {
width = Integer.parseInt(widthStr);
} catch (Exception ex) {
}
return width;
}
public void setBorderColor(Color color){
String str = GenColor.genColor(color);
root.setAttributeNS(null, "stroke", str);
}
public int getHeight() {
String heightStr = root.getAttribute("width");
int height = 0;
try {
height = Integer.parseInt(heightStr);
} catch (Exception ex) {
}
return height;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -