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

📄 graphmanager.java

📁 jawe的最新版本,基于Java的图形化工作流编辑器。图形化工作流编辑器 。使用JAVA语言开发
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
   protected void arrangeParticipantsHorizontally(Object[] pars, Map propertyMap, ParentMap parentMap) {      if ((pars == null) || (pars.length == 0))         return;      for (int i = 0; i < pars.length; i++) {         arrangeParticipantHorizontally(pars[i], propertyMap, parentMap);      }   }   /**    * Arranging heights and positions of given participants and positions of    * participants that must be translated due to a change of given    * participants.    */   protected void arrangeParticipantsVertically(Object[] pars, Map propertyMap, ParentMap parentMap) {      if ((pars == null) || (pars.length == 0))         return;      for (int i = 0; i < pars.length; i++) {         // arrange participants vertically         arrangeParticipantVertically(pars[i], propertyMap, parentMap);      }   }   protected void arrangeParticipantHorizontally(Object par, Map propertyMap, ParentMap parentMap) {      // can't be null, must be instance of Participant,      // and can't have other participants      // also it can't be removed      if (par == null)         return;      if (!(par instanceof GraphParticipantInterface))         return;      GraphParticipantInterface p = (GraphParticipantInterface) par;      if (hasAnyParticipant(p, parentMap))         return;      ArrayList removedPars = ((JaWEParentMap) parentMap).getRemovedNodes();      if (removedPars.contains(p))         return;      // getting optimal and current height for participant      int optWidth = optimalParticipantWidth(p, propertyMap, parentMap);      int curWidth = getParticipantWidth(p, propertyMap);      // calculating value for vertical resizing of new participant      int dwidth = optWidth - curWidth;      if (dwidth != 0) {         // translating horizontally participants under right edge         // of participant for value of dwidth         translateHorizontally(propertyMap, parentMap, getBounds(p, propertyMap).getBounds().x + curWidth - 1, dwidth);//HM,         // JGraph3.4.1         // gets all parents participant (and given participant) into array         // and resizes them for value of dheight         Object[] allParentsAndPar = p.getPath();         resize(allParentsAndPar, propertyMap, dwidth, 0);      }   }   /**    * Resizing participant par and it's parents to appropriate height, and    * translating other participants accordingly to changes of participant par.    * The size's and positions are calculated considering propertyMap and    * parentMap - which means for future children state, and for bounds that are    * constantly changed during other calculations. If propertyMap and parentMap    * are null, size's and positions are calculated for current state. Also, if    * par that is to be arranged has entry in parentMap as removed participant,    * it will not be arranged.    */   protected void arrangeParticipantVertically(Object par, Map propertyMap, ParentMap parentMap) {      // can't be null, must be instance of Participant,      // and can't have other participants      // also it can't be removed      if (par == null)         return;      if (!(par instanceof GraphParticipantInterface))         return;      GraphParticipantInterface p = (GraphParticipantInterface) par;      if (hasAnyParticipant(p, parentMap))         return;      ArrayList removedPars = ((JaWEParentMap) parentMap).getRemovedNodes();      if (removedPars.contains(p))         return;      // getting optimal and current height for participant      int optHeight = optimalParticipantHeight(p, propertyMap, parentMap);      int curHeight = getParticipantHeight(p, propertyMap);      // calculating value for vertical resizing of new participant      int dheight = optHeight - curHeight;      if (dheight != 0) {         // translating verticaly participants under bottom edge         // of participant for value of dheight         translateVertically(propertyMap, parentMap, getBounds(p, propertyMap).getBounds().y + curHeight - 1, dheight);//HM,                                                                                                                       // JGraph3.4.1         // gets all parents participant (and given participant) into array         // and resizes them for value of dheight         Object[] allParentsAndPar = p.getPath();         resize(allParentsAndPar, propertyMap, 0, dheight);      }   }   /**    * Method that resizes all participants horizontally to get there minimal    * needed sizes. The size is calculated considering propertyMap and parentMap -    * which means for future children state, and for bounds that are constantly    * changed during other calculations. If propertyMap and parentMap are null,    * size is calculated for current state.    */   protected void resizeAllParticipantsHorizontally(Map propertyMap, ParentMap parentMap) {      List participants = JaWEGraphModel.getAllParticipantsInModel(graphModel());      // removing ones which parent in a parentMap is null      if (parentMap != null && participants != null) {         participants.removeAll(((JaWEParentMap) parentMap).getRemovedNodes());      }      // if there is a need for resizing      int optimalRDW = optimalRootParticipantWidth(participants, propertyMap, parentMap);      int rootParWidth = getRootParticipantWidth(propertyMap, parentMap);      if (optimalRDW != rootParWidth) {         // resize all participants for needed increment         int dw = optimalRDW - rootParWidth;         if (participants != null) {            resize(participants.toArray(), propertyMap, dw, 0);         }      }   }   protected void resizeAllParticipantsVertically(Map propertyMap, ParentMap parentMap) {      List participants = JaWEGraphModel.getAllParticipantsInModel(graphModel());      // removing ones which parent in a parentMap is null      if (parentMap != null && participants != null) {         participants.removeAll(((JaWEParentMap) parentMap).getRemovedNodes());      }      // if there is a need for resizing      int optimalBDW = optimalRootParticipantHeight(participants, propertyMap, parentMap);      int rootParHeight = getRootParticipantHeight(propertyMap, parentMap);      if (optimalBDW != rootParHeight) {         // resize all participants for needed increment         int dw = optimalBDW - rootParHeight;         if (participants != null) {            resize(participants.toArray(), propertyMap, 0, dw);         }      }   }   protected int optimalRootParticipantHeight(List participants, Map propertyMap, ParentMap parentMap) {      // initial value for width stays the same      int minHeight;      if (isGraphRotated())         minHeight = minParWidth;      else         minHeight = minParHeight;      // exits if there are no participants created      if (participants == null)         return minHeight;      // finds the leaf participants      Set leafParticipants = new HashSet();      Iterator it = participants.iterator();      while (it.hasNext()) {         GraphParticipantInterface par = (GraphParticipantInterface) it.next();         // if participant doesn't have any other participants,         // it is a leaf participant and should be added to collection         if (!hasAnyParticipant(par, parentMap)) {            leafParticipants.add(par);         }      }      // max. right edge position minus horizontalOffset (of all leafs) becomes      // minWidth      it = leafParticipants.iterator();      int maxBottomEdgePosition = 0;      while (it.hasNext()) {         GraphParticipantInterface lpar = (GraphParticipantInterface) it.next();         int minBEdge;         int minParBEdge;         int minChildrenBEdge = 0;         // getting future participant bounds         if (isGraphRotated())            minParBEdge = (int) getBounds(lpar, propertyMap).getY() + minParWidth;//HM,         else            minParBEdge = (int) getBounds(lpar, propertyMap).getY() + minParHeight;//HM,         // JGraph3.4.1         // getting the future child views bounding rectangle -> its right         // edge plus some extra space is min. right edge for that participant         Rectangle r = getBoundsOfParticipantFutureActivities(lpar, propertyMap, parentMap);         if (r != null) {            minChildrenBEdge = r.y + r.height + defParNameWidth;         }         minBEdge = java.lang.Math.max(minParBEdge, minChildrenBEdge);         // if entering first time, set the starting max.         if (maxBottomEdgePosition == 0) {            maxBottomEdgePosition = minBEdge;         } else if (minBEdge > maxBottomEdgePosition) {            maxBottomEdgePosition = minBEdge;         }      }      int minH = maxBottomEdgePosition - verticalOffset;      // can't allow that the minWidth<minParWidth      if (minH > minParWidth) {         minHeight = minH;      }      return minHeight;   }   /**    * Calculates the minimal width of root participants. It depends of minimal    * allowed width of leaf participants, which depends on the position of    * Activity cells in them. The width is calculated considering propertyMap    * and parentMap - which means for future children state, and for bounds that    * are constantly changed during other calculations. If propertyMap and    * parentMap are null, size is calculated for current state.    */   protected int optimalRootParticipantWidth(List participants, Map propertyMap, ParentMap parentMap) {      // initial value for width stays the same      int minWidth;      if (isGraphRotated())         minWidth = minParHeight;      else         minWidth = minParWidth;      // exits if there are no participants created      if (participants == null)         return minWidth;      // finds the leaf participants      Set leafParticipants = new HashSet();      Iterator it = participants.iterator();      while (it.hasNext()) {         GraphParticipantInterface par = (GraphParticipantInterface) it.next();         // if participant doesn't have any other participants,         // it is a leaf participant and should be added to collection         if (!hasAnyParticipant(par, parentMap)) {            leafParticipants.add(par);         }      }      // max. right edge position minus horizontalOffset (of all leafs) becomes      // minWidth      it = leafParticipants.iterator();      int maxRightEdgePosition = 0;      while (it.hasNext()) {         GraphParticipantInterface lpar = (GraphParticipantInterface) it.next();         int minREdge;         int minParREdge;         int minChildrenREdge = 0;         // getting future participant bounds         if (isGraphRotated())            minParREdge = (int) getBounds(lpar, propertyMap).getX() + minParHeight;//HM,                                                                                   // JGraph3.4.1         else            minParREdge = (int) getBounds(lpar, propertyMap).getX() + minParWidth;//HM,                                                                                  // JGraph3.4.1         // getting the future child views bounding rectangle -> its right         // edge plus some extra space is min. right edge for that participant         Rectangle r = getBoundsOfParticipantFutureActivities(lpar, propertyMap, parentMap);         if (r != null) {            minChildrenREdge = r.x + r.width + defParNameWidth;         }         minREdge = java.lang.Math.max(minParREdge, minChildrenREdge);         // if entering first time, set the starting max.         if (maxRightEdgePosition == 0) {            maxRightEdgePosition = minREdge;         } else if (minREdge > maxRightEdgePosition) {            maxRightEdgePosition = minREdge;         }      }      int minW = maxRightEdgePosition - horizontalOffset;      // can't allow that the minWidth<minParWidth      if (minW > minParWidth) {         minWidth = minW;      }      return minWidth;   }   protected int optimalParticipantWidth(GraphParticipantInterface par, Map propertyMap, ParentMap parentMap) {      // initial value for width      int optWidth;      if (isGraphRotated())         optWidth = minParHeight;      else         optWidth = minParWidth;      // exits returning minParHeight if there are no activity cells within      // participant      if (!hasAnyActivity(par, parentMap))         return optWidth;      // get bounds of par (either current or future)      Rectangle2D rCurrent = getBounds(par, propertyMap);//HM,      // JGraph3.4.1      // get preffered bounding rectangle of participant (according to it's      // children)      Rectangle rPreferred = getBoundsOfParticipantFutureActivities(par, propertyMap, parentMap);      // difference of these rectangle's bottom positions plus current par      // height      // plus some extra space is min. height for given participant      // calcul

⌨️ 快捷键说明

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