⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graphmanager.java

📁 jawe的最新版本,基于Java的图形化工作流编辑器。图形化工作流编辑器 。使用JAVA语言开发
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
      }      toRem.add(gact);      Object[] remove = toRem.toArray();      graphModel().removeAndEdit(remove, null,            getGraphController().getSettings().getLanguageDependentString("MessageRemovingObjects"));      Map propertyMap = new HashMap();      ParentMap parentMap = new JaWEParentMap();      arrangeParticipants(propertyMap, parentMap);      updateModelAndArrangeParticipants(new Object[] {}, propertyMap, parentMap, new HashMap(), "an", null, true);   }   public void arrangeActivityPosition(Activity act) {//      System.out.println("Searching graph act for id "+act.getId());      GraphActivityInterface gact = getGraphActivity(act.getId());//      System.out.println("agact "+gact);      GraphParticipantInterface newPar=getGraphParticipant(GraphUtilities.getParticipantId(act));//      System.out.println("newpar "+newPar);      GraphParticipantInterface oldPar=(GraphParticipantInterface)gact.getParent();//      System.out.println("odlpar "+oldPar);      //if (newPar==null || oldPar==null) return; // can happen when participant Id is updated      ParentMap parentMap = new JaWEParentMap();      if (!newPar.equals(oldPar)) {         parentMap.addEntry(gact, newPar);      }      Map propertyMap = new HashMap();      Point actRealPos=getRealPosition(gact, newPar);//      GraphParticipantViewInterface gpvi=(GraphParticipantViewInterface)getView(newPar);//      Rectangle parBounds=getBounds(newPar, propertyMap);//      if (actRealPos.x>parBounds.width) {////         gpvi.//         resizeAllParticipantsHorizontally(propertyMap, parentMap);//      }               changeBounds(gact, propertyMap, new Rectangle(actRealPos, new Dimension(defActivityWidth,defActivityHeight)));      if (!newPar.equals(oldPar)) {         if (isGraphRotated()) {            arrangeParticipantHorizontally(newPar, propertyMap, parentMap);            if (oldPar!=null) {               arrangeParticipantHorizontally(oldPar, propertyMap, parentMap);            }         } else {            arrangeParticipantVertically(newPar, propertyMap, parentMap);            if (oldPar!=null) {               arrangeParticipantVertically(oldPar, propertyMap, parentMap);            }         }      }      updateModelAndArrangeParticipants(null, propertyMap, parentMap, null, getGraphController().getSettings().getLanguageDependentString(            "MessageMovingObjects"), null, true);   }   // --------------------- transition handling   public GraphTransitionInterface insertTransition(Transition xpdltra) {      Map viewMap = new HashMap();//      System.out.println("Inserting xpdltra " + xpdltra.getId() + ", F=" + xpdltra.getFrom() + ", T=" + xpdltra.getTo());      List breakPoints = GraphUtilities.getBreakpoints(xpdltra);      GraphActivityInterface source = getGraphActivity(xpdltra.getFrom());      GraphActivityInterface target = getGraphActivity(xpdltra.getTo());      if (source == null || target == null) return null;      Point p11 = getCenter(source);      Point p21 = getCenter(target);      Point p = (Point) graph.fromScreen(new Point(p11));      Point p2 = (Point) graph.fromScreen(new Point(p21));      List points = new ArrayList();      points.add(p);      points.addAll(breakPoints);      points.add(p2);      GraphTransitionInterface gtra = getGraphController().getGraphObjectFactory().createTransition(points, viewMap,            xpdltra);      //      System.out.println("\ngTra11="+getView(gtra).getBounds());      Object[] insert = new Object[] { gtra };      ConnectionSet cs = new ConnectionSet();      cs.connect(gtra, source.getPort(), target.getPort());      //cs.connect(transition,source.getCell(),true);      //cs.connect(transition,target.getCell(),false);      String undoMsg = getGraphController().getSettings().getLanguageDependentString("MessageInsertingTransition");      //      graphModel().insertAndEdit(insert,cs,null,null,viewMap,undoMsg);      graphModel().insertAndEdit(insert, viewMap, cs, null, null, undoMsg);      return gtra;   }   public void removeTransition(Transition xpdltra) {//System.out.println("Graphmanager->removing transition "+xpdltra.getId());      GraphTransitionInterface gtra = getGraphTransition(xpdltra);//System.out.println("              found graph transition "+gtra);      removeTransition(gtra);   }   public void updateTransition (Transition xpdltra) {      GraphTransitionInterface gtra = getGraphTransition(xpdltra);      if (gtra==null) {         gtra=insertTransition(xpdltra);      } else {         GraphActivityInterface s1=gtra.getSourceActivity();         GraphActivityInterface t1=gtra.getTargetActivity();                  if (s1==null || t1==null) {            removeTransition(gtra);            gtra=insertTransition(xpdltra);            return;         }                  if (!s1.getPropertyObject().get("Id").toValue().equals(xpdltra.getFrom()) ||                !t1.getPropertyObject().get("Id").toValue().equals(xpdltra.getTo())) {            removeTransition(gtra);            gtra=insertTransition(xpdltra);            return;         }                  Map propertyMap = new HashMap();                  // breakpoints         updateBreakPoints(gtra, propertyMap);                  // style         updateStyle(gtra,propertyMap);                  ((JaWEGraphModel) graph.getModel()).insertAndEdit(null, propertyMap, null, null, null, "");               }   }   public void updateBreakPoints (GraphTransitionInterface gtra,Map propertyMap) {      List bps = GraphUtilities.getBreakpoints((Transition)gtra.getUserObject());      GraphTransitionViewInterface gtraview = (GraphTransitionViewInterface) getView(gtra);      if (gtraview==null) return;      AttributeMap map = (AttributeMap)propertyMap.get(gtra);       if (map==null) {         map = new AttributeMap(gtra.getAttributes());         propertyMap.put(gtra, map);               }      int pcnt = gtraview.getPointCount();      Point2D ps = gtraview.getPoint(0);      Point2D pt = gtraview.getPoint(pcnt - 1);      List points = new ArrayList();      points.add(ps);      points.addAll(bps);      points.add(pt);//JaWEManager.getInstance().getLoggingManager().debug("Updating breakpoints for transition: "+points);      GraphConstants.setPoints(map, points);   }   public List addOrRemoveBreakPoint (GraphTransitionInterface gtra,Point p,boolean toAdd) {      CellView view=graph.getGraphLayoutCache().getMapping(gtra,false);      GraphTransitionViewInterface tv=(GraphTransitionViewInterface)view;      if (toAdd) {         tv.addPoint(graph, p);      } else {         tv.removePoint(graph, p);      }      int noOfPoints=tv.getPointCount();      List pnts=new ArrayList();      for (int i=1; i<noOfPoints-1; i++) {         pnts.add(new Point((int)tv.getPoint(i).getX(),(int)tv.getPoint(i).getY()));//HM, JGraph3.4.1      }//JaWEManager.getInstance().getLoggingManager().debug("Adding/removing breakpoint for transition: "+pnts);      return pnts;   }      public void updateStyle (GraphTransitionInterface gtra) {      Map propertyMap = new HashMap();      updateStyle(gtra,propertyMap);      String undoMsg=getGraphController().getSettings().getLanguageDependentString("MessageSettingTransitionTypeToNoRouting");      ((JaWEGraphModel)graph.getModel()).insertAndEdit(null,propertyMap,null,null,null,undoMsg);         }      protected void updateStyle (GraphTransitionInterface gtra,Map propertyMap) {      String style=GraphUtilities.getStyle((Transition)gtra.getUserObject());      AttributeMap map = (AttributeMap)propertyMap.get(gtra);       if (map==null) {         map = new AttributeMap(gtra.getAttributes());         propertyMap.put(gtra, map);               }      if (style.equals(GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE_VALUE_NO_ROUTING_BEZIER)) {         GraphConstants.setRouting(map,new NoRouting());         GraphConstants.setLineStyle(map,GraphConstants.STYLE_BEZIER);      } else if (style.equals(GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE_VALUE_NO_ROUTING_SPLINE)) {         GraphConstants.setRouting(map,new NoRouting());         GraphConstants.setLineStyle(map,GraphConstants.STYLE_SPLINE);      } else if (style.equals(GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE_VALUE_SIMPLE_ROUTING_BEZIER)) {         GraphConstants.setRouting(map, GraphConstants.ROUTING_SIMPLE);         GraphConstants.setLineStyle(map,GraphConstants.STYLE_BEZIER);      } else if (style.equals(GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE_VALUE_SIMPLE_ROUTING_ORTHOGONAL)) {         GraphConstants.setRouting(map, GraphConstants.ROUTING_SIMPLE);         GraphConstants.setLineStyle(map,GraphConstants.STYLE_ORTHOGONAL);      } else if (style.equals(GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE_VALUE_SIMPLE_ROUTING_SPLINE)) {         GraphConstants.setRouting(map, GraphConstants.ROUTING_SIMPLE);         GraphConstants.setLineStyle(map,GraphConstants.STYLE_SPLINE);      } else {         GraphConstants.setRouting(map,new NoRouting());         GraphConstants.setLineStyle(map,GraphConstants.STYLE_ORTHOGONAL);      }   }      protected void removeTransition(GraphTransitionInterface gtra) {      if (gtra==null) return;      //      System.out.println("\ngTra11="+getView(gtra).getBounds());      Object[] remove = new Object[] { gtra };      //cs.connect(transition,source.getCell(),true);      //cs.connect(transition,target.getCell(),false);      graphModel().removeAndEdit(remove, null,            getGraphController().getSettings().getLanguageDependentString("MessageRemovingObjects"));      Map propertyMap = new HashMap();      ParentMap parentMap = new JaWEParentMap();      arrangeParticipants(propertyMap, parentMap);      updateModelAndArrangeParticipants(new Object[] {}, propertyMap, parentMap, new HashMap(), "an", null, true);   }   // --------------------- start/end bubble handling   public GraphActivityInterface insertStart(ExtendedAttribute sea) {      Map viewMap = new HashMap();      StartEndDescription sd = new StartEndDescription(sea);      GraphParticipantInterface gpar = getGraphParticipant(sd.getParticipantId());      Point p = getBounds(gpar, null).getBounds().getLocation();      GraphBubbleActivityInterface gact = getGraphController().getGraphObjectFactory().createStart(viewMap, sea, p);      updateModelAndArrangeParticipants(new Object[] { gact }, null, null, viewMap, getGraphController().getSettings()            .getLanguageDependentString("MessageInsertingGenericActivity"), null, true);      connectStartOrEndBubble(gact, sd.getActId());      return gact;   }   public GraphActivityInterface insertEnd(ExtendedAttribute eea) {      Map viewMap = new HashMap();      StartEndDescription ed = new StartEndDescription(eea);      GraphParticipantInterface gpar = getGraphParticipant(ed.getParticipantId());//      System.err.println("Par for id "+ed.getParticipantId()+" is "+gpar);      Point p = getBounds(gpar, null).getBounds().getLocation();      GraphBubbleActivityInterface gact = getGraphController().getGraphObjectFactory().createEnd(viewMap, eea, p);      updateModelAndArrangeParticipants(new Object[] { gact }, null, null, viewMap, getGraphController().getSettings()            .getLanguageDependentString("MessageInsertingGenericActivity"), null, true);      connectStartOrEndBubble(gact, ed.getActId());      return gact;   }   public void removeBubble(ExtendedAttribute ea) {//      System.err.println("REMOVVING BUBBLE " + ea.getVValue());      GraphBubbleActivityInterface gact = getBubble(ea);      if (gact==null) return;      Set edges = gact.getPort().getEdges();      Object[] remove;      if (edges != null && edges.size() > 0) {         remove = new Object[] { gact, edges.toArray()[0] };      } else {         remove = new Object[] { gact };      }      graphModel().removeAndEdit(remove, null,            getGraphController().getSettings().getLanguageDependentString("MessageRemovingObjects"));      Map propertyMap = new HashMap();      ParentMap parentMap = new JaWEParentMap();      arrangeParticipants(propertyMap, parentMap);      updateModelAndArrangeParticipants(new Object[] {}, propertyMap, parentMap, new HashMap(), "an", null, true);   }      public GraphTransitionInterface connectStartOrEndBubble(GraphBubbleActivityInterface startOrEnd, String actId) {      if (actId==null) return null;      Map viewMap = new HashMap();      StartEndDescription sed=startOrEnd.getStartEndDescription();      GraphActivityInterface source = startOrEnd;      GraphActivityInterface target = getGraphActivity(actId);            if (source==null || target==null) return null;            if (!sed.isStart()) {         source = target;         target = startOrEnd;      }      Point p11 = getCenter(source);      Point p21 = getCenter(target);      Point p = (Point) graph.fromScreen(new Point(p11));      Point p2 = (Point) graph.fromScreen(new Point(p21));      List points = new ArrayList();      points.add(p);      points.add(p2);      GraphTransitionInterface gtra = getGraphController().getGraphObjectFactory().createBubbleTransition(points,            viewMap, sed.getTransitionStyle());      //      System.out.println("\ngTra11="+getView(gtra).getBounds());      Object[] insert = new Object[] { gtra };      ConnectionSet cs = new ConnectionSet();      cs.connect(gtra, source.getPort(), target.getPort());      //cs.connect(transition,source.getCell(),true);      //cs.connect(transition,target.getCell(),false);      String undoMsg = getGraphController().getSettings().getLanguageDependentString("MessageInsertingTransition");      //      graphModel().insertAndEdit(insert,cs,null,null,viewMap,undoMsg);      graphModel().insertAndEdit(insert, viewMap, cs, null, null, undoMsg);      return gtra;   }   public void updateBubble (ExtendedAttribute ea) {      GraphBubbleActivityInterface gact = getBubble(ea);      if (gact == null) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -