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

📄 graph.java

📁 jawe的最新版本,基于Java的图形化工作流编辑器。图形化工作流编辑器 。使用JAVA语言开发
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      }      return tmp;   }   /**    * Only for debugging purpose.    */   public void printOrderedAllSelectables() {      CellView[] sel = getOrderedAllSelectableCells();      for (int i=0; i<sel.length; i++)         System.out.println("view"+i+"="+sel[i].getCell());   }   /**    * Overrides <code>JComponent</code>'s <code>getToolTipText</code>    * method in order to allow the graph controller to create a tooltip    * for the topmost cell under the mousepointer. This differs from JTree    * where the renderers tooltip is used.    * <p>    * NOTE: For <code>JGraph</code> to properly display tooltips of its    * renderers, <code>JGraph</code> must be a registered component with the    * <code>ToolTipManager</code>.  This can be done by invoking    * <code>ToolTipManager.sharedInstance().registerComponent(graph)</code>.    * This is not done automatically!    * @param event the <code>MouseEvent</code> that initiated the    * <code>ToolTip</code> display    * @return a string containing the  tooltip or <code>null</code>    * if <code>event</code> is null    */   public String getToolTipText(MouseEvent event) {      if(event != null) {         Object cell;         // if activity or Participant is to be inserted, show         // underlying Participant, else show other         GraphMarqueeHandler mh=(GraphMarqueeHandler)marquee;         Point p=(Point) fromScreen(event.getPoint());         if (!(mh.isSelectButtonSelected() || mh.isTransitionButtonSelected())) {            cell=getFirstParticipantForLocation((int)p.getX(),(int)p.getY());         }         else {            cell=getFirstCellForLocation(p.getX(),p.getY());         }         if (cell != null) {            String s=convertValueToString(cell);            if (cell instanceof WorkflowElement) {               s=((WorkflowElement)cell).getTooltip();            }            return s;         }      }      return null;   }   public boolean validateAgainsXPDLSchema () {      return true;   }//   /**//    * Reacts upon the XML element change by setting isModified flag//    * of PackageEditor if needed.//    *///   public void xmlElementChanged (XMLElement el) {//      if (el instanceof org.enhydra.shark.xpdl.elements.Activity) {//         editor.getStatusBar().updateMessage();//      }//   }//   public void initGraphBehavior() {      setHandleSize(4);      setTolerance(4);      setSizeable(false);      setMoveable(!getXPDLObject().isReadOnly());      setDisconnectable(true);      setDisconnectOnMove(false);      setAntiAliased(true);      setAutoscrolls(true);      selectionModel.setSelectionMode(GraphSelectionModel.MULTIPLE_GRAPH_SELECTION);      refreshGraphConfiguration();   }   public void refreshGraphConfiguration () {      GraphSettings gval = GraphUtilities.getGraphController().getGraphSettings();      boolean gs = gval.shouldShowGrid();      setGridEnabled(gs);      setGridVisible(gs);      setGridSize(gval.getGridSize());      setBackground(gval.getBackgroundColor());            setHighlightColor(gval.getSelectedActivityColor());      setGridColor(gval.getGridColor());      setHandleColor(gval.getHandleColor());      setMarqueeColor(gval.getMarqueeColor());      setFontSize();//      ((JaWEMarqueeHandler)getMarqueeHandler()).enableBubblesButtons(JaWEConfig.getInstance().getUseBubblesStatus());//      updateStartEndBubbles();   }   protected void setFontSize () {//      boolean isModified=JaWE.getInstance().isModified();      List cellList=JaWEGraphModel.getAllCellsInModel(getModel());      if (cellList==null) return;      //Filter ports out      java.util.List list = new ArrayList();      for (Iterator i=cellList.iterator(); i.hasNext();) {         Object cell=i.next();         if (!(cell instanceof Port)) {            list.add(cell);         }      }      Object[] cells = list.toArray();            String fntn = JaWEManager.getFontName();      int fntsize=graphController.getGraphSettings().getGraphFontSize();      javax.swing.plaf.FontUIResource f;      try {         try {            f = new javax.swing.plaf.FontUIResource(fntn, Font.PLAIN, fntsize);         } catch (Exception ex) {            f = new javax.swing.plaf.FontUIResource("Label.font", Font.PLAIN, fntsize);         }         Map nested = new HashMap();         for (int i = 0; i < cells.length; i++) {            CellView view = getGraphLayoutCache().getMapping(cells[i], false);            if (view != null) {               Font font = GraphConstants.getFont(view.getAllAttributes());               if (font.getSize() == fntsize) {                  return;               }               AttributeMap attr = new AttributeMap();               GraphConstants.setFont(attr, f.deriveFont(fntsize));               nested.put(cells[i], attr);            }         }               //getGraphLayoutCache().edit(nested, null, null, null);         //graphModel.edit(nested,null,null,null);         ((JaWEGraphModel)graphModel).editFonts(nested);      } catch (Exception ex) {               }   }   /**    * Overrides  super method - don't need to waste a time for this.    */   public static void addSampleData(GraphModel model) {      return;   }      /**    * Notification from the <code>UIManager</code> that the L&F has changed.    * Replaces the current UI object with the latest version from the    * <code>UIManager</code>. Subclassers can override this to support    * different GraphUIs.    * @see JComponent#updateUI    *    */   public void updateUI() {      setUI(new JaWEGraphUI());      invalidate();   }      public String toString () {      XMLCollectionElement xpdlo=getXPDLObject();      if (xpdlo!=null) {         return JaWEManager.getInstance().getDisplayNameGenerator().getDisplayName(xpdlo);      }      return "";   }      public List checkConnections (boolean fullCheck) {      boolean wellConnected=true;      List verrors=new ArrayList();            // check start's and end's connections      Set icStarts=getImproperlyConnectedStarts(fullCheck);      if (icStarts.size()>0) {         wellConnected=false;         for (Iterator i=icStarts.iterator(); i.hasNext();) {            GraphActivityInterface s=(GraphActivityInterface)i.next();            ValidationError ve=null;            if (s instanceof GraphBubbleActivityInterface) {               ve=new ValidationError(                     new XMLValidationError(                           XMLValidationError.TYPE_ERROR,                           XMLValidationError.SUB_TYPE_CONNECTION,                           getGraphController().getSettings().getLanguageDependentString("ErrorConnectionToStartingActivityIsMissing"),                           "",                           s.getPropertyObject())                           );            } else {               ve=new ValidationError(                     new XMLValidationError(                           XMLValidationError.TYPE_ERROR,                           XMLValidationError.SUB_TYPE_CONNECTION,                           getGraphController().getSettings().getLanguageDependentString("ErrorIncomingTransitionOrConnectionFromStartBubbleIsMissing"),                           "",                           s.getPropertyObject())                           );            }            verrors.add(ve);            if (!(wellConnected || fullCheck)) {               break;            }         }      }      if (fullCheck || wellConnected) {         Set icEnds=getImproperlyConnectedEnds(fullCheck);         if (icEnds.size()>0) {            wellConnected=false;            for (Iterator i=icEnds.iterator(); i.hasNext();) {               GraphActivityInterface e=(GraphActivityInterface)i.next();               ValidationError ve=null;               if (e instanceof GraphBubbleActivityInterface) {                  if (e.getReferencingActivities().size()==0) {                     ve=new ValidationError(                           new XMLValidationError(                                 XMLValidationError.TYPE_ERROR,                                 XMLValidationError.SUB_TYPE_CONNECTION,                                 getGraphController().getSettings().getLanguageDependentString("ErrorConnectionFromEndingActivityIsMissing"),                                 "",                                 e.getPropertyObject())                                 );                  } else {                     ve=new ValidationError(                           new XMLValidationError(                                 XMLValidationError.TYPE_ERROR,                                 XMLValidationError.SUB_TYPE_CONNECTION,                                 getGraphController().getSettings().getLanguageDependentString("ErrorNotConnectedToEndingActivity"),                                 "",                                 e.getPropertyObject())                                 );                  }               } else {                  ve=new ValidationError(                        new XMLValidationError(                              XMLValidationError.TYPE_ERROR,                              XMLValidationError.SUB_TYPE_CONNECTION,                              getGraphController().getSettings().getLanguageDependentString("ErrorOutgoingTransitionOrConnectionToEndBubbleIsMissing"),                              "",                              e.getPropertyObject())                              );                                 }               verrors.add(ve);               if (!(wellConnected || fullCheck)) {                  break;               }            }         }      }      return verrors;   }   public Set getImproperlyConnectedStarts (boolean fullCheck) {      Set icStarts=new HashSet();      List allGraphActivities=JaWEGraphModel.getAllActivitiesInModel(graphModel);      if (allGraphActivities!=null) {         Iterator it=allGraphActivities.iterator();         while (it.hasNext()) {            GraphActivityInterface gact=(GraphActivityInterface)it.next();                        if (gact instanceof GraphBubbleActivityInterface && ((GraphBubbleActivityInterface)gact).isStart()) {               if (gact.getReferencedActivities().size()==0) {                  icStarts.add(gact);                  if (!fullCheck) {                     break;                  }               }            } else if (!(gact instanceof GraphBubbleActivityInterface)) {               Set incomingTrans=gact.getReferencingActivities();               if (incomingTrans.size()==0) {                  icStarts.add(gact);                  if (!fullCheck) {                     break;                  }               } //               else if (incomingTrans.size()==1) {//                  if (Utils.hasCircularTransitions(incomingTrans)) {//                     icStarts.add(act);//                     if (!fullCheck) {//                        break;//                     }//                  }//               }            }         }      }      return icStarts;   }   public Set getImproperlyConnectedEnds (boolean fullCheck) {      Set icEnds=new HashSet();      List allGraphActivities=JaWEGraphModel.getAllActivitiesInModel(graphModel);      if (allGraphActivities!=null) {         Iterator it=allGraphActivities.iterator();         while (it.hasNext()) {            GraphActivityInterface gact=(GraphActivityInterface)it.next();                        if (gact instanceof GraphBubbleActivityInterface && !((GraphBubbleActivityInterface)gact).isStart()) {               Set incT=gact.getReferencingActivities();               if (incT.size()==0) {                  icEnds.add(gact);                  if (!fullCheck) {                     break;                  }               } //               else if (incT.size()==1) {//                  Transition t=(Transition)incT.toArray()[0];//                  Activity a=(Activity)((DefaultPort)t.getSource()).getParent();//                  Set eas=XMLUtil.getEndingActivities((XMLCollectionElement)getXPDLObject());//                  if (!eas.contains(a.getPropertyObject())) {//                     icEnds.add(act);//                     if (!fullCheck) {//                        break;//                     }//                  }//               }            } else if (!(gact instanceof GraphBubbleActivityInterface)) {               Set excTrans=XMLUtil.getExceptionalOutgoingTransitions((Activity)gact.getPropertyObject());               Set outgoingTrans=gact.getReferencedActivities();               if (outgoingTrans.size()==0 || (outgoingTrans.size()==1 && excTrans.size()>0)) {                  icEnds.add(gact);                  if (!fullCheck) {                     break;                  }               }//               if (outgoingTrans.size()==1) {//                  if (Utils.hasCircularTransitions(outgoingTrans)) {//                     icEnds.add(act);//                     if (!fullCheck) {//                        break;//                     }//                  }//               }            }         }      }      return icEnds;   }      // TO AVOID MEMORY LEAK -> RENDERERS HOLD A REFERENCE TO GRAPHS   public void clearXPDLObjectReferences () {//      Object[] elem = JaWEGraphModel.getAll(graphModel);//      graphModel.remove(elem);//      setUI(null);//      wp=null;//      as=null;//      graphLayoutCache=null;//      graphModel=null;//      selectionModel=null;      DefaultGraphActivityView.renderers.clear();//      DefaultGraphBubbleActivityView.renderers.clear();      DefaultGraphParticipantView.renderers.clear();      DefaultGraphTransitionView.renderers.clear();      DefaultGraphPortView.renderers.clear();   }}

⌨️ 快捷键说明

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