diff --git a/.gitignore b/.gitignore
index 8963733..969d625 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@ doc
*.jar
.settings
.classpath
+.vscode
# Editor specific files and folders
*~
@@ -17,4 +18,4 @@ doc
*.mapfg
*.mapgr
*.path
-*.tgz
\ No newline at end of file
+*.tgz
diff --git a/be-graphes-algos/pom.xml b/be-graphes-algos/pom.xml
index d66075a..42179f0 100644
--- a/be-graphes-algos/pom.xml
+++ b/be-graphes-algos/pom.xml
@@ -1,19 +1,16 @@
-
+4.0.0
-
+
org.insa.graphsbe-graphes-all0.0.1-SNAPSHOT
-
+
be-graphes-algosbe-graphes-algos
-
+
org.insa.graphs
@@ -21,5 +18,5 @@
${project.version}
-
+
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AbstractAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AbstractAlgorithm.java
index 10fe8c4..6f6f4f7 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AbstractAlgorithm.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AbstractAlgorithm.java
@@ -19,7 +19,7 @@ public abstract class AbstractAlgorithm {
/**
* Create a new algorithm with an empty list of observers.
- *
+ *
* @param data Input data for the algorithm.
*/
protected AbstractAlgorithm(AbstractInputData data) {
@@ -29,7 +29,7 @@ public abstract class AbstractAlgorithm {
/**
* Create a new algorithm with the given list of observers.
- *
+ *
* @param data Input data for the algorithm.
* @param observers Initial list of observers for the algorithm.
*/
@@ -40,7 +40,7 @@ public abstract class AbstractAlgorithm {
/**
* Add an observer to this algorithm.
- *
+ *
* @param observer Observer to add to this algorithm.
*/
public void addObserver(Observer observer) {
@@ -62,11 +62,9 @@ public abstract class AbstractAlgorithm {
}
/**
- * Run the algorithm and return the solution.
- *
- * This methods internally time the call to doRun() and update the result of the
- * call with the computed solving time.
- *
+ * Run the algorithm and return the solution. This methods internally time the call
+ * to doRun() and update the result of the call with the computed solving time.
+ *
* @return The solution found by the algorithm (may not be a feasible solution).
*/
public AbstractSolution run() {
@@ -78,9 +76,9 @@ public abstract class AbstractAlgorithm {
/**
* Abstract method that should be implemented by child class.
- *
- * @return The solution found, must not be null (use an infeasible or unknown
- * status if necessary).
+ *
+ * @return The solution found, must not be null (use an infeasible or unknown status
+ * if necessary).
*/
protected abstract AbstractSolution doRun();
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AbstractInputData.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AbstractInputData.java
index a2a1b1f..2fb172d 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AbstractInputData.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AbstractInputData.java
@@ -5,16 +5,15 @@ import org.insa.graphs.model.Graph;
import org.insa.graphs.model.GraphStatistics;
/**
- * Base class for algorithm input data classes. This class contains the basic
- * data that are required by most graph algorithms, i.e. a graph, a mode (time /
- * length) and a filter for the arc.
- *
+ * Base class for algorithm input data classes. This class contains the basic data that
+ * are required by most graph algorithms, i.e. a graph, a mode (time / length) and a
+ * filter for the arc.
*/
public abstract class AbstractInputData {
/**
* Enum specifying the top mode of the algorithms.
- *
+ *
* @see ArcInspector
*/
public enum Mode {
@@ -29,7 +28,7 @@ public abstract class AbstractInputData {
/**
* Create a new AbstractInputData instance for the given graph, mode and filter.
- *
+ *
* @param graph Graph for this input data.
* @param arcInspector Arc inspector for this input data.
*/
@@ -46,13 +45,11 @@ public abstract class AbstractInputData {
}
/**
- * Retrieve the cost associated with the given arc according to the underlying
- * arc inspector.
- *
+ * Retrieve the cost associated with the given arc according to the underlying arc
+ * inspector.
+ *
* @param arc Arc for which cost should be retrieved.
- *
* @return Cost for the given arc.
- *
* @see ArcInspector
*/
public double getCost(Arc arc) {
@@ -61,7 +58,6 @@ public abstract class AbstractInputData {
/**
* @return Mode associated with this input data.
- *
* @see Mode
*/
public Mode getMode() {
@@ -70,10 +66,10 @@ public abstract class AbstractInputData {
/**
* Retrieve the maximum speed associated with this input data, or
- * {@link GraphStatistics#NO_MAXIMUM_SPEED} if none is associated. The maximum
- * speed associated with input data is different from the maximum speed
- * associated with graph (accessible via {@link Graph#getGraphInformation()}).
- *
+ * {@link GraphStatistics#NO_MAXIMUM_SPEED} if none is associated. The maximum speed
+ * associated with input data is different from the maximum speed associated with
+ * graph (accessible via {@link Graph#getGraphInformation()}).
+ *
* @return The maximum speed for this inspector, or
* {@link GraphStatistics#NO_MAXIMUM_SPEED} if none is set.
*/
@@ -83,11 +79,9 @@ public abstract class AbstractInputData {
/**
* Check if the given arc is allowed for the filter corresponding to this input.
- *
+ *
* @param arc Arc to check.
- *
* @return true if the given arc is allowed.
- *
* @see ArcInspector
*/
public boolean isAllowed(Arc arc) {
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AbstractSolution.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AbstractSolution.java
index 0d271eb..cb312ab 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AbstractSolution.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/AbstractSolution.java
@@ -3,16 +3,14 @@ package org.insa.graphs.algorithm;
import java.time.Duration;
/**
- * Base class for solution classes returned by the algorithm. This class
- * contains the basic information that any solution should have: status of the
- * solution (unknown, infeasible, etc.), solving time and the original input
- * data.
+ * Base class for solution classes returned by the algorithm. This class contains the
+ * basic information that any solution should have: status of the solution (unknown,
+ * infeasible, etc.), solving time and the original input data.
*/
public abstract class AbstractSolution {
/**
* Possible status for a solution.
- *
*/
public enum Status {
UNKNOWN, INFEASIBLE, FEASIBLE, OPTIMAL,
@@ -29,7 +27,7 @@ public abstract class AbstractSolution {
/**
* Create a new abstract solution with unknown status.
- *
+ *
* @param data
*/
protected AbstractSolution(AbstractInputData data) {
@@ -39,7 +37,6 @@ public abstract class AbstractSolution {
}
/**
- *
* @param data
* @param status
*/
@@ -71,7 +68,7 @@ public abstract class AbstractSolution {
/**
* Set the solving time of this solution.
- *
+ *
* @param solvingTime Solving time for the solution.
*/
protected void setSolvingTime(Duration solvingTime) {
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/ArcInspector.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/ArcInspector.java
index 18e6f2a..ff6d26e 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/ArcInspector.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/ArcInspector.java
@@ -5,26 +5,23 @@ import org.insa.graphs.model.Arc;
import org.insa.graphs.model.GraphStatistics;
/**
- * This class can be used to indicate to an algorithm which arcs can be used and
- * the costs of the usable arcs..
- *
+ * This class can be used to indicate to an algorithm which arcs can be used and the
+ * costs of the usable arcs..
*/
public interface ArcInspector {
/**
* Check if the given arc can be used (is allowed).
- *
+ *
* @param arc Arc to check.
- *
* @return true if the given arc is allowed.
*/
public boolean isAllowed(Arc arc);
/**
* Find the cost of the given arc.
- *
+ *
* @param arc Arc for which the cost should be returned.
- *
* @return Cost of the arc.
*/
public double getCost(Arc arc);
@@ -40,4 +37,4 @@ public interface ArcInspector {
*/
public Mode getMode();
-}
\ No newline at end of file
+}
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/ArcInspectorFactory.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/ArcInspectorFactory.java
index d43df60..d13caf6 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/ArcInspectorFactory.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/ArcInspectorFactory.java
@@ -52,9 +52,10 @@ public class ArcInspectorFactory {
filters.add(new ArcInspector() {
@Override
public boolean isAllowed(Arc arc) {
- return arc.getRoadInformation().getAccessRestrictions()
- .isAllowedForAny(AccessMode.MOTORCAR, EnumSet.complementOf(EnumSet
- .of(AccessRestriction.FORBIDDEN, AccessRestriction.PRIVATE)));
+ return arc.getRoadInformation().getAccessRestrictions().isAllowedForAny(
+ AccessMode.MOTORCAR,
+ EnumSet.complementOf(EnumSet.of(AccessRestriction.FORBIDDEN,
+ AccessRestriction.PRIVATE)));
}
@Override
@@ -110,9 +111,10 @@ public class ArcInspectorFactory {
filters.add(new ArcInspector() {
@Override
public boolean isAllowed(Arc arc) {
- return arc.getRoadInformation().getAccessRestrictions()
- .isAllowedForAny(AccessMode.MOTORCAR, EnumSet.complementOf(EnumSet
- .of(AccessRestriction.FORBIDDEN, AccessRestriction.PRIVATE)));
+ return arc.getRoadInformation().getAccessRestrictions().isAllowedForAny(
+ AccessMode.MOTORCAR,
+ EnumSet.complementOf(EnumSet.of(AccessRestriction.FORBIDDEN,
+ AccessRestriction.PRIVATE)));
}
@Override
@@ -141,15 +143,16 @@ public class ArcInspectorFactory {
@Override
public boolean isAllowed(Arc arc) {
- return arc.getRoadInformation().getAccessRestrictions()
- .isAllowedForAny(AccessMode.FOOT, EnumSet.complementOf(EnumSet
- .of(AccessRestriction.FORBIDDEN, AccessRestriction.PRIVATE)));
+ return arc.getRoadInformation().getAccessRestrictions().isAllowedForAny(
+ AccessMode.FOOT,
+ EnumSet.complementOf(EnumSet.of(AccessRestriction.FORBIDDEN,
+ AccessRestriction.PRIVATE)));
}
@Override
public double getCost(Arc arc) {
- return arc.getTravelTime(
- Math.min(getMaximumSpeed(), arc.getRoadInformation().getMaximumSpeed()));
+ return arc.getTravelTime(Math.min(getMaximumSpeed(),
+ arc.getRoadInformation().getMaximumSpeed()));
}
@Override
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/carpooling/CarPoolingAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/carpooling/CarPoolingAlgorithm.java
index a895e38..55a76c7 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/carpooling/CarPoolingAlgorithm.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/carpooling/CarPoolingAlgorithm.java
@@ -2,7 +2,8 @@ package org.insa.graphs.algorithm.carpooling;
import org.insa.graphs.algorithm.AbstractAlgorithm;
-public abstract class CarPoolingAlgorithm extends AbstractAlgorithm {
+public abstract class CarPoolingAlgorithm
+ extends AbstractAlgorithm {
protected CarPoolingAlgorithm(CarPoolingData data) {
super(data);
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/packageswitch/PackageSwitchAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/packageswitch/PackageSwitchAlgorithm.java
index 191e927..6856aba 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/packageswitch/PackageSwitchAlgorithm.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/packageswitch/PackageSwitchAlgorithm.java
@@ -2,11 +2,12 @@ package org.insa.graphs.algorithm.packageswitch;
import org.insa.graphs.algorithm.AbstractAlgorithm;
-public abstract class PackageSwitchAlgorithm extends AbstractAlgorithm {
+public abstract class PackageSwitchAlgorithm
+ extends AbstractAlgorithm {
/**
* Create a new PackageSwitchAlgorithm with the given data.
- *
+ *
* @param data
*/
protected PackageSwitchAlgorithm(PackageSwitchData data) {
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/BellmanFordAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/BellmanFordAlgorithm.java
index 42986aa..709438e 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/BellmanFordAlgorithm.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/BellmanFordAlgorithm.java
@@ -41,8 +41,8 @@ public class BellmanFordAlgorithm extends ShortestPathAlgorithm {
boolean found = false;
for (int i = 0; !found && i < nbNodes; ++i) {
found = true;
- for (Node node: graph.getNodes()) {
- for (Arc arc: node.getSuccessors()) {
+ for (Node node : graph.getNodes()) {
+ for (Arc arc : node.getSuccessors()) {
// Small test to check allowed roads...
if (!data.isAllowed(arc)) {
@@ -54,14 +54,16 @@ public class BellmanFordAlgorithm extends ShortestPathAlgorithm {
double oldDistance = distances[arc.getDestination().getId()];
double newDistance = distances[node.getId()] + w;
- if (Double.isInfinite(oldDistance) && Double.isFinite(newDistance)) {
+ if (Double.isInfinite(oldDistance)
+ && Double.isFinite(newDistance)) {
notifyNodeReached(arc.getDestination());
}
// Check if new distances would be better, if so update...
if (newDistance < oldDistance) {
found = false;
- distances[arc.getDestination().getId()] = distances[node.getId()] + w;
+ distances[arc.getDestination().getId()] =
+ distances[node.getId()] + w;
predecessorArcs[arc.getDestination().getId()] = arc;
}
}
@@ -91,7 +93,8 @@ public class BellmanFordAlgorithm extends ShortestPathAlgorithm {
Collections.reverse(arcs);
// Create the final solution.
- solution = new ShortestPathSolution(data, Status.OPTIMAL, new Path(graph, arcs));
+ solution = new ShortestPathSolution(data, Status.OPTIMAL,
+ new Path(graph, arcs));
}
return solution;
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/ShortestPathAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/ShortestPathAlgorithm.java
index 005e40c..fdebcd6 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/ShortestPathAlgorithm.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/ShortestPathAlgorithm.java
@@ -3,7 +3,8 @@ package org.insa.graphs.algorithm.shortestpath;
import org.insa.graphs.algorithm.AbstractAlgorithm;
import org.insa.graphs.model.Node;
-public abstract class ShortestPathAlgorithm extends AbstractAlgorithm {
+public abstract class ShortestPathAlgorithm
+ extends AbstractAlgorithm {
protected ShortestPathAlgorithm(ShortestPathData data) {
super(data);
@@ -24,45 +25,45 @@ public abstract class ShortestPathAlgorithm extends AbstractAlgorithm> implements PriorityQueue {
/**
* Construct a copy of the given heap.
- *
+ *
* @param heap Binary heap to copy.
*/
public BinaryHeap(BinaryHeap heap) {
@@ -39,7 +37,7 @@ public class BinaryHeap> implements PriorityQueue {
/**
* Set an element at the given index.
- *
+ *
* @param index Index at which the element should be set.
* @param value Element to set.
*/
@@ -68,15 +66,14 @@ public class BinaryHeap> implements PriorityQueue {
/**
* Internal method to percolate up in the heap.
- *
+ *
* @param index Index at which the percolate begins.
*/
private void percolateUp(int index) {
E x = this.array.get(index);
- for (; index > 0
- && x.compareTo(this.array.get(indexParent(index))) < 0; index = indexParent(
- index)) {
+ for (; index > 0 && x.compareTo(this.array.get(indexParent(index))) < 0; index =
+ indexParent(index)) {
E moving_val = this.array.get(indexParent(index));
this.arraySet(index, moving_val);
}
@@ -86,7 +83,7 @@ public class BinaryHeap> implements PriorityQueue {
/**
* Internal method to percolate down in the heap.
- *
+ *
* @param index Index at which the percolate begins.
*/
private void percolateDown(int index) {
@@ -158,7 +155,7 @@ public class BinaryHeap> implements PriorityQueue {
/**
* Creates a multi-lines string representing a sorted view of this binary heap.
- *
+ *
* @return a string containing a sorted view this binary heap.
*/
public String toStringSorted() {
@@ -167,10 +164,9 @@ public class BinaryHeap> implements PriorityQueue {
/**
* Creates a multi-lines string representing a sorted view of this binary heap.
- *
- * @param maxElement Maximum number of elements to display. or {@code -1} to
- * display all the elements.
- *
+ *
+ * @param maxElement Maximum number of elements to display. or {@code -1} to display
+ * all the elements.
* @return a string containing a sorted view this binary heap.
*/
public String toStringSorted(int maxElement) {
@@ -179,7 +175,7 @@ public class BinaryHeap> implements PriorityQueue {
/**
* Creates a multi-lines string representing a tree view of this binary heap.
- *
+ *
* @return a string containing a tree view of this binary heap.
*/
public String toStringTree() {
@@ -188,9 +184,8 @@ public class BinaryHeap> implements PriorityQueue {
/**
* Creates a multi-lines string representing a tree view of this binary heap.
- *
+ *
* @param maxDepth Maximum depth of the tree to display.
- *
* @return a string containing a tree view of this binary heap.
*/
public String toStringTree(int maxDepth) {
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinaryHeapFormatter.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinaryHeapFormatter.java
index adad622..a0468fe 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinaryHeapFormatter.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinaryHeapFormatter.java
@@ -7,7 +7,6 @@ public class BinaryHeapFormatter {
/**
* This class is used by {@link #toStringTree}, and simply contains three string
* accumulating. This is an immutable class.
- *
*/
private static class Context {
@@ -22,9 +21,9 @@ public class BinaryHeapFormatter {
/**
* Creaet a new {@code Context}.
- *
- * @param acu The accumulated string.
- * @param margin The current margin.
+ *
+ * @param acu The accumulated string.
+ * @param margin The current margin.
* @param lastMargin The last margin used.
*/
public Context(String acu, String margin, String lastMargin) {
@@ -35,9 +34,8 @@ public class BinaryHeapFormatter {
/**
* Creates a new context by appending newlines to this context.
- *
+ *
* @param n Number of newlines to append.
- *
* @return a new context with {@code n} newlines appended.
*/
public Context appendNewlines(int n) {
@@ -45,40 +43,40 @@ public class BinaryHeapFormatter {
return this;
}
else {
- return (new Context(this.acu + "\n" + this.margin, this.margin, this.lastmargin)
- .appendNewlines(n - 1));
+ return (new Context(this.acu + "\n" + this.margin, this.margin,
+ this.lastmargin).appendNewlines(n - 1));
}
}
/**
* Creates a new context by appending the given string to this context.
- *
+ *
* @param count Number of spaces to add to the margin, or {@code null} to use
- * the length of the string.
- * @param text String to append.
- *
+ * the length of the string.
+ * @param text String to append.
* @return a new context with {@code text} appended.
*/
public Context appendText(Integer count, String text) {
int cnt = (count == null) ? text.length() : count;
final String spaces = new String(new char[cnt]).replace('\0', ' ');
- return new Context(this.acu + text, this.margin + spaces, this.lastmargin + spaces);
+ return new Context(this.acu + text, this.margin + spaces,
+ this.lastmargin + spaces);
}
/**
* Creates a new context by appending a branch to this context.
- *
- * @param n Number of spaces to add to the margin, or {@code null} to use
- * the length of the string.
+ *
+ * @param n Number of spaces to add to the margin, or {@code null} to use the
+ * length of the string.
* @param label Name of the branch.
- *
* @return a new context with the branch appended.
*/
public Context appendBranch(Integer count, String label) {
final Context ctxt = this.appendText(count, label);
if (count == null) {
- return new Context(ctxt.acu + "_", ctxt.margin + "|", ctxt.margin + " ");
+ return new Context(ctxt.acu + "_", ctxt.margin + "|",
+ ctxt.margin + " ");
}
else {
return new Context(ctxt.acu, ctxt.margin + "|", ctxt.margin + " ")
@@ -89,8 +87,8 @@ public class BinaryHeapFormatter {
}
/*
- * Input : ready to write the current node at the current context position.
- * Output : the last character of acu is the last character of the current node.
+ * Input : ready to write the current node at the current context position. Output :
+ * the last character of acu is the last character of the current node.
*/
protected static > Context toStringLoop(BinaryHeap heap,
Context ctxt, int node, int max_depth) {
@@ -122,13 +120,16 @@ public class BinaryHeapFormatter {
int child = childs.get(ch);
if (is_last) {
- Context ctxt3 = new Context(ctxt2.acu, ctxt2.lastmargin, ctxt2.lastmargin);
- ctxt2 = new Context(toStringLoop(heap, ctxt3.appendText(null, "___"), child,
- max_depth - 1).acu, ctxt2.margin, ctxt2.lastmargin);
+ Context ctxt3 =
+ new Context(ctxt2.acu, ctxt2.lastmargin, ctxt2.lastmargin);
+ ctxt2 = new Context(toStringLoop(heap,
+ ctxt3.appendText(null, "___"), child, max_depth - 1).acu,
+ ctxt2.margin, ctxt2.lastmargin);
}
else {
- ctxt2 = new Context(toStringLoop(heap, ctxt2.appendText(null, "___"), child,
- max_depth - 1).acu, ctxt2.margin, ctxt2.lastmargin).appendNewlines(2);
+ ctxt2 = new Context(toStringLoop(heap,
+ ctxt2.appendText(null, "___"), child, max_depth - 1).acu,
+ ctxt2.margin, ctxt2.lastmargin).appendNewlines(2);
}
}
@@ -137,28 +138,25 @@ public class BinaryHeapFormatter {
}
/**
- * Creates a multi-lines string representing a tree view of the given binary
- * heap.
- *
- * @param heap The binary heap to display.
+ * Creates a multi-lines string representing a tree view of the given binary heap.
+ *
+ * @param heap The binary heap to display.
* @param maxDepth Maximum depth of the tree to display.
- *
* @return a string containing a tree view of the given binary heap.
*/
- public static > String toStringTree(BinaryHeap heap, int maxDepth) {
+ public static > String toStringTree(BinaryHeap heap,
+ int maxDepth) {
final Context init_context = new Context(" ", " ", " ");
final Context result = toStringLoop(heap, init_context, 0, maxDepth);
return result.acu;
}
/**
- * Creates a multi-lines string representing a sorted view of the given binary
- * heap.
- *
- * @param heap The binary heap to display.
- * @param maxElement Maximum number of elements to display. or {@code -1} to
- * display all the elements.
- *
+ * Creates a multi-lines string representing a sorted view of the given binary heap.
+ *
+ * @param heap The binary heap to display.
+ * @param maxElement Maximum number of elements to display. or {@code -1} to display
+ * all the elements.
* @return a string containing a sorted view the given binary heap.
*/
public static > String toStringSorted(BinaryHeap heap,
@@ -174,7 +172,8 @@ public class BinaryHeapFormatter {
truncate = ", only " + max_elements + " elements are shown";
}
- result += "======== Sorted HEAP (size = " + heap.size() + truncate + ") ========\n\n";
+ result += "======== Sorted HEAP (size = " + heap.size() + truncate
+ + ") ========\n\n";
while (!copy.isEmpty() && max_elements-- != 0) {
result += copy.deleteMin() + "\n";
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinarySearchTree.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinarySearchTree.java
index 32dfbb1..f711b30 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinarySearchTree.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinarySearchTree.java
@@ -17,7 +17,7 @@ public class BinarySearchTree> implements PriorityQueue<
/**
* Create a copy of the given binary search tree.
- *
+ *
* @param bst Binary search tree to copy.
*/
public BinarySearchTree(BinarySearchTree bst) {
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/ElementNotFoundException.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/ElementNotFoundException.java
index 3fb2729..fad7f9d 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/ElementNotFoundException.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/ElementNotFoundException.java
@@ -3,7 +3,7 @@ package org.insa.graphs.algorithm.utils;
public class ElementNotFoundException extends RuntimeException {
/**
- *
+ *
*/
private static final long serialVersionUID = 1L;
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/EmptyPriorityQueueException.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/EmptyPriorityQueueException.java
index bf09c5d..d45aa2e 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/EmptyPriorityQueueException.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/EmptyPriorityQueueException.java
@@ -3,14 +3,13 @@ package org.insa.graphs.algorithm.utils;
public class EmptyPriorityQueueException extends RuntimeException {
/**
- *
+ *
*/
private static final long serialVersionUID = 1L;
/**
- *
+ *
*/
- public EmptyPriorityQueueException() {
- }
+ public EmptyPriorityQueueException() {}
}
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/PriorityQueue.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/PriorityQueue.java
index 104f79e..c7eb60b 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/PriorityQueue.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/PriorityQueue.java
@@ -1,79 +1,69 @@
package org.insa.graphs.algorithm.utils;
/**
- * Interface representing a basic priority queue.
- *
- * Implementation should enforce the required complexity of each method.
- *
+ * Interface representing a basic priority queue. Implementation should enforce the
+ * required complexity of each method.
*/
public interface PriorityQueue> {
/**
* Check if the priority queue is empty.
- *
*
* Complexity:O(1)
*
- *
+ *
* @return true if the queue is empty, false otherwise.
*/
public boolean isEmpty();
/**
* Get the number of elements in this queue.
- *
*
* Complexity:O(1)
*
- *
+ *
* @return Current size (number of elements) of this queue.
*/
public int size();
/**
* Insert the given element into the queue.
- *
*
* Complexity:O(log n)
*
- *
+ *
* @param x Item to insert.
*/
public void insert(E x);
/**
* Remove the given element from the priority queue.
- *
*
* Complexity:O(log n)
*
- *
+ *
* @param x Item to remove.
*/
public void remove(E x) throws ElementNotFoundException;
/**
* Retrieve (but not remove) the smallest item in the queue.
- *
*
* Complexity:O(1)
*
- *
+ *
* @return The smallest item in the queue.
- *
* @throws EmptyPriorityQueueException if this queue is empty.
*/
public E findMin() throws EmptyPriorityQueueException;
/**
* Remove and return the smallest item from the priority queue.
- *
*
* Complexity:O(log n)
*
- *
+ *
* @return The smallest item in the queue.
- *
* @throws EmptyPriorityQueueException if this queue is empty.
*/
public E deleteMin() throws EmptyPriorityQueueException;
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentObserver.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentObserver.java
index e7b0a5a..e47dbcb 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentObserver.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentObserver.java
@@ -6,25 +6,25 @@ import org.insa.graphs.model.Node;
public interface WeaklyConnectedComponentObserver {
- /**
- * Notify that the algorithm is entering a new component.
- *
- * @param curNode Starting node for the component.
- */
- public void notifyStartComponent(Node curNode);
-
- /**
- * Notify that a new node has been found for the current component.
- *
- * @param node New node found for the current component.
- */
- public void notifyNewNodeInComponent(Node node);
-
- /**
- * Notify that the algorithm has computed a new component.
- *
- * @param nodes List of nodes in the component.
- */
- public void notifyEndComponent(ArrayList nodes);
+ /**
+ * Notify that the algorithm is entering a new component.
+ *
+ * @param curNode Starting node for the component.
+ */
+ public void notifyStartComponent(Node curNode);
+
+ /**
+ * Notify that a new node has been found for the current component.
+ *
+ * @param node New node found for the current component.
+ */
+ public void notifyNewNodeInComponent(Node node);
+
+ /**
+ * Notify that the algorithm has computed a new component.
+ *
+ * @param nodes List of nodes in the component.
+ */
+ public void notifyEndComponent(ArrayList nodes);
}
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentTextObserver.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentTextObserver.java
index 1a725c7..862ebc7 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentTextObserver.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentTextObserver.java
@@ -5,32 +5,33 @@ import java.util.ArrayList;
import org.insa.graphs.model.Node;
-public class WeaklyConnectedComponentTextObserver implements WeaklyConnectedComponentObserver {
-
- // Number of the current component.
- private int numComponent = 1;
-
- // Output stream
- PrintStream stream;
+public class WeaklyConnectedComponentTextObserver
+ implements WeaklyConnectedComponentObserver {
- public WeaklyConnectedComponentTextObserver(PrintStream stream) {
- this.stream = stream;
- }
+ // Number of the current component.
+ private int numComponent = 1;
- @Override
- public void notifyStartComponent(Node curNode) {
- stream.print("Entering component #" + numComponent + " from node #" + curNode.getId() + "... ");
- }
+ // Output stream
+ PrintStream stream;
- @Override
- public void notifyNewNodeInComponent(Node node) {
- }
+ public WeaklyConnectedComponentTextObserver(PrintStream stream) {
+ this.stream = stream;
+ }
- @Override
- public void notifyEndComponent(ArrayList nodes) {
- stream.println(nodes.size() + " nodes found.");
- stream.flush();
- numComponent += 1;
- }
+ @Override
+ public void notifyStartComponent(Node curNode) {
+ stream.print("Entering component #" + numComponent + " from node #"
+ + curNode.getId() + "... ");
+ }
+
+ @Override
+ public void notifyNewNodeInComponent(Node node) {}
+
+ @Override
+ public void notifyEndComponent(ArrayList nodes) {
+ stream.println(nodes.size() + " nodes found.");
+ stream.flush();
+ numComponent += 1;
+ }
}
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentsAlgorithm.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentsAlgorithm.java
index 42462bb..74cc623 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentsAlgorithm.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentsAlgorithm.java
@@ -34,34 +34,33 @@ public class WeaklyConnectedComponentsAlgorithm
/**
* Notify all observers that the algorithm is entering a new component.
- *
+ *
* @param curNode Starting node for the component.
*/
protected void notifyStartComponent(Node curNode) {
- for (WeaklyConnectedComponentObserver obs: getObservers()) {
+ for (WeaklyConnectedComponentObserver obs : getObservers()) {
obs.notifyStartComponent(curNode);
}
}
/**
- * Notify all observers that a new node has been found for the current
- * component.
- *
+ * Notify all observers that a new node has been found for the current component.
+ *
* @param node New node found for the current component.
*/
protected void notifyNewNodeInComponent(Node node) {
- for (WeaklyConnectedComponentObserver obs: getObservers()) {
+ for (WeaklyConnectedComponentObserver obs : getObservers()) {
obs.notifyNewNodeInComponent(node);
}
}
/**
* Notify all observers that the algorithm has computed a new component.
- *
+ *
* @param nodes List of nodes in the component.
*/
protected void notifyEndComponent(ArrayList nodes) {
- for (WeaklyConnectedComponentObserver obs: getObservers()) {
+ for (WeaklyConnectedComponentObserver obs : getObservers()) {
obs.notifyEndComponent(nodes);
}
}
@@ -77,8 +76,8 @@ public class WeaklyConnectedComponentsAlgorithm
res.add(new HashSet());
}
- for (Node node: getInputData().getGraph().getNodes()) {
- for (Arc arc: node.getSuccessors()) {
+ for (Node node : getInputData().getGraph().getNodes()) {
+ for (Arc arc : node.getSuccessors()) {
res.get(node.getId()).add(arc.getDestination().getId());
if (arc.getRoadInformation().isOneWay()) {
res.get(arc.getDestination().getId()).add(node.getId());
@@ -90,15 +89,15 @@ public class WeaklyConnectedComponentsAlgorithm
}
/**
- * Apply a breadth first search algorithm on the given undirected graph
- * (adjacency list), starting at node cur, and marking nodes in marked.
- *
+ * Apply a breadth first search algorithm on the given undirected graph (adjacency
+ * list), starting at node cur, and marking nodes in marked.
+ *
* @param marked
* @param cur
- *
* @return
*/
- protected ArrayList bfs(ArrayList> ugraph, boolean[] marked, int cur) {
+ protected ArrayList bfs(ArrayList> ugraph, boolean[] marked,
+ int cur) {
Graph graph = getInputData().getGraph();
ArrayList component = new ArrayList();
@@ -118,7 +117,7 @@ public class WeaklyConnectedComponentsAlgorithm
// Notify observers
notifyNewNodeInComponent(node);
- for (Integer destId: ugraph.get(node.getId())) {
+ for (Integer destId : ugraph.get(node.getId())) {
Node dest = graph.get(destId);
if (!marked[dest.getId()]) {
queue.add(destId);
@@ -149,11 +148,11 @@ public class WeaklyConnectedComponentsAlgorithm
components.add(this.bfs(ugraph, marked, cur));
// Find next non-marked
- for (; cur < marked.length && marked[cur]; ++cur)
- ;
+ for (; cur < marked.length && marked[cur]; ++cur);
}
- return new WeaklyConnectedComponentsSolution(getInputData(), Status.OPTIMAL, components);
+ return new WeaklyConnectedComponentsSolution(getInputData(), Status.OPTIMAL,
+ components);
}
}
diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentsSolution.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentsSolution.java
index a0b2d4a..ac422f4 100644
--- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentsSolution.java
+++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/weakconnectivity/WeaklyConnectedComponentsSolution.java
@@ -14,8 +14,8 @@ public class WeaklyConnectedComponentsSolution extends AbstractSolution {
super(data);
}
- protected WeaklyConnectedComponentsSolution(WeaklyConnectedComponentsData data, Status status,
- ArrayList> components) {
+ protected WeaklyConnectedComponentsSolution(WeaklyConnectedComponentsData data,
+ Status status, ArrayList> components) {
super(data, status);
this.components = components;
}
@@ -34,14 +34,14 @@ public class WeaklyConnectedComponentsSolution extends AbstractSolution {
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
int nIsolated = 0;
int nGt10 = 0;
- for (ArrayList component: components) {
+ for (ArrayList component : components) {
if (component.size() == 1) {
nIsolated += 1;
}
@@ -49,8 +49,9 @@ public class WeaklyConnectedComponentsSolution extends AbstractSolution {
nGt10 += 1;
}
}
- return "Found " + components.size() + " components (" + nGt10 + " with more than 10 nodes, "
- + nIsolated + " isolated nodes) in " + getSolvingTime().getSeconds() + " seconds.";
+ return "Found " + components.size() + " components (" + nGt10
+ + " with more than 10 nodes, " + nIsolated + " isolated nodes) in "
+ + getSolvingTime().getSeconds() + " seconds.";
}
diff --git a/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/BinaryHeapTest.java b/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/BinaryHeapTest.java
index df91636..ba9b9ed 100644
--- a/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/BinaryHeapTest.java
+++ b/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/BinaryHeapTest.java
@@ -8,7 +8,8 @@ public class BinaryHeapTest extends PriorityQueueTest {
}
@Override
- public PriorityQueue createQueue(PriorityQueue queue) {
+ public PriorityQueue createQueue(
+ PriorityQueue queue) {
return new BinaryHeap<>((BinaryHeap) queue);
}
diff --git a/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/BinarySearchTreeTest.java b/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/BinarySearchTreeTest.java
index 803846d..102e440 100644
--- a/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/BinarySearchTreeTest.java
+++ b/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/BinarySearchTreeTest.java
@@ -8,7 +8,8 @@ public class BinarySearchTreeTest extends PriorityQueueTest {
}
@Override
- public PriorityQueue createQueue(PriorityQueue queue) {
+ public PriorityQueue createQueue(
+ PriorityQueue queue) {
return new BinarySearchTree<>((BinarySearchTree) queue);
}
diff --git a/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/PriorityQueueTest.java b/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/PriorityQueueTest.java
index c796598..2da689f 100644
--- a/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/PriorityQueueTest.java
+++ b/be-graphes-algos/src/test/java/org/insa/graphs/algorithm/utils/PriorityQueueTest.java
@@ -25,7 +25,7 @@ public abstract class PriorityQueueTest {
/**
* Needs to be implemented by child class to actually provide priority queue
* implementation.
- *
+ *
* @return A new instance of a PriorityQueue implementation.
*/
public abstract PriorityQueue createQueue();
@@ -33,12 +33,12 @@ public abstract class PriorityQueueTest {
/**
* Needs to be implemented by child class to actually provide priority queue
* implementation.
- *
+ *
* @param queue Queue to copy.
- *
* @return Copy of the given queue.
*/
- public abstract PriorityQueue createQueue(PriorityQueue queue);
+ public abstract PriorityQueue createQueue(
+ PriorityQueue queue);
protected static class MutableInteger implements Comparable {
@@ -58,7 +58,7 @@ public abstract class PriorityQueueTest {
/**
* Update the integer value stored inside this MutableInteger.
- *
+ *
* @param value New value to set.
*/
public void set(int value) {
@@ -92,7 +92,6 @@ public abstract class PriorityQueueTest {
/**
* Set of parameters.
- *
*/
@Parameters
public static Collection
- *
*
* If {@code roadInformation.isOneWay()} is {@code true}, only a forward arc is
- * created (origin to destination) and added to origin. Otherwise, a
- * corresponding backward arc is created and add to destination.
+ * created (origin to destination) and added to origin. Otherwise, a corresponding
+ * backward arc is created and add to destination.
*
- *
- * @param origin Origin of the arc.
- * @param destination Destination of the arc.
- * @param length Length of the arc.
+ *
+ * @param origin Origin of the arc.
+ * @param destination Destination of the arc.
+ * @param length Length of the arc.
* @param roadInformation Information corresponding to the arc.
- * @param points Points for the arc.
- *
+ * @param points Points for the arc.
* @return The newly created forward arc (origin to destination).
*/
public static Arc linkNodes(Node origin, Node destination, float length,
@@ -51,12 +46,14 @@ public final class Node implements Comparable {
else {
final Arc d2o;
if (origin.getId() < destination.getId()) {
- arc = new ArcForward(origin, destination, length, roadInformation, points);
+ arc = new ArcForward(origin, destination, length, roadInformation,
+ points);
d2o = new ArcBackward(arc);
}
else {
Collections.reverse(points);
- d2o = new ArcForward(destination, origin, length, roadInformation, points);
+ d2o = new ArcForward(destination, origin, length, roadInformation,
+ points);
arc = new ArcBackward(d2o);
}
origin.addSuccessor(arc);
@@ -77,8 +74,8 @@ public final class Node implements Comparable {
/**
* Create a new Node with the given ID corresponding to the given Point with an
* empty list of successors.
- *
- * @param id ID of the node.
+ *
+ * @param id ID of the node.
* @param point Position of the node.
*/
public Node(int id, Point point) {
@@ -89,7 +86,7 @@ public final class Node implements Comparable {
/**
* Add a successor to this node.
- *
+ *
* @param arc Arc to the successor.
*/
protected void addSuccessor(Arc arc) {
@@ -119,7 +116,6 @@ public final class Node implements Comparable {
/**
* @return List of successors of this node (unmodifiable list).
- *
* @see Collections#unmodifiableList(List)
*/
public List getSuccessors() {
@@ -146,9 +142,8 @@ public final class Node implements Comparable {
/**
* Compare the ID of this node with the ID of the given node.
- *
+ *
* @param other Node to compare this node with.
- *
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/Point.java b/be-graphes-model/src/main/java/org/insa/graphs/model/Point.java
index 82c6f57..13302dd 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/Point.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/Point.java
@@ -2,7 +2,6 @@ package org.insa.graphs.model;
/**
* Class representing a point (position) on Earth.
- *
*/
public final class Point {
@@ -13,10 +12,9 @@ public final class Point {
/**
* Compute the distance in meters between the two given points.
- *
+ *
* @param p1 First point.
* @param p2 second point.
- *
* @return Distance between the two given points (in meters).
*/
public static double distance(Point p1, Point p2) {
@@ -24,7 +22,8 @@ public final class Point {
* Math.sin(Math.toRadians(p2.getLatitude()));
double cosLat = Math.cos(Math.toRadians(p1.getLatitude()))
* Math.cos(Math.toRadians(p2.getLatitude()));
- double cosLong = Math.cos(Math.toRadians(p2.getLongitude() - p1.getLongitude()));
+ double cosLong =
+ Math.cos(Math.toRadians(p2.getLongitude() - p1.getLongitude()));
return EARTH_RADIUS * Math.acos(sinLat + cosLat * cosLong);
}
@@ -33,7 +32,7 @@ public final class Point {
/**
* Create a new point corresponding to the given (longitude, latitude) position.
- *
+ *
* @param longitude Longitude of the point (in degrees).
* @param latitude Latitude of the point (in degrees).
*/
@@ -58,9 +57,8 @@ public final class Point {
/**
* Compute the distance from this point to the given point
- *
+ *
* @param target Target point to compute distance to.
- *
* @return Distance between this point and the target point, in meters.
*/
public double distanceTo(Point target) {
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/RoadInformation.java b/be-graphes-model/src/main/java/org/insa/graphs/model/RoadInformation.java
index f5fa39c..e0472eb 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/RoadInformation.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/RoadInformation.java
@@ -4,41 +4,22 @@ package org.insa.graphs.model;
*
* Class containing information for road that may be shared by multiple arcs.
*
- *
*
- * Sharing information between arcs reduces memory footprints of the program (a
- * long road is often split into multiple arcs at each intersection).
+ * Sharing information between arcs reduces memory footprints of the program (a long
+ * road is often split into multiple arcs at each intersection).
*
- *
*/
public class RoadInformation {
/**
* Enumeration for road types.
- *
+ *
* @see OpenStreetMap
* reference for road types.
*/
public enum RoadType {
- MOTORWAY,
- TRUNK,
- PRIMARY,
- SECONDARY,
- MOTORWAY_LINK,
- TRUNK_LINK,
- PRIMARY_LINK,
- SECONDARY_LINK,
- TERTIARY,
- TRACK,
- RESIDENTIAL,
- UNCLASSIFIED,
- LIVING_STREET,
- SERVICE,
- ROUNDABOUT,
- PEDESTRIAN,
- CYCLEWAY,
- COASTLINE
+ MOTORWAY, TRUNK, PRIMARY, SECONDARY, MOTORWAY_LINK, TRUNK_LINK, PRIMARY_LINK, SECONDARY_LINK, TERTIARY, TRACK, RESIDENTIAL, UNCLASSIFIED, LIVING_STREET, SERVICE, ROUNDABOUT, PEDESTRIAN, CYCLEWAY, COASTLINE
}
// Type of the road (see above).
@@ -58,16 +39,15 @@ public class RoadInformation {
/**
* Create a new RoadInformation instance containing the given parameters.
- *
+ *
* @param roadType Type of the road (see {@link RoadType}).
- * @param access Access restrictions for the road (see
- * {@link AccessRestrictions}).
+ * @param access Access restrictions for the road (see {@link AccessRestrictions}).
* @param isOneWay true if this road is a one way road, false otherwise.
* @param maxSpeed Maximum speed for the road (in kilometers-per-hour).
* @param name Name of the road.
*/
- public RoadInformation(RoadType roadType, AccessRestrictions access, boolean isOneWay,
- int maxSpeed, String name) {
+ public RoadInformation(RoadType roadType, AccessRestrictions access,
+ boolean isOneWay, int maxSpeed, String name) {
this.type = roadType;
this.access = access;
this.oneway = isOneWay;
@@ -119,8 +99,8 @@ public class RoadInformation {
if (getType() == RoadType.MOTORWAY) {
typeAsString = "highway";
}
- return typeAsString + " : " + getName() + " " + (isOneWay() ? " (oneway) " : "") + maxSpeed
- + " km/h (max.)";
+ return typeAsString + " : " + getName() + " " + (isOneWay() ? " (oneway) " : "")
+ + maxSpeed + " km/h (max.)";
}
}
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BadFormatException.java b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BadFormatException.java
index 78439f0..23e5077 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BadFormatException.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BadFormatException.java
@@ -5,12 +5,11 @@ import java.io.IOException;
/**
* Exception thrown when a format-error is detected when reading a graph (e.g.,
* non-matching check bytes).
- *
*/
public class BadFormatException extends IOException {
/**
- *
+ *
*/
private static final long serialVersionUID = 1270945933549613579L;
@@ -23,7 +22,7 @@ public class BadFormatException extends IOException {
/**
* Create a new format exception with the given message.
- *
+ *
* @param message Message for the exception.
*/
public BadFormatException(String message) {
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BadMagicNumberException.java b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BadMagicNumberException.java
index 31d9f42..5bb4799 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BadMagicNumberException.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BadMagicNumberException.java
@@ -1,14 +1,12 @@
package org.insa.graphs.model.io;
/**
- * Exception thrown when there is a mismatch between expected and actual magic
- * number.
- *
+ * Exception thrown when there is a mismatch between expected and actual magic number.
*/
public class BadMagicNumberException extends BadFormatException {
/**
- *
+ *
*/
private static final long serialVersionUID = -2176603967548838864L;
@@ -18,13 +16,13 @@ public class BadMagicNumberException extends BadFormatException {
/**
* Create a new BadMagicNumberException with the given expected and actual magic
* number.
- *
+ *
* @param actualNumber Actual magic number (read from a file).
* @param expectedNumber Expected magic number.
*/
public BadMagicNumberException(int actualNumber, int expectedNumber) {
- super(String.format("Magic number mismatch, expected %#X, got %#X.", expectedNumber,
- actualNumber));
+ super(String.format("Magic number mismatch, expected %#X, got %#X.",
+ expectedNumber, actualNumber));
this.actualNumber = actualNumber;
this.expectedNumber = expectedNumber;
}
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BadVersionException.java b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BadVersionException.java
index 892f534..808d6ab 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BadVersionException.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BadVersionException.java
@@ -1,14 +1,12 @@
package org.insa.graphs.model.io;
/**
- * Exception thrown when the version of the file is not at least the expected
- * one.
- *
+ * Exception thrown when the version of the file is not at least the expected one.
*/
public class BadVersionException extends BadFormatException {
/**
- *
+ *
*/
private static final long serialVersionUID = 7776317018302386042L;
@@ -16,7 +14,6 @@ public class BadVersionException extends BadFormatException {
private int actualVersion, expectedVersion;
/**
- *
* @param actualVersion Actual version of the file.
* @param expectedVersion Expected version of the file.
*/
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryGraphReader.java b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryGraphReader.java
index 84833e8..9e52574 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryGraphReader.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryGraphReader.java
@@ -20,7 +20,6 @@ import org.insa.graphs.model.RoadInformation.RoadType;
/**
* Implementation of {@link GraphReader} to read graph in binary format.
- *
*/
public class BinaryGraphReader extends BinaryReader implements GraphReader {
@@ -36,9 +35,8 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
/**
* Parse the given long value into a new instance of AccessRestrictions.
- *
+ *
* @param access The value to parse.
- *
* @return New instance of access restrictions parsed from the given value.
*/
protected static AccessRestrictions toAccessInformation(final long access) {
@@ -50,22 +48,25 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
// the order correspond to the 4 bits value (i.e. FORBIDDEN is 0 or PRIVATE is
// 2) - UKNOWN is not included because value above 6 (FORESTRY) are all
// considered unknown.
- final AccessRestriction[] allRestrictions = new AccessRestriction[] {
- AccessRestriction.FORBIDDEN, AccessRestriction.ALLOWED, AccessRestriction.PRIVATE,
- AccessRestriction.DESTINATION, AccessRestriction.DELIVERY,
- AccessRestriction.CUSTOMERS, AccessRestriction.FORESTRY };
+ final AccessRestriction[] allRestrictions =
+ new AccessRestriction[] { AccessRestriction.FORBIDDEN,
+ AccessRestriction.ALLOWED, AccessRestriction.PRIVATE,
+ AccessRestriction.DESTINATION, AccessRestriction.DELIVERY,
+ AccessRestriction.CUSTOMERS, AccessRestriction.FORESTRY };
// The order of values inside this array is VERY IMPORTANT: The order is such
// that each 4-bits group of the long value is processed in the correct order,
// i.e. FOOT is processed first (4 lowest bits), and so on.
- final AccessMode[] allModes = new AccessMode[] { AccessMode.FOOT, null, AccessMode.BICYCLE,
- AccessMode.SMALL_MOTORCYCLE, AccessMode.AGRICULTURAL, AccessMode.MOTORCYCLE,
- AccessMode.MOTORCAR, AccessMode.HEAVY_GOODS, null, AccessMode.PUBLIC_TRANSPORT };
+ final AccessMode[] allModes = new AccessMode[] { AccessMode.FOOT, null,
+ AccessMode.BICYCLE, AccessMode.SMALL_MOTORCYCLE,
+ AccessMode.AGRICULTURAL, AccessMode.MOTORCYCLE, AccessMode.MOTORCAR,
+ AccessMode.HEAVY_GOODS, null, AccessMode.PUBLIC_TRANSPORT };
// fill maps...
- final EnumMap restrictions = new EnumMap<>(AccessMode.class);
+ final EnumMap restrictions =
+ new EnumMap<>(AccessMode.class);
long copyAccess = access;
- for (AccessMode mode: allModes) {
+ for (AccessMode mode : allModes) {
if (mode == null) {
continue; // filling cells
}
@@ -84,58 +85,56 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
/**
* Convert a character to its corresponding road type.
- *
+ *
* @param ch Character to convert.
- *
* @return Road type corresponding to the given character.
- *
*/
protected static RoadType toRoadType(char ch) {
switch (ch) {
- case 'a':
- return RoadType.MOTORWAY;
- case 'b':
- return RoadType.TRUNK;
- case 'c':
- return RoadType.PRIMARY;
- case 'd':
- return RoadType.SECONDARY;
- case 'e':
- return RoadType.MOTORWAY_LINK;
- case 'f':
- return RoadType.TRUNK_LINK;
- case 'g':
- return RoadType.PRIMARY_LINK;
- case 'h':
- return RoadType.SECONDARY_LINK;
- case 'i':
- return RoadType.TERTIARY;
- case 'j':
- return RoadType.RESIDENTIAL;
- case 'k':
- case 'l':
- return RoadType.UNCLASSIFIED;
- case 'm':
- return RoadType.LIVING_STREET;
- case 'n':
- return RoadType.SERVICE;
- case 'o':
- return RoadType.ROUNDABOUT;
- case 'p':
- return RoadType.PEDESTRIAN;
- case 'r':
- return RoadType.CYCLEWAY;
- case 's':
- return RoadType.TRACK;
- case 'z':
- return RoadType.COASTLINE;
+ case 'a':
+ return RoadType.MOTORWAY;
+ case 'b':
+ return RoadType.TRUNK;
+ case 'c':
+ return RoadType.PRIMARY;
+ case 'd':
+ return RoadType.SECONDARY;
+ case 'e':
+ return RoadType.MOTORWAY_LINK;
+ case 'f':
+ return RoadType.TRUNK_LINK;
+ case 'g':
+ return RoadType.PRIMARY_LINK;
+ case 'h':
+ return RoadType.SECONDARY_LINK;
+ case 'i':
+ return RoadType.TERTIARY;
+ case 'j':
+ return RoadType.RESIDENTIAL;
+ case 'k':
+ case 'l':
+ return RoadType.UNCLASSIFIED;
+ case 'm':
+ return RoadType.LIVING_STREET;
+ case 'n':
+ return RoadType.SERVICE;
+ case 'o':
+ return RoadType.ROUNDABOUT;
+ case 'p':
+ return RoadType.PEDESTRIAN;
+ case 'r':
+ return RoadType.CYCLEWAY;
+ case 's':
+ return RoadType.TRACK;
+ case 'z':
+ return RoadType.COASTLINE;
}
return RoadType.UNCLASSIFIED;
}
/**
* Create a new BinaryGraphReader that read from the given input stream.
- *
+ *
* @param dis Input stream to read from.
*/
public BinaryGraphReader(DataInputStream dis) {
@@ -181,8 +180,10 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
final ArrayList nodes = new ArrayList(nbNodes);
// Read nodes.
- float minLongitude = Float.POSITIVE_INFINITY, minLatitude = Float.POSITIVE_INFINITY,
- maxLongitude = Float.NEGATIVE_INFINITY, maxLatitude = Float.NEGATIVE_INFINITY;
+ float minLongitude = Float.POSITIVE_INFINITY,
+ minLatitude = Float.POSITIVE_INFINITY,
+ maxLongitude = Float.NEGATIVE_INFINITY,
+ maxLatitude = Float.NEGATIVE_INFINITY;
observers.forEach((observer) -> observer.notifyStartReadingNodes(nbNodes));
for (int node = 0; node < nbNodes; ++node) {
// Read longitude / latitude.
@@ -230,7 +231,8 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
float maxLength = 0;
final int copyNbTotalSuccesors = nbTotalSuccessors; // Stupid Java...
int nbOneWayRoad = 0;
- observers.forEach((observer) -> observer.notifyStartReadingArcs(copyNbTotalSuccesors));
+ observers.forEach(
+ (observer) -> observer.notifyStartReadingArcs(copyNbTotalSuccesors));
for (int node = 0; node < nbNodes; ++node) {
for (int succ = 0; succ < nbSuccessors[node]; ++succ) {
@@ -250,8 +252,9 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
}
maxLength = Math.max(length, maxLength);
- length = Math.max(length, (float) Point.distance(nodes.get(node).getPoint(),
- nodes.get(destNode).getPoint()));
+ length = Math.max(length,
+ (float) Point.distance(nodes.get(node).getPoint(),
+ nodes.get(destNode).getPoint()));
// Number of segments.
final int nbSegments = dis.readUnsignedShort();
@@ -294,14 +297,14 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
new GraphStatistics(
new BoundingBox(new Point(minLongitude, maxLatitude),
new Point(maxLongitude, minLatitude)),
- nbOneWayRoad, nbTotalSuccessors - nbOneWayRoad, maxSpeed, maxLength));
+ nbOneWayRoad, nbTotalSuccessors - nbOneWayRoad, maxSpeed,
+ maxLength));
}
/**
* Read the next road information from the stream.
- *
+ *
* @return The next RoadInformation in the stream.
- *
* @throws IOException if an error occurs while reading from the stream.
*/
private RoadInformation readRoadInformation() throws IOException {
@@ -315,8 +318,8 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
// TODO: Try to create something...
dis.readUnsignedShort();
}
- return new RoadInformation(toRoadType(type), access, (x & 0x80) > 0, (x & 0x7F) * 5,
- dis.readUTF());
+ return new RoadInformation(toRoadType(type), access, (x & 0x80) > 0,
+ (x & 0x7F) * 5, dis.readUTF());
}
}
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryPathReader.java b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryPathReader.java
index 4aca938..7ebb8f9 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryPathReader.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryPathReader.java
@@ -10,7 +10,6 @@ import org.insa.graphs.model.Path;
/**
* Implementation of {@link PathReader} to read paths in binary format.
- *
*/
public class BinaryPathReader extends BinaryReader implements PathReader {
@@ -20,7 +19,7 @@ public class BinaryPathReader extends BinaryReader implements PathReader {
/**
* Create a new BinaryPathReader that read from the given input stream.
- *
+ *
* @param dis Input stream to read from.
*/
public BinaryPathReader(DataInputStream dis) {
@@ -35,7 +34,8 @@ public class BinaryPathReader extends BinaryReader implements PathReader {
checkVersionOrThrow(dis.readInt());
// Read map ID and check against graph.
- final String mapId = readFixedLengthString(BinaryGraphReader.MAP_ID_FIELD_LENGTH, "UTF-8");
+ final String mapId =
+ readFixedLengthString(BinaryGraphReader.MAP_ID_FIELD_LENGTH, "UTF-8");
if (!mapId.equals(graph.getMapId())) {
throw new MapMismatchException(mapId, graph.getMapId());
@@ -59,12 +59,10 @@ public class BinaryPathReader extends BinaryReader implements PathReader {
/**
* Read a node from the input stream and returns it.
- *
+ *
* @param graph Graph containing the nodes.
- *
* @return The next node in the input stream.
- *
- * @throws IOException if something occurs while reading the note.
+ * @throws IOException if something occurs while reading the note.
* @throws IndexOutOfBoundsException if the node is not in the graph.
*/
protected Node readNode(Graph graph) throws IOException {
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryPathWriter.java b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryPathWriter.java
index 52b00df..4cc1cc8 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryPathWriter.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryPathWriter.java
@@ -9,13 +9,12 @@ import org.insa.graphs.model.Path;
/**
* Implementation of {@link PathWriter} to write paths in binary format.
- *
*/
public class BinaryPathWriter extends BinaryWriter implements PathWriter {
/**
* Create a new BinaryPathWriter that writes to the given output stream.
- *
+ *
* @param dos Output stream to write to.
*/
public BinaryPathWriter(DataOutputStream dos) {
@@ -43,7 +42,7 @@ public class BinaryPathWriter extends BinaryWriter implements PathWriter {
// Write nodes.
dos.writeInt(path.getOrigin().getId());
- for (Arc arc: path.getArcs()) {
+ for (Arc arc : path.getArcs()) {
dos.writeInt(arc.getDestination().getId());
}
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryReader.java b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryReader.java
index 159a59b..b73a745 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryReader.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryReader.java
@@ -6,7 +6,6 @@ import java.io.IOException;
/**
* Base class for writing binary file.
- *
*/
public abstract class BinaryReader implements AutoCloseable, Closeable {
@@ -19,12 +18,12 @@ public abstract class BinaryReader implements AutoCloseable, Closeable {
protected final DataInputStream dis;
/**
- * Create a new BinaryReader that reads from the given stream and that expected
- * the given magic number and at least the given minimum version.
- *
+ * Create a new BinaryReader that reads from the given stream and that expected the
+ * given magic number and at least the given minimum version.
+ *
* @param magicNumber Magic number of files to be read.
- * @param minVersion Minimum version of files to be read.
- * @param dis Input stream from which to read.
+ * @param minVersion Minimum version of files to be read.
+ * @param dis Input stream from which to read.
*/
protected BinaryReader(int magicNumber, int minVersion, DataInputStream dis) {
this.magicNumber = magicNumber;
@@ -38,13 +37,12 @@ public abstract class BinaryReader implements AutoCloseable, Closeable {
}
/**
- * Check if the given version is greater than the minimum version, and update
- * the current version if it is.
- *
+ * Check if the given version is greater than the minimum version, and update the
+ * current version if it is.
+ *
* @param version Version to check.
- *
- * @throws BadVersionException if the given version is not greater than the
- * minimum version.
+ * @throws BadVersionException if the given version is not greater than the minimum
+ * version.
*/
protected void checkVersionOrThrow(int version) throws BadVersionException {
if (version < this.minVersion) {
@@ -62,25 +60,23 @@ public abstract class BinaryReader implements AutoCloseable, Closeable {
/**
* Check if the given number matches the expected magic number.
- *
+ *
* @param magicNumber The magic number to check.
- *
* @throws BadMagicNumberException If the two magic numbers are not equal.
*/
- protected void checkMagicNumberOrThrow(int magicNumber) throws BadMagicNumberException {
+ protected void checkMagicNumberOrThrow(int magicNumber)
+ throws BadMagicNumberException {
if (this.magicNumber != magicNumber) {
throw new BadMagicNumberException(magicNumber, this.magicNumber);
}
}
/**
- * Check if the next byte in the input stream correspond to the given byte.
- *
- * This function consumes the next byte in the input stream.
- *
+ * Check if the next byte in the input stream correspond to the given byte. This
+ * function consumes the next byte in the input stream.
+ *
* @param b Byte to check.
- *
- * @throws IOException if an error occurs while reading the byte.
+ * @throws IOException if an error occurs while reading the byte.
* @throws BadFormatException if the byte read is not the expected one.
*/
protected void checkByteOrThrow(int b) throws IOException {
@@ -90,17 +86,16 @@ public abstract class BinaryReader implements AutoCloseable, Closeable {
}
/**
- * Read a byte array of fixed length from the input and convert it to a string
- * using the given charset, removing any trailing '\0'.
- *
- * @param length Number of bytes to read.
+ * Read a byte array of fixed length from the input and convert it to a string using
+ * the given charset, removing any trailing '\0'.
+ *
+ * @param length Number of bytes to read.
* @param charset Charset to use to convert the bytes into a string.
- *
* @return The convert string.
- *
* @throws IOException if an error occurs while reading or converting.
*/
- protected String readFixedLengthString(int length, String charset) throws IOException {
+ protected String readFixedLengthString(int length, String charset)
+ throws IOException {
byte[] bytes = new byte[length];
this.dis.read(bytes);
return new String(bytes, "UTF-8").trim();
@@ -109,9 +104,8 @@ public abstract class BinaryReader implements AutoCloseable, Closeable {
/**
* Read 24 bits in BigEndian order from the stream and return the corresponding
* integer value.
- *
+ *
* @return Integer value read from the next 24 bits of the stream.
- *
* @throws IOException if an error occurs while reading from the stream.
*/
protected int read24bits() throws IOException {
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryWriter.java b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryWriter.java
index 34cad06..8152afe 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryWriter.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/io/BinaryWriter.java
@@ -6,7 +6,6 @@ import java.io.IOException;
/**
* Base class for writing binary file.
- *
*/
public abstract class BinaryWriter implements AutoCloseable, Closeable {
@@ -15,7 +14,7 @@ public abstract class BinaryWriter implements AutoCloseable, Closeable {
/**
* Create a new BinaryWriter that writes to the given output stream.
- *
+ *
* @param dos Stream to write to.
*/
protected BinaryWriter(DataOutputStream dos) {
@@ -29,9 +28,8 @@ public abstract class BinaryWriter implements AutoCloseable, Closeable {
/**
* Write a 24-bits integer in BigEndian order to the output stream.
- *
+ *
* @param value Value to write.
- *
* @throws IOException if an error occurs while writing to the stream.
*/
protected void write24bits(int value) throws IOException {
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/io/GraphReader.java b/be-graphes-model/src/main/java/org/insa/graphs/model/io/GraphReader.java
index 29ed437..7d01fb1 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/io/GraphReader.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/io/GraphReader.java
@@ -7,32 +7,28 @@ import org.insa.graphs.model.Graph;
/**
* Base interface for classes that can read graph.
- *
*/
public interface GraphReader extends AutoCloseable, Closeable {
/**
* Add a new observer to this graph reader.
- *
+ *
* @param observer Observer to add.
*/
public void addObserver(GraphReaderObserver observer);
/**
* Read a graph an returns it.
- *
+ *
* @return The graph read.
- *
* @throws IOException if an exception occurs while reading the graph.
- *
*/
public Graph read() throws IOException;
/**
* Close this graph reader.
- *
+ *
* @throws IOException if an exception occurs while closing the reader.
- *
*/
public void close() throws IOException;
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/io/GraphReaderObserver.java b/be-graphes-model/src/main/java/org/insa/graphs/model/io/GraphReaderObserver.java
index 4f25835..6722c55 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/io/GraphReaderObserver.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/io/GraphReaderObserver.java
@@ -5,16 +5,15 @@ import org.insa.graphs.model.Node;
import org.insa.graphs.model.RoadInformation;
/**
- * Base interface that should be implemented by classes that want to observe the
- * reading of a graph by a {@link GraphReader}.
- *
+ * Base interface that should be implemented by classes that want to observe the reading
+ * of a graph by a {@link GraphReader}.
*/
public interface GraphReaderObserver {
/**
- * Notify observer about information on the graph, this method is always the
- * first called
- *
+ * Notify observer about information on the graph, this method is always the first
+ * called
+ *
* @param mapId ID of the graph.
*/
public void notifyStartReading(String mapId);
@@ -26,42 +25,42 @@ public interface GraphReaderObserver {
/**
* Notify that the reader is starting to read node.
- *
+ *
* @param nNodes Number of nodes to read.
*/
public void notifyStartReadingNodes(int nNodes);
/**
* Notify that a new nodes has been read.
- *
+ *
* @param node read.
*/
public void notifyNewNodeRead(Node node);
/**
* Notify that the reader is starting to read descriptor/road informations.
- *
+ *
* @param nDesc Number of descriptors to read.
*/
public void notifyStartReadingDescriptors(int nDesc);
/**
* Notify that a new descriptor has been read.
- *
+ *
* @param desc Descriptor read.
*/
public void notifyNewDescriptorRead(RoadInformation desc);
/**
* Notify that the reader is starting to read arcs.
- *
+ *
* @param nArcs Number of arcs to read (!= number of arcs in the graph).
*/
public void notifyStartReadingArcs(int nArcs);
/**
* Notify that a new arc has been read.
- *
+ *
* @param arc Arc read.
*/
public void notifyNewArcRead(Arc arc);
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/io/MapMismatchException.java b/be-graphes-model/src/main/java/org/insa/graphs/model/io/MapMismatchException.java
index ea80056..f559d74 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/io/MapMismatchException.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/io/MapMismatchException.java
@@ -3,14 +3,13 @@ package org.insa.graphs.model.io;
import java.io.IOException;
/**
- * Exception thrown when there is mismatch between the expected map ID and the
- * actual map ID when reading a graph.
- *
+ * Exception thrown when there is mismatch between the expected map ID and the actual
+ * map ID when reading a graph.
*/
public class MapMismatchException extends IOException {
/**
- *
+ *
*/
private static final long serialVersionUID = 1L;
@@ -19,8 +18,8 @@ public class MapMismatchException extends IOException {
/**
* Create a new MapMismatchException with the given IDs.
- *
- * @param actualMapId Actual map ID found when reading the path.
+ *
+ * @param actualMapId Actual map ID found when reading the path.
* @param expectedMapId Expected map ID from the graph.
*/
public MapMismatchException(String actualMapId, String expectedMapId) {
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/io/PathReader.java b/be-graphes-model/src/main/java/org/insa/graphs/model/io/PathReader.java
index e14a5a2..4d6ff7c 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/io/PathReader.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/io/PathReader.java
@@ -8,26 +8,22 @@ import org.insa.graphs.model.Path;
/**
* Base interface that should be implemented by class used to read paths.
- *
*/
public interface PathReader extends AutoCloseable, Closeable {
/**
* Read a path of the given graph and returns it.
- *
+ *
* @param graph Graph of the path.
- *
* @return Path read.
- *
* @throws IOException When an error occurs while reading the path.
*/
public Path readPath(Graph graph) throws IOException;
/**
* Close this graph reader.
- *
+ *
* @throws IOException if an exception occurs while closing the reader.
- *
*/
public void close() throws IOException;
diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/io/PathWriter.java b/be-graphes-model/src/main/java/org/insa/graphs/model/io/PathWriter.java
index b261763..e094e8e 100644
--- a/be-graphes-model/src/main/java/org/insa/graphs/model/io/PathWriter.java
+++ b/be-graphes-model/src/main/java/org/insa/graphs/model/io/PathWriter.java
@@ -7,24 +7,21 @@ import org.insa.graphs.model.Path;
/**
* Base interface that should be implemented by class used to write paths.
- *
*/
public interface PathWriter extends AutoCloseable, Closeable {
/**
* Write the given path.
- *
+ *
* @param path Path to write.
- *
* @throws IOException When an error occurs while writing the path.
*/
public void writePath(Path path) throws IOException;
/**
* Close this graph reader.
- *
+ *
* @throws IOException if an exception occurs while closing the reader.
- *
*/
public void close() throws IOException;
diff --git a/be-graphes-model/src/test/java/org/insa/graphes/model/GraphTest.java b/be-graphes-model/src/test/java/org/insa/graphes/model/GraphTest.java
index f9333b9..34e1989 100644
--- a/be-graphes-model/src/test/java/org/insa/graphes/model/GraphTest.java
+++ b/be-graphes-model/src/test/java/org/insa/graphes/model/GraphTest.java
@@ -39,23 +39,29 @@ public class GraphTest {
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
new ArrayList<>());
Node.linkNodes(nodes[0], nodes[4], 0,
- new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null), new ArrayList<>());
+ new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null),
+ new ArrayList<>());
Node.linkNodes(nodes[1], nodes[2], 0,
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
new ArrayList<>());
Node.linkNodes(nodes[2], nodes[3], 0,
- new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null), new ArrayList<>());
+ new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null),
+ new ArrayList<>());
Node.linkNodes(nodes[2], nodes[3], 0,
- new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null), new ArrayList<>());
+ new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null),
+ new ArrayList<>());
Node.linkNodes(nodes[2], nodes[3], 0,
- new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null), new ArrayList<>());
+ new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null),
+ new ArrayList<>());
Node.linkNodes(nodes[3], nodes[0], 0,
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
new ArrayList<>());
Node.linkNodes(nodes[3], nodes[4], 0,
- new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null), new ArrayList<>());
+ new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null),
+ new ArrayList<>());
Node.linkNodes(nodes[4], nodes[0], 0,
- new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null), new ArrayList<>());
+ new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null),
+ new ArrayList<>());
graph = new Graph("ID", "", Arrays.asList(nodes), null);
@@ -66,7 +72,7 @@ public class GraphTest {
*/
private List getArcsBetween(Node a, Node b) {
List arcs = new ArrayList<>();
- for (Arc arc: a.getSuccessors()) {
+ for (Arc arc : a.getSuccessors()) {
if (arc.getDestination().equals(b)) {
arcs.add(arc);
}
diff --git a/be-graphes-model/src/test/java/org/insa/graphes/model/NodeTest.java b/be-graphes-model/src/test/java/org/insa/graphes/model/NodeTest.java
index 057c5d5..b2146d1 100644
--- a/be-graphes-model/src/test/java/org/insa/graphes/model/NodeTest.java
+++ b/be-graphes-model/src/test/java/org/insa/graphes/model/NodeTest.java
@@ -33,23 +33,29 @@ public class NodeTest {
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
new ArrayList<>());
Node.linkNodes(nodes[0], nodes[4], 0,
- new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null), new ArrayList<>());
+ new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null),
+ new ArrayList<>());
Node.linkNodes(nodes[1], nodes[2], 0,
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
new ArrayList<>());
Node.linkNodes(nodes[2], nodes[3], 0,
- new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null), new ArrayList<>());
+ new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null),
+ new ArrayList<>());
Node.linkNodes(nodes[2], nodes[3], 0,
- new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null), new ArrayList<>());
+ new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null),
+ new ArrayList<>());
Node.linkNodes(nodes[2], nodes[3], 0,
- new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null), new ArrayList<>());
+ new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null),
+ new ArrayList<>());
Node.linkNodes(nodes[3], nodes[0], 0,
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
new ArrayList<>());
Node.linkNodes(nodes[3], nodes[4], 0,
- new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null), new ArrayList<>());
+ new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null),
+ new ArrayList<>());
Node.linkNodes(nodes[4], nodes[0], 0,
- new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null), new ArrayList<>());
+ new RoadInformation(RoadType.UNCLASSIFIED, null, true, 1, null),
+ new ArrayList<>());
}
@@ -57,7 +63,7 @@ public class NodeTest {
* @return The first arc between from a to b, or null.
*/
private Arc getFirstArcBetween(Node a, Node b) {
- for (Arc arc: a.getSuccessors()) {
+ for (Arc arc : a.getSuccessors()) {
if (arc.getDestination().equals(b)) {
return arc;
}
diff --git a/be-graphes-model/src/test/java/org/insa/graphes/model/PathTest.java b/be-graphes-model/src/test/java/org/insa/graphes/model/PathTest.java
index fbef0f3..e8cf97e 100644
--- a/be-graphes-model/src/test/java/org/insa/graphes/model/PathTest.java
+++ b/be-graphes-model/src/test/java/org/insa/graphes/model/PathTest.java
@@ -30,14 +30,15 @@ public class PathTest {
private static Arc a2b, a2c, a2e, b2c, c2d_1, c2d_2, c2d_3, c2a, d2a, d2e, e2d;
// Some paths...
- private static Path emptyPath, singleNodePath, shortPath, longPath, loopPath, longLoopPath,
- invalidPath;
+ private static Path emptyPath, singleNodePath, shortPath, longPath, loopPath,
+ longLoopPath, invalidPath;
@BeforeClass
public static void initAll() throws IOException {
// 10 and 20 meters per seconds
- RoadInformation speed10 = new RoadInformation(RoadType.MOTORWAY, null, true, 36, ""),
+ RoadInformation speed10 =
+ new RoadInformation(RoadType.MOTORWAY, null, true, 36, ""),
speed20 = new RoadInformation(RoadType.MOTORWAY, null, true, 72, "");
// Create nodes
@@ -65,8 +66,8 @@ public class PathTest {
shortPath = new Path(graph, Arrays.asList(new Arc[] { a2b, b2c, c2d_1 }));
longPath = new Path(graph, Arrays.asList(new Arc[] { a2b, b2c, c2d_1, d2e }));
loopPath = new Path(graph, Arrays.asList(new Arc[] { a2b, b2c, c2d_1, d2a }));
- longLoopPath = new Path(graph,
- Arrays.asList(new Arc[] { a2b, b2c, c2d_1, d2a, a2c, c2d_3, d2a, a2b, b2c }));
+ longLoopPath = new Path(graph, Arrays
+ .asList(new Arc[] { a2b, b2c, c2d_1, d2a, a2c, c2d_3, d2a, a2b, b2c }));
invalidPath = new Path(graph, Arrays.asList(new Arc[] { a2b, c2d_1, d2e }));
}
@@ -184,7 +185,8 @@ public class PathTest {
}
// Trap construction!
- path = Path.createFastestPathFromNodes(graph, Arrays.asList(new Node[] { nodes[1] }));
+ path = Path.createFastestPathFromNodes(graph,
+ Arrays.asList(new Node[] { nodes[1] }));
assertEquals(nodes[1], path.getOrigin());
assertEquals(0, path.getArcs().size());
@@ -219,7 +221,8 @@ public class PathTest {
}
// Trap construction!
- path = Path.createShortestPathFromNodes(graph, Arrays.asList(new Node[] { nodes[1] }));
+ path = Path.createShortestPathFromNodes(graph,
+ Arrays.asList(new Node[] { nodes[1] }));
assertEquals(nodes[1], path.getOrigin());
assertEquals(0, path.getArcs().size());
@@ -232,12 +235,14 @@ public class PathTest {
@Test(expected = IllegalArgumentException.class)
public void testCreateFastestPathFromNodesException() {
- Path.createFastestPathFromNodes(graph, Arrays.asList(new Node[] { nodes[1], nodes[0] }));
+ Path.createFastestPathFromNodes(graph,
+ Arrays.asList(new Node[] { nodes[1], nodes[0] }));
}
@Test(expected = IllegalArgumentException.class)
public void testCreateShortestPathFromNodesException() {
- Path.createShortestPathFromNodes(graph, Arrays.asList(new Node[] { nodes[1], nodes[0] }));
+ Path.createShortestPathFromNodes(graph,
+ Arrays.asList(new Node[] { nodes[1], nodes[0] }));
}
}
diff --git a/eclipse-java-google-style.xml b/eclipse-java-google-style.xml
new file mode 100644
index 0000000..840826c
--- /dev/null
+++ b/eclipse-java-google-style.xml
@@ -0,0 +1,338 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index 260a625..bcd9806 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,7 +1,5 @@
-
+4.0.0org.insa.graphs