📄 graphmarqueehandler.java
字号:
getGraphManager().insertActivity(act); List toSelect=new ArrayList(); toSelect.add(act); JaWEManager.getInstance().getJaWEController().endUndouableChange(toSelect); getGraph().selectActivity(act, false); graphController.setUpdateInProgress(false); } } // if start button is selected else if (isStartButtonSelected()) { if (!getGraphManager().doesRootParticipantExist()) { JaWEFrame frame = JaWEManager.getInstance().getJaWEController().getJaWEFrame(); JOptionPane.showMessageDialog(frame, getGraphController().getSettings().getLanguageDependentString( "WarningInvalidOperation"), frame.getAppTitle(), JOptionPane.WARNING_MESSAGE); } else { GraphParticipantInterface gpar = getGraphManager().findParentActivityParticipantForLocation(whereTo, null, null); Point partLoc = getGraphManager().getBounds(gpar, null).getBounds().getLocation(); Point offset = new Point(whereTo.x - partLoc.x, whereTo.y - partLoc.y); String partId = gpar.getPropertyObject().get("Id").toValue(); graphController.setUpdateInProgress(true); JaWEManager.getInstance().getJaWEController().startUndouableChange(); ExtendedAttribute ea=GraphUtilities.createStartOrEndExtendedAttribute(getGraph().getXPDLObject(), true, partId, offset, subType, true); getGraphManager().insertStart(ea); List toSelect=new ArrayList(); toSelect.add(ea); JaWEManager.getInstance().getJaWEController().endUndouableChange(toSelect); getGraph().selectBubble(ea, false); graphController.setUpdateInProgress(false); } } // if end button is selected if (isEndButtonSelected()) { if (!getGraphManager().doesRootParticipantExist()) { JaWEFrame frame = JaWEManager.getInstance().getJaWEController().getJaWEFrame(); JOptionPane.showMessageDialog(frame, getGraphController().getSettings().getLanguageDependentString( "WarningInvalidOperation"), frame.getAppTitle(), JOptionPane.WARNING_MESSAGE); } else { GraphParticipantInterface gpar = getGraphManager().findParentActivityParticipantForLocation(whereTo, null, null); Point partLoc = getGraphManager().getBounds(gpar, null).getBounds().getLocation(); Point offset = new Point(whereTo.x - partLoc.x, whereTo.y - partLoc.y); String partId = gpar.getPropertyObject().get("Id").toValue(); graphController.setUpdateInProgress(true); JaWEManager.getInstance().getJaWEController().startUndouableChange(); ExtendedAttribute ea=GraphUtilities.createStartOrEndExtendedAttribute(getGraph().getXPDLObject(), false, partId, offset, subType, true); getGraphManager().insertEnd(ea); List toSelect=new ArrayList(); toSelect.add(ea); JaWEManager.getInstance().getJaWEController().endUndouableChange(toSelect); getGraph().selectBubble(ea, false); graphController.setUpdateInProgress(false); } } } public boolean insertTransitionFirstPort(GraphPortViewInterface pPort) { if (pPort != null) { if (firstPort == null) { // start the transition only if start is valid// System.out.println("POINTED TO ACT" + ((GraphPortInterface) (port).getCell()).getActivity()); if (validateSource(pPort)) { points = new Vector(); firstPort = pPort; double scale = getGraph().getScale(); start = firstPort.getBounds().getBounds().getLocation();// HM, JGraph3.4.1 start.x += firstPort.getPortSize().width / 2; start.y += firstPort.getPortSize().height / 2; start = new Point((int) (start.getX() * scale), (int) (start.getY() * scale)); return true; } } } return false; } public boolean insertTransitionSecondPort(GraphPortViewInterface pPort) { if (pPort != null) { // normal if (pPort != firstPort) { if (validateConnection(firstPort, pPort, null)) { GraphActivityInterface s = ((GraphPortInterface) firstPort.getCell()).getActivity(); GraphActivityInterface t = ((GraphPortInterface) pPort.getCell()).getActivity(); XMLElement sxpdl = s.getPropertyObject(); XMLElement txpdl = t.getPropertyObject(); if (sxpdl instanceof Activity && txpdl instanceof Activity) { Transitions tras=(Transitions) getGraph().getXPDLObject().get("Transitions"); String fromId=((Activity) sxpdl).getId(); String toId=((Activity) txpdl).getId(); Transition tra=JaWEManager.getInstance().getXPDLObjectFactory().createXPDLObject(tras, subType,false); tra.setFrom(fromId); tra.setTo(toId); if (fromId.equals(toId)) { GraphUtilities.setStyle(tra, GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE_VALUE_NO_ROUTING_BEZIER); } else { GraphUtilities.setStyle(tra, getGraphController().getGraphSettings().getDefaultTransitionStyle()); } GraphUtilities.setBreakpoints(tra, points); points.clear(); graphController.setUpdateInProgress(true); JaWEManager.getInstance().getJaWEController().startUndouableChange(); tras.add(tra); getGraphManager().insertTransition(tra); List toSelect=new ArrayList(); toSelect.add(tra); JaWEManager.getInstance().getJaWEController().endUndouableChange(toSelect); getGraph().selectTransition(tra, false); graphController.setUpdateInProgress(false); } else if (sxpdl instanceof ExtendedAttribute && txpdl instanceof Activity) { connectStartOrEndBubble((ExtendedAttribute)sxpdl, ((Activity) txpdl).getId()); } else if (txpdl instanceof ExtendedAttribute && sxpdl instanceof Activity) { connectStartOrEndBubble((ExtendedAttribute)txpdl,((Activity) sxpdl).getId()); } return true; } // circular } else { if (validateConnection(pPort, pPort, null)) { Point realP = (Point) getGraph().fromScreen(new Point(start)); List breakpoints = new ArrayList(); if (points.size() == 0) { int rp50x1 = realP.x - 50; int rp50x2 = realP.x + 50; if (rp50x1 < 0) { rp50x2 = rp50x2 - rp50x1; rp50x1 = 0; } int rp50y = realP.y - 50; if (rp50y < 0) rp50y = realP.y + 50; breakpoints.add(new Point(Math.abs(rp50x1), Math.abs(rp50y))); breakpoints.add(new Point(Math.abs(rp50x2), Math.abs(rp50y))); } else { breakpoints.addAll(points); points.clear(); } Activity act = (Activity) ((GraphPortInterface) firstPort.getCell()).getActivity().getPropertyObject(); Transitions tras=(Transitions) getGraph().getXPDLObject().get("Transitions"); Transition tra=JaWEManager.getInstance().getXPDLObjectFactory().createXPDLObject(tras, subType,false); tra.setFrom(act.getId()); tra.setTo(act.getId()); GraphUtilities.setStyle(tra, GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE_VALUE_NO_ROUTING_BEZIER); GraphUtilities.setBreakpoints(tra, breakpoints); getGraphController().setUpdateInProgress(true); JaWEManager.getInstance().getJaWEController().startUndouableChange(); tras.add(tra); getGraphManager().insertTransition(tra); List toSelect=new ArrayList(); toSelect.add(tra); JaWEManager.getInstance().getJaWEController().endUndouableChange(toSelect); getGraph().selectTransition(tra, false); getGraphController().setUpdateInProgress(false); return true; } } } return false; } public void overlay(JGraph graph, Graphics g, boolean clear) { super.overlay(graph, g, clear); if (getGraph()!=null) { paintPort(getGraph().getGraphics()); } if (start != null) { if (isTransitionButtonSelected()) { drawTransition(g); } } } protected void drawTransition (MouseEvent ev) { Graphics g = getGraph().getGraphics(); Color bg = getGraph().getBackground(); Color fg = graphController.getGraphSettings().getBubbleConectionColor(); g.setColor(fg); g.setXORMode(bg); overlay(getGraph(), g, false); current = (Point)getGraph().snap(ev.getPoint()); double scale=getGraph().getScale(); port=(GraphPortViewInterface)getGraph().getPortViewAt(ev.getX(), ev.getY()); if (port!=null) { current = port.getBounds().getBounds().getLocation();//HM, JGraph3.4.1 //current=lastPort.getLocation(null); current=new Point((int)(current.x * scale), (int)(current.y * scale)); current.x+=port.getPortSize().width/2;current.y+=port.getPortSize().height/2; } g.setColor(bg); g.setXORMode(fg); overlay(getGraph(), g, false); } protected void drawTransition(Graphics g) { Point l = start; if (points.size() != 0) l = (Point)points.get(points.size()-1); if (current != null) { g.drawLine(l.x, l.y, current.x, current.y); } } protected void paintPort(Graphics g) { if (port != null) { boolean offset = (GraphConstants.getOffset(port.getAttributes()) != null); Rectangle r = (offset) ? port.getBounds().getBounds()//HM, JGraph3.4.1 : port.getParentView().getBounds().getBounds();//HM, JGraph3.4.1 r = (Rectangle)getGraph().toScreen(new Rectangle(r));//HM, JGraph3.4.1 int s = 3; r.translate(-s, -s); r.setSize(r.width+2*s, r.height+2*s); JaWEGraphUI ui = (JaWEGraphUI)getGraph().getUI(); ui.paintCell(g, port, r, true); } } public void connectStartOrEndBubble (ExtendedAttribute sea,String actId) { GraphBubbleActivityInterface gactb=getGraphManager().getBubble(sea); if (gactb!=null) { GraphTransitionInterface gtra=getGraphManager().connectStartOrEndBubble(gactb, actId); if (gtra!=null) { getGraphController().setUpdateInProgress(true); JaWEManager.getInstance().getJaWEController().startUndouableChange(); StartEndDescription sed=gactb.getStartEndDescription(); sed.setActId(actId); sea.setVValue(sed.toString()); List toSelect=new ArrayList(); toSelect.add(getGraph().getXPDLObject()); JaWEManager.getInstance().getJaWEController().endUndouableChange(toSelect); getGraph().clearSelection(); getGraphController().setUpdateInProgress(false); } } } public String getMainType() { return mainType; } public String getSubType() { return subType; } public void setType(String mainType, String subType, Cursor cursor) { this.mainType = mainType; this.subType = subType; if (cursor != null) getGraph().setCursor(cursor); else getGraph().setCursor(Cursor.getDefaultCursor()); reset(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -