📄 gpmarqueehandler.java
字号:
bounds = new Rectangle(event.getX(),
event.getY(),
SplitView.defaultWidth,
SplitView.defaultHeight);
}
else if (buttonJoin.isSelected()) {
bounds = new Rectangle(event.getX(),
event.getY(),
JoinView.defaultWidth,
JoinView.defaultHeight);
}
}
if (bounds != null) {
graphpad.getCurrentGraph().fromScreen(bounds);
bounds.width++;
bounds.height++;
if (buttonZoomArea.isSelected()) {
Rectangle view = graphpad.getCurrentGraph().getBounds();
if (graphpad.getCurrentGraph().getParent()
instanceof JViewport) {
view =
( (JViewport) graphpad.getCurrentGraph().getParent())
.getViewRect();
}
if (bounds.width != 0
&& bounds.height != 0
&& SwingUtilities.isLeftMouseButton(event)) {
double scale =
Math.min(
(double) view.width / (double) bounds.width,
(double) view.height / (double) bounds.height);
if (scale > 0.1) {
Rectangle unzoomed =
graphpad.getCurrentGraph().fromScreen(bounds);
graphpad.getCurrentGraph().setScale(scale);
graphpad.getCurrentGraph().scrollRectToVisible(
graphpad.getCurrentGraph().toScreen(unzoomed));
}
}
else {
graphpad.getCurrentGraph().setScale(1);
// FIX: Set ResizeAction to null!
}
}
else if (buttonActivity.isSelected()) {
addActivity(bounds);
}
else if (buttonDecision.isSelected()) {
addDecision(bounds);
}
// 如果选择了inclusiveGateway
else if (buttonInclusiveGateway.isSelected()) {
addInclusiveGateway(bounds);
}
// 如果选择了ComplexGateway
else if (buttonComplexGateway.isSelected()) {
addComplexGateway(bounds);
}
// 如果选择了ParallecGateway
else if (buttonParallelGateway.isSelected()) {
addParallelGateway(bounds);
}
// 如果选择了DataObj
else if (buttonDataObj.isSelected()) {
addDataObj(bounds);
}
// 如果选择了textAnnotation
else if (buttonTextAnnotation.isSelected()) {
addTextAnnotation(bounds);
}
// 如果选择了subProcess
else if (buttonSubProcess.isSelected()) {
addSubProcess(bounds);
}
else if (buttonInter.isSelected()) {
addInter(bounds);
}
else if (buttonPool.isSelected()) {
addPool(bounds);
}
else if (buttonLane.isSelected()) {
addLane(bounds);
}
else if (buttonStart.isSelected()) {
addStart(bounds);
}
else if (buttonEnd.isSelected()) {
addEnd(bounds);
}
else if (buttonSplit.isSelected()) {
addSplit(bounds);
}
else if (buttonJoin.isSelected()) {
addJoin(bounds);
}
else if (buttonText.isSelected()) {
Object cell =
addVertex(
GraphModelProvider.CELL_VERTEX_TEXT,
"在这输入文字",
bounds,
false,
Color.black);
graphpad.getCurrentGraph().startEditingAtCell(cell);
}
else if (buttonEdge.isSelected()) {
Point p =
graphpad.getCurrentGraph().fromScreen(new Point(start));
Point p2 =
graphpad.getCurrentGraph().fromScreen(new Point(current));
ArrayList list = new ArrayList();
list.add(p);
list.add(p2);
Map map = GraphConstants.createMap();
GraphConstants.setPoints(map, list);
// FIXME this should be whatever the current default routing is
GraphConstants.setRouting(map, GraphConstants.ROUTING_SIMPLE);
Map viewMap = new Hashtable();
//DefaultEdge cell = new DefaultEdge("");
Object cell =
gmp.createCell(
model,
GraphModelProvider.CELL_EDGE_DEFAULT,
new GPUserObject(""),
map);
viewMap.put(cell, map);
Object[] insert = new Object[] {
cell};
ConnectionSet cs = new ConnectionSet();
if (firstPort != null) {
cs.connect(cell, firstPort.getCell(), true);
}
if (port != null) {
cs.connect(cell, port.getCell(), false);
}
graphpad.getCurrentGraph().getModel().insert(
insert,
viewMap,
cs,
null,
null);
}
else if (buttonAssociate.isSelected()) {
Point p =
graphpad.getCurrentGraph().fromScreen(new Point(start));
Point p2 =
graphpad.getCurrentGraph().toScreen(new Point(current));
ArrayList list = new ArrayList();
list.add(p);
list.add(p2);
Map map = GraphConstants.createMap();
GraphConstants.setRouting(map, GraphConstants.ROUTING_SIMPLE);
GraphConstants.setPoints(map, list);
GraphConstants.setLineEnd(map, GraphConstants.ARROW_NONE);
GraphConstants.setDashPattern(map, new float[] {2, 1});
//GraphConstants.setEndFill(map, true);
//GraphConstants.setConnectable(map, false);
Map viewMap = new Hashtable();
//DefaultEdge cell = new DefaultEdge("");
Object cell =
gmp.createCell(
model,
GraphModelProvider.CELL_EDGE_DEFAULT,
new GPUserObject(""),
map);
viewMap.put(cell, map);
Object[] insert = new Object[] {
cell};
ConnectionSet cs = new ConnectionSet();
if (firstPort != null) {
cs.connect(cell, firstPort.getCell(), true);
}
if (port != null) {
cs.connect(cell, port.getCell(), false);
}
graphpad.getCurrentGraph().getModel().insert(
insert,
viewMap,
cs,
null,
null);
}
else if (buttonSequence.isSelected()) {
Point p =
graphpad.getCurrentGraph().fromScreen(new Point(start));
Point p2 =
graphpad.getCurrentGraph().toScreen(new Point(current));
ArrayList list = new ArrayList();
list.add(p);
list.add(p2);
Map map = GraphConstants.createMap();
GraphConstants.setRouting(map, GraphConstants.ROUTING_SIMPLE);
GraphConstants.setPoints(map, list);
GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL);
GraphConstants.setEndFill(map, true);
//GraphConstants.setConnectable(map, false);
Map viewMap = new Hashtable();
//DefaultEdge cell = new DefaultEdge("");
Object cell =
gmp.createCell(
model,
GraphModelProvider.CELL_EDGE_DEFAULT,
new GPUserObject(""),
map);
viewMap.put(cell, map);
Object[] insert = new Object[] {
cell};
ConnectionSet cs = new ConnectionSet();
if (firstPort != null) {
cs.connect(cell, firstPort.getCell(), true);
}
if (port != null) {
cs.connect(cell, port.getCell(), false);
}
graphpad.getCurrentGraph().getModel().insert(
insert,
viewMap,
cs,
null,
null);
}
else if (buttonMessage.isSelected()) {
Point p =
graphpad.getCurrentGraph().fromScreen(new Point(start));
Point p2 =
graphpad.getCurrentGraph().toScreen(new Point(current));
ArrayList list = new ArrayList();
list.add(p);
list.add(p2);
Map map = GraphConstants.createMap();
GraphConstants.setRouting(map, GraphConstants.ROUTING_SIMPLE);
GraphConstants.setPoints(map, list);
GraphConstants.setLineBegin(map, GraphConstants.ARROW_CIRCLE);
GraphConstants.setDashPattern(map, new float[] {8, 6});
GraphConstants.setLineWidth(map, 2.0f);
GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL);
GraphConstants.setEndFill(map, false);
//GraphConstants.setConnectable(map, false);
Map viewMap = new Hashtable();
//DefaultEdge cell = new DefaultEdge("");
Object cell =
gmp.createCell(
model,
GraphModelProvider.CELL_EDGE_DEFAULT,
new GPUserObject(""),
map);
viewMap.put(cell, map);
Object[] insert = new Object[] {
cell};
ConnectionSet cs = new ConnectionSet();
if (firstPort != null) {
cs.connect(cell, firstPort.getCell(), true);
}
if (port != null) {
cs.connect(cell, port.getCell(), false);
}
graphpad.getCurrentGraph().getModel().insert(
insert,
viewMap,
cs,
null,
null);
}
event.consume();
}
}
buttonSelect.doClick();
firstPort = null;
port = null;
start = null;
current = null;
bounds = null;
super.mouseReleased(event);
}
public void mouseMoved(MouseEvent event) {
if (!buttonSelect.isSelected() && !event.isConsumed()) {
graphpad.getCurrentGraph().setCursor(
new Cursor(Cursor.CROSSHAIR_CURSOR));
event.consume();
if (buttonEdge.isSelected() || buttonSequence.isSelected() ||
buttonMessage.isSelected() || buttonAssociate.isSelected()) {
PortView oldPort = port;
PortView newPort =
getPortViewAt(
event.getX(),
event.getY(),
!event.isShiftDown());
if (oldPort != newPort) {
Graphics g = graphpad.getCurrentGraph().getGraphics();
Color bg = graphpad.getCurrentGraph().getBackground();
Color fg = graphpad.getCurrentGraph().getMarqueeColor();
g.setColor(fg);
g.setXORMode(bg);
overlay(g);
port = newPort;
g.setColor(bg);
g.setXORMode(fg);
overlay(g);
}
}
}
super.mouseMoved(event);
}
public void overlay(Graphics g) {
super.overlay(g);
paintPort(graphpad.getCurrentGraph().getGraphics());
if (bounds != null && start != null) {
if (buttonZoomArea.isSelected()) {
( (Graphics2D) g).setStroke(GraphConstants.SELECTION_STROKE);
}
if (
(buttonSequence.isSelected() || buttonEdge.isSelected() ||
buttonMessage.isSelected() || buttonAssociate.isSelected())
&& current != null) {
g.drawLine(start.x, start.y, current.x, current.y);
}
else if (!buttonSelect.isSelected()) {
g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height);
}
else if (buttonActivity.isSelected()) {
int arcSize = ActivityView.getArcSize(bounds.width, bounds.height);
g.drawRoundRect(bounds.x,
bounds.y,
bounds.width,
bounds.height,
arcSize,
arcSize);
}
else if (buttonDecision.isSelected()) {
Graphics2D g2 = (Graphics2D) g;
int[] polyx = {
0,
bounds.width / 2,
bounds.width,
bounds.width / 2};
int[] polyy = {
bounds.height / 2,
0,
bounds.height / 2,
bounds.height};
Polygon poly = new Polygon(polyx, polyy, 4);
g2.draw(poly);
}
//如果选择了 inclusiveButton
else if (buttonInclusiveGateway.isSelected()) {
Graphics2D g2 = (Graphics2D) g;
int[] polyx = {
0,
bounds.width / 2,
bounds.width,
bounds.width / 2};
int[] polyy = {
bounds.height / 2,
0,
bounds.height / 2,
bounds.height};
Polygon poly = new Polygon(polyx, polyy, 4);
g2.draw(poly);
}
//如果选择了 buttonComplexGateway
else if (buttonComplexGateway.isSelected()) {
Graphics2D g2 = (Graphics2D) g;
int[] polyx = {
0,
bounds.width / 2,
bounds.width,
bounds.width / 2};
int[] polyy = {
bounds.height / 2,
0,
bounds.height / 2,
bounds.height};
Polygon poly = new Polygon(polyx, polyy, 4);
g2.draw(poly);
}
//如果选择了 buttonParallelGateway
else if (buttonParallelGateway.isSelected()) {
Graphics2D g2 = (Graphics2D) g;
int[] polyx = {
0,
bounds.width / 2,
bounds.width,
bounds.width / 2};
int[] polyy = {
bounds.height / 2,
0,
bounds.height / 2,
bounds.height};
Polygon poly = new Polygon(polyx, polyy, 4);
g2.draw(poly);
}
else if (buttonPool.isSelected()) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -