Tabnine Logo
DefaultGraphModel.getRoots
Code IndexAdd Tabnine to your IDE (free)

How to use
getRoots
method
in
org.jgraph.graph.DefaultGraphModel

Best Java code snippets using org.jgraph.graph.DefaultGraphModel.getRoots (Showing top 17 results out of 315)

origin: net.sf.ingenias/ingeniasjgraphmod

/**
 * Returns all root cells (cells that have no parent) that the model
 * contains.
 */
public Object[] getRoots() {
  return DefaultGraphModel.getRoots(graphModel);
}
origin: net.sf.ingenias/ingeniasjgraphmod

/**
 * Returns all cells including all descendants.
 */
protected List getAll() {
  return DefaultGraphModel.getDescendants(model, DefaultGraphModel
      .getRoots(model));
}
origin: net.sf.ingenias/ingeniasjgraphmod

/**
 * Returns all cells of the model in an array.
 * 
 * @see #getDescendants(GraphModel, Object[])
 * 
 * @return Returns all cells in the model including all descandants.
 */
public static Object[] getAll(GraphModel model) {
  return getDescendants(model, getRoots(model)).toArray();
}
origin: uk.org.mygrid.taverna.scufl/scufl-ui

/**
 * @param model
 * @return all edges in the model
 */
public static Set getAllEdges(GraphModel model)
{
  List cells = DefaultGraphModel.getDescendants(model, (DefaultGraphModel.getRoots(model)));
  if (cells != null)
  {
    Set result = new HashSet();
    for (int index = 0; index < cells.size(); index++)
      if (model.isEdge(cells.get(index)))
        result.add(cells.get(index));
    return result;
  }
  return null;
}
origin: net.sf.ingenias/ingeniasjgraphmod

/**
 * 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;
}
origin: net.sf.ingenias/ingeniasjgraphmod

/**
 * Divides the graph into groups of sibling vertices, vertices that
 * share the same parent. This is mostly used for layouting of cell
 * relative to their group context.
 *
 */
protected void determineLayoutHierarchies() {
  if (model != null) {
    groupHierarchies = new ArrayList();
    Set rootsSet = null;
    Object[] modelRoots = DefaultGraphModel.getRoots(model);
    for (int i = 0; i < modelRoots.length; i++) {
      if (DefaultGraphModel.isVertex(model, modelRoots[i])) {
        populateGroupHierarchies(modelRoots[i]);
        if (rootsSet == null) {
          rootsSet = new LinkedHashSet();
        }
        rootsSet.add(modelRoots[i]);
      }
    }
    if (rootsSet != null) {
      groupHierarchies.add(rootsSet);
    }
    
  }
}
origin: net.sf.ingenias/editor

public void hideOrShowChildrenAndDrawExtraEdges() {
  Vector<Runnable> graphicmodificationactions = new Vector<Runnable>();
  for (Object root : DefaultGraphModel.getRoots(dgm)) {
    Object nedge;
    final DefaultGraphCell vertex = (DefaultGraphCell) root;
    if (parentHasVisibleContainers(vertex).isEmpty()) {
      // hide children
      hideAllChildren(graphicmodificationactions, vertex);
    } else {
      showAllChildren(vertex);
    }
  }
  for (Runnable run : graphicmodificationactions) {
    run.run(); // insert pending edges, if there is any
  }
}
origin: net.sf.ingenias/ingeniasjgraphmod

/**
 * 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;
}
origin: net.sf.ingenias/ingeniasjgraphmod

/**
 * Updates the cached array of ports.
 */
protected void updatePorts() {
  Object[] roots = DefaultGraphModel.getRoots(graphModel);
  List list = DefaultGraphModel.getDescendants(graphModel, roots);
  if (list != null) {
    ArrayList result = new ArrayList();
    Iterator it = list.iterator();
    while (it.hasNext()) {
      Object cell = it.next();
      if (graphModel.isPort(cell)) {
        CellView portView = getMapping(cell, false);
        if (portView != null) {
          result.add(portView);
          portView.refresh(this, this, false);
        }
      }
    }
    ports = new PortView[result.size()];
    result.toArray(ports);
  }
}
origin: net.sf.ingenias/editor

private Vector getCells(org.jgraph.JGraph graph){		
  List roots=new Vector(((DefaultGraphModel)graph.getModel()).getRoots());
  Vector v=new Vector();
  boolean found=false;
  int k=0;
  Vector dgcs=new Vector();
  org.jgraph.graph.DefaultGraphCell dgc=null;
  while (k<roots.size()){
    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());
      if (found)
        dgcs.add(dgc);
    }
    k++;
  }
  return dgcs;
}
origin: net.sf.ingenias/ingeniasjgraphmod

