[clean] Apply formatting and add formatter configuration.
This commit is contained in:
parent
2f936d44ec
commit
730cda6426
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,6 +8,7 @@ doc
|
|||||||
*.jar
|
*.jar
|
||||||
.settings
|
.settings
|
||||||
.classpath
|
.classpath
|
||||||
|
.vscode
|
||||||
|
|
||||||
# Editor specific files and folders
|
# Editor specific files and folders
|
||||||
*~
|
*~
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<project
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
@ -62,10 +62,8 @@ public abstract class AbstractAlgorithm<Observer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the algorithm and return the solution.
|
* 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.
|
||||||
* 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).
|
* @return The solution found by the algorithm (may not be a feasible solution).
|
||||||
*/
|
*/
|
||||||
@ -79,8 +77,8 @@ public abstract class AbstractAlgorithm<Observer> {
|
|||||||
/**
|
/**
|
||||||
* Abstract method that should be implemented by child class.
|
* Abstract method that should be implemented by child class.
|
||||||
*
|
*
|
||||||
* @return The solution found, must not be null (use an infeasible or unknown
|
* @return The solution found, must not be null (use an infeasible or unknown status
|
||||||
* status if necessary).
|
* if necessary).
|
||||||
*/
|
*/
|
||||||
protected abstract AbstractSolution doRun();
|
protected abstract AbstractSolution doRun();
|
||||||
|
|
||||||
|
@ -5,10 +5,9 @@ import org.insa.graphs.model.Graph;
|
|||||||
import org.insa.graphs.model.GraphStatistics;
|
import org.insa.graphs.model.GraphStatistics;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for algorithm input data classes. This class contains the basic
|
* Base class for algorithm input data classes. This class contains the basic data that
|
||||||
* data that are required by most graph algorithms, i.e. a graph, a mode (time /
|
* are required by most graph algorithms, i.e. a graph, a mode (time / length) and a
|
||||||
* length) and a filter for the arc.
|
* filter for the arc.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractInputData {
|
public abstract class AbstractInputData {
|
||||||
|
|
||||||
@ -46,13 +45,11 @@ public abstract class AbstractInputData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the cost associated with the given arc according to the underlying
|
* Retrieve the cost associated with the given arc according to the underlying arc
|
||||||
* arc inspector.
|
* inspector.
|
||||||
*
|
*
|
||||||
* @param arc Arc for which cost should be retrieved.
|
* @param arc Arc for which cost should be retrieved.
|
||||||
*
|
|
||||||
* @return Cost for the given arc.
|
* @return Cost for the given arc.
|
||||||
*
|
|
||||||
* @see ArcInspector
|
* @see ArcInspector
|
||||||
*/
|
*/
|
||||||
public double getCost(Arc arc) {
|
public double getCost(Arc arc) {
|
||||||
@ -61,7 +58,6 @@ public abstract class AbstractInputData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Mode associated with this input data.
|
* @return Mode associated with this input data.
|
||||||
*
|
|
||||||
* @see Mode
|
* @see Mode
|
||||||
*/
|
*/
|
||||||
public Mode getMode() {
|
public Mode getMode() {
|
||||||
@ -70,9 +66,9 @@ public abstract class AbstractInputData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the maximum speed associated with this input data, or
|
* Retrieve the maximum speed associated with this input data, or
|
||||||
* {@link GraphStatistics#NO_MAXIMUM_SPEED} if none is associated. The maximum
|
* {@link GraphStatistics#NO_MAXIMUM_SPEED} if none is associated. The maximum speed
|
||||||
* speed associated with input data is different from the maximum speed
|
* associated with input data is different from the maximum speed associated with
|
||||||
* associated with graph (accessible via {@link Graph#getGraphInformation()}).
|
* graph (accessible via {@link Graph#getGraphInformation()}).
|
||||||
*
|
*
|
||||||
* @return The maximum speed for this inspector, or
|
* @return The maximum speed for this inspector, or
|
||||||
* {@link GraphStatistics#NO_MAXIMUM_SPEED} if none is set.
|
* {@link GraphStatistics#NO_MAXIMUM_SPEED} if none is set.
|
||||||
@ -85,9 +81,7 @@ public abstract class AbstractInputData {
|
|||||||
* Check if the given arc is allowed for the filter corresponding to this input.
|
* Check if the given arc is allowed for the filter corresponding to this input.
|
||||||
*
|
*
|
||||||
* @param arc Arc to check.
|
* @param arc Arc to check.
|
||||||
*
|
|
||||||
* @return true if the given arc is allowed.
|
* @return true if the given arc is allowed.
|
||||||
*
|
|
||||||
* @see ArcInspector
|
* @see ArcInspector
|
||||||
*/
|
*/
|
||||||
public boolean isAllowed(Arc arc) {
|
public boolean isAllowed(Arc arc) {
|
||||||
|
@ -3,16 +3,14 @@ package org.insa.graphs.algorithm;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for solution classes returned by the algorithm. This class
|
* Base class for solution classes returned by the algorithm. This class contains the
|
||||||
* contains the basic information that any solution should have: status of the
|
* basic information that any solution should have: status of the solution (unknown,
|
||||||
* solution (unknown, infeasible, etc.), solving time and the original input
|
* infeasible, etc.), solving time and the original input data.
|
||||||
* data.
|
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSolution {
|
public abstract class AbstractSolution {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Possible status for a solution.
|
* Possible status for a solution.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public enum Status {
|
public enum Status {
|
||||||
UNKNOWN, INFEASIBLE, FEASIBLE, OPTIMAL,
|
UNKNOWN, INFEASIBLE, FEASIBLE, OPTIMAL,
|
||||||
@ -39,7 +37,6 @@ public abstract class AbstractSolution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param data
|
* @param data
|
||||||
* @param status
|
* @param status
|
||||||
*/
|
*/
|
||||||
|
@ -5,9 +5,8 @@ import org.insa.graphs.model.Arc;
|
|||||||
import org.insa.graphs.model.GraphStatistics;
|
import org.insa.graphs.model.GraphStatistics;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class can be used to indicate to an algorithm which arcs can be used and
|
* This class can be used to indicate to an algorithm which arcs can be used and the
|
||||||
* the costs of the usable arcs..
|
* costs of the usable arcs..
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface ArcInspector {
|
public interface ArcInspector {
|
||||||
|
|
||||||
@ -15,7 +14,6 @@ public interface ArcInspector {
|
|||||||
* Check if the given arc can be used (is allowed).
|
* Check if the given arc can be used (is allowed).
|
||||||
*
|
*
|
||||||
* @param arc Arc to check.
|
* @param arc Arc to check.
|
||||||
*
|
|
||||||
* @return true if the given arc is allowed.
|
* @return true if the given arc is allowed.
|
||||||
*/
|
*/
|
||||||
public boolean isAllowed(Arc arc);
|
public boolean isAllowed(Arc arc);
|
||||||
@ -24,7 +22,6 @@ public interface ArcInspector {
|
|||||||
* Find the cost of the given arc.
|
* Find the cost of the given arc.
|
||||||
*
|
*
|
||||||
* @param arc Arc for which the cost should be returned.
|
* @param arc Arc for which the cost should be returned.
|
||||||
*
|
|
||||||
* @return Cost of the arc.
|
* @return Cost of the arc.
|
||||||
*/
|
*/
|
||||||
public double getCost(Arc arc);
|
public double getCost(Arc arc);
|
||||||
|
@ -52,9 +52,10 @@ public class ArcInspectorFactory {
|
|||||||
filters.add(new ArcInspector() {
|
filters.add(new ArcInspector() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isAllowed(Arc arc) {
|
public boolean isAllowed(Arc arc) {
|
||||||
return arc.getRoadInformation().getAccessRestrictions()
|
return arc.getRoadInformation().getAccessRestrictions().isAllowedForAny(
|
||||||
.isAllowedForAny(AccessMode.MOTORCAR, EnumSet.complementOf(EnumSet
|
AccessMode.MOTORCAR,
|
||||||
.of(AccessRestriction.FORBIDDEN, AccessRestriction.PRIVATE)));
|
EnumSet.complementOf(EnumSet.of(AccessRestriction.FORBIDDEN,
|
||||||
|
AccessRestriction.PRIVATE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -110,9 +111,10 @@ public class ArcInspectorFactory {
|
|||||||
filters.add(new ArcInspector() {
|
filters.add(new ArcInspector() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isAllowed(Arc arc) {
|
public boolean isAllowed(Arc arc) {
|
||||||
return arc.getRoadInformation().getAccessRestrictions()
|
return arc.getRoadInformation().getAccessRestrictions().isAllowedForAny(
|
||||||
.isAllowedForAny(AccessMode.MOTORCAR, EnumSet.complementOf(EnumSet
|
AccessMode.MOTORCAR,
|
||||||
.of(AccessRestriction.FORBIDDEN, AccessRestriction.PRIVATE)));
|
EnumSet.complementOf(EnumSet.of(AccessRestriction.FORBIDDEN,
|
||||||
|
AccessRestriction.PRIVATE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -141,15 +143,16 @@ public class ArcInspectorFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAllowed(Arc arc) {
|
public boolean isAllowed(Arc arc) {
|
||||||
return arc.getRoadInformation().getAccessRestrictions()
|
return arc.getRoadInformation().getAccessRestrictions().isAllowedForAny(
|
||||||
.isAllowedForAny(AccessMode.FOOT, EnumSet.complementOf(EnumSet
|
AccessMode.FOOT,
|
||||||
.of(AccessRestriction.FORBIDDEN, AccessRestriction.PRIVATE)));
|
EnumSet.complementOf(EnumSet.of(AccessRestriction.FORBIDDEN,
|
||||||
|
AccessRestriction.PRIVATE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getCost(Arc arc) {
|
public double getCost(Arc arc) {
|
||||||
return arc.getTravelTime(
|
return arc.getTravelTime(Math.min(getMaximumSpeed(),
|
||||||
Math.min(getMaximumSpeed(), arc.getRoadInformation().getMaximumSpeed()));
|
arc.getRoadInformation().getMaximumSpeed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,7 +2,8 @@ package org.insa.graphs.algorithm.carpooling;
|
|||||||
|
|
||||||
import org.insa.graphs.algorithm.AbstractAlgorithm;
|
import org.insa.graphs.algorithm.AbstractAlgorithm;
|
||||||
|
|
||||||
public abstract class CarPoolingAlgorithm extends AbstractAlgorithm<CarPoolingObserver> {
|
public abstract class CarPoolingAlgorithm
|
||||||
|
extends AbstractAlgorithm<CarPoolingObserver> {
|
||||||
|
|
||||||
protected CarPoolingAlgorithm(CarPoolingData data) {
|
protected CarPoolingAlgorithm(CarPoolingData data) {
|
||||||
super(data);
|
super(data);
|
||||||
|
@ -2,7 +2,8 @@ package org.insa.graphs.algorithm.packageswitch;
|
|||||||
|
|
||||||
import org.insa.graphs.algorithm.AbstractAlgorithm;
|
import org.insa.graphs.algorithm.AbstractAlgorithm;
|
||||||
|
|
||||||
public abstract class PackageSwitchAlgorithm extends AbstractAlgorithm<PackageSwitchObserver> {
|
public abstract class PackageSwitchAlgorithm
|
||||||
|
extends AbstractAlgorithm<PackageSwitchObserver> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PackageSwitchAlgorithm with the given data.
|
* Create a new PackageSwitchAlgorithm with the given data.
|
||||||
|
@ -41,8 +41,8 @@ public class BellmanFordAlgorithm extends ShortestPathAlgorithm {
|
|||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (int i = 0; !found && i < nbNodes; ++i) {
|
for (int i = 0; !found && i < nbNodes; ++i) {
|
||||||
found = true;
|
found = true;
|
||||||
for (Node node: graph.getNodes()) {
|
for (Node node : graph.getNodes()) {
|
||||||
for (Arc arc: node.getSuccessors()) {
|
for (Arc arc : node.getSuccessors()) {
|
||||||
|
|
||||||
// Small test to check allowed roads...
|
// Small test to check allowed roads...
|
||||||
if (!data.isAllowed(arc)) {
|
if (!data.isAllowed(arc)) {
|
||||||
@ -54,14 +54,16 @@ public class BellmanFordAlgorithm extends ShortestPathAlgorithm {
|
|||||||
double oldDistance = distances[arc.getDestination().getId()];
|
double oldDistance = distances[arc.getDestination().getId()];
|
||||||
double newDistance = distances[node.getId()] + w;
|
double newDistance = distances[node.getId()] + w;
|
||||||
|
|
||||||
if (Double.isInfinite(oldDistance) && Double.isFinite(newDistance)) {
|
if (Double.isInfinite(oldDistance)
|
||||||
|
&& Double.isFinite(newDistance)) {
|
||||||
notifyNodeReached(arc.getDestination());
|
notifyNodeReached(arc.getDestination());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if new distances would be better, if so update...
|
// Check if new distances would be better, if so update...
|
||||||
if (newDistance < oldDistance) {
|
if (newDistance < oldDistance) {
|
||||||
found = false;
|
found = false;
|
||||||
distances[arc.getDestination().getId()] = distances[node.getId()] + w;
|
distances[arc.getDestination().getId()] =
|
||||||
|
distances[node.getId()] + w;
|
||||||
predecessorArcs[arc.getDestination().getId()] = arc;
|
predecessorArcs[arc.getDestination().getId()] = arc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +93,8 @@ public class BellmanFordAlgorithm extends ShortestPathAlgorithm {
|
|||||||
Collections.reverse(arcs);
|
Collections.reverse(arcs);
|
||||||
|
|
||||||
// Create the final solution.
|
// 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;
|
return solution;
|
||||||
|
@ -3,7 +3,8 @@ package org.insa.graphs.algorithm.shortestpath;
|
|||||||
import org.insa.graphs.algorithm.AbstractAlgorithm;
|
import org.insa.graphs.algorithm.AbstractAlgorithm;
|
||||||
import org.insa.graphs.model.Node;
|
import org.insa.graphs.model.Node;
|
||||||
|
|
||||||
public abstract class ShortestPathAlgorithm extends AbstractAlgorithm<ShortestPathObserver> {
|
public abstract class ShortestPathAlgorithm
|
||||||
|
extends AbstractAlgorithm<ShortestPathObserver> {
|
||||||
|
|
||||||
protected ShortestPathAlgorithm(ShortestPathData data) {
|
protected ShortestPathAlgorithm(ShortestPathData data) {
|
||||||
super(data);
|
super(data);
|
||||||
@ -28,7 +29,7 @@ public abstract class ShortestPathAlgorithm extends AbstractAlgorithm<ShortestPa
|
|||||||
* @param node Origin.
|
* @param node Origin.
|
||||||
*/
|
*/
|
||||||
public void notifyOriginProcessed(Node node) {
|
public void notifyOriginProcessed(Node node) {
|
||||||
for (ShortestPathObserver obs: getObservers()) {
|
for (ShortestPathObserver obs : getObservers()) {
|
||||||
obs.notifyOriginProcessed(node);
|
obs.notifyOriginProcessed(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,19 +40,19 @@ public abstract class ShortestPathAlgorithm extends AbstractAlgorithm<ShortestPa
|
|||||||
* @param node Node that has been reached.
|
* @param node Node that has been reached.
|
||||||
*/
|
*/
|
||||||
public void notifyNodeReached(Node node) {
|
public void notifyNodeReached(Node node) {
|
||||||
for (ShortestPathObserver obs: getObservers()) {
|
for (ShortestPathObserver obs : getObservers()) {
|
||||||
obs.notifyNodeReached(node);
|
obs.notifyNodeReached(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify all observers that a node has been marked, i.e. its final value has
|
* Notify all observers that a node has been marked, i.e. its final value has been
|
||||||
* been set.
|
* set.
|
||||||
*
|
*
|
||||||
* @param node Node that has been marked.
|
* @param node Node that has been marked.
|
||||||
*/
|
*/
|
||||||
public void notifyNodeMarked(Node node) {
|
public void notifyNodeMarked(Node node) {
|
||||||
for (ShortestPathObserver obs: getObservers()) {
|
for (ShortestPathObserver obs : getObservers()) {
|
||||||
obs.notifyNodeMarked(node);
|
obs.notifyNodeMarked(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,7 +63,7 @@ public abstract class ShortestPathAlgorithm extends AbstractAlgorithm<ShortestPa
|
|||||||
* @param node Destination.
|
* @param node Destination.
|
||||||
*/
|
*/
|
||||||
public void notifyDestinationReached(Node node) {
|
public void notifyDestinationReached(Node node) {
|
||||||
for (ShortestPathObserver obs: getObservers()) {
|
for (ShortestPathObserver obs : getObservers()) {
|
||||||
obs.notifyDestinationReached(node);
|
obs.notifyDestinationReached(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,11 @@ public class ShortestPathData extends AbstractInputData {
|
|||||||
* @param graph Graph in which the path should be looked for.
|
* @param graph Graph in which the path should be looked for.
|
||||||
* @param origin Origin node of the path.
|
* @param origin Origin node of the path.
|
||||||
* @param destination Destination node of the path.
|
* @param destination Destination node of the path.
|
||||||
* @param arcInspector Filter for arcs (used to allow only a specific set of
|
* @param arcInspector Filter for arcs (used to allow only a specific set of arcs in
|
||||||
* arcs in the graph to be used).
|
* the graph to be used).
|
||||||
*/
|
*/
|
||||||
public ShortestPathData(Graph graph, Node origin, Node destination, ArcInspector arcInspector) {
|
public ShortestPathData(Graph graph, Node origin, Node destination,
|
||||||
|
ArcInspector arcInspector) {
|
||||||
super(graph, arcInspector);
|
super(graph, arcInspector);
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
@ -41,7 +42,7 @@ public class ShortestPathData extends AbstractInputData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Shortest-path from #" + origin.getId() + " to #" + destination.getId() + " ["
|
return "Shortest-path from #" + origin.getId() + " to #" + destination.getId()
|
||||||
+ this.arcInspector.toString().toLowerCase() + "]";
|
+ " [" + this.arcInspector.toString().toLowerCase() + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,16 +12,15 @@ public interface ShortestPathObserver {
|
|||||||
public void notifyOriginProcessed(Node node);
|
public void notifyOriginProcessed(Node node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify the observer that a node has been reached for the first
|
* Notify the observer that a node has been reached for the first time.
|
||||||
* time.
|
|
||||||
*
|
*
|
||||||
* @param node Node that has been reached.
|
* @param node Node that has been reached.
|
||||||
*/
|
*/
|
||||||
public void notifyNodeReached(Node node);
|
public void notifyNodeReached(Node node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify the observer that a node has been marked, i.e. its final
|
* Notify the observer that a node has been marked, i.e. its final value has been
|
||||||
* value has been set.
|
* set.
|
||||||
*
|
*
|
||||||
* @param node Node that has been marked.
|
* @param node Node that has been marked.
|
||||||
*/
|
*/
|
||||||
|
@ -11,8 +11,7 @@ public class ShortestPathSolution extends AbstractSolution {
|
|||||||
private final Path path;
|
private final Path path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new infeasible shortest-path solution for the given input and
|
* Create a new infeasible shortest-path solution for the given input and status.
|
||||||
* status.
|
|
||||||
*
|
*
|
||||||
* @param data Original input data for this solution.
|
* @param data Original input data for this solution.
|
||||||
* @param status Status of the solution (UNKNOWN / INFEASIBLE).
|
* @param status Status of the solution (UNKNOWN / INFEASIBLE).
|
||||||
@ -51,15 +50,17 @@ public class ShortestPathSolution extends AbstractSolution {
|
|||||||
String info = null;
|
String info = null;
|
||||||
if (!isFeasible()) {
|
if (!isFeasible()) {
|
||||||
info = String.format("No path found from node #%d to node #%d",
|
info = String.format("No path found from node #%d to node #%d",
|
||||||
getInputData().getOrigin().getId(), getInputData().getDestination().getId());
|
getInputData().getOrigin().getId(),
|
||||||
|
getInputData().getDestination().getId());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
double cost = 0;
|
double cost = 0;
|
||||||
for (Arc arc: getPath().getArcs()) {
|
for (Arc arc : getPath().getArcs()) {
|
||||||
cost += getInputData().getCost(arc);
|
cost += getInputData().getCost(arc);
|
||||||
}
|
}
|
||||||
info = String.format("Found a path from node #%d to node #%d",
|
info = String.format("Found a path from node #%d to node #%d",
|
||||||
getInputData().getOrigin().getId(), getInputData().getDestination().getId());
|
getInputData().getOrigin().getId(),
|
||||||
|
getInputData().getDestination().getId());
|
||||||
if (getInputData().getMode() == Mode.LENGTH) {
|
if (getInputData().getMode() == Mode.LENGTH) {
|
||||||
info = String.format("%s, %.4f kilometers", info, cost / 1000.0);
|
info = String.format("%s, %.4f kilometers", info, cost / 1000.0);
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,8 @@ package org.insa.graphs.algorithm.utils;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements a binary heap containing elements of type E.
|
* Implements a binary heap containing elements of type E. Note that all comparisons are
|
||||||
*
|
* based on the compareTo method, hence E must implement Comparable
|
||||||
* Note that all comparisons are based on the compareTo method, hence E must
|
|
||||||
* implement Comparable
|
|
||||||
*
|
*
|
||||||
* @author Mark Allen Weiss
|
* @author Mark Allen Weiss
|
||||||
* @author DLB
|
* @author DLB
|
||||||
@ -74,9 +72,8 @@ public class BinaryHeap<E extends Comparable<E>> implements PriorityQueue<E> {
|
|||||||
private void percolateUp(int index) {
|
private void percolateUp(int index) {
|
||||||
E x = this.array.get(index);
|
E x = this.array.get(index);
|
||||||
|
|
||||||
for (; index > 0
|
for (; index > 0 && x.compareTo(this.array.get(indexParent(index))) < 0; index =
|
||||||
&& x.compareTo(this.array.get(indexParent(index))) < 0; index = indexParent(
|
indexParent(index)) {
|
||||||
index)) {
|
|
||||||
E moving_val = this.array.get(indexParent(index));
|
E moving_val = this.array.get(indexParent(index));
|
||||||
this.arraySet(index, moving_val);
|
this.arraySet(index, moving_val);
|
||||||
}
|
}
|
||||||
@ -168,9 +165,8 @@ public class BinaryHeap<E extends Comparable<E>> implements PriorityQueue<E> {
|
|||||||
/**
|
/**
|
||||||
* Creates a multi-lines string representing a sorted view of this binary heap.
|
* 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
|
* @param maxElement Maximum number of elements to display. or {@code -1} to display
|
||||||
* display all the elements.
|
* all the elements.
|
||||||
*
|
|
||||||
* @return a string containing a sorted view this binary heap.
|
* @return a string containing a sorted view this binary heap.
|
||||||
*/
|
*/
|
||||||
public String toStringSorted(int maxElement) {
|
public String toStringSorted(int maxElement) {
|
||||||
@ -190,7 +186,6 @@ public class BinaryHeap<E extends Comparable<E>> implements PriorityQueue<E> {
|
|||||||
* Creates a multi-lines string representing a tree view of this binary heap.
|
* Creates a multi-lines string representing a tree view of this binary heap.
|
||||||
*
|
*
|
||||||
* @param maxDepth Maximum depth of the tree to display.
|
* @param maxDepth Maximum depth of the tree to display.
|
||||||
*
|
|
||||||
* @return a string containing a tree view of this binary heap.
|
* @return a string containing a tree view of this binary heap.
|
||||||
*/
|
*/
|
||||||
public String toStringTree(int maxDepth) {
|
public String toStringTree(int maxDepth) {
|
||||||
|
@ -7,7 +7,6 @@ public class BinaryHeapFormatter {
|
|||||||
/**
|
/**
|
||||||
* This class is used by {@link #toStringTree}, and simply contains three string
|
* This class is used by {@link #toStringTree}, and simply contains three string
|
||||||
* accumulating. This is an immutable class.
|
* accumulating. This is an immutable class.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private static class Context {
|
private static class Context {
|
||||||
|
|
||||||
@ -37,7 +36,6 @@ public class BinaryHeapFormatter {
|
|||||||
* Creates a new context by appending newlines to this context.
|
* Creates a new context by appending newlines to this context.
|
||||||
*
|
*
|
||||||
* @param n Number of newlines to append.
|
* @param n Number of newlines to append.
|
||||||
*
|
|
||||||
* @return a new context with {@code n} newlines appended.
|
* @return a new context with {@code n} newlines appended.
|
||||||
*/
|
*/
|
||||||
public Context appendNewlines(int n) {
|
public Context appendNewlines(int n) {
|
||||||
@ -45,8 +43,8 @@ public class BinaryHeapFormatter {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (new Context(this.acu + "\n" + this.margin, this.margin, this.lastmargin)
|
return (new Context(this.acu + "\n" + this.margin, this.margin,
|
||||||
.appendNewlines(n - 1));
|
this.lastmargin).appendNewlines(n - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,29 +54,29 @@ public class BinaryHeapFormatter {
|
|||||||
* @param count Number of spaces to add to the margin, or {@code null} to use
|
* @param count Number of spaces to add to the margin, or {@code null} to use
|
||||||
* the length of the string.
|
* the length of the string.
|
||||||
* @param text String to append.
|
* @param text String to append.
|
||||||
*
|
|
||||||
* @return a new context with {@code text} appended.
|
* @return a new context with {@code text} appended.
|
||||||
*/
|
*/
|
||||||
public Context appendText(Integer count, String text) {
|
public Context appendText(Integer count, String text) {
|
||||||
int cnt = (count == null) ? text.length() : count;
|
int cnt = (count == null) ? text.length() : count;
|
||||||
final String spaces = new String(new char[cnt]).replace('\0', ' ');
|
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.
|
* 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
|
* @param n Number of spaces to add to the margin, or {@code null} to use the
|
||||||
* the length of the string.
|
* length of the string.
|
||||||
* @param label Name of the branch.
|
* @param label Name of the branch.
|
||||||
*
|
|
||||||
* @return a new context with the branch appended.
|
* @return a new context with the branch appended.
|
||||||
*/
|
*/
|
||||||
public Context appendBranch(Integer count, String label) {
|
public Context appendBranch(Integer count, String label) {
|
||||||
final Context ctxt = this.appendText(count, label);
|
final Context ctxt = this.appendText(count, label);
|
||||||
|
|
||||||
if (count == null) {
|
if (count == null) {
|
||||||
return new Context(ctxt.acu + "_", ctxt.margin + "|", ctxt.margin + " ");
|
return new Context(ctxt.acu + "_", ctxt.margin + "|",
|
||||||
|
ctxt.margin + " ");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new Context(ctxt.acu, ctxt.margin + "|", ctxt.margin + " ")
|
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.
|
* Input : ready to write the current node at the current context position. Output :
|
||||||
* Output : the last character of acu is the last character of the current node.
|
* the last character of acu is the last character of the current node.
|
||||||
*/
|
*/
|
||||||
protected static <E extends Comparable<E>> Context toStringLoop(BinaryHeap<E> heap,
|
protected static <E extends Comparable<E>> Context toStringLoop(BinaryHeap<E> heap,
|
||||||
Context ctxt, int node, int max_depth) {
|
Context ctxt, int node, int max_depth) {
|
||||||
@ -122,13 +120,16 @@ public class BinaryHeapFormatter {
|
|||||||
int child = childs.get(ch);
|
int child = childs.get(ch);
|
||||||
|
|
||||||
if (is_last) {
|
if (is_last) {
|
||||||
Context ctxt3 = new Context(ctxt2.acu, ctxt2.lastmargin, ctxt2.lastmargin);
|
Context ctxt3 =
|
||||||
ctxt2 = new Context(toStringLoop(heap, ctxt3.appendText(null, "___"), child,
|
new Context(ctxt2.acu, ctxt2.lastmargin, ctxt2.lastmargin);
|
||||||
max_depth - 1).acu, ctxt2.margin, ctxt2.lastmargin);
|
ctxt2 = new Context(toStringLoop(heap,
|
||||||
|
ctxt3.appendText(null, "___"), child, max_depth - 1).acu,
|
||||||
|
ctxt2.margin, ctxt2.lastmargin);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ctxt2 = new Context(toStringLoop(heap, ctxt2.appendText(null, "___"), child,
|
ctxt2 = new Context(toStringLoop(heap,
|
||||||
max_depth - 1).acu, ctxt2.margin, ctxt2.lastmargin).appendNewlines(2);
|
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
|
* Creates a multi-lines string representing a tree view of the given binary heap.
|
||||||
* heap.
|
|
||||||
*
|
*
|
||||||
* @param heap The binary heap to display.
|
* @param heap The binary heap to display.
|
||||||
* @param maxDepth Maximum depth of the tree to display.
|
* @param maxDepth Maximum depth of the tree to display.
|
||||||
*
|
|
||||||
* @return a string containing a tree view of the given binary heap.
|
* @return a string containing a tree view of the given binary heap.
|
||||||
*/
|
*/
|
||||||
public static <E extends Comparable<E>> String toStringTree(BinaryHeap<E> heap, int maxDepth) {
|
public static <E extends Comparable<E>> String toStringTree(BinaryHeap<E> heap,
|
||||||
|
int maxDepth) {
|
||||||
final Context init_context = new Context(" ", " ", " ");
|
final Context init_context = new Context(" ", " ", " ");
|
||||||
final Context result = toStringLoop(heap, init_context, 0, maxDepth);
|
final Context result = toStringLoop(heap, init_context, 0, maxDepth);
|
||||||
return result.acu;
|
return result.acu;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a multi-lines string representing a sorted view of the given binary
|
* Creates a multi-lines string representing a sorted view of the given binary heap.
|
||||||
* heap.
|
|
||||||
*
|
*
|
||||||
* @param heap The binary heap to display.
|
* @param heap The binary heap to display.
|
||||||
* @param maxElement Maximum number of elements to display. or {@code -1} to
|
* @param maxElement Maximum number of elements to display. or {@code -1} to display
|
||||||
* display all the elements.
|
* all the elements.
|
||||||
*
|
|
||||||
* @return a string containing a sorted view the given binary heap.
|
* @return a string containing a sorted view the given binary heap.
|
||||||
*/
|
*/
|
||||||
public static <E extends Comparable<E>> String toStringSorted(BinaryHeap<E> heap,
|
public static <E extends Comparable<E>> String toStringSorted(BinaryHeap<E> heap,
|
||||||
@ -174,7 +172,8 @@ public class BinaryHeapFormatter {
|
|||||||
truncate = ", only " + max_elements + " elements are shown";
|
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) {
|
while (!copy.isEmpty() && max_elements-- != 0) {
|
||||||
result += copy.deleteMin() + "\n";
|
result += copy.deleteMin() + "\n";
|
||||||
|
@ -10,7 +10,6 @@ public class EmptyPriorityQueueException extends RuntimeException {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public EmptyPriorityQueueException() {
|
public EmptyPriorityQueueException() {}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
package org.insa.graphs.algorithm.utils;
|
package org.insa.graphs.algorithm.utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface representing a basic priority queue.
|
* Interface representing a basic priority queue. Implementation should enforce the
|
||||||
*
|
* required complexity of each method.
|
||||||
* Implementation should enforce the required complexity of each method.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface PriorityQueue<E extends Comparable<E>> {
|
public interface PriorityQueue<E extends Comparable<E>> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the priority queue is empty.
|
* Check if the priority queue is empty.
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Complexity:</b> <i>O(1)</i>
|
* <b>Complexity:</b> <i>O(1)</i>
|
||||||
* </p>
|
* </p>
|
||||||
@ -21,7 +18,6 @@ public interface PriorityQueue<E extends Comparable<E>> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of elements in this queue.
|
* Get the number of elements in this queue.
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Complexity:</b> <i>O(1)</i>
|
* <b>Complexity:</b> <i>O(1)</i>
|
||||||
* </p>
|
* </p>
|
||||||
@ -32,7 +28,6 @@ public interface PriorityQueue<E extends Comparable<E>> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert the given element into the queue.
|
* Insert the given element into the queue.
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Complexity:</b> <i>O(log n)</i>
|
* <b>Complexity:</b> <i>O(log n)</i>
|
||||||
* </p>
|
* </p>
|
||||||
@ -43,7 +38,6 @@ public interface PriorityQueue<E extends Comparable<E>> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the given element from the priority queue.
|
* Remove the given element from the priority queue.
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Complexity:</b> <i>O(log n)</i>
|
* <b>Complexity:</b> <i>O(log n)</i>
|
||||||
* </p>
|
* </p>
|
||||||
@ -54,26 +48,22 @@ public interface PriorityQueue<E extends Comparable<E>> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve (but not remove) the smallest item in the queue.
|
* Retrieve (but not remove) the smallest item in the queue.
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Complexity:</b> <i>O(1)</i>
|
* <b>Complexity:</b> <i>O(1)</i>
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @return The smallest item in the queue.
|
* @return The smallest item in the queue.
|
||||||
*
|
|
||||||
* @throws EmptyPriorityQueueException if this queue is empty.
|
* @throws EmptyPriorityQueueException if this queue is empty.
|
||||||
*/
|
*/
|
||||||
public E findMin() throws EmptyPriorityQueueException;
|
public E findMin() throws EmptyPriorityQueueException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove and return the smallest item from the priority queue.
|
* Remove and return the smallest item from the priority queue.
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Complexity:</b> <i>O(log n)</i>
|
* <b>Complexity:</b> <i>O(log n)</i>
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @return The smallest item in the queue.
|
* @return The smallest item in the queue.
|
||||||
*
|
|
||||||
* @throws EmptyPriorityQueueException if this queue is empty.
|
* @throws EmptyPriorityQueueException if this queue is empty.
|
||||||
*/
|
*/
|
||||||
public E deleteMin() throws EmptyPriorityQueueException;
|
public E deleteMin() throws EmptyPriorityQueueException;
|
||||||
|
@ -5,7 +5,8 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import org.insa.graphs.model.Node;
|
import org.insa.graphs.model.Node;
|
||||||
|
|
||||||
public class WeaklyConnectedComponentTextObserver implements WeaklyConnectedComponentObserver {
|
public class WeaklyConnectedComponentTextObserver
|
||||||
|
implements WeaklyConnectedComponentObserver {
|
||||||
|
|
||||||
// Number of the current component.
|
// Number of the current component.
|
||||||
private int numComponent = 1;
|
private int numComponent = 1;
|
||||||
@ -19,12 +20,12 @@ public class WeaklyConnectedComponentTextObserver implements WeaklyConnectedComp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyStartComponent(Node curNode) {
|
public void notifyStartComponent(Node curNode) {
|
||||||
stream.print("Entering component #" + numComponent + " from node #" + curNode.getId() + "... ");
|
stream.print("Entering component #" + numComponent + " from node #"
|
||||||
|
+ curNode.getId() + "... ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyNewNodeInComponent(Node node) {
|
public void notifyNewNodeInComponent(Node node) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyEndComponent(ArrayList<Node> nodes) {
|
public void notifyEndComponent(ArrayList<Node> nodes) {
|
||||||
|
@ -38,19 +38,18 @@ public class WeaklyConnectedComponentsAlgorithm
|
|||||||
* @param curNode Starting node for the component.
|
* @param curNode Starting node for the component.
|
||||||
*/
|
*/
|
||||||
protected void notifyStartComponent(Node curNode) {
|
protected void notifyStartComponent(Node curNode) {
|
||||||
for (WeaklyConnectedComponentObserver obs: getObservers()) {
|
for (WeaklyConnectedComponentObserver obs : getObservers()) {
|
||||||
obs.notifyStartComponent(curNode);
|
obs.notifyStartComponent(curNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify all observers that a new node has been found for the current
|
* Notify all observers that a new node has been found for the current component.
|
||||||
* component.
|
|
||||||
*
|
*
|
||||||
* @param node New node found for the current component.
|
* @param node New node found for the current component.
|
||||||
*/
|
*/
|
||||||
protected void notifyNewNodeInComponent(Node node) {
|
protected void notifyNewNodeInComponent(Node node) {
|
||||||
for (WeaklyConnectedComponentObserver obs: getObservers()) {
|
for (WeaklyConnectedComponentObserver obs : getObservers()) {
|
||||||
obs.notifyNewNodeInComponent(node);
|
obs.notifyNewNodeInComponent(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,7 +60,7 @@ public class WeaklyConnectedComponentsAlgorithm
|
|||||||
* @param nodes List of nodes in the component.
|
* @param nodes List of nodes in the component.
|
||||||
*/
|
*/
|
||||||
protected void notifyEndComponent(ArrayList<Node> nodes) {
|
protected void notifyEndComponent(ArrayList<Node> nodes) {
|
||||||
for (WeaklyConnectedComponentObserver obs: getObservers()) {
|
for (WeaklyConnectedComponentObserver obs : getObservers()) {
|
||||||
obs.notifyEndComponent(nodes);
|
obs.notifyEndComponent(nodes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,8 +76,8 @@ public class WeaklyConnectedComponentsAlgorithm
|
|||||||
res.add(new HashSet<Integer>());
|
res.add(new HashSet<Integer>());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Node node: getInputData().getGraph().getNodes()) {
|
for (Node node : getInputData().getGraph().getNodes()) {
|
||||||
for (Arc arc: node.getSuccessors()) {
|
for (Arc arc : node.getSuccessors()) {
|
||||||
res.get(node.getId()).add(arc.getDestination().getId());
|
res.get(node.getId()).add(arc.getDestination().getId());
|
||||||
if (arc.getRoadInformation().isOneWay()) {
|
if (arc.getRoadInformation().isOneWay()) {
|
||||||
res.get(arc.getDestination().getId()).add(node.getId());
|
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
|
* Apply a breadth first search algorithm on the given undirected graph (adjacency
|
||||||
* (adjacency list), starting at node cur, and marking nodes in marked.
|
* list), starting at node cur, and marking nodes in marked.
|
||||||
*
|
*
|
||||||
* @param marked
|
* @param marked
|
||||||
* @param cur
|
* @param cur
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected ArrayList<Node> bfs(ArrayList<HashSet<Integer>> ugraph, boolean[] marked, int cur) {
|
protected ArrayList<Node> bfs(ArrayList<HashSet<Integer>> ugraph, boolean[] marked,
|
||||||
|
int cur) {
|
||||||
Graph graph = getInputData().getGraph();
|
Graph graph = getInputData().getGraph();
|
||||||
ArrayList<Node> component = new ArrayList<Node>();
|
ArrayList<Node> component = new ArrayList<Node>();
|
||||||
|
|
||||||
@ -118,7 +117,7 @@ public class WeaklyConnectedComponentsAlgorithm
|
|||||||
// Notify observers
|
// Notify observers
|
||||||
notifyNewNodeInComponent(node);
|
notifyNewNodeInComponent(node);
|
||||||
|
|
||||||
for (Integer destId: ugraph.get(node.getId())) {
|
for (Integer destId : ugraph.get(node.getId())) {
|
||||||
Node dest = graph.get(destId);
|
Node dest = graph.get(destId);
|
||||||
if (!marked[dest.getId()]) {
|
if (!marked[dest.getId()]) {
|
||||||
queue.add(destId);
|
queue.add(destId);
|
||||||
@ -149,11 +148,11 @@ public class WeaklyConnectedComponentsAlgorithm
|
|||||||
components.add(this.bfs(ugraph, marked, cur));
|
components.add(this.bfs(ugraph, marked, cur));
|
||||||
|
|
||||||
// Find next non-marked
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ public class WeaklyConnectedComponentsSolution extends AbstractSolution {
|
|||||||
super(data);
|
super(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WeaklyConnectedComponentsSolution(WeaklyConnectedComponentsData data, Status status,
|
protected WeaklyConnectedComponentsSolution(WeaklyConnectedComponentsData data,
|
||||||
ArrayList<ArrayList<Node>> components) {
|
Status status, ArrayList<ArrayList<Node>> components) {
|
||||||
super(data, status);
|
super(data, status);
|
||||||
this.components = components;
|
this.components = components;
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ public class WeaklyConnectedComponentsSolution extends AbstractSolution {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
int nIsolated = 0;
|
int nIsolated = 0;
|
||||||
int nGt10 = 0;
|
int nGt10 = 0;
|
||||||
for (ArrayList<Node> component: components) {
|
for (ArrayList<Node> component : components) {
|
||||||
if (component.size() == 1) {
|
if (component.size() == 1) {
|
||||||
nIsolated += 1;
|
nIsolated += 1;
|
||||||
}
|
}
|
||||||
@ -49,8 +49,9 @@ public class WeaklyConnectedComponentsSolution extends AbstractSolution {
|
|||||||
nGt10 += 1;
|
nGt10 += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "Found " + components.size() + " components (" + nGt10 + " with more than 10 nodes, "
|
return "Found " + components.size() + " components (" + nGt10
|
||||||
+ nIsolated + " isolated nodes) in " + getSolvingTime().getSeconds() + " seconds.";
|
+ " with more than 10 nodes, " + nIsolated + " isolated nodes) in "
|
||||||
|
+ getSolvingTime().getSeconds() + " seconds.";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ public class BinaryHeapTest extends PriorityQueueTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PriorityQueue<MutableInteger> createQueue(PriorityQueue<MutableInteger> queue) {
|
public PriorityQueue<MutableInteger> createQueue(
|
||||||
|
PriorityQueue<MutableInteger> queue) {
|
||||||
return new BinaryHeap<>((BinaryHeap<MutableInteger>) queue);
|
return new BinaryHeap<>((BinaryHeap<MutableInteger>) queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ public class BinarySearchTreeTest extends PriorityQueueTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PriorityQueue<MutableInteger> createQueue(PriorityQueue<MutableInteger> queue) {
|
public PriorityQueue<MutableInteger> createQueue(
|
||||||
|
PriorityQueue<MutableInteger> queue) {
|
||||||
return new BinarySearchTree<>((BinarySearchTree<MutableInteger>) queue);
|
return new BinarySearchTree<>((BinarySearchTree<MutableInteger>) queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,10 +35,10 @@ public abstract class PriorityQueueTest {
|
|||||||
* implementation.
|
* implementation.
|
||||||
*
|
*
|
||||||
* @param queue Queue to copy.
|
* @param queue Queue to copy.
|
||||||
*
|
|
||||||
* @return Copy of the given queue.
|
* @return Copy of the given queue.
|
||||||
*/
|
*/
|
||||||
public abstract PriorityQueue<MutableInteger> createQueue(PriorityQueue<MutableInteger> queue);
|
public abstract PriorityQueue<MutableInteger> createQueue(
|
||||||
|
PriorityQueue<MutableInteger> queue);
|
||||||
|
|
||||||
protected static class MutableInteger implements Comparable<MutableInteger> {
|
protected static class MutableInteger implements Comparable<MutableInteger> {
|
||||||
|
|
||||||
@ -92,7 +92,6 @@ public abstract class PriorityQueueTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set of parameters.
|
* Set of parameters.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Parameters
|
@Parameters
|
||||||
public static Collection<Object> data() {
|
public static Collection<Object> data() {
|
||||||
@ -102,27 +101,28 @@ public abstract class PriorityQueueTest {
|
|||||||
objects.add(new TestParameters<>(new MutableInteger[0], new int[0]));
|
objects.add(new TestParameters<>(new MutableInteger[0], new int[0]));
|
||||||
|
|
||||||
// Queue with 50 elements from 0 to 49, inserted in order and deleted in order.
|
// Queue with 50 elements from 0 to 49, inserted in order and deleted in order.
|
||||||
objects.add(new TestParameters<>(
|
objects.add(
|
||||||
IntStream.range(0, 50).mapToObj(MutableInteger::new).toArray(MutableInteger[]::new),
|
new TestParameters<>(
|
||||||
|
IntStream.range(0, 50).mapToObj(MutableInteger::new)
|
||||||
|
.toArray(MutableInteger[]::new),
|
||||||
IntStream.range(0, 50).toArray()));
|
IntStream.range(0, 50).toArray()));
|
||||||
|
|
||||||
// Queue with 20 elements from 0 to 19, inserted in order, deleted in the given
|
// Queue with 20 elements from 0 to 19, inserted in order, deleted in the given
|
||||||
// order.
|
// order.
|
||||||
objects.add(new TestParameters<>(
|
objects.add(new TestParameters<>(
|
||||||
IntStream.range(0, 20).mapToObj(MutableInteger::new).toArray(MutableInteger[]::new),
|
IntStream.range(0, 20).mapToObj(MutableInteger::new)
|
||||||
new int[] { 12, 17, 18, 19, 4, 5, 3, 2, 0, 9, 10, 16, 8, 14, 13, 15, 7, 6, 1,
|
.toArray(MutableInteger[]::new),
|
||||||
11 }));
|
new int[] { 12, 17, 18, 19, 4, 5, 3, 2, 0, 9, 10, 16, 8, 14, 13, 15, 7,
|
||||||
|
6, 1, 11 }));
|
||||||
|
|
||||||
// Queue with 7 elements.
|
// Queue with 7 elements.
|
||||||
objects.add(
|
objects.add(new TestParameters<>(
|
||||||
new TestParameters<>(
|
|
||||||
Arrays.stream(new int[] { 8, 1, 6, 3, 4, 5, 9 })
|
Arrays.stream(new int[] { 8, 1, 6, 3, 4, 5, 9 })
|
||||||
.mapToObj(MutableInteger::new).toArray(MutableInteger[]::new),
|
.mapToObj(MutableInteger::new).toArray(MutableInteger[]::new),
|
||||||
new int[] { 6, 5, 0, 1, 4, 2, 3 }));
|
new int[] { 6, 5, 0, 1, 4, 2, 3 }));
|
||||||
|
|
||||||
// Queue with 7 elements.
|
// Queue with 7 elements.
|
||||||
objects.add(
|
objects.add(new TestParameters<>(
|
||||||
new TestParameters<>(
|
|
||||||
Arrays.stream(new int[] { 1, 7, 4, 8, 9, 6, 5 })
|
Arrays.stream(new int[] { 1, 7, 4, 8, 9, 6, 5 })
|
||||||
.mapToObj(MutableInteger::new).toArray(MutableInteger[]::new),
|
.mapToObj(MutableInteger::new).toArray(MutableInteger[]::new),
|
||||||
new int[] { 2, 0, 1, 3, 4, 5, 6 }));
|
new int[] { 2, 0, 1, 3, 4, 5, 6 }));
|
||||||
@ -147,7 +147,7 @@ public abstract class PriorityQueueTest {
|
|||||||
// Create the range queue
|
// Create the range queue
|
||||||
this.queue = createQueue();
|
this.queue = createQueue();
|
||||||
|
|
||||||
for (MutableInteger v: parameters.data) {
|
for (MutableInteger v : parameters.data) {
|
||||||
this.queue.insert(v);
|
this.queue.insert(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ public abstract class PriorityQueueTest {
|
|||||||
public void testInsert() {
|
public void testInsert() {
|
||||||
PriorityQueue<MutableInteger> queue = createQueue();
|
PriorityQueue<MutableInteger> queue = createQueue();
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (MutableInteger x: parameters.data) {
|
for (MutableInteger x : parameters.data) {
|
||||||
queue.insert(x);
|
queue.insert(x);
|
||||||
assertEquals(++size, queue.size());
|
assertEquals(++size, queue.size());
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ public abstract class PriorityQueueTest {
|
|||||||
MutableInteger[] range = Arrays.copyOf(parameters.data, parameters.data.length);
|
MutableInteger[] range = Arrays.copyOf(parameters.data, parameters.data.length);
|
||||||
Arrays.sort(range);
|
Arrays.sort(range);
|
||||||
|
|
||||||
for (MutableInteger mi: range) {
|
for (MutableInteger mi : range) {
|
||||||
assertEquals(mi.get(), queue.deleteMin().value);
|
assertEquals(mi.get(), queue.deleteMin().value);
|
||||||
assertEquals(--size, queue.size());
|
assertEquals(--size, queue.size());
|
||||||
}
|
}
|
||||||
@ -189,7 +189,8 @@ public abstract class PriorityQueueTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testFindMin() {
|
public void testFindMin() {
|
||||||
Assume.assumeFalse(queue.isEmpty());
|
Assume.assumeFalse(queue.isEmpty());
|
||||||
assertEquals(Collections.min(Arrays.asList(parameters.data)).get(), queue.findMin().get());
|
assertEquals(Collections.min(Arrays.asList(parameters.data)).get(),
|
||||||
|
queue.findMin().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = EmptyPriorityQueueException.class)
|
@Test(expected = EmptyPriorityQueueException.class)
|
||||||
@ -204,7 +205,7 @@ public abstract class PriorityQueueTest {
|
|||||||
assertEquals(size, queue.size());
|
assertEquals(size, queue.size());
|
||||||
MutableInteger[] range = Arrays.copyOf(parameters.data, parameters.data.length);
|
MutableInteger[] range = Arrays.copyOf(parameters.data, parameters.data.length);
|
||||||
Arrays.sort(range);
|
Arrays.sort(range);
|
||||||
for (MutableInteger x: range) {
|
for (MutableInteger x : range) {
|
||||||
assertEquals(x, queue.deleteMin());
|
assertEquals(x, queue.deleteMin());
|
||||||
size -= 1;
|
size -= 1;
|
||||||
assertEquals(size, queue.size());
|
assertEquals(size, queue.size());
|
||||||
@ -259,7 +260,7 @@ public abstract class PriorityQueueTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testRemoveTwice() {
|
public void testRemoveTwice() {
|
||||||
Assume.assumeFalse(queue.isEmpty());
|
Assume.assumeFalse(queue.isEmpty());
|
||||||
for (MutableInteger data: parameters.data) {
|
for (MutableInteger data : parameters.data) {
|
||||||
PriorityQueue<MutableInteger> copyQueue = this.createQueue(this.queue);
|
PriorityQueue<MutableInteger> copyQueue = this.createQueue(this.queue);
|
||||||
copyQueue.remove(data);
|
copyQueue.remove(data);
|
||||||
try {
|
try {
|
||||||
@ -307,7 +308,7 @@ public abstract class PriorityQueueTest {
|
|||||||
public void testRemoveThenAdd() {
|
public void testRemoveThenAdd() {
|
||||||
Assume.assumeFalse(queue.isEmpty());
|
Assume.assumeFalse(queue.isEmpty());
|
||||||
int min = Collections.min(Arrays.asList(parameters.data)).get();
|
int min = Collections.min(Arrays.asList(parameters.data)).get();
|
||||||
for (MutableInteger mi: parameters.data) {
|
for (MutableInteger mi : parameters.data) {
|
||||||
queue.remove(mi);
|
queue.remove(mi);
|
||||||
assertEquals(parameters.data.length - 1, queue.size());
|
assertEquals(parameters.data.length - 1, queue.size());
|
||||||
mi.set(--min);
|
mi.set(--min);
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<project
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.insa.graphs</groupId>
|
<groupId>org.insa.graphs</groupId>
|
||||||
|
@ -57,8 +57,8 @@ public class AlgorithmPanel extends JPanel implements DrawingChangeListener {
|
|||||||
private final boolean graphicVisualization;
|
private final boolean graphicVisualization;
|
||||||
private final boolean textualVisualization;
|
private final boolean textualVisualization;
|
||||||
|
|
||||||
public StartActionEvent(Class<? extends AbstractAlgorithm<?>> algoClass, List<Node> nodes,
|
public StartActionEvent(Class<? extends AbstractAlgorithm<?>> algoClass,
|
||||||
ArcInspector arcFilter, boolean graphicVisualization,
|
List<Node> nodes, ArcInspector arcFilter, boolean graphicVisualization,
|
||||||
boolean textualVisualization) {
|
boolean textualVisualization) {
|
||||||
super(AlgorithmPanel.this, START_EVENT_ID, START_EVENT_COMMAND);
|
super(AlgorithmPanel.this, START_EVENT_ID, START_EVENT_COMMAND);
|
||||||
this.nodes = nodes;
|
this.nodes = nodes;
|
||||||
@ -125,18 +125,17 @@ public class AlgorithmPanel extends JPanel implements DrawingChangeListener {
|
|||||||
/**
|
/**
|
||||||
* Create a new AlgorithmPanel with the given parameters.
|
* Create a new AlgorithmPanel with the given parameters.
|
||||||
*
|
*
|
||||||
* @param parent Parent component for this panel. Only use for centering
|
* @param parent Parent component for this panel. Only use for centering dialogs.
|
||||||
* dialogs.
|
|
||||||
* @param baseAlgorithm Base algorithm for this algorithm panel.
|
* @param baseAlgorithm Base algorithm for this algorithm panel.
|
||||||
* @param title Title of the panel.
|
* @param title Title of the panel.
|
||||||
* @param nodeNames Names of the input nodes.
|
* @param nodeNames Names of the input nodes.
|
||||||
* @param enableArcFilterSelection <code>true</code> to enable
|
* @param enableArcFilterSelection <code>true</code> to enable {@link ArcInspector}
|
||||||
* {@link ArcInspector} selection.
|
* selection.
|
||||||
*
|
|
||||||
* @see ArcInspectorFactory
|
* @see ArcInspectorFactory
|
||||||
*/
|
*/
|
||||||
public AlgorithmPanel(Component parent, Class<? extends AbstractAlgorithm<?>> baseAlgorithm,
|
public AlgorithmPanel(Component parent,
|
||||||
String title, String[] nodeNames, boolean enableArcFilterSelection) {
|
Class<? extends AbstractAlgorithm<?>> baseAlgorithm, String title,
|
||||||
|
String[] nodeNames, boolean enableArcFilterSelection) {
|
||||||
super();
|
super();
|
||||||
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
|
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
|
||||||
|
|
||||||
@ -217,7 +216,7 @@ public class AlgorithmPanel extends JPanel implements DrawingChangeListener {
|
|||||||
startAlgoButton.addActionListener(new ActionListener() {
|
startAlgoButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
for (ActionListener lis: startActionListeners) {
|
for (ActionListener lis : startActionListeners) {
|
||||||
lis.actionPerformed(new StartActionEvent(
|
lis.actionPerformed(new StartActionEvent(
|
||||||
AlgorithmFactory.getAlgorithmClass(baseAlgorithm,
|
AlgorithmFactory.getAlgorithmClass(baseAlgorithm,
|
||||||
(String) algoSelect.getSelectedItem()),
|
(String) algoSelect.getSelectedItem()),
|
||||||
@ -280,7 +279,6 @@ public class AlgorithmPanel extends JPanel implements DrawingChangeListener {
|
|||||||
* Create the title JLabel for this panel.
|
* Create the title JLabel for this panel.
|
||||||
*
|
*
|
||||||
* @param title Title for the label.
|
* @param title Title for the label.
|
||||||
*
|
|
||||||
* @return A new JLabel containing the given title with proper font.
|
* @return A new JLabel containing the given title with proper font.
|
||||||
*/
|
*/
|
||||||
protected JLabel createTitleLabel(String title) {
|
protected JLabel createTitleLabel(String title) {
|
||||||
@ -297,17 +295,14 @@ public class AlgorithmPanel extends JPanel implements DrawingChangeListener {
|
|||||||
/**
|
/**
|
||||||
* Create the combo box for the algorithm selection.
|
* Create the combo box for the algorithm selection.
|
||||||
*
|
*
|
||||||
* @param baseAlgorithm Base algorithm for which the select box should be
|
* @param baseAlgorithm Base algorithm for which the select box should be created.
|
||||||
* created.
|
|
||||||
*
|
|
||||||
* @return A new JComboBox containing algorithms for the given base algorithm.
|
* @return A new JComboBox containing algorithms for the given base algorithm.
|
||||||
*
|
|
||||||
* @see AlgorithmFactory
|
* @see AlgorithmFactory
|
||||||
*/
|
*/
|
||||||
protected JComboBox<String> createAlgoritmSelectComboBox(
|
protected JComboBox<String> createAlgoritmSelectComboBox(
|
||||||
Class<? extends AbstractAlgorithm<?>> baseAlgorithm) {
|
Class<? extends AbstractAlgorithm<?>> baseAlgorithm) {
|
||||||
JComboBox<String> algoSelect = new JComboBox<>(
|
JComboBox<String> algoSelect = new JComboBox<>(AlgorithmFactory
|
||||||
AlgorithmFactory.getAlgorithmNames(baseAlgorithm).toArray(new String[0]));
|
.getAlgorithmNames(baseAlgorithm).toArray(new String[0]));
|
||||||
algoSelect.setBackground(Color.WHITE);
|
algoSelect.setBackground(Color.WHITE);
|
||||||
algoSelect.setAlignmentX(Component.LEFT_ALIGNMENT);
|
algoSelect.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||||
return algoSelect;
|
return algoSelect;
|
||||||
@ -318,7 +313,6 @@ public class AlgorithmPanel extends JPanel implements DrawingChangeListener {
|
|||||||
* Create a node input panel with the given node input names.
|
* Create a node input panel with the given node input names.
|
||||||
*
|
*
|
||||||
* @param nodeNames Field names for the inputs to create.
|
* @param nodeNames Field names for the inputs to create.
|
||||||
*
|
|
||||||
* @return A new NodesInputPanel containing inputs for the given names.
|
* @return A new NodesInputPanel containing inputs for the given names.
|
||||||
*/
|
*/
|
||||||
protected NodesInputPanel createNodesInputPanel(String[] nodeNames) {
|
protected NodesInputPanel createNodesInputPanel(String[] nodeNames) {
|
||||||
@ -332,17 +326,15 @@ public class AlgorithmPanel extends JPanel implements DrawingChangeListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the given list of nodes does not contain any <code>null</code>
|
* Check if the given list of nodes does not contain any <code>null</code> value.
|
||||||
* value.
|
|
||||||
*
|
*
|
||||||
* @param nodes List of {@link Node} to check.
|
* @param nodes List of {@link Node} to check.
|
||||||
*
|
|
||||||
* @return <code>true</code> if the list does not contain any <code>null</code>
|
* @return <code>true</code> if the list does not contain any <code>null</code>
|
||||||
* value, <code>false</code> otherwise.
|
* value, <code>false</code> otherwise.
|
||||||
*/
|
*/
|
||||||
protected boolean allNotNull(List<Node> nodes) {
|
protected boolean allNotNull(List<Node> nodes) {
|
||||||
boolean allNotNull = true;
|
boolean allNotNull = true;
|
||||||
for (Node node: nodes) {
|
for (Node node : nodes) {
|
||||||
allNotNull = allNotNull && node != null;
|
allNotNull = allNotNull && node != null;
|
||||||
}
|
}
|
||||||
return allNotNull;
|
return allNotNull;
|
||||||
@ -353,7 +345,7 @@ public class AlgorithmPanel extends JPanel implements DrawingChangeListener {
|
|||||||
super.setEnabled(enabled);
|
super.setEnabled(enabled);
|
||||||
nodesInputPanel.setEnabled(enabled);
|
nodesInputPanel.setEnabled(enabled);
|
||||||
solutionPanel.setEnabled(enabled);
|
solutionPanel.setEnabled(enabled);
|
||||||
for (JComponent component: components) {
|
for (JComponent component : components) {
|
||||||
component.setEnabled(enabled);
|
component.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
graphicObserverCheckbox.setEnabled(enabled);
|
graphicObserverCheckbox.setEnabled(enabled);
|
||||||
@ -371,11 +363,9 @@ public class AlgorithmPanel extends JPanel implements DrawingChangeListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDrawingLoaded(Drawing oldDrawing, Drawing newDrawing) {
|
public void onDrawingLoaded(Drawing oldDrawing, Drawing newDrawing) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRedrawRequest() {
|
public void onRedrawRequest() {}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,17 +7,15 @@ public interface DrawingChangeListener {
|
|||||||
/**
|
/**
|
||||||
* Event fired when a new drawing is loaded.
|
* Event fired when a new drawing is loaded.
|
||||||
*
|
*
|
||||||
* @param oldDrawing Old drawing, may be null if no drawing exits prior to this
|
* @param oldDrawing Old drawing, may be null if no drawing exits prior to this one.
|
||||||
* one.
|
|
||||||
* @param newDrawing New drawing.
|
* @param newDrawing New drawing.
|
||||||
*/
|
*/
|
||||||
public void onDrawingLoaded(Drawing oldDrawing, Drawing newDrawing);
|
public void onDrawingLoaded(Drawing oldDrawing, Drawing newDrawing);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event fired when a redraw request is emitted - This is typically emitted
|
* Event fired when a redraw request is emitted - This is typically emitted after a
|
||||||
* after a onDrawingLoaded event, but not always, and request that elements are
|
* onDrawingLoaded event, but not always, and request that elements are drawn again
|
||||||
* drawn again on the new drawing.
|
* on the new drawing.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void onRedrawRequest();
|
public void onRedrawRequest();
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import org.insa.graphs.model.io.GraphReaderObserver;
|
|||||||
* JProgressBar.
|
* JProgressBar.
|
||||||
*
|
*
|
||||||
* @author Mikael
|
* @author Mikael
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class GraphReaderProgressBar extends JDialog implements GraphReaderObserver {
|
public class GraphReaderProgressBar extends JDialog implements GraphReaderObserver {
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ public class GraphReaderProgressBar extends JDialog implements GraphReaderObserv
|
|||||||
private final JProgressBar[] progressBars = new JProgressBar[3];
|
private final JProgressBar[] progressBars = new JProgressBar[3];
|
||||||
|
|
||||||
// Current element read, and modulo.
|
// Current element read, and modulo.
|
||||||
private int[] counters = new int[]{ 0, 0, 0 };
|
private int[] counters = new int[] { 0, 0, 0 };
|
||||||
private int[] modulos = new int[3];
|
private int[] modulos = new int[3];
|
||||||
|
|
||||||
public GraphReaderProgressBar(JFrame owner) {
|
public GraphReaderProgressBar(JFrame owner) {
|
||||||
|
@ -162,7 +162,8 @@ public class MainWindow extends JFrame {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
StartActionEvent evt = (StartActionEvent) e;
|
StartActionEvent evt = (StartActionEvent) e;
|
||||||
WeaklyConnectedComponentsData data = new WeaklyConnectedComponentsData(graph);
|
WeaklyConnectedComponentsData data =
|
||||||
|
new WeaklyConnectedComponentsData(graph);
|
||||||
|
|
||||||
WeaklyConnectedComponentsAlgorithm wccAlgorithm = null;
|
WeaklyConnectedComponentsAlgorithm wccAlgorithm = null;
|
||||||
try {
|
try {
|
||||||
@ -181,10 +182,12 @@ public class MainWindow extends JFrame {
|
|||||||
wccPanel.setEnabled(false);
|
wccPanel.setEnabled(false);
|
||||||
|
|
||||||
if (evt.isGraphicVisualizationEnabled()) {
|
if (evt.isGraphicVisualizationEnabled()) {
|
||||||
wccAlgorithm.addObserver(new WeaklyConnectedComponentGraphicObserver(drawing));
|
wccAlgorithm.addObserver(
|
||||||
|
new WeaklyConnectedComponentGraphicObserver(drawing));
|
||||||
}
|
}
|
||||||
if (evt.isTextualVisualizationEnabled()) {
|
if (evt.isTextualVisualizationEnabled()) {
|
||||||
wccAlgorithm.addObserver(new WeaklyConnectedComponentTextObserver(printStream));
|
wccAlgorithm.addObserver(
|
||||||
|
new WeaklyConnectedComponentTextObserver(printStream));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We love Java...
|
// We love Java...
|
||||||
@ -207,7 +210,8 @@ public class MainWindow extends JFrame {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
StartActionEvent evt = (StartActionEvent) e;
|
StartActionEvent evt = (StartActionEvent) e;
|
||||||
ShortestPathData data = new ShortestPathData(graph, evt.getNodes().get(0),
|
ShortestPathData data =
|
||||||
|
new ShortestPathData(graph, evt.getNodes().get(0),
|
||||||
evt.getNodes().get(1), evt.getArcFilter());
|
evt.getNodes().get(1), evt.getArcFilter());
|
||||||
|
|
||||||
ShortestPathAlgorithm spAlgorithm = null;
|
ShortestPathAlgorithm spAlgorithm = null;
|
||||||
@ -254,12 +258,15 @@ public class MainWindow extends JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cpPanel = new AlgorithmPanel(this, CarPoolingAlgorithm.class, "Car-Pooling", new String[] {
|
cpPanel = new AlgorithmPanel(this, CarPoolingAlgorithm.class, "Car-Pooling",
|
||||||
"Origin Car", "Origin Pedestrian", "Destination Car", "Destination Pedestrian" },
|
new String[] { "Origin Car", "Origin Pedestrian", "Destination Car",
|
||||||
|
"Destination Pedestrian" },
|
||||||
true);
|
true);
|
||||||
|
|
||||||
psPanel = new AlgorithmPanel(this, PackageSwitchAlgorithm.class, "Car-Pooling",
|
psPanel = new AlgorithmPanel(
|
||||||
new String[] { "Oribin A", "Origin B", "Destination A", "Destination B" }, true);
|
this, PackageSwitchAlgorithm.class, "Car-Pooling", new String[] {
|
||||||
|
"Oribin A", "Origin B", "Destination A", "Destination B" },
|
||||||
|
true);
|
||||||
|
|
||||||
// add algorithm panels
|
// add algorithm panels
|
||||||
algoPanels.add(wccPanel);
|
algoPanels.add(wccPanel);
|
||||||
@ -271,7 +278,7 @@ public class MainWindow extends JFrame {
|
|||||||
|
|
||||||
// Add click listeners to both drawing.
|
// Add click listeners to both drawing.
|
||||||
|
|
||||||
for (AlgorithmPanel panel: algoPanels) {
|
for (AlgorithmPanel panel : algoPanels) {
|
||||||
this.basicDrawing.addDrawingClickListener(panel.nodesInputPanel);
|
this.basicDrawing.addDrawingClickListener(panel.nodesInputPanel);
|
||||||
this.mapViewDrawing.addDrawingClickListener(panel.nodesInputPanel);
|
this.mapViewDrawing.addDrawingClickListener(panel.nodesInputPanel);
|
||||||
this.graphChangeListeneres.add(panel.nodesInputPanel);
|
this.graphChangeListeneres.add(panel.nodesInputPanel);
|
||||||
@ -294,10 +301,12 @@ public class MainWindow extends JFrame {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
JFileChooser chooser = FileUtils.createFileChooser(FolderType.Map);
|
JFileChooser chooser = FileUtils.createFileChooser(FolderType.Map);
|
||||||
if (chooser.showOpenDialog(MainWindow.this) == JFileChooser.APPROVE_OPTION) {
|
if (chooser.showOpenDialog(
|
||||||
|
MainWindow.this) == JFileChooser.APPROVE_OPTION) {
|
||||||
graphFilePath = chooser.getSelectedFile().getAbsolutePath();
|
graphFilePath = chooser.getSelectedFile().getAbsolutePath();
|
||||||
|
|
||||||
// Note: Don't use a try-resources block since loadGraph is asynchronous.
|
// Note: Don't use a try-resources block since loadGraph is
|
||||||
|
// asynchronous.
|
||||||
final DataInputStream stream;
|
final DataInputStream stream;
|
||||||
try {
|
try {
|
||||||
stream = new DataInputStream(new BufferedInputStream(
|
stream = new DataInputStream(new BufferedInputStream(
|
||||||
@ -329,8 +338,8 @@ public class MainWindow extends JFrame {
|
|||||||
addWindowListener(new WindowAdapter() {
|
addWindowListener(new WindowAdapter() {
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
int confirmed = JOptionPane.showConfirmDialog(MainWindow.this,
|
int confirmed = JOptionPane.showConfirmDialog(MainWindow.this,
|
||||||
"Are you sure you want to close the application?", "Exit Confirmation",
|
"Are you sure you want to close the application?",
|
||||||
JOptionPane.YES_NO_OPTION);
|
"Exit Confirmation", JOptionPane.YES_NO_OPTION);
|
||||||
|
|
||||||
if (confirmed == JOptionPane.YES_OPTION) {
|
if (confirmed == JOptionPane.YES_OPTION) {
|
||||||
dispose();
|
dispose();
|
||||||
@ -360,7 +369,7 @@ public class MainWindow extends JFrame {
|
|||||||
rightComponent.add(pathPanel, c);
|
rightComponent.add(pathPanel, c);
|
||||||
|
|
||||||
c.gridy = 1;
|
c.gridy = 1;
|
||||||
for (AlgorithmPanel panel: algoPanels) {
|
for (AlgorithmPanel panel : algoPanels) {
|
||||||
panel.setVisible(false);
|
panel.setVisible(false);
|
||||||
rightComponent.add(panel, c);
|
rightComponent.add(panel, c);
|
||||||
}
|
}
|
||||||
@ -428,7 +437,7 @@ public class MainWindow extends JFrame {
|
|||||||
* Notify all listeners that a new graph has been loaded.
|
* Notify all listeners that a new graph has been loaded.
|
||||||
*/
|
*/
|
||||||
private void notifyNewGraphLoaded() {
|
private void notifyNewGraphLoaded() {
|
||||||
for (GraphChangeListener listener: graphChangeListeneres) {
|
for (GraphChangeListener listener : graphChangeListeneres) {
|
||||||
listener.newGraphLoaded(graph);
|
listener.newGraphLoaded(graph);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -440,7 +449,7 @@ public class MainWindow extends JFrame {
|
|||||||
* @param newDrawing
|
* @param newDrawing
|
||||||
*/
|
*/
|
||||||
private void notifyDrawingLoaded(Drawing oldDrawing, Drawing newDrawing) {
|
private void notifyDrawingLoaded(Drawing oldDrawing, Drawing newDrawing) {
|
||||||
for (DrawingChangeListener listener: drawingChangeListeners) {
|
for (DrawingChangeListener listener : drawingChangeListeners) {
|
||||||
listener.onDrawingLoaded(oldDrawing, newDrawing);
|
listener.onDrawingLoaded(oldDrawing, newDrawing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -449,7 +458,7 @@ public class MainWindow extends JFrame {
|
|||||||
* Notify all listeners that a redraw request is emitted.
|
* Notify all listeners that a redraw request is emitted.
|
||||||
*/
|
*/
|
||||||
private void notifyRedrawRequest() {
|
private void notifyRedrawRequest() {
|
||||||
for (DrawingChangeListener listener: drawingChangeListeners) {
|
for (DrawingChangeListener listener : drawingChangeListeners) {
|
||||||
listener.onRedrawRequest();
|
listener.onRedrawRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -478,7 +487,8 @@ public class MainWindow extends JFrame {
|
|||||||
// We need to draw MapView, we have to check if the file exists.
|
// We need to draw MapView, we have to check if the file exists.
|
||||||
File mfile = null;
|
File mfile = null;
|
||||||
if (isMapView) {
|
if (isMapView) {
|
||||||
String mfpath = graphFilePath.substring(0, graphFilePath.lastIndexOf(".map"))
|
String mfpath =
|
||||||
|
graphFilePath.substring(0, graphFilePath.lastIndexOf(".map"))
|
||||||
+ ".mapfg";
|
+ ".mapfg";
|
||||||
mfile = new File(mfpath);
|
mfile = new File(mfpath);
|
||||||
if (!mfile.exists()) {
|
if (!mfile.exists()) {
|
||||||
@ -576,7 +586,8 @@ public class MainWindow extends JFrame {
|
|||||||
launchThread(new Runnable() {
|
launchThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
GraphReaderProgressBar progressBar = new GraphReaderProgressBar(MainWindow.this);
|
GraphReaderProgressBar progressBar =
|
||||||
|
new GraphReaderProgressBar(MainWindow.this);
|
||||||
progressBar.setLocationRelativeTo(mainPanel.getLeftComponent());
|
progressBar.setLocationRelativeTo(mainPanel.getLeftComponent());
|
||||||
reader.addObserver(progressBar);
|
reader.addObserver(progressBar);
|
||||||
try {
|
try {
|
||||||
@ -601,19 +612,20 @@ public class MainWindow extends JFrame {
|
|||||||
|
|
||||||
String info = graph.getMapId();
|
String info = graph.getMapId();
|
||||||
if (graph.getMapName() != null && !graph.getMapName().isEmpty()) {
|
if (graph.getMapName() != null && !graph.getMapName().isEmpty()) {
|
||||||
// The \u200e character is the left-to-right mark, we need to avoid issue with
|
// The \u200e character is the left-to-right mark, we need to avoid
|
||||||
|
// issue with
|
||||||
// name that are right-to-left (e.g. arabic names).
|
// name that are right-to-left (e.g. arabic names).
|
||||||
info += " - " + graph.getMapName() + "\u200e";
|
info += " - " + graph.getMapName() + "\u200e";
|
||||||
}
|
}
|
||||||
info += ", " + graph.size() + " nodes, " + graph.getGraphInformation().getArcCount()
|
info += ", " + graph.size() + " nodes, "
|
||||||
+ " arcs.";
|
+ graph.getGraphInformation().getArcCount() + " arcs.";
|
||||||
graphInfoPanel.setText(info);
|
graphInfoPanel.setText(info);
|
||||||
|
|
||||||
drawGraph();
|
drawGraph();
|
||||||
|
|
||||||
notifyNewGraphLoaded();
|
notifyNewGraphLoaded();
|
||||||
|
|
||||||
for (JMenuItem item: graphLockItems) {
|
for (JMenuItem item : graphLockItems) {
|
||||||
item.setEnabled(true);
|
item.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -627,7 +639,7 @@ public class MainWindow extends JFrame {
|
|||||||
*/
|
*/
|
||||||
private void enableAlgorithmPanel(AlgorithmPanel algorithmPanel) {
|
private void enableAlgorithmPanel(AlgorithmPanel algorithmPanel) {
|
||||||
int dividerLocation = mainPanel.getDividerLocation();
|
int dividerLocation = mainPanel.getDividerLocation();
|
||||||
for (AlgorithmPanel panel: algoPanels) {
|
for (AlgorithmPanel panel : algoPanels) {
|
||||||
panel.setVisible(panel == algorithmPanel);
|
panel.setVisible(panel == algorithmPanel);
|
||||||
}
|
}
|
||||||
mainPanel.setDividerLocation(dividerLocation);
|
mainPanel.setDividerLocation(dividerLocation);
|
||||||
@ -637,20 +649,25 @@ public class MainWindow extends JFrame {
|
|||||||
|
|
||||||
// Open Map item...
|
// Open Map item...
|
||||||
JMenuItem openMapItem = new JMenuItem("Open Map... ", KeyEvent.VK_O);
|
JMenuItem openMapItem = new JMenuItem("Open Map... ", KeyEvent.VK_O);
|
||||||
openMapItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.ALT_MASK));
|
openMapItem.setAccelerator(
|
||||||
|
KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.ALT_MASK));
|
||||||
openMapItem.addActionListener(baf.createBlockingAction(openMapActionListener));
|
openMapItem.addActionListener(baf.createBlockingAction(openMapActionListener));
|
||||||
|
|
||||||
// Open Path item...
|
// Open Path item...
|
||||||
JMenuItem openPathItem = new JMenuItem("Open Path... ", KeyEvent.VK_P);
|
JMenuItem openPathItem = new JMenuItem("Open Path... ", KeyEvent.VK_P);
|
||||||
openPathItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK));
|
openPathItem.setAccelerator(
|
||||||
|
KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK));
|
||||||
openPathItem.addActionListener(baf.createBlockingAction(new ActionListener() {
|
openPathItem.addActionListener(baf.createBlockingAction(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
JFileChooser chooser = FileUtils.createFileChooser(FolderType.PathInput);
|
JFileChooser chooser =
|
||||||
if (chooser.showOpenDialog(MainWindow.this) == JFileChooser.APPROVE_OPTION) {
|
FileUtils.createFileChooser(FolderType.PathInput);
|
||||||
try (BinaryPathReader reader = new BinaryPathReader(new DataInputStream(new BufferedInputStream(
|
if (chooser.showOpenDialog(
|
||||||
new FileInputStream(chooser.getSelectedFile()))))){
|
MainWindow.this) == JFileChooser.APPROVE_OPTION) {
|
||||||
|
try (BinaryPathReader reader = new BinaryPathReader(
|
||||||
|
new DataInputStream(new BufferedInputStream(
|
||||||
|
new FileInputStream(chooser.getSelectedFile()))))) {
|
||||||
Path path = reader.readPath(graph);
|
Path path = reader.readPath(graph);
|
||||||
pathPanel.addPath(path);
|
pathPanel.addPath(path);
|
||||||
}
|
}
|
||||||
@ -673,7 +690,8 @@ public class MainWindow extends JFrame {
|
|||||||
|
|
||||||
// Close item
|
// Close item
|
||||||
JMenuItem closeItem = new JMenuItem("Quit", KeyEvent.VK_Q);
|
JMenuItem closeItem = new JMenuItem("Quit", KeyEvent.VK_Q);
|
||||||
closeItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK));
|
closeItem.setAccelerator(
|
||||||
|
KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK));
|
||||||
closeItem.addActionListener(new ActionListener() {
|
closeItem.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
@ -691,7 +709,8 @@ public class MainWindow extends JFrame {
|
|||||||
|
|
||||||
// Second menu
|
// Second menu
|
||||||
JMenuItem drawGraphItem = new JMenuItem("Redraw", KeyEvent.VK_R);
|
JMenuItem drawGraphItem = new JMenuItem("Redraw", KeyEvent.VK_R);
|
||||||
drawGraphItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.ALT_MASK));
|
drawGraphItem.setAccelerator(
|
||||||
|
KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.ALT_MASK));
|
||||||
drawGraphItem.addActionListener(baf.createBlockingAction(new ActionListener() {
|
drawGraphItem.addActionListener(baf.createBlockingAction(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
@ -700,8 +719,10 @@ public class MainWindow extends JFrame {
|
|||||||
}));
|
}));
|
||||||
graphLockItems.add(drawGraphItem);
|
graphLockItems.add(drawGraphItem);
|
||||||
JMenuItem drawGraphBWItem = new JMenuItem("Redraw (B&W)", KeyEvent.VK_B);
|
JMenuItem drawGraphBWItem = new JMenuItem("Redraw (B&W)", KeyEvent.VK_B);
|
||||||
drawGraphBWItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.ALT_MASK));
|
drawGraphBWItem.setAccelerator(
|
||||||
drawGraphBWItem.addActionListener(baf.createBlockingAction(new ActionListener() {
|
KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.ALT_MASK));
|
||||||
|
drawGraphBWItem
|
||||||
|
.addActionListener(baf.createBlockingAction(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
drawGraph(BasicDrawing.class, blackAndWhitePalette);
|
drawGraph(BasicDrawing.class, blackAndWhitePalette);
|
||||||
@ -709,9 +730,10 @@ public class MainWindow extends JFrame {
|
|||||||
}));
|
}));
|
||||||
graphLockItems.add(drawGraphBWItem);
|
graphLockItems.add(drawGraphBWItem);
|
||||||
JMenuItem drawGraphMapsforgeItem = new JMenuItem("Redraw (Map)", KeyEvent.VK_M);
|
JMenuItem drawGraphMapsforgeItem = new JMenuItem("Redraw (Map)", KeyEvent.VK_M);
|
||||||
|
drawGraphMapsforgeItem.setAccelerator(
|
||||||
|
KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.ALT_MASK));
|
||||||
drawGraphMapsforgeItem
|
drawGraphMapsforgeItem
|
||||||
.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.ALT_MASK));
|
.addActionListener(baf.createBlockingAction(new ActionListener() {
|
||||||
drawGraphMapsforgeItem.addActionListener(baf.createBlockingAction(new ActionListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
drawGraph(MapViewDrawing.class);
|
drawGraph(MapViewDrawing.class);
|
||||||
@ -782,7 +804,7 @@ public class MainWindow extends JFrame {
|
|||||||
menuBar.add(graphMenu);
|
menuBar.add(graphMenu);
|
||||||
menuBar.add(algoMenu);
|
menuBar.add(algoMenu);
|
||||||
|
|
||||||
for (JMenuItem item: graphLockItems) {
|
for (JMenuItem item : graphLockItems) {
|
||||||
item.setEnabled(false);
|
item.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -792,8 +814,8 @@ public class MainWindow extends JFrame {
|
|||||||
private JPanel createStatusBar() {
|
private JPanel createStatusBar() {
|
||||||
// create the status bar panel and shove it down the bottom of the frame
|
// create the status bar panel and shove it down the bottom of the frame
|
||||||
JPanel statusPanel = new JPanel();
|
JPanel statusPanel = new JPanel();
|
||||||
statusPanel.setBorder(
|
statusPanel.setBorder(new CompoundBorder(
|
||||||
new CompoundBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.GRAY),
|
BorderFactory.createMatteBorder(1, 0, 0, 0, Color.GRAY),
|
||||||
new EmptyBorder(0, 15, 0, 15)));
|
new EmptyBorder(0, 15, 0, 15)));
|
||||||
statusPanel.setPreferredSize(new Dimension(getWidth(), 38));
|
statusPanel.setPreferredSize(new Dimension(getWidth(), 38));
|
||||||
statusPanel.setLayout(new BorderLayout());
|
statusPanel.setLayout(new BorderLayout());
|
||||||
|
@ -40,9 +40,7 @@ public class NodesInputPanel extends JPanel
|
|||||||
private static final Color DEFAULT_MARKER_COLOR = Color.BLUE;
|
private static final Color DEFAULT_MARKER_COLOR = Color.BLUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class that can be used to find a node from coordinates in a "fast"
|
* Utility class that can be used to find a node from coordinates in a "fast" way.
|
||||||
* way.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private static class NodeFinder {
|
private static class NodeFinder {
|
||||||
|
|
||||||
@ -58,14 +56,13 @@ public class NodesInputPanel extends JPanel
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param point
|
* @param point
|
||||||
*
|
|
||||||
* @return the closest node to the given point, or null if no node is "close
|
* @return the closest node to the given point, or null if no node is "close
|
||||||
* enough".
|
* enough".
|
||||||
*/
|
*/
|
||||||
public Node findClosestNode(Point point) {
|
public Node findClosestNode(Point point) {
|
||||||
Node minNode = null;
|
Node minNode = null;
|
||||||
double minDis = Double.POSITIVE_INFINITY;
|
double minDis = Double.POSITIVE_INFINITY;
|
||||||
for (Node node: graph.getNodes()) {
|
for (Node node : graph.getNodes()) {
|
||||||
double dlon = point.getLongitude() - node.getPoint().getLongitude();
|
double dlon = point.getLongitude() - node.getPoint().getLongitude();
|
||||||
double dlat = point.getLatitude() - node.getPoint().getLatitude();
|
double dlat = point.getLatitude() - node.getPoint().getLatitude();
|
||||||
double dis = dlon * dlon + dlat * dlat; // No need to square
|
double dis = dlon * dlon + dlat * dlat; // No need to square
|
||||||
@ -81,7 +78,6 @@ public class NodesInputPanel extends JPanel
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Event data send when a node input has changed.
|
* Event data send when a node input has changed.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class InputChangedEvent extends ActionEvent {
|
public class InputChangedEvent extends ActionEvent {
|
||||||
|
|
||||||
@ -98,7 +94,8 @@ public class NodesInputPanel extends JPanel
|
|||||||
List<Node> nodes;
|
List<Node> nodes;
|
||||||
|
|
||||||
public InputChangedEvent(List<Node> nodes2) {
|
public InputChangedEvent(List<Node> nodes2) {
|
||||||
super(NodesInputPanel.this, ALL_INPUT_FILLED_EVENT_ID, ALL_INPUT_FILLED_EVENT_COMMAND);
|
super(NodesInputPanel.this, ALL_INPUT_FILLED_EVENT_ID,
|
||||||
|
ALL_INPUT_FILLED_EVENT_COMMAND);
|
||||||
this.nodes = nodes2;
|
this.nodes = nodes2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +107,8 @@ public class NodesInputPanel extends JPanel
|
|||||||
|
|
||||||
// Node inputs and markers.
|
// Node inputs and markers.
|
||||||
private final ArrayList<JTextField> nodeInputs = new ArrayList<>();
|
private final ArrayList<JTextField> nodeInputs = new ArrayList<>();
|
||||||
private final Map<JTextField, MarkerOverlay> markerTrackers = new IdentityHashMap<JTextField, MarkerOverlay>();
|
private final Map<JTextField, MarkerOverlay> markerTrackers =
|
||||||
|
new IdentityHashMap<JTextField, MarkerOverlay>();
|
||||||
|
|
||||||
// Component that can be enabled/disabled.
|
// Component that can be enabled/disabled.
|
||||||
private ArrayList<JComponent> components = new ArrayList<>();
|
private ArrayList<JComponent> components = new ArrayList<>();
|
||||||
@ -126,7 +124,6 @@ public class NodesInputPanel extends JPanel
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new NodesInputPanel.
|
* Create a new NodesInputPanel.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public NodesInputPanel() {
|
public NodesInputPanel() {
|
||||||
super(new GridBagLayout());
|
super(new GridBagLayout());
|
||||||
@ -134,12 +131,11 @@ public class NodesInputPanel extends JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an InputChanged listener to this panel. This listener will be notified by
|
* Add an InputChanged listener to this panel. This listener will be notified by a
|
||||||
* a {@link InputChangedEvent} each time an input in this panel change (click,
|
* {@link InputChangedEvent} each time an input in this panel change (click, clear,
|
||||||
* clear, manual input).
|
* manual input).
|
||||||
*
|
*
|
||||||
* @param listener Listener to add.
|
* @param listener Listener to add.
|
||||||
*
|
|
||||||
* @see InputChangedEvent
|
* @see InputChangedEvent
|
||||||
*/
|
*/
|
||||||
public void addInputChangedListener(ActionListener listener) {
|
public void addInputChangedListener(ActionListener listener) {
|
||||||
@ -149,7 +145,7 @@ public class NodesInputPanel extends JPanel
|
|||||||
@Override
|
@Override
|
||||||
public void setVisible(boolean visible) {
|
public void setVisible(boolean visible) {
|
||||||
super.setVisible(visible);
|
super.setVisible(visible);
|
||||||
for (JTextField input: nodeInputs) {
|
for (JTextField input : nodeInputs) {
|
||||||
MarkerOverlay marker = markerTrackers.getOrDefault(input, null);
|
MarkerOverlay marker = markerTrackers.getOrDefault(input, null);
|
||||||
if (marker != null) {
|
if (marker != null) {
|
||||||
marker.setVisible(visible && !input.getText().trim().isEmpty());
|
marker.setVisible(visible && !input.getText().trim().isEmpty());
|
||||||
@ -159,7 +155,7 @@ public class NodesInputPanel extends JPanel
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setEnabled(boolean enabled) {
|
public void setEnabled(boolean enabled) {
|
||||||
for (JComponent component: components) {
|
for (JComponent component : components) {
|
||||||
component.setEnabled(enabled);
|
component.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
super.setEnabled(enabled);
|
super.setEnabled(enabled);
|
||||||
@ -176,7 +172,7 @@ public class NodesInputPanel extends JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
for (JTextField field: nodeInputs) {
|
for (JTextField field : nodeInputs) {
|
||||||
field.setText("");
|
field.setText("");
|
||||||
markerTrackers.put(field, null);
|
markerTrackers.put(field, null);
|
||||||
}
|
}
|
||||||
@ -248,8 +244,8 @@ public class NodesInputPanel extends JPanel
|
|||||||
MarkerOverlay tracker = markerTrackers.getOrDefault(textField, null);
|
MarkerOverlay tracker = markerTrackers.getOrDefault(textField, null);
|
||||||
if (curnode != null) {
|
if (curnode != null) {
|
||||||
if (tracker == null) {
|
if (tracker == null) {
|
||||||
tracker = drawing.drawMarker(curnode.getPoint(), markerColor, Color.BLACK,
|
tracker = drawing.drawMarker(curnode.getPoint(), markerColor,
|
||||||
AlphaMode.TRANSPARENT);
|
Color.BLACK, AlphaMode.TRANSPARENT);
|
||||||
markerTrackers.put(textField, tracker);
|
markerTrackers.put(textField, tracker);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -268,7 +264,7 @@ public class NodesInputPanel extends JPanel
|
|||||||
List<Node> nodes = getNodeForInputs();
|
List<Node> nodes = getNodeForInputs();
|
||||||
|
|
||||||
// Trigger change event.
|
// Trigger change event.
|
||||||
for (ActionListener lis: inputChangeListeners) {
|
for (ActionListener lis : inputChangeListeners) {
|
||||||
lis.actionPerformed(new InputChangedEvent(nodes));
|
lis.actionPerformed(new InputChangedEvent(nodes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -317,20 +313,20 @@ public class NodesInputPanel extends JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return List of nodes associated with the input. Some nodes may be null if
|
* @return List of nodes associated with the input. Some nodes may be null if their
|
||||||
* their associated input is invalid.
|
* associated input is invalid.
|
||||||
*/
|
*/
|
||||||
public List<Node> getNodeForInputs() {
|
public List<Node> getNodeForInputs() {
|
||||||
List<Node> nodes = new ArrayList<>(nodeInputs.size());
|
List<Node> nodes = new ArrayList<>(nodeInputs.size());
|
||||||
for (JTextField input: nodeInputs) {
|
for (JTextField input : nodeInputs) {
|
||||||
nodes.add(getNodeForInput(input));
|
nodes.add(getNodeForInput(input));
|
||||||
}
|
}
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the next input that should be filled by a click, or null if none should
|
* Get the next input that should be filled by a click, or null if none should be
|
||||||
* be filled.
|
* filled.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -410,7 +406,7 @@ public class NodesInputPanel extends JPanel
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRedrawRequest() {
|
public void onRedrawRequest() {
|
||||||
for (JTextField input: nodeInputs) {
|
for (JTextField input : nodeInputs) {
|
||||||
MarkerOverlay tracker = markerTrackers.getOrDefault(input, null);
|
MarkerOverlay tracker = markerTrackers.getOrDefault(input, null);
|
||||||
if (tracker != null) {
|
if (tracker != null) {
|
||||||
MarkerOverlay newMarker = this.drawing.drawMarker(tracker.getPoint(),
|
MarkerOverlay newMarker = this.drawing.drawMarker(tracker.getPoint(),
|
||||||
|
@ -41,7 +41,8 @@ import org.insa.graphs.model.Graph;
|
|||||||
import org.insa.graphs.model.Path;
|
import org.insa.graphs.model.Path;
|
||||||
import org.insa.graphs.model.io.BinaryPathWriter;
|
import org.insa.graphs.model.io.BinaryPathWriter;
|
||||||
|
|
||||||
public class PathsPanel extends JPanel implements DrawingChangeListener, GraphChangeListener {
|
public class PathsPanel extends JPanel
|
||||||
|
implements DrawingChangeListener, GraphChangeListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -57,7 +58,6 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple icon that represents a unicolor rectangle.
|
* Simple icon that represents a unicolor rectangle.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
protected class ColorIcon implements Icon {
|
protected class ColorIcon implements Icon {
|
||||||
|
|
||||||
@ -105,9 +105,7 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
|
|||||||
* corresponding to the path.
|
* corresponding to the path.
|
||||||
*
|
*
|
||||||
* @param path Path for this bundle, must not be null.
|
* @param path Path for this bundle, must not be null.
|
||||||
*
|
|
||||||
* @throws IOException If a resource was not found.
|
* @throws IOException If a resource was not found.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public PathPanel(Path path, Color color) throws IOException {
|
public PathPanel(Path path, Color color) throws IOException {
|
||||||
super();
|
super();
|
||||||
@ -181,21 +179,24 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
|
|||||||
chooser.getSelectionModel().addChangeListener(new ChangeListener() {
|
chooser.getSelectionModel().addChangeListener(new ChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(ChangeEvent e) {
|
public void stateChanged(ChangeEvent e) {
|
||||||
icon.setColor(chooser.getSelectionModel().getSelectedColor());
|
icon.setColor(
|
||||||
|
chooser.getSelectionModel().getSelectedColor());
|
||||||
colorButton.repaint();
|
colorButton.repaint();
|
||||||
overlay.setColor(chooser.getSelectionModel().getSelectedColor());
|
overlay.setColor(
|
||||||
|
chooser.getSelectionModel().getSelectedColor());
|
||||||
overlay.redraw();
|
overlay.redraw();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
JColorChooser.createDialog(getTopLevelAncestor(), "Pick a new color", true,
|
JColorChooser.createDialog(getTopLevelAncestor(),
|
||||||
chooser, new ActionListener() {
|
"Pick a new color", true, chooser, new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
icon.setColor(chooser.getSelectionModel().getSelectedColor());
|
icon.setColor(chooser.getSelectionModel()
|
||||||
|
.getSelectedColor());
|
||||||
colorButton.repaint();
|
colorButton.repaint();
|
||||||
overlay.setColor(
|
overlay.setColor(chooser.getSelectionModel()
|
||||||
chooser.getSelectionModel().getSelectedColor());
|
.getSelectedColor());
|
||||||
overlay.redraw();
|
overlay.redraw();
|
||||||
}
|
}
|
||||||
}, new ActionListener() {
|
}, new ActionListener() {
|
||||||
@ -206,13 +207,13 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
|
|||||||
overlay.setColor(originalColor);
|
overlay.setColor(originalColor);
|
||||||
overlay.redraw();
|
overlay.redraw();
|
||||||
}
|
}
|
||||||
}).setVisible(true);
|
}).setVisible(true);;
|
||||||
;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Image saveImg = ImageIO.read(getClass().getResourceAsStream("/save-icon.png"))
|
Image saveImg =
|
||||||
|
ImageIO.read(getClass().getResourceAsStream("/save-icon.png"))
|
||||||
.getScaledInstance(14, 14, java.awt.Image.SCALE_SMOOTH);
|
.getScaledInstance(14, 14, java.awt.Image.SCALE_SMOOTH);
|
||||||
JButton saveButton = new JButton(new ImageIcon(saveImg));
|
JButton saveButton = new JButton(new ImageIcon(saveImg));
|
||||||
saveButton.setFocusPainted(false);
|
saveButton.setFocusPainted(false);
|
||||||
@ -224,16 +225,18 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
String filepath = String.format("path_%s_%d_%d.path",
|
String filepath = String.format("path_%s_%d_%d.path",
|
||||||
path.getGraph().getMapId().toLowerCase().replaceAll("[^a-z0-9_]", ""),
|
path.getGraph().getMapId().toLowerCase()
|
||||||
|
.replaceAll("[^a-z0-9_]", ""),
|
||||||
path.getOrigin().getId(), path.getDestination().getId());
|
path.getOrigin().getId(), path.getDestination().getId());
|
||||||
JFileChooser chooser = FileUtils.createFileChooser(FolderType.PathOutput,
|
JFileChooser chooser = FileUtils
|
||||||
filepath);
|
.createFileChooser(FolderType.PathOutput, filepath);
|
||||||
|
|
||||||
if (chooser
|
if (chooser.showSaveDialog(
|
||||||
.showSaveDialog(getTopLevelAncestor()) == JFileChooser.APPROVE_OPTION) {
|
getTopLevelAncestor()) == JFileChooser.APPROVE_OPTION) {
|
||||||
File file = chooser.getSelectedFile();
|
File file = chooser.getSelectedFile();
|
||||||
try (BinaryPathWriter writer = new BinaryPathWriter(new DataOutputStream(
|
try (BinaryPathWriter writer = new BinaryPathWriter(
|
||||||
new BufferedOutputStream(new FileOutputStream(file))))) {
|
new DataOutputStream(new BufferedOutputStream(
|
||||||
|
new FileOutputStream(file))))) {
|
||||||
writer.writePath(path);
|
writer.writePath(path);
|
||||||
}
|
}
|
||||||
catch (IOException e1) {
|
catch (IOException e1) {
|
||||||
@ -245,7 +248,8 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Image newimg = ImageIO.read(getClass().getResourceAsStream("/delete-icon.png"))
|
Image newimg =
|
||||||
|
ImageIO.read(getClass().getResourceAsStream("/delete-icon.png"))
|
||||||
.getScaledInstance(14, 14, java.awt.Image.SCALE_SMOOTH);
|
.getScaledInstance(14, 14, java.awt.Image.SCALE_SMOOTH);
|
||||||
JButton deleteButton = new JButton(new ImageIcon(newimg));
|
JButton deleteButton = new JButton(new ImageIcon(newimg));
|
||||||
deleteButton.setFocusPainted(false);
|
deleteButton.setFocusPainted(false);
|
||||||
@ -273,7 +277,6 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-draw the current overlay (if any) on the new drawing.
|
* Re-draw the current overlay (if any) on the new drawing.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void updateOverlay() {
|
public void updateOverlay() {
|
||||||
PathOverlay oldOverlay = this.overlay;
|
PathOverlay oldOverlay = this.overlay;
|
||||||
@ -312,7 +315,8 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
|
|||||||
|
|
||||||
public void addPath(Path path) {
|
public void addPath(Path path) {
|
||||||
try {
|
try {
|
||||||
this.add(new PathPanel(path, ColorUtils.getColor(this.getComponentCount())));
|
this.add(
|
||||||
|
new PathPanel(path, ColorUtils.getColor(this.getComponentCount())));
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
this.repaint();
|
this.repaint();
|
||||||
@ -333,7 +337,7 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void newGraphLoaded(Graph graph) {
|
public void newGraphLoaded(Graph graph) {
|
||||||
for (Component c: this.getComponents()) {
|
for (Component c : this.getComponents()) {
|
||||||
if (c instanceof PathPanel) {
|
if (c instanceof PathPanel) {
|
||||||
((PathPanel) c).overlay.delete();
|
((PathPanel) c).overlay.delete();
|
||||||
}
|
}
|
||||||
@ -351,7 +355,7 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRedrawRequest() {
|
public void onRedrawRequest() {
|
||||||
for (Component c: this.getComponents()) {
|
for (Component c : this.getComponents()) {
|
||||||
if (c instanceof PathPanel) {
|
if (c instanceof PathPanel) {
|
||||||
((PathPanel) c).updateOverlay();
|
((PathPanel) c).updateOverlay();
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,8 @@ import org.insa.graphs.gui.drawing.overlays.PathOverlay;
|
|||||||
import org.insa.graphs.model.Graph;
|
import org.insa.graphs.model.Graph;
|
||||||
import org.insa.graphs.model.Path;
|
import org.insa.graphs.model.Path;
|
||||||
|
|
||||||
public class SolutionPanel extends JPanel implements DrawingChangeListener, GraphChangeListener {
|
public class SolutionPanel extends JPanel
|
||||||
|
implements DrawingChangeListener, GraphChangeListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -46,7 +47,6 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap
|
|||||||
* corresponding to the solution (if the solution is feasible).
|
* corresponding to the solution (if the solution is feasible).
|
||||||
*
|
*
|
||||||
* @param solution Solution for this bundle, must not be null.
|
* @param solution Solution for this bundle, must not be null.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public SolutionBundle(AbstractSolution solution, boolean createOverlays) {
|
public SolutionBundle(AbstractSolution solution, boolean createOverlays) {
|
||||||
this.solution = solution;
|
this.solution = solution;
|
||||||
@ -85,7 +85,6 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-draw the current overlay (if any) on the new drawing.
|
* Re-draw the current overlay (if any) on the new drawing.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void updateOverlays() {
|
public void updateOverlays() {
|
||||||
if (this.overlays.isEmpty()) {
|
if (this.overlays.isEmpty()) {
|
||||||
@ -102,7 +101,7 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap
|
|||||||
List<PathOverlay> overlays = new ArrayList<>();
|
List<PathOverlay> overlays = new ArrayList<>();
|
||||||
if (solution.isFeasible()) {
|
if (solution.isFeasible()) {
|
||||||
Method[] methods = this.solution.getClass().getDeclaredMethods();
|
Method[] methods = this.solution.getClass().getDeclaredMethods();
|
||||||
for (Method method: methods) {
|
for (Method method : methods) {
|
||||||
if (method.getReturnType().equals(Path.class)
|
if (method.getReturnType().equals(Path.class)
|
||||||
&& method.getParameterCount() == 0) {
|
&& method.getParameterCount() == 0) {
|
||||||
try {
|
try {
|
||||||
@ -145,7 +144,8 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap
|
|||||||
public SolutionPanel(Component parent) {
|
public SolutionPanel(Component parent) {
|
||||||
super();
|
super();
|
||||||
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
|
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
|
||||||
setBorder(new CompoundBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, Color.LIGHT_GRAY),
|
setBorder(new CompoundBorder(
|
||||||
|
BorderFactory.createMatteBorder(1, 0, 1, 0, Color.LIGHT_GRAY),
|
||||||
new EmptyBorder(10, 0, 10, 0)));
|
new EmptyBorder(10, 0, 10, 0)));
|
||||||
|
|
||||||
solutionSelect = new JComboBox<>();
|
solutionSelect = new JComboBox<>();
|
||||||
@ -167,7 +167,7 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
for (PathOverlay overlay: currentBundle.getOverlays()) {
|
for (PathOverlay overlay : currentBundle.getOverlays()) {
|
||||||
if (overlay.isVisible()) {
|
if (overlay.isVisible()) {
|
||||||
overlay.setVisible(false);
|
overlay.setVisible(false);
|
||||||
clearButton.setText("Show");
|
clearButton.setText("Show");
|
||||||
@ -193,21 +193,23 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
if (currentBundle != null) {
|
if (currentBundle != null) {
|
||||||
for (PathOverlay overlay: currentBundle.getOverlays()) {
|
for (PathOverlay overlay : currentBundle.getOverlays()) {
|
||||||
overlay.setVisible(false);
|
overlay.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SolutionBundle bundle = (SolutionBundle) solutionSelect.getSelectedItem();
|
SolutionBundle bundle =
|
||||||
|
(SolutionBundle) solutionSelect.getSelectedItem();
|
||||||
|
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
|
|
||||||
updateInformationLabel(bundle);
|
updateInformationLabel(bundle);
|
||||||
buttonPanel
|
buttonPanel.setVisible(
|
||||||
.setVisible(bundle.getSolution().isFeasible() && bundle.hasOverlays());
|
bundle.getSolution().isFeasible() && bundle.hasOverlays());
|
||||||
clearButton.setText(bundle.getSolution().isFeasible() ? "Hide" : "Show");
|
clearButton.setText(
|
||||||
|
bundle.getSolution().isFeasible() ? "Hide" : "Show");
|
||||||
|
|
||||||
for (PathOverlay overlay: bundle.getOverlays()) {
|
for (PathOverlay overlay : bundle.getOverlays()) {
|
||||||
overlay.setVisible(true);
|
overlay.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -226,8 +228,7 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap
|
|||||||
* Add the given solution to the panel.
|
* Add the given solution to the panel.
|
||||||
*
|
*
|
||||||
* @param solution the solution to add to the panel
|
* @param solution the solution to add to the panel
|
||||||
* @param createOverlays Whether or not overlay should be created for this
|
* @param createOverlays Whether or not overlay should be created for this solution.
|
||||||
* solution.
|
|
||||||
*/
|
*/
|
||||||
public void addSolution(AbstractSolution solution, boolean createOverlays) {
|
public void addSolution(AbstractSolution solution, boolean createOverlays) {
|
||||||
SolutionBundle bundle = new SolutionBundle(solution, createOverlays);
|
SolutionBundle bundle = new SolutionBundle(solution, createOverlays);
|
||||||
@ -251,9 +252,10 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap
|
|||||||
solutionSelect.setSelectedItem(currentBundle);
|
solutionSelect.setSelectedItem(currentBundle);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SolutionBundle bundle = (SolutionBundle) this.solutionSelect.getSelectedItem();
|
SolutionBundle bundle =
|
||||||
|
(SolutionBundle) this.solutionSelect.getSelectedItem();
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
for (PathOverlay overlay: bundle.getOverlays()) {
|
for (PathOverlay overlay : bundle.getOverlays()) {
|
||||||
overlay.setVisible(false);
|
overlay.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,7 +265,7 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap
|
|||||||
@Override
|
@Override
|
||||||
public void newGraphLoaded(Graph graph) {
|
public void newGraphLoaded(Graph graph) {
|
||||||
for (int i = 0; i < this.solutionSelect.getItemCount(); ++i) {
|
for (int i = 0; i < this.solutionSelect.getItemCount(); ++i) {
|
||||||
for (PathOverlay overlay: this.solutionSelect.getItemAt(i).getOverlays()) {
|
for (PathOverlay overlay : this.solutionSelect.getItemAt(i).getOverlays()) {
|
||||||
overlay.delete();
|
overlay.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,9 @@ import org.insa.graphs.model.Arc;
|
|||||||
public class BlackAndWhiteGraphPalette extends BasicGraphPalette {
|
public class BlackAndWhiteGraphPalette extends BasicGraphPalette {
|
||||||
|
|
||||||
// Road colors (index
|
// Road colors (index
|
||||||
private final static Color[] ROAD_COLOR_FROM_WIDTH = { null, new Color(140, 140, 140),
|
private final static Color[] ROAD_COLOR_FROM_WIDTH =
|
||||||
new Color(80, 80, 80), new Color(40, 40, 40), new Color(30, 30, 30) };
|
{ null, new Color(140, 140, 140), new Color(80, 80, 80),
|
||||||
|
new Color(40, 40, 40), new Color(30, 30, 30) };
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Color getColorForArc(Arc arc) {
|
public Color getColorForArc(Arc arc) {
|
||||||
|
@ -12,8 +12,8 @@ import org.insa.graphs.model.Point;
|
|||||||
public interface Drawing {
|
public interface Drawing {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Available fill mode for the creation of markers, see the documentation of
|
* Available fill mode for the creation of markers, see the documentation of each
|
||||||
* each value for more details.
|
* value for more details.
|
||||||
*/
|
*/
|
||||||
enum AlphaMode {
|
enum AlphaMode {
|
||||||
|
|
||||||
@ -53,37 +53,34 @@ public interface Drawing {
|
|||||||
public void clearOverlays();
|
public void clearOverlays();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a marker at the given position using the given colors and according to
|
* Draw a marker at the given position using the given colors and according to the
|
||||||
* the given mode.
|
* given mode.
|
||||||
*
|
*
|
||||||
* @param point Position of the marker to draw.
|
* @param point Position of the marker to draw.
|
||||||
* @param outer Color for the outer part of the marker to draw.
|
* @param outer Color for the outer part of the marker to draw.
|
||||||
* @param inner Color for the inner part of the marker to draw.
|
* @param inner Color for the inner part of the marker to draw.
|
||||||
* @param mode Mode for filling the inner par of the marker.
|
* @param mode Mode for filling the inner par of the marker.
|
||||||
*
|
|
||||||
* @return A MarkerOverlay instance representing the newly drawn marker.
|
* @return A MarkerOverlay instance representing the newly drawn marker.
|
||||||
*/
|
*/
|
||||||
public MarkerOverlay drawMarker(Point point, Color outer, Color inner, AlphaMode mode);
|
public MarkerOverlay drawMarker(Point point, Color outer, Color inner,
|
||||||
|
AlphaMode mode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PointSetOverlay that can be used to add overlay points to this
|
* Create a new PointSetOverlay that can be used to add overlay points to this
|
||||||
* drawing.
|
* drawing. PointSetOverlay are heavy memory resources, do not use one for each
|
||||||
*
|
* point!
|
||||||
* PointSetOverlay are heavy memory resources, do not use one for each point!
|
|
||||||
*
|
*
|
||||||
* @return A new PointSetOverlay for this drawing.
|
* @return A new PointSetOverlay for this drawing.
|
||||||
*/
|
*/
|
||||||
public PointSetOverlay createPointSetOverlay();
|
public PointSetOverlay createPointSetOverlay();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PointSetOverlay with the given initial width and color that can
|
* Create a new PointSetOverlay with the given initial width and color that can be
|
||||||
* be used to add overlay points to this drawing.
|
* used to add overlay points to this drawing. PointSetOverlay are heavy memory
|
||||||
*
|
* resources, do not use one for each point!
|
||||||
* PointSetOverlay are heavy memory resources, do not use one for each point!
|
|
||||||
*
|
*
|
||||||
* @param width Initial width of points in the overlay.
|
* @param width Initial width of points in the overlay.
|
||||||
* @param color Initial width of points in the overlay.
|
* @param color Initial width of points in the overlay.
|
||||||
*
|
|
||||||
* @return A new PointSetOverlay for this drawing.
|
* @return A new PointSetOverlay for this drawing.
|
||||||
*/
|
*/
|
||||||
public PointSetOverlay createPointSetOverlay(int width, Color color);
|
public PointSetOverlay createPointSetOverlay(int width, Color color);
|
||||||
@ -93,7 +90,6 @@ public interface Drawing {
|
|||||||
*
|
*
|
||||||
* @param graph Graph to draw.
|
* @param graph Graph to draw.
|
||||||
* @param palette Palette to use to draw the graph.
|
* @param palette Palette to use to draw the graph.
|
||||||
*
|
|
||||||
* @see BasicGraphPalette
|
* @see BasicGraphPalette
|
||||||
* @see BlackAndWhiteGraphPalette
|
* @see BlackAndWhiteGraphPalette
|
||||||
*/
|
*/
|
||||||
@ -112,7 +108,6 @@ public interface Drawing {
|
|||||||
* @param path Path to draw.
|
* @param path Path to draw.
|
||||||
* @param color Color of the path to draw.
|
* @param color Color of the path to draw.
|
||||||
* @param markers true to show origin and destination markers.
|
* @param markers true to show origin and destination markers.
|
||||||
*
|
|
||||||
* @return A PathOverlay instance representing the newly drawn path.
|
* @return A PathOverlay instance representing the newly drawn path.
|
||||||
*/
|
*/
|
||||||
public PathOverlay drawPath(Path path, Color color, boolean markers);
|
public PathOverlay drawPath(Path path, Color color, boolean markers);
|
||||||
@ -122,9 +117,7 @@ public interface Drawing {
|
|||||||
*
|
*
|
||||||
* @param path Path to draw.
|
* @param path Path to draw.
|
||||||
* @param color Color of the path to draw.
|
* @param color Color of the path to draw.
|
||||||
*
|
|
||||||
* @return A PathOverlay instance representing the newly drawn path.
|
* @return A PathOverlay instance representing the newly drawn path.
|
||||||
*
|
|
||||||
* @see Drawing#drawPath(Path, Color, boolean)
|
* @see Drawing#drawPath(Path, Color, boolean)
|
||||||
*/
|
*/
|
||||||
public PathOverlay drawPath(Path path, Color color);
|
public PathOverlay drawPath(Path path, Color color);
|
||||||
@ -134,9 +127,7 @@ public interface Drawing {
|
|||||||
*
|
*
|
||||||
* @param path Path to draw.
|
* @param path Path to draw.
|
||||||
* @param markers true to show origin and destination markers.
|
* @param markers true to show origin and destination markers.
|
||||||
*
|
|
||||||
* @return A PathOverlay instance representing the newly drawn path.
|
* @return A PathOverlay instance representing the newly drawn path.
|
||||||
*
|
|
||||||
* @see Drawing#drawPath(Path, Color, boolean)
|
* @see Drawing#drawPath(Path, Color, boolean)
|
||||||
*/
|
*/
|
||||||
public PathOverlay drawPath(Path path, boolean markers);
|
public PathOverlay drawPath(Path path, boolean markers);
|
||||||
@ -145,11 +136,8 @@ public interface Drawing {
|
|||||||
* Draw a path with both origin and destination markers using a default color
|
* Draw a path with both origin and destination markers using a default color
|
||||||
* specific to the implementation
|
* specific to the implementation
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param path Path to draw.
|
* @param path Path to draw.
|
||||||
*
|
|
||||||
* @return A PathOverlay instance representing the newly drawn path.
|
* @return A PathOverlay instance representing the newly drawn path.
|
||||||
*
|
|
||||||
* @see Drawing#drawPath(Path, Color, boolean)
|
* @see Drawing#drawPath(Path, Color, boolean)
|
||||||
*/
|
*/
|
||||||
public PathOverlay drawPath(Path path);
|
public PathOverlay drawPath(Path path);
|
||||||
|
@ -8,14 +8,12 @@ public interface GraphPalette {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param arc Arc for which color should be retrieved.
|
* @param arc Arc for which color should be retrieved.
|
||||||
*
|
|
||||||
* @return Color associated with the given arc.
|
* @return Color associated with the given arc.
|
||||||
*/
|
*/
|
||||||
public Color getColorForArc(Arc arc);
|
public Color getColorForArc(Arc arc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param arc Arc for which width should be retrieved.
|
* @param arc Arc for which width should be retrieved.
|
||||||
*
|
|
||||||
* @return Width associated with the given arc.
|
* @return Width associated with the given arc.
|
||||||
*/
|
*/
|
||||||
public int getWidthForArc(Arc arc);
|
public int getWidthForArc(Arc arc);
|
||||||
|
@ -30,8 +30,8 @@ public class MercatorProjection implements Projection {
|
|||||||
* maxSize.
|
* maxSize.
|
||||||
*
|
*
|
||||||
* @param boundingBox Box for this projection.
|
* @param boundingBox Box for this projection.
|
||||||
* @param maxSize Maximum size of any side (width / height) of the image to
|
* @param maxSize Maximum size of any side (width / height) of the image to which
|
||||||
* which this projection should draw.
|
* this projection should draw.
|
||||||
*/
|
*/
|
||||||
public MercatorProjection(BoundingBox boundingBox, int maxSize) {
|
public MercatorProjection(BoundingBox boundingBox, int maxSize) {
|
||||||
// Find minimum/maximum longitude and latitude.
|
// Find minimum/maximum longitude and latitude.
|
||||||
@ -53,7 +53,6 @@ public class MercatorProjection implements Projection {
|
|||||||
* Compute the projection (without scaling) of the given latitude.
|
* Compute the projection (without scaling) of the given latitude.
|
||||||
*
|
*
|
||||||
* @param latitude Latitude to project.
|
* @param latitude Latitude to project.
|
||||||
*
|
|
||||||
* @return Projection of the given latitude (without scaling).
|
* @return Projection of the given latitude (without scaling).
|
||||||
*/
|
*/
|
||||||
private static double projectY(double latitude) {
|
private static double projectY(double latitude) {
|
||||||
@ -62,11 +61,10 @@ public class MercatorProjection implements Projection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the dimension required for drawing a projection of the given box on
|
* Compute the dimension required for drawing a projection of the given box on an
|
||||||
* an image, ensuring that none of the side of image is greater than maxSize.
|
* image, ensuring that none of the side of image is greater than maxSize.
|
||||||
*
|
*
|
||||||
* @param maxSize Maximum side of any side of the image.
|
* @param maxSize Maximum side of any side of the image.
|
||||||
*
|
|
||||||
* @return Dimension corresponding to the preferred size for the image.
|
* @return Dimension corresponding to the preferred size for the image.
|
||||||
*/
|
*/
|
||||||
protected Dimension computeImageSize(int maxSize) {
|
protected Dimension computeImageSize(int maxSize) {
|
||||||
@ -97,7 +95,8 @@ public class MercatorProjection implements Projection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int longitudeToPixelX(float longitude) {
|
public int longitudeToPixelX(float longitude) {
|
||||||
return (int) (width * (longitude - minLongitude) / (maxLongitude - minLongitude));
|
return (int) (width * (longitude - minLongitude)
|
||||||
|
/ (maxLongitude - minLongitude));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,8 +15,8 @@ public class PlateCarreProjection implements Projection {
|
|||||||
* maxSize.
|
* maxSize.
|
||||||
*
|
*
|
||||||
* @param boundingBox Box for this projection.
|
* @param boundingBox Box for this projection.
|
||||||
* @param maxSize Maximum size of any side (width / height) of the image to
|
* @param maxSize Maximum size of any side (width / height) of the image to which
|
||||||
* which this projection should draw.
|
* this projection should draw.
|
||||||
*/
|
*/
|
||||||
public PlateCarreProjection(BoundingBox boundingBox, int maxSize) {
|
public PlateCarreProjection(BoundingBox boundingBox, int maxSize) {
|
||||||
// Find minimum/maximum longitude and latitude.
|
// Find minimum/maximum longitude and latitude.
|
||||||
@ -25,7 +25,8 @@ public class PlateCarreProjection implements Projection {
|
|||||||
this.minLatitude = boundingBox.getBottomRightPoint().getLatitude();
|
this.minLatitude = boundingBox.getBottomRightPoint().getLatitude();
|
||||||
this.maxLatitude = boundingBox.getTopLeftPoint().getLatitude();
|
this.maxLatitude = boundingBox.getTopLeftPoint().getLatitude();
|
||||||
|
|
||||||
float diffLon = maxLongitude - minLongitude, diffLat = maxLatitude - minLatitude;
|
float diffLon = maxLongitude - minLongitude,
|
||||||
|
diffLat = maxLatitude - minLatitude;
|
||||||
|
|
||||||
this.width = diffLon < diffLat ? (int) (maxSize * diffLon / diffLat) : maxSize;
|
this.width = diffLon < diffLat ? (int) (maxSize * diffLon / diffLat) : maxSize;
|
||||||
this.height = diffLon < diffLat ? maxSize : (int) (maxSize * diffLat / diffLon);
|
this.height = diffLon < diffLat ? maxSize : (int) (maxSize * diffLat / diffLon);
|
||||||
|
@ -16,7 +16,6 @@ public interface Projection {
|
|||||||
* Project the given latitude on the image.
|
* Project the given latitude on the image.
|
||||||
*
|
*
|
||||||
* @param latitude Latitude to project.
|
* @param latitude Latitude to project.
|
||||||
*
|
|
||||||
* @return Projected position of the latitude on the image.
|
* @return Projected position of the latitude on the image.
|
||||||
*/
|
*/
|
||||||
public int latitudeToPixelY(float latitude);
|
public int latitudeToPixelY(float latitude);
|
||||||
@ -25,7 +24,6 @@ public interface Projection {
|
|||||||
* Project the given longitude on the image.
|
* Project the given longitude on the image.
|
||||||
*
|
*
|
||||||
* @param longitude Longitude to project.
|
* @param longitude Longitude to project.
|
||||||
*
|
|
||||||
* @return Projected position of the longitude on the image.
|
* @return Projected position of the longitude on the image.
|
||||||
*/
|
*/
|
||||||
public int longitudeToPixelX(float longitude);
|
public int longitudeToPixelX(float longitude);
|
||||||
@ -34,7 +32,6 @@ public interface Projection {
|
|||||||
* Retrieve the latitude associated to the given projected point.
|
* Retrieve the latitude associated to the given projected point.
|
||||||
*
|
*
|
||||||
* @param py Projected y-position for which latitude should be retrieved.
|
* @param py Projected y-position for which latitude should be retrieved.
|
||||||
*
|
|
||||||
* @return The original latitude of the point.
|
* @return The original latitude of the point.
|
||||||
*/
|
*/
|
||||||
public float pixelYToLatitude(double py);
|
public float pixelYToLatitude(double py);
|
||||||
@ -43,7 +40,6 @@ public interface Projection {
|
|||||||
* Retrieve the longitude associated to the given projected point.
|
* Retrieve the longitude associated to the given projected point.
|
||||||
*
|
*
|
||||||
* @param px Projected x-position for which longitude should be retrieved.
|
* @param px Projected x-position for which longitude should be retrieved.
|
||||||
*
|
|
||||||
* @return The original longitude of the point.
|
* @return The original longitude of the point.
|
||||||
*/
|
*/
|
||||||
public float pixelXToLongitude(double px);
|
public float pixelXToLongitude(double px);
|
||||||
|
@ -125,7 +125,8 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
private Color innerColor;
|
private Color innerColor;
|
||||||
private final AlphaMode alphaMode;
|
private final AlphaMode alphaMode;
|
||||||
|
|
||||||
public BasicMarkerOverlay(Point point, Color color, Color inner, AlphaMode alphaMode) {
|
public BasicMarkerOverlay(Point point, Color color, Color inner,
|
||||||
|
AlphaMode alphaMode) {
|
||||||
super(color);
|
super(color);
|
||||||
this.point = point;
|
this.point = point;
|
||||||
this.image = MarkerUtils.getMarkerForColor(color, inner, alphaMode);
|
this.image = MarkerUtils.getMarkerForColor(color, inner, alphaMode);
|
||||||
@ -146,7 +147,8 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
public void setColor(Color color) {
|
public void setColor(Color color) {
|
||||||
this.innerColor = this.innerColor.equals(this.color) ? color : innerColor;
|
this.innerColor = this.innerColor.equals(this.color) ? color : innerColor;
|
||||||
super.setColor(color);
|
super.setColor(color);
|
||||||
this.image = MarkerUtils.getMarkerForColor(color, this.innerColor, alphaMode);
|
this.image =
|
||||||
|
MarkerUtils.getMarkerForColor(color, this.innerColor, alphaMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -161,8 +163,8 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
int px = projection.longitudeToPixelX(getPoint().getLongitude());
|
int px = projection.longitudeToPixelX(getPoint().getLongitude());
|
||||||
int py = projection.latitudeToPixelY(getPoint().getLatitude());
|
int py = projection.latitudeToPixelY(getPoint().getLatitude());
|
||||||
|
|
||||||
graphics.drawImage(this.image, px - MARKER_WIDTH / 2, py - MARKER_HEIGHT, MARKER_WIDTH,
|
graphics.drawImage(this.image, px - MARKER_WIDTH / 2, py - MARKER_HEIGHT,
|
||||||
MARKER_HEIGHT, BasicDrawing.this);
|
MARKER_WIDTH, MARKER_HEIGHT, BasicDrawing.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -175,8 +177,8 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
// Origin / Destination markers.
|
// Origin / Destination markers.
|
||||||
private BasicMarkerOverlay origin, destination;
|
private BasicMarkerOverlay origin, destination;
|
||||||
|
|
||||||
public BasicPathOverlay(List<Point> points, Color color, BasicMarkerOverlay origin,
|
public BasicPathOverlay(List<Point> points, Color color,
|
||||||
BasicMarkerOverlay destination) {
|
BasicMarkerOverlay origin, BasicMarkerOverlay destination) {
|
||||||
super(color);
|
super(color);
|
||||||
this.points = points;
|
this.points = points;
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
@ -244,8 +246,8 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
|
|
||||||
public BasicPointSetOverlay() {
|
public BasicPointSetOverlay() {
|
||||||
super(Color.BLACK);
|
super(Color.BLACK);
|
||||||
this.image = new BufferedImage(BasicDrawing.this.width, BasicDrawing.this.height,
|
this.image = new BufferedImage(BasicDrawing.this.width,
|
||||||
BufferedImage.TYPE_4BYTE_ABGR);
|
BasicDrawing.this.height, BufferedImage.TYPE_4BYTE_ABGR);
|
||||||
this.graphics = image.createGraphics();
|
this.graphics = image.createGraphics();
|
||||||
this.graphics.setBackground(new Color(0, 0, 0, 0));
|
this.graphics.setBackground(new Color(0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
@ -307,7 +309,6 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class encapsulating a set of overlays.
|
* Class encapsulating a set of overlays.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private class BasicOverlays {
|
private class BasicOverlays {
|
||||||
|
|
||||||
@ -316,8 +317,8 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
|
|
||||||
public synchronized void draw(Graphics2D g) {
|
public synchronized void draw(Graphics2D g) {
|
||||||
// Clear overlays.
|
// Clear overlays.
|
||||||
for (ArrayList<BasicOverlay> arr: this.overlays) {
|
for (ArrayList<BasicOverlay> arr : this.overlays) {
|
||||||
for (BasicOverlay overlay: arr) {
|
for (BasicOverlay overlay : arr) {
|
||||||
overlay.draw(g);
|
overlay.draw(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -334,7 +335,7 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
|
|
||||||
public void clear(boolean repaint) {
|
public void clear(boolean repaint) {
|
||||||
// Clear overlays.
|
// Clear overlays.
|
||||||
for (ArrayList<BasicOverlay> arr: this.overlays) {
|
for (ArrayList<BasicOverlay> arr : this.overlays) {
|
||||||
arr.clear();
|
arr.clear();
|
||||||
}
|
}
|
||||||
// Repaint if requested.
|
// Repaint if requested.
|
||||||
@ -397,7 +398,6 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new BasicDrawing.
|
* Create a new BasicDrawing.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public BasicDrawing() {
|
public BasicDrawing() {
|
||||||
setLayout(null);
|
setLayout(null);
|
||||||
@ -440,7 +440,7 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
catch (NoninvertibleTransformException e) {
|
catch (NoninvertibleTransformException e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (DrawingClickListener listener: drawingClickListeners) {
|
for (DrawingClickListener listener : drawingClickListeners) {
|
||||||
listener.mouseClicked(lonlat);
|
listener.mouseClicked(lonlat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -510,14 +510,12 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
* MouseEvent.
|
* MouseEvent.
|
||||||
*
|
*
|
||||||
* @param event MouseEvent from which longitude/latitude should be retrieved.
|
* @param event MouseEvent from which longitude/latitude should be retrieved.
|
||||||
*
|
|
||||||
* @return Point representing the projection of the MouseEvent position in the
|
* @return Point representing the projection of the MouseEvent position in the
|
||||||
* graph/map.
|
* graph/map.
|
||||||
*
|
* @throws NoninvertibleTransformException if the actual transformation is invalid.
|
||||||
* @throws NoninvertibleTransformException if the actual transformation is
|
|
||||||
* invalid.
|
|
||||||
*/
|
*/
|
||||||
protected Point getLongitudeLatitude(MouseEvent event) throws NoninvertibleTransformException {
|
protected Point getLongitudeLatitude(MouseEvent event)
|
||||||
|
throws NoninvertibleTransformException {
|
||||||
// Get the point using the inverse transform of the Zoom/Pan object, this gives
|
// Get the point using the inverse transform of the Zoom/Pan object, this gives
|
||||||
// us
|
// us
|
||||||
// a point within the drawing box (between [0, 0] and [width, height]).
|
// a point within the drawing box (between [0, 0] and [width, height]).
|
||||||
@ -532,8 +530,7 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see
|
* @see org.insa.graphics.drawing.Drawing#addDrawingClickListener(org.insa.graphics.
|
||||||
* org.insa.graphics.drawing.Drawing#addDrawingClickListener(org.insa.graphics.
|
|
||||||
* drawing.DrawingClickListener)
|
* drawing.DrawingClickListener)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -552,13 +549,16 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
this.drawingClickListeners.remove(listener);
|
this.drawingClickListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BasicMarkerOverlay createMarker(Point point, Color outer, Color inner, AlphaMode mode) {
|
public BasicMarkerOverlay createMarker(Point point, Color outer, Color inner,
|
||||||
|
AlphaMode mode) {
|
||||||
return new BasicMarkerOverlay(point, outer, inner, mode);
|
return new BasicMarkerOverlay(point, outer, inner, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MarkerOverlay drawMarker(Point point, Color outer, Color inner, AlphaMode mode) {
|
public MarkerOverlay drawMarker(Point point, Color outer, Color inner,
|
||||||
return (MarkerOverlay) this.overlays.add(createMarker(point, outer, inner, mode));
|
AlphaMode mode) {
|
||||||
|
return (MarkerOverlay) this.overlays
|
||||||
|
.add(createMarker(point, outer, inner, mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -577,15 +577,16 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
* Draw the given arc.
|
* Draw the given arc.
|
||||||
*
|
*
|
||||||
* @param arc Arc to draw.
|
* @param arc Arc to draw.
|
||||||
* @param palette Palette to use to retrieve color and width for arc, or null to
|
* @param palette Palette to use to retrieve color and width for arc, or null to use
|
||||||
* use current settings.
|
* current settings.
|
||||||
*/
|
*/
|
||||||
protected void drawArc(Arc arc, GraphPalette palette, boolean repaint) {
|
protected void drawArc(Arc arc, GraphPalette palette, boolean repaint) {
|
||||||
List<Point> pts = arc.getPoints();
|
List<Point> pts = arc.getPoints();
|
||||||
if (!pts.isEmpty()) {
|
if (!pts.isEmpty()) {
|
||||||
if (palette != null) {
|
if (palette != null) {
|
||||||
this.graphGraphics.setColor(palette.getColorForArc(arc));
|
this.graphGraphics.setColor(palette.getColorForArc(arc));
|
||||||
this.graphGraphics.setStroke(new BasicStroke(palette.getWidthForArc(arc)));
|
this.graphGraphics
|
||||||
|
.setStroke(new BasicStroke(palette.getWidthForArc(arc)));
|
||||||
}
|
}
|
||||||
Iterator<Point> it1 = pts.iterator();
|
Iterator<Point> it1 = pts.iterator();
|
||||||
Point prev = it1.next();
|
Point prev = it1.next();
|
||||||
@ -633,7 +634,8 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
|
|
||||||
// Special projection for non-realistic maps...
|
// Special projection for non-realistic maps...
|
||||||
if (graph.getMapId().startsWith("0x")) {
|
if (graph.getMapId().startsWith("0x")) {
|
||||||
projection = new PlateCarreProjection(extendedBox, MAXIMUM_DRAWING_WIDTH / 4);
|
projection =
|
||||||
|
new PlateCarreProjection(extendedBox, MAXIMUM_DRAWING_WIDTH / 4);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
projection = new MercatorProjection(extendedBox, MAXIMUM_DRAWING_WIDTH);
|
projection = new MercatorProjection(extendedBox, MAXIMUM_DRAWING_WIDTH);
|
||||||
@ -679,8 +681,8 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
this.removeMouseMotionListener(zoomAndPanListener);
|
this.removeMouseMotionListener(zoomAndPanListener);
|
||||||
this.removeMouseWheelListener(zoomAndPanListener);
|
this.removeMouseWheelListener(zoomAndPanListener);
|
||||||
|
|
||||||
for (Node node: graph.getNodes()) {
|
for (Node node : graph.getNodes()) {
|
||||||
for (Arc arc: node.getSuccessors()) {
|
for (Arc arc : node.getSuccessors()) {
|
||||||
// Draw arcs only if there are one-way arcs or if origin is lower than
|
// Draw arcs only if there are one-way arcs or if origin is lower than
|
||||||
// destination, avoid drawing two-ways arc twice.
|
// destination, avoid drawing two-ways arc twice.
|
||||||
if (arc.getRoadInformation().isOneWay()
|
if (arc.getRoadInformation().isOneWay()
|
||||||
@ -710,7 +712,7 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
List<Point> points = new ArrayList<Point>();
|
List<Point> points = new ArrayList<Point>();
|
||||||
if (!path.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
points.add(path.getOrigin().getPoint());
|
points.add(path.getOrigin().getPoint());
|
||||||
for (Arc arc: path.getArcs()) {
|
for (Arc arc : path.getArcs()) {
|
||||||
Iterator<Point> itPoint = arc.getPoints().iterator();
|
Iterator<Point> itPoint = arc.getPoints().iterator();
|
||||||
// Discard origin each time
|
// Discard origin each time
|
||||||
itPoint.next();
|
itPoint.next();
|
||||||
@ -721,7 +723,8 @@ public class BasicDrawing extends JPanel implements Drawing {
|
|||||||
}
|
}
|
||||||
BasicMarkerOverlay origin = null, destination = null;
|
BasicMarkerOverlay origin = null, destination = null;
|
||||||
if (markers && !path.isEmpty()) {
|
if (markers && !path.isEmpty()) {
|
||||||
origin = createMarker(path.getOrigin().getPoint(), color, color, AlphaMode.TRANSPARENT);
|
origin = createMarker(path.getOrigin().getPoint(), color, color,
|
||||||
|
AlphaMode.TRANSPARENT);
|
||||||
destination = createMarker(path.getDestination().getPoint(), color, color,
|
destination = createMarker(path.getDestination().getPoint(), color, color,
|
||||||
AlphaMode.TRANSPARENT);
|
AlphaMode.TRANSPARENT);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,6 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Base Overlay for MapViewDrawing overlays.
|
* Base Overlay for MapViewDrawing overlays.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private abstract class MapViewOverlay implements Overlay {
|
private abstract class MapViewOverlay implements Overlay {
|
||||||
|
|
||||||
@ -74,7 +73,7 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
|
|
||||||
public MapViewOverlay(Layer[] layers, Color color) {
|
public MapViewOverlay(Layer[] layers, Color color) {
|
||||||
this.layers = layers;
|
this.layers = layers;
|
||||||
for (Layer layer: this.layers) {
|
for (Layer layer : this.layers) {
|
||||||
MapViewDrawing.this.getLayerManager().getLayers().add(layer);
|
MapViewDrawing.this.getLayerManager().getLayers().add(layer);
|
||||||
}
|
}
|
||||||
this.color = color;
|
this.color = color;
|
||||||
@ -92,7 +91,7 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVisible(boolean visible) {
|
public void setVisible(boolean visible) {
|
||||||
for (Layer layer: layers) {
|
for (Layer layer : layers) {
|
||||||
layer.setVisible(visible);
|
layer.setVisible(visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,7 +107,7 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
@Override
|
@Override
|
||||||
public void delete() {
|
public void delete() {
|
||||||
Layers mlayers = MapViewDrawing.this.getLayerManager().getLayers();
|
Layers mlayers = MapViewDrawing.this.getLayerManager().getLayers();
|
||||||
for (Layer layer: layers) {
|
for (Layer layer : layers) {
|
||||||
mlayers.remove(layer);
|
mlayers.remove(layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,7 +120,6 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* MarkerOverlay for MapViewDrawing.
|
* MarkerOverlay for MapViewDrawing.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private class MapViewMarkerOverlay extends MapViewOverlay implements MarkerOverlay {
|
private class MapViewMarkerOverlay extends MapViewOverlay implements MarkerOverlay {
|
||||||
|
|
||||||
@ -144,10 +142,12 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setColor(Color outer) {
|
public void setColor(Color outer) {
|
||||||
this.innerColor = this.innerColor.equals(this.color) ? outer : this.innerColor;
|
this.innerColor =
|
||||||
|
this.innerColor.equals(this.color) ? outer : this.innerColor;
|
||||||
super.setColor(color);
|
super.setColor(color);
|
||||||
MarkerAutoScaling marker = (MarkerAutoScaling) super.layers[0];
|
MarkerAutoScaling marker = (MarkerAutoScaling) super.layers[0];
|
||||||
marker.setImage(MarkerUtils.getMarkerForColor(color, this.innerColor, this.alphaMode));
|
marker.setImage(MarkerUtils.getMarkerForColor(color, this.innerColor,
|
||||||
|
this.alphaMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -163,7 +163,6 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* PathOverlay for MapViewDrawing.
|
* PathOverlay for MapViewDrawing.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private class MapViewPathOverlay extends MapViewOverlay implements PathOverlay {
|
private class MapViewPathOverlay extends MapViewOverlay implements PathOverlay {
|
||||||
|
|
||||||
@ -180,19 +179,19 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
public void setColor(Color color) {
|
public void setColor(Color color) {
|
||||||
super.setColor(color);
|
super.setColor(color);
|
||||||
((PolylineAutoScaling) this.layers[0]).setColor(color);
|
((PolylineAutoScaling) this.layers[0]).setColor(color);
|
||||||
((MarkerAutoScaling) this.layers[1])
|
((MarkerAutoScaling) this.layers[1]).setImage(
|
||||||
.setImage(MarkerUtils.getMarkerForColor(color, color, AlphaMode.TRANSPARENT));
|
MarkerUtils.getMarkerForColor(color, color, AlphaMode.TRANSPARENT));
|
||||||
((MarkerAutoScaling) this.layers[2])
|
((MarkerAutoScaling) this.layers[2]).setImage(
|
||||||
.setImage(MarkerUtils.getMarkerForColor(color, color, AlphaMode.TRANSPARENT));
|
MarkerUtils.getMarkerForColor(color, color, AlphaMode.TRANSPARENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PointSetOverlay for MapViewDrawing - Not currently implemented.
|
* PointSetOverlay for MapViewDrawing - Not currently implemented.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private class MapViewPointSetOverlay extends MapViewOverlay implements PointSetOverlay {
|
private class MapViewPointSetOverlay extends MapViewOverlay
|
||||||
|
implements PointSetOverlay {
|
||||||
|
|
||||||
private List<Point> points = new ArrayList<>();
|
private List<Point> points = new ArrayList<>();
|
||||||
private final Polygon polygon;
|
private final Polygon polygon;
|
||||||
@ -205,8 +204,9 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
List<Point> h = new ArrayList<>();
|
List<Point> h = new ArrayList<>();
|
||||||
|
|
||||||
// lower hull
|
// lower hull
|
||||||
for (Point pt: p) {
|
for (Point pt : p) {
|
||||||
while (h.size() >= 2 && !ccw(h.get(h.size() - 2), h.get(h.size() - 1), pt)) {
|
while (h.size() >= 2
|
||||||
|
&& !ccw(h.get(h.size() - 2), h.get(h.size() - 1), pt)) {
|
||||||
h.remove(h.size() - 1);
|
h.remove(h.size() - 1);
|
||||||
}
|
}
|
||||||
h.add(pt);
|
h.add(pt);
|
||||||
@ -216,7 +216,8 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
int t = h.size() + 1;
|
int t = h.size() + 1;
|
||||||
for (int i = p.size() - 1; i >= 0; i--) {
|
for (int i = p.size() - 1; i >= 0; i--) {
|
||||||
Point pt = p.get(i);
|
Point pt = p.get(i);
|
||||||
while (h.size() >= t && !ccw(h.get(h.size() - 2), h.get(h.size() - 1), pt)) {
|
while (h.size() >= t
|
||||||
|
&& !ccw(h.get(h.size() - 2), h.get(h.size() - 1), pt)) {
|
||||||
h.remove(h.size() - 1);
|
h.remove(h.size() - 1);
|
||||||
}
|
}
|
||||||
h.add(pt);
|
h.add(pt);
|
||||||
@ -228,13 +229,14 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
|
|
||||||
// ccw returns true if the three points make a counter-clockwise turn
|
// ccw returns true if the three points make a counter-clockwise turn
|
||||||
private boolean ccw(Point a, Point b, Point c) {
|
private boolean ccw(Point a, Point b, Point c) {
|
||||||
return ((b.getLongitude() - a.getLongitude())
|
return ((b.getLongitude() - a.getLongitude()) * (c.getLatitude()
|
||||||
* (c.getLatitude() - a.getLatitude())) > ((b.getLatitude() - a.getLatitude())
|
- a.getLatitude())) > ((b.getLatitude() - a.getLatitude())
|
||||||
* (c.getLongitude() - a.getLongitude()));
|
* (c.getLongitude() - a.getLongitude()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapViewPointSetOverlay() {
|
public MapViewPointSetOverlay() {
|
||||||
super(new Layer[] { new Polygon(GRAPHIC_FACTORY.createPaint(), null, GRAPHIC_FACTORY) },
|
super(new Layer[] {
|
||||||
|
new Polygon(GRAPHIC_FACTORY.createPaint(), null, GRAPHIC_FACTORY) },
|
||||||
Color.BLACK);
|
Color.BLACK);
|
||||||
polygon = (Polygon) this.layers[0];
|
polygon = (Polygon) this.layers[0];
|
||||||
}
|
}
|
||||||
@ -242,13 +244,12 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
@Override
|
@Override
|
||||||
public void setColor(Color color) {
|
public void setColor(Color color) {
|
||||||
super.setColor(color);
|
super.setColor(color);
|
||||||
polygon.getPaintFill().setColor(GRAPHIC_FACTORY.createColor(100, color.getRed(),
|
polygon.getPaintFill().setColor(GRAPHIC_FACTORY.createColor(100,
|
||||||
color.getGreen(), color.getBlue()));
|
color.getRed(), color.getGreen(), color.getBlue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWidth(int width) {
|
public void setWidth(int width) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWidthAndColor(int width, Color color) {
|
public void setWidthAndColor(int width, Color color) {
|
||||||
@ -260,7 +261,8 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
public void addPoint(Point point) {
|
public void addPoint(Point point) {
|
||||||
points.add(point);
|
points.add(point);
|
||||||
this.points = convexHull(points);
|
this.points = convexHull(points);
|
||||||
polygon.setPoints(this.points.stream().map(MapViewDrawing.this::convertPoint)
|
polygon.setPoints(
|
||||||
|
this.points.stream().map(MapViewDrawing.this::convertPoint)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
polygon.requestRedraw();
|
polygon.requestRedraw();
|
||||||
}
|
}
|
||||||
@ -347,7 +349,8 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
public void paint(Graphics graphics) {
|
public void paint(Graphics graphics) {
|
||||||
super.paint(graphics);
|
super.paint(graphics);
|
||||||
if (this.zoomControls != null) {
|
if (this.zoomControls != null) {
|
||||||
this.zoomControls.setZoomLevel(this.getModel().mapViewPosition.getZoomLevel());
|
this.zoomControls
|
||||||
|
.setZoomLevel(this.getModel().mapViewPosition.getZoomLevel());
|
||||||
this.zoomControls.draw((Graphics2D) graphics,
|
this.zoomControls.draw((Graphics2D) graphics,
|
||||||
getWidth() - this.zoomControls.getWidth() - 20,
|
getWidth() - this.zoomControls.getWidth() - 20,
|
||||||
this.getHeight() - this.zoomControls.getHeight() - 10, this);
|
this.getHeight() - this.zoomControls.getHeight() - 10, this);
|
||||||
@ -374,8 +377,9 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
@Override
|
@Override
|
||||||
public void clearOverlays() {
|
public void clearOverlays() {
|
||||||
Layers layers = getLayerManager().getLayers();
|
Layers layers = getLayerManager().getLayers();
|
||||||
for (Layer layer: layers) {
|
for (Layer layer : layers) {
|
||||||
if (layer instanceof PolylineAutoScaling || layer instanceof MarkerAutoScaling) {
|
if (layer instanceof PolylineAutoScaling
|
||||||
|
|| layer instanceof MarkerAutoScaling) {
|
||||||
getLayerManager().getLayers().remove(layer, false);
|
getLayerManager().getLayers().remove(layer, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -389,17 +393,20 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
private TileRendererLayer createTileRendererLayer(TileCache tileCache,
|
private TileRendererLayer createTileRendererLayer(TileCache tileCache,
|
||||||
MapDataStore mapDataStore, IMapViewPosition mapViewPosition,
|
MapDataStore mapDataStore, IMapViewPosition mapViewPosition,
|
||||||
HillsRenderConfig hillsRenderConfig) {
|
HillsRenderConfig hillsRenderConfig) {
|
||||||
TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore,
|
TileRendererLayer tileRendererLayer =
|
||||||
mapViewPosition, false, true, false, GRAPHIC_FACTORY, hillsRenderConfig) {
|
new TileRendererLayer(tileCache, mapDataStore, mapViewPosition, false,
|
||||||
|
true, false, GRAPHIC_FACTORY, hillsRenderConfig) {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTap(LatLong tapLatLong, org.mapsforge.core.model.Point layerXY,
|
public boolean onTap(LatLong tapLatLong,
|
||||||
|
org.mapsforge.core.model.Point layerXY,
|
||||||
org.mapsforge.core.model.Point tapXY) {
|
org.mapsforge.core.model.Point tapXY) {
|
||||||
if (zoomControls.contains(new java.awt.Point((int) tapXY.x, (int) tapXY.y))) {
|
if (zoomControls.contains(
|
||||||
|
new java.awt.Point((int) tapXY.x, (int) tapXY.y))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Point pt = new Point((float) tapLatLong.getLongitude(),
|
Point pt = new Point((float) tapLatLong.getLongitude(),
|
||||||
(float) tapLatLong.getLatitude());
|
(float) tapLatLong.getLatitude());
|
||||||
for (DrawingClickListener listener: MapViewDrawing.this.drawingClickListeners) {
|
for (DrawingClickListener listener : MapViewDrawing.this.drawingClickListeners) {
|
||||||
listener.mouseClicked(pt);
|
listener.mouseClicked(pt);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -426,9 +433,10 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MarkerOverlay drawMarker(Point point, Color outer, Color inner, AlphaMode mode) {
|
public MarkerOverlay drawMarker(Point point, Color outer, Color inner,
|
||||||
return new MapViewMarkerOverlay(createMarker(point, outer, inner, mode), outer, inner,
|
AlphaMode mode) {
|
||||||
mode);
|
return new MapViewMarkerOverlay(createMarker(point, outer, inner, mode), outer,
|
||||||
|
inner, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -448,24 +456,26 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
// Tile cache
|
// Tile cache
|
||||||
TileCache tileCache = AwtUtil.createTileCache(tileSize,
|
TileCache tileCache = AwtUtil.createTileCache(tileSize,
|
||||||
getModel().frameBufferModel.getOverdrawFactor(), 1024,
|
getModel().frameBufferModel.getOverdrawFactor(), 1024,
|
||||||
new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()));
|
new File(System.getProperty("java.io.tmpdir"),
|
||||||
|
UUID.randomUUID().toString()));
|
||||||
|
|
||||||
// Layers
|
// Layers
|
||||||
Layers layers = getLayerManager().getLayers();
|
Layers layers = getLayerManager().getLayers();
|
||||||
|
|
||||||
MapDataStore mapDataStore = new MapFile(file);
|
MapDataStore mapDataStore = new MapFile(file);
|
||||||
TileRendererLayer tileRendererLayer = createTileRendererLayer(tileCache, mapDataStore,
|
TileRendererLayer tileRendererLayer = createTileRendererLayer(tileCache,
|
||||||
getModel().mapViewPosition, null);
|
mapDataStore, getModel().mapViewPosition, null);
|
||||||
layers.add(tileRendererLayer);
|
layers.add(tileRendererLayer);
|
||||||
BoundingBox boundingBox = mapDataStore.boundingBox();
|
BoundingBox boundingBox = mapDataStore.boundingBox();
|
||||||
|
|
||||||
final Model model = getModel();
|
final Model model = getModel();
|
||||||
if (model.mapViewPosition.getZoomLevel() == 0
|
if (model.mapViewPosition.getZoomLevel() == 0
|
||||||
|| !boundingBox.contains(model.mapViewPosition.getCenter())) {
|
|| !boundingBox.contains(model.mapViewPosition.getCenter())) {
|
||||||
byte zoomLevel = LatLongUtils.zoomForBounds(model.mapViewDimension.getDimension(),
|
byte zoomLevel =
|
||||||
|
LatLongUtils.zoomForBounds(model.mapViewDimension.getDimension(),
|
||||||
boundingBox, model.displayModel.getTileSize());
|
boundingBox, model.displayModel.getTileSize());
|
||||||
model.mapViewPosition
|
model.mapViewPosition.setMapPosition(
|
||||||
.setMapPosition(new MapPosition(boundingBox.getCenterPoint(), zoomLevel));
|
new MapPosition(boundingBox.getCenterPoint(), zoomLevel));
|
||||||
zoomControls.setZoomLevel(zoomLevel);
|
zoomControls.setZoomLevel(zoomLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,16 +495,17 @@ public class MapViewDrawing extends MapView implements Drawing {
|
|||||||
public PathOverlay drawPath(Path path, Color color, boolean markers) {
|
public PathOverlay drawPath(Path path, Color color, boolean markers) {
|
||||||
PolylineAutoScaling line = new PolylineAutoScaling(1, color);
|
PolylineAutoScaling line = new PolylineAutoScaling(1, color);
|
||||||
ArrayList<Point> points = new ArrayList<>(path.getArcs().size() * 4);
|
ArrayList<Point> points = new ArrayList<>(path.getArcs().size() * 4);
|
||||||
for (Arc arc: path.getArcs()) {
|
for (Arc arc : path.getArcs()) {
|
||||||
points.addAll(arc.getPoints());
|
points.addAll(arc.getPoints());
|
||||||
}
|
}
|
||||||
line.addAll(points);
|
line.addAll(points);
|
||||||
PathOverlay overlay = null;
|
PathOverlay overlay = null;
|
||||||
if (markers) {
|
if (markers) {
|
||||||
MarkerAutoScaling origin = createMarker(path.getOrigin().getPoint(), color, color,
|
MarkerAutoScaling origin =
|
||||||
|
createMarker(path.getOrigin().getPoint(), color, color,
|
||||||
AlphaMode.TRANSPARENT),
|
AlphaMode.TRANSPARENT),
|
||||||
destination = createMarker(path.getDestination().getPoint(), color, color,
|
destination = createMarker(path.getDestination().getPoint(), color,
|
||||||
AlphaMode.TRANSPARENT);
|
color, AlphaMode.TRANSPARENT);
|
||||||
overlay = new MapViewPathOverlay(line, origin, destination);
|
overlay = new MapViewPathOverlay(line, origin, destination);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -61,8 +61,8 @@ public class MapZoomControls {
|
|||||||
private final List<ActionListener> zoomInListeners = new ArrayList<>();
|
private final List<ActionListener> zoomInListeners = new ArrayList<>();
|
||||||
private final List<ActionListener> zoomOutListeners = new ArrayList<>();
|
private final List<ActionListener> zoomOutListeners = new ArrayList<>();
|
||||||
|
|
||||||
public MapZoomControls(Component component, final int defaultZoom, final int minZoom,
|
public MapZoomControls(Component component, final int defaultZoom,
|
||||||
final int maxZoom) throws IOException {
|
final int minZoom, final int maxZoom) throws IOException {
|
||||||
|
|
||||||
zoomIn = ImageIO.read(getClass().getResourceAsStream("/zoomIn.png"))
|
zoomIn = ImageIO.read(getClass().getResourceAsStream("/zoomIn.png"))
|
||||||
.getScaledInstance(DEFAULT_HEIGHT, DEFAULT_HEIGHT, Image.SCALE_SMOOTH);
|
.getScaledInstance(DEFAULT_HEIGHT, DEFAULT_HEIGHT, Image.SCALE_SMOOTH);
|
||||||
@ -76,7 +76,8 @@ public class MapZoomControls {
|
|||||||
component.addMouseMotionListener(new MouseAdapter() {
|
component.addMouseMotionListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {
|
||||||
if (zoomInRect.contains(e.getPoint()) || zoomOutRect.contains(e.getPoint())) {
|
if (zoomInRect.contains(e.getPoint())
|
||||||
|
|| zoomOutRect.contains(e.getPoint())) {
|
||||||
component.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
component.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -90,16 +91,17 @@ public class MapZoomControls {
|
|||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if (zoomInRect.contains(e.getPoint()) && currentLevel < maxLevel) {
|
if (zoomInRect.contains(e.getPoint()) && currentLevel < maxLevel) {
|
||||||
currentLevel += 1;
|
currentLevel += 1;
|
||||||
for (ActionListener al: zoomInListeners) {
|
for (ActionListener al : zoomInListeners) {
|
||||||
al.actionPerformed(
|
al.actionPerformed(new ActionEvent(this, ZOOM_IN_ACTION_ID,
|
||||||
new ActionEvent(this, ZOOM_IN_ACTION_ID, ZOOM_IN_ACTION_NAME));
|
ZOOM_IN_ACTION_NAME));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (zoomOutRect.contains(e.getPoint()) && currentLevel > minLevel) {
|
else if (zoomOutRect.contains(e.getPoint())
|
||||||
|
&& currentLevel > minLevel) {
|
||||||
currentLevel -= 1;
|
currentLevel -= 1;
|
||||||
for (ActionListener al: zoomOutListeners) {
|
for (ActionListener al : zoomOutListeners) {
|
||||||
al.actionPerformed(
|
al.actionPerformed(new ActionEvent(this, ZOOM_OUT_ACTION_ID,
|
||||||
new ActionEvent(this, ZOOM_OUT_ACTION_ID, ZOOM_OUT_ACTION_NAME));
|
ZOOM_OUT_ACTION_NAME));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
component.repaint();
|
component.repaint();
|
||||||
@ -152,24 +154,23 @@ public class MapZoomControls {
|
|||||||
* @return Width of this "component" when drawn.
|
* @return Width of this "component" when drawn.
|
||||||
*/
|
*/
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
return DEFAULT_HEIGHT + 2 + (this.maxLevel - this.minLevel) * DEFAULT_SPACING + 1 + 2
|
return DEFAULT_HEIGHT + 2 + (this.maxLevel - this.minLevel) * DEFAULT_SPACING
|
||||||
+ DEFAULT_HEIGHT;
|
+ 1 + 2 + DEFAULT_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a point is contained inside an element of this zoom controls, useful
|
* Check if a point is contained inside an element of this zoom controls, useful to
|
||||||
* to avoid spurious click listeners.
|
* avoid spurious click listeners.
|
||||||
*
|
*
|
||||||
* @param point Point to check.
|
* @param point Point to check.
|
||||||
*
|
* @return true if the given point correspond to an element of this zoom controls.
|
||||||
* @return true if the given point correspond to an element of this zoom
|
|
||||||
* controls.
|
|
||||||
*/
|
*/
|
||||||
public boolean contains(Point point) {
|
public boolean contains(Point point) {
|
||||||
return zoomInRect.contains(point) || zoomOutRect.contains(point);
|
return zoomInRect.contains(point) || zoomOutRect.contains(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void draw(Graphics2D g, int xoffset, int yoffset, ImageObserver observer) {
|
protected void draw(Graphics2D g, int xoffset, int yoffset,
|
||||||
|
ImageObserver observer) {
|
||||||
|
|
||||||
int height = getHeight();
|
int height = getHeight();
|
||||||
|
|
||||||
|
@ -11,7 +11,8 @@ import java.awt.geom.AffineTransform;
|
|||||||
import java.awt.geom.NoninvertibleTransformException;
|
import java.awt.geom.NoninvertibleTransformException;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
public class ZoomAndPanListener implements MouseListener, MouseMotionListener, MouseWheelListener {
|
public class ZoomAndPanListener
|
||||||
|
implements MouseListener, MouseMotionListener, MouseWheelListener {
|
||||||
public static final int DEFAULT_MIN_ZOOM_LEVEL = -20;
|
public static final int DEFAULT_MIN_ZOOM_LEVEL = -20;
|
||||||
public static final int DEFAULT_MAX_ZOOM_LEVEL = 10;
|
public static final int DEFAULT_MAX_ZOOM_LEVEL = 10;
|
||||||
public static final double DEFAULT_ZOOM_MULTIPLICATION_FACTOR = 1.2;
|
public static final double DEFAULT_ZOOM_MULTIPLICATION_FACTOR = 1.2;
|
||||||
@ -31,8 +32,8 @@ public class ZoomAndPanListener implements MouseListener, MouseMotionListener, M
|
|||||||
this.targetComponent = targetComponent;
|
this.targetComponent = targetComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZoomAndPanListener(Component targetComponent, int minZoomLevel, int maxZoomLevel,
|
public ZoomAndPanListener(Component targetComponent, int minZoomLevel,
|
||||||
double zoomMultiplicationFactor) {
|
int maxZoomLevel, double zoomMultiplicationFactor) {
|
||||||
this.targetComponent = targetComponent;
|
this.targetComponent = targetComponent;
|
||||||
this.minZoomLevel = minZoomLevel;
|
this.minZoomLevel = minZoomLevel;
|
||||||
this.maxZoomLevel = maxZoomLevel;
|
this.maxZoomLevel = maxZoomLevel;
|
||||||
@ -44,25 +45,20 @@ public class ZoomAndPanListener implements MouseListener, MouseMotionListener, M
|
|||||||
targetComponent.repaint();
|
targetComponent.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {}
|
||||||
}
|
|
||||||
|
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
dragStartScreen = e.getPoint();
|
dragStartScreen = e.getPoint();
|
||||||
dragEndScreen = null;
|
dragEndScreen = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {}
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {}
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {}
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseMoved(MouseEvent e) {
|
public void mouseMoved(MouseEvent e) {}
|
||||||
}
|
|
||||||
|
|
||||||
public void mouseDragged(MouseEvent e) {
|
public void mouseDragged(MouseEvent e) {
|
||||||
moveCamera(e);
|
moveCamera(e);
|
||||||
@ -97,9 +93,11 @@ public class ZoomAndPanListener implements MouseListener, MouseMotionListener, M
|
|||||||
if (zoomLevel < maxZoomLevel) {
|
if (zoomLevel < maxZoomLevel) {
|
||||||
zoomLevel++;
|
zoomLevel++;
|
||||||
Point2D p1 = transformPoint(p);
|
Point2D p1 = transformPoint(p);
|
||||||
coordTransform.scale(zoomMultiplicationFactor, zoomMultiplicationFactor);
|
coordTransform.scale(zoomMultiplicationFactor,
|
||||||
|
zoomMultiplicationFactor);
|
||||||
Point2D p2 = transformPoint(p);
|
Point2D p2 = transformPoint(p);
|
||||||
coordTransform.translate(p2.getX() - p1.getX(), p2.getY() - p1.getY());
|
coordTransform.translate(p2.getX() - p1.getX(),
|
||||||
|
p2.getY() - p1.getY());
|
||||||
targetComponent.repaint();
|
targetComponent.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,7 +108,8 @@ public class ZoomAndPanListener implements MouseListener, MouseMotionListener, M
|
|||||||
coordTransform.scale(1 / zoomMultiplicationFactor,
|
coordTransform.scale(1 / zoomMultiplicationFactor,
|
||||||
1 / zoomMultiplicationFactor);
|
1 / zoomMultiplicationFactor);
|
||||||
Point2D p2 = transformPoint(p);
|
Point2D p2 = transformPoint(p);
|
||||||
coordTransform.translate(p2.getX() - p1.getX(), p2.getY() - p1.getY());
|
coordTransform.translate(p2.getX() - p1.getX(),
|
||||||
|
p2.getY() - p1.getY());
|
||||||
targetComponent.repaint();
|
targetComponent.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,7 +119,8 @@ public class ZoomAndPanListener implements MouseListener, MouseMotionListener, M
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point2D.Float transformPoint(Point p1) throws NoninvertibleTransformException {
|
private Point2D.Float transformPoint(Point p1)
|
||||||
|
throws NoninvertibleTransformException {
|
||||||
|
|
||||||
AffineTransform inverse = coordTransform.createInverse();
|
AffineTransform inverse = coordTransform.createInverse();
|
||||||
|
|
||||||
@ -139,7 +139,8 @@ public class ZoomAndPanListener implements MouseListener, MouseMotionListener, M
|
|||||||
|
|
||||||
public void zoomIn() {
|
public void zoomIn() {
|
||||||
try {
|
try {
|
||||||
Point p = new Point(targetComponent.getWidth() / 2, targetComponent.getHeight() / 2);
|
Point p = new Point(targetComponent.getWidth() / 2,
|
||||||
|
targetComponent.getHeight() / 2);
|
||||||
zoomLevel++;
|
zoomLevel++;
|
||||||
Point2D p1 = transformPoint(p);
|
Point2D p1 = transformPoint(p);
|
||||||
coordTransform.scale(zoomMultiplicationFactor, zoomMultiplicationFactor);
|
coordTransform.scale(zoomMultiplicationFactor, zoomMultiplicationFactor);
|
||||||
@ -154,10 +155,12 @@ public class ZoomAndPanListener implements MouseListener, MouseMotionListener, M
|
|||||||
|
|
||||||
public void zoomOut() {
|
public void zoomOut() {
|
||||||
try {
|
try {
|
||||||
Point p = new Point(targetComponent.getWidth() / 2, targetComponent.getHeight() / 2);
|
Point p = new Point(targetComponent.getWidth() / 2,
|
||||||
|
targetComponent.getHeight() / 2);
|
||||||
zoomLevel--;
|
zoomLevel--;
|
||||||
Point2D p1 = transformPoint(p);
|
Point2D p1 = transformPoint(p);
|
||||||
coordTransform.scale(1 / zoomMultiplicationFactor, 1 / zoomMultiplicationFactor);
|
coordTransform.scale(1 / zoomMultiplicationFactor,
|
||||||
|
1 / zoomMultiplicationFactor);
|
||||||
Point2D p2 = transformPoint(p);
|
Point2D p2 = transformPoint(p);
|
||||||
coordTransform.translate(p2.getX() - p1.getX(), p2.getY() - p1.getY());
|
coordTransform.translate(p2.getX() - p1.getX(), p2.getY() - p1.getY());
|
||||||
targetComponent.repaint();
|
targetComponent.repaint();
|
||||||
|
@ -12,11 +12,9 @@ import org.mapsforge.map.awt.graphics.AwtBitmap;
|
|||||||
import org.mapsforge.map.layer.overlay.Marker;
|
import org.mapsforge.map.layer.overlay.Marker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class extending the default Mapsforge's {@link Marker} with auto-scaling.
|
* Class extending the default Mapsforge's {@link Marker} with auto-scaling. Mapsforge's
|
||||||
*
|
* Markers do not scale with zoom level, this class aims at correcting this. Internally,
|
||||||
* Mapsforge's Markers do not scale with zoom level, this class aims at
|
* this image stores an {@link Image} instance and scale it when a redraw is requested.
|
||||||
* correcting this. Internally, this image stores an {@link Image} instance and
|
|
||||||
* scale it when a redraw is requested.
|
|
||||||
*
|
*
|
||||||
* @see MarkerUtils#getMarkerForColor(java.awt.Color, java.awt.Color,
|
* @see MarkerUtils#getMarkerForColor(java.awt.Color, java.awt.Color,
|
||||||
* org.insa.graphics.drawing.Drawing.AlphaMode)
|
* org.insa.graphics.drawing.Drawing.AlphaMode)
|
||||||
@ -55,15 +53,15 @@ public class MarkerAutoScaling extends Marker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas,
|
public synchronized void draw(BoundingBox boundingBox, byte zoomLevel,
|
||||||
Point topLeftPoint) {
|
Canvas canvas, Point topLeftPoint) {
|
||||||
int width = (int) PaintUtils.getStrokeWidth(8, zoomLevel),
|
int width = (int) PaintUtils.getStrokeWidth(8, zoomLevel),
|
||||||
height = (int) PaintUtils.getStrokeWidth(16, zoomLevel);
|
height = (int) PaintUtils.getStrokeWidth(16, zoomLevel);
|
||||||
BufferedImage bfd = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
|
BufferedImage bfd =
|
||||||
|
new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
|
||||||
Graphics2D g = bfd.createGraphics();
|
Graphics2D g = bfd.createGraphics();
|
||||||
g.drawImage(
|
g.drawImage(this.image.getScaledInstance(bfd.getWidth(), bfd.getHeight(),
|
||||||
this.image.getScaledInstance(bfd.getWidth(), bfd.getHeight(), Image.SCALE_SMOOTH),
|
Image.SCALE_SMOOTH), 0, 0, null);
|
||||||
0, 0, null);
|
|
||||||
setBitmap(new AwtBitmap(bfd));
|
setBitmap(new AwtBitmap(bfd));
|
||||||
|
|
||||||
setVerticalOffset(-height / 2);
|
setVerticalOffset(-height / 2);
|
||||||
|
@ -16,7 +16,6 @@ public class MarkerUtils {
|
|||||||
* @param outer Outer color of the marker.
|
* @param outer Outer color of the marker.
|
||||||
* @param inner Inner color of the marker.
|
* @param inner Inner color of the marker.
|
||||||
* @param mode Mode to use to fill the inner part of the marker.
|
* @param mode Mode to use to fill the inner part of the marker.
|
||||||
*
|
|
||||||
* @return An image representing a marker.
|
* @return An image representing a marker.
|
||||||
*/
|
*/
|
||||||
public static Image getMarkerForColor(Color outer, Color inner, AlphaMode mode) {
|
public static Image getMarkerForColor(Color outer, Color inner, AlphaMode mode) {
|
||||||
@ -31,23 +30,28 @@ public class MarkerUtils {
|
|||||||
for (int j = 0; j < image.getWidth(); ++j) {
|
for (int j = 0; j < image.getWidth(); ++j) {
|
||||||
|
|
||||||
// If we are in the "inner" part of the marker...
|
// If we are in the "inner" part of the marker...
|
||||||
if (i >= MIN_Y_CENTER && i < MAX_Y_CENTER && j >= MIN_X_CENTER && j < MAX_X_CENTER
|
if (i >= MIN_Y_CENTER && i < MAX_Y_CENTER && j >= MIN_X_CENTER
|
||||||
&& mask[i][j] != MAXIMUM_INNER_MASK_VALUE) {
|
&& j < MAX_X_CENTER && mask[i][j] != MAXIMUM_INNER_MASK_VALUE) {
|
||||||
// Don't ask... https://stackoverflow.com/a/29321264/2666289
|
// Don't ask... https://stackoverflow.com/a/29321264/2666289
|
||||||
// Basically, this compute a "middle" color between outer and inner depending on
|
// Basically, this compute a "middle" color between outer and inner
|
||||||
|
// depending on
|
||||||
// the current mask value.
|
// the current mask value.
|
||||||
double t = 1 - (mask[i][j] - MINIMUM_INNER_MASK_VALUE)
|
double t = 1 - (mask[i][j] - MINIMUM_INNER_MASK_VALUE)
|
||||||
/ (double) (MAXIMUM_INNER_MASK_VALUE - MINIMUM_INNER_MASK_VALUE);
|
/ (double) (MAXIMUM_INNER_MASK_VALUE
|
||||||
|
- MINIMUM_INNER_MASK_VALUE);
|
||||||
int r = (int) Math.sqrt((1 - t) * outer.getRed() * outer.getRed()
|
int r = (int) Math.sqrt((1 - t) * outer.getRed() * outer.getRed()
|
||||||
+ t * inner.getRed() * inner.getRed());
|
+ t * inner.getRed() * inner.getRed());
|
||||||
int g = (int) Math.sqrt((1 - t) * outer.getGreen() * outer.getGreen()
|
int g = (int) Math
|
||||||
|
.sqrt((1 - t) * outer.getGreen() * outer.getGreen()
|
||||||
+ t * inner.getGreen() * inner.getGreen());
|
+ t * inner.getGreen() * inner.getGreen());
|
||||||
int b = (int) Math.sqrt((1 - t) * outer.getBlue() * outer.getBlue()
|
int b = (int) Math.sqrt((1 - t) * outer.getBlue() * outer.getBlue()
|
||||||
+ t * inner.getBlue() * inner.getBlue());
|
+ t * inner.getBlue() * inner.getBlue());
|
||||||
int a = mode == AlphaMode.OPAQUE ? MAXIMUM_INNER_MASK_VALUE : mask[i][j];
|
int a = mode == AlphaMode.OPAQUE ? MAXIMUM_INNER_MASK_VALUE
|
||||||
|
: mask[i][j];
|
||||||
image.setRGB(j, i, (a << 24) | (r << 16) | (g << 8) | b);
|
image.setRGB(j, i, (a << 24) | (r << 16) | (g << 8) | b);
|
||||||
}
|
}
|
||||||
// Otherwize, just fill with the outer color and set the alpha value properly.
|
// Otherwize, just fill with the outer color and set the alpha value
|
||||||
|
// properly.
|
||||||
else {
|
else {
|
||||||
image.setRGB(j, i, outerRGB | (mask[i][j] << 24));
|
image.setRGB(j, i, outerRGB | (mask[i][j] << 24));
|
||||||
}
|
}
|
||||||
@ -64,7 +68,8 @@ public class MarkerUtils {
|
|||||||
// with a different color.
|
// with a different color.
|
||||||
private static final int MIN_X_CENTER = 40, MAX_X_CENTER = 101, MIN_Y_CENTER = 40,
|
private static final int MIN_X_CENTER = 40, MAX_X_CENTER = 101, MIN_Y_CENTER = 40,
|
||||||
MAX_Y_CENTER = 100;
|
MAX_Y_CENTER = 100;
|
||||||
private static final int MINIMUM_INNER_MASK_VALUE = 116, MAXIMUM_INNER_MASK_VALUE = 249;
|
private static final int MINIMUM_INNER_MASK_VALUE = 116,
|
||||||
|
MAXIMUM_INNER_MASK_VALUE = 249;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Retrieve the mask from the mask file or from the cache.
|
* @return Retrieve the mask from the mask file or from the cache.
|
||||||
|
@ -16,19 +16,17 @@ public class PaintUtils {
|
|||||||
* Convert the given AWT color to a mapsforge compatible color.
|
* Convert the given AWT color to a mapsforge compatible color.
|
||||||
*
|
*
|
||||||
* @param color AWT color to convert.
|
* @param color AWT color to convert.
|
||||||
*
|
|
||||||
* @return Integer value representing a corresponding mapsforge color.
|
* @return Integer value representing a corresponding mapsforge color.
|
||||||
*/
|
*/
|
||||||
public static int convertColor(Color color) {
|
public static int convertColor(Color color) {
|
||||||
return GRAPHIC_FACTORY.createColor(color.getAlpha(), color.getRed(), color.getGreen(),
|
return GRAPHIC_FACTORY.createColor(color.getAlpha(), color.getRed(),
|
||||||
color.getBlue());
|
color.getGreen(), color.getBlue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the given mapsforge color to an AWT Color.
|
* Convert the given mapsforge color to an AWT Color.
|
||||||
*
|
*
|
||||||
* @param color Integer value representing a mapsforge color.
|
* @param color Integer value representing a mapsforge color.
|
||||||
*
|
|
||||||
* @return AWT color corresponding to the given value.
|
* @return AWT color corresponding to the given value.
|
||||||
*/
|
*/
|
||||||
public static Color convertColor(int color) {
|
public static Color convertColor(int color) {
|
||||||
@ -37,12 +35,11 @@ public class PaintUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute an updated value for the given width at the given zoom level. This
|
* Compute an updated value for the given width at the given zoom level. This
|
||||||
* function can be used to automatically scale {@link Polyline} or
|
* function can be used to automatically scale {@link Polyline} or {@link Marker}
|
||||||
* {@link Marker} when zooming (which is not done by default in Mapsforge).
|
* when zooming (which is not done by default in Mapsforge).
|
||||||
*
|
*
|
||||||
* @param width Original width to convert.
|
* @param width Original width to convert.
|
||||||
* @param zoomLevel Zoom level for which the width should be computed.
|
* @param zoomLevel Zoom level for which the width should be computed.
|
||||||
*
|
|
||||||
* @return Actual width at the given zoom level.
|
* @return Actual width at the given zoom level.
|
||||||
*/
|
*/
|
||||||
public static float getStrokeWidth(int width, byte zoomLevel) {
|
public static float getStrokeWidth(int width, byte zoomLevel) {
|
||||||
|
@ -25,7 +25,6 @@ public interface PointSetOverlay extends Overlay {
|
|||||||
* Add a new point using the current width and color.
|
* Add a new point using the current width and color.
|
||||||
*
|
*
|
||||||
* @param point Position of the point to add.
|
* @param point Position of the point to add.
|
||||||
*
|
|
||||||
* @see #setWidth(int)
|
* @see #setWidth(int)
|
||||||
* @see #setColor(Color)
|
* @see #setColor(Color)
|
||||||
*/
|
*/
|
||||||
@ -36,7 +35,6 @@ public interface PointSetOverlay extends Overlay {
|
|||||||
*
|
*
|
||||||
* @param point Position of the point to add.
|
* @param point Position of the point to add.
|
||||||
* @param width New default width for this overlay.
|
* @param width New default width for this overlay.
|
||||||
*
|
|
||||||
* @see #setWidth(int)
|
* @see #setWidth(int)
|
||||||
* @see PointSetOverlay#addPoint(Point)
|
* @see PointSetOverlay#addPoint(Point)
|
||||||
*/
|
*/
|
||||||
@ -47,20 +45,18 @@ public interface PointSetOverlay extends Overlay {
|
|||||||
*
|
*
|
||||||
* @param point Position of the point to add.
|
* @param point Position of the point to add.
|
||||||
* @param color New default color for this overlay.
|
* @param color New default color for this overlay.
|
||||||
*
|
|
||||||
* @see #setColor(Color)
|
* @see #setColor(Color)
|
||||||
* @see PointSetOverlay#addPoint(Point)
|
* @see PointSetOverlay#addPoint(Point)
|
||||||
*/
|
*/
|
||||||
public void addPoint(Point point, Color color);
|
public void addPoint(Point point, Color color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new point at the given location, with the given color and width, and
|
* Add a new point at the given location, with the given color and width, and update
|
||||||
* update the current width and color.
|
* the current width and color.
|
||||||
*
|
*
|
||||||
* @param point Position of the point to add.
|
* @param point Position of the point to add.
|
||||||
* @param width New default width for this overlay.
|
* @param width New default width for this overlay.
|
||||||
* @param color New default color for this overlay.
|
* @param color New default color for this overlay.
|
||||||
*
|
|
||||||
* @see #setWidth(int)
|
* @see #setWidth(int)
|
||||||
* @see #setColor(Color)
|
* @see #setColor(Color)
|
||||||
* @see PointSetOverlay#addPoint(Point)
|
* @see PointSetOverlay#addPoint(Point)
|
||||||
|
@ -15,10 +15,9 @@ import org.mapsforge.map.layer.overlay.Polyline;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class extending the default Mapsforge's {@link Polyline} with auto-scaling.
|
* Class extending the default Mapsforge's {@link Polyline} with auto-scaling.
|
||||||
*
|
* Mapsforge's Polylines do not scale with zoom level, this class aims at correcting
|
||||||
* Mapsforge's Polylines do not scale with zoom level, this class aims at
|
* this. When a redraw is requested, the width of the line is recomputed for the current
|
||||||
* correcting this. When a redraw is requested, the width of the line is
|
* zoom level.
|
||||||
* recomputed for the current zoom level.
|
|
||||||
*
|
*
|
||||||
* @see PaintUtils#getStrokeWidth(int, byte)
|
* @see PaintUtils#getStrokeWidth(int, byte)
|
||||||
*/
|
*/
|
||||||
@ -35,7 +34,6 @@ public class PolylineAutoScaling extends Polyline {
|
|||||||
*
|
*
|
||||||
* @param width Original width of the line (independent of the zoom level).
|
* @param width Original width of the line (independent of the zoom level).
|
||||||
* @param color Color of the line.
|
* @param color Color of the line.
|
||||||
*
|
|
||||||
* @see PaintUtils#getStrokeWidth(int, byte)
|
* @see PaintUtils#getStrokeWidth(int, byte)
|
||||||
*/
|
*/
|
||||||
public PolylineAutoScaling(int width, Color color) {
|
public PolylineAutoScaling(int width, Color color) {
|
||||||
@ -73,18 +71,19 @@ public class PolylineAutoScaling extends Polyline {
|
|||||||
*/
|
*/
|
||||||
public void addAll(Collection<? extends Point> points) {
|
public void addAll(Collection<? extends Point> points) {
|
||||||
ArrayList<LatLong> latlongs = new ArrayList<>(points.size());
|
ArrayList<LatLong> latlongs = new ArrayList<>(points.size());
|
||||||
for (Point point: points) {
|
for (Point point : points) {
|
||||||
latlongs.add(new LatLong(point.getLatitude(), point.getLongitude()));
|
latlongs.add(new LatLong(point.getLatitude(), point.getLongitude()));
|
||||||
}
|
}
|
||||||
getLatLongs().addAll(latlongs);
|
getLatLongs().addAll(latlongs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas,
|
public synchronized void draw(BoundingBox boundingBox, byte zoomLevel,
|
||||||
org.mapsforge.core.model.Point topLeftPoint) {
|
Canvas canvas, org.mapsforge.core.model.Point topLeftPoint) {
|
||||||
|
|
||||||
// Update paint stroke with width for level
|
// Update paint stroke with width for level
|
||||||
this.getPaintStroke().setStrokeWidth(PaintUtils.getStrokeWidth(width, zoomLevel));
|
this.getPaintStroke()
|
||||||
|
.setStrokeWidth(PaintUtils.getStrokeWidth(width, zoomLevel));
|
||||||
|
|
||||||
super.draw(boundingBox, zoomLevel, canvas, topLeftPoint);
|
super.draw(boundingBox, zoomLevel, canvas, topLeftPoint);
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,11 @@ import org.insa.graphs.gui.drawing.Drawing;
|
|||||||
import org.insa.graphs.gui.drawing.overlays.PointSetOverlay;
|
import org.insa.graphs.gui.drawing.overlays.PointSetOverlay;
|
||||||
import org.insa.graphs.model.Node;
|
import org.insa.graphs.model.Node;
|
||||||
|
|
||||||
public class WeaklyConnectedComponentGraphicObserver implements WeaklyConnectedComponentObserver {
|
public class WeaklyConnectedComponentGraphicObserver
|
||||||
|
implements WeaklyConnectedComponentObserver {
|
||||||
|
|
||||||
private static final Color[] COLORS = { Color.BLUE, Color.ORANGE, Color.GREEN, Color.YELLOW,
|
private static final Color[] COLORS =
|
||||||
Color.RED };
|
{ Color.BLUE, Color.ORANGE, Color.GREEN, Color.YELLOW, Color.RED };
|
||||||
|
|
||||||
// Drawing + Graph drawing
|
// Drawing + Graph drawing
|
||||||
private PointSetOverlay grPoints;
|
private PointSetOverlay grPoints;
|
||||||
|
@ -14,11 +14,11 @@ import javax.swing.filechooser.FileNameExtensionFilter;
|
|||||||
public class FileUtils {
|
public class FileUtils {
|
||||||
|
|
||||||
// Preferences
|
// Preferences
|
||||||
private static Preferences preferences = Preferences.userRoot().node(FileUtils.class.getName());
|
private static Preferences preferences =
|
||||||
|
Preferences.userRoot().node(FileUtils.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of folder with associated preferred folder and path filters.
|
* Type of folder with associated preferred folder and path filters.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public enum FolderType {
|
public enum FolderType {
|
||||||
|
|
||||||
@ -49,34 +49,35 @@ public class FileUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Map folder type -> PreferencesEntry
|
// Map folder type -> PreferencesEntry
|
||||||
private static final Map<FolderType, PreferencesEntry> folderToEntry = new EnumMap<>(
|
private static final Map<FolderType, PreferencesEntry> folderToEntry =
|
||||||
FolderType.class);
|
new EnumMap<>(FolderType.class);
|
||||||
|
|
||||||
// Map folder type -> File Filter
|
// Map folder type -> File Filter
|
||||||
private static final Map<FolderType, FileFilter> folderToFilter = new EnumMap<>(
|
private static final Map<FolderType, FileFilter> folderToFilter =
|
||||||
FolderType.class);
|
new EnumMap<>(FolderType.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// Populate folderToEntry
|
// Populate folderToEntry
|
||||||
folderToEntry.put(FolderType.Map, new PreferencesEntry("DefaultMapFolder",
|
folderToEntry.put(FolderType.Map, new PreferencesEntry("DefaultMapFolder",
|
||||||
"/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps"));
|
"/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps"));
|
||||||
folderToEntry.put(FolderType.PathInput, new PreferencesEntry("DefaultPathInputFolder",
|
folderToEntry.put(FolderType.PathInput,
|
||||||
|
new PreferencesEntry("DefaultPathInputFolder",
|
||||||
"/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Paths"));
|
"/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Paths"));
|
||||||
folderToEntry.put(FolderType.PathOutput,
|
folderToEntry.put(FolderType.PathOutput,
|
||||||
new PreferencesEntry("DefaultPathOutputsFolder", "paths"));
|
new PreferencesEntry("DefaultPathOutputsFolder", "paths"));
|
||||||
|
|
||||||
// Populate folderToFilter
|
// Populate folderToFilter
|
||||||
folderToFilter.put(FolderType.Map, new FileNameExtensionFilter("Graph files", "mapgr"));
|
folderToFilter.put(FolderType.Map,
|
||||||
folderToFilter.put(FolderType.PathInput, new FileNameExtensionFilter("Path files", "path"));
|
new FileNameExtensionFilter("Graph files", "mapgr"));
|
||||||
|
folderToFilter.put(FolderType.PathInput,
|
||||||
|
new FileNameExtensionFilter("Path files", "path"));
|
||||||
folderToFilter.put(FolderType.PathOutput,
|
folderToFilter.put(FolderType.PathOutput,
|
||||||
new FileNameExtensionFilter("Path files", "path"));
|
new FileNameExtensionFilter("Path files", "path"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param folderType Type of folder to retrieve.
|
* @param folderType Type of folder to retrieve.
|
||||||
*
|
|
||||||
* @return A File instance pointing to the preferred folder for the given type.
|
* @return A File instance pointing to the preferred folder for the given type.
|
||||||
*
|
|
||||||
* @see FolderType
|
* @see FolderType
|
||||||
*/
|
*/
|
||||||
public static File getPreferredFolder(FolderType folderType) {
|
public static File getPreferredFolder(FolderType folderType) {
|
||||||
@ -92,14 +93,14 @@ public class FileUtils {
|
|||||||
* @param folderType Type of folder to update.
|
* @param folderType Type of folder to update.
|
||||||
* @param newPreferredFolder New preferred folder.
|
* @param newPreferredFolder New preferred folder.
|
||||||
*/
|
*/
|
||||||
public static void updatePreferredFolder(FolderType folderType, File newPreferredFolder) {
|
public static void updatePreferredFolder(FolderType folderType,
|
||||||
|
File newPreferredFolder) {
|
||||||
PreferencesEntry entry = folderToEntry.get(folderType);
|
PreferencesEntry entry = folderToEntry.get(folderType);
|
||||||
preferences.put(entry.key, newPreferredFolder.getAbsolutePath());
|
preferences.put(entry.key, newPreferredFolder.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param folderType Type of folder for which the filter should be retrieved.
|
* @param folderType Type of folder for which the filter should be retrieved.
|
||||||
*
|
|
||||||
* @return A FileFilter corresponding to input graph files.
|
* @return A FileFilter corresponding to input graph files.
|
||||||
*/
|
*/
|
||||||
public static FileFilter getFileFilter(FolderType folderType) {
|
public static FileFilter getFileFilter(FolderType folderType) {
|
||||||
@ -108,17 +109,17 @@ public class FileUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param folderType Type of folder for which a file chooser should be created.
|
* @param folderType Type of folder for which a file chooser should be created.
|
||||||
* @param defaultFileName Default file name to show, or null to not show any
|
* @param defaultFileName Default file name to show, or null to not show any file.
|
||||||
* file.
|
|
||||||
*
|
|
||||||
* @return A new JFileChooser pointing to the preferred folder for the given
|
* @return A new JFileChooser pointing to the preferred folder for the given
|
||||||
* folderType, with the given default file selected (if given).
|
* folderType, with the given default file selected (if given).
|
||||||
*/
|
*/
|
||||||
public static JFileChooser createFileChooser(FolderType folderType, String defaultFileName) {
|
public static JFileChooser createFileChooser(FolderType folderType,
|
||||||
|
String defaultFileName) {
|
||||||
JFileChooser chooser = new JFileChooser();
|
JFileChooser chooser = new JFileChooser();
|
||||||
chooser.setCurrentDirectory(getPreferredFolder(folderType));
|
chooser.setCurrentDirectory(getPreferredFolder(folderType));
|
||||||
if (defaultFileName != null) {
|
if (defaultFileName != null) {
|
||||||
chooser.setSelectedFile(new File(chooser.getCurrentDirectory().getAbsolutePath()
|
chooser.setSelectedFile(
|
||||||
|
new File(chooser.getCurrentDirectory().getAbsolutePath()
|
||||||
+ File.separator + defaultFileName));
|
+ File.separator + defaultFileName));
|
||||||
}
|
}
|
||||||
chooser.setFileFilter(getFileFilter(folderType));
|
chooser.setFileFilter(getFileFilter(folderType));
|
||||||
@ -138,10 +139,8 @@ public class FileUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param folderType Type of folder for which a file chooser should be created.
|
* @param folderType Type of folder for which a file chooser should be created.
|
||||||
*
|
|
||||||
* @return A new JFileChooser pointing to the preferred folder for the given
|
* @return A new JFileChooser pointing to the preferred folder for the given
|
||||||
* folderType.
|
* folderType.
|
||||||
*
|
|
||||||
* @see #createFileChooser(FolderType, String)
|
* @see #createFileChooser(FolderType, String)
|
||||||
*/
|
*/
|
||||||
public static JFileChooser createFileChooser(FolderType folderType) {
|
public static JFileChooser createFileChooser(FolderType folderType) {
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<project
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
@ -7,18 +7,15 @@ import java.util.EnumSet;
|
|||||||
* <p>
|
* <p>
|
||||||
* Class containing access restrictions for roads/arcs.
|
* Class containing access restrictions for roads/arcs.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* This class maps transport modes to their restriction and provide interface
|
* This class maps transport modes to their restriction and provide interface based on
|
||||||
* based on EnumSet to query restrictions.
|
* EnumSet to query restrictions.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* To each transport is associated at most one restriction per road (no
|
* To each transport is associated at most one restriction per road (no restriction
|
||||||
* restriction corresponds to {@link AccessRestriction#UNKNOWN} but a road can
|
* corresponds to {@link AccessRestriction#UNKNOWN} but a road can have different
|
||||||
* have different restrictions for different modes.
|
* restrictions for different modes.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class AccessRestrictions {
|
public class AccessRestrictions {
|
||||||
|
|
||||||
@ -73,24 +70,20 @@ public class AccessRestrictions {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code EnumSet} containing all possible transport modes.
|
* {@code EnumSet} containing all possible transport modes.
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static final EnumSet<AccessMode> ALL = EnumSet.allOf(AccessMode.class);
|
public static final EnumSet<AccessMode> ALL = EnumSet.allOf(AccessMode.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code EnumSet} containing all vehicle transport modes.
|
* {@code EnumSet} containing all vehicle transport modes.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static final EnumSet<AccessMode> VEHICLE = EnumSet.range(AccessMode.BICYCLE,
|
public static final EnumSet<AccessMode> VEHICLE =
|
||||||
AccessMode.PUBLIC_TRANSPORT);
|
EnumSet.range(AccessMode.BICYCLE, AccessMode.PUBLIC_TRANSPORT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code EnumSet} containing all motorized vehicle transport modes.
|
* {@code EnumSet} containing all motorized vehicle transport modes.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static final EnumSet<AccessMode> MOTOR_VEHICLE = EnumSet
|
public static final EnumSet<AccessMode> MOTOR_VEHICLE =
|
||||||
.range(AccessMode.SMALL_MOTORCYCLE, AccessMode.PUBLIC_TRANSPORT);
|
EnumSet.range(AccessMode.SMALL_MOTORCYCLE, AccessMode.PUBLIC_TRANSPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,10 +137,9 @@ public class AccessRestrictions {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code EnumSet} corresponding to restrictions that are not totally private.
|
* {@code EnumSet} corresponding to restrictions that are not totally private.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static final EnumSet<AccessRestriction> ALLOWED_FOR_SOMETHING = EnumSet.of(
|
public static final EnumSet<AccessRestriction> ALLOWED_FOR_SOMETHING =
|
||||||
AccessRestriction.ALLOWED, AccessRestriction.DESTINATION,
|
EnumSet.of(AccessRestriction.ALLOWED, AccessRestriction.DESTINATION,
|
||||||
AccessRestriction.DESTINATION, AccessRestriction.DELIVERY,
|
AccessRestriction.DESTINATION, AccessRestriction.DELIVERY,
|
||||||
AccessRestriction.CUSTOMERS, AccessRestriction.FORESTRY);
|
AccessRestriction.CUSTOMERS, AccessRestriction.FORESTRY);
|
||||||
|
|
||||||
@ -161,7 +153,7 @@ public class AccessRestrictions {
|
|||||||
*/
|
*/
|
||||||
public AccessRestrictions() {
|
public AccessRestrictions() {
|
||||||
this.restrictions = new EnumMap<>(AccessMode.class);
|
this.restrictions = new EnumMap<>(AccessMode.class);
|
||||||
for (AccessMode mode: AccessMode.values()) {
|
for (AccessMode mode : AccessMode.values()) {
|
||||||
this.restrictions.put(mode, AccessRestriction.UNKNOWN);
|
this.restrictions.put(mode, AccessRestriction.UNKNOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,8 +161,7 @@ public class AccessRestrictions {
|
|||||||
/**
|
/**
|
||||||
* Create a new AccessRestrictions instances with the given restrictions.
|
* Create a new AccessRestrictions instances with the given restrictions.
|
||||||
*
|
*
|
||||||
* @param restrictions Map of restrictions for this instance of
|
* @param restrictions Map of restrictions for this instance of AccessRestrictions.
|
||||||
* AccessRestrictions.
|
|
||||||
*/
|
*/
|
||||||
public AccessRestrictions(EnumMap<AccessMode, AccessRestriction> restrictions) {
|
public AccessRestrictions(EnumMap<AccessMode, AccessRestriction> restrictions) {
|
||||||
this.restrictions = restrictions;
|
this.restrictions = restrictions;
|
||||||
@ -180,7 +171,6 @@ public class AccessRestrictions {
|
|||||||
* Retrieve the restriction corresponding to the given mode.
|
* Retrieve the restriction corresponding to the given mode.
|
||||||
*
|
*
|
||||||
* @param mode Mode for which the restriction should be retrieved.
|
* @param mode Mode for which the restriction should be retrieved.
|
||||||
*
|
|
||||||
* @return Restriction for the given mode.
|
* @return Restriction for the given mode.
|
||||||
*/
|
*/
|
||||||
public AccessRestriction getRestrictionFor(AccessMode mode) {
|
public AccessRestriction getRestrictionFor(AccessMode mode) {
|
||||||
@ -193,21 +183,19 @@ public class AccessRestrictions {
|
|||||||
*
|
*
|
||||||
* @param mode Mode for which to check the restrictions.
|
* @param mode Mode for which to check the restrictions.
|
||||||
* @param restrictions List of queried restrictions for the mode.
|
* @param restrictions List of queried restrictions for the mode.
|
||||||
*
|
|
||||||
* @return {@code true} if the restriction of the given mode is one of the given
|
* @return {@code true} if the restriction of the given mode is one of the given
|
||||||
* restrictions.
|
* restrictions.
|
||||||
*/
|
*/
|
||||||
public boolean isAllowedForAny(AccessMode mode, EnumSet<AccessRestriction> restrictions) {
|
public boolean isAllowedForAny(AccessMode mode,
|
||||||
|
EnumSet<AccessRestriction> restrictions) {
|
||||||
return restrictions.contains(getRestrictionFor(mode));
|
return restrictions.contains(getRestrictionFor(mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the restriction for the given mode corresponds to the given
|
* Check if the restriction for the given mode corresponds to the given restriction.
|
||||||
* restriction.
|
|
||||||
*
|
*
|
||||||
* @param mode Mode for which the restriction should be checked.
|
* @param mode Mode for which the restriction should be checked.
|
||||||
* @param restriction Restriction to check against.
|
* @param restriction Restriction to check against.
|
||||||
*
|
|
||||||
* @return {@code true} if the restriction of the given mode corresponds to the
|
* @return {@code true} if the restriction of the given mode corresponds to the
|
||||||
* given restriction.
|
* given restriction.
|
||||||
*/
|
*/
|
||||||
@ -221,7 +209,6 @@ public class AccessRestrictions {
|
|||||||
*
|
*
|
||||||
* @param modes Modes for which restrictions should be checked.
|
* @param modes Modes for which restrictions should be checked.
|
||||||
* @param restrictions Set of wanted restrictions for the modes.
|
* @param restrictions Set of wanted restrictions for the modes.
|
||||||
*
|
|
||||||
* @return {@code true} if all the given modes are allowed for any of the given
|
* @return {@code true} if all the given modes are allowed for any of the given
|
||||||
* restrictions.
|
* restrictions.
|
||||||
*/
|
*/
|
||||||
|
@ -4,18 +4,16 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Interface representing an arc in the graph. {@code Arc} is an interface and
|
* Interface representing an arc in the graph. {@code Arc} is an interface and not a
|
||||||
* not a class to allow us to represent two-ways roads in a memory efficient
|
* class to allow us to represent two-ways roads in a memory efficient manner (without
|
||||||
* manner (without having to duplicate attributes).
|
* having to duplicate attributes).
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* Arc should never be created manually but always using the
|
* Arc should never be created manually but always using the
|
||||||
* {@link Node#linkNodes(Node, Node, float, RoadInformation, java.util.ArrayList)}
|
* {@link Node#linkNodes(Node, Node, float, RoadInformation, java.util.ArrayList)}
|
||||||
* method to ensure proper instantiation of the {@link ArcForward} and
|
* method to ensure proper instantiation of the {@link ArcForward} and
|
||||||
* {@link ArcBackward} classes.
|
* {@link ArcBackward} classes.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class Arc {
|
public abstract class Arc {
|
||||||
|
|
||||||
@ -38,7 +36,6 @@ public abstract class Arc {
|
|||||||
* Compute the time required to travel this arc if moving at the given speed.
|
* Compute the time required to travel this arc if moving at the given speed.
|
||||||
*
|
*
|
||||||
* @param speed Speed to compute the travel time.
|
* @param speed Speed to compute the travel time.
|
||||||
*
|
|
||||||
* @return Time (in seconds) required to travel this arc at the given speed (in
|
* @return Time (in seconds) required to travel this arc at the given speed (in
|
||||||
* kilometers-per-hour).
|
* kilometers-per-hour).
|
||||||
*/
|
*/
|
||||||
@ -51,7 +48,6 @@ public abstract class Arc {
|
|||||||
* required to travel this arc at the maximum speed allowed.
|
* required to travel this arc at the maximum speed allowed.
|
||||||
*
|
*
|
||||||
* @return Minimum time required to travel this arc, in seconds.
|
* @return Minimum time required to travel this arc, in seconds.
|
||||||
*
|
|
||||||
* @see Arc#getTravelTime(double)
|
* @see Arc#getTravelTime(double)
|
||||||
*/
|
*/
|
||||||
public double getMinimumTravelTime() {
|
public double getMinimumTravelTime() {
|
||||||
|
@ -5,10 +5,8 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of Arc that represents a "backward" arc in a graph, i.e., an
|
* Implementation of Arc that represents a "backward" arc in a graph, i.e., an arc that
|
||||||
* arc that is the reverse of another one. This arc only holds a reference to
|
* is the reverse of another one. This arc only holds a reference to the original arc.
|
||||||
* the original arc.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class ArcBackward extends Arc {
|
class ArcBackward extends Arc {
|
||||||
|
|
||||||
@ -16,8 +14,7 @@ class ArcBackward extends Arc {
|
|||||||
private final Arc originalArc;
|
private final Arc originalArc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new backward arc which corresponds to the reverse arc of the given
|
* Create a new backward arc which corresponds to the reverse arc of the given arc.
|
||||||
* arc.
|
|
||||||
*
|
*
|
||||||
* @param originalArc Original forwarc arc corresponding to this backward arc.
|
* @param originalArc Original forwarc arc corresponding to this backward arc.
|
||||||
*/
|
*/
|
||||||
|
@ -4,9 +4,8 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of Arc that represents a "forward" arc in a graph, this is the
|
* Implementation of Arc that represents a "forward" arc in a graph, this is the arc
|
||||||
* arc implementation that stores data relative to the arc.
|
* implementation that stores data relative to the arc.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class ArcForward extends Arc {
|
class ArcForward extends Arc {
|
||||||
|
|
||||||
@ -31,8 +30,8 @@ class ArcForward extends Arc {
|
|||||||
* @param roadInformation Road information for this arc.
|
* @param roadInformation Road information for this arc.
|
||||||
* @param points Points representing this arc.
|
* @param points Points representing this arc.
|
||||||
*/
|
*/
|
||||||
protected ArcForward(Node origin, Node dest, float length, RoadInformation roadInformation,
|
protected ArcForward(Node origin, Node dest, float length,
|
||||||
List<Point> points) {
|
RoadInformation roadInformation, List<Point> points) {
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
this.destination = dest;
|
this.destination = dest;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
|
@ -8,12 +8,10 @@ import java.util.List;
|
|||||||
* <p>
|
* <p>
|
||||||
* Main graph class.
|
* Main graph class.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* This class acts as a object-oriented <b>adjacency list</b> for a graph, i.e.,
|
* This class acts as a object-oriented <b>adjacency list</b> for a graph, i.e., it
|
||||||
* it holds a list of nodes and each node holds a list of its successors.
|
* holds a list of nodes and each node holds a list of its successors.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class Graph {
|
public final class Graph {
|
||||||
|
|
||||||
@ -37,7 +35,8 @@ public final class Graph {
|
|||||||
* @param nodes List of nodes for this graph.
|
* @param nodes List of nodes for this graph.
|
||||||
* @param graphStatistics Information for this graph.
|
* @param graphStatistics Information for this graph.
|
||||||
*/
|
*/
|
||||||
public Graph(String mapId, String mapName, List<Node> nodes, GraphStatistics graphStatistics) {
|
public Graph(String mapId, String mapName, List<Node> nodes,
|
||||||
|
GraphStatistics graphStatistics) {
|
||||||
this.mapId = mapId;
|
this.mapId = mapId;
|
||||||
this.mapName = mapName;
|
this.mapName = mapName;
|
||||||
this.nodes = Collections.unmodifiableList(nodes);
|
this.nodes = Collections.unmodifiableList(nodes);
|
||||||
@ -52,12 +51,9 @@ public final class Graph {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the node with the given ID.
|
* Fetch the node with the given ID. Complexity: O(1).
|
||||||
*
|
|
||||||
* Complexity: O(1).
|
|
||||||
*
|
*
|
||||||
* @param id ID of the node to fetch.
|
* @param id ID of the node to fetch.
|
||||||
*
|
|
||||||
* @return Node with the given ID.
|
* @return Node with the given ID.
|
||||||
*/
|
*/
|
||||||
public Node get(int id) {
|
public Node get(int id) {
|
||||||
@ -73,7 +69,6 @@ public final class Graph {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return List of nodes in this graph (unmodifiable).
|
* @return List of nodes in this graph (unmodifiable).
|
||||||
*
|
|
||||||
* @see Collections#unmodifiableList(List)
|
* @see Collections#unmodifiableList(List)
|
||||||
*/
|
*/
|
||||||
public List<Node> getNodes() {
|
public List<Node> getNodes() {
|
||||||
@ -99,15 +94,16 @@ public final class Graph {
|
|||||||
*/
|
*/
|
||||||
public Graph transpose() {
|
public Graph transpose() {
|
||||||
final ArrayList<Node> trNodes = new ArrayList<>(nodes.size());
|
final ArrayList<Node> trNodes = new ArrayList<>(nodes.size());
|
||||||
for (Node node: nodes) {
|
for (Node node : nodes) {
|
||||||
trNodes.add(new Node(node.getId(), node.getPoint()));
|
trNodes.add(new Node(node.getId(), node.getPoint()));
|
||||||
}
|
}
|
||||||
for (Node node: nodes) {
|
for (Node node : nodes) {
|
||||||
final Node orig = trNodes.get(node.getId());
|
final Node orig = trNodes.get(node.getId());
|
||||||
for (Arc arc: node.getSuccessors()) {
|
for (Arc arc : node.getSuccessors()) {
|
||||||
if (arc.getRoadInformation().isOneWay()) {
|
if (arc.getRoadInformation().isOneWay()) {
|
||||||
final Node dest = trNodes.get(arc.getDestination().getId());
|
final Node dest = trNodes.get(arc.getDestination().getId());
|
||||||
dest.addSuccessor(new ArcBackward(new ArcForward(orig, dest, arc.getLength(),
|
dest.addSuccessor(
|
||||||
|
new ArcBackward(new ArcForward(orig, dest, arc.getLength(),
|
||||||
arc.getRoadInformation(), arc.getPoints())));
|
arc.getRoadInformation(), arc.getPoints())));
|
||||||
}
|
}
|
||||||
else if (arc instanceof ArcForward) {
|
else if (arc instanceof ArcForward) {
|
||||||
@ -124,8 +120,8 @@ public final class Graph {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%s[id=%s, name=%s, #nodes=%d]", getClass().getCanonicalName(),
|
return String.format("%s[id=%s, name=%s, #nodes=%d]",
|
||||||
getMapId(), getMapName(), size());
|
getClass().getCanonicalName(), getMapId(), getMapName(), size());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,30 +2,24 @@ package org.insa.graphs.model;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Utility class that stores some statistics of graphs that are not easy to
|
* Utility class that stores some statistics of graphs that are not easy to access.
|
||||||
* access.
|
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* This class is used to provide constant ({@code O(1)}) access to information
|
* This class is used to provide constant ({@code O(1)}) access to information in graph
|
||||||
* in graph that do not change, and that usually require linear complexity to
|
* that do not change, and that usually require linear complexity to compute.
|
||||||
* compute.
|
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class GraphStatistics {
|
public class GraphStatistics {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special value used to indicate that the graph has no maximum speed limit
|
* Special value used to indicate that the graph has no maximum speed limit (some
|
||||||
* (some roads are not limited).
|
* roads are not limited).
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static final int NO_MAXIMUM_SPEED = -1;
|
public static final int NO_MAXIMUM_SPEED = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing a bounding box for a graph (a rectangle that contains all
|
* Class representing a bounding box for a graph (a rectangle that contains all
|
||||||
* nodes in the graph).
|
* nodes in the graph).
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static class BoundingBox {
|
public static class BoundingBox {
|
||||||
|
|
||||||
@ -65,12 +59,12 @@ public class GraphStatistics {
|
|||||||
* @param top Extra size to add to the top of the box.
|
* @param top Extra size to add to the top of the box.
|
||||||
* @param right Extra size to add to the right of the box.
|
* @param right Extra size to add to the right of the box.
|
||||||
* @param bottom Extra size to add to the bottom of the box.
|
* @param bottom Extra size to add to the bottom of the box.
|
||||||
*
|
|
||||||
* @return New bounding box corresponding to an extension of the current one.
|
* @return New bounding box corresponding to an extension of the current one.
|
||||||
*/
|
*/
|
||||||
public BoundingBox extend(float left, float top, float right, float bottom) {
|
public BoundingBox extend(float left, float top, float right, float bottom) {
|
||||||
return new BoundingBox(
|
return new BoundingBox(
|
||||||
new Point(this.topLeft.getLongitude() - left, this.topLeft.getLatitude() + top),
|
new Point(this.topLeft.getLongitude() - left,
|
||||||
|
this.topLeft.getLatitude() + top),
|
||||||
new Point(this.bottomRight.getLongitude() + right,
|
new Point(this.bottomRight.getLongitude() + right,
|
||||||
this.bottomRight.getLatitude() - bottom));
|
this.bottomRight.getLatitude() - bottom));
|
||||||
}
|
}
|
||||||
@ -80,7 +74,6 @@ public class GraphStatistics {
|
|||||||
* value on each side.
|
* value on each side.
|
||||||
*
|
*
|
||||||
* @param size Extra size to add to each side of this box.
|
* @param size Extra size to add to each side of this box.
|
||||||
*
|
|
||||||
* @return New bounding box corresponding to an extension of the current one.
|
* @return New bounding box corresponding to an extension of the current one.
|
||||||
*/
|
*/
|
||||||
public BoundingBox extend(float size) {
|
public BoundingBox extend(float size) {
|
||||||
@ -89,7 +82,6 @@ public class GraphStatistics {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param point Point to check
|
* @param point Point to check
|
||||||
*
|
|
||||||
* @return true if this box contains the given point.
|
* @return true if this box contains the given point.
|
||||||
*/
|
*/
|
||||||
public boolean contains(Point point) {
|
public boolean contains(Point point) {
|
||||||
@ -101,7 +93,6 @@ public class GraphStatistics {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param other Box to intersect.
|
* @param other Box to intersect.
|
||||||
*
|
|
||||||
* @return true if this box contains the given box.
|
* @return true if this box contains the given box.
|
||||||
*/
|
*/
|
||||||
public boolean contains(BoundingBox other) {
|
public boolean contains(BoundingBox other) {
|
||||||
@ -110,8 +101,8 @@ public class GraphStatistics {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "BoundingBox(topLeft=" + this.topLeft + ", bottomRight=" + this.bottomRight
|
return "BoundingBox(topLeft=" + this.topLeft + ", bottomRight="
|
||||||
+ ")";
|
+ this.bottomRight + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -135,8 +126,8 @@ public class GraphStatistics {
|
|||||||
* @param nbRoadOneWay Number of one-way roads in the graph.
|
* @param nbRoadOneWay Number of one-way roads in the graph.
|
||||||
* @param nbRoadTwoWays Number of two-ways roads in the graph.
|
* @param nbRoadTwoWays Number of two-ways roads in the graph.
|
||||||
* @param maximumSpeed Maximum speed of any road of the graph. You can use
|
* @param maximumSpeed Maximum speed of any road of the graph. You can use
|
||||||
* {@link #NO_MAXIMUM_SPEED} to indicate that the graph has no maximum
|
* {@link #NO_MAXIMUM_SPEED} to indicate that the graph has no maximum speed
|
||||||
* speed limit.
|
* limit.
|
||||||
* @param maximumLength Maximum length of any arc of the graph.
|
* @param maximumLength Maximum length of any arc of the graph.
|
||||||
*/
|
*/
|
||||||
public GraphStatistics(BoundingBox boundingBox, int nbRoadOneWay, int nbRoadTwoWays,
|
public GraphStatistics(BoundingBox boundingBox, int nbRoadOneWay, int nbRoadTwoWays,
|
||||||
@ -171,7 +162,6 @@ public class GraphStatistics {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Number of arcs in this graph.
|
* @return Number of arcs in this graph.
|
||||||
*
|
|
||||||
* @see #getOneWayRoadCount()
|
* @see #getOneWayRoadCount()
|
||||||
* @see #getTwoWaysRoadCount()
|
* @see #getTwoWaysRoadCount()
|
||||||
*/
|
*/
|
||||||
@ -187,8 +177,8 @@ public class GraphStatistics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Maximum speed of any arc in the graph, or {@link #NO_MAXIMUM_SPEED}
|
* @return Maximum speed of any arc in the graph, or {@link #NO_MAXIMUM_SPEED} if
|
||||||
* if some roads have no speed limitation.
|
* some roads have no speed limitation.
|
||||||
*/
|
*/
|
||||||
public int getMaximumSpeed() {
|
public int getMaximumSpeed() {
|
||||||
return this.maximumSpeed;
|
return this.maximumSpeed;
|
||||||
|
@ -8,16 +8,13 @@ import java.util.List;
|
|||||||
* <p>
|
* <p>
|
||||||
* Class representing a Node in a {@link Graph}.
|
* Class representing a Node in a {@link Graph}.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* This class holds information regarding nodes in the graph together with the
|
* This class holds information regarding nodes in the graph together with the
|
||||||
* successors associated to the nodes.
|
* successors associated to the nodes.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* Nodes are comparable based on their ID.
|
* Nodes are comparable based on their ID.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class Node implements Comparable<Node> {
|
public final class Node implements Comparable<Node> {
|
||||||
|
|
||||||
@ -26,11 +23,10 @@ public final class Node implements Comparable<Node> {
|
|||||||
* Link the two given nodes with one or two arcs (depending on roadInformation),
|
* Link the two given nodes with one or two arcs (depending on roadInformation),
|
||||||
* with the given attributes.
|
* with the given attributes.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* If {@code roadInformation.isOneWay()} is {@code true}, only a forward arc is
|
* If {@code roadInformation.isOneWay()} is {@code true}, only a forward arc is
|
||||||
* created (origin to destination) and added to origin. Otherwise, a
|
* created (origin to destination) and added to origin. Otherwise, a corresponding
|
||||||
* corresponding backward arc is created and add to destination.
|
* backward arc is created and add to destination.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param origin Origin of the arc.
|
* @param origin Origin of the arc.
|
||||||
@ -38,7 +34,6 @@ public final class Node implements Comparable<Node> {
|
|||||||
* @param length Length of the arc.
|
* @param length Length of the arc.
|
||||||
* @param roadInformation Information corresponding to 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).
|
* @return The newly created forward arc (origin to destination).
|
||||||
*/
|
*/
|
||||||
public static Arc linkNodes(Node origin, Node destination, float length,
|
public static Arc linkNodes(Node origin, Node destination, float length,
|
||||||
@ -51,12 +46,14 @@ public final class Node implements Comparable<Node> {
|
|||||||
else {
|
else {
|
||||||
final Arc d2o;
|
final Arc d2o;
|
||||||
if (origin.getId() < destination.getId()) {
|
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);
|
d2o = new ArcBackward(arc);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Collections.reverse(points);
|
Collections.reverse(points);
|
||||||
d2o = new ArcForward(destination, origin, length, roadInformation, points);
|
d2o = new ArcForward(destination, origin, length, roadInformation,
|
||||||
|
points);
|
||||||
arc = new ArcBackward(d2o);
|
arc = new ArcBackward(d2o);
|
||||||
}
|
}
|
||||||
origin.addSuccessor(arc);
|
origin.addSuccessor(arc);
|
||||||
@ -119,7 +116,6 @@ public final class Node implements Comparable<Node> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return List of successors of this node (unmodifiable list).
|
* @return List of successors of this node (unmodifiable list).
|
||||||
*
|
|
||||||
* @see Collections#unmodifiableList(List)
|
* @see Collections#unmodifiableList(List)
|
||||||
*/
|
*/
|
||||||
public List<Arc> getSuccessors() {
|
public List<Arc> getSuccessors() {
|
||||||
@ -148,7 +144,6 @@ public final class Node implements Comparable<Node> {
|
|||||||
* Compare the ID of this node with the ID of the given node.
|
* Compare the ID of this node with the ID of the given node.
|
||||||
*
|
*
|
||||||
* @param other Node to compare this node with.
|
* @param other Node to compare this node with.
|
||||||
*
|
|
||||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,7 +2,6 @@ package org.insa.graphs.model;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing a point (position) on Earth.
|
* Class representing a point (position) on Earth.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class Point {
|
public final class Point {
|
||||||
|
|
||||||
@ -16,7 +15,6 @@ public final class Point {
|
|||||||
*
|
*
|
||||||
* @param p1 First point.
|
* @param p1 First point.
|
||||||
* @param p2 second point.
|
* @param p2 second point.
|
||||||
*
|
|
||||||
* @return Distance between the two given points (in meters).
|
* @return Distance between the two given points (in meters).
|
||||||
*/
|
*/
|
||||||
public static double distance(Point p1, Point p2) {
|
public static double distance(Point p1, Point p2) {
|
||||||
@ -24,7 +22,8 @@ public final class Point {
|
|||||||
* Math.sin(Math.toRadians(p2.getLatitude()));
|
* Math.sin(Math.toRadians(p2.getLatitude()));
|
||||||
double cosLat = Math.cos(Math.toRadians(p1.getLatitude()))
|
double cosLat = Math.cos(Math.toRadians(p1.getLatitude()))
|
||||||
* Math.cos(Math.toRadians(p2.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);
|
return EARTH_RADIUS * Math.acos(sinLat + cosLat * cosLong);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +59,6 @@ public final class Point {
|
|||||||
* Compute the distance from this point to the given point
|
* Compute the distance from this point to the given point
|
||||||
*
|
*
|
||||||
* @param target Target point to compute distance to.
|
* @param target Target point to compute distance to.
|
||||||
*
|
|
||||||
* @return Distance between this point and the target point, in meters.
|
* @return Distance between this point and the target point, in meters.
|
||||||
*/
|
*/
|
||||||
public double distanceTo(Point target) {
|
public double distanceTo(Point target) {
|
||||||
|
@ -4,12 +4,10 @@ package org.insa.graphs.model;
|
|||||||
* <p>
|
* <p>
|
||||||
* Class containing information for road that may be shared by multiple arcs.
|
* Class containing information for road that may be shared by multiple arcs.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* Sharing information between arcs reduces memory footprints of the program (a
|
* Sharing information between arcs reduces memory footprints of the program (a long
|
||||||
* long road is often split into multiple arcs at each intersection).
|
* road is often split into multiple arcs at each intersection).
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RoadInformation {
|
public class RoadInformation {
|
||||||
|
|
||||||
@ -21,24 +19,7 @@ public class RoadInformation {
|
|||||||
* reference for road types.</a>
|
* reference for road types.</a>
|
||||||
*/
|
*/
|
||||||
public enum RoadType {
|
public enum RoadType {
|
||||||
MOTORWAY,
|
MOTORWAY, TRUNK, PRIMARY, SECONDARY, MOTORWAY_LINK, TRUNK_LINK, PRIMARY_LINK, SECONDARY_LINK, TERTIARY, TRACK, RESIDENTIAL, UNCLASSIFIED, LIVING_STREET, SERVICE, ROUNDABOUT, PEDESTRIAN, CYCLEWAY, COASTLINE
|
||||||
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).
|
// Type of the road (see above).
|
||||||
@ -60,14 +41,13 @@ public class RoadInformation {
|
|||||||
* Create a new RoadInformation instance containing the given parameters.
|
* Create a new RoadInformation instance containing the given parameters.
|
||||||
*
|
*
|
||||||
* @param roadType Type of the road (see {@link RoadType}).
|
* @param roadType Type of the road (see {@link RoadType}).
|
||||||
* @param access Access restrictions for the road (see
|
* @param access Access restrictions for the road (see {@link AccessRestrictions}).
|
||||||
* {@link AccessRestrictions}).
|
|
||||||
* @param isOneWay true if this road is a one way road, false otherwise.
|
* @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 maxSpeed Maximum speed for the road (in kilometers-per-hour).
|
||||||
* @param name Name of the road.
|
* @param name Name of the road.
|
||||||
*/
|
*/
|
||||||
public RoadInformation(RoadType roadType, AccessRestrictions access, boolean isOneWay,
|
public RoadInformation(RoadType roadType, AccessRestrictions access,
|
||||||
int maxSpeed, String name) {
|
boolean isOneWay, int maxSpeed, String name) {
|
||||||
this.type = roadType;
|
this.type = roadType;
|
||||||
this.access = access;
|
this.access = access;
|
||||||
this.oneway = isOneWay;
|
this.oneway = isOneWay;
|
||||||
@ -119,8 +99,8 @@ public class RoadInformation {
|
|||||||
if (getType() == RoadType.MOTORWAY) {
|
if (getType() == RoadType.MOTORWAY) {
|
||||||
typeAsString = "highway";
|
typeAsString = "highway";
|
||||||
}
|
}
|
||||||
return typeAsString + " : " + getName() + " " + (isOneWay() ? " (oneway) " : "") + maxSpeed
|
return typeAsString + " : " + getName() + " " + (isOneWay() ? " (oneway) " : "")
|
||||||
+ " km/h (max.)";
|
+ maxSpeed + " km/h (max.)";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Exception thrown when a format-error is detected when reading a graph (e.g.,
|
* Exception thrown when a format-error is detected when reading a graph (e.g.,
|
||||||
* non-matching check bytes).
|
* non-matching check bytes).
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class BadFormatException extends IOException {
|
public class BadFormatException extends IOException {
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package org.insa.graphs.model.io;
|
package org.insa.graphs.model.io;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown when there is a mismatch between expected and actual magic
|
* Exception thrown when there is a mismatch between expected and actual magic number.
|
||||||
* number.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class BadMagicNumberException extends BadFormatException {
|
public class BadMagicNumberException extends BadFormatException {
|
||||||
|
|
||||||
@ -23,8 +21,8 @@ public class BadMagicNumberException extends BadFormatException {
|
|||||||
* @param expectedNumber Expected magic number.
|
* @param expectedNumber Expected magic number.
|
||||||
*/
|
*/
|
||||||
public BadMagicNumberException(int actualNumber, int expectedNumber) {
|
public BadMagicNumberException(int actualNumber, int expectedNumber) {
|
||||||
super(String.format("Magic number mismatch, expected %#X, got %#X.", expectedNumber,
|
super(String.format("Magic number mismatch, expected %#X, got %#X.",
|
||||||
actualNumber));
|
expectedNumber, actualNumber));
|
||||||
this.actualNumber = actualNumber;
|
this.actualNumber = actualNumber;
|
||||||
this.expectedNumber = expectedNumber;
|
this.expectedNumber = expectedNumber;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package org.insa.graphs.model.io;
|
package org.insa.graphs.model.io;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown when the version of the file is not at least the expected
|
* Exception thrown when the version of the file is not at least the expected one.
|
||||||
* one.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class BadVersionException extends BadFormatException {
|
public class BadVersionException extends BadFormatException {
|
||||||
|
|
||||||
@ -16,7 +14,6 @@ public class BadVersionException extends BadFormatException {
|
|||||||
private int actualVersion, expectedVersion;
|
private int actualVersion, expectedVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param actualVersion Actual version of the file.
|
* @param actualVersion Actual version of the file.
|
||||||
* @param expectedVersion Expected version of the file.
|
* @param expectedVersion Expected version of the file.
|
||||||
*/
|
*/
|
||||||
|
@ -20,7 +20,6 @@ import org.insa.graphs.model.RoadInformation.RoadType;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link GraphReader} to read graph in binary format.
|
* Implementation of {@link GraphReader} to read graph in binary format.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class BinaryGraphReader extends BinaryReader implements GraphReader {
|
public class BinaryGraphReader extends BinaryReader implements GraphReader {
|
||||||
|
|
||||||
@ -38,7 +37,6 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
|
|||||||
* Parse the given long value into a new instance of AccessRestrictions.
|
* Parse the given long value into a new instance of AccessRestrictions.
|
||||||
*
|
*
|
||||||
* @param access The value to parse.
|
* @param access The value to parse.
|
||||||
*
|
|
||||||
* @return New instance of access restrictions parsed from the given value.
|
* @return New instance of access restrictions parsed from the given value.
|
||||||
*/
|
*/
|
||||||
protected static AccessRestrictions toAccessInformation(final long access) {
|
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
|
// 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
|
// 2) - UKNOWN is not included because value above 6 (FORESTRY) are all
|
||||||
// considered unknown.
|
// considered unknown.
|
||||||
final AccessRestriction[] allRestrictions = new AccessRestriction[] {
|
final AccessRestriction[] allRestrictions =
|
||||||
AccessRestriction.FORBIDDEN, AccessRestriction.ALLOWED, AccessRestriction.PRIVATE,
|
new AccessRestriction[] { AccessRestriction.FORBIDDEN,
|
||||||
|
AccessRestriction.ALLOWED, AccessRestriction.PRIVATE,
|
||||||
AccessRestriction.DESTINATION, AccessRestriction.DELIVERY,
|
AccessRestriction.DESTINATION, AccessRestriction.DELIVERY,
|
||||||
AccessRestriction.CUSTOMERS, AccessRestriction.FORESTRY };
|
AccessRestriction.CUSTOMERS, AccessRestriction.FORESTRY };
|
||||||
|
|
||||||
// The order of values inside this array is VERY IMPORTANT: The order is such
|
// 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,
|
// 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.
|
// i.e. FOOT is processed first (4 lowest bits), and so on.
|
||||||
final AccessMode[] allModes = new AccessMode[] { AccessMode.FOOT, null, AccessMode.BICYCLE,
|
final AccessMode[] allModes = new AccessMode[] { AccessMode.FOOT, null,
|
||||||
AccessMode.SMALL_MOTORCYCLE, AccessMode.AGRICULTURAL, AccessMode.MOTORCYCLE,
|
AccessMode.BICYCLE, AccessMode.SMALL_MOTORCYCLE,
|
||||||
AccessMode.MOTORCAR, AccessMode.HEAVY_GOODS, null, AccessMode.PUBLIC_TRANSPORT };
|
AccessMode.AGRICULTURAL, AccessMode.MOTORCYCLE, AccessMode.MOTORCAR,
|
||||||
|
AccessMode.HEAVY_GOODS, null, AccessMode.PUBLIC_TRANSPORT };
|
||||||
|
|
||||||
// fill maps...
|
// fill maps...
|
||||||
final EnumMap<AccessMode, AccessRestriction> restrictions = new EnumMap<>(AccessMode.class);
|
final EnumMap<AccessMode, AccessRestriction> restrictions =
|
||||||
|
new EnumMap<>(AccessMode.class);
|
||||||
long copyAccess = access;
|
long copyAccess = access;
|
||||||
for (AccessMode mode: allModes) {
|
for (AccessMode mode : allModes) {
|
||||||
if (mode == null) {
|
if (mode == null) {
|
||||||
continue; // filling cells
|
continue; // filling cells
|
||||||
}
|
}
|
||||||
@ -86,9 +87,7 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
|
|||||||
* Convert a character to its corresponding road type.
|
* Convert a character to its corresponding road type.
|
||||||
*
|
*
|
||||||
* @param ch Character to convert.
|
* @param ch Character to convert.
|
||||||
*
|
|
||||||
* @return Road type corresponding to the given character.
|
* @return Road type corresponding to the given character.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
protected static RoadType toRoadType(char ch) {
|
protected static RoadType toRoadType(char ch) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
@ -181,8 +180,10 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
|
|||||||
final ArrayList<Node> nodes = new ArrayList<Node>(nbNodes);
|
final ArrayList<Node> nodes = new ArrayList<Node>(nbNodes);
|
||||||
|
|
||||||
// Read nodes.
|
// Read nodes.
|
||||||
float minLongitude = Float.POSITIVE_INFINITY, minLatitude = Float.POSITIVE_INFINITY,
|
float minLongitude = Float.POSITIVE_INFINITY,
|
||||||
maxLongitude = Float.NEGATIVE_INFINITY, maxLatitude = Float.NEGATIVE_INFINITY;
|
minLatitude = Float.POSITIVE_INFINITY,
|
||||||
|
maxLongitude = Float.NEGATIVE_INFINITY,
|
||||||
|
maxLatitude = Float.NEGATIVE_INFINITY;
|
||||||
observers.forEach((observer) -> observer.notifyStartReadingNodes(nbNodes));
|
observers.forEach((observer) -> observer.notifyStartReadingNodes(nbNodes));
|
||||||
for (int node = 0; node < nbNodes; ++node) {
|
for (int node = 0; node < nbNodes; ++node) {
|
||||||
// Read longitude / latitude.
|
// Read longitude / latitude.
|
||||||
@ -230,7 +231,8 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
|
|||||||
float maxLength = 0;
|
float maxLength = 0;
|
||||||
final int copyNbTotalSuccesors = nbTotalSuccessors; // Stupid Java...
|
final int copyNbTotalSuccesors = nbTotalSuccessors; // Stupid Java...
|
||||||
int nbOneWayRoad = 0;
|
int nbOneWayRoad = 0;
|
||||||
observers.forEach((observer) -> observer.notifyStartReadingArcs(copyNbTotalSuccesors));
|
observers.forEach(
|
||||||
|
(observer) -> observer.notifyStartReadingArcs(copyNbTotalSuccesors));
|
||||||
for (int node = 0; node < nbNodes; ++node) {
|
for (int node = 0; node < nbNodes; ++node) {
|
||||||
for (int succ = 0; succ < nbSuccessors[node]; ++succ) {
|
for (int succ = 0; succ < nbSuccessors[node]; ++succ) {
|
||||||
|
|
||||||
@ -250,7 +252,8 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
|
|||||||
}
|
}
|
||||||
maxLength = Math.max(length, maxLength);
|
maxLength = Math.max(length, maxLength);
|
||||||
|
|
||||||
length = Math.max(length, (float) Point.distance(nodes.get(node).getPoint(),
|
length = Math.max(length,
|
||||||
|
(float) Point.distance(nodes.get(node).getPoint(),
|
||||||
nodes.get(destNode).getPoint()));
|
nodes.get(destNode).getPoint()));
|
||||||
|
|
||||||
// Number of segments.
|
// Number of segments.
|
||||||
@ -294,14 +297,14 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
|
|||||||
new GraphStatistics(
|
new GraphStatistics(
|
||||||
new BoundingBox(new Point(minLongitude, maxLatitude),
|
new BoundingBox(new Point(minLongitude, maxLatitude),
|
||||||
new Point(maxLongitude, minLatitude)),
|
new Point(maxLongitude, minLatitude)),
|
||||||
nbOneWayRoad, nbTotalSuccessors - nbOneWayRoad, maxSpeed, maxLength));
|
nbOneWayRoad, nbTotalSuccessors - nbOneWayRoad, maxSpeed,
|
||||||
|
maxLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the next road information from the stream.
|
* Read the next road information from the stream.
|
||||||
*
|
*
|
||||||
* @return The next RoadInformation in the stream.
|
* @return The next RoadInformation in the stream.
|
||||||
*
|
|
||||||
* @throws IOException if an error occurs while reading from the stream.
|
* @throws IOException if an error occurs while reading from the stream.
|
||||||
*/
|
*/
|
||||||
private RoadInformation readRoadInformation() throws IOException {
|
private RoadInformation readRoadInformation() throws IOException {
|
||||||
@ -315,8 +318,8 @@ public class BinaryGraphReader extends BinaryReader implements GraphReader {
|
|||||||
// TODO: Try to create something...
|
// TODO: Try to create something...
|
||||||
dis.readUnsignedShort();
|
dis.readUnsignedShort();
|
||||||
}
|
}
|
||||||
return new RoadInformation(toRoadType(type), access, (x & 0x80) > 0, (x & 0x7F) * 5,
|
return new RoadInformation(toRoadType(type), access, (x & 0x80) > 0,
|
||||||
dis.readUTF());
|
(x & 0x7F) * 5, dis.readUTF());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import org.insa.graphs.model.Path;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link PathReader} to read paths in binary format.
|
* Implementation of {@link PathReader} to read paths in binary format.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class BinaryPathReader extends BinaryReader implements PathReader {
|
public class BinaryPathReader extends BinaryReader implements PathReader {
|
||||||
|
|
||||||
@ -35,7 +34,8 @@ public class BinaryPathReader extends BinaryReader implements PathReader {
|
|||||||
checkVersionOrThrow(dis.readInt());
|
checkVersionOrThrow(dis.readInt());
|
||||||
|
|
||||||
// Read map ID and check against graph.
|
// 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())) {
|
if (!mapId.equals(graph.getMapId())) {
|
||||||
throw new MapMismatchException(mapId, graph.getMapId());
|
throw new MapMismatchException(mapId, graph.getMapId());
|
||||||
@ -61,9 +61,7 @@ public class BinaryPathReader extends BinaryReader implements PathReader {
|
|||||||
* Read a node from the input stream and returns it.
|
* Read a node from the input stream and returns it.
|
||||||
*
|
*
|
||||||
* @param graph Graph containing the nodes.
|
* @param graph Graph containing the nodes.
|
||||||
*
|
|
||||||
* @return The next node in the input stream.
|
* @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.
|
* @throws IndexOutOfBoundsException if the node is not in the graph.
|
||||||
*/
|
*/
|
||||||
|
@ -9,7 +9,6 @@ import org.insa.graphs.model.Path;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link PathWriter} to write paths in binary format.
|
* Implementation of {@link PathWriter} to write paths in binary format.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class BinaryPathWriter extends BinaryWriter implements PathWriter {
|
public class BinaryPathWriter extends BinaryWriter implements PathWriter {
|
||||||
|
|
||||||
@ -43,7 +42,7 @@ public class BinaryPathWriter extends BinaryWriter implements PathWriter {
|
|||||||
|
|
||||||
// Write nodes.
|
// Write nodes.
|
||||||
dos.writeInt(path.getOrigin().getId());
|
dos.writeInt(path.getOrigin().getId());
|
||||||
for (Arc arc: path.getArcs()) {
|
for (Arc arc : path.getArcs()) {
|
||||||
dos.writeInt(arc.getDestination().getId());
|
dos.writeInt(arc.getDestination().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import java.io.IOException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for writing binary file.
|
* Base class for writing binary file.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class BinaryReader implements AutoCloseable, Closeable {
|
public abstract class BinaryReader implements AutoCloseable, Closeable {
|
||||||
|
|
||||||
@ -19,8 +18,8 @@ public abstract class BinaryReader implements AutoCloseable, Closeable {
|
|||||||
protected final DataInputStream dis;
|
protected final DataInputStream dis;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new BinaryReader that reads from the given stream and that expected
|
* Create a new BinaryReader that reads from the given stream and that expected the
|
||||||
* the given magic number and at least the given minimum version.
|
* given magic number and at least the given minimum version.
|
||||||
*
|
*
|
||||||
* @param magicNumber Magic number of files to be read.
|
* @param magicNumber Magic number of files to be read.
|
||||||
* @param minVersion Minimum version of files to be read.
|
* @param minVersion Minimum version of files to be read.
|
||||||
@ -38,13 +37,12 @@ public abstract class BinaryReader implements AutoCloseable, Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the given version is greater than the minimum version, and update
|
* Check if the given version is greater than the minimum version, and update the
|
||||||
* the current version if it is.
|
* current version if it is.
|
||||||
*
|
*
|
||||||
* @param version Version to check.
|
* @param version Version to check.
|
||||||
*
|
* @throws BadVersionException if the given version is not greater than the minimum
|
||||||
* @throws BadVersionException if the given version is not greater than the
|
* version.
|
||||||
* minimum version.
|
|
||||||
*/
|
*/
|
||||||
protected void checkVersionOrThrow(int version) throws BadVersionException {
|
protected void checkVersionOrThrow(int version) throws BadVersionException {
|
||||||
if (version < this.minVersion) {
|
if (version < this.minVersion) {
|
||||||
@ -64,22 +62,20 @@ public abstract class BinaryReader implements AutoCloseable, Closeable {
|
|||||||
* Check if the given number matches the expected magic number.
|
* Check if the given number matches the expected magic number.
|
||||||
*
|
*
|
||||||
* @param magicNumber The magic number to check.
|
* @param magicNumber The magic number to check.
|
||||||
*
|
|
||||||
* @throws BadMagicNumberException If the two magic numbers are not equal.
|
* @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) {
|
if (this.magicNumber != magicNumber) {
|
||||||
throw new BadMagicNumberException(magicNumber, this.magicNumber);
|
throw new BadMagicNumberException(magicNumber, this.magicNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the next byte in the input stream correspond to the given byte.
|
* Check if the next byte in the input stream correspond to the given byte. This
|
||||||
*
|
* function consumes the next byte in the input stream.
|
||||||
* This function consumes the next byte in the input stream.
|
|
||||||
*
|
*
|
||||||
* @param b Byte to check.
|
* @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.
|
* @throws BadFormatException if the byte read is not the expected one.
|
||||||
*/
|
*/
|
||||||
@ -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
|
* Read a byte array of fixed length from the input and convert it to a string using
|
||||||
* using the given charset, removing any trailing '\0'.
|
* the given charset, removing any trailing '\0'.
|
||||||
*
|
*
|
||||||
* @param length Number of bytes to read.
|
* @param length Number of bytes to read.
|
||||||
* @param charset Charset to use to convert the bytes into a string.
|
* @param charset Charset to use to convert the bytes into a string.
|
||||||
*
|
|
||||||
* @return The convert string.
|
* @return The convert string.
|
||||||
*
|
|
||||||
* @throws IOException if an error occurs while reading or converting.
|
* @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];
|
byte[] bytes = new byte[length];
|
||||||
this.dis.read(bytes);
|
this.dis.read(bytes);
|
||||||
return new String(bytes, "UTF-8").trim();
|
return new String(bytes, "UTF-8").trim();
|
||||||
@ -111,7 +106,6 @@ public abstract class BinaryReader implements AutoCloseable, Closeable {
|
|||||||
* integer value.
|
* integer value.
|
||||||
*
|
*
|
||||||
* @return Integer value read from the next 24 bits of the stream.
|
* @return Integer value read from the next 24 bits of the stream.
|
||||||
*
|
|
||||||
* @throws IOException if an error occurs while reading from the stream.
|
* @throws IOException if an error occurs while reading from the stream.
|
||||||
*/
|
*/
|
||||||
protected int read24bits() throws IOException {
|
protected int read24bits() throws IOException {
|
||||||
|
@ -6,7 +6,6 @@ import java.io.IOException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for writing binary file.
|
* Base class for writing binary file.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class BinaryWriter implements AutoCloseable, Closeable {
|
public abstract class BinaryWriter implements AutoCloseable, Closeable {
|
||||||
|
|
||||||
@ -31,7 +30,6 @@ public abstract class BinaryWriter implements AutoCloseable, Closeable {
|
|||||||
* Write a 24-bits integer in BigEndian order to the output stream.
|
* Write a 24-bits integer in BigEndian order to the output stream.
|
||||||
*
|
*
|
||||||
* @param value Value to write.
|
* @param value Value to write.
|
||||||
*
|
|
||||||
* @throws IOException if an error occurs while writing to the stream.
|
* @throws IOException if an error occurs while writing to the stream.
|
||||||
*/
|
*/
|
||||||
protected void write24bits(int value) throws IOException {
|
protected void write24bits(int value) throws IOException {
|
||||||
|
@ -7,7 +7,6 @@ import org.insa.graphs.model.Graph;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Base interface for classes that can read graph.
|
* Base interface for classes that can read graph.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface GraphReader extends AutoCloseable, Closeable {
|
public interface GraphReader extends AutoCloseable, Closeable {
|
||||||
|
|
||||||
@ -22,9 +21,7 @@ public interface GraphReader extends AutoCloseable, Closeable {
|
|||||||
* Read a graph an returns it.
|
* Read a graph an returns it.
|
||||||
*
|
*
|
||||||
* @return The graph read.
|
* @return The graph read.
|
||||||
*
|
|
||||||
* @throws IOException if an exception occurs while reading the graph.
|
* @throws IOException if an exception occurs while reading the graph.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public Graph read() throws IOException;
|
public Graph read() throws IOException;
|
||||||
|
|
||||||
@ -32,7 +29,6 @@ public interface GraphReader extends AutoCloseable, Closeable {
|
|||||||
* Close this graph reader.
|
* Close this graph reader.
|
||||||
*
|
*
|
||||||
* @throws IOException if an exception occurs while closing the reader.
|
* @throws IOException if an exception occurs while closing the reader.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void close() throws IOException;
|
public void close() throws IOException;
|
||||||
|
|
||||||
|
@ -5,15 +5,14 @@ import org.insa.graphs.model.Node;
|
|||||||
import org.insa.graphs.model.RoadInformation;
|
import org.insa.graphs.model.RoadInformation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base interface that should be implemented by classes that want to observe the
|
* Base interface that should be implemented by classes that want to observe the reading
|
||||||
* reading of a graph by a {@link GraphReader}.
|
* of a graph by a {@link GraphReader}.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface GraphReaderObserver {
|
public interface GraphReaderObserver {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify observer about information on the graph, this method is always the
|
* Notify observer about information on the graph, this method is always the first
|
||||||
* first called
|
* called
|
||||||
*
|
*
|
||||||
* @param mapId ID of the graph.
|
* @param mapId ID of the graph.
|
||||||
*/
|
*/
|
||||||
|
@ -3,9 +3,8 @@ package org.insa.graphs.model.io;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown when there is mismatch between the expected map ID and the
|
* Exception thrown when there is mismatch between the expected map ID and the actual
|
||||||
* actual map ID when reading a graph.
|
* map ID when reading a graph.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class MapMismatchException extends IOException {
|
public class MapMismatchException extends IOException {
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import org.insa.graphs.model.Path;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Base interface that should be implemented by class used to read paths.
|
* Base interface that should be implemented by class used to read paths.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface PathReader extends AutoCloseable, Closeable {
|
public interface PathReader extends AutoCloseable, Closeable {
|
||||||
|
|
||||||
@ -16,9 +15,7 @@ public interface PathReader extends AutoCloseable, Closeable {
|
|||||||
* Read a path of the given graph and returns it.
|
* Read a path of the given graph and returns it.
|
||||||
*
|
*
|
||||||
* @param graph Graph of the path.
|
* @param graph Graph of the path.
|
||||||
*
|
|
||||||
* @return Path read.
|
* @return Path read.
|
||||||
*
|
|
||||||
* @throws IOException When an error occurs while reading the path.
|
* @throws IOException When an error occurs while reading the path.
|
||||||
*/
|
*/
|
||||||
public Path readPath(Graph graph) throws IOException;
|
public Path readPath(Graph graph) throws IOException;
|
||||||
@ -27,7 +24,6 @@ public interface PathReader extends AutoCloseable, Closeable {
|
|||||||
* Close this graph reader.
|
* Close this graph reader.
|
||||||
*
|
*
|
||||||
* @throws IOException if an exception occurs while closing the reader.
|
* @throws IOException if an exception occurs while closing the reader.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void close() throws IOException;
|
public void close() throws IOException;
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import org.insa.graphs.model.Path;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Base interface that should be implemented by class used to write paths.
|
* Base interface that should be implemented by class used to write paths.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface PathWriter extends AutoCloseable, Closeable {
|
public interface PathWriter extends AutoCloseable, Closeable {
|
||||||
|
|
||||||
@ -15,7 +14,6 @@ public interface PathWriter extends AutoCloseable, Closeable {
|
|||||||
* Write the given path.
|
* Write the given path.
|
||||||
*
|
*
|
||||||
* @param path Path to write.
|
* @param path Path to write.
|
||||||
*
|
|
||||||
* @throws IOException When an error occurs while writing the path.
|
* @throws IOException When an error occurs while writing the path.
|
||||||
*/
|
*/
|
||||||
public void writePath(Path path) throws IOException;
|
public void writePath(Path path) throws IOException;
|
||||||
@ -24,7 +22,6 @@ public interface PathWriter extends AutoCloseable, Closeable {
|
|||||||
* Close this graph reader.
|
* Close this graph reader.
|
||||||
*
|
*
|
||||||
* @throws IOException if an exception occurs while closing the reader.
|
* @throws IOException if an exception occurs while closing the reader.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void close() throws IOException;
|
public void close() throws IOException;
|
||||||
|
|
||||||
|
@ -39,23 +39,29 @@ public class GraphTest {
|
|||||||
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
|
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
|
||||||
new ArrayList<>());
|
new ArrayList<>());
|
||||||
Node.linkNodes(nodes[0], nodes[4], 0,
|
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,
|
Node.linkNodes(nodes[1], nodes[2], 0,
|
||||||
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
|
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
|
||||||
new ArrayList<>());
|
new ArrayList<>());
|
||||||
Node.linkNodes(nodes[2], nodes[3], 0,
|
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,
|
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,
|
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,
|
Node.linkNodes(nodes[3], nodes[0], 0,
|
||||||
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
|
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
|
||||||
new ArrayList<>());
|
new ArrayList<>());
|
||||||
Node.linkNodes(nodes[3], nodes[4], 0,
|
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,
|
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);
|
graph = new Graph("ID", "", Arrays.asList(nodes), null);
|
||||||
|
|
||||||
@ -66,7 +72,7 @@ public class GraphTest {
|
|||||||
*/
|
*/
|
||||||
private List<Arc> getArcsBetween(Node a, Node b) {
|
private List<Arc> getArcsBetween(Node a, Node b) {
|
||||||
List<Arc> arcs = new ArrayList<>();
|
List<Arc> arcs = new ArrayList<>();
|
||||||
for (Arc arc: a.getSuccessors()) {
|
for (Arc arc : a.getSuccessors()) {
|
||||||
if (arc.getDestination().equals(b)) {
|
if (arc.getDestination().equals(b)) {
|
||||||
arcs.add(arc);
|
arcs.add(arc);
|
||||||
}
|
}
|
||||||
|
@ -33,23 +33,29 @@ public class NodeTest {
|
|||||||
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
|
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
|
||||||
new ArrayList<>());
|
new ArrayList<>());
|
||||||
Node.linkNodes(nodes[0], nodes[4], 0,
|
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,
|
Node.linkNodes(nodes[1], nodes[2], 0,
|
||||||
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
|
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
|
||||||
new ArrayList<>());
|
new ArrayList<>());
|
||||||
Node.linkNodes(nodes[2], nodes[3], 0,
|
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,
|
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,
|
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,
|
Node.linkNodes(nodes[3], nodes[0], 0,
|
||||||
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
|
new RoadInformation(RoadType.UNCLASSIFIED, null, false, 1, null),
|
||||||
new ArrayList<>());
|
new ArrayList<>());
|
||||||
Node.linkNodes(nodes[3], nodes[4], 0,
|
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,
|
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.
|
* @return The first arc between from a to b, or null.
|
||||||
*/
|
*/
|
||||||
private Arc getFirstArcBetween(Node a, Node b) {
|
private Arc getFirstArcBetween(Node a, Node b) {
|
||||||
for (Arc arc: a.getSuccessors()) {
|
for (Arc arc : a.getSuccessors()) {
|
||||||
if (arc.getDestination().equals(b)) {
|
if (arc.getDestination().equals(b)) {
|
||||||
return arc;
|
return arc;
|
||||||
}
|
}
|
||||||
|
@ -30,14 +30,15 @@ public class PathTest {
|
|||||||
private static Arc a2b, a2c, a2e, b2c, c2d_1, c2d_2, c2d_3, c2a, d2a, d2e, e2d;
|
private static Arc a2b, a2c, a2e, b2c, c2d_1, c2d_2, c2d_3, c2a, d2a, d2e, e2d;
|
||||||
|
|
||||||
// Some paths...
|
// Some paths...
|
||||||
private static Path emptyPath, singleNodePath, shortPath, longPath, loopPath, longLoopPath,
|
private static Path emptyPath, singleNodePath, shortPath, longPath, loopPath,
|
||||||
invalidPath;
|
longLoopPath, invalidPath;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initAll() throws IOException {
|
public static void initAll() throws IOException {
|
||||||
|
|
||||||
// 10 and 20 meters per seconds
|
// 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, "");
|
speed20 = new RoadInformation(RoadType.MOTORWAY, null, true, 72, "");
|
||||||
|
|
||||||
// Create nodes
|
// Create nodes
|
||||||
@ -65,8 +66,8 @@ public class PathTest {
|
|||||||
shortPath = new Path(graph, Arrays.asList(new Arc[] { a2b, b2c, c2d_1 }));
|
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 }));
|
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 }));
|
loopPath = new Path(graph, Arrays.asList(new Arc[] { a2b, b2c, c2d_1, d2a }));
|
||||||
longLoopPath = new Path(graph,
|
longLoopPath = new Path(graph, Arrays
|
||||||
Arrays.asList(new Arc[] { a2b, b2c, c2d_1, d2a, a2c, c2d_3, d2a, a2b, b2c }));
|
.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 }));
|
invalidPath = new Path(graph, Arrays.asList(new Arc[] { a2b, c2d_1, d2e }));
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -184,7 +185,8 @@ public class PathTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Trap construction!
|
// 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(nodes[1], path.getOrigin());
|
||||||
assertEquals(0, path.getArcs().size());
|
assertEquals(0, path.getArcs().size());
|
||||||
|
|
||||||
@ -219,7 +221,8 @@ public class PathTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Trap construction!
|
// 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(nodes[1], path.getOrigin());
|
||||||
assertEquals(0, path.getArcs().size());
|
assertEquals(0, path.getArcs().size());
|
||||||
|
|
||||||
@ -232,12 +235,14 @@ public class PathTest {
|
|||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void testCreateFastestPathFromNodesException() {
|
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)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void testCreateShortestPathFromNodesException() {
|
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] }));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
338
eclipse-java-google-style.xml
Normal file
338
eclipse-java-google-style.xml
Normal file
@ -0,0 +1,338 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<profiles version="13">
|
||||||
|
<profile kind="CodeFormatterProfile" version="13">
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_cascading_method_invocation_with_arguments.count_dependent" value="16|-1|16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_prefer_two_fragments" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_comment_inline_tags" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="1040" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type.count_dependent" value="1585|-1|1585" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields.count_dependent" value="16|-1|16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression.count_dependent" value="16|4|80" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration.count_dependent" value="16|4|48" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration.count_dependent" value="16|4|49" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_cascading_method_invocation_with_arguments" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.compiler.source" value="1.7" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration.count_dependent" value="16|4|48" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="0" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants.count_dependent" value="16|5|48" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="88" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation.count_dependent" value="16|4|48" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="1585" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_type_annotation" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_field_declaration" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment_new_line_at_start_of_html_paragraph" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comment_prefix" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_parameter_annotation" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="1585" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="2" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation.count_dependent" value="16|5|80" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter.count_dependent" value="1040|-1|1040" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package.count_dependent" value="1585|-1|1585" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.force_if_else_statement_brace" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="2" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_package_annotation" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation.count_dependent" value="16|-1|16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="1585" />
|
||||||
|
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.7" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class" value="20" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable.count_dependent" value="1585|-1|1585" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field.count_dependent" value="1585|-1|1585" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration.count_dependent" value="16|5|80" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant.count_dependent" value="16|-1|16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="88" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="0" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="2" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="0" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field" value="1585" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer.count_dependent" value="16|5|80" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.7" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration.count_dependent" value="16|4|48" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method.count_dependent" value="1585|-1|1585" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression.count_dependent" value="16|-1|16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_member_annotation" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="1585" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call.count_dependent" value="16|5|80" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments.count_dependent" value="16|-1|16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression.count_dependent" value="16|5|80" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration.count_dependent" value="16|5|80" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.alignment_for_for_statement" value="16" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false" />
|
||||||
|
<setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position" value="false" />
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
4
pom.xml
4
pom.xml
@ -1,7 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.insa.graphs</groupId>
|
<groupId>org.insa.graphs</groupId>
|
||||||
|
Loading…
Reference in New Issue
Block a user