Switch to Maven project.

This commit is contained in:
Mikaël Capelle 2020-02-23 16:30:06 +01:00
parent fd503d148e
commit 5bb454a3b2
139 changed files with 2487 additions and 2198 deletions

View File

@ -1,69 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/kxml2-2.3.0.jar"/>
<classpathentry kind="lib" path="libs/mapsforge-core-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-core-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-map-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-map-awt-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-awt-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-map-reader-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-reader-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-poi-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-poi-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-poi-awt-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-poi-awt-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-themes-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-themes-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/svg-salamander-1.0.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/svg-salamander-1.0-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="res"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

4
.gitignore vendored
View File

@ -6,12 +6,14 @@ bin
target target
doc doc
*.jar *.jar
.settings
.classpath
# Editor specific files and folders # Editor specific files and folders
*~ *~
.project .project
# Project speicific files and folders # Project specific files and folders
*.mapfg *.mapfg
*.mapgr *.mapgr
*.path *.path

View File

@ -1,5 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -1,4 +0,0 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

25
be-graphes-algos/pom.xml Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0"?>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.insa.graphs</groupId>
<artifactId>be-graphes-all</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>be-graphes-algos</artifactId>
<name>be-graphes-algos</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.insa.graphs</groupId>
<artifactId>be-graphes-model</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +1,4 @@
package org.insa.algo; package org.insa.graphs.algorithm;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;

View File

@ -1,8 +1,8 @@
package org.insa.algo; package org.insa.graphs.algorithm;
import org.insa.graph.Arc; import org.insa.graphs.model.Arc;
import org.insa.graph.Graph; import org.insa.graphs.model.Graph;
import org.insa.graph.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

View File

