public GraphEntity createModelEntity(String diagramType, String id,Graph diagram) throws InvalidEntity{ ModelEntity modelEntity; try { modelEntity = (ModelEntity) Class.forName("ingenias.editor.entities."+diagramType+"ModelEntity").getConstructor(new Class[]{String.class}).newInstance(id); GraphEntityImp gei=new GraphEntityImp(modelEntity,null,diagram.getGraph(),ids); return gei; } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | ClassNotFoundException e) { throw new InvalidEntity(e); // TODO Auto-generated catch block } catch (NullEntity e) { throw new InvalidEntity(e); } }
public static Vector< String> getPossibleRelationships( String[] connectedEntities, Graph graph) throws NotFound{ Vector<GraphCell> entities=new Vector<GraphCell>(); for (String entityID:connectedEntities) { DefaultGraphCell entity = findEntity(entityID,graph); if (entity==null) throw new ingenias.exception.NotFound("Entity "+entityID+" that you tried to connect did not exist in the graph "+graph.getName()); entities.add(findEntity(entityID,graph)); } GraphCell[] selected=new GraphCell[entities.size()]; selected=entities.toArray(selected); Object[] relObjArray = graph.getGraph().getPossibleRelationships(selected); Vector<String> result = new Vector<String>(); for (Object rel:relObjArray){ result.add(rel.toString()); } return result; }
private static DefaultGraphCell findEntity(String id, Graph graph){ DefaultGraphCell result=null; for (int k=0;k<graph.getGraph().getModel().getRootCount() && result==null;k++){ if (graph.getGraph().getModel().getRootAt(k) instanceof DefaultGraphCell){ DefaultGraphCell root=(DefaultGraphCell)graph.getGraph().getModel().getRootAt(k); if (root.getUserObject()!=null && ((Entity)root.getUserObject()).getId().equals(id)){ result=root; } } } return result; }
public GraphEntity createEntity(String entType, Graph diagram) throws InvalidEntity{ Model mjg = (Model) diagram.getGraph().getModel(); return createEntity(entType, mjg.getNewId(entType), diagram); }
bimp.getGraph(diagramPath); g = bimp.getGraph(diagramPath); ids.editor.changeGraph(g.getGraph()); g.getGraph().clearSelection(); Vector<DefaultGraphCell> dgcs=new Vector<DefaultGraphCell>(); for (int j=0;j<g.getGraph().getModel().getRootCount();j++){ dgc=(DefaultGraphCell)g.getGraph().getModel().getRootAt(j); if (dgc.getUserObject() instanceof Entity){ Entity ent=(Entity)dgc.getUserObject(); if (ent.getId().equals(entityPath)){ g.getGraph().addSelectionCell(dgc); dgcs.add(dgc); g.getGraph().scrollCellToVisible(dgcs.elementAt(lastScrolledIndex)); lastScrolledIndex=(lastScrolledIndex+1)%dgcs.size(); } else { g.getGraph().scrollCellToVisible(dgcs.elementAt(lastScrolledIndex)); for (int j=0;j<graphs[k].getGraph().getModel().getRootCount();j++){ DefaultGraphCell dgc=(DefaultGraphCell)graphs[k].getGraph().getModel().getRootAt(j); if (dgc.getUserObject() instanceof Entity){ Entity ent=(Entity)dgc.getUserObject(); if (ent.getId().equals(entity)){ userobject.add(ent); graphs[k].getGraph().setSelectionCell(dgc); graphs[k].getGraph().scrollCellToVisible(dgc);
Hashtable<String,String> assignment) throws InvalidEntity{ ModelJGraph graph = diagram.getGraph(); Collection<String> cells = assignment.values(); Vector<DefaultGraphCell> selectedV=new Vector<DefaultGraphCell>(); ConnectionSet cs = nEdge.connections(selectedAssignation, auxiliaryEdges, getPorts(newSelected, diagram.getGraph()));