Package com.evelopers.unimod.glayout.graph

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


     * @param sg
     * @return result
     */
    public static SimpleEdge getUpperEdge(SimpleGraph sg) {
        double y        = Double.MAX_VALUE;
        SimpleEdge res  = null;
        ListIterator li = sg.getEdges()
                            .listIterator();

        while (li.hasNext()) {
            SimpleEdge edge = (SimpleEdge) li.next();

            if (edge.isHorizontal() && (edge.getSource()
                                                .getOrthY() < y)) {
                y     = edge.getSource()
                            .getOrthY();
                res = edge;
            }
        }

View Full Code Here


        while (route > 0) {
            ListIterator li = curr.getEdges()
                                  .listIterator();

            while (li.hasNext()) {
                SimpleEdge element = (SimpleEdge) li.next();

                if ((f.getEdges()
                          .indexOf(element) != -1) && (element.getAnother(curr) != prev)) {
                    prev     = curr;
                    curr     = element.getAnother(curr);
                    resLeft.addVertex(curr);
                    resLeft.addEdge(element);
                    route--;

                    break;
View Full Code Here

        ListIterator li = v.getEdges()
                           .listIterator();
        int count = 0;

        while (li.hasNext()) {
            SimpleEdge edge = (SimpleEdge) li.next();

            if (f.getEdges()
                     .indexOf(edge) != -1) {
                se[count++] = edge;
            }
View Full Code Here

    private void addDeffered() {
        ListIterator li = f.getEdges()
                           .listIterator();

        while (li.hasNext()) {
            SimpleEdge edge = (SimpleEdge) li.next();

            if (edge.getProperty(DEFFEREDFRONT_KEY) != null) {
                SimpleVertex v     = (SimpleVertex) edge.getProperty(DEFFEREDFRONT_KEY);
                SimpleEdge front   = (SimpleEdge) v.getProperty(DEFFEREDFRONT_KEY);
                SimpleEdge[] added = (SimpleEdge[]) addededges.toArray(new SimpleEdge[0]);
                SimpleEdge split   = splitByVertex(v, front, added);
                SimpleEdge e1      = new SimpleEdge(split.getSource(),
                                                    v);
                e1.setProperty(FICTIVEFACE_KEY, FICTIVE_VALUE);
                sg.addEdge(e1);
                addededges.add(e1);

                SimpleEdge e2 = new SimpleEdge(v,
                                               split.getTarget());
                e2.setProperty(FICTIVEFACE_KEY, FICTIVE_VALUE);
                sg.addEdge(e2);
                sg.removeEdge(split);
                addededges.add(e2);
                addededges.remove(split);
            }
View Full Code Here

    private void addFictive() {
        ListIterator li = f.getEdges()
                           .listIterator();

        while (li.hasNext()) {
            SimpleEdge edge = (SimpleEdge) li.next();

            if (((Integer) iTurn.get(edge)).intValue() == -1) {
                SimpleEdge front    = (SimpleEdge) eFront.get(edge);
                SimpleVertex corner = (SimpleVertex) vCorner.get(edge);
                double nx;
                double ny;

                if (front.isHorizontal()) {
                    nx     = corner.getOrthX();
                    ny     = front.getSource()
                                  .getOrthY();
                } else {
                    nx     = front.getSource()
                                  .getOrthX();
                    ny = corner.getOrthY();
                }

                SimpleVertex project = new SimpleVertex();
                project.setOrthX(nx);
                project.setOrthY(ny);

                if (front.getProperty(FICTIVEFACE_KEY) == null) {
                    project.setProperty(FICTIVEFACE_KEY, front);
                } else {
                    project.setProperty(FICTIVEFACE_KEY,
                                        front.getProperty(FICTIVEFACE_KEY));
                }

                boolean newvertex;

                if (CompactionHelper.equalsOrth(project,
                                                    front.getSource())) {
                    project       = front.getSource();
                    newvertex     = false;
                } else if (CompactionHelper.equalsOrth(
                                                           project,
                                                               front.getTarget())) {
                    project       = front.getTarget();
                    newvertex     = false;
                } else {
                    newvertex = true;
                }

                if (newvertex) {
                    // added a new vertex
                    if (edge.getProperty(DEFFEREDFRONT_KEY) == null) {
                        sg.addVertex(project);
                        sg.removeEdge(front);

                        SimpleEdge extend = new SimpleEdge(corner, project);
                        extend.setProperty(FICTIVEFACE_KEY, FICTIVE_VALUE);
                        sg.addEdge(extend);
                        addededges.add(extend);

                        SimpleEdge e1 = new SimpleEdge(front.getSource(),
                                                       project);
                        e1.setProperty(FICTIVEFACE_KEY, front);
                        sg.addEdge(e1);

                        SimpleEdge e2 = new SimpleEdge(project,
                                                       front.getTarget());
                        e2.setProperty(FICTIVEFACE_KEY, front);
                        sg.addEdge(e2);
                        refineFronts(front, e1, e2);
                    } else {
                        // no need to remove front
                        sg.addVertex(project);

                        SimpleEdge extend = new SimpleEdge(corner, project);
                        extend.setProperty(FICTIVEFACE_KEY, FICTIVE_VALUE);
                        sg.addEdge(extend);
                        addededges.add(extend);

                        project.setProperty(DEFFEREDFRONT_KEY, front);
                        edge.setProperty(DEFFEREDFRONT_KEY, project);
                    }

                    // evertyng added is not in face (this is no error)
                    // cause we do not use faces in compaction algorithm                   
                } else {
                    SimpleEdge extend = new SimpleEdge(corner, project);
                    addededges.add(extend);
                    extend.setProperty(FICTIVEFACE_KEY, FICTIVE_VALUE);
                    sg.addEdge(extend);
                }
            }
        }
    }
View Full Code Here

                      gd.getTarget(),
                      this,
                      TEMP_VALUE);

        while (li.hasNext()) {
            SimpleEdge edge = (SimpleEdge) li.next();
            workingedges.addLast(edge);
        }

        while (workingedges.size() > 0) {
            SimpleEdge working = (SimpleEdge) workingedges.removeFirst();
            Face eface         = InvestigatorHelper.getFaceForEdge(gd, working, this);

            if (eface != null) {
                eface.setProperty(this, TEMP_VALUE);

                Chain[] paths;

                if (eface == gd.getOuterRight()) {
                    paths =
                        InvestigatorHelper.twoPathsUnOri(eface,
                                                         working.getSource(),
                                                         working.getTarget(),
                                                         true);
                } else {
                    paths =
                        InvestigatorHelper.twoPathsUnOri(eface,
                                                         working.getSource(),
                                                         working.getTarget(),
                                                         false);
                }

                if (paths.length == 2) {
                    int containing   = 0;
                    int uncontaining = 1;

                    if (paths[0].getEdges()
                                    .indexOf(working) == -1) {
                        containing       = 1;
                        uncontaining     = 0;
                    }

                    ListIterator lie = paths[uncontaining].getEdges()
                                                          .listIterator();

                    while (lie.hasNext()) {
                        SimpleEdge edge = (SimpleEdge) lie.next();

                        if (edge.getProperty(this) == null) {
                            workingedges.add(edge);
                        } else {
                            workingedges.remove(edge);
                        }
                    }
View Full Code Here

    private void refineFronts(SimpleEdge front, SimpleEdge e1, SimpleEdge e2) {
        ListIterator li = f.getEdges()
                           .listIterator();

        while (li.hasNext()) {
            SimpleEdge edge     = (SimpleEdge) li.next();
            SimpleEdge curfront = (SimpleEdge) eFront.get(edge);
            SimpleEdge newfront = curfront;

            if (front.equals(curfront)) {
                if (front.isHorizontal()) {
                    if ((edge.getSource()
                                 .getOrthX() < GeometricHelper.getRightVetrtex(e1)
View Full Code Here

    private void countFront() {
        ListIterator li = f.getEdges()
                           .listIterator();

        while (li.hasNext()) {
            SimpleEdge edge = (SimpleEdge) li.next();

            if (((Integer) iTurn.get(edge)).intValue() == -1) {
                SimpleEdge front = countFront(edge);
                eFront.put(edge, front);
            }
        }
    }
View Full Code Here

     * @param edge
     * @return
     */
    private SimpleEdge countFront(SimpleEdge edge) {
        int sum         = -1;
        SimpleEdge curr = edge;

        do {
            curr = (SimpleEdge) eNext.get(curr);
            sum += ((Integer) iTurn.get(curr)).intValue();
        } while ((!edge.equals(curr)) && (sum != 1));

        curr = (SimpleEdge) eNext.get(curr);

        SimpleEdge tcurr = curr;

        if (edge.isHorizontal()) {
            while (!((edge.getSource()
                              .getOrthY() <= GeometricHelper.getMaxVertical(curr)
                                                                .getOrthY())
View Full Code Here

                                            (SimpleVertex) f.getVertices().get(0),
                                            (SimpleVertex) f.getVertices().get(0));
        f.removePropertyAsc(GraphHelper.getInstance());

        // the uppermost edge
        SimpleEdge upperedge = GeometricHelper.getUpperEdge(c);

        // index of the next for upper
        int nexti;

        if (c.getEdges()
                 .indexOf(upperedge) == (c.getEdges()
                                              .size() - 1)) {
            nexti = 0;
        } else {
            nexti = c.getEdges()
                     .indexOf(upperedge) + 1;
        }

        // whether order is ccw or cw
        SimpleEdge nextupper = (SimpleEdge) c.getEdges()
                                             .get(nexti);

        if (!CompactionHelper.getIntersection(upperedge, nextupper)
                                 .equals(GeometricHelper.getRightVetrtex(upperedge))) {
            Collections.reverse(c.getEdges());
        }

        SimpleEdge[] edges = (SimpleEdge[]) c.getEdges()
                                             .toArray(new SimpleEdge[0]);
        SimpleEdge prev = edges[edges.length - 1];

        for (int i = 0; i < edges.length; i++) {
            SimpleEdge curr     = edges[i];
            SimpleVertex corner = CompactionHelper.getIntersection(prev, curr);
            SimpleEdge next     = getAnotherEdge(corner, curr);
            int turn            = computeTurn(corner, curr, next);
            eNext.put(curr, next);
            vCorner.put(curr, corner);
            iTurn.put(curr,
                      new Integer(turn));
View Full Code Here

TOP

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

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.