public GraphEntity getPlayer() throws NullEntity{ return new GraphEntityImp(player,graph,ids); }
GraphEntityImp(ingenias.editor.entities.Entity ent, ModelJGraph graph, IDEState ids) throws NullEntity{ super(ent,graph,ids); if (ent==null) throw new ingenias.exception.NullEntity(); this.ent=ent; this.graph=graph; dgc=this.getCell(graph); this.ids=ids; if (graph==null){ throw new RuntimeException("Graph is null in entity "+ent+ " when creating a GraphEntityImp"); } if (ids==null) throw new RuntimeException("The ids parameter cannot be null"); this.browser=new BrowserImp(ids); }
public GraphCollection createCollection(Vector<GraphEntity> elements, Graph g) throws InvalidColection{ if (elements.size()>0){ TypedVector tv=new TypedVector(((GraphEntityImp)elements.firstElement()).getEntity().getClass()); for (int k=0;k<elements.size();k++){ tv.add(((GraphEntityImp)elements.elementAt(k)).getEntity()); } return new GraphCollectionImp(tv,((GraphImp)g).getGraph(),ids); } throw new InvalidColection("Collection used is empty"); }
private HashSet<GraphRelationship> getRelationshipsFromAGraph(ingenias.editor.ModelJGraph graph){ HashSet<GraphRelationship> v=new HashSet<GraphRelationship>(); Enumeration dgcs=this.getCells(graph).elements(); while (dgcs.hasMoreElements()){ DefaultGraphCell dgc=(DefaultGraphCell)dgcs.nextElement(); if (dgc!=null && dgc.getChildren()!=null){ Iterator ports=dgc.getChildren().iterator(); while (ports.hasNext()){ Object port=ports.next(); Iterator it=graph.getModel().edges(port); while (it.hasNext()){ org.jgraph.graph.Edge current= (org.jgraph.graph.Edge)it.next(); DefaultGraphCell extr=this.getExtreme(current); ingenias.editor.entities.NAryEdgeEntity nary= (ingenias.editor.entities.NAryEdgeEntity)extr.getUserObject(); v.add(new GraphRelationshipImp(nary,graph,ids)); } } } } return v; }
public void setAttribute(GraphAttribute ga) throws InvalidAttribute{ try { GraphAttribute oldga=this.getAttributeByName(ga.getName()); ((GraphAttributeImp)oldga).setValue(((GraphAttributeImp)ga).getValue()); Object nvalue=((GraphAttributeImp)ga).getValue(); nvalue=((GraphEntityImp)nvalue).getEntity();
public Vector<GraphRelationship> getAllRelationships(){ HashSet<GraphRelationship> result=new HashSet<GraphRelationship>(); Graph[] g=null; g = browser.getGraphs(); for (int k=0;k<g.length;k++){ HashSet rel=this.getRelationshipsFromAGraph(((GraphImp)g[k]).getGraph()); result.addAll(rel); } return new Vector<GraphRelationship>(result); }
public GraphRelationship[] getRelationships(){ Vector v=new Vector(); Iterator ports=dgc.getChildren().iterator(); while (ports.hasNext()){ Object port=ports.next(); Iterator it=graph.getModel().edges(port); while (it.hasNext()){ org.jgraph.graph.Edge current= (org.jgraph.graph.Edge)it.next(); DefaultGraphCell extr=this.getExtreme(current); ingenias.editor.entities.NAryEdgeEntity nary= (ingenias.editor.entities.NAryEdgeEntity)extr.getUserObject(); v.add(nary); } } GraphRelationship[] result=new GraphRelationship[v.size()]; for (int k=0;k<result.length;k++){ result[k]=new GraphRelationshipImp((NAryEdgeEntity)v.elementAt(k),graph,ids); } return result; }
public static void setAttribute(GraphEntity ge, GraphAttribute ga) throws InvalidAttribute{ ((GraphEntityImp)ge).setAttribute(ga); }
private DefaultGraphCell getCell(org.jgraph.JGraph graph){ List roots=new Vector(((DefaultGraphModel)graph.getModel()).getRoots()); Vector v=new Vector(); boolean found=false; int k=0; Vector dgcs=getCells(graph); org.jgraph.graph.DefaultGraphCell dgc=null; while (k<roots.size() &&!found){ Object o=roots.get(k); if (o instanceof org.jgraph.graph.DefaultGraphCell){ dgc=(org.jgraph.graph.DefaultGraphCell)o; if (dgc.getUserObject()!=null) found=((ingenias.editor.entities.Entity)dgc.getUserObject()).getId().equals(ent.getId()); } k++; } return dgc; }
GraphEntity ge = gesWithDups[j]; GraphEntityImp gei = (ingenias.generator.browser.GraphEntityImp)ge; DefaultGraphCell dgc1=gei.getDgc(); AttributeMap attributes = dgc1.getAttributes(); Rectangle2D bounds = org.jgraph.graph.GraphConstants.getBounds(attributes); DefaultGraphCell dgc1=gei.getDgc(); AttributeMap attributes = dgc1.getAttributes(); Rectangle2D bounds = org.jgraph.graph.GraphConstants.getBounds(attributes);
public Vector getAllRelationships(String relType){ HashSet<GraphRelationship> result=new HashSet<GraphRelationship>(); Graph[] g=null; g = browser.getGraphs(); for (int k=0;k<g.length;k++){ HashSet<GraphRelationship> rel=this.getRelationshipsFromAGraph(((GraphImp)g[k]).getGraph()); for (GraphRelationship gr:rel){ if (gr.getType().equalsIgnoreCase(relType)) result.add(gr); } } return new Vector<GraphRelationship>(result); }
@Override public GraphRelationship[] getRelationships(String type) { Vector v=new Vector(); Iterator ports=dgc.getChildren().iterator(); while (ports.hasNext()){ Object port=ports.next(); Iterator it=graph.getModel().edges(port); while (it.hasNext()){ org.jgraph.graph.Edge current= (org.jgraph.graph.Edge)it.next(); DefaultGraphCell extr=this.getExtreme(current); ingenias.editor.entities.NAryEdgeEntity nary= (ingenias.editor.entities.NAryEdgeEntity)extr.getUserObject(); if (nary.getType().equalsIgnoreCase(type)) v.add(nary); } } GraphRelationship[] result=new GraphRelationship[v.size()]; for (int k=0;k<result.length;k++){ result[k]=new GraphRelationshipImp((NAryEdgeEntity)v.elementAt(k),graph,ids); } return result; }
public GraphEntity getEntityValue() throws NullEntity { if (attribute == null) { throw new NullEntity(); } else { return new GraphEntityImp( (ingenias.editor.entities.Entity) attribute, graph,ids); } }
public GraphEntity getElementAt(int k) throws NullEntity{ return new GraphEntityImp((Entity)tv.elementAt(k),g,ids); }
public GraphEntity createEntityWithoutDiagram(String entType, String id) { Method m; try { m = ids.om.getClass().getMethod("create"+entType,new Class[]{String.class}); Entity result=(Entity)(m.invoke(ids.om,new Object[]{id})); GraphEntityImp gei=new GraphEntityImp(result,null,ids); return gei; } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NullEntity e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
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); } }
GraphEntity ge=null; ge = new GraphEntityImp(ne, dgc,mjg,ids);
GraphEntity ge=null; ge = new GraphEntityImp(ne, mjg,ids);
GraphEntityImp gei=new GraphEntityImp(result,((GraphImp)diagram).getGraph(),ids);
GraphEntityImp gei=new GraphEntityImp(result,((GraphImp)diagram).getGraph(),ids); if (this.isGraphicalEntity(result.getType())){