The JBotSim Library
- Introduction
- Hello World example
- Current version
- Maven dependency
- Project structure
- Issue tracking
- Contributing to JBotSim
- License
- Binaries signing
Introduction
JBotSim is a simulation library for distributed algorithms in dynamic networks. The style of programming is mainly event-driven: your code can react to various events (pulse of a clock, appearance/disappearance of a link, arrival of a message, movement of the node, etc.). Node movements can be controlled by program (e.g. mobile robots or mobility models), or by means of mouse-based interactions during the execution. Beyond its features, the main asset of JBotSim is its simplicity of use.
Hello World example
JBotSim's HelloWorld is pretty simple. We simply need to:
- declare the dependency to JBotSim,
- provide the HelloWorld.java class.
It is that simple!
Declaring the dependency
Here, we work with a IntelliJ IDEA Java project, fetching dependencies from Maven Central. Other configurations are detailed here.
For this HelloWorld, we will simply retrieve the jbotsim-all
artifact (See Which artifact should I use? section to easily find out which artifact will best suit your project's needs):
-
Open the Project Structure popup
File
>Project Structure
-
Open the "New Project Library" popup:
- select
Libraries
in the left panel - click
+
- choose
From Maven ...
.
- select
-
In the "Download Library from Maven Repository" popup:
- provide the following dependence
io.jbotsim:jbotsim-all:1.2.0
- make sure to tick
JavaDocs
- Hit
OK
.
- provide the following dependence
-
Confirm that you want to add it to your (only) module.
And you are done! You can start to use the example code.
Maven will take care of retrieving any required dependencies.
HelloWorld class
The source code of this example is pretty straightforward. You can also download the file from here.
import io.jbotsim.core.Topology;
import io.jbotsim.ui.JViewer;
public class HelloWorld{
public static void main(String[] args){
Topology tp = new Topology();
new JViewer (tp);
tp.start();
}
}
- We simply create a
Topology
, which is the main object of JBotSim and thus contains the main information of the simulation. - We pass it to a
JViewer
, which will display the simulation elements and allow the user to interact with it. - And eventually, we start the simulation (
tp.start();
). Since we use aJViewer
, this step could also be done by the user by selecting "Start execution" in theJViewer
's contextual menu (right click anywhere).
Please see the Examples section of JBotSim's website for more examples.
Current version
The latest public version is 1.2.0
. Please see the CHANGELOG.md for previous versions modifications.
Retrieving JBotSim
There are two ways to depend on JBotSim's API:
-
using Maven
This is the preferred way to depend on JBotSim. It is flexible and convenient: you don't need to download anything manually or bother about dependencies.
-
using one of the standalone jars
This is the way JBotSim was originally published. It is less flexible, but can still be used for existing/straightforward projects.
Maven dependency
Although the example provided here should work in most cases, you might want to head to the Which artifact should I use? section for a finer grain explanation of which artifact(s) can suit your needs.
Using Maven is the preferred way to retrieve JBotSim (over standalone fat jars).
Using Gradle
If your build system uses Gradle, you will want to add something like this to your build.gradle
:
dependencies {
implementation "io.jbotsim:jbotsim-all:1.2.0"
}
Using Maven
If your build system uses Maven, you will want to add something like this to your .pom
:
<dependency>
<groupId>io.jbotsim</groupId>
<artifactId>jbotsim-all</artifactId>
<version>1.2.0</version>
</dependency>
Using IntelliJ IDEA
If you use a Java Project in IntelliJ IDEA, add the following dependency (as explained here):
io.jbotsim:jbotsim-all:1.2.0
Project structure
The JBotSim project is separated in three main modules. Please follow the links to each of them for more information:
apps
: contains some sample apps and mains using modules fromlib
.lib
: contains submodules responsible for the generation and publication of unitary jars files on Maven Central.fats
: contains submodules responsible for the generation of standalone fat jars by using existing published JBotSim jars (published bylib
).
Issue tracking
JBotSim's issues are currently tracked on GitHub. If you feel like something is missing or buggy, please feel free to create a ticket (a check on existing/former tickets can't hurt! ;-).
Contributing to JBotSim
The JBotSim project will gladly welcome help. If you consider contributing, please refer to CONTRIBUTING.md
.
License
(C) Copyright 2008-2020, by Arnaud Casteigts and the JBotSim contributors. All rights reserved.
JBotSim is published under license LGPL 3.0 or later.
A copy of the license should be available in the product. The repository also contains a copy of the GPL and a copy of the LGPL. You can also access copies of the license at https://www.gnu.org/licenses/.
SPDX-License-Identifier: LGPL-3.0-or-later
Binaries signing
JBotSim's artifacts are signed with JBotSim project's PGP key (DFA48EDB1EDEBA6F
) displaying "Arnaud Casteigts (JBotSim project) <[email protected]>".
Should you ever need to verify that your binaries actually come from us, you can retrieve the public key with the following command:
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys DFA48EDB1EDEBA6F