public static Enumeration getRelationshipsModels(GraphManager gm){ Enumeration graphs=gm.getUOModels().elements(); Vector result=new Vector(); while (graphs.hasMoreElements()){ ModelJGraph jg=(ModelJGraph) graphs.nextElement(); for (int k=0;k<jg.getModel().getRootCount();k++){ Object cand=((DefaultGraphCell)jg.getModel().getRootAt(k)); if (cand!=null && ingenias.editor.cell.NAryEdge.class.isAssignableFrom(cand.getClass())){ result.add(jg); } } } return result.elements(); }
public static Enumeration getRelationshipsCells(GraphManager gm){ Enumeration graphs=gm.getUOModels().elements(); Vector result=new Vector(); while (graphs.hasMoreElements()){ ModelJGraph jg=(ModelJGraph) graphs.nextElement(); for (int k=0;k<jg.getModel().getRootCount();k++){ Object cand=((DefaultGraphCell)jg.getModel().getRootAt(k)); if (cand!=null && ingenias.editor.cell.NAryEdge.class.isAssignableFrom(cand.getClass())){ result.add(cand); } } } return result.elements(); } public static Enumeration getRelationshipsModels(GraphManager gm){
public static Enumeration getRelationships(GraphManager gm){ Enumeration graphs=gm.getUOModels().elements(); Vector result=new Vector(); while (graphs.hasMoreElements()){ ModelJGraph jg=(ModelJGraph) graphs.nextElement(); for (int k=0;k<jg.getModel().getRootCount();k++){ Object cand=((DefaultGraphCell)jg.getModel().getRootAt(k)).getUserObject(); if (cand!=null && ingenias.editor.entities.NAryEdgeEntity.class.isAssignableFrom(cand.getClass())){ result.add(cand); } } } return result.elements(); }
private static boolean contains(ModelJGraph graph, Entity entity2) { boolean found=false; for (int k=0;k<graph.getModel().getRootCount() && !found;k++){ if (graph.getModel().getRootAt(k) instanceof DefaultGraphCell){ if (((DefaultGraphCell)(graph.getModel().getRootAt(k))).getUserObject()!=null) found= ((DefaultGraphCell)(graph.getModel().getRootAt(k))).getUserObject().equals(entity2); } } return found; }
/** * Returns the roots of the specified model as a collection. This implementation * uses the GraphModel interface in the general case, but if the model is a * <code>DefaultGraphModel</code> the performance can be improved to * linear time. */ public static Collection getRootsAsCollection(GraphModel model) { Collection cells = null; if (model != null) { // If model is DefaultGraphModel, we can do a linear time getRoots if (model instanceof DefaultGraphModel) { cells = ((DefaultGraphModel) model).getRoots(); } else { cells = new LinkedHashSet(model.getRootCount()); for (int i = 0; i < cells.size(); i++) { cells.add(model.getRootAt(i)); } } } return cells; }
/** * Orders cells so that they reflect the model order. */ public static Object[] order(GraphModel model, Object[] cells) { if (cells != null) { Set cellSet = new HashSet(); for (int i = 0; i < cells.length; i++) cellSet.add(cells[i]); Stack stack = new Stack(); for (int i = model.getRootCount() - 1; i >= 0; i--) stack.add(model.getRootAt(i)); LinkedList result = new LinkedList(); while (!stack.isEmpty()) { Object tmp = stack.pop(); for (int i = model.getChildCount(tmp) - 1; i >= 0; i--) stack.add(model.getChild(tmp, i)); if (cellSet.remove(tmp)) result.add(tmp); } return result.toArray(); } return null; }
public static Vector<NAryEdgeEntity> getRelationshipsVector(GraphManager gm){ Enumeration graphs=gm.getUOModels().elements(); Vector result=new Vector(); while (graphs.hasMoreElements()){ ModelJGraph jg=(ModelJGraph) graphs.nextElement(); for (int k=0;k<jg.getModel().getRootCount();k++){ Object cand=((DefaultGraphCell)jg.getModel().getRootAt(k)).getUserObject(); if (cand!=null && ingenias.editor.entities.NAryEdgeEntity.class.isAssignableFrom(cand.getClass())){ result.add(cand); } } } return result; }
/** * Returns the roots of the specified model as an array. This implementation * uses the GraphModel interface in the general case, but if the model is a * <code>DefaultGraphModel</code> the performance can be improved to * linear time. */ public static Object[] getRoots(GraphModel model) { Object[] cells = null; if (model != null) { // If model is DefaultGraphModel, we can do a linear time getRoots if (model instanceof DefaultGraphModel) { cells = ((DefaultGraphModel) model).getRoots().toArray(); } else { cells = new Object[model.getRootCount()]; for (int i = 0; i < cells.length; i++) { cells[i] = model.getRootAt(i); } } } return cells; }
public static void solveOverlappings(ModelJGraph graph, Hashtable<DefaultGraphCell, Map> map) { Hashtable<Object,Map> naryedgeatts=new Hashtable<Object,Map>(); for (int k=0;k<graph.getModel().getRootCount();k++){ if (graph.getModel().getRootAt(k) instanceof NAryEdge){ /*if (changes.get(graph.getModel().getRootAt(k))!=null) naryedgeatts.put(graph.getModel().getRootAt(k), changes.get(graph.getModel().getRootAt(k))); else*/ naryedgeatts.put(graph.getModel().getRootAt(k), graph.getModel().getAttributes(graph.getModel().getRootAt(k))); } } Set<DefaultGraphCell> naries = map.keySet(); for (Object currentnary:naries){ if (currentnary instanceof NAryEdge){ Rectangle2D rect1= GraphConstants.getBounds(map.get(currentnary)); detectingOverlappingsAndRadialLayout(map, naryedgeatts, currentnary, rect1,graph); } } }
private DefaultGraphCell getCell(){ int max=graph.getModel().getRootCount(); Vector v=new Vector(); boolean found=false; int k=0; org.jgraph.graph.DefaultGraphCell dgc=null; while (k<max &&!found){ Object o=graph.getModel().getRootAt(k); if (o instanceof org.jgraph.graph.DefaultGraphCell){ dgc=(org.jgraph.graph.DefaultGraphCell)o; found=dgc.getUserObject()==rel; } k++; } return dgc; }
private DefaultGraphCell getGraphCell(ModelJGraph mj, String id) { for (int k = 0; k < mj.getModel().getRootCount(); k++) { DefaultGraphCell dgc = (DefaultGraphCell) mj.getModel().getRootAt(k); ingenias.editor.entities.Entity ent = (ingenias.editor.entities.Entity) dgc.getUserObject(); if (ent.getId().equalsIgnoreCase(id)) { return dgc; } } return null; }
public int repeatedInstanceInModels(String id){ int repeated=0; Vector v=this.getUOModels(); Enumeration enumeration=v.elements(); while (enumeration.hasMoreElements()){ ModelJGraph next=(ModelJGraph)enumeration.nextElement(); for (int k=0;k<next.getModel().getRootCount();k++){ Object root=next.getModel().getRootAt(k); if (root instanceof DefaultGraphCell && ((DefaultGraphCell) root).getUserObject() instanceof ingenias.editor.entities.Entity){ ingenias.editor.entities.Entity ent=(ingenias.editor.entities.Entity)((DefaultGraphCell)root).getUserObject(); if (ent.getId().equalsIgnoreCase(id)){ repeated++; } } } } return repeated; }
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; }
/** * Returns the cells that are currently selectable. The array is ordered so * that the top-most cell appears first. <br> */ public Object[] getSelectables() { if (isChildrenSelectable()) { List result = new ArrayList(); // Roots Are Always Selectable Stack s = new Stack(); GraphModel model = graph.getModel(); for (int i = 0; i < model.getRootCount(); i++) s.add(model.getRootAt(i)); while (!s.isEmpty()) { Object cell = s.pop(); AttributeMap attrs = graph.getAttributes(cell); if (!model.isPort(cell) && (attrs == null || GraphConstants.isSelectable(attrs))) result.add(cell); if (isChildrenSelectable(cell)) { for (int i = 0; i < model.getChildCount(cell); i++) s.add(model.getChild(cell, i)); } } return result.toArray(); } return graph.getRoots(); }
public void storeContraints(DefaultGraphCell cell) { Hashtable<DefaultGraphCell, Dimension> cellDimension = new Hashtable<DefaultGraphCell, Dimension>(); Entity ent=(Entity)cell.getUserObject(); String constraintKey = this.hashCode()+":"+cell.hashCode() + ":" + ent.getPrefs(jg.getModel().getAttributes(cell)).getView(); entityConstraints.put( constraintKey, cellDimension); for (int k = 0; k < jg.getModel().getRootCount(); k++) { if (jg.getModel().getRootAt(k) instanceof DefaultGraphCell && !(jg.getModel().getRootAt(k) instanceof DefaultEdge)) { DefaultGraphCell currentDGCRoot = (DefaultGraphCell) jg .getModel().getRootAt(k); //if (currentDGCRoot.getUserObject().equals(ent) if (currentDGCRoot.equals(cell) && currentDGCRoot.getAttributes() != null && GraphConstants.getBounds(currentDGCRoot .getAttributes()) != null) { cellDimension.put( currentDGCRoot, new Dimension((int) GraphConstants.getBounds( currentDGCRoot.getAttributes()).getWidth(), (int) GraphConstants.getBounds( currentDGCRoot.getAttributes()) .getHeight())); } } } }
ModelJGraph mjg=(ModelJGraph)enumeration.nextElement(); for (int k=0;k<mjg.getModel().getRootCount();k++){ if (mjg.getModel().getRootAt(k) instanceof DefaultGraphCell){ DefaultGraphCell dgc=(DefaultGraphCell)mjg.getModel().getRootAt(k); if (dgc.getUserObject().equals(oldent)){ dgc.setUserObject(newent);
/** * Gets the graphCell attribute of the GraphLoad object * *@param mj Description of Parameter *@param id Description of Parameter *@return The graphCell value */ private GraphCell getGraphCell(ModelJGraph mj, String id) { for (int k = 0; k < mj.getModel().getRootCount(); k++) { DefaultGraphCell dgc = (DefaultGraphCell) mj.getModel().getRootAt(k); ingenias.editor.entities.Entity ent = (ingenias.editor.entities.Entity) dgc.getUserObject(); if (ent.getId().equalsIgnoreCase(id)) { return dgc; } } return null; }
public void actionPerformed(ActionEvent e) { Log.getInstance().logERROR("Replacing"); try { Vector<GraphRelationship> rels = browser.findEntity(ent.getId()).getAllRelationships(); Entity newent = ConvertUtils.convert(state,ent.getId(), ent.getType(), current); for (int j=0;j<rels.size();j++){ ((GraphRelationshipImp)rels.elementAt(j)).getNAryEdge().replace(ent.getId(),newent); } Vector<ModelJGraph> models = state.gm.getUOModels(); for (int j=0;j<models.size();j++){ GraphModel mjg = models.elementAt(j).getModel(); for (int l=0;l<mjg.getRootCount();l++){ if (((DefaultGraphCell)mjg.getRootAt(l)).getUserObject().equals(ent)){ ((DefaultGraphCell)mjg.getRootAt(l)).setUserObject(newent); Log.getInstance().logERROR("Replaced in model "+models.elementAt(j).getName()); } } } } catch (Exception e1) { e1.printStackTrace(); Log.getInstance().log(e1.getMessage()); } } });
GraphModel gm=diagrams.elementAt(j).getModel(); for (int k=0;k<gm.getRootCount();k++){ DefaultGraphCell dgc = (DefaultGraphCell) gm.getRootAt(k); Object userobject=dgc.getUserObject(); CellView currentview=diagrams.elementAt(j).getGraphLayoutCache().getMapping(dgc,false);
public void resizeCurrentDiagram(ActionEvent e) { GraphModel gm=editor.getGraph().getModel(); for (int k=0;k<gm.getRootCount();k++){ DefaultGraphCell dgc = (DefaultGraphCell) gm.getRootAt(k); if (editor.getGraph().getListenerContainer().parentHasVisibleContainers(dgc).isEmpty()){ Object userobject=dgc.getUserObject(); CellView currentview=editor.getGraph().getGraphLayoutCache().getMapping(dgc,false); Entity ent=(Entity)dgc.getUserObject(); Map dgcMap=gm.getAttributes(dgc); if (ent!=null && RenderComponentManager.retrievePanel(ent.getType(),ent.getPrefs(dgcMap).getView())!=null){ Dimension dim=RenderComponentManager.getSize(ent,ent.getType(),ent.getPrefs(dgcMap).getView()); if (dim!=null){ Map attributes=dgc.getAttributes(); Rectangle2D loc=GraphConstants.getBounds(attributes); loc.setRect(loc.getX(),loc.getY(),dim.getWidth(),dim.getHeight()); GraphConstants.setBounds(attributes,loc); //attributes.put("view", ent.getPrefs(null).getView().toString()); Map nmap=new Hashtable(); nmap.put(dgc,attributes); editor.getGraph().getModel().edit(nmap,null,null,null); editor.getGraph().repaint(); } } } } } }