[med-svn] [Git][med-team/libjloda-java][upstream] New upstream version 0.0+git20180523.cbaf6d1
Andreas Tille
gitlab at salsa.debian.org
Fri May 25 22:33:39 BST 2018
Andreas Tille pushed to branch upstream at Debian Med / libjloda-java
Commits:
62d90dfc by Andreas Tille at 2018-05-25T23:08:08+02:00
New upstream version 0.0+git20180523.cbaf6d1
- - - - -
8 changed files:
- src/jloda/fx/IHasJavaFXStageAndRoot.java
- src/jloda/fx/JPanelWithFXStageAndRoot.java
- src/jloda/fx/JavaFX2PDF.java
- src/jloda/graph/FruchtermanReingoldLayout.java
- src/jloda/util/GFF3FileFilter.java
- src/jloda/util/Pair.java
- src/jloda/util/RecursiveFileLister.java
- src/jloda/util/Statistics.java
Changes:
=====================================
src/jloda/fx/IHasJavaFXStageAndRoot.java
=====================================
--- a/src/jloda/fx/IHasJavaFXStageAndRoot.java
+++ b/src/jloda/fx/IHasJavaFXStageAndRoot.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Daniel H. Huson
+ * Copyright (C) 2018 Daniel H. Huson
*
* (Some files contain contributions from other authors, who are then mentioned separately.)
*
=====================================
src/jloda/fx/JPanelWithFXStageAndRoot.java
=====================================
--- a/src/jloda/fx/JPanelWithFXStageAndRoot.java
+++ b/src/jloda/fx/JPanelWithFXStageAndRoot.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Daniel H. Huson
+ * Copyright (C) 2018 Daniel H. Huson
*
* (Some files contain contributions from other authors, who are then mentioned separately.)
*
=====================================
src/jloda/fx/JavaFX2PDF.java
=====================================
--- a/src/jloda/fx/JavaFX2PDF.java
+++ b/src/jloda/fx/JavaFX2PDF.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Daniel H. Huson
+ * Copyright (C) 2018 Daniel H. Huson
*
* (Some files contain contributions from other authors, who are then mentioned separately.)
*
=====================================
src/jloda/graph/FruchtermanReingoldLayout.java
=====================================
--- a/src/jloda/graph/FruchtermanReingoldLayout.java
+++ b/src/jloda/graph/FruchtermanReingoldLayout.java
@@ -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;
}
}
}
=====================================
src/jloda/util/GFF3FileFilter.java
=====================================
--- a/src/jloda/util/GFF3FileFilter.java
+++ b/src/jloda/util/GFF3FileFilter.java
@@ -1,5 +1,5 @@
/*
- * 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
- final String[] lines = Basic.getFirstLinesFromFile(new File(fileName), 1);
- return lines != null && lines[0] != null && lines[0].startsWith("##gff-version 3");
+ 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;
}
}
=====================================
src/jloda/util/Pair.java
=====================================
--- a/src/jloda/util/Pair.java
+++ b/src/jloda/util/Pair.java
@@ -20,6 +20,7 @@
package jloda.util;
import java.util.Comparator;
+import java.util.Iterator;
/**
* a generic pair of objects
@@ -196,4 +197,72 @@ public class Pair<S, T> implements Comparable<Pair<S, T>>, Comparator<Pair<S, T>
public boolean contains(Object x) {
return x.equals(first) || x.equals(second);
}
+
+ /**
+ * iterable over first elements
+ *
+ * @param src
+ * @param <P>
+ * @param <Q>
+ * @return iterable over all first elements
+ */
+ public static <P, Q> Iterable<P> firstValues(final Iterable<Pair<P, Q>> src) {
+ return new Iterable<P>() {
+ @Override
+ public Iterator<P> iterator() {
+ return new Iterator<P>() {
+ private final Iterator<Pair<P, Q>> it = src.iterator();
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public P next() {
+ return it.next().getFirst();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+ };
+ }
+
+ /**
+ * iterable over second elements
+ *
+ * @param src
+ * @param <P>
+ * @param <Q>
+ * @return iterable over all second elements
+ */
+ public static <P, Q> Iterable<Q> secondValues(final Iterable<Pair<P, Q>> src) {
+ return new Iterable<Q>() {
+ @Override
+ public Iterator<Q> iterator() {
+ return new Iterator<Q>() {
+ private final Iterator<Pair<P, Q>> it = src.iterator();
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public Q next() {
+ return it.next().getSecond();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+ };
+ }
}
=====================================
src/jloda/util/RecursiveFileLister.java
=====================================
--- a/src/jloda/util/RecursiveFileLister.java
+++ b/src/jloda/util/RecursiveFileLister.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Daniel H. Huson
+ * Copyright (C) 2018 Daniel H. Huson
*
* (Some files contain contributions from other authors, who are then mentioned separately.)
*
=====================================
src/jloda/util/Statistics.java
=====================================
--- a/src/jloda/util/Statistics.java
+++ b/src/jloda/util/Statistics.java
@@ -19,8 +19,6 @@
*/
package jloda.util;
-import java.util.Collection;
-
/**
* calculates basic statistics
* Daniel Huson, 5.2006
@@ -38,17 +36,19 @@ public class Statistics {
*
* @param data
*/
- public Statistics(Collection<? extends Number> data) {
- count = data.size();
+ public Statistics(Iterable<? extends Number> data) {
+ int count = 0;
+ for (Number number : data) {
+ double value = number.doubleValue();
+ sum += value;
+ if (value < min)
+ min = value;
+ if (value > max)
+ max = value;
+ count++;
+ }
+ this.count = count;
if (count > 0) {
- for (Number number : data) {
- double value = number.doubleValue();
- sum += value;
- if (value < min)
- min = value;
- if (value > max)
- max = value;
- }
mean = sum / count;
if (count > 1) {
double sum2 = 0;
View it on GitLab: https://salsa.debian.org/med-team/libjloda-java/commit/62d90dfc8165655c0fcd7d6996c36d9328a634a4
--
View it on GitLab: https://salsa.debian.org/med-team/libjloda-java/commit/62d90dfc8165655c0fcd7d6996c36d9328a634a4
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20180525/0283d69d/attachment-0001.html>
More information about the debian-med-commit
mailing list