Package com.evelopers.unimod.glayout.graph

Examples of com.evelopers.unimod.glayout.graph.SimpleGraph


     *
     *
     * @param args
     */
    public static void main(String[] args) {
        SimpleGraph sg  = GraphGenerator.generateTriangles();
        SimpleGraph sg1 = GraphGenerator.generateOneV();
        ((SimpleVertex) sg.getVertices()
                          .get(2)).setProperty(Constant.LAYER_KEY, sg1);

        SimpleVertex test1 = (SimpleVertex) sg.getVertices()
                                              .get(3);
        SimpleVertex test2 = (SimpleVertex) sg1.getVertices()
                                               .get(0);
        SimpleEdge e = new SimpleEdge(test2, test1);
        sg.addEdge(e);

        long time = System.currentTimeMillis();
View Full Code Here


            sg.removePropertyAsc(ESUBGRAPH_KEY);

            return;
        }

        SimpleGraph blk = provideBLK(sg, cutpoints);

        sg.removePropertyAsc(ESUBGRAPH_KEY);

        // getting list to connect vertices
        ListIterator liv = blk.getVertices()
                              .listIterator();

        // toconnect will be from sg vertices
        List toconnect = new ArrayList();
View Full Code Here

     * @param sg
     * @param cutpoints
     * @return
     */
    private static SimpleGraph provideBLK(SimpleGraph sg, List cutpoints) {
        SimpleGraph blk = new SimpleGraph();

        // adding cutpoints
        ListIterator licp = cutpoints.listIterator();

        while (licp.hasNext()) {
            SimpleVertex element = (SimpleVertex) licp.next();
            SimpleVertex toadd   = new SimpleVertex();
            blk.addVertex(toadd);
            toadd.setProperty(CORRESP_KEY, element);
            element.setProperty(CORRESP_KEY, toadd);
        }

        // searching for biconn subgraph count
        int esub_count   = 0;
        ListIterator lie = sg.getEdges()
                             .listIterator();

        while (lie.hasNext()) {
            SimpleEdge element = (SimpleEdge) lie.next();
            int esub_n         = element.getIntProperty(ESUBGRAPH_KEY);

            if (esub_n > esub_count) {
                esub_count = esub_n;
            }
        }

        // creating vertices
        SimpleVertex[] white = new SimpleVertex[esub_count];

        for (int i = 0; i < white.length; i++) {
            white[i] = new SimpleVertex();
            blk.addVertex(white[i]);
        }

        // setting vertex corresp
        lie = sg.getEdges()
                .listIterator();

        while (lie.hasNext()) {
            SimpleEdge element  = (SimpleEdge) lie.next();
            SimpleVertex svcomp = white[element.getIntProperty(ESUBGRAPH_KEY) - 1];
            SimpleVertex v1     = element.getSource();
            SimpleVertex v2     = element.getTarget();

            //setting corresp vertex not from cutpoints
            if ((svcomp.getVertexProperty(CORRESP_KEY) == null)
                    || (!cutpoints.contains(v1))) {
                svcomp.setProperty(CORRESP_KEY, v1);
            }

            if ((svcomp.getVertexProperty(CORRESP_KEY) == null)
                    || (!cutpoints.contains(v2))) {
                svcomp.setProperty(CORRESP_KEY, v2);
            }
        }

        // adding edges
        licp = cutpoints.listIterator();

        while (licp.hasNext()) {
            SimpleVertex element = (SimpleVertex) licp.next();
            SimpleVertex svcutp  = element.getVertexProperty(CORRESP_KEY);
            ListIterator liedges = element.getEdgesRelative(sg)
                                          .listIterator();

            List v2c = new ArrayList();

            // but no duplicate edges
            while (liedges.hasNext()) {
                SimpleEdge edge     = (SimpleEdge) liedges.next();
                SimpleVertex svcomp = white[edge.getIntProperty(ESUBGRAPH_KEY) - 1];

                if (!v2c.contains(svcomp)) {
                    v2c.add(svcomp);
                }
            }

            ListIterator liv2c = v2c.listIterator();

            while (liv2c.hasNext()) {
                SimpleVertex vertex = (SimpleVertex) liv2c.next();

                SimpleEdge toadd = new SimpleEdge(svcutp, vertex);
                blk.addEdge(toadd);
            }
        }

        sg.removePropertyAsc(CORRESP_KEY);

View Full Code Here

        ListIterator li0 = sg.getVertices()
                             .listIterator();

        while (li0.hasNext()) {
            SimpleVertex el = (SimpleVertex) li0.next();
            SimpleGraph sgr = (SimpleGraph) el.getProperty(Constant.LAYER_KEY);

            if (sgr != null) {
                iPaint(sgr, bg);
            }
        }
View Full Code Here

    /**
     * Build a dighraph.
     */
    public void buildDigraph() {
        associated = new SimpleGraph();

        ListIterator lif = gd.getFaces()
                             .listIterator();

        while (lif.hasNext()) {
View Full Code Here

        return produce(false);
    }

    private SimpleGraph produce(boolean hor) {
        this.hor     = hor;
        ngraph       = new SimpleGraph();
        createVertices();
        createEdges();

        return ngraph;
    }
View Full Code Here

    /*
     *  (non-Javadoc)
     * @see com.evelopers.unimod.glayout.graph.utils.AssociatedDigraph#buildDigraph()
     */
    public void buildDigraph() {
        associated = new SimpleGraph();

        ListIterator lif = gd.getFaces()
                             .listIterator();

        while (lif.hasNext()) {
View Full Code Here

    public void construct() {
        /* there is no need to add corners there
         * 'cause they are needed before
         */
        NGraphProducer np = new NGraphProducer(sg);
        SimpleGraph nhor  = np.produceHorizontal();
        TopSorterFactory.getTopSorter(nhor)
                        .unitTopSort();

        ListIterator liv = sg.getVertices()
                             .listIterator();

        while (liv.hasNext()) {
            SimpleVertex sv      = (SimpleVertex) liv.next();
            SimpleVertex corresp = np.getCorrespondingVertex(sv);
            sv.setOrthX(corresp.getTopnum());
        }

        np.cleanProps();

        SimpleGraph nver = np.produceVertical();
        TopSorterFactory.getTopSorter(nver)
                        .unitTopSort();
        liv = sg.getVertices()
                .listIterator();

View Full Code Here

    super(graph);
  }

  @Override
  public void execute(Object parent) {
    SimpleGraph sg = new SimpleGraph();   
    HashMap <mxCell, SimpleVertex> vertexes = new HashMap<mxCell, SimpleVertex>();
    for (Object obj : graph.getChildVertices(parent)) {
      if (obj instanceof mxCell) {
        mxCell cell = (mxCell) obj;
        SimpleVertex sv = new SimpleVertex();
        int width = (int) Math.round(cell.getGeometry().getWidth());
        int height = (int) Math.round(cell.getGeometry().getHeight());
        VertexExt ve = new VertexExt(cell.getGeometry().getPoint(), width, height);
        sv.setVertexext(ve);
        sv.setProperty("id", cell.getId());
        sg.addVertex(sv);
        vertexes.put(cell, sv);
      }
    }
    for (Object obj : graph.getChildEdges(parent)) {
      if (obj instanceof mxCell) {
        mxCell cell = (mxCell) obj;
        SimpleEdge se = new SimpleEdge(vertexes.get(cell.getSource()), vertexes.get(cell.getTarget()));
        se.setProperty("id", cell.getId());
        sg.addEdge(se);
      }
    }
    MultiLayerLayouter.layout(sg);
   
        mxCell someCell = ((mxCell)vertexes.keySet().toArray()[0]);
        double xscale = someCell.getGeometry().getWidth() / (vertexes.get(someCell).getVertexext().getWidth() - .5);
        double yscale = someCell.getGeometry().getHeight() / (vertexes.get(someCell).getVertexext().getHeight() - .5);
    for (Object obj : sg.getVertices()) {
      if (obj instanceof SimpleVertex) {
        SimpleVertex sv = (SimpleVertex) obj;
       
        for (mxCell vertex: vertexes.keySet()) {
          if (vertex.getId().equals(sv.getProperty("id"))) {
            VertexExt ve =  sv.getVertexext();
            mxGeometry vertexGeometry = vertex.getGeometry();
            super.setVertexLocation(vertex, ve.getLeftTop().getX()*xscale, ve.getLeftTop().getY()*yscale);
          }
        }
               
      }
    }
    for (Object obj : sg.getEdges()) {
      if (obj instanceof SimpleEdge) {
        SimpleEdge se = (SimpleEdge) obj;
        for (Object e : graph.getChildEdges(parent)) {
          if (e instanceof mxCell) {
            mxCell edge = (mxCell) e;
View Full Code Here

    /**
     *Orientate
     */
    public void construct() {
        SimpleGraph temp = new SimpleGraph();
        GraphHelper.instanceCopy(getGraph(),
                                 temp);

        while (true) {
            Chain ac = new Chain(temp);
            ac = GraphHelper.getInstance()
                            .dfsChainSearchUnOri(temp,
                                                 ac,
                                                 gd.getSource(),
                                                 gd.getTarget());
            getGraph()
                .removePropertyAsc(GraphHelper.getInstance());

            if (ac == null) {
                break;
            }

            orientOnSTChain(ac);
            temp.removeEdges(ac.getEdges());
        }
    }
View Full Code Here

TOP

Related Classes of com.evelopers.unimod.glayout.graph.SimpleGraph

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.