/**
 * Sets the current model.
 */
public void setModel(GraphModel model) {
  roots.clear();
  mapping.clear();
  hiddenMapping.clear();
  visibleSet.clear();
  graphModel = model;
  if (!isPartial()) {
    Object[] cells = DefaultGraphModel.getRoots(getModel());
    CellView[] cellViews = getMapping(cells, true);
    insertViews(cellViews);
  }
  // Update PortView Cache and Notify Observers
  update();
}
origin: net.sf.ingenias/editor

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;
}
origin: net.sf.ingenias/editor

private void initializeOccupiedPositions() {
  occupiedpositions.clear();
  for (Object obj : dgm.getRoots()) {
    if (obj instanceof DefaultGraphCell) {
      // if (getChildren(obj).isEmpty()){
      if (dgm.getAttributes(obj) != null
          && GraphConstants.getBounds(dgm.getAttributes(obj)) != null)
        occupiedpositions.put((DefaultGraphCell) obj,
            GraphConstants.getBounds(dgm.getAttributes(obj)));
      // }
    }
  }
}
origin: net.sf.ingenias/ingeniasjgraphmod

Object[] cells = DefaultGraphModel.getRoots(model);
if (cells != null && cells.length > 0) {
  Rectangle2D ret = null;
origin: net.sf.ingenias/ingeniasjgraphmod

Object[] roots = DefaultGraphModel.getRoots(model);
if (roots.length == 0) {
  return null;
origin: net.sf.ingenias/ingeniasjgraphmod

public void graphLayoutCacheChanged(GraphLayoutCacheEvent e) {
  Object[] changed = e.getChange().getChanged();
  if (changed != null && changed.length > 0) {
    for (int i = 0; i < changed.length; i++) {
      graph.updateAutoSize(graphLayoutCache.getMapping(
          changed[i], false));
    }
  }
  Rectangle2D oldDirtyRegion = e.getChange().getDirtyRegion();
  graph.addOffscreenDirty(oldDirtyRegion);
  Rectangle2D newDirtyRegion = graph.getClipRectangle(e.getChange());
  graph.addOffscreenDirty(newDirtyRegion);
  Object[] inserted = e.getChange().getInserted();
  if (inserted != null
      && inserted.length > 0
      && graphLayoutCache.isSelectsLocalInsertedCells()
      && !(graphLayoutCache.isSelectsAllInsertedCells() && !graphLayoutCache
          .isPartial()) && graph.isEnabled()) {
    Object[] roots = DefaultGraphModel.getRoots(graphModel,
        inserted);
    if (roots != null && roots.length > 0) {
      lastFocus = focus;
      focus = graphLayoutCache.getMapping(roots[0], false);
      graph.setSelectionCells(roots);
    }
  }
  updateSize();
}
origin: net.sf.ingenias/ingeniasjgraphmod

  && graphLayoutCache.isSelectsAllInsertedCells()
  && graph.isEnabled()) {
Object[] roots = DefaultGraphModel.getRoots(graphModel,
    inserted);
if (roots != null && roots.length > 0) {
org.jgraph.graphDefaultGraphModelgetRoots

Javadoc

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 DefaultGraphModel the performance can be improved to linear time.

Popular methods of DefaultGraphModel

  • <init>
    Constructs a model using the specified information to construct the cells, attributes and connection
  • getEdges
    Returns the set of all connected edges to cells or their descendants. The passed-in cells are never
  • isGroup
    Checks whether the cell has at least one child which is not a port. This implementation operates on
  • connect
    Connects or disconnects the edge and port in this model based onremove. Subclassers should override
  • edit
    Applies attributes and the connection changes to the model. The initial edits that triggered the ca
  • getAll
    Returns all cells of the model in an array.
  • getAttributes
    Returns a Map that represents the attributes for the specified cell. This attributes have precedence
  • getDescendants
    Flattens the given array of root cells by adding the roots and their descandants. The resulting set
  • getRootsAsCollection
    Returns the roots of the specified model as a collection. This implementation uses the GraphModel in
  • addUndoableEditListener
  • cloneCell
    Returns a deep clone of the specified cells, including all children.
  • cloneUserObject
    Clones the user object. Helper method that is invoked from cloneCells. You must use cloneCells (or c
  • cloneCell,
  • cloneUserObject,
  • createEdit,
  • createLayerEdit,
  • createRemoveEdit,
  • fireGraphChanged,
  • getChildCount,
  • getEdgesBetween,
  • getGraphModelListeners

Popular in Java

  • Parsing JSON documents to java classes using gson
  • scheduleAtFixedRate (Timer)
  • onRequestPermissionsResult (Fragment)
  • getSupportFragmentManager (FragmentActivity)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now