📄 node.java
字号:
package com.mc.svg.shape.supershape;
import org.w3c.dom.Document;
import com.mc.svg.shape.basicshape.GPanel;
import com.mc.svg.shape.basicshape.Image;
import com.mc.svg.shape.basicshape.Text;
public class Node extends GPanel {
private Image image = null;
private Text text = null;
private int width = 0;
private int height = 0;
public Node(Document doc, String textStr) {
super(doc);
image = new Image(doc);
text = new Text(doc);
setText(textStr);
this.add(image);
this.add(text);
}
public void setText(String textStr) {
text.setText(textStr);
text.setStyle("fill: #000; font-size: 18px");
}
public void setImage(String imagePath) {
image.setImagePath(imagePath);
}
/**
* 给节点添加超连接 :/*url
* @param str
*/
public void setXlinkHerf(String str) {
//root.setAttributeNS(null,"xlink:herf",str);
image.addOnClick(str);
}
public void addMouseOver(String functionName, String[] params) {
image.addMouseOver(functionName, params);
}
public void addMouseOut(String functionName, String[] params) {
image.addMouseOut(functionName, params);
}
public void setSize(int width, int height) {
super.setSize(width, height);
image.setSize(width, height);
this.width = width;
this.height = height;
}
public void setLocation(int x, int y) {
super.setLocation(x, y);
image.setLocation(x, y);
text.setLocation(x + width / 2 - 30, y + height + 15);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -