Package org.jgraph.graph

Examples of org.jgraph.graph.ConnectionSet$Connection


    GraphConstants.setLineEnd(edge.getAttributes(), arrow);
    GraphConstants.setEndFill(edge.getAttributes(), true);
    setLineAttribs(edge);

      // Create ConnectionSet for Insertion
      ConnectionSet cs = new ConnectionSet(edge, wcCell.getChildAt(0), wsCell.getChildAt(0));

      // Add Edge and Connections to the Model
      Object[] insert = new Object[]{edge};
      model.insert(insert, null,cs, null, null);
View Full Code Here


      Object sourceKey = ((CellComponent) ((JmtCell) ((OutputPort) (outPort.getCell())).getUserObject()).getUserObject()).getKey();
      Object targetKey = ((CellComponent) ((JmtCell) ((InputPort) (inPort.getCell())).getUserObject()).getUserObject()).getKey();
      JmtEdge connection = new JmtEdge(sourceKey, targetKey, this);
      viewMap.put(connection, map);
      Object[] insert = new Object[] { connection };
      ConnectionSet cs = new ConnectionSet();
      cs.connect(connection, outPort.getCell(), true);
      cs.connect(connection, inPort.getCell(), false);
      // Visualize connection only if it can be created into data
      // structure
      if (model.setConnected(sourceKey, targetKey, true)) {
        graph.getModel().insert(insert, viewMap, cs, null, null);
        // FG
View Full Code Here

    GraphConstants.setEndFill(map, true);
    Map<Object, Map> viewMap = new Hashtable<Object, Map>();
    JmtEdge connection = new JmtEdge(sourceKey, targetKey, this);
    viewMap.put(connection, map);
    Object[] insert = new Object[] { connection };
    ConnectionSet cs = new ConnectionSet();
    // Finds sourcePort
    Iterator it;
    it = source.getChildren().iterator();
    DefaultPort tmpPort, sourcePort, targetPort;
    sourcePort = null;
    while (it.hasNext()) {
      tmpPort = (DefaultPort) it.next();
      if (tmpPort instanceof OutputPort) {
        sourcePort = tmpPort;
      }
    }
    // Finds targetPort
    it = target.getChildren().iterator();
    targetPort = null;
    while (it.hasNext()) {
      tmpPort = (DefaultPort) it.next();
      if (tmpPort instanceof InputPort) {
        targetPort = tmpPort;
      }
    }
    if (sourcePort != null && targetPort != null) {
      cs.connect(connection, sourcePort, true);
      cs.connect(connection, targetPort, false);
      // Adds connection to the graph only if it can be created into data
      // structure
      if (model.setConnected(sourceKey, targetKey, true) || forced) {
        graph.getModel().insert(insert, viewMap, cs, null, null);
        return connection;
View Full Code Here

  java.text.NumberFormat numberFormat = java.text.NumberFormat.getInstance();

  private void openModel() {
    try {
      // Intersections model
      ConnectionSet intersectionSet = new ConnectionSet();

      // Attributes
      java.util.HashMap attributes = new java.util.HashMap();

      java.net.URL url =
        new java.net.URL(
          this.getCodeBase().toString() + getParameter("url"));
      java.io.InputStream inp = url.openStream();
      java.io.ObjectInputStream obj = new java.io.ObjectInputStream(inp);
      GraphCallings callings = (GraphCallings) obj.readObject();
      callings.printDebug();

      DefaultGraphCell elements[] =
        new DefaultGraphCell[callings.getMethods().size()
          + callings.getReferences().size()];

      int currentLevel = -1;
      int currentCell = -1;
      int currentElement = 0;

      Iterator iter = callings.getMethods().iterator();

      HashMap hashMethods = new HashMap();

      while (iter.hasNext()) {
        GraphMethod graphmethod = (GraphMethod) iter.next();

        if (graphmethod.getLevel() != currentLevel) {
          currentLevel = graphmethod.getLevel();
          currentCell = 0;
        } else {
          currentCell++;
        }

        DefaultGraphCell graphcell = new DefaultGraphCell(graphmethod);
        graphcell.add(new DefaultPort("port/Center"));
        graphcell.add(new DefaultPort("port/Left"));
        Color color = null;
        switch (currentCell) {
          case 0 :
            color = Color.red;
            break;
          case 1 :
            color = Color.yellow;
            break;
          default :
            color = Color.blue;
            break;
        }
        attributes.put(
          graphcell,
          createBounds(currentLevel, currentCell, color));
        elements[currentElement++] = graphcell;
        hashMethods.put(graphmethod, graphcell);
      }

      Map simpleArrow = GraphConstants.createMap();
      GraphConstants.setLineEnd(
        simpleArrow,
        GraphConstants.ARROW_CLASSIC);
      GraphConstants.setBeginSize(simpleArrow, 10);
      GraphConstants.setDashPattern(simpleArrow, new float[] { 3, 3 });
      GraphConstants.setFont(
        simpleArrow,
        GraphConstants.defaultFont.deriveFont(10));

      GraphMethod key = new GraphMethod();

      iter = callings.getReferences().iterator();
      while (iter.hasNext()) {
        GraphReference referenceCalling = (GraphReference) iter.next();

        key.setMethodId(referenceCalling.getMethodCallee());
        key.setLevel(referenceCalling.getLevelCallee());
        DefaultGraphCell cellcallee =
          (DefaultGraphCell) hashMethods.get(key);

        key.setMethodId(referenceCalling.getMethodCalled());
        key.setLevel(referenceCalling.getLevelCalled());
        DefaultGraphCell cellcalled =
          (DefaultGraphCell) hashMethods.get(key);

                if (cellcallee!=null && cellcalled!=null) {
          DefaultEdge relationship =
            new DefaultEdge(
              numberFormat.format(
                referenceCalling.getPercentageCPU())
                + "%");
          elements[currentElement++] = relationship;

          intersectionSet.connect(
            relationship,
            cellcallee.getChildAt(0),
            cellcalled.getChildAt(1));
          attributes.put(relationship, simpleArrow);
                }
View Full Code Here

  java.text.NumberFormat numberFormat = java.text.NumberFormat.getInstance();

  private void openModel() {
    try {
      // Intersections model
      ConnectionSet intersectionSet = new ConnectionSet();

      // Attributes
      java.util.HashMap attributes = new java.util.HashMap();

      GraphCallings callings = readObject();
      callings.printDebug();

      DefaultGraphCell elements[] =
        new DefaultGraphCell[callings.getMethods().size()
          + callings.getReferences().size()];

      int currentLevel = -1;
      int currentCell = -1;
      int currentElement = 0;

      Iterator iter = callings.getMethods().iterator();

      HashMap hashMethods = new HashMap();

      while (iter.hasNext()) {
        GraphMethod graphmethod = (GraphMethod) iter.next();

        if (graphmethod.getLevel() != currentLevel) {
          currentLevel = graphmethod.getLevel();
          currentCell = 0;
        } else {
          currentCell++;
        }

        DefaultGraphCell graphcell = new DefaultGraphCell(graphmethod);
        graphcell.add(new DefaultPort("port/Center"));
        graphcell.add(new DefaultPort("port/Left"));
        Color color = null;
        switch (currentCell) {
          case 0 :
            color = Color.red;
            break;
          case 1 :
            color = Color.yellow;
            break;
          default :
            color = Color.blue;
            break;
        }
        attributes.put(
          graphcell,
          createBounds(currentLevel, currentCell, color));
        elements[currentElement++] = graphcell;
        hashMethods.put(graphmethod, graphcell);
      }

      Map simpleArrow = GraphConstants.createMap();
      GraphConstants.setLineEnd(
        simpleArrow,
        GraphConstants.ARROW_CLASSIC);
      GraphConstants.setBeginSize(simpleArrow, 10);
      GraphConstants.setDashPattern(simpleArrow, new float[] { 3, 3 });
      GraphConstants.setFont(
        simpleArrow,
        GraphConstants.defaultFont.deriveFont(10));

      GraphMethod key = new GraphMethod();

      iter = callings.getReferences().iterator();
      while (iter.hasNext()) {
        GraphReference referenceCalling = (GraphReference) iter.next();

        key.setMethodId(referenceCalling.getMethodCallee());
        key.setLevel(referenceCalling.getLevelCallee());
        DefaultGraphCell cellcallee =
          (DefaultGraphCell) hashMethods.get(key);

        key.setMethodId(referenceCalling.getMethodCalled());
        key.setLevel(referenceCalling.getLevelCalled());
        DefaultGraphCell cellcalled =
          (DefaultGraphCell) hashMethods.get(key);

        DefaultEdge relationship =
          new DefaultEdge(
            numberFormat.format(
              referenceCalling.getInstancesCreated())
              + " instances");
        elements[currentElement++] = relationship;

                if (cellcallee!=null && cellcalled!=null) {
          intersectionSet.connect(
            relationship,
            cellcallee.getChildAt(0),
            cellcalled.getChildAt(1));

          attributes.put(relationship, simpleArrow);
View Full Code Here

                    // attrs.translate(dx, dy);
                    attributes.put(cells[i], attrs.clone());
                  }
                }
              }
              ConnectionSet cs = ConnectionSet.create(graphModel,
                  cells, false);
              ParentMap pm = ParentMap.create(graphModel, cells,
                  false, true);
              cells = graphLayoutCache.insertClones(cells, graph
                  .cloneCells(cells), attributes, cs, pm, 0,
View Full Code Here

        if (isValidConnection(source, target))
        {
            source.addEdge(edge);
            target.addEdge(edge);
            // Use Edge to Connect Source and Target
            ConnectionSet cs = new ConnectionSet(edge, source, target);
            // Create a Map that holds the attributes for the edge
            AttributeMap attr = edge.getAttributes();// GraphConstants.createMap();
            // Construct a Map from cells to Maps (for insert)
            Hashtable<DefaultEdge, AttributeMap> nest = new Hashtable<DefaultEdge, AttributeMap>();
            // Associate the Edge with its Attributes
View Full Code Here

  /**
   * Creates and returns a sample <code>GraphModel</code>. Used primarily
   * for beanbuilders to show something interesting.
   */
  public static void addSampleData(GraphModel model) {
    ConnectionSet cs = new ConnectionSet();
    Map attributes = new Hashtable();
    // Styles For Implement/Extend/Aggregation
    AttributeMap implementStyle = new AttributeMap();
    GraphConstants.setLineBegin(implementStyle,
        GraphConstants.ARROW_TECHNICAL);
    GraphConstants.setBeginSize(implementStyle, 10);
    GraphConstants.setDashPattern(implementStyle, new float[] { 3, 3 });
    if (GraphConstants.DEFAULTFONT != null) {
      GraphConstants.setFont(implementStyle, GraphConstants.DEFAULTFONT
          .deriveFont(10));
    }
    AttributeMap extendStyle = new AttributeMap();
    GraphConstants
        .setLineBegin(extendStyle, GraphConstants.ARROW_TECHNICAL);
    GraphConstants.setBeginFill(extendStyle, true);
    GraphConstants.setBeginSize(extendStyle, 10);
    if (GraphConstants.DEFAULTFONT != null) {
      GraphConstants.setFont(extendStyle, GraphConstants.DEFAULTFONT
          .deriveFont(10));
    }
    AttributeMap aggregateStyle = new AttributeMap();
    GraphConstants.setLineBegin(aggregateStyle,
        GraphConstants.ARROW_DIAMOND);
    GraphConstants.setBeginFill(aggregateStyle, true);
    GraphConstants.setBeginSize(aggregateStyle, 6);
    GraphConstants.setLineEnd(aggregateStyle, GraphConstants.ARROW_SIMPLE);
    GraphConstants.setEndSize(aggregateStyle, 8);
    GraphConstants.setLabelPosition(aggregateStyle, new Point2D.Double(500,
        0));
    if (GraphConstants.DEFAULTFONT != null) {
      GraphConstants.setFont(aggregateStyle, GraphConstants.DEFAULTFONT
          .deriveFont(10));
    }
    //
    // The Swing MVC Pattern
    //
    // Model Column
    DefaultGraphCell gm = new DefaultGraphCell("GraphModel");
    attributes.put(gm,
        createBounds(new AttributeMap(), 20, 100, Color.blue));
    gm.addPort(null, "GraphModel/Center");
    DefaultGraphCell dgm = new DefaultGraphCell("DefaultGraphModel");
    attributes.put(dgm, createBounds(new AttributeMap(), 20, 180,
        Color.blue));
    dgm.addPort(null, "DefaultGraphModel/Center");
    DefaultEdge dgmImplementsGm = new DefaultEdge("implements");
    cs.connect(dgmImplementsGm, gm.getChildAt(0), dgm.getChildAt(0));
    attributes.put(dgmImplementsGm, implementStyle);
    DefaultGraphCell modelGroup = new DefaultGraphCell("ModelGroup");
    modelGroup.add(gm);
    modelGroup.add(dgm);
    modelGroup.add(dgmImplementsGm);
    // JComponent Column
    DefaultGraphCell jc = new DefaultGraphCell("JComponent");
    attributes.put(jc, createBounds(new AttributeMap(), 180, 20,
        Color.green));
    jc.addPort(null, "JComponent/Center");
    DefaultGraphCell jg = new DefaultGraphCell("JGraph");
    attributes.put(jg, createBounds(new AttributeMap(), 180, 100,
        Color.green));
    jg.addPort(null, "JGraph/Center");
    DefaultEdge jgExtendsJc = new DefaultEdge("extends");
    cs.connect(jgExtendsJc, jc.getChildAt(0), jg.getChildAt(0));
    attributes.put(jgExtendsJc, extendStyle);
    // UI Column
    DefaultGraphCell cu = new DefaultGraphCell("ComponentUI");
    attributes
        .put(cu, createBounds(new AttributeMap(), 340, 20, Color.red));
    cu.addPort(null, "ComponentUI/Center");
    DefaultGraphCell gu = new DefaultGraphCell("GraphUI");
    attributes.put(gu,
        createBounds(new AttributeMap(), 340, 100, Color.red));
    gu.addPort(null, "GraphUI/Center");
    DefaultGraphCell dgu = new DefaultGraphCell("BasicGraphUI");
    attributes.put(dgu, createBounds(new AttributeMap(), 340, 180,
        Color.red));
    dgu.addPort(null, "BasicGraphUI/Center");
    DefaultEdge guExtendsCu = new DefaultEdge("extends");
    cs.connect(guExtendsCu, cu.getChildAt(0), gu.getChildAt(0));
    attributes.put(guExtendsCu, extendStyle);
    DefaultEdge dguImplementsDu = new DefaultEdge("implements");
    cs.connect(dguImplementsDu, gu.getChildAt(0), dgu.getChildAt(0));
    attributes.put(dguImplementsDu, implementStyle);
    DefaultGraphCell uiGroup = new DefaultGraphCell("UIGroup");
    uiGroup.add(cu);
    uiGroup.add(gu);
    uiGroup.add(dgu);
    uiGroup.add(dguImplementsDu);
    uiGroup.add(guExtendsCu);
    // Aggregations
    DefaultEdge jgAggregatesGm = new DefaultEdge("model");
    cs.connect(jgAggregatesGm, jg.getChildAt(0), gm.getChildAt(0));
    attributes.put(jgAggregatesGm, aggregateStyle);
    DefaultEdge jcAggregatesCu = new DefaultEdge("ui");
    cs.connect(jcAggregatesCu, jc.getChildAt(0), cu.getChildAt(0));
    attributes.put(jcAggregatesCu, aggregateStyle);
    // Insert Cells into model
    Object[] cells = new Object[] { jgAggregatesGm, jcAggregatesCu,
        modelGroup, jc, jg, jgExtendsJc, uiGroup };
    model.insert(cells, attributes, cs, null, null);
View Full Code Here

                    // attrs.translate(dx, dy);
                    attributes.put(cells[i], attrs.clone());
                  }
                }
              }
              ConnectionSet cs = ConnectionSet.create(graphModel,
                  cells, false);
              ParentMap pm = ParentMap.create(graphModel, cells,
                  false, true);
              cells = graphLayoutCache.insertClones(cells, graph
                  .cloneCells(cells), attributes, cs, pm, 0,
View Full Code Here

  /**
   * Creates and returns a sample <code>GraphModel</code>. Used primarily
   * for beanbuilders to show something interesting.
   */
  public static void addSampleData(GraphModel model) {
    ConnectionSet cs = new ConnectionSet();
    Map attributes = new Hashtable();
    // Styles For Implement/Extend/Aggregation
    AttributeMap implementStyle = new AttributeMap();
    GraphConstants.setLineBegin(implementStyle,
        GraphConstants.ARROW_TECHNICAL);
    GraphConstants.setBeginSize(implementStyle, 10);
    GraphConstants.setDashPattern(implementStyle, new float[] { 3, 3 });
    GraphConstants.setFont(implementStyle, GraphConstants.DEFAULTFONT
        .deriveFont(10));
    AttributeMap extendStyle = new AttributeMap();
    GraphConstants
        .setLineBegin(extendStyle, GraphConstants.ARROW_TECHNICAL);
    GraphConstants.setBeginFill(extendStyle, true);
    GraphConstants.setBeginSize(extendStyle, 10);
    GraphConstants.setFont(extendStyle, GraphConstants.DEFAULTFONT
        .deriveFont(10));
    AttributeMap aggregateStyle = new AttributeMap();
    GraphConstants.setLineBegin(aggregateStyle,
        GraphConstants.ARROW_DIAMOND);
    GraphConstants.setBeginFill(aggregateStyle, true);
    GraphConstants.setBeginSize(aggregateStyle, 6);
    GraphConstants.setLineEnd(aggregateStyle, GraphConstants.ARROW_SIMPLE);
    GraphConstants.setEndSize(aggregateStyle, 8);
    GraphConstants.setLabelPosition(aggregateStyle, new Point2D.Double(500,
        0));
    GraphConstants.setFont(aggregateStyle, GraphConstants.DEFAULTFONT
        .deriveFont(10));
    //
    // The Swing MVC Pattern
    //
    // Model Column
    DefaultGraphCell gm = new DefaultGraphCell("GraphModel");
    attributes.put(gm,
        createBounds(new AttributeMap(), 20, 100, Color.blue));
    gm.add(new DefaultPort("GraphModel/Center"));
    DefaultGraphCell dgm = new DefaultGraphCell("DefaultGraphModel");
    attributes.put(dgm, createBounds(new AttributeMap(), 20, 180,
        Color.blue));
    dgm.add(new DefaultPort("DefaultGraphModel/Center"));
    DefaultEdge dgmImplementsGm = new DefaultEdge("implements");
    cs.connect(dgmImplementsGm, gm.getChildAt(0), dgm.getChildAt(0));
    attributes.put(dgmImplementsGm, implementStyle);
    DefaultGraphCell modelGroup = new DefaultGraphCell("ModelGroup");
    modelGroup.add(gm);
    modelGroup.add(dgm);
    modelGroup.add(dgmImplementsGm);
    // JComponent Column
    DefaultGraphCell jc = new DefaultGraphCell("JComponent");
    attributes.put(jc, createBounds(new AttributeMap(), 180, 20,
        Color.green));
    jc.add(new DefaultPort("JComponent/Center"));
    DefaultGraphCell jg = new DefaultGraphCell("JGraph");
    attributes.put(jg, createBounds(new AttributeMap(), 180, 100,
        Color.green));
    jg.add(new DefaultPort("JGraph/Center"));
    DefaultEdge jgExtendsJc = new DefaultEdge("extends");
    cs.connect(jgExtendsJc, jc.getChildAt(0), jg.getChildAt(0));
    attributes.put(jgExtendsJc, extendStyle);
    // UI Column
    DefaultGraphCell cu = new DefaultGraphCell("ComponentUI");
    attributes
        .put(cu, createBounds(new AttributeMap(), 340, 20, Color.red));
    cu.add(new DefaultPort("ComponentUI/Center"));
    DefaultGraphCell gu = new DefaultGraphCell("GraphUI");
    attributes.put(gu,
        createBounds(new AttributeMap(), 340, 100, Color.red));
    gu.add(new DefaultPort("GraphUI/Center"));
    DefaultGraphCell dgu = new DefaultGraphCell("BasicGraphUI");
    attributes.put(dgu, createBounds(new AttributeMap(), 340, 180,
        Color.red));
    dgu.add(new DefaultPort("BasicGraphUI/Center"));
    DefaultEdge guExtendsCu = new DefaultEdge("extends");
    cs.connect(guExtendsCu, cu.getChildAt(0), gu.getChildAt(0));
    attributes.put(guExtendsCu, extendStyle);
    DefaultEdge dguImplementsDu = new DefaultEdge("implements");
    cs.connect(dguImplementsDu, gu.getChildAt(0), dgu.getChildAt(0));
    attributes.put(dguImplementsDu, implementStyle);
    DefaultGraphCell uiGroup = new DefaultGraphCell("UIGroup");
    uiGroup.add(cu);
    uiGroup.add(gu);
    uiGroup.add(dgu);
    uiGroup.add(dguImplementsDu);
    uiGroup.add(guExtendsCu);
    // Aggregations
    DefaultEdge jgAggregatesGm = new DefaultEdge("model");
    cs.connect(jgAggregatesGm, jg.getChildAt(0), gm.getChildAt(0));
    attributes.put(jgAggregatesGm, aggregateStyle);
    DefaultEdge jcAggregatesCu = new DefaultEdge("ui");
    cs.connect(jcAggregatesCu, jc.getChildAt(0), cu.getChildAt(0));
    attributes.put(jcAggregatesCu, aggregateStyle);
    // Insert Cells into model
    Object[] cells = new Object[] { jgAggregatesGm, jcAggregatesCu,
        modelGroup, jc, jg, jgExtendsJc, uiGroup };
    model.insert(cells, attributes, cs, null, null);
View Full Code Here

TOP

Related Classes of org.jgraph.graph.ConnectionSet$Connection

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.