📄 gpcellviewfactory.java
字号:
package flow.graph.gui.graph;
import java.awt.Color;
import java.util.Map;
import org.jgraph.graph.DefaultCellViewFactory;
import org.jgraph.graph.DefaultGraphCell;
import org.jgraph.graph.GraphConstants;
import org.jgraph.graph.Port;
import org.jgraph.graph.PortView;
import org.jgraph.graph.VertexView;
import flow.graph.gui.graph.item.GraphPortView;
/**
* A default view factory for a JGraph. This simple factory associate a given
* cell class to a cell view. This is a javabean, just parameter it correctly in
* order it meets your requirements (else subclass it or subclass
* DefaultCellViewFactory). You can also recover the gpConfiguration of that
* javabean via an XML file via XMLEncoder/XMLDecoder.
*
* @author rvalyi, license of this file: LGPL as stated by the Free Software
* Foundation
*/
public class GPCellViewFactory extends DefaultCellViewFactory {
public static final String VIEW_CLASS_KEY = "viewClassKey";
public static final void setViewClass(Map map, String viewClass) {
map.put(VIEW_CLASS_KEY, viewClass);
}
public static final String getViewClass(Map map) {
return (String) map.get(VIEW_CLASS_KEY);
}
/*
protected PortView createPortView(Port p) {
return new GraphPortView(p);
}
*/
protected VertexView createVertexView(Object v) {
try {
DefaultGraphCell cell = (DefaultGraphCell) v;
String viewClass = (String) cell.getAttributes().get(VIEW_CLASS_KEY);
VertexView view = (VertexView) Thread.currentThread()
.getContextClassLoader().loadClass(viewClass).newInstance();
view.setCell(v);
return view;
} catch (Exception ex) {
}
return super.createVertexView(v);
}
/*
protected PortView createPortView(Port p) {
return new FlowPortView(p);
}
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -