Package edu.uci.ics.jung.visualization

Examples of edu.uci.ics.jung.visualization.Coordinates


    private Location _location = null;
   
   
    /** Creates a new instance of MapHost */
    public MapHost() {
        _coord = new Coordinates();
    }
View Full Code Here


        StringBuffer sb = new StringBuffer();
        Set vertices = _myGraph.getVertices();
        Set edges = _myGraph.getEdges();
        Vertex v = null;
        Edge e = null;
        Coordinates coord = null;
        Boolean hidden = null;
        Object tmp = null;
       
        sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
        sb.append("<mapdefinition>\n");
        // The config
        sb.append("<config>\n");
        sb.append("<view>" + name + "</view>\n");
        double scale = getVV(key).getLayoutTransformer().getScale();
        double ltranslateX = getVV(key).getLayoutTransformer().getTranslateX();
        double ltranslateY = getVV(key).getLayoutTransformer().getTranslateY();
        double vtranslateX = getVV(key).getViewTransformer().getTranslateX();
        double vtranslateY = getVV(key).getViewTransformer().getTranslateY();
        if (scale == 1.0)  {
            scale = getVV(key).getViewTransformer().getScale();
        }
        sb.append("<layouttranslatex>" + ltranslateX + "</layouttranslatex>\n");
        sb.append("<layouttranslatey>" + ltranslateY + "</layouttranslatey>\n");
        sb.append("<viewtranslatex>" + vtranslateX + "</viewtranslatex>\n");
        sb.append("<viewtranslatey>" + vtranslateY + "</viewtranslatey>\n");
        sb.append("<scale>" + scale + "</scale>\n");
        String title = getBackgroundTitle(key);
        if (title != null && title.length() > 0)  {
            sb.append("<backgroundtitle>" + title + "</backgroundtitle>\n");
        }
        String bgImage = getBackground(key);
        if (bgImage != null && bgImage.length() > 0)
            sb.append("<backgroundimage>"+ bgImage +"</backgroundimage>\n");
        sb.append("</config>\n");
        // The hosts
        if (!vertices.isEmpty()) {
            sb.append("<hosts>\n");
            for (Object o: vertices) {
                if (o != null && o instanceof Vertex) {
                    v = (Vertex)o;
                    coord = getLayout(key).getCoordinates(v);
                    hidden = (Boolean)v.getUserDatum(userdatumkey+key);
                    sb.append("<host");
                    if (hidden != null && hidden.booleanValue()) {
                        sb.append(" hidden=\"true\"");
                    } if (isLocked(v, key)) {
                        sb.append(" locked=\"true\"");
                    }
                    sb.append(">\n");
                    sb.append("<name>" + getLabel(v) + "</name>\n");
                    sb.append("<coords>" + coord.getX() + "," + coord.getY() + "</coords>\n");
                    tmp = v.getUserDatum("labelLocation");
                    if (tmp != null && tmp instanceof Location) {
                        sb.append("<label_location>" + ((Location)tmp).toString() + "</label_location>\n");
                        tmp = null;
                    }
View Full Code Here

            Point2D p = l.getLocation(v);
           
            while (it.hasNext()) {
                v = (Vertex)it.next();
                if (loc == Location.Top) {
                    moveVertex(v, new Coordinates(l.getLocation(v).getX(), p.getY()), key);
                } else if (loc == Location.Left) {
                    moveVertex(v, new Coordinates(p.getX(), l.getLocation(v).getY()), key);
                }
            }
        }
    }
View Full Code Here

            if (o instanceof Vertex) {
               
                v = (Vertex)o;
                if (isLocked(v))
                    continue;
                Coordinates coord = getCoordinates(v);
               
                junk = v.getUserDatum("level");
                if (junk instanceof Integer) {
                    lvl = (double)((Integer)junk).intValue();
                }
                if (lvl != nivelVisitado)
                    continue;
               
                double my_lvl_radius = radius / nivelVisitado;
                //double my_lvl_radius = radius * angles[(int)lvl-((int)lvl > 0?1:0)];
               
                double angle = (2 * Math.PI * i++) / angles[(int)lvl-((int)lvl > 0?1:0)];
               
                double cosX = Math.cos(angle);
                double sinY = Math.sin(angle);
                double xradius = (my_lvl_radius + (width/3 * (lvl / level_num)));
                double yradius = (my_lvl_radius + (width/3 * (lvl / level_num)));

    
     if (coord.getX() == 0d || coord.getY() == 0d)  {
         System.out.println("Oops... alguna coordenada es 0");
     }

     // test
                LinkedList parents = (LinkedList)v.getUserDatum("parents");
                Vertex parent = null;
                if (parents != null) {
                 parent = (Vertex)parents.getFirst();
                 if (parent != null) {
                     Coordinates pcoords = getCoordinates(parent);
                     if (pcoords.getX() == 0 || pcoords.getY() == 0) {
                         continue;
                     }
                    
     coord.setX(cosX * xradius + pcoords.getX());
     coord.setY(sinY * yradius + pcoords.getY());
     if (true)
                    continue;

                     double normaParent = Math.hypot(pcoords.getX(), pcoords.getY());
                     double normaYo = Math.hypot(coord.getX(), coord.getY());
                     System.out.println("normaParent: " + normaParent + "   normaYo: " + normaYo);
                     double porcent = 0;
                     if (normaParent > normaYo) {
                         porcent = normaParent / normaYo;
                         coord.setX(coord.getX() * porcent);
                         coord.setY(coord.getY() * porcent);
                     } else  {
                         porcent = normaYo / normaParent;
                         coord.setX(pcoords.getX() * porcent);
                         coord.setY(pcoords.getY() * porcent);
                     }
               }
          if (coord.getX() == 0d || coord.getY() == 0d)  {
         System.out.println("Oops... despues ... alguna coordenada es 0");
     }
View Full Code Here

            if (o instanceof Vertex) {
                cuantos++;
                v = (Vertex)o;
                if (isLocked(v))
                    continue;
                Coordinates coord = getCoordinates(v);
               
                junk = v.getUserDatum("level");
                if (junk instanceof Integer) {
                    lvl = (double)((Integer)junk).intValue();
                }
                if (lvl != nivelVisitado)
                    continue;
                // calcular el angulo segun la cantidad de Vertices
                // en este nivel vCant
                // level_num cantidad de niveles
                //double angle = (2 * Math.PI * angles[(int)lvl-((int)lvl > 0?1:0)]++) / angles[(int)lvl-((int)lvl > 0?1:0)];
                //double angle = (2 * Math.PI * angles[(int)lvl-((int)lvl > 0?1:0)]++) / (vertices.size() / level_num);
// funca                double angle = (Math.PI * angles[(int)lvl-((int)lvl > 0?1:0)]++) / (double)(vertices.size() / level_num) ;
                // calcular el x,y segun la cantidad de niveles
//                coord.setX(Math.cos(angle) * (width / 2) + (radius * (lvl / level_num)));
//                coord.setY(Math.sin(angle) * (height / 2)  + (radius * (lvl / level_num)));
//coord.setX(Math.cos(angle) * radius + width / 2);
//coord.setY(Math.sin(angle) * radius + height / 2);
    
               

double angle = (2 * Math.PI * i++) / vCant;

               
                double cosX = Math.cos(angle);
                double sinY = Math.sin(angle);
                double xradius = (radius + (width * (lvl / level_num)));
                double yradius = (radius + (width * (lvl / level_num)));

     coord.setX(cosX * xradius + (width / 2));
     coord.setY(sinY * yradius + (height / 2));
    
     if (coord.getX() == 0d || coord.getY() == 0d)  {
         System.out.println("Oops... alguna coordenada es 0");
     }


     // test
                LinkedList parents = (LinkedList)v.getUserDatum("parents");
                Vertex parent = null;
                if (parents != null) {
                 parent = (Vertex)parents.getFirst();
                 if (parent != null) {
                     Coordinates pcoords = getCoordinates(parent);
                     if (pcoords.getX() == 0 || pcoords.getY() == 0) {
                         continue;
                     }
                     double normaParent = Math.hypot(pcoords.getX(), pcoords.getY());
                     double normaYo = Math.hypot(coord.getX(), coord.getY());
                     System.out.println("normaParent: " + normaParent + "   normaYo: " + normaYo);
                     double porcent = 0;
                     if (normaParent > normaYo) {
                         porcent = normaParent / normaYo;
                         coord.setX(coord.getX() * porcent);
                         coord.setY(coord.getY() * porcent);
                     } else  {
                         porcent = normaYo / normaParent;
                         coord.setX(pcoords.getX() * porcent);
                         coord.setY(pcoords.getY() * porcent);
                     }
               }
          if (coord.getX() == 0d || coord.getY() == 0d)  {
         System.out.println("Oops... despues ... alguna coordenada es 0");
     }
View Full Code Here

    double dH = 0;
   
    //initialize coordinates
    double x = width;
    double y = 0;
    Coordinates coord = null;
   
    //convert coordinate from array lists
    Vertex v;
    LinkedList<Vertex> vertices;
    while (!sortedVertices.isEmpty()) {
      vertices = sortedVertices.removeFirst();
      lengthH = vertices.size();
      dH = height / (lengthH + 1);
      x -= dW;
      y = 0;
     
      //down to each level of vertices
      while (!vertices.isEmpty()) {
        y += dH;
        v = vertices.removeFirst();
        // VoidVertex serves as place holder in LinkedList
        if (!(v instanceof VoidVertex)) {
          coord = this.getCoordinates(v);
          coord.setX(x);
          coord.setY(y);
        }
      }
    }
  }
View Full Code Here

        if (isLocked(v))
          continue;
        SpringVertexData vd = getSpringData(v);
        if (vd == null)
          continue;
        Coordinates xyd = getCoordinates(v);

        vd.dx += vd.repulsiondx + vd.edgedx;
        vd.dy += vd.repulsiondy + vd.edgedy;

        // keeps nodes from moving any faster than 5 per time unit
        xyd.addX(Math.max(-5, Math.min(5, vd.dx)));
        xyd.addY(Math.max(-5, Math.min(5, vd.dy)));

      }
    } catch (ConcurrentModificationException cme) {
      moveNodes();
    }
View Full Code Here

   */
  public void update() {
    try {
      for (Iterator<?> iter = getGraph().getVertices().iterator(); iter.hasNext();) {
        Vertex v = (Vertex) iter.next();
        Coordinates coord = (Coordinates) v.getUserDatum(getBaseKey());
        if (coord == null) {
          coord = new Coordinates();
          v.addUserDatum(getBaseKey(), coord, UserData.REMOVE);
          initializeLocation(v, coord, getCurrentSize());
          initialize_local_vertex(v);
        }
      }
View Full Code Here

TOP

Related Classes of edu.uci.ics.jung.visualization.Coordinates

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.