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

📄 graphmanager.java

📁 jawe的最新版本,基于Java的图形化工作流编辑器。图形化工作流编辑器 。使用JAVA语言开发
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
         return;      }      StartEndDescription sed=gact.getStartEndDescription();      String connectingActivityId=sed.getActId();      GraphActivityInterface connAct=null;      Set cas=null;      if (gact.isStart()) {         cas=gact.getReferencedActivities();      } else {         cas=gact.getReferencingActivities();      }      if (cas.size()>0) {         connAct=(GraphActivityInterface)cas.toArray()[0];      }      boolean disconnect=false;      boolean connect=false;      if (connectingActivityId==null) {         if (connAct!=null) {            disconnect=true;         }      } else {         if (connAct==null) {            connect=true;         } else {            if (!connAct.getPropertyObject().get("Id").toValue().equals(connectingActivityId)) {               disconnect=true;               connect=true;            }         }      }      if (disconnect) {         Set edges = gact.getPort().getEdges();         removeTransition((GraphTransitionInterface) edges.toArray()[0]);      }      if (connect) {         connectStartOrEndBubble(gact, connectingActivityId);      }                        GraphParticipantInterface oldPar=(GraphParticipantInterface)gact.getParent();      GraphParticipantInterface newPar=getGraphParticipant(sed.getParticipantId());      if (newPar==null || oldPar==null) {         Thread.dumpStack();         return; // can happen when participant Id is updated      }      ParentMap parentMap = new JaWEParentMap();      if (!newPar.equals(oldPar)) {         parentMap.addEntry(gact, newPar);      }         Map propertyMap = new HashMap();      changeBounds(gact, propertyMap, new Rectangle(getRealPosition(gact, newPar),             new Dimension(defActivityHeight / 5 * 3, defActivityHeight / 5 * 3)));      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);      }   public void arrangeBubblePosition(ExtendedAttribute ea,GraphParticipantInterface newPar) {      GraphBubbleActivityInterface gact = getBubble(ea);//      System.out.println("bubble "+gact);//      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();      changeBounds(gact, propertyMap, new Rectangle(getRealPosition(gact, newPar),             new Dimension(defActivityHeight / 5 * 3, defActivityHeight / 5 * 3)));      updateModelAndArrangeParticipants(null, propertyMap, parentMap, null, getGraphController().getSettings().getLanguageDependentString(            "MessageMovingObjects"), null, true);      }   // ----------------------- participant handling   /**    * Inserts new Participant cell into model. First, the    * parent of new Participant is searched, and if found, put into ParentMap    * (it is not inserted into model at ones). If parent participant isn't found ->    * root participant will be inserted. After that model's view is arranged    * (Participants are moved and translated along with it's children cells) to    * suite to the new model state - this is done "virtually" which means that    * changes are not directly applied to view until all changes are made. At    * the end, all changes are applied to model and view. Such procedure enables    * compound undo support. <BR>    * This method is called when inserting new Participant into model.    *     */   public GraphParticipantInterface insertParticipantAndArrangeParticipants(Participant par) {      Map viewMap = new HashMap();      ParentMap parentMap = null;      Map propertyMap = null;      // get the topmost participant at the location where      // user want to insert participant      Rectangle bounds = null;//System.err.println("Inserting participant "+par.getId()+", isGR="+isGraphRotated());      if (isGraphRotated()) {         bounds = new Rectangle(getNewRootParXPos(null, null), verticalOffset, minParHeight, getRootParticipantHeight(               null, null));      } else {         bounds = new Rectangle(horizontalOffset, getNewRootParYPos(null, null), getRootParticipantWidth(null, null),               minParHeight);      }      GraphParticipantInterface gpar = getGraphController().getGraphObjectFactory().createParticipant(bounds, viewMap,            par);      propertyMap = new HashMap(viewMap);      Object[] insert = new Object[] { gpar };      //         graphModel().insertAndEdit(insert,null,propertyMap,parentMap,viewMap,      graphModel().insertAndEdit(insert, propertyMap, null, parentMap, null,            getGraphController().getSettings().getLanguageDependentString("MessageInsertingParticipant"));            if (!creatingGraph) {         try {            graph.setPreferredSize(getGraphsPreferredSize());         } catch (Exception ex) {         }      }      return gpar;   }   /**    * Removes cells <b>cellsToDelete </b> from model. This means that given    * cells and all of their descendants as well as all transitions that    * connects given cells, will be removed from model. First, all remained    * participants are moved and resized according to participants that are    * beeing removed and ParentMap for all removed cells is created (all these    * things are made "virtually" - not applied to model and view). After that    * model's new view is arranged (Participants are moved and translated (along    * with it's children cells) according to the remained children - this is    * also done "virtually". At the end, all changes are applied to model and    * view. Such procedure enables compound undo support. <BR>    * This method is called when deleting or cutting cells from graph.    */   public void removeCellsAndArrangeParticipants(Object[] cellsToDelete) {      Set participantsToArrange = new HashSet();      Map propertyMap = new HashMap();      ParentMap parentMap = new JaWEParentMap();      Set ports = new HashSet();      // begining arrangement of parent of cells that will be deleted      if (cellsToDelete != null && cellsToDelete.length > 0) {         for (int i = 0; i < cellsToDelete.length; i++) {            if (cellsToDelete[i] instanceof GraphParticipantInterface) {               GraphParticipantInterface par = (GraphParticipantInterface) cellsToDelete[i];               // getting bounds of rectangle               Rectangle2D r = getBounds(par, propertyMap);//HM, JGraph3.4.1               int yPos = r.getBounds().y + r.getBounds().height - 1;//HM,               int xPos = r.getBounds().x + r.getBounds().width - 1;//HM,                                                                     // JGraph3.4.1               // resize all parent participants (reduce their sizes) if needed,               // and               // also if needed, translate up all participants under yPos               GraphParticipantInterface ppar = (GraphParticipantInterface) par.getParent();               if (ppar != null) {                  // resizing and translating is needed only if "first" parent                  // has other children except one that is beeing removed                  // or if its height can be reduced                  if (ppar.getChildCount() > 1 || getParticipantHeight(ppar, propertyMap) > minParHeight) {                     // gets all parents and resizes it                     Object[] allParents = ppar.getPath();                     // calculates resize value                     int resizeValue = r.getBounds().height;//HM, JGraph3.4.1                     int pHeight = getParticipantHeight(ppar, propertyMap);                     // do not allow to resize participant under it's minimal                     // height                     if (pHeight - r.getBounds().height < minParHeight) {//HM,                                                                         // JGraph3.4.1                        resizeValue = pHeight - minParHeight;                     }                     resize(allParents, propertyMap, 0, -resizeValue);                     // translate up all participants under yPos                     translateVertically(propertyMap, null, yPos, -resizeValue);                  }               }               // if participant is root there is a need of translating               // participants under it               else {                  // translate up all participants under yPos                  if (!isGraphRotated()) {                     translateVertically(propertyMap, null, yPos, -r.getBounds().height);//HM,                                                                                      // JGraph3.4.1                  } else {                     // JGraph3.4.1                     translateHorizontally(propertyMap, null, xPos, -r.getBounds().width);                  }               }               // if some port is originally set to be deleted it must be               // removed            } else if (cellsToDelete[i] instanceof Port) {               ports.add(cellsToDelete[i]);            }         }         // removing ports if they were somehow selected         Set ctd = new HashSet(Arrays.asList(cellsToDelete));         ctd.removeAll(ports);         if (ctd.size() == 0)            return;         cellsToDelete = ctd.toArray();         // after previous, participant's are transleted and resized to certain         // extent,         // now final resizing and translation takes place (translation and         // resizing         // that calculates minimal possible height and width of participants         // according         // to the activities that are contained within participant after         // deletion)         // All cells in model to be deleted         List cellsToDel = JaWEGraphModel.getDescendantList(graphModel(), cellsToDelete);         // getting transitions(edges) which are connected to the cellsForDel ->         // also has to be deleted         List edges = JaWEGraphModel.getEdges(graphModel(), cellsToDel.toArray());         // putting all items for deletation (edges and cells) together - thats         // ALL FOR DELETION         cellsToDel.addAll(edges);         // Separate cells and edges         Set allEdgesToDelete = new HashSet();         Set allCellsToDelete = new HashSet();         Iterator it = cellsToDel.iterator();         while (it.hasNext()) {            Object cell = it.next();            if (cell instanceof Edge) {               allEdgesToDelete.add(cell);            } else if (!(cell instanceof Port)) {               allCellsToDelete.add(cell);            }         }         // working resize and translation only with cells (edges doesn't count)         cellsToDelete = allCellsToDelete.toArray();         for (int i = 0; i < cellsToDelete.length; i++) {            // adding parent of removing Activity cell (if there is one and if            // it is Participant) into array for arranging participants, and            // creating            // entry in parentMap -> this will be of use after basic resizing            // and translating operations            Object parent = ((DefaultMutableTreeNode) cellsToDelete[i]).getParent();            if ((parent != null) && (parent instanceof GraphParticipantInterface)) {               if (cellsToDelete[i] instanceof GraphActivityInterface) {                  participantsToArrange.add(parent);               }            }            parentMap.addEntry(cellsToDelete[i], null);         }         // resizing remained participants         if (!isGraphRotated()) {            resizeAllParticipantsHorizontally(propertyMap, parentMap);            arrangeParticipantsVertically(participantsToArrange.toArray(), propertyMap, parentMap);         } else {            resizeAllParticipantsVertically(propertyMap, parentMap);            arrangeParticipantsHorizontally(participantsToArrange.toArray(), propertyMap, parentMap);         }         graphModel().removeAndEdit(cellsToDel.toArray(), propertyMap,               getGraphController().getSettings().getLanguageDependentString("MessageRemovingObjects"));      }      try {         graph.setPreferredSize(getGraphsPreferredSize());      } catch (Exception ex) {      }   }   /**    * Returns horizontal offset for inserting participants.    */   public int getHorizontalOffset() {      return horizontalOffset;   }   /**    * Returns the point within the graph where the upper-left corner of given    * graph activity is placed. The point origin is the upper-left corner of    * participant graph object that holds given activity.    */   public Point getOffset(GraphActivityInterface a, Map propertyMap) {      if (a != null) {         GraphParticipantInterface par = (GraphParticipantInterface) a.getParent();         if (par != null) {

⌨️ 快捷键说明

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