Package org.jgraph.graph

Examples of org.jgraph.graph.DefaultGraphCell


   * @param height Height to set
   */
  @SuppressWarnings("unchecked")
  protected void positionVertexAt(Object vertex, int x, int y, double width,
      double height) {
    DefaultGraphCell cell = jgAdapter.getVertexCell(vertex);
    AttributeMap attr = cell.getAttributes();

    Rectangle2D newBounds = new Rectangle2D.Double(x, y, width, height);

    GraphConstants.setBounds(attr, newBounds);

View Full Code Here


   */
  @SuppressWarnings("unchecked")
  private void addAgentToVis(String name, String host) {
   
    directedGraph.addVertex(name);
    DefaultGraphCell dgc = jgAdapter.getVertexCell(host);
    AttributeMap cellAttr = dgc.getAttributes();
    Rectangle2D rect = GraphConstants.getBounds(cellAttr);
    positionVertexAt(name, (int) (rect.getX() + (agentsOnVis - 1)
        * agentWidth), (int) rect.getCenterY(), agentWidth, 20);
  }
View Full Code Here

  }
 
  private DefaultGraphCell createGraphCell(String text, int x, int y,
      int numPorts, String type)
    {
      DefaultGraphCell cell = new DefaultGraphCell(text);
      GraphConstants.setBounds(cell.getAttributes(),
        new Rectangle2D.Double(x, y, graphCellWidth, graphCellHeight));
      GraphConstants.setBorder(cell.getAttributes(), BorderFactory.createLineBorder(Color.black));
      GraphConstants.setOpaque(cell.getAttributes(), true);
     
      if(type.equals(Productions.BUILDING))
      {
        GraphConstants.setGradientColor(cell.getAttributes(),
          Color.cyan);
        cell.add(createPort(0, 0)); // lo
        cell.add(createPort(GraphConstants.PERMILLE/4, 0)); // zwischen lo und om
        cell.add(createPort(GraphConstants.PERMILLE/2, 0)); // om
        cell.add(createPort(Float.valueOf(GraphConstants.PERMILLE/(4F/3)), 0)); // zwischen om und ro
        cell.add(createPort(GraphConstants.PERMILLE, 0)); // ro
        cell.add(createPort(GraphConstants.PERMILLE, GraphConstants.PERMILLE/4)); // zwischen ro und rm
        cell.add(createPort(GraphConstants.PERMILLE, GraphConstants.PERMILLE/2)); // rm
        cell.add(createPort(GraphConstants.PERMILLE, GraphConstants.PERMILLE/(4F/3))); // zwischen rm und ru
        cell.add(createPort(GraphConstants.PERMILLE, GraphConstants.PERMILLE)); // ru
        cell.add(createPort(GraphConstants.PERMILLE/(4F/3), GraphConstants.PERMILLE)); // zwischen um und ru
        cell.add(createPort(GraphConstants.PERMILLE/2, GraphConstants.PERMILLE));// um
        cell.add(createPort(GraphConstants.PERMILLE/4, GraphConstants.PERMILLE)); // zwischen lu und um
        cell.add(createPort(0, GraphConstants.PERMILLE));// lu
        cell.add(createPort(0, GraphConstants.PERMILLE/(4F/3))); // zwischen lu und lm
        cell.add(createPort(0, GraphConstants.PERMILLE/2));// lm
        cell.add(createPort(0, GraphConstants.PERMILLE/4)); // zwischen lm und lo
      }
      else if(type.equals(Productions.UNIT))
      {
        GraphConstants.setGradientColor(cell.getAttributes(),
          Color.orange);
        cell.add(new DefaultPort());
      }
      else if(type.equals(Productions.UNIT_BUILDING))
      {
        GraphConstants.setGradientColor(cell.getAttributes(),
          Color.cyan);
        cell.add(new DefaultPort());
      }
     
      return cell;
    }
