Commit 62d90dfc authored by Andreas Tille's avatar Andreas Tille
Browse files

New upstream version 0.0+git20180523.cbaf6d1

parent ab0dd4fa
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
/*
 *  Copyright (C) 2015 Daniel H. Huson
 *  Copyright (C) 2018 Daniel H. Huson
 *
 *  (Some files contain contributions from other authors, who are then mentioned separately.)
 *
+1 −1
Original line number Diff line number Diff line
/*
 *  Copyright (C) 2015 Daniel H. Huson
 *  Copyright (C) 2018 Daniel H. Huson
 *
 *  (Some files contain contributions from other authors, who are then mentioned separately.)
 *
+1 −1
Original line number Diff line number Diff line
/*
 *  Copyright (C) 2015 Daniel H. Huson
 *  Copyright (C) 2018 Daniel H. Huson
 *
 *  (Some files contain contributions from other authors, who are then mentioned separately.)
 *
+30 −30
Original line number Diff line number Diff line
@@ -43,9 +43,9 @@ public class FruchtermanReingoldLayout {
    public FruchtermanReingoldLayout(Graph graph, NodeSet fixedNodes) {
        this.graph = graph;
        nodes = graph.getNodes().toArray();
        edges = new int[graph.getNumberOfEdges()][2];
        coordinates = new float[nodes.length][2];
        forceDelta = new float[nodes.length][2];
        edges = new int[2][graph.getNumberOfEdges()];
        coordinates = new float[2][nodes.length];
        forceDelta = new float[2][nodes.length];
        fixed = new BitSet();

        initialize(fixedNodes);
@@ -63,8 +63,8 @@ public class FruchtermanReingoldLayout {
        }
        int eId = 0;
        for (Edge e = graph.getFirstEdge(); e != null; e = e.getNext()) {
            edges[eId][0] = node2id.get(e.getSource());
            edges[eId][1] = node2id.get(e.getTarget());
            edges[0][eId] = node2id.get(e.getSource());
            edges[1][eId] = node2id.get(e.getTarget());
            eId++;
        }

@@ -79,8 +79,8 @@ public class FruchtermanReingoldLayout {
                    while (stack.size() > 0) {
                        Node w = stack.pop();
                        int id = node2id.get(w);
                        coordinates[id][0] = (float) (100 * Math.sin(2 * Math.PI * count / nodes.length));
                        coordinates[id][1] = (float) (100 * Math.cos(2 * Math.PI * count / nodes.length));
                        coordinates[0][id] = (float) (100 * Math.sin(2 * Math.PI * count / nodes.length));
                        coordinates[1][id] = (float) (100 * Math.cos(2 * Math.PI * count / nodes.length));
                        count++;
                        for (Edge e = w.getFirstAdjacentEdge(); e != null; e = w.getNextAdjacentEdge(e)) {
                            Node u = e.getOpposite(w);
@@ -114,7 +114,7 @@ public class FruchtermanReingoldLayout {
        }

        for (int v = 0; v < nodes.length; v++) {
            result.set(nodes[v], new Point2D.Float(coordinates[v][0], coordinates[v][1]));
            result.set(nodes[v], new Point2D.Float(coordinates[0][v], coordinates[1][v]));

        }
    }
@@ -131,57 +131,57 @@ public class FruchtermanReingoldLayout {
        for (int v1 = 0; v1 < nodes.length; v1++) {
            for (int v2 = 0; v2 < nodes.length; v2++) {
                if (v1 != v2) {
                    float xDist = coordinates[v1][0] - coordinates[v2][0];
                    float yDist = coordinates[v1][1] - coordinates[v2][1];
                    float xDist = coordinates[0][v1] - coordinates[0][v2];
                    float yDist = coordinates[1][v1] - coordinates[1][v2];
                    float dist = (float) Math.sqrt(xDist * xDist + yDist * yDist);
                    if (dist > 0) {
                        float repulsiveF = k * k / dist;
                        forceDelta[v1][0] += xDist / dist * repulsiveF;
                        forceDelta[v1][1] += yDist / dist * repulsiveF;
                        forceDelta[0][v1] += xDist / dist * repulsiveF;
                        forceDelta[1][v1] += yDist / dist * repulsiveF;
                    }
                }
            }
        }
        // attraction
        for (int[] edge : edges) {
            int v1 = edge[0];
            int v2 = edge[1];
            float xDist = coordinates[v1][0] - coordinates[v2][0];
            float yDist = coordinates[v1][1] - coordinates[v2][1];
        for (int i = 0; i < edges[0].length; i++) {
            int v1 = edges[0][i];
            int v2 = edges[1][i];
            float xDist = coordinates[0][v1] - coordinates[0][v2];
            float yDist = coordinates[1][v1] - coordinates[1][v2];
            float dist = (float) Math.sqrt(xDist * xDist + yDist * yDist);
            if (dist > 0) {
                float attractiveF = dist * dist / k;
                forceDelta[v1][0] -= xDist / dist * attractiveF;
                forceDelta[v1][1] -= yDist / dist * attractiveF;
                forceDelta[v2][0] += xDist / dist * attractiveF;
                forceDelta[v2][1] += yDist / dist * attractiveF;
                forceDelta[0][v1] -= xDist / dist * attractiveF;
                forceDelta[1][v1] -= yDist / dist * attractiveF;
                forceDelta[0][v2] += xDist / dist * attractiveF;
                forceDelta[1][v2] += yDist / dist * attractiveF;
            }
        }

        // gravity
        for (int v = 0; v < nodes.length; v++) {
            float distSquared = (float) Math.sqrt(coordinates[v][0] * coordinates[v][0] + coordinates[v][1] * coordinates[v][1]);
            float distSquared = (float) Math.sqrt(coordinates[0][v] * coordinates[0][v] + coordinates[1][v] * coordinates[1][v]);
            float gravityF = 0.01f * k * (float) gravity * distSquared;
            forceDelta[v][0] -= gravityF * coordinates[v][0] / distSquared;
            forceDelta[v][1] -= gravityF * coordinates[v][1] / distSquared;
            forceDelta[0][v] -= gravityF * coordinates[0][v] / distSquared;
            forceDelta[1][v] -= gravityF * coordinates[1][v] / distSquared;
        }

        // speed
        for (int v = 0; v < nodes.length; v++) {
            forceDelta[v][0] *= speed / SPEED_DIVISOR;
            forceDelta[v][1] *= speed / SPEED_DIVISOR;
            forceDelta[0][v] *= speed / SPEED_DIVISOR;
            forceDelta[1][v] *= speed / SPEED_DIVISOR;

        }

        // apply the forces:
        for (int v = 0; v < nodes.length; v++) {
            float xDist = forceDelta[v][0];
            float yDist = forceDelta[v][1];
            float xDist = forceDelta[0][v];
            float yDist = forceDelta[1][v];
            float dist = (float) Math.sqrt(xDist * xDist + yDist * yDist);
            if (dist > 0 && !fixed.get(v)) {
                float limitedDist = Math.min(maxDisplace * ((float) speed / SPEED_DIVISOR), dist);
                coordinates[v][0] += xDist / dist * limitedDist;
                coordinates[v][1] += yDist / dist * limitedDist;
                coordinates[0][v] += xDist / dist * limitedDist;
                coordinates[1][v] += yDist / dist * limitedDist;
            }
        }
    }
+20 −6
Original line number Diff line number Diff line
/*
 *  Copyright (C) 2015 Daniel H. Huson
 *  Copyright (C) 2018 Daniel H. Huson
 *
 *  (Some files contain contributions from other authors, who are then mentioned separately.)
 *
@@ -26,8 +26,11 @@ import java.io.FilenameFilter;
 * Daniel Huson, 12.2017
 */
