本文整理汇总了Java中com.mxgraph.examples.swing.editor.EditorPalette.addTemplate方法的典型用法代码示例。如果您正苦于以下问题:Java EditorPalette.addTemplate方法的具体用法?Java EditorPalette.addTemplate怎么用?Java EditorPalette.addTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mxgraph.examples.swing.editor.EditorPalette
的用法示例。
在下文中一共展示了EditorPalette.addTemplate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SchemaEditor
import com.mxgraph.examples.swing.editor.EditorPalette; //导入方法依赖的package包/类
/**
*
*/
public SchemaEditor()
{
super("mxGraph for JFC/Swing", new SchemaGraphComponent(new mxGraph()
{
/**
* Allows expanding tables
*/
public boolean isCellFoldable(Object cell, boolean collapse)
{
return model.isVertex(cell);
}
})
{
/**
*
*/
private static final long serialVersionUID = -1194463455177427496L;
/**
* Disables folding icons.
*/
public ImageIcon getFoldingIcon(mxCellState state)
{
return null;
}
});
// Creates a single shapes palette
EditorPalette shapesPalette = insertPalette("Schema");
graphOutline.setVisible(false);
mxCell tableTemplate = new mxCell("New Table", new mxGeometry(0, 0,
200, 280), null);
tableTemplate.getGeometry().setAlternateBounds(
new mxRectangle(0, 0, 140, 25));
tableTemplate.setVertex(true);
shapesPalette
.addTemplate(
"Table",
new ImageIcon(
GraphEditor.class
.getResource("/com/mxgraph/examples/swing/images/rectangle.png")),
tableTemplate);
getGraphComponent().getGraph().setCellsResizable(false);
getGraphComponent().setConnectable(false);
getGraphComponent().getGraphHandler().setCloneEnabled(false);
getGraphComponent().getGraphHandler().setImagePreview(false);
// Prefers default JComponent event-handling before mxCellHandler handling
//getGraphComponent().getGraphHandler().setKeepOnTop(false);
mxGraph graph = getGraphComponent().getGraph();
Object parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
try
{
mxCell v1 = (mxCell) graph.insertVertex(parent, null, "Customers",
20, 20, 200, 280);
v1.getGeometry().setAlternateBounds(new mxRectangle(0, 0, 140, 25));
mxCell v2 = (mxCell) graph.insertVertex(parent, null, "Orders",
280, 20, 200, 280);
v2.getGeometry().setAlternateBounds(new mxRectangle(0, 0, 140, 25));
}
finally
{
graph.getModel().endUpdate();
}
}
示例2: SchemaEditor
import com.mxgraph.examples.swing.editor.EditorPalette; //导入方法依赖的package包/类
/**
*
*/
public SchemaEditor() {
super("mxGraph for JFC/Swing", new SchemaGraphComponent(new mxGraph() {
/**
* Allows expanding tables
*/
public boolean isCellFoldable(Object cell, boolean collapse) {
return model.isVertex(cell);
}
})
{
/**
*
*/
private static final long serialVersionUID = -1194463455177427496L;
/**
* Disables folding icons.
*/
public ImageIcon getFoldingIcon(mxCellState state) {
return null;
}
});
// Creates a single shapes palette
EditorPalette shapesPalette = insertPalette("Schema");
graphOutline.setVisible(false);
mxCell tableTemplate = new mxCell("New Table", new mxGeometry(0, 0, 200, 280), null);
tableTemplate.getGeometry().setAlternateBounds(new mxRectangle(0, 0, 140, 25));
tableTemplate.setVertex(true);
shapesPalette.addTemplate("Table",
new ImageIcon(
GraphEditor.class.getResource("/com/mxgraph/examples/swing/images/rectangle.png")),
tableTemplate);
getGraphComponent().getGraph().setCellsResizable(false);
getGraphComponent().setConnectable(false);
getGraphComponent().getGraphHandler().setCloneEnabled(false);
getGraphComponent().getGraphHandler().setImagePreview(false);
// Prefers default JComponent event-handling before mxCellHandler handling
// getGraphComponent().getGraphHandler().setKeepOnTop(false);
mxGraph graph = getGraphComponent().getGraph();
Object parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
try {
mxCell v1 = (mxCell) graph.insertVertex(parent, null, "Customers", 20, 20, 200, 280);
v1.getGeometry().setAlternateBounds(new mxRectangle(0, 0, 140, 25));
mxCell v2 = (mxCell) graph.insertVertex(parent, null, "Orders", 280, 20, 200, 280);
v2.getGeometry().setAlternateBounds(new mxRectangle(0, 0, 140, 25));
} finally {
graph.getModel().endUpdate();
}
}