@ -1,4 +1,4 @@
package org.insa.algo; package org.insa.graphs.algorithm;
import java.time.Duration; import java.time.Duration;
@ -38,6 +38,11 @@ public abstract class AbstractSolution {
this.status = Status.UNKNOWN; this.status = Status.UNKNOWN;
} }
/**
*
* @param data
* @param status
*/
protected AbstractSolution(AbstractInputData data, Status status) { protected AbstractSolution(AbstractInputData data, Status status) {
this.data = data; this.data = data;
this.status = status; this.status = status;

View File

@ -1,4 +1,4 @@
package org.insa.algo; package org.insa.graphs.algorithm;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.IdentityHashMap; import java.util.IdentityHashMap;
@ -7,11 +7,11 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import org.insa.algo.shortestpath.AStarAlgorithm; import org.insa.graphs.algorithm.shortestpath.AStarAlgorithm;
import org.insa.algo.shortestpath.BellmanFordAlgorithm; import org.insa.graphs.algorithm.shortestpath.BellmanFordAlgorithm;
import org.insa.algo.shortestpath.DijkstraAlgorithm; import org.insa.graphs.algorithm.shortestpath.DijkstraAlgorithm;
import org.insa.algo.shortestpath.ShortestPathAlgorithm; import org.insa.graphs.algorithm.shortestpath.ShortestPathAlgorithm;
import org.insa.algo.weakconnectivity.WeaklyConnectedComponentsAlgorithm; import org.insa.graphs.algorithm.weakconnectivity.WeaklyConnectedComponentsAlgorithm;
/** /**
* Factory class used to register and retrieve algorithms based on their common * Factory class used to register and retrieve algorithms based on their common
@ -43,10 +43,10 @@ public class AlgorithmFactory {
* the given base algorithm. * the given base algorithm.
* *
* @param baseAlgorithm Base algorithm class that corresponds to the newly * @param baseAlgorithm Base algorithm class that corresponds to the newly
* registered algorithm class (e.g., generic algorithm class for the * registered algorithm class (e.g., generic algorithm
* problem). * class for the problem).
* @param name Name for the registered algorithm class. * @param name Name for the registered algorithm class.
* @param algoClass Algorithm class to register. * @param algoClass Algorithm class to register.
*/ */
public static void registerAlgorithm(Class<? extends AbstractAlgorithm<?>> baseAlgorithm, public static void registerAlgorithm(Class<? extends AbstractAlgorithm<?>> baseAlgorithm,
String name, Class<? extends AbstractAlgorithm<?>> algoClass) { String name, Class<? extends AbstractAlgorithm<?>> algoClass) {
@ -62,14 +62,14 @@ public class AlgorithmFactory {
* an object equivalent to `new Algorithm(data)`. * an object equivalent to `new Algorithm(data)`.
* *
* @param algorithm Class of the algorithm to create. * @param algorithm Class of the algorithm to create.
* @param data Input data for the algorithm. * @param data Input data for the algorithm.
* *
* @return A new instance of the given algorithm class using the given data. * @return A new instance of the given algorithm class using the given data.
* *
* @throws Exception if something wrong happens when constructing the object, * @throws Exception if something wrong happens when constructing the object,
* i.e. the given input data does not correspond to the given algorithm * i.e. the given input data does not correspond to the given
* and/or no constructor that takes a single parameter of type * algorithm and/or no constructor that takes a single
* (data.getClass()) exists. * parameter of type (data.getClass()) exists.
*/ */
public static AbstractAlgorithm<?> createAlgorithm( public static AbstractAlgorithm<?> createAlgorithm(
Class<? extends AbstractAlgorithm<?>> algorithm, AbstractInputData data) Class<? extends AbstractAlgorithm<?>> algorithm, AbstractInputData data)
@ -96,7 +96,7 @@ public class AlgorithmFactory {
* registerAlgorithm. * registerAlgorithm.
* *
* @param baseAlgorithm Base algorithm class for the algorithm to retrieve. * @param baseAlgorithm Base algorithm class for the algorithm to retrieve.
* @param name Name of the algorithm to retrieve. * @param name Name of the algorithm to retrieve.
* *
* @return Class corresponding to the given name. * @return Class corresponding to the given name.
* *
@ -112,7 +112,7 @@ public class AlgorithmFactory {
* for the given base algorithm class. * for the given base algorithm class.
* *
* @param baseAlgorithm Base algorithm class for the algorithm class names to * @param baseAlgorithm Base algorithm class for the algorithm class names to
* retrieve. * retrieve.
* *
* @return Names of the currently registered algorithms. * @return Names of the currently registered algorithms.
* *

View File

@ -1,8 +1,8 @@
package org.insa.algo; package org.insa.graphs.algorithm;
import org.insa.algo.AbstractInputData.Mode; import org.insa.graphs.algorithm.AbstractInputData.Mode;
import org.insa.graph.Arc; import org.insa.graphs.model.Arc;
import org.insa.graph.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

View File

@ -1,14 +1,14 @@
package org.insa.algo; package org.insa.graphs.algorithm;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import org.insa.algo.AbstractInputData.Mode; import org.insa.graphs.algorithm.AbstractInputData.Mode;
import org.insa.graph.AccessRestrictions.AccessMode; import org.insa.graphs.model.Arc;
import org.insa.graph.AccessRestrictions.AccessRestriction; import org.insa.graphs.model.GraphStatistics;
import org.insa.graph.Arc; import org.insa.graphs.model.AccessRestrictions.AccessMode;
import org.insa.graph.GraphStatistics; import org.insa.graphs.model.AccessRestrictions.AccessRestriction;
public class ArcInspectorFactory { public class ArcInspectorFactory {

View File

@ -1,6 +1,6 @@
package org.insa.algo.carpooling; package org.insa.graphs.algorithm.carpooling;
import org.insa.algo.AbstractAlgorithm; import org.insa.graphs.algorithm.AbstractAlgorithm;
public abstract class CarPoolingAlgorithm extends AbstractAlgorithm<CarPoolingObserver> { public abstract class CarPoolingAlgorithm extends AbstractAlgorithm<CarPoolingObserver> {

View File

@ -0,0 +1,13 @@
package org.insa.graphs.algorithm.carpooling;
import org.insa.graphs.algorithm.AbstractInputData;
import org.insa.graphs.algorithm.ArcInspector;
import org.insa.graphs.model.Graph;
public class CarPoolingData extends AbstractInputData {
protected CarPoolingData(Graph graph, ArcInspector arcFilter) {
super(graph, arcFilter);
}
}

View File

@ -1,4 +1,4 @@
package org.insa.algo.carpooling; package org.insa.graphs.algorithm.carpooling;
public class CarPoolingGraphicObserver implements CarPoolingObserver { public class CarPoolingGraphicObserver implements CarPoolingObserver {

View File

@ -0,0 +1,5 @@
package org.insa.graphs.algorithm.carpooling;
public interface CarPoolingObserver {
}

View File

@ -1,6 +1,6 @@
package org.insa.algo.carpooling; package org.insa.graphs.algorithm.carpooling;
import org.insa.algo.AbstractSolution; import org.insa.graphs.algorithm.AbstractSolution;
public class CarPoolingSolution extends AbstractSolution { public class CarPoolingSolution extends AbstractSolution {

View File

@ -1,4 +1,4 @@
package org.insa.algo.carpooling; package org.insa.graphs.algorithm.carpooling;
public class CarPoolingTextObserver implements CarPoolingObserver { public class CarPoolingTextObserver implements CarPoolingObserver {

View File

@ -1,6 +1,6 @@
package org.insa.algo.packageswitch; package org.insa.graphs.algorithm.packageswitch;
import org.insa.algo.AbstractAlgorithm; import org.insa.graphs.algorithm.AbstractAlgorithm;
public abstract class PackageSwitchAlgorithm extends AbstractAlgorithm<PackageSwitchObserver> { public abstract class PackageSwitchAlgorithm extends AbstractAlgorithm<PackageSwitchObserver> {

View File

@ -0,0 +1,13 @@
package org.insa.graphs.algorithm.packageswitch;
import org.insa.graphs.algorithm.AbstractInputData;
import org.insa.graphs.algorithm.ArcInspector;
import org.insa.graphs.model.Graph;
public class PackageSwitchData extends AbstractInputData {
protected PackageSwitchData(Graph graph, ArcInspector arcFilter) {
super(graph, arcFilter);
}
}

View File

@ -1,4 +1,4 @@
package org.insa.algo.packageswitch; package org.insa.graphs.algorithm.packageswitch;
public class PackageSwitchGraphicObserver implements PackageSwitchObserver { public class PackageSwitchGraphicObserver implements PackageSwitchObserver {

View File

@ -0,0 +1,5 @@
package org.insa.graphs.algorithm.packageswitch;
public interface PackageSwitchObserver {
}

View File

@ -1,6 +1,6 @@
package org.insa.algo.packageswitch; package org.insa.graphs.algorithm.packageswitch;
import org.insa.algo.AbstractSolution; import org.insa.graphs.algorithm.AbstractSolution;
public class PackageSwitchSolution extends AbstractSolution { public class PackageSwitchSolution extends AbstractSolution {

View File

@ -1,4 +1,4 @@
package org.insa.algo.packageswitch; package org.insa.graphs.algorithm.packageswitch;
public class PackageSwitchTextObserver implements PackageSwitchObserver { public class PackageSwitchTextObserver implements PackageSwitchObserver {

View File

@ -1,4 +1,4 @@
package org.insa.algo.shortestpath; package org.insa.graphs.algorithm.shortestpath;
public class AStarAlgorithm extends DijkstraAlgorithm { public class AStarAlgorithm extends DijkstraAlgorithm {

View File

@ -1,14 +1,14 @@
package org.insa.algo.shortestpath; package org.insa.graphs.algorithm.shortestpath;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import org.insa.algo.AbstractSolution.Status; import org.insa.graphs.algorithm.AbstractSolution.Status;
import org.insa.graph.Arc; import org.insa.graphs.model.Arc;
import org.insa.graph.Graph; import org.insa.graphs.model.Graph;
import org.insa.graph.Node; import org.insa.graphs.model.Node;
import org.insa.graph.Path; import org.insa.graphs.model.Path;
public class BellmanFordAlgorithm extends ShortestPathAlgorithm { public class BellmanFordAlgorithm extends ShortestPathAlgorithm {

View File

@ -1,4 +1,4 @@
package org.insa.algo.shortestpath; package org.insa.graphs.algorithm.shortestpath;
public class DijkstraAlgorithm extends ShortestPathAlgorithm { public class DijkstraAlgorithm extends ShortestPathAlgorithm {
@ -8,7 +8,7 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
@Override @Override
protected ShortestPathSolution doRun() { protected ShortestPathSolution doRun() {
ShortestPathData data = getInputData(); final ShortestPathData data = getInputData();
ShortestPathSolution solution = null; ShortestPathSolution solution = null;
// TODO: // TODO:
return solution; return solution;

View File

@ -1,7 +1,7 @@
package org.insa.algo.shortestpath; package org.insa.graphs.algorithm.shortestpath;
import org.insa.algo.AbstractAlgorithm; import org.insa.graphs.algorithm.AbstractAlgorithm;
import org.insa.graph.Node; import org.insa.graphs.model.Node;
public abstract class ShortestPathAlgorithm extends AbstractAlgorithm<ShortestPathObserver> { public abstract class ShortestPathAlgorithm extends AbstractAlgorithm<ShortestPathObserver> {

View File

@ -1,9 +1,9 @@
package org.insa.algo.shortestpath; package org.insa.graphs.algorithm.shortestpath;
import org.insa.algo.AbstractInputData; import org.insa.graphs.algorithm.AbstractInputData;
import org.insa.algo.ArcInspector; import org.insa.graphs.algorithm.ArcInspector;
import org.insa.graph.Graph; import org.insa.graphs.model.Graph;
import org.insa.graph.Node; import org.insa.graphs.model.Node;
public class ShortestPathData extends AbstractInputData { public class ShortestPathData extends AbstractInputData {

View File

@ -1,6 +1,6 @@
package org.insa.algo.shortestpath; package org.insa.graphs.algorithm.shortestpath;
import org.insa.graph.Node; import org.insa.graphs.model.Node;
public interface ShortestPathObserver { public interface ShortestPathObserver {

View File

@ -1,21 +1,14 @@
package org.insa.algo.shortestpath; package org.insa.graphs.algorithm.shortestpath;
import org.insa.algo.AbstractInputData.Mode; import org.insa.graphs.algorithm.AbstractInputData.Mode;
import org.insa.algo.AbstractSolution; import org.insa.graphs.model.Arc;
import org.insa.graph.Arc; import org.insa.graphs.model.Path;
import org.insa.graph.Path; import org.insa.graphs.algorithm.AbstractSolution;
public class ShortestPathSolution extends AbstractSolution { public class ShortestPathSolution extends AbstractSolution {
// Optimal solution. // Optimal solution.
private Path path; private final Path path;
/**
* {@inheritDoc}
*/
public ShortestPathSolution(ShortestPathData data) {
super(data);
}
/** /**
* Create a new infeasible shortest-path solution for the given input and * Create a new infeasible shortest-path solution for the given input and
@ -26,6 +19,7 @@ public class ShortestPathSolution extends AbstractSolution {
*/ */
public ShortestPathSolution(ShortestPathData data, Status status) { public ShortestPathSolution(ShortestPathData data, Status status) {
super(data, status); super(data, status);
this.path = null;
} }
/** /**

View File

@ -1,8 +1,8 @@
package org.insa.algo.shortestpath; package org.insa.graphs.algorithm.shortestpath;
import java.io.PrintStream; import java.io.PrintStream;
import org.insa.graph.Node; import org.insa.graphs.model.Node;
public class ShortestPathTextObserver implements ShortestPathObserver { public class ShortestPathTextObserver implements ShortestPathObserver {

View File

@ -0,0 +1,205 @@
package org.insa.graphs.algorithm.utils;
import java.util.ArrayList;
/**
* Implements a binary heap containing elements of type E.
*
* Note that all comparisons are based on the compareTo method, hence E must
* implement Comparable
*
* @author Mark Allen Weiss
* @author DLB
*/
public class BinaryHeap<E extends Comparable<E>> implements PriorityQueue<E> {
// Number of elements in heap.
private int currentSize;
// The heap array.
protected final ArrayList<E> array;
/**
* Construct a new empty binary heap.
*/
public BinaryHeap() {
this.currentSize = 0;
this.array = new ArrayList<E>();
}
/**
* Construct a copy of the given heap.
*
* @param heap Binary heap to copy.
*/
public BinaryHeap(BinaryHeap<E> heap) {
this.currentSize = heap.currentSize;
this.array = new ArrayList<E>(heap.array);
}
/**
* Set an element at the given index.
*
* @param index Index at which the element should be set.
* @param value Element to set.
*/
private void arraySet(int index, E value) {
if (index == this.array.size()) {
this.array.add(value);
}
else {
this.array.set(index, value);
}
}
/**
* @return Index of the parent of the given index.
*/
protected int indexParent(int index) {
return (index - 1) / 2;
}
/**
* @return Index of the left child of the given index.
*/
protected int indexLeft(int index) {
return index * 2 + 1;
}
/**
* Internal method to percolate up in the heap.
*
* @param index Index at which the percolate begins.
*/
private void percolateUp(int index) {
E x = this.array.get(index);
for (; index > 0
&& x.compareTo(this.array.get(indexParent(index))) < 0; index = indexParent(
index)) {
E moving_val = this.array.get(indexParent(index));
this.arraySet(index, moving_val);
}
this.arraySet(index, x);
}
/**
* Internal method to percolate down in the heap.
*
* @param index Index at which the percolate begins.
*/
private void percolateDown(int index) {
int ileft = indexLeft(index);
int iright = ileft + 1;
if (ileft < this.currentSize) {
E current = this.array.get(index);
E left = this.array.get(ileft);
boolean hasRight = iright < this.currentSize;
E right = (hasRight) ? this.array.get(iright) : null;
if (!hasRight || left.compareTo(right) < 0) {
// Left is smaller
if (left.compareTo(current) < 0) {
this.arraySet(index, left);
this.arraySet(ileft, current);
this.percolateDown(ileft);
}
}
else {
// Right is smaller
if (right.compareTo(current) < 0) {
this.arraySet(index, right);
this.arraySet(iright, current);
this.percolateDown(iright);
}
}
}
}
@Override
public boolean isEmpty() {
return this.currentSize == 0;
}
@Override
public int size() {
return this.currentSize;
}
@Override
public void insert(E x) {
int index = this.currentSize++;
this.arraySet(index, x);
this.percolateUp(index);
}
@Override
public void remove(E x) throws ElementNotFoundException {
// TODO:
}
@Override
public E findMin() throws EmptyPriorityQueueException {
if (isEmpty())
throw new EmptyPriorityQueueException();
return this.array.get(0);
}
@Override
public E deleteMin() throws EmptyPriorityQueueException {
E minItem = findMin();
E lastItem = this.array.get(--this.currentSize);
this.arraySet(0, lastItem);
this.percolateDown(0);
return minItem;
}
/**
* Creates a multi-lines string representing a sorted view of this binary heap.
*
* @return a string containing a sorted view this binary heap.
*/
public String toStringSorted() {
return BinaryHeapFormatter.toStringSorted(this, -1);
}
/**
* Creates a multi-lines string representing a sorted view of this binary heap.
*
* @param maxElement Maximum number of elements to display. or {@code -1} to
* display all the elements.
*
* @return a string containing a sorted view this binary heap.
*/
public String toStringSorted(int maxElement) {
return BinaryHeapFormatter.toStringSorted(this, maxElement);
}
/**
* Creates a multi-lines string representing a tree view of this binary heap.
*
* @return a string containing a tree view of this binary heap.
*/
public String toStringTree() {
return BinaryHeapFormatter.toStringTree(this, Integer.MAX_VALUE);
}
/**
* Creates a multi-lines string representing a tree view of this binary heap.
*
* @param maxDepth Maximum depth of the tree to display.
*
* @return a string containing a tree view of this binary heap.
*/
public String toStringTree(int maxDepth) {
return BinaryHeapFormatter.toStringTree(this, maxDepth);
}
@Override
public String toString() {
return BinaryHeapFormatter.toStringTree(this, 8);
}
}

View File

@ -0,0 +1,198 @@
package org.insa.graphs.algorithm.utils;
import java.util.ArrayList;
public class BinaryHeapFormatter {
/**
* This class is used by {@link #toStringTree}, and simply contains three string
* accumulating. This is an immutable class.
*
*/
private static class Context {
// Output text:
public final String acu;
// Margin to get back exactly under the current position:
public final String margin;
// Last margin used for the last child of a node. The markers are different:
public final String lastmargin;
/**
* Creaet a new {@code Context}.
*
* @param acu The accumulated string.
* @param margin The current margin.
* @param lastMargin The last margin used.
*/
public Context(String acu, String margin, String lastMargin) {
this.acu = acu;
this.margin = margin;
this.lastmargin = lastMargin;
}
/**
* Creates a new context by appending newlines to this context.
*
* @param n Number of newlines to append.
*
* @return a new context with {@code n} newlines appended.
*/
public Context appendNewlines(int n) {
if (n <= 0) {
return this;
}
else {
return (new Context(this.acu + "\n" + this.margin, this.margin, this.lastmargin)
.appendNewlines(n - 1));
}
}
/**
* Creates a new context by appending the given string to this context.
*
* @param count Number of spaces to add to the margin, or {@code null} to use
* the length of the string.
* @param text String to append.
*
* @return a new context with {@code text} appended.
*/
public Context appendText(Integer count, String text) {
int cnt = (count == null) ? text.length() : count;
final String spaces = new String(new char[cnt]).replace('\0', ' ');
return new Context(this.acu + text, this.margin + spaces, this.lastmargin + spaces);
}
/**
* Creates a new context by appending a branch to this context.
*
* @param n Number of spaces to add to the margin, or {@code null} to use
* the length of the string.
* @param label Name of the branch.
*
* @return a new context with the branch appended.
*/
public Context appendBranch(Integer count, String label) {
final Context ctxt = this.appendText(count, label);
if (count == null) {
return new Context(ctxt.acu + "_", ctxt.margin + "|", ctxt.margin + " ");
}
else {
return new Context(ctxt.acu, ctxt.margin + "|", ctxt.margin + " ")
.appendNewlines(1);
}
}
}
/*
* Input : ready to write the current node at the current context position.
* Output : the last character of acu is the last character of the current node.
*/
protected static <E extends Comparable<E>> Context toStringLoop(BinaryHeap<E> heap,
Context ctxt, int node, int max_depth) {
if (max_depth < 0) {
return ctxt.appendText(null, "...");
}
else {
E nodeval = heap.array.get(node);
String nodevals = nodeval.toString();
ArrayList<Integer> childs = new ArrayList<Integer>();
// Add childs
int index_left = heap.indexLeft(node);
int index_right = index_left + 1;
if (index_left < heap.size()) {
childs.add(index_left);
}
if (index_right < heap.size()) {
childs.add(index_right);
}
Context ctxt2 = childs.isEmpty() ? ctxt.appendText(null, nodevals)
: ctxt.appendBranch(1, nodevals);
for (int ch = 0; ch < childs.size(); ch++) {
boolean is_last = (ch == childs.size() - 1);
int child = childs.get(ch);
if (is_last) {
Context ctxt3 = new Context(ctxt2.acu, ctxt2.lastmargin, ctxt2.lastmargin);
ctxt2 = new Context(toStringLoop(heap, ctxt3.appendText(null, "___"), child,
max_depth - 1).acu, ctxt2.margin, ctxt2.lastmargin);
}
else {
ctxt2 = new Context(toStringLoop(heap, ctxt2.appendText(null, "___"), child,
max_depth - 1).acu, ctxt2.margin, ctxt2.lastmargin).appendNewlines(2);
}
}
return ctxt2;
}
}
/**
* Creates a multi-lines string representing a tree view of the given binary
* heap.
*
* @param heap The binary heap to display.
* @param maxDepth Maximum depth of the tree to display.
*
* @return a string containing a tree view of the given binary heap.
*/
public static <E extends Comparable<E>> String toStringTree(BinaryHeap<E> heap, int maxDepth) {
final Context init_context = new Context(" ", " ", " ");
final Context result = toStringLoop(heap, init_context, 0, maxDepth);
return result.acu;
}
/**
* Creates a multi-lines string representing a sorted view of the given binary
* heap.
*
* @param heap The binary heap to display.
* @param maxElement Maximum number of elements to display. or {@code -1} to
* display all the elements.
*
* @return a string containing a sorted view the given binary heap.
*/
public static <E extends Comparable<E>> String toStringSorted(BinaryHeap<E> heap,
int max_elements) {
String result = "";
final BinaryHeap<E> copy = new BinaryHeap<E>(heap);
final String truncate;
if (max_elements < 0 || max_elements >= heap.size()) {
truncate = "";
}
else {
truncate = ", only " + max_elements + " elements are shown";
}
result += "======== Sorted HEAP (size = " + heap.size() + truncate + ") ========\n\n";
while (!copy.isEmpty() && max_elements-- != 0) {
result += copy.deleteMin() + "\n";
}
result += "\n-------- End of heap --------";
return result;
}
public static void main(String[] args) {
final BinaryHeap<Integer> heap = new BinaryHeap<Integer>();
for (int i = 0; i < 12; i++) {
heap.insert(i);
}
System.out.println(heap.toStringSorted(-1));
System.out.println(heap.toStringTree(6));
}
}

View File

@ -1,4 +1,4 @@
package org.insa.algo.utils; package org.insa.graphs.algorithm.utils;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;

View File

@ -1,4 +1,4 @@
package org.insa.algo.utils; package org.insa.graphs.algorithm.utils;
public class ElementNotFoundException extends RuntimeException { public class ElementNotFoundException extends RuntimeException {

View File

@ -1,4 +1,4 @@
package org.insa.algo.utils; package org.insa.graphs.algorithm.utils;
public class EmptyPriorityQueueException extends RuntimeException { public class EmptyPriorityQueueException extends RuntimeException {

View File

@ -1,4 +1,4 @@
package org.insa.algo.utils; package org.insa.graphs.algorithm.utils;
/** /**
* Interface representing a basic priority queue. * Interface representing a basic priority queue.

View File

@ -1,8 +1,8 @@
package org.insa.algo.weakconnectivity; package org.insa.graphs.algorithm.weakconnectivity;
import java.util.ArrayList; import java.util.ArrayList;
import org.insa.graph.Node; import org.insa.graphs.model.Node;
public interface WeaklyConnectedComponentObserver { public interface WeaklyConnectedComponentObserver {

View File

@ -1,9 +1,9 @@
package org.insa.algo.weakconnectivity; package org.insa.graphs.algorithm.weakconnectivity;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.ArrayList; import java.util.ArrayList;
import org.insa.graph.Node; import org.insa.graphs.model.Node;
public class WeaklyConnectedComponentTextObserver implements WeaklyConnectedComponentObserver { public class WeaklyConnectedComponentTextObserver implements WeaklyConnectedComponentObserver {

View File

@ -1,4 +1,4 @@
package org.insa.algo.weakconnectivity; package org.insa.graphs.algorithm.weakconnectivity;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -6,11 +6,11 @@ import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Queue; import java.util.Queue;
import org.insa.algo.AbstractAlgorithm; import org.insa.graphs.algorithm.AbstractAlgorithm;
import org.insa.algo.AbstractSolution.Status; import org.insa.graphs.algorithm.AbstractSolution.Status;
import org.insa.graph.Arc; import org.insa.graphs.model.Arc;
import org.insa.graph.Graph; import org.insa.graphs.model.Graph;
import org.insa.graph.Node; import org.insa.graphs.model.Node;
public class WeaklyConnectedComponentsAlgorithm public class WeaklyConnectedComponentsAlgorithm
extends AbstractAlgorithm<WeaklyConnectedComponentObserver> { extends AbstractAlgorithm<WeaklyConnectedComponentObserver> {

View File

@ -1,7 +1,7 @@
package org.insa.algo.weakconnectivity; package org.insa.graphs.algorithm.weakconnectivity;
import org.insa.algo.AbstractInputData; import org.insa.graphs.algorithm.AbstractInputData;
import org.insa.graph.Graph; import org.insa.graphs.model.Graph;
public class WeaklyConnectedComponentsData extends AbstractInputData { public class WeaklyConnectedComponentsData extends AbstractInputData {

View File

@ -1,9 +1,9 @@
package org.insa.algo.weakconnectivity; package org.insa.graphs.algorithm.weakconnectivity;
import java.util.ArrayList; import java.util.ArrayList;
import org.insa.algo.AbstractSolution; import org.insa.graphs.algorithm.AbstractSolution;
import org.insa.graph.Node; import org.insa.graphs.model.Node;
public class WeaklyConnectedComponentsSolution extends AbstractSolution { public class WeaklyConnectedComponentsSolution extends AbstractSolution {

View File

@ -1,4 +1,4 @@
package org.insa.algo.utils; package org.insa.graphs.algorithm.utils;
public class BinaryHeapTest extends PriorityQueueTest { public class BinaryHeapTest extends PriorityQueueTest {

View File

@ -1,4 +1,4 @@
package org.insa.algo.utils; package org.insa.graphs.algorithm.utils;
public class BinarySearchTreeTest extends PriorityQueueTest { public class BinarySearchTreeTest extends PriorityQueueTest {

View File

@ -1,4 +1,4 @@
package org.insa.algo.utils; package org.insa.graphs.algorithm.utils;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;

84
be-graphes-gui/pom.xml Normal file
View File

@ -0,0 +1,84 @@
<?xml version="1.0"?>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.insa.graphs</groupId>
<artifactId>be-graphes-all</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<properties>
<mapsforge.version>0.13.0</mapsforge.version>
</properties>
<artifactId>be-graphes-gui</artifactId>
<name>be-graphes-gui</name>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.insa.graphs</groupId>
<artifactId>be-graphes-model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.insa.graphs</groupId>
<artifactId>be-graphes-algos</artifactId>
<version>${project.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mapsforge/mapsforge-core -->
<dependency>
<groupId>net.sf.kxml</groupId>
<artifactId>kxml2</artifactId>
<version>2.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mapsforge/mapsforge-map-reader -->
<dependency>
<groupId>org.mapsforge</groupId>
<artifactId>mapsforge-themes</artifactId>
<version>${mapsforge.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mapsforge/mapsforge-map -->
<dependency>
<groupId>org.mapsforge</groupId>
<artifactId>mapsforge-map</artifactId>
<version>${mapsforge.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mapsforge/mapsforge-map-awt -->
<dependency>
<groupId>org.mapsforge</groupId>
<artifactId>mapsforge-map-awt</artifactId>
<version>${mapsforge.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mapsforge/mapsforge-map-reader -->
<dependency>
<groupId>org.mapsforge</groupId>
<artifactId>mapsforge-themes</artifactId>
<version>${mapsforge.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mapsforge/mapsforge-map-reader -->
<dependency>
<groupId>org.mapsforge</groupId>
<artifactId>mapsforge-map-reader</artifactId>
<version>${mapsforge.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +1,4 @@
package org.insa.graphics; package org.insa.graphs.gui;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
@ -22,15 +22,14 @@ import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import org.insa.algo.AbstractAlgorithm; import org.insa.graphs.algorithm.AbstractAlgorithm;
import org.insa.algo.AlgorithmFactory; import org.insa.graphs.algorithm.AlgorithmFactory;
import org.insa.algo.ArcInspector; import org.insa.graphs.algorithm.ArcInspector;
import org.insa.algo.ArcInspectorFactory; import org.insa.graphs.algorithm.ArcInspectorFactory;
import org.insa.graph.Node; import org.insa.graphs.gui.NodesInputPanel.InputChangedEvent;
import org.insa.graphics.NodesInputPanel.InputChangedEvent; import org.insa.graphs.gui.drawing.Drawing;
import org.insa.graphics.drawing.Drawing; import org.insa.graphs.gui.utils.ColorUtils;
import org.insa.graphics.drawing.components.MapViewDrawing; import org.insa.graphs.model.Node;
import org.insa.graphics.utils.ColorUtils;
public class AlgorithmPanel extends JPanel implements DrawingChangeListener { public class AlgorithmPanel extends JPanel implements DrawingChangeListener {
@ -118,9 +117,6 @@ public class AlgorithmPanel extends JPanel implements DrawingChangeListener {
// Graphic / Text checkbox observer // Graphic / Text checkbox observer
private final JCheckBox graphicObserverCheckbox, textualObserverCheckbox; private final JCheckBox graphicObserverCheckbox, textualObserverCheckbox;
// Drawing
private Drawing drawing = null;
private JButton startAlgoButton; private JButton startAlgoButton;
// Start listeners // Start listeners
@ -360,7 +356,7 @@ public class AlgorithmPanel extends JPanel implements DrawingChangeListener {
for (JComponent component: components) { for (JComponent component: components) {
component.setEnabled(enabled); component.setEnabled(enabled);
} }
graphicObserverCheckbox.setEnabled(enabled && !(drawing instanceof MapViewDrawing)); graphicObserverCheckbox.setEnabled(enabled);
enabled = enabled && allNotNull(this.nodesInputPanel.getNodeForInputs()); enabled = enabled && allNotNull(this.nodesInputPanel.getNodeForInputs());
startAlgoButton.setEnabled(enabled); startAlgoButton.setEnabled(enabled);
} }
@ -376,15 +372,6 @@ public class AlgorithmPanel extends JPanel implements DrawingChangeListener {
@Override @Override
public void onDrawingLoaded(Drawing oldDrawing, Drawing newDrawing) { public void onDrawingLoaded(Drawing oldDrawing, Drawing newDrawing) {
if (newDrawing instanceof MapViewDrawing) {
graphicObserverCheckbox.setSelected(false);
graphicObserverCheckbox.setEnabled(false);
}
else {
graphicObserverCheckbox.setSelected(true);
graphicObserverCheckbox.setEnabled(true);
}
this.drawing = newDrawing;
} }
@Override @Override

View File

@ -1,4 +1,4 @@
package org.insa.graphics; package org.insa.graphs.gui;
import java.awt.Component; import java.awt.Component;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;

View File

@ -1,6 +1,6 @@
package org.insa.graphics; package org.insa.graphs.gui;
import org.insa.graphics.drawing.Drawing; import org.insa.graphs.gui.drawing.Drawing;
public interface DrawingChangeListener { public interface DrawingChangeListener {

View File

@ -1,6 +1,6 @@
package org.insa.graphics; package org.insa.graphs.gui;
import org.insa.graph.Graph; import org.insa.graphs.model.Graph;
public interface GraphChangeListener { public interface GraphChangeListener {

View File

@ -1,4 +1,4 @@
package org.insa.graphics; package org.insa.graphs.gui;
import java.awt.Component; import java.awt.Component;
@ -11,10 +11,10 @@ import javax.swing.JPanel;
import javax.swing.JProgressBar; import javax.swing.JProgressBar;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import org.insa.graph.Arc; import org.insa.graphs.model.Arc;
import org.insa.graph.Node; import org.insa.graphs.model.Node;
import org.insa.graph.RoadInformation; import org.insa.graphs.model.RoadInformation;
import org.insa.graph.io.GraphReaderObserver; import org.insa.graphs.model.io.GraphReaderObserver;
/** /**
* One-time use GraphReaderObserver that display progress in three different * One-time use GraphReaderObserver that display progress in three different

View File

@ -1,4 +1,4 @@
package org.insa.graphics; package org.insa.graphs.gui;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
@ -21,13 +21,13 @@ import javax.swing.JTextField;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import org.insa.graph.Graph; import org.insa.graphs.gui.drawing.Drawing;
import org.insa.graph.Node; import org.insa.graphs.gui.drawing.Drawing.AlphaMode;
import org.insa.graph.Point; import org.insa.graphs.gui.drawing.DrawingClickListener;
import org.insa.graphics.drawing.Drawing; import org.insa.graphs.gui.drawing.overlays.MarkerOverlay;
import org.insa.graphics.drawing.Drawing.AlphaMode; import org.insa.graphs.model.Graph;
import org.insa.graphics.drawing.DrawingClickListener; import org.insa.graphs.model.Node;
import org.insa.graphics.drawing.overlays.MarkerOverlay; import org.insa.graphs.model.Point;
public class NodesInputPanel extends JPanel public class NodesInputPanel extends JPanel
implements DrawingClickListener, DrawingChangeListener, GraphChangeListener { implements DrawingClickListener, DrawingChangeListener, GraphChangeListener {

View File

@ -1,4 +1,4 @@
package org.insa.graphics; package org.insa.graphs.gui;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
@ -32,14 +32,14 @@ import javax.swing.border.EmptyBorder;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import org.insa.graph.Graph; import org.insa.graphs.gui.drawing.Drawing;
import org.insa.graph.Path; import org.insa.graphs.gui.drawing.overlays.PathOverlay;
import org.insa.graph.io.BinaryPathWriter; import org.insa.graphs.gui.utils.ColorUtils;
import org.insa.graphics.drawing.Drawing; import org.insa.graphs.gui.utils.FileUtils;
import org.insa.graphics.drawing.overlays.PathOverlay; import org.insa.graphs.gui.utils.FileUtils.FolderType;
import org.insa.graphics.utils.ColorUtils; import org.insa.graphs.model.Graph;
import org.insa.graphics.utils.FileUtils; import org.insa.graphs.model.Path;
import org.insa.graphics.utils.FileUtils.FolderType; import org.insa.graphs.model.io.BinaryPathWriter;
public class PathsPanel extends JPanel implements DrawingChangeListener, GraphChangeListener { public class PathsPanel extends JPanel implements DrawingChangeListener, GraphChangeListener {
@ -232,9 +232,8 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
if (chooser if (chooser
.showSaveDialog(getTopLevelAncestor()) == JFileChooser.APPROVE_OPTION) { .showSaveDialog(getTopLevelAncestor()) == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile(); File file = chooser.getSelectedFile();
try { try (BinaryPathWriter writer = new BinaryPathWriter(new DataOutputStream(
BinaryPathWriter writer = new BinaryPathWriter(new DataOutputStream( new BufferedOutputStream(new FileOutputStream(file))))) {
new BufferedOutputStream(new FileOutputStream(file))));
writer.writePath(path); writer.writePath(path);
} }
catch (IOException e1) { catch (IOException e1) {

View File

@ -1,4 +1,4 @@
package org.insa.graphics; package org.insa.graphs.gui;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;

View File

@ -1,4 +1,4 @@
package org.insa.graphics; package org.insa.graphs.gui;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
@ -19,12 +19,12 @@ import javax.swing.JPanel;
import javax.swing.border.CompoundBorder; import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import org.insa.algo.AbstractInputData; import org.insa.graphs.algorithm.AbstractInputData;
import org.insa.algo.AbstractSolution; import org.insa.graphs.algorithm.AbstractSolution;
import org.insa.graph.Graph; import org.insa.graphs.gui.drawing.Drawing;
import org.insa.graph.Path; import org.insa.graphs.gui.drawing.overlays.PathOverlay;
import org.insa.graphics.drawing.Drawing; import org.insa.graphs.model.Graph;
import org.insa.graphics.drawing.overlays.PathOverlay; import org.insa.graphs.model.Path;
public class SolutionPanel extends JPanel implements DrawingChangeListener, GraphChangeListener { public class SolutionPanel extends JPanel implements DrawingChangeListener, GraphChangeListener {
@ -122,6 +122,7 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap
/* /*
* (non-Javadoc) * (non-Javadoc)
*
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
public String toString() { public String toString() {

View File

@ -1,4 +1,4 @@
package org.insa.graphics; package org.insa.graphs.gui;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;

View File

@ -1,4 +1,4 @@
package org.insa.graphics; package org.insa.graphs.gui;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;

View File

@ -1,9 +1,9 @@
package org.insa.graphics.drawing; package org.insa.graphs.gui.drawing;
import java.awt.Color; import java.awt.Color;
import org.insa.graph.Arc; import org.insa.graphs.model.Arc;
import org.insa.graph.RoadInformation.RoadType; import org.insa.graphs.model.RoadInformation.RoadType;
public class BasicGraphPalette implements GraphPalette { public class BasicGraphPalette implements GraphPalette {

View File

@ -1,8 +1,8 @@
package org.insa.graphics.drawing; package org.insa.graphs.gui.drawing;
import java.awt.Color; import java.awt.Color;
import org.insa.graph.Arc; import org.insa.graphs.model.Arc;
public class BlackAndWhiteGraphPalette extends BasicGraphPalette { public class BlackAndWhiteGraphPalette extends BasicGraphPalette {

View File

@ -1,13 +1,13 @@
package org.insa.graphics.drawing; package org.insa.graphs.gui.drawing;
import java.awt.Color; import java.awt.Color;
import org.insa.graph.Graph; import org.insa.graphs.gui.drawing.overlays.MarkerOverlay;
import org.insa.graph.Path; import org.insa.graphs.gui.drawing.overlays.PathOverlay;
import org.insa.graph.Point; import org.insa.graphs.gui.drawing.overlays.PointSetOverlay;
import org.insa.graphics.drawing.overlays.MarkerOverlay; import org.insa.graphs.model.Graph;
import org.insa.graphics.drawing.overlays.PathOverlay; import org.insa.graphs.model.Path;
import org.insa.graphics.drawing.overlays.PointSetOverlay; import org.insa.graphs.model.Point;
public interface Drawing { public interface Drawing {

View File

@ -1,14 +1,14 @@
package org.insa.graphics.drawing; package org.insa.graphs.gui.drawing;
import org.insa.graph.Point; import org.insa.graphs.model.Point;
public interface DrawingClickListener { public interface DrawingClickListener {
/** /**
* Event triggered when a click is made on the map. * Event triggered when a click is made on the map.
* *
* @param point Position (on the map) of the mouse click. * @param point Position (on the map) of the mouse click.
*/ */
public void mouseClicked(Point point); public void mouseClicked(Point point);
} }

View File

@ -1,8 +1,8 @@
package org.insa.graphics.drawing; package org.insa.graphs.gui.drawing;
import java.awt.Color; import java.awt.Color;
import org.insa.graph.Arc; import org.insa.graphs.model.Arc;
public interface GraphPalette { public interface GraphPalette {

View File

@ -1,8 +1,8 @@
package org.insa.graphics.drawing; package org.insa.graphs.gui.drawing;
import java.awt.Dimension; import java.awt.Dimension;
import org.insa.graph.GraphStatistics.BoundingBox; import org.insa.graphs.model.GraphStatistics.BoundingBox;
public class MercatorProjection implements Projection { public class MercatorProjection implements Projection {

View File

@ -1,6 +1,6 @@
package org.insa.graphics.drawing; package org.insa.graphs.gui.drawing;
import org.insa.graph.GraphStatistics.BoundingBox; import org.insa.graphs.model.GraphStatistics.BoundingBox;
public class PlateCarreProjection implements Projection { public class PlateCarreProjection implements Projection {

View File

@ -1,4 +1,4 @@
package org.insa.graphics.drawing; package org.insa.graphs.gui.drawing;
public interface Projection { public interface Projection {

View File

@ -1,4 +1,4 @@
package org.insa.graphics.drawing.components; package org.insa.graphs.gui.drawing.components;
import java.awt.BasicStroke; import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;
@ -20,24 +20,24 @@ import java.util.List;
import javax.swing.JPanel; import javax.swing.JPanel;
import org.insa.graph.Arc; import org.insa.graphs.gui.drawing.BasicGraphPalette;
import org.insa.graph.Graph; import org.insa.graphs.gui.drawing.Drawing;
import org.insa.graph.GraphStatistics.BoundingBox; import org.insa.graphs.gui.drawing.DrawingClickListener;
import org.insa.graph.Node; import org.insa.graphs.gui.drawing.GraphPalette;
import org.insa.graph.Path; import org.insa.graphs.gui.drawing.MercatorProjection;
import org.insa.graph.Point; import org.insa.graphs.gui.drawing.PlateCarreProjection;
import org.insa.graphics.drawing.BasicGraphPalette; import org.insa.graphs.gui.drawing.Projection;
import org.insa.graphics.drawing.Drawing; import org.insa.graphs.gui.drawing.overlays.MarkerOverlay;
import org.insa.graphics.drawing.DrawingClickListener; import org.insa.graphs.gui.drawing.overlays.MarkerUtils;
import org.insa.graphics.drawing.GraphPalette; import org.insa.graphs.gui.drawing.overlays.Overlay;
import org.insa.graphics.drawing.MercatorProjection; import org.insa.graphs.gui.drawing.overlays.PathOverlay;
import org.insa.graphics.drawing.PlateCarreProjection; import org.insa.graphs.gui.drawing.overlays.PointSetOverlay;
import org.insa.graphics.drawing.Projection; import org.insa.graphs.model.Arc;
import org.insa.graphics.drawing.overlays.MarkerOverlay; import org.insa.graphs.model.Graph;
import org.insa.graphics.drawing.overlays.MarkerUtils; import org.insa.graphs.model.Node;
import org.insa.graphics.drawing.overlays.Overlay; import org.insa.graphs.model.Path;
import org.insa.graphics.drawing.overlays.PathOverlay; import org.insa.graphs.model.Point;
import org.insa.graphics.drawing.overlays.PointSetOverlay; import org.insa.graphs.model.GraphStatistics.BoundingBox;
/** /**
* *

View File

@ -1,465 +1,521 @@
package org.insa.graphics.drawing.components; package org.insa.graphs.gui.drawing.components;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.UUID; import java.util.List;
import java.util.UUID;
import org.insa.graph.Arc; import java.util.stream.Collectors;
import org.insa.graph.Graph;
import org.insa.graph.Path; import org.insa.graphs.gui.drawing.Drawing;
import org.insa.graph.Point; import org.insa.graphs.gui.drawing.DrawingClickListener;
import org.insa.graphics.drawing.Drawing; import org.insa.graphs.gui.drawing.GraphPalette;
import org.insa.graphics.drawing.DrawingClickListener; import org.insa.graphs.gui.drawing.overlays.MarkerAutoScaling;
import org.insa.graphics.drawing.GraphPalette; import org.insa.graphs.gui.drawing.overlays.MarkerOverlay;
import org.insa.graphics.drawing.overlays.MarkerAutoScaling; import org.insa.graphs.gui.drawing.overlays.MarkerUtils;
import org.insa.graphics.drawing.overlays.MarkerOverlay; import org.insa.graphs.gui.drawing.overlays.Overlay;
import org.insa.graphics.drawing.overlays.MarkerUtils; import org.insa.graphs.gui.drawing.overlays.PathOverlay;
import org.insa.graphics.drawing.overlays.Overlay; import org.insa.graphs.gui.drawing.overlays.PointSetOverlay;
import org.insa.graphics.drawing.overlays.PathOverlay; import org.insa.graphs.gui.drawing.overlays.PolylineAutoScaling;
import org.insa.graphics.drawing.overlays.PointSetOverlay; import org.insa.graphs.model.Arc;
import org.insa.graphics.drawing.overlays.PolylineAutoScaling; import org.insa.graphs.model.Graph;
import org.mapsforge.core.graphics.GraphicFactory; import org.insa.graphs.model.Path;
import org.mapsforge.core.model.BoundingBox; import org.insa.graphs.model.Point;
import org.mapsforge.core.model.LatLong; import org.mapsforge.core.graphics.GraphicFactory;
import org.mapsforge.core.model.MapPosition; import org.mapsforge.core.model.BoundingBox;
import org.mapsforge.core.util.LatLongUtils; import org.mapsforge.core.model.LatLong;
import org.mapsforge.core.util.Parameters; import org.mapsforge.core.model.MapPosition;
import org.mapsforge.map.awt.graphics.AwtGraphicFactory; import org.mapsforge.core.util.LatLongUtils;
import org.mapsforge.map.awt.util.AwtUtil; import org.mapsforge.core.util.Parameters;
import org.mapsforge.map.awt.view.MapView; import org.mapsforge.map.awt.graphics.AwtGraphicFactory;
import org.mapsforge.map.datastore.MapDataStore; import org.mapsforge.map.awt.util.AwtUtil;
import org.mapsforge.map.layer.Layer; import org.mapsforge.map.awt.view.MapView;
import org.mapsforge.map.layer.Layers; import org.mapsforge.map.datastore.MapDataStore;
import org.mapsforge.map.layer.cache.TileCache; import org.mapsforge.map.layer.Layer;
import org.mapsforge.map.layer.hills.HillsRenderConfig; import org.mapsforge.map.layer.Layers;
import org.mapsforge.map.layer.overlay.Marker; import org.mapsforge.map.layer.cache.TileCache;
import org.mapsforge.map.layer.renderer.TileRendererLayer; import org.mapsforge.map.layer.hills.HillsRenderConfig;
import org.mapsforge.map.model.DisplayModel; import org.mapsforge.map.layer.overlay.Marker;
import org.mapsforge.map.model.MapViewPosition; import org.mapsforge.map.layer.overlay.Polygon;
import org.mapsforge.map.model.Model; import org.mapsforge.map.layer.renderer.TileRendererLayer;
import org.mapsforge.map.reader.MapFile; import org.mapsforge.map.model.DisplayModel;
import org.mapsforge.map.rendertheme.InternalRenderTheme; import org.mapsforge.map.model.IMapViewPosition;
import org.mapsforge.map.model.Model;
/** import org.mapsforge.map.reader.MapFile;
* import org.mapsforge.map.rendertheme.InternalRenderTheme;
*/
public class MapViewDrawing extends MapView implements Drawing { /**
*
/** */
* public class MapViewDrawing extends MapView implements Drawing {
*/
private static final long serialVersionUID = 8606967833704938092L; /**
*
/** */
* Base Overlay for MapViewDrawing overlays. private static final long serialVersionUID = 8606967833704938092L;
*
*/ /**
private abstract class MapViewOverlay implements Overlay { * Base Overlay for MapViewDrawing overlays.
*
// Marker associated. */
protected Layer[] layers; private abstract class MapViewOverlay implements Overlay {
// Current color // Marker associated.
protected Color color; protected Layer[] layers;
public MapViewOverlay(Layer[] layers, Color color) { // Current color
this.layers = layers; protected Color color;
for (Layer layer: this.layers) {
MapViewDrawing.this.getLayerManager().getLayers().add(layer); public MapViewOverlay(Layer[] layers, Color color) {
} this.layers = layers;
this.color = color; for (Layer layer: this.layers) {
} MapViewDrawing.this.getLayerManager().getLayers().add(layer);
}
@Override this.color = color;
public void setColor(Color color) { }
this.color = color;
} @Override
public void setColor(Color color) {
@Override this.color = color;
public Color getColor() { }
return this.color;
} @Override
public Color getColor() {
@Override return this.color;
public void setVisible(boolean visible) { }
for (Layer layer: layers) {
layer.setVisible(visible); @Override
} public void setVisible(boolean visible) {
} for (Layer layer: layers) {
layer.setVisible(visible);
@Override }
public boolean isVisible() { }
if (this.layers.length == 0) {
return true; @Override
} public boolean isVisible() {
return this.layers[0].isVisible(); if (this.layers.length == 0) {
} return true;
}
@Override return this.layers[0].isVisible();
public void delete() { }
Layers mlayers = MapViewDrawing.this.getLayerManager().getLayers();
for (Layer layer: layers) { @Override
mlayers.remove(layer); public void delete() {
} Layers mlayers = MapViewDrawing.this.getLayerManager().getLayers();
} for (Layer layer: layers) {
mlayers.remove(layer);
@Override }
public void redraw() { }
MapViewDrawing.this.getLayerManager().redrawLayers();
} @Override
}; public void redraw() {
MapViewDrawing.this.getLayerManager().redrawLayers();
/** }
* MarkerOverlay for MapViewDrawing. };
*
*/ /**
private class MapViewMarkerOverlay extends MapViewOverlay implements MarkerOverlay { * MarkerOverlay for MapViewDrawing.
*
private final AlphaMode alphaMode; */
private Color innerColor; private class MapViewMarkerOverlay extends MapViewOverlay implements MarkerOverlay {
public MapViewMarkerOverlay(Marker marker, Color outer, Color innerColor, private final AlphaMode alphaMode;
AlphaMode alphaMode) { private Color innerColor;
super(new Layer[] { marker }, outer);
this.innerColor = innerColor; public MapViewMarkerOverlay(Marker marker, Color outer, Color innerColor,
this.alphaMode = alphaMode; AlphaMode alphaMode) {
} super(new Layer[] { marker }, outer);
this.innerColor = innerColor;
@Override this.alphaMode = alphaMode;
public Point getPoint() { }
Marker marker = (Marker) super.layers[0];
return new Point((float) marker.getLatLong().getLongitude(), @Override
(float) marker.getLatLong().getLatitude()); public Point getPoint() {
} Marker marker = (Marker) super.layers[0];
return new Point((float) marker.getLatLong().getLongitude(),
@Override (float) marker.getLatLong().getLatitude());
public void setColor(Color outer) { }
this.innerColor = this.innerColor.equals(this.color) ? outer : this.innerColor;
super.setColor(color); @Override
MarkerAutoScaling marker = (MarkerAutoScaling) super.layers[0]; public void setColor(Color outer) {
marker.setImage(MarkerUtils.getMarkerForColor(color, this.innerColor, this.alphaMode)); this.innerColor = this.innerColor.equals(this.color) ? outer : this.innerColor;
} super.setColor(color);
MarkerAutoScaling marker = (MarkerAutoScaling) super.layers[0];
@Override marker.setImage(MarkerUtils.getMarkerForColor(color, this.innerColor, this.alphaMode));
public void moveTo(Point point) { }
MarkerAutoScaling marker = (MarkerAutoScaling) this.layers[0];
this.delete(); @Override
marker = new MarkerAutoScaling(convertPoint(point), marker.getImage()); public void moveTo(Point point) {
this.layers[0] = marker; MarkerAutoScaling marker = (MarkerAutoScaling) this.layers[0];
MapViewDrawing.this.getLayerManager().getLayers().add(marker); this.delete();
} marker = new MarkerAutoScaling(convertPoint(point), marker.getImage());
this.layers[0] = marker;
}; MapViewDrawing.this.getLayerManager().getLayers().add(marker);
}
/**
* PathOverlay for MapViewDrawing. };
*
*/ /**
private class MapViewPathOverlay extends MapViewOverlay implements PathOverlay { * PathOverlay for MapViewDrawing.
*
public MapViewPathOverlay(PolylineAutoScaling path, MarkerAutoScaling origin, */
MarkerAutoScaling destination) { private class MapViewPathOverlay extends MapViewOverlay implements PathOverlay {
super(new Layer[] { path, origin, destination }, path.getColor());
} public MapViewPathOverlay(PolylineAutoScaling path, MarkerAutoScaling origin,
MarkerAutoScaling destination) {
public MapViewPathOverlay(PolylineAutoScaling path) { super(new Layer[] { path, origin, destination }, path.getColor());
super(new Layer[] { path }, path.getColor()); }
}
public MapViewPathOverlay(PolylineAutoScaling path) {
@Override super(new Layer[] { path }, path.getColor());
public void setColor(Color color) { }
super.setColor(color);
((PolylineAutoScaling) this.layers[0]).setColor(color); @Override
((MarkerAutoScaling) this.layers[1]) public void setColor(Color color) {
.setImage(MarkerUtils.getMarkerForColor(color, color, AlphaMode.TRANSPARENT)); super.setColor(color);
((MarkerAutoScaling) this.layers[2]) ((PolylineAutoScaling) this.layers[0]).setColor(color);
.setImage(MarkerUtils.getMarkerForColor(color, color, AlphaMode.TRANSPARENT)); ((MarkerAutoScaling) this.layers[1])
} .setImage(MarkerUtils.getMarkerForColor(color, color, AlphaMode.TRANSPARENT));
((MarkerAutoScaling) this.layers[2])
} .setImage(MarkerUtils.getMarkerForColor(color, color, AlphaMode.TRANSPARENT));
}
/**
* PointSetOverlay for MapViewDrawing - Not currently implemented. }
*
*/ /**
private class MapViewPointSetOverlay extends MapViewOverlay implements PointSetOverlay { * PointSetOverlay for MapViewDrawing - Not currently implemented.
*
public MapViewPointSetOverlay() { */
super(new Layer[0], Color.BLACK); private class MapViewPointSetOverlay extends MapViewOverlay implements PointSetOverlay {
}
private List<Point> points = new ArrayList<>();
@Override private final Polygon polygon;
public void setWidth(int width) {
} private List<Point> convexHull(List<Point> p) {
if (p.isEmpty()) {
@Override return new ArrayList<>();
public void setWidthAndColor(int width, Color color) { }
setWidth(width); p.sort((p1, p2) -> Float.compare(p1.getLongitude(), p2.getLongitude()));
setColor(color); List<Point> h = new ArrayList<>();
}
// lower hull
@Override for (Point pt: p) {
public void addPoint(Point point) { while (h.size() >= 2 && !ccw(h.get(h.size() - 2), h.get(h.size() - 1), pt)) {
} h.remove(h.size() - 1);
}
@Override h.add(pt);
public void addPoint(Point point, int width) { }
setWidth(width);
addPoint(point); // upper hull
} int t = h.size() + 1;
for (int i = p.size() - 1; i >= 0; i--) {
@Override Point pt = p.get(i);
public void addPoint(Point point, Color color) { while (h.size() >= t && !ccw(h.get(h.size() - 2), h.get(h.size() - 1), pt)) {
setColor(color); h.remove(h.size() - 1);
addPoint(point); }
} h.add(pt);
}
@Override
public void addPoint(Point point, int width, Color color) { h.remove(h.size() - 1);
setWidth(width); return h;
setColor(color); }
addPoint(point);
} // ccw returns true if the three points make a counter-clockwise turn
private boolean ccw(Point a, Point b, Point c) {
}; return ((b.getLongitude() - a.getLongitude())
* (c.getLatitude() - a.getLatitude())) > ((b.getLatitude() - a.getLatitude())
// Default path color. * (c.getLongitude() - a.getLongitude()));
public static final Color DEFAULT_PATH_COLOR = new Color(66, 134, 244); }
// Graphic factory. public MapViewPointSetOverlay() {
private static final GraphicFactory GRAPHIC_FACTORY = AwtGraphicFactory.INSTANCE; super(new Layer[] { new Polygon(GRAPHIC_FACTORY.createPaint(), null, GRAPHIC_FACTORY) },
Color.BLACK);
// Default tile size. polygon = (Polygon) this.layers[0];
private static final int DEFAULT_TILE_SIZE = 512; }
// List of listeners. @Override
private ArrayList<DrawingClickListener> drawingClickListeners = new ArrayList<>(); public void setColor(Color color) {
super.setColor(color);
// Tile size polygon.getPaintFill().setColor(GRAPHIC_FACTORY.createColor(100, color.getRed(),
private int tileSize; color.getGreen(), color.getBlue()));
}
// Zoom controls
private MapZoomControls zoomControls; @Override
public void setWidth(int width) {
public MapViewDrawing() { }
super();
Parameters.NUMBER_OF_THREADS = 2; @Override
Parameters.SQUARE_FRAME_BUFFER = false; public void setWidthAndColor(int width, Color color) {
setWidth(width);
getMapScaleBar().setVisible(true); setColor(color);
DisplayModel model = getModel().displayModel; }
this.tileSize = DEFAULT_TILE_SIZE;
model.setFixedTileSize(this.tileSize); @Override
public void addPoint(Point point) {
this.setZoomLevelMin((byte) 0); points.add(point);
this.setZoomLevelMax((byte) 20); this.points = convexHull(points);
polygon.setPoints(this.points.stream().map(MapViewDrawing.this::convertPoint)
// Try... .collect(Collectors.toList()));
try { polygon.requestRedraw();
this.zoomControls = new MapZoomControls(this, 0, 0, 20); }
this.zoomControls.addZoomInListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void addPoint(Point point, int width) {
getModel().mapViewPosition.zoomIn(); setWidth(width);
} addPoint(point);
}); }
this.zoomControls.addZoomOutListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void addPoint(Point point, Color color) {
getModel().mapViewPosition.zoomOut(); setColor(color);
} addPoint(point);
}); }
}
catch (IOException e) { @Override
e.printStackTrace(); public void addPoint(Point point, int width, Color color) {
} setWidth(width);
} setColor(color);
addPoint(point);
/* }
* (non-Javadoc)
* };
* @see org.mapsforge.map.awt.view.MapView#paint(java.awt.Graphics)
*/ // Default path color.
@Override public static final Color DEFAULT_PATH_COLOR = new Color(66, 134, 244);
public void paint(Graphics graphics) {
super.paint(graphics); // Graphic factory.
if (this.zoomControls != null) { private static final GraphicFactory GRAPHIC_FACTORY = AwtGraphicFactory.INSTANCE;
this.zoomControls.setZoomLevel(this.getModel().mapViewPosition.getZoomLevel());
this.zoomControls.draw((Graphics2D) graphics, // Default tile size.
getWidth() - this.zoomControls.getWidth() - 20, private static final int DEFAULT_TILE_SIZE = 512;
this.getHeight() - this.zoomControls.getHeight() - 10, this);
} // List of listeners.
private ArrayList<DrawingClickListener> drawingClickListeners = new ArrayList<>();
}
// Tile size
/* private int tileSize;
* (non-Javadoc)
* // Zoom controls
* @see org.insa.graphics.drawing.Drawing#clear() private MapZoomControls zoomControls;
*/
@Override public MapViewDrawing() {
public void clear() { super();
getLayerManager().getLayers().clear(); Parameters.NUMBER_OF_THREADS = 2;
repaint(); Parameters.SQUARE_FRAME_BUFFER = false;
}
getMapScaleBar().setVisible(true);
/* DisplayModel model = getModel().displayModel;
* (non-Javadoc) this.tileSize = DEFAULT_TILE_SIZE;
* model.setFixedTileSize(this.tileSize);
* @see org.insa.graphics.drawing.Drawing#clearOverlays()
*/ this.setZoomLevelMin((byte) 0);
@Override this.setZoomLevelMax((byte) 20);
public void clearOverlays() {
Layers layers = getLayerManager().getLayers(); // Try...
for (Layer layer: layers) { try {
if (layer instanceof PolylineAutoScaling || layer instanceof MarkerAutoScaling) { this.zoomControls = new MapZoomControls(this, 0, 0, 20);
getLayerManager().getLayers().remove(layer, false); this.zoomControls.addZoomInListener(new ActionListener() {
} @Override
} public void actionPerformed(ActionEvent e) {
repaint(); getModel().mapViewPosition.zoomIn();
} }
});
protected LatLong convertPoint(Point point) { this.zoomControls.addZoomOutListener(new ActionListener() {
return new LatLong(point.getLatitude(), point.getLongitude()); @Override
} public void actionPerformed(ActionEvent e) {
getModel().mapViewPosition.zoomOut();
private TileRendererLayer createTileRendererLayer(TileCache tileCache, }
MapDataStore mapDataStore, MapViewPosition mapViewPosition, });
HillsRenderConfig hillsRenderConfig) { }
TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore, catch (IOException e) {
mapViewPosition, false, true, false, GRAPHIC_FACTORY, hillsRenderConfig) { e.printStackTrace();
@Override }
public boolean onTap(LatLong tapLatLong, org.mapsforge.core.model.Point layerXY, }
org.mapsforge.core.model.Point tapXY) {
if (zoomControls.contains(new java.awt.Point((int) tapXY.x, (int) tapXY.y))) { /*
return false; * (non-Javadoc)
} *
Point pt = new Point((float) tapLatLong.getLongitude(), * @see org.mapsforge.map.awt.view.MapView#paint(java.awt.Graphics)
(float) tapLatLong.getLatitude()); */
for (DrawingClickListener listener: MapViewDrawing.this.drawingClickListeners) { @Override
listener.mouseClicked(pt); public void paint(Graphics graphics) {
} super.paint(graphics);
return true; if (this.zoomControls != null) {
} this.zoomControls.setZoomLevel(this.getModel().mapViewPosition.getZoomLevel());
}; this.zoomControls.draw((Graphics2D) graphics,
tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.DEFAULT); getWidth() - this.zoomControls.getWidth() - 20,
return tileRendererLayer; this.getHeight() - this.zoomControls.getHeight() - 10, this);
} }
@Override }
public void addDrawingClickListener(DrawingClickListener listener) {
this.drawingClickListeners.add(listener); /*
} * (non-Javadoc)
*
@Override * @see org.insa.graphics.drawing.Drawing#clear()
public void removeDrawingClickListener(DrawingClickListener listener) { */
this.drawingClickListeners.remove(listener); @Override
} public void clear() {
getLayerManager().getLayers().clear();
protected MarkerAutoScaling createMarker(Point point, Color outer, Color inner, repaint();
AlphaMode mode) { }
Image image = MarkerUtils.getMarkerForColor(outer, inner, mode);
return new MarkerAutoScaling(convertPoint(point), image); /*
} * (non-Javadoc)
*
@Override * @see org.insa.graphics.drawing.Drawing#clearOverlays()
public MarkerOverlay drawMarker(Point point, Color outer, Color inner, AlphaMode mode) { */
return new MapViewMarkerOverlay(createMarker(point, outer, inner, mode), outer, inner, @Override
mode); public void clearOverlays() {
} Layers layers = getLayerManager().getLayers();
for (Layer layer: layers) {
@Override if (layer instanceof PolylineAutoScaling || layer instanceof MarkerAutoScaling) {
public PointSetOverlay createPointSetOverlay() { getLayerManager().getLayers().remove(layer, false);
return new MapViewPointSetOverlay(); }
} }
repaint();
@Override }
public PointSetOverlay createPointSetOverlay(int width, Color color) {
PointSetOverlay ps = new MapViewPointSetOverlay(); protected LatLong convertPoint(Point point) {
ps.setWidthAndColor(width, color); return new LatLong(point.getLatitude(), point.getLongitude());
return ps; }
}
private TileRendererLayer createTileRendererLayer(TileCache tileCache,
public void drawGraph(File file) { MapDataStore mapDataStore, IMapViewPosition mapViewPosition,
HillsRenderConfig hillsRenderConfig) {
// Tile cache TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore,
TileCache tileCache = AwtUtil.createTileCache(tileSize, mapViewPosition, false, true, false, GRAPHIC_FACTORY, hillsRenderConfig) {
getModel().frameBufferModel.getOverdrawFactor(), 1024, @Override
new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString())); public boolean onTap(LatLong tapLatLong, org.mapsforge.core.model.Point layerXY,
org.mapsforge.core.model.Point tapXY) {
// Layers if (zoomControls.contains(new java.awt.Point((int) tapXY.x, (int) tapXY.y))) {
Layers layers = getLayerManager().getLayers(); return false;
}
MapDataStore mapDataStore = new MapFile(file); Point pt = new Point((float) tapLatLong.getLongitude(),
TileRendererLayer tileRendererLayer = createTileRendererLayer(tileCache, mapDataStore, (float) tapLatLong.getLatitude());
getModel().mapViewPosition, null); for (DrawingClickListener listener: MapViewDrawing.this.drawingClickListeners) {
layers.add(tileRendererLayer); listener.mouseClicked(pt);
BoundingBox boundingBox = mapDataStore.boundingBox(); }
return true;
final Model model = getModel(); }
if (model.mapViewPosition.getZoomLevel() == 0 };
|| !boundingBox.contains(model.mapViewPosition.getCenter())) { tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.DEFAULT);
byte zoomLevel = LatLongUtils.zoomForBounds(model.mapViewDimension.getDimension(), return tileRendererLayer;
boundingBox, model.displayModel.getTileSize()); }
model.mapViewPosition
.setMapPosition(new MapPosition(boundingBox.getCenterPoint(), zoomLevel)); @Override
zoomControls.setZoomLevel(zoomLevel); public void addDrawingClickListener(DrawingClickListener listener) {
} this.drawingClickListeners.add(listener);
}
}
@Override
@Override public void removeDrawingClickListener(DrawingClickListener listener) {
public void drawGraph(Graph graph, GraphPalette palette) { this.drawingClickListeners.remove(listener);
throw new RuntimeException("Not implemented, use drawGraph(File)."); }
}
protected MarkerAutoScaling createMarker(Point point, Color outer, Color inner,
@Override AlphaMode mode) {
public void drawGraph(Graph graph) { Image image = MarkerUtils.getMarkerForColor(outer, inner, mode);
throw new RuntimeException("Not implemented, use drawGraph(File)."); return new MarkerAutoScaling(convertPoint(point), image);
} }
@Override @Override
public PathOverlay drawPath(Path path, Color color, boolean markers) { public MarkerOverlay drawMarker(Point point, Color outer, Color inner, AlphaMode mode) {
PolylineAutoScaling line = new PolylineAutoScaling(1, color); return new MapViewMarkerOverlay(createMarker(point, outer, inner, mode), outer, inner,
ArrayList<Point> points = new ArrayList<>(path.getArcs().size() * 4); mode);
for (Arc arc: path.getArcs()) { }
points.addAll(arc.getPoints());
} @Override
line.addAll(points); public PointSetOverlay createPointSetOverlay() {
PathOverlay overlay = null; return new MapViewPointSetOverlay();
if (markers) { }
MarkerAutoScaling origin = createMarker(path.getOrigin().getPoint(), color, color,
AlphaMode.TRANSPARENT), @Override
destination = createMarker(path.getDestination().getPoint(), color, color, public PointSetOverlay createPointSetOverlay(int width, Color color) {
AlphaMode.TRANSPARENT); PointSetOverlay ps = new MapViewPointSetOverlay();
overlay = new MapViewPathOverlay(line, origin, destination); ps.setWidthAndColor(width, color);
} return ps;
else { }
overlay = new MapViewPathOverlay(line);
} public void drawGraph(File file) {
return overlay;
} // Tile cache
TileCache tileCache = AwtUtil.createTileCache(tileSize,
@Override getModel().frameBufferModel.getOverdrawFactor(), 1024,
public PathOverlay drawPath(Path path, Color color) { new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()));
return drawPath(path, color, true);
} // Layers
Layers layers = getLayerManager().getLayers();
@Override
public PathOverlay drawPath(Path path) { MapDataStore mapDataStore = new MapFile(file);
return drawPath(path, DEFAULT_PATH_COLOR, true); TileRendererLayer tileRendererLayer = createTileRendererLayer(tileCache, mapDataStore,
} getModel().mapViewPosition, null);
layers.add(tileRendererLayer);
@Override BoundingBox boundingBox = mapDataStore.boundingBox();
public PathOverlay drawPath(Path path, boolean markers) {
return drawPath(path, DEFAULT_PATH_COLOR, markers); final Model model = getModel();
} if (model.mapViewPosition.getZoomLevel() == 0
|| !boundingBox.contains(model.mapViewPosition.getCenter())) {
} byte zoomLevel = LatLongUtils.zoomForBounds(model.mapViewDimension.getDimension(),
boundingBox, model.displayModel.getTileSize());
model.mapViewPosition
.setMapPosition(new MapPosition(boundingBox.getCenterPoint(), zoomLevel));
zoomControls.setZoomLevel(zoomLevel);
}
}
@Override
public void drawGraph(Graph graph, GraphPalette palette) {
throw new RuntimeException("Not implemented, use drawGraph(File).");
}
@Override
public void drawGraph(Graph graph) {
throw new RuntimeException("Not implemented, use drawGraph(File).");
}
@Override
public PathOverlay drawPath(Path path, Color color, boolean markers) {
PolylineAutoScaling line = new PolylineAutoScaling(1, color);
ArrayList<Point> points = new ArrayList<>(path.getArcs().size() * 4);
for (Arc arc: path.getArcs()) {
points.addAll(arc.getPoints());
}
line.addAll(points);
PathOverlay overlay = null;
if (markers) {
MarkerAutoScaling origin = createMarker(path.getOrigin().getPoint(), color, color,
AlphaMode.TRANSPARENT),
destination = createMarker(path.getDestination().getPoint(), color, color,
AlphaMode.TRANSPARENT);
overlay = new MapViewPathOverlay(line, origin, destination);
}
else {
overlay = new MapViewPathOverlay(line);
}
return overlay;
}
@Override
public PathOverlay drawPath(Path path, Color color) {
return drawPath(path, color, true);
}
@Override
public PathOverlay drawPath(Path path) {
return drawPath(path, DEFAULT_PATH_COLOR, true);
}
@Override
public PathOverlay drawPath(Path path, boolean markers) {
return drawPath(path, DEFAULT_PATH_COLOR, markers);
}
}

View File

@ -1,4 +1,4 @@
package org.insa.graphics.drawing.components; package org.insa.graphs.gui.drawing.components;
import java.awt.BasicStroke; import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;

View File

@ -1,4 +1,4 @@
package org.insa.graphics.drawing.components; package org.insa.graphs.gui.drawing.components;
import java.awt.Component; import java.awt.Component;
import java.awt.Point; import java.awt.Point;

View File

@ -1,4 +1,4 @@
package org.insa.graphics.drawing.overlays; package org.insa.graphs.gui.drawing.overlays;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;

View File

@ -1,6 +1,6 @@
package org.insa.graphics.drawing.overlays; package org.insa.graphs.gui.drawing.overlays;
import org.insa.graph.Point; import org.insa.graphs.model.Point;
public interface MarkerOverlay extends Overlay { public interface MarkerOverlay extends Overlay {

View File

@ -1,97 +1,97 @@
package org.insa.graphics.drawing.overlays; package org.insa.graphs.gui.drawing.overlays;
import java.awt.Color; import java.awt.Color;
import java.awt.Image; import java.awt.Image;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.DataInputStream; import java.io.DataInputStream;
import org.insa.graphics.drawing.Drawing.AlphaMode; import org.insa.graphs.gui.drawing.Drawing.AlphaMode;
public class MarkerUtils { public class MarkerUtils {
/** /**
* Create an image to represent a marker using the given color for the outer and * Create an image to represent a marker using the given color for the outer and
* inner part, and the given mode for the inner part. * inner part, and the given mode for the inner part.
* *
* @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) {
// create image // create image
int[][] mask = readMarkerMask(); int[][] mask = readMarkerMask();
BufferedImage image = new BufferedImage(mask[0].length, mask.length, BufferedImage image = new BufferedImage(mask[0].length, mask.length,
BufferedImage.TYPE_4BYTE_ABGR); BufferedImage.TYPE_4BYTE_ABGR);
// Color[] map = getColorMapping(color); // Color[] map = getColorMapping(color);
int outerRGB = outer.getRGB() & 0x00ffffff; int outerRGB = outer.getRGB() & 0x00ffffff;
for (int i = 0; i < image.getHeight(); ++i) { for (int i = 0; i < image.getHeight(); ++i) {
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 && j < MAX_X_CENTER
&& mask[i][j] != MAXIMUM_INNER_MASK_VALUE) { && 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));
} }
} }
} }
return image; return image;
} }
// Mask cache // Mask cache
private static int[][] MASK_CACHE = null; private static int[][] MASK_CACHE = null;
// Hand-made... These defines the "center" of the marker, that can be filled // Hand-made... These defines the "center" of the marker, that can be filled
// 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.
*/ */
private static int[][] readMarkerMask() { private static int[][] readMarkerMask() {
if (MASK_CACHE == null) { if (MASK_CACHE == null) {
try { try {
DataInputStream dis = new DataInputStream( DataInputStream dis = new DataInputStream(
MarkerUtils.class.getResourceAsStream("/marker_mask.bin")); MarkerUtils.class.getResourceAsStream("/marker_mask.bin"));
int nrows = dis.readInt(); int nrows = dis.readInt();
int ncols = dis.readInt(); int ncols = dis.readInt();
MASK_CACHE = new int[nrows][ncols]; MASK_CACHE = new int[nrows][ncols];
for (int i = 0; i < nrows; ++i) { for (int i = 0; i < nrows; ++i) {
for (int j = 0; j < ncols; ++j) { for (int j = 0; j < ncols; ++j) {
MASK_CACHE[i][j] = dis.readUnsignedByte(); MASK_CACHE[i][j] = dis.readUnsignedByte();
} }
} }
dis.close(); dis.close();
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
MASK_CACHE = null; MASK_CACHE = null;
} }
} }
return MASK_CACHE; return MASK_CACHE;
} }
} }

View File

@ -1,4 +1,4 @@
package org.insa.graphics.drawing.overlays; package org.insa.graphs.gui.drawing.overlays;
import java.awt.Color; import java.awt.Color;

View File

@ -1,4 +1,4 @@
package org.insa.graphics.drawing.overlays; package org.insa.graphs.gui.drawing.overlays;
import java.awt.Color; import java.awt.Color;

View File

@ -1,4 +1,4 @@
package org.insa.graphics.drawing.overlays; package org.insa.graphs.gui.drawing.overlays;
public interface PathOverlay extends Overlay { public interface PathOverlay extends Overlay {

View File

@ -1,8 +1,8 @@
package org.insa.graphics.drawing.overlays; package org.insa.graphs.gui.drawing.overlays;
import java.awt.Color; import java.awt.Color;
import org.insa.graph.Point; import org.insa.graphs.model.Point;
public interface PointSetOverlay extends Overlay { public interface PointSetOverlay extends Overlay {

View File

@ -1,10 +1,10 @@
package org.insa.graphics.drawing.overlays; package org.insa.graphs.gui.drawing.overlays;
import java.awt.Color; import java.awt.Color;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import org.insa.graph.Point; import org.insa.graphs.model.Point;
import org.mapsforge.core.graphics.Canvas; import org.mapsforge.core.graphics.Canvas;
import org.mapsforge.core.graphics.GraphicFactory; import org.mapsforge.core.graphics.GraphicFactory;
import org.mapsforge.core.graphics.Style; import org.mapsforge.core.graphics.Style;

View File

@ -1,10 +1,11 @@
package org.insa.algo.shortestpath; package org.insa.graphs.gui.observers;
import java.awt.Color; import java.awt.Color;
import org.insa.graph.Node; import org.insa.graphs.algorithm.shortestpath.ShortestPathObserver;
import org.insa.graphics.drawing.Drawing; import org.insa.graphs.gui.drawing.Drawing;
import org.insa.graphics.drawing.overlays.PointSetOverlay; import org.insa.graphs.gui.drawing.overlays.PointSetOverlay;
import org.insa.graphs.model.Node;
public class ShortestPathGraphicObserver implements ShortestPathObserver { public class ShortestPathGraphicObserver implements ShortestPathObserver {

View File

@ -1,15 +1,17 @@
package org.insa.algo.weakconnectivity; package org.insa.graphs.gui.observers;
import java.awt.Color; import java.awt.Color;
import java.util.ArrayList; import java.util.ArrayList;
import org.insa.graph.Node; import org.insa.graphs.algorithm.weakconnectivity.WeaklyConnectedComponentObserver;
import org.insa.graphics.drawing.Drawing; import org.insa.graphs.gui.drawing.Drawing;
import org.insa.graphics.drawing.overlays.PointSetOverlay; import org.insa.graphs.gui.drawing.overlays.PointSetOverlay;
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, Color.RED }; private static final Color[] COLORS = { Color.BLUE, Color.ORANGE, Color.GREEN, Color.YELLOW,
Color.RED };
// Drawing + Graph drawing // Drawing + Graph drawing
private PointSetOverlay grPoints; private PointSetOverlay grPoints;

View File

@ -1,4 +1,4 @@
package org.insa.base; package org.insa.graphs.gui.simple;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Dimension; import java.awt.Dimension;
@ -9,13 +9,13 @@ import java.io.FileInputStream;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import org.insa.graph.Graph; import org.insa.graphs.gui.drawing.Drawing;
import org.insa.graph.Path; import org.insa.graphs.gui.drawing.components.BasicDrawing;
import org.insa.graph.io.BinaryGraphReader; import org.insa.graphs.model.Graph;
import org.insa.graph.io.GraphReader; import org.insa.graphs.model.Path;
import org.insa.graph.io.PathReader; import org.insa.graphs.model.io.BinaryGraphReader;
import org.insa.graphics.drawing.Drawing; import org.insa.graphs.model.io.GraphReader;
import org.insa.graphics.drawing.components.BasicDrawing; import org.insa.graphs.model.io.PathReader;
public class Launch { public class Launch {
@ -46,29 +46,28 @@ public class Launch {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// Visit these directory to see the list of available files on Commetud. // Visit these directory to see the list of available files on Commetud.
String mapName = "/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/insa.mapgr"; final String mapName = "/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/insa.mapgr";
String pathName = "/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Paths/path_fr31insa_rangueil_r2.path"; final String pathName = "/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Paths/path_fr31insa_rangueil_r2.path";
// Create a graph reader. // Create a graph reader.
GraphReader reader = new BinaryGraphReader( final GraphReader reader = new BinaryGraphReader(
new DataInputStream(new BufferedInputStream(new FileInputStream(mapName)))); new DataInputStream(new BufferedInputStream(new FileInputStream(mapName))));
// TODO: Read the graph. // TODO: Read the graph.
Graph graph = null; final Graph graph = null;
// Create the drawing: // Create the drawing:
Drawing drawing = createDrawing(); final Drawing drawing = createDrawing();
// TODO: Draw the graph on the drawing. // TODO: Draw the graph on the drawing.
// TODO: Create a PathReader. // TODO: Create a PathReader.
PathReader pathReader = null; final PathReader pathReader = null;
// TODO: Read the path. // TODO: Read the path.
Path path = null; final Path path = null;
// TODO: Draw the path. // TODO: Draw the path.
} }
} }

View File

@ -1,4 +1,4 @@
package org.insa.graphics.utils; package org.insa.graphs.gui.utils;
import java.awt.Color; import java.awt.Color;

View File

@ -1,4 +1,4 @@
package org.insa.graphics.utils; package org.insa.graphs.gui.utils;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

14
be-graphes-model/pom.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.insa.graphs</groupId>
<artifactId>be-graphes-all</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>be-graphes-model</artifactId>
<name>be-graphes-model</name>
</project>

View File

@ -1,4 +1,4 @@
package org.insa.graph; package org.insa.graphs.model;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.EnumSet; import java.util.EnumSet;

View File

@ -1,4 +1,4 @@
package org.insa.graph; package org.insa.graphs.model;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,4 @@
package org.insa.graph; package org.insa.graphs.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;

View File

@ -1,4 +1,4 @@
package org.insa.graph; package org.insa.graphs.model;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,4 @@
package org.insa.graph; package org.insa.graphs.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;

View File

@ -1,4 +1,4 @@
package org.insa.graph; package org.insa.graphs.model;
/** /**
* <p> * <p>

View File

@ -1,4 +1,4 @@
package org.insa.graph; package org.insa.graphs.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;

View File

@ -1,4 +1,4 @@
package org.insa.graph; package org.insa.graphs.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;

View File

@ -1,4 +1,4 @@
package org.insa.graph; package org.insa.graphs.model;
/** /**
* Class representing a point (position) on Earth. * Class representing a point (position) on Earth.

View File

@ -1,4 +1,4 @@
package org.insa.graph; package org.insa.graphs.model;
/** /**
* <p> * <p>

View File

@ -1,4 +1,4 @@
package org.insa.graph.io; package org.insa.graphs.model.io;
import java.io.IOException; import java.io.IOException;
@ -21,4 +21,13 @@ public class BadFormatException extends IOException {
super(); super();
} }
/**
* Create a new format exception with the given message.
*
* @param message Message for the exception.
*/
public BadFormatException(String message) {
super(message);
}
} }

Some files were not shown because too many files have changed in this diff Show More