Package org.jgraph.graph

Examples of org.jgraph.graph.GraphModel


   * @return Object[] Array of parallel edges (include edge passed on
   *         argument)
   */
  protected Object[] getParallelEdges(GraphLayoutCache cache, EdgeView edge,
      CellView cellView1, CellView cellView2) {
    GraphModel model = cache.getModel();
    Object cell1 = cellView1.getCell();
    Object cell2 = cellView2.getCell();
    // Need to exit if a load has just been performed and the model
    // isn't in place properly yet
    Object[] roots = DefaultGraphModel.getRoots(model);
    if (roots.length == 0) {
      return null;
    }
    // Need to order cells so direction of the edges doesn't
    // affect the ordering of the output edges
    Object[] cells = new Object[] { cell1, cell2 };
    cells = DefaultGraphModel.order(model, cells);
    if (cells == null || cells.length < 2) {
      return null;
    }
    cell1 = cells[0];
    cell2 = cells[1];
    // System.out
    // .println("cell1 of parallel edges = "
    // + String.valueOf(((DefaultGraphCell) cell1)
    // .getUserObject()));
    while (model.getParent(cell1) != null && !cache.isVisible(cell1)) {
      cell1 = model.getParent(cell1);
      // if (cache.isVisible(cell1)) {
      // System.out
      // .println("cell1 promoted to = "
      // + String.valueOf(((DefaultGraphCell) cell1)
      // .getUserObject()));

      // }
    }
    // System.out
    // .println("cell2 of parallel edges = "
    // + String.valueOf(((DefaultGraphCell) cell2)
    // .getUserObject()));
    while (model.getParent(cell2) != null && !cache.isVisible(cell2)) {
      cell2 = model.getParent(cell2);
      // if (cache.isVisible(cell2)) {
      // System.out
      // .println("cell2 promoted to = "
      // + String.valueOf(((DefaultGraphCell) cell2)
      // .getUserObject()));
View Full Code Here


                return (PortView) result;
            }
        }

        // Shortcut Variable
        GraphModel model = getEditor().getGraph().getModel();
        // Loop Children to find first PortView
        for (int i = 0; i < model.getChildCount(cell); i++) {
            // Get Child from Model
            Object tmp = getEditor().getGraph().getModel().getChild(cell, i);
            // Map Cell to View
            // ??? lai
            tmp = getEditor().getGraph().getGraphLayoutCache().getMapping(tmp, false);
View Full Code Here

     * @param cells
     */
    public void ungroup(Object[] cells)
    {
        // Shortcut to the model
        GraphModel graphModel = getModel();
        GroupModel aGroup;
        // If any Cells
        if (cells != null && cells.length > 0)
        {
            // List that Holds the Groups
            ArrayList<Object> groups = new ArrayList<Object>();
            // List that Holds the Children
            ArrayList<Object> children = new ArrayList<Object>();
            // Loop Cells
            for (int i = 0; i < cells.length; i++)
            {
                // If Cell is a Group
                if (isGroup(cells[i]))
                {
                    aGroup = (GroupModel) cells[i];
                    if (aGroup.isUngroupable())
                    {
                        // Add to List of Groups
                        groups.add(cells[i]);
                        // Loop Children of Cell
                        for (int j = 0; j < graphModel.getChildCount(cells[i]); j++) {
                            // Get Child from Model
                            children.add(graphModel.getChild(cells[i], j));
                        }
                    }
                }
                // Remove Groups from Model (Without Children)
                graphModel.remove(groups.toArray());
                // Select Children
                setSelectionCells(children.toArray());
                LoggerManager.debug(Constants.CORE_LOGGER, "Grouping of Elements deleted. ");
            }
        }
View Full Code Here

   *
   * @param newModel
   *            the <code>GraphModel</code> that is to provide the data
   */
  public void setModel(GraphModel newModel) {
    GraphModel oldModel = graphModel;
    graphModel = newModel;
    clearOffscreen();
    firePropertyChange(GRAPH_MODEL_PROPERTY, oldModel, graphModel);
    // FIX: Use Listener
    if (graphLayoutCache != null
View Full Code Here

      root.appendChild(titleNode);
      dy -= titleheight;
    }

    // "Draws" all views, topmost first
    GraphModel model = cache.getModel();
    CellView[] views = cache.getAllViews();
    for (int i = 0; i < views.length; i++) {
      Object cell = views[i].getCell();
      if (!model.isPort(cell)) {

        // Invokes edge- or vertex renderer based on the cell type
        Node node = (model.isEdge(cell)) ? edgeFactory.createNode(this,
            document, views[i], dx, dy) : vertexFactory.createNode(
            this, document, cache, views[i], dx, dy);
        if (node != null) {
          root.appendChild(node);
        }
View Full Code Here

        return loadPython;
    }

    private JGraph setupGraph() {
        // Construct Model and Graph
        GraphModel model = new DefaultGraphModel();
        JGraph graph = new JGraph(model);

        // Control-drag should clone selection
        graph.setCloneable(true);
View Full Code Here

public class HelloWorld {

  public static void main(String[] args) {

    // Construct Model and Graph
    GraphModel model = new DefaultGraphModel();
    JGraph graph = new JGraph(model);

    // Control-drag should clone selection
    graph.setCloneable(true);
View Full Code Here

   *
   * @param newModel
   *            the <code>GraphModel</code> that is to provide the data
   */
  public void setModel(GraphModel newModel) {
    GraphModel oldModel = graphModel;
    graphModel = newModel;
    firePropertyChange(GRAPH_MODEL_PROPERTY, oldModel, graphModel);
    // FIX: Use Listener
    if (graphLayoutCache != null
        && graphLayoutCache.getModel() != graphModel)
View Full Code Here

TOP

Related Classes of org.jgraph.graph.GraphModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.