View Full Code Here

     
      DefaultGraphCell[] cells = new DefaultGraphCell[144];
     
      int i = 0;
      // buildings in building techtree
      DefaultGraphCell ks = createGraphCell("Ks", 315, 20, 1, Productions.BUILDING); // K�ruterschule
      DefaultGraphCell kh = createGraphCell("Kh", 315, 70, 2, Productions.BUILDING); // Kristallh�hle
      DefaultGraphCell ha = createGraphCell("Ha", 395, 70, 2, Productions.BUILDING); // Harzader
      DefaultGraphCell bdl = createGraphCell("BdL", 315, 120, 1, Productions.BUILDING); // Baum des Lebens
      DefaultGraphCell sw = createGraphCell("Sw", 395, 170, 1, Productions.BUILDING); // Steinwurzel
      DefaultGraphCell kb = createGraphCell("Kb", 315, 170, 1, Productions.BUILDING); // Kriegsbrunnen
      DefaultGraphCell ph = createGraphCell("Ph", 235, 120, 1, Productions.BUILDING); // Palasthof
      DefaultGraphCell xdk = createGraphCell("XdK", 235, 170, 1, Productions.BUILDING); // Xhodotorischer Kokon
      DefaultGraphCell kt = createGraphCell("Kt", 155, 170, 1, Productions.BUILDING); // Kristallturm
      DefaultGraphCell sm = createGraphCell("Sm", 75, 170, 1, Productions.BUILDING); // Steinmantel
      DefaultGraphCell ia = createGraphCell("IA", 475, 170, 1, Productions.BUILDING); // Irres Auge
      DefaultGraphCell zs = createGraphCell("Zs", 235, 220, 1, Productions.BUILDING); // Zuchtstation
      DefaultGraphCell kk = createGraphCell("KK", 235, 270, 1, Productions.BUILDING); // Kristallines Katapult
      DefaultGraphCell gg = createGraphCell("GG", 475, 45, 1, Productions.BUILDING); // Geheime Grotte
      DefaultGraphCell hs = createGraphCell("Hs", 155, 45, 1, Productions.BUILDING); // Heldenstatue
     
      // Units and buildings in units trees
      DefaultGraphCell bdlDRE = createGraphCell("BdL", 15, 315, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell zsDRE = createGraphCell("Zs", 15, 345, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell hsDRE = createGraphCell("Hs", 15, 375, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell dre = createGraphCell("Dre", 85, 345, 1, Productions.UNIT);
     
      DefaultGraphCell zsEHW = createGraphCell("Zs", 15, 405, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell ehw = createGraphCell("Ehw", 85, 405, 1, Productions.UNIT);
     
      DefaultGraphCell xdkKob = createGraphCell("XdK", 155, 315, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell kob = createGraphCell("Kob", 225, 315, 1, Productions.UNIT);
     
      DefaultGraphCell kbEIK = createGraphCell("Kb", 155, 345, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell xdkEIK = createGraphCell("XdK", 155, 375, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell eik = createGraphCell("Eik", 225, 345, 1, Productions.UNIT);
     
      DefaultGraphCell phKDM = createGraphCell("Ph", 15, 435, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell xdkKDM = createGraphCell("XdK", 15, 465, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell kdm = createGraphCell("KdM", 85, 435, 1, Productions.UNIT);
     
      DefaultGraphCell bdlKRP = createGraphCell("BdL", 155, 465, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell xdkKRP = createGraphCell("XdK", 155, 435, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell kbKRP = createGraphCell("Kb", 155, 405, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell krp = createGraphCell("Krp", 225, 435, 1, Productions.UNIT);
     
      DefaultGraphCell phHYZ = createGraphCell("Ph", 295, 315, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell zsHYZ = createGraphCell("Zs", 295, 345, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell hyz = createGraphCell("HyZ", 365, 315, 1, Productions.UNIT);
     
      DefaultGraphCell phWIZ = createGraphCell("Ph", 295, 375, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell zsWIZ = createGraphCell("Zs", 295, 405, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell wiz = createGraphCell("WiZ", 365, 375, 1, Productions.UNIT);
     
      DefaultGraphCell phEBS = createGraphCell("Ph", 295, 435, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell xdkEBS = createGraphCell("Xdk", 295, 465, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell ebs = createGraphCell("Ebs", 365, 435, 1, Productions.UNIT);
     
      DefaultGraphCell smAXZ = createGraphCell("Sm", 435, 375, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell xdkAXZ = createGraphCell("XdK", 435, 345, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell kbAXZ = createGraphCell("Kb", 435, 315, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell axz = createGraphCell("AxZ", 505, 345, 1, Productions.UNIT);
     
      DefaultGraphCell smDAZ = createGraphCell("Sm", 435, 465, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell xdkDAZ = createGraphCell("XdK", 435, 435, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell kbDAZ = createGraphCell("Kb", 435, 405, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell daz = createGraphCell("Daz", 505, 435, 1, Productions.UNIT);
     
      DefaultGraphCell sihKB = createGraphCell("Kb", 575, 405, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell sihBDL = createGraphCell("BdL", 575, 435, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell sihSM = createGraphCell("Sm", 575, 465, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell sihZS = createGraphCell("Zs", 645, 465, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell sih = createGraphCell("SiH", 645, 435, 1, Productions.UNIT);
     
      DefaultGraphCell efmPH = createGraphCell("Ph", 575, 315, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell efmBDL = createGraphCell("BdL", 575, 345, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell efmKT = createGraphCell("Kt", 575, 375, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell efmXDK = createGraphCell("XdK", 645, 375, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell efm = createGraphCell("Efm", 645, 345, 1, Productions.UNIT);
     
      DefaultGraphCell fefPH = createGraphCell("Ph", 575, 225, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell fefKT = createGraphCell("Kt", 575, 255, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell fefZS = createGraphCell("Zs", 575, 285, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell fefBDL = createGraphCell("BdL", 645, 285, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell fef = createGraphCell("Fef", 645, 255, 1, Productions.UNIT);
     
      DefaultGraphCell stfPH = createGraphCell("Ph", 575, 135, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell stfKB = createGraphCell("Kb", 575, 165, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell stfKT = createGraphCell("Kt", 575, 195, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell stfZS = createGraphCell("Zs", 645, 195, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell stf = createGraphCell("Stf", 645, 165, 1, Productions.UNIT);
     
      DefaultGraphCell swbKB = createGraphCell("Kb", 575, 45, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell swbBDL = createGraphCell("BdL", 575, 75, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell swbZS = createGraphCell("Zs", 575, 105, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell swb = createGraphCell("SwB", 645, 75, 1, Productions.UNIT);
     
      DefaultGraphCell briPH = createGraphCell("Ph", 15, 255, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell briXDK = createGraphCell("XdK", 15, 285, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell bri = createGraphCell("Bri", 85, 255, 1, Productions.UNIT);
     
      // cells of buildings
      cells[i++] = ks;
      cells[i++] = kh;
      cells[i++] = ha;
View Full Code Here

        }
    }

    private void positionVertexAt(Object vertex, int x, int y)
    {
        DefaultGraphCell cell = jgAdapter.getVertexCell(vertex);
        AttributeMap attr = cell.getAttributes();
        Rectangle2D bounds = GraphConstants.getBounds(attr);

        Rectangle2D newBounds =
                new Rectangle2D.Double(
                x,
View Full Code Here

  public static DefaultGraphCell createVertex(String name, double x,
      double y, double w, double h, Color bg, boolean raised) {

    // Create vertex with the given name
    DefaultGraphCell cell = new DefaultGraphCell(name);

    // Set bounds
    GraphConstants.setBounds(cell.getAttributes(), new Rectangle2D.Double(
        x, y, w, h));

    // Set fill color
    if (bg != null) {
      GraphConstants.setGradientColor(cell.getAttributes(), Color.orange);
      GraphConstants.setOpaque(cell.getAttributes(), true);
    }

    // Set raised border
    if (raised)
      GraphConstants.setBorder(cell.getAttributes(), BorderFactory
          .createRaisedBevelBorder());
    else
      // Set black border
      GraphConstants.setBorderColor(cell.getAttributes(), Color.black);

    // Add a Floating Port
    cell.addPort();

    return cell;
  }
View Full Code Here

      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

    try {
      if (ev.getClickCount() == 2) {
        Object obj =
          jgraph.getFirstCellForLocation(ev.getX(), ev.getY());
        if (obj != null && obj instanceof DefaultGraphCell) {
          DefaultGraphCell graphCell = (DefaultGraphCell) obj;
          GraphMethod graphMethod =
            (GraphMethod) graphCell.getUserObject();
          java.net.URL urlNavigate =
            new java.net.URL(
              this.getCodeBase().toString()
                + "methodCriticalPath.jsp"
                + graphMethod.getUrl());
          this.getAppletContext().showDocument(urlNavigate);
        }
      } else {
        Object obj =
          jgraph.getFirstCellForLocation(ev.getX(), ev.getY());
        if (obj != null && obj instanceof DefaultGraphCell) {
          DefaultGraphCell graphCell = (DefaultGraphCell) obj;
          GraphMethod graphMethod =
            (GraphMethod) graphCell.getUserObject();
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      JOptionPane.showMessageDialog(this, ex.toString());
View Full Code Here

      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);
                } else {
          if (cellcallee==null) System.out.println("Callee id=" + referenceCalling.getMethodCallee());
          if (cellcalled==null) System.out.println("Called id=" + referenceCalling.getMethodCalled());
View Full Code Here

    try {
      if (ev.getClickCount() == 2) {
        Object obj =
          jgraph.getFirstCellForLocation(ev.getX(), ev.getY());
        if (obj != null && obj instanceof DefaultGraphCell) {
          DefaultGraphCell graphCell = (DefaultGraphCell) obj;
          GraphMethod graphMethod =
            (GraphMethod) graphCell.getUserObject();
          java.net.URL urlNavigate =
            new java.net.URL(
              this.getCodeBase().toString()
                + "instancesStackGraph.jsp"
                + graphMethod.getUrl());
          this.getAppletContext().showDocument(urlNavigate);
        }
      } else {
        Object obj =
          jgraph.getFirstCellForLocation(ev.getX(), ev.getY());
        if (obj != null && obj instanceof DefaultGraphCell) {
          DefaultGraphCell graphCell = (DefaultGraphCell) obj;
          GraphMethod graphMethod =
            (GraphMethod) graphCell.getUserObject();
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      JOptionPane.showMessageDialog(this, ex.toString());
View Full Code Here

TOP

Related Classes of org.jgraph.graph.DefaultGraphCell

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.