public class GFF3FileFilter extends FileFilterBase implements FilenameFilter {
    public GFF3FileFilter() {
        this(true);
    private boolean lookInside = true;

    public GFF3FileFilter(boolean allowGZip, boolean lookInside, String... additionalSuffixes) {
        this(allowGZip, additionalSuffixes);
        this.lookInside = lookInside;
    }

    public GFF3FileFilter(String... additionalSuffixes) {
@@ -46,8 +49,11 @@ public class GFF3FileFilter extends FileFilterBase implements FilenameFilter {
    public boolean accept(String fileName) {
        boolean suffixOk = super.accept(Basic.getFileNameWithoutZipOrGZipSuffix(fileName));
        if (suffixOk) {   // look inside the file
            if (lookInside) {
                final String[] lines = Basic.getFirstLinesFromFile(new File(fileName), 1);
                return lines != null && lines[0] != null && lines[0].startsWith("##gff-version 3");
            } else
                return true;
        } else
            return false;
    }
@@ -56,6 +62,14 @@ public class GFF3FileFilter extends FileFilterBase implements FilenameFilter {
     * @return description of file matching the filter
     */
    public String getBriefDescription() {
        return "GFF Files";
        return "GFF3 Files";
    }

    public boolean isLookInside() {
        return lookInside;
    }

    public void setLookInside(boolean lookInside) {
        this.lookInside = lookInside;
    }
}
Loading