?? workflow_graphed.java
字號:
// If Not Floating Port...
boolean o =
(GraphConstants.getOffset(port.getAttributes()) != null);
// ...Then use Parent's Bounds
Rectangle2D r =
(o) ? port.getBounds() : port.getParentView().getBounds();
// Scale from Model to Screen
r = graph.toScreen( (Rectangle2D) r.clone());
// Add Space For the Highlight Border
r.setFrame(r.getX() - 3, r.getY() - 3, r.getWidth() + 6,
r.getHeight() + 6);
// Paint Port in Preview (=Highlight) Mode
graph.getUI().paintCell(g, port, r, true);
}
}
} // End of Editor.MyMarqueeHandler
//
//
//
//
// PopupMenu and ToolBar
//
//
//
//
public void newgraph(JGraph graph) {
GraphModel model = graph.getModel();
Object[] oldCells = graph.getRoots();
if (oldCells != null) {
oldCells =
DefaultGraphModel.getDescendants(model, oldCells).toArray();
model.remove(oldCells);
}
}
//
// PopupMenu
//
public JPopupMenu createPopupMenu(final Point pt, final Object cell) {
JPopupMenu menu = new JPopupMenu();
// if (cell != null) {
// Edit
// menu.add(new AbstractAction("Edit") {
// public void actionPerformed(ActionEvent e) {
// graph.startEditingAtCell(cell);
// }
// });
// }
// Remove
if (!graph.isSelectionEmpty()) {
menu.addSeparator();
menu.add(new AbstractAction("刪除該節點") {
public void actionPerformed(ActionEvent e) {
remove.actionPerformed(e);
}
});
}
menu.addSeparator();
// Insert
menu.add(new AbstractAction("插入新節點") {
public void actionPerformed(ActionEvent e) {
insert(pt);
}
});
menu.addSeparator();
//edit
menu.add(new AbstractAction("增加節點屬性") {
public void actionPerformed(ActionEvent e) {
// CellView view = graph.getGraphLayoutCache().getMapping(cell, false);
// view.update();
reflash();
ed.validate();
ed.pack();
ed.setTitle("節點屬性修改");
// ed.setSize(350, 283);
ed.show();
}
});
return menu;
}
public void reflash(){
ed = new workflow_GraphEd_ChangeCellAttribute_Dialog(this);
}
public JToolBar createToolBar1() {
JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
return toolbar;
}
public JToolBar createToolBar() {
JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
// export
// URL insertUrl1 = getClass().getClassLoader().getResource(
// "resources/16.gif");
// ImageIcon insertIcon1 = new ImageIcon(insertUrl1);
// export = new AbstractAction("", insertIcon1) {
// public void actionPerformed(ActionEvent e) {
// he.saveGXL(graph);
// }
// };
// toolbar.add(export);
// toolbar.add();
// insert start cell
URL insert_startUrl = getClass().getClassLoader().getResource(
"resources/StartNew.gif");
ImageIcon insert_startIcon = new ImageIcon(insert_startUrl);
toolbar.add(new AbstractAction("", insert_startIcon) {
public void actionPerformed(ActionEvent e) {
insert_start(new Point(20, 145));
}
});
// insert end cell
URL insert_endUrl = getClass().getClassLoader().getResource(
"resources/EndNew.gif");
ImageIcon insert_endIcon = new ImageIcon(insert_endUrl);
toolbar.add(new AbstractAction("", insert_endIcon) {
public void actionPerformed(ActionEvent e) {
insert_end(new Point(550, 142));
}
});
// toolbar.addSeparator();
// Insert
URL insertUrl = getClass().getClassLoader().getResource(
"resources/insert.gif");
ImageIcon insertIcon = new ImageIcon(insertUrl);
toolbar.add(new AbstractAction("", insertIcon) {
public void actionPerformed(ActionEvent e) {
insert(new Point(40, 100));
}
});
// Toggle Connect Mode
URL connectUrl =
getClass().getClassLoader().getResource(
"resources/connecton.gif");
ImageIcon connectIcon = new ImageIcon(connectUrl);
toolbar.add(new AbstractAction("", connectIcon) {
public void actionPerformed(ActionEvent e) {
graph.setPortsVisible(!graph.isPortsVisible());
URL connectUrl;
if (graph.isPortsVisible()) {
connectUrl =
getClass().getClassLoader().getResource(
"resources/connecton.gif");
}
else {
connectUrl =
getClass().getClassLoader().getResource(
"resources/connectoff.gif");
}
ImageIcon connectIcon = new ImageIcon(connectUrl);
putValue(SMALL_ICON, connectIcon);
}
});
// Undo
// toolbar.addSeparator();
URL undoUrl = getClass().getClassLoader().getResource(
"resources/undo.gif");
ImageIcon undoIcon = new ImageIcon(undoUrl);
undo = new AbstractAction("", undoIcon) {
public void actionPerformed(ActionEvent e) {
// undo();
}
};
undo.setEnabled(false);
// toolbar.add(undo);
// Redo
URL redoUrl = getClass().getClassLoader().getResource(
"resources/redo.gif");
ImageIcon redoIcon = new ImageIcon(redoUrl);
redo = new AbstractAction("", redoIcon) {
public void actionPerformed(ActionEvent e) {
redo();
}
};
redo.setEnabled(false);
// toolbar.add(redo);
//
// Edit Block
//
toolbar.addSeparator();
Action action;
URL url;
// Copy
action = javax.swing.TransferHandler // JAVA13: org.jgraph.plaf.basic.TransferHandler
.getCopyAction();
url = getClass().getClassLoader().getResource(
"resources/copy.gif");
action.putValue(Action.SMALL_ICON, new ImageIcon(url));
toolbar.add(copy = new EventRedirector(action));
// Paste
action = javax.swing.TransferHandler // JAVA13: org.jgraph.plaf.basic.TransferHandler
.getPasteAction();
url = getClass().getClassLoader().getResource(
"resources/paste.gif");
action.putValue(Action.SMALL_ICON, new ImageIcon(url));
toolbar.add(paste = new EventRedirector(action));
// Cut
action = javax.swing.TransferHandler // JAVA13: org.jgraph.plaf.basic.TransferHandler
.getCutAction();
url = getClass().getClassLoader().getResource(
"resources/cut.gif");
action.putValue(Action.SMALL_ICON, new ImageIcon(url));
toolbar.add(cut = new EventRedirector(action));
// Remove
URL removeUrl = getClass().getClassLoader().getResource(
"resources/delete.gif");
ImageIcon removeIcon = new ImageIcon(removeUrl);
remove = new AbstractAction("", removeIcon) {
public void actionPerformed(ActionEvent e) {
if (!graph.isSelectionEmpty()) {
Object[] cells = graph.getSelectionCells();
cells = graph.getDescendants(cells);
graph.getModel().remove(cells);
}
}
};
remove.setEnabled(false);
toolbar.add(remove);
// Zoom Std
toolbar.addSeparator();
URL zoomUrl = getClass().getClassLoader().getResource(
"resources/zoom.gif");
ImageIcon zoomIcon = new ImageIcon(zoomUrl);
toolbar.add(new AbstractAction("", zoomIcon) {
public void actionPerformed(ActionEvent e) {
graph.setScale(1.0);
}
});
// Zoom In
URL zoomInUrl = getClass().getClassLoader().getResource(
"resources/zoomin.gif");
ImageIcon zoomInIcon = new ImageIcon(zoomInUrl);
toolbar.add(new AbstractAction("", zoomInIcon) {
public void actionPerformed(ActionEvent e) {
graph.setScale(2 * graph.getScale());
}
});
// Zoom Out
URL zoomOutUrl = getClass().getClassLoader().getResource(
"resources/zoomout.gif");
ImageIcon zoomOutIcon = new ImageIcon(zoomOutUrl);
toolbar.add(new AbstractAction("", zoomOutIcon) {
public void actionPerformed(ActionEvent e) {
graph.setScale(graph.getScale() / 1.2);
}
});
// Group
toolbar.addSeparator();
URL groupUrl = getClass().getClassLoader().getResource(
"resources/group.gif");
ImageIcon groupIcon = new ImageIcon(groupUrl);
group = new AbstractAction("", groupIcon) {
public void actionPerformed(ActionEvent e) {
group(graph.getSelectionCells());
}
};
group.setEnabled(false);
toolbar.add(group);
// Ungroup
URL ungroupUrl = getClass().getClassLoader().getResource(
"resources/ungroup.gif");
ImageIcon ungroupIcon = new ImageIcon(ungroupUrl);
ungroup = new AbstractAction("", ungroupIcon) {
public void actionPerformed(ActionEvent e) {
ungroup(graph.getSelectionCells());
}
};
ungroup.setEnabled(false);
toolbar.add(ungroup);
// To Front
toolbar.addSeparator();
URL toFrontUrl = getClass().getClassLoader().getResource(
"resources/tofront.gif");
ImageIcon toFrontIcon = new ImageIcon(toFrontUrl);
tofront = new AbstractAction("", toFrontIcon) {
public void actionPerformed(ActionEvent e) {
if (!graph.isSelectionEmpty()) {
toFront(graph.getSelectionCells());
}
}
};
tofront.setEnabled(false);
// toolbar.add(tofront);
// To Back
URL toBackUrl = getClass().getClassLoader().getResource(
"resources/toback.gif");
ImageIcon toBackIcon = new ImageIcon(toBackUrl);
toback = new AbstractAction("", toBackIcon) {
public void actionPerformed(ActionEvent e) {
if (!graph.isSelectionEmpty()) {
toBack(graph.getSelectionCells());
}
}
};
toback.setEnabled(false);
// toolbar.add(toback);
return toolbar;
}
// This will change the source of the actionevent to graph.
protected class EventRedirector
extends AbstractAction {
protected Action action;
// Construct the "Wrapper" Action
public EventRedirector(Action a) {
super("", (ImageIcon) a.getValue(Action.SMALL_ICON));
this.action = a;
}
// Redirect the Actionevent
public void actionPerformed(ActionEvent e) {
e =
new ActionEvent(
graph,
e.getID(),
e.getActionCommand(),
e.getModifiers());
action.actionPerformed(e);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -