コード例 #1
0
  public org.jgraph.graph.CellView createView(GraphModel model, Object cell) {

    org.jgraph.graph.CellView view = null;
    if (model.isPort(cell)) view = new PortView(cell);
    else if (model.isEdge(cell)) view = createEdgeView(cell);
    else view = createVertexView(cell);
    return view;
  }
コード例 #2
0
 /**
  * Returns an list containing all graph cells taht have the same userObject.
  *
  * @param userObject The userObject for which all graph cels should be found.
  * @return java.util.List
  */
 private List<Object> getCellsWithUserObject(Object userObject) {
   List<Object> cells = new ArrayList<Object>();
   if (userObject != null) {
     // get the graph model, which contains all the cells of the graph
     GraphModel model = graph.getModel();
     // loop through all the cells of the model
     for (int i = 0; i < model.getRootCount(); i++) {
       Object root = model.getRootAt(i);
       // get the userObject for the curent graph cell
       Object rootUserObject = getUserObject(root);
       if (rootUserObject != null) {
         if (userObject == rootUserObject) {
           // the userObject of the current graph cell is teh same like the wanted userObject
           cells.add(root);
         }
       }
     }
   }
   return cells;
 }