diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Direction.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Direction.java
index 9d372c2a6..10d657617 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Direction.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Direction.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -23,9 +23,9 @@
*
* {@link #WEST} is at the left of the screen ({@link Position#getX()} getting smaller)
*
- *
+ *
* @see Position
- *
+ *
* @author Tim Neumann
*/
public enum Direction {
@@ -37,10 +37,10 @@ public enum Direction {
SOUTH,
/** The west direction; at the left of the screen ({@link Position#getX()} getting smaller) */
WEST;
-
+
/**
* Get the direction that is next in a clock wise rotation
- *
+ *
* @return The next direction
*/
public Direction clockWiseNext() {
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/MultiTypedList.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/MultiTypedList.java
index 7b1d028c1..d79aff19f 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/MultiTypedList.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/MultiTypedList.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -18,18 +18,18 @@
/**
* A list which can contain and return multiple types.
- *
+ *
* @author Tim Neumann
* @param
* The parent type of all types contained in this list.
*/
public class MultiTypedList
{
-
+
private final HashMap, List> items = new HashMap<>();
-
+
/**
* Get the relevant list for the given type.
- *
+ *
* @param type
* The type to get the list for
* @return an Optional with the list if it exists, otherwise an empty Optional
@@ -43,7 +43,7 @@ private Optional> getRelevantListGeneric(final Class ext
final var listOfCorrectType = (List) list;
return Optional.ofNullable(listOfCorrectType);
}
-
+
private Class extends P> getClass(final P o) {
//Actually a cast should not be necessary here.
//Should be totally safe, because o is of type P, so o.getClass() should extend P.
@@ -51,10 +51,10 @@ private Class extends P> getClass(final P o) {
final var type = (Class extends P>) o.getClass();
return type;
}
-
+
/**
* Get the relevant list for the given object.
- *
+ *
* @param o
* The object to get the list for
* @return an Optional with the list if it exists, otherwise an empty Optional
@@ -62,10 +62,10 @@ private Class extends P> getClass(final P o) {
private Optional> getRelevantList(final P o) {
return this.getRelevantListGeneric(this.getClass(o));
}
-
+
/**
* Get the relevant list for the given entity and create it if it is not there.
- *
+ *
* @param o
* The object to get the list for
* @return The list for the given object
@@ -73,25 +73,25 @@ private Optional> getRelevantList(final P o) {
private List getRelevantListAndCreate(final P o) {
final var type = this.getClass(o);
if (this.items.containsKey(type)) return this.items.get(type);
-
+
final List
list = new ArrayList<>();
this.items.put(type, list);
return list;
}
-
+
/**
* Add the given object to this list.
- *
+ *
* @param o
* The object to add
*/
public synchronized void add(final P o) {
this.getRelevantListAndCreate(o).add(o);
}
-
+
/**
* Check whether this list contains the given object.
- *
+ *
* @param o
* The object to check for
* @return Whether this list contains the given object
@@ -101,19 +101,19 @@ public synchronized boolean contains(final P o) {
if (opt.isEmpty()) return false;
return opt.get().contains(o);
}
-
+
/**
* Return {@code true} iff the list contains no objects.
- *
+ *
* @return {@code true} if empty
*/
public synchronized boolean isEmpty() {
return this.items.isEmpty();
}
-
+
/**
* Remove the given object from this list.
- *
+ *
* @param o
* The object to remove
* @return Whether this cell contained the given object
@@ -123,10 +123,10 @@ public synchronized boolean remove(final P o) {
if (opt.isEmpty()) return false;
return opt.get().remove(o);
}
-
+
/**
* Get all objects in this list of the given type.
- *
+ *
* @param
* The generic type to return the objects as
* @param type
@@ -137,9 +137,9 @@ public synchronized boolean remove(final P o) {
*/
public synchronized List get(final Class extends T> type, final boolean includeSubclasses) {
if (!includeSubclasses) return this.getRelevantListGeneric(type).orElse(List.of());
-
+
final List result = new ArrayList<>();
-
+
for (final Class extends P> storedType : this.items.keySet()) {
if (type.isAssignableFrom(storedType)) {
final Class extends T> storedTypeAsSubOfRequested = storedType.asSubclass(type);
@@ -147,10 +147,10 @@ public synchronized List get(final Class extends T> type, fin
result.addAll(listForStoredType);
}
}
-
+
return result;
}
-
+
/**
* @return a list of stored types.
*/
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Playfield.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Playfield.java
index 785bf8d3b..78f3f8279 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Playfield.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Playfield.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -21,26 +21,26 @@
/**
* The interface for the playfield of the simulation
- *
+ *
* @author Tim Neumann
*/
public interface Playfield {
-
+
/**
* @return the simulation this playfield is part of
*/
Simulation getSimulation();
-
+
/**
* Get a list of all entities on this playfield.
- *
+ *
* @return A list of all entities
*/
List getAllEntities();
-
+
/**
* Get a list of all entities matching the given type on this playfield.
- *
+ *
* @param
* The generic type to return the entities as
* @param type
@@ -52,10 +52,10 @@ public interface Playfield {
* if the given type is null
*/
List getAllEntitiesOfType(Class extends T> type, boolean includeSubclasses);
-
+
/**
* Get a list of all entities at the given position on this playfield.
- *
+ *
* @param pos
* The position at which to get the entities; must not be null
* @return A list of all entities at that position
@@ -63,10 +63,10 @@ public interface Playfield {
* if the given pos is null
*/
List getEntitiesAt(final Position pos);
-
+
/**
* Get a list of all entities matching the given type at the given position on this playfield.
- *
+ *
* @param
* The generic type to return the entities as
* @param pos
@@ -80,15 +80,15 @@ public interface Playfield {
* if the given pos or type is null
*/
List getEntitiesOfTypeAt(final Position pos, Class extends T> type, boolean includeSubclasses);
-
+
/**
* Add a given entity to this simulation at a given position on this playfield.
- *
+ *
* @param pos
* The position to add the entity; must not be null
* @param entity
* The entity to add; must not be on the field; must not be null
- *
+ *
* @throws EntityAlreadyOnFieldExcpetion
* if the given entity has been added to this playfield before
* @throws EntityOnAnotherFieldException
@@ -97,13 +97,13 @@ public interface Playfield {
* if the given pos or entity is null
*/
void addEntity(Position pos, Entity entity);
-
+
/**
* Move a entity of this simulation to a given position on this playfield.
*
* This causes a {@link EntityTeleportAction}.
*
- *
+ *
* @param entity
* The entity to move; must be on the field; must not be null
* @param pos
@@ -114,10 +114,10 @@ public interface Playfield {
* if the given pos or entity is null
*/
void moveEntity(Entity entity, Position pos);
-
+
/**
* Move a entity of this simulation to a given position on this playfield.
- *
+ *
* @param entity
* The entity to move; must be on the field; must not be null
* @param pos
@@ -132,10 +132,10 @@ public interface Playfield {
* if the given action match with the other arguments
*/
void moveEntity(Entity entity, Position pos, EntityMoveAction action);
-
+
/**
* Remove a entity of this simulation from this playfield.
- *
+ *
* @param entity
* The entity to add; must be on the field; must not be null
* @throws EntityNotOnFieldException
@@ -144,10 +144,10 @@ public interface Playfield {
* if the given entity is null
*/
void removeEntity(Entity entity);
-
+
/**
* Get the position of the specified entity on the playfield.
- *
+ *
* @param entity
* The entity to get the position of; must be on the field; must not be null
* @return The position of the given entity
@@ -157,10 +157,10 @@ public interface Playfield {
* if the given entity is null
*/
Position getEntityPosition(Entity entity);
-
+
/**
* Check whether the specified entity is on this playfield.
- *
+ *
* @param entity
* The entity to check; must not be null
* @return whether the given entity is on this playfield
@@ -168,10 +168,10 @@ public interface Playfield {
* if the given entity is null
*/
boolean containsEntity(Entity entity);
-
+
/**
* Check whether a solid entity is at the given position.
- *
+ *
* @param pos
* The position to check
* @return true if and only if a solid entity is at that position
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Position.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Position.java
index 736da7348..56f61ac3f 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Position.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Position.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -17,7 +17,7 @@
*
* Objects of this class are immutable
*
- *
+ *
*
* x is the row; negative towards the top ({@link Direction#NORTH}) and positive towards the bottom
* ({@link Direction#SOUTH})
@@ -26,18 +26,18 @@
* y is the column; negative towards the left ({@link Direction#WEST}) and positive towards the right
* ({@link Direction#EAST})
*
- *
+ *
* @see Direction
- *
+ *
* @author Tim Neumann
*/
public class Position {
private final int x;
private final int y;
-
+
/**
* Create a new position from the given parameters.
- *
+ *
* @param x
* The x coordinate for the new position
* @param y
@@ -47,24 +47,24 @@ public Position(final int x, final int y) {
this.x = x;
this.y = y;
}
-
+
/**
* @return the x coordinate of this position
*/
public int getX() {
return this.x;
}
-
+
/**
* @return the y coordinate of this position
*/
public int getY() {
return this.y;
}
-
+
/**
* Get the adjacent position in the given direction.
- *
+ *
* @param direction
* The direction to get the adjacent position in
* @return The position adjacent to this in the given direction
@@ -83,20 +83,20 @@ public Position adjacentPosition(final Direction direction) {
throw new IllegalArgumentException("Unknown direction");
}
}
-
+
@Override
public boolean equals(final Object o) {
if (!(o instanceof Position)) return false;
final Position p = (Position) o;
return (this.x == p.getX()) && (this.y == p.getY());
}
-
+
@Override
public int hashCode() {
final int[] numbers = { this.x, this.y };
return Arrays.hashCode(numbers);
}
-
+
@Override
public String toString() {
return "(x=" + this.x + ", y=" + this.y + ")";
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Simulation.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Simulation.java
index 9ebeb8bab..9c6828f9c 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Simulation.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/Simulation.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -30,80 +30,80 @@ public interface Simulation {
* @return The playfield used by this simulation
*/
Playfield getPlayfield();
-
+
/**
* Get the task verifier set for this simulation.
*
* @return The task verifier set for this simulation
*/
TaskVerifier getTaskVerifier();
-
+
/**
* Get the simulation clock for this simulation.
*
* @return the simulation clock used by this simulation
*/
SimulationClock getSimulationClock();
-
+
/**
* Get the entity type registry associated with the simulation host.
*
* @return The entity type registry
*/
EntityTypeRegistry getEntityTypeRegistry();
-
+
/**
* Get the action log for this simulation.
*
* @return the action log used by this siumulation
*/
ActionLog getActionLog();
-
+
/**
* Get the simulation proxy used by the game window to communicate with the simulation.
- *
+ *
* @return The simulation proxy for the UI to use
*/
SimulationProxy getSimulationProxyForWindow();
-
+
/**
* Attach this simulation to the given window.
- *
+ *
* @param window
* The window to attach to
*/
void attachToWindow(GameWindow window);
-
+
/**
* Attach this simulation to the given window.
- *
+ *
* @param window
* The window to attach to
* @param stopWithWindowClose
* If {@code true} the simulation will stop when the attached window is closed
*/
void attachToWindow(GameWindow window, boolean stopWithWindowClose);
-
+
/**
* Irreversibly stop the simulation and all running background tasks and programs.
- *
+ *
* Calling this method twice will not throw an exception.
*/
void stop();
-
+
/**
* Run the given task in the background.
- *
+ *
* Only one task can be run for a simulation so calling this twice will throw an exception.
- *
+ *
* @param taskToRun
* The task to run
*/
void runTask(Task taskToRun);
-
+
/**
* Run the given program for the given Entity in the background.
- *
+ *
* @param
* The subtype of Entity that the Program accepts
* @param
@@ -112,7 +112,7 @@ public interface Simulation {
* The program to run
* @param entity
* The Entity to run the program for
- *
+ *
*/
void runProgram(Program program, S entity);
}
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/SimulationBuilder.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/SimulationBuilder.java
index 4dd0d5f5d..f5fbdf2f2 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/SimulationBuilder.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/SimulationBuilder.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -23,11 +23,11 @@
* @author Tim Neumann
*/
public class SimulationBuilder {
-
+
private TaskVerifier taskVerifier;
-
+
private Simulation simulation;
-
+
/**
* Set the task verifier to use with this simulation.
*
@@ -47,7 +47,7 @@ public void setTaskVerifier(final TaskVerifier taskVerifier) {
);
this.taskVerifier = taskVerifier;
}
-
+
/**
* Actually build the simulation.
*
@@ -56,32 +56,31 @@ public void setTaskVerifier(final TaskVerifier taskVerifier) {
*
*/
public void buildSimulation() {
- if (
- this.hasBuiltSimulation()
- ) throw new IllegalStateException("The simulation was already built! Use getBuiltSimulation() to acess the built window.");
+ if (this.hasBuiltSimulation())
+ throw new IllegalStateException("The simulation was already built! Use getBuiltSimulation() to acess the built window.");
final StandardPlayfield playfield = new StandardPlayfield();
final StandardSimulationClock simulationClock = new StandardSimulationClock();
-
+
final StandardEntityTypeRegistry entityTypeRegistry = new StandardEntityTypeRegistry();
-
+
final StandardActionLog actionLog = new StandardActionLog();
-
+
final InspectionManager inspectionManager = new InspectionManager();
-
+
this.simulation = new StandardSimulation(
playfield, simulationClock, entityTypeRegistry, actionLog, inspectionManager, this.taskVerifier
);
}
-
+
/**
* Get whether the window has been built.
- *
+ *
* @return true if and only if the window has been built
*/
public boolean hasBuiltSimulation() {
return this.simulation != null;
}
-
+
/**
* Get the simulation that was built.
*
@@ -91,10 +90,9 @@ public boolean hasBuiltSimulation() {
* @return The created {@link Simulation}
*/
public Simulation getBuiltSimulation() {
- if (
- !this.hasBuiltSimulation()
- ) throw new IllegalStateException("The simulation was not yet built! Use buildSimulation() to do that.");
-
+ if (!this.hasBuiltSimulation())
+ throw new IllegalStateException("The simulation was not yet built! Use buildSimulation() to do that.");
+
return this.simulation;
}
}
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/SimulationClock.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/SimulationClock.java
index 1034c8f57..1857b9e1a 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/SimulationClock.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/SimulationClock.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -21,17 +21,17 @@
* @version 1.0
*/
public interface SimulationClock {
-
+
/**
* The number of render ticks per one simulation tick.
*/
int RENDER_TICKS_PER_SIMULATION_TICK = 8;
-
+
/**
* The render period, that is set by default.
*/
int DEFAULT_RENDER_TICK_PERIOD = 50;
-
+
/**
* Set the period of the render ticks. The game ticks will have this period times
* {@value #RENDER_TICKS_PER_SIMULATION_TICK}.
@@ -40,33 +40,33 @@ public interface SimulationClock {
* The new period in milliseconds.
*/
void setPeriod(int millis);
-
+
/**
* Get the period of the render ticks.
*
* @return The number of milliseconds per render tick period.
*/
int getRenderTickPeriod();
-
+
/**
* Get the period of the game ticks.
*
* @return The number of milliseconds per game tick period.
*/
int getGameTickPeriod();
-
+
/**
* Query the clock if its running
*
* @return if the clock is running
*/
boolean isRunning();
-
+
/**
* Start ticking.
*/
void start();
-
+
/**
* Stop ticking.
*
@@ -74,12 +74,12 @@ public interface SimulationClock {
*
*/
void stop();
-
+
/**
* Execute one single tick
*/
void step();
-
+
/**
* Register a listener for simulation ticks.
*
@@ -90,7 +90,7 @@ public interface SimulationClock {
* The listener to be called.
*/
void registerTickListener(Function listener);
-
+
/**
* Register a listener for the end of simulation ticks.
*
@@ -101,17 +101,17 @@ public interface SimulationClock {
* The listener to be called.
*/
void registerPostTickListener(Function listener);
-
+
/**
* @return the number of the last simulation tick
*/
long getLastTickNumber();
-
+
/**
* @return the number of the last render tick
*/
long getLastRenderTickNumber();
-
+
/**
* Schedule an operation, to happen during the given tick. This method will block until that tick. Then the tick
* processing will halt until the given end of operation is completed.
@@ -127,7 +127,7 @@ public interface SimulationClock {
* if the end of operation completes exceptionally
*/
void scheduleOperationAtTick(long tick, CompletableFuture endOfOperation);
-
+
/**
* Schedule an operation, to happen during the tick a given number of ticks in the future. This method will block
* until that tick. Then the tick processing will halt until the given end of operation is completed.
@@ -143,7 +143,7 @@ public interface SimulationClock {
* if the end of operation completes exceptionally
*/
void scheduleOperationInTicks(long ticks, CompletableFuture endOfOperation);
-
+
/**
* Schedule an operation, to happen during the next tick. This method will block until that tick. Then the tick
* processing will halt until the given end of operation is completed.
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/TaskVerifier.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/TaskVerifier.java
index da571ad7d..7e2bfa00e 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/TaskVerifier.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/TaskVerifier.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -22,24 +22,24 @@ public interface TaskVerifier {
* Attach the verifier to a simulation.
*
* Must be called by the simulation or the simulation builder.
- *
+ *
* @param sim
* the simulation to verify
*/
void attachToSimulation(Simulation sim);
-
+
/**
* Verify if the current state of the simulation matches the requirements for the successful completion of the task.
*
* This method should update the task information returned by {@link #getTaskInformation}.
*/
void verify();
-
+
/**
* Get the current task information.
*
* The information returned by this method should not change unless {@link #verify} is called.
- *
+ *
* @return the task information
*/
TaskInformation getTaskInformation();
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/Action.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/Action.java
index 4f6cf9d34..94f49a22f 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/Action.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/Action.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -11,35 +11,35 @@
/**
* An action which happens during the execution of a simulation.
- *
+ *
* @author Tim Neumann
*/
public abstract class Action {
-
+
private final long tickNumber;
-
+
/**
* Create an action.
- *
+ *
* @param tickNumber
* the tick the action happened at
*/
public Action(final long tickNumber) {
this.tickNumber = tickNumber;
}
-
+
/**
* @return the description of this action
*/
public abstract String getDescription();
-
+
/**
* @return the number of the simulation tick the action happened
*/
public long getTickNumber() {
return this.tickNumber;
}
-
+
@Override
public String toString() {
return this.getDescription();
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/ActionLog.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/ActionLog.java
index 61f94b5d1..29700b5f7 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/ActionLog.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/ActionLog.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,24 +16,24 @@
/**
* A log for all {@link Action}s.
- *
+ *
* @author Tim Neumann
*/
public interface ActionLog {
-
+
/**
* Get all actions which were logged.
*
* Warning: No order is guaranteed.
*
- *
+ *
* @return A list of all actions logged
*/
List getAllActions();
-
+
/**
* Get all actions which were logged of the given type.
- *
+ *
* @param
* The generic type to return the actions as
* @param type
@@ -43,19 +43,19 @@ public interface ActionLog {
* @return A list of all matching actions
*/
List getActionsOfType(final Class extends T> type, final boolean includeSubclasses);
-
+
/**
* Get all actions which were logged and were caused by the given entity.
- *
+ *
* @param entity
* The entity to get actions for
* @return A list of all matching actions
*/
List getAllActionsOfEntity(Entity entity);
-
+
/**
* Get all actions which were logged of the given type and were caused by the given entity.
- *
+ *
* @param
* The generic type to return the actions as
* @param entity
@@ -69,15 +69,15 @@ public interface ActionLog {
List getActionsOfTypeOfEntity(
Entity entity, final Class extends T> type, final boolean includeSubclasses
);
-
+
/**
* Log an action.
- *
+ *
* @param actionToLog
* The action to log
*/
void logAction(Action actionToLog);
-
+
/**
* Set ActionLog console output (default: {@code true})
*
@@ -85,7 +85,7 @@ List getActionsOfTypeOfEntity(
* true: log to console, false: do not log to console
*/
void setConsoleOutput(boolean enable);
-
+
/**
* Get ActionLog console output status.
*
@@ -93,5 +93,5 @@ List getActionsOfTypeOfEntity(
* logged but not printed to console.
*/
boolean getConsoleOutput();
-
+
}
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityAction.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityAction.java
index 7298c965e..a0f45a739 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityAction.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityAction.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -14,16 +14,16 @@
/**
* An action originating from an entity.
- *
+ *
* @author Tim Neumann
*/
public abstract class EntityAction extends Action {
-
+
private final Entity entity;
-
+
/**
* Create an entity action.
- *
+ *
* @param tickNumber
* the tick the action happened at
* @param entity
@@ -33,7 +33,7 @@ public EntityAction(final long tickNumber, final Entity entity) {
super(tickNumber);
this.entity = entity;
}
-
+
/**
* @return the entity that caused this action.
*/
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityCollectAction.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityCollectAction.java
index 774464809..97db49de2 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityCollectAction.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityCollectAction.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,18 +16,18 @@
/**
* An entity action for when an entity collects another entity.
- *
+ *
* @author Tim Neumann
*/
public class EntityCollectAction extends EntityAction {
-
+
private final CollectableEntity collected;
private final Position collectorPos;
private final Position collectedPos;
-
+
/**
* Create an entity collect action.
- *
+ *
* @param tickNumber
* the tick the action happened at
* @param entity
@@ -38,7 +38,7 @@ public class EntityCollectAction extends EntityAction {
* the position the collector was at while collecting
* @param collectedPos
* the position the collected entity was at while being collected
- *
+ *
*/
public EntityCollectAction(
final long tickNumber, final Entity entity, final CollectableEntity collected, final Position collectorPos,
@@ -49,32 +49,32 @@ public EntityCollectAction(
this.collectedPos = collectedPos;
this.collectorPos = collectorPos;
}
-
+
/**
* @return the entity that was collected
*/
public CollectableEntity getCollectedEntity() {
return this.collected;
}
-
+
/**
* @return the position the collected entity was at while being collected
*/
public Position getCollectedEntityPosition() {
return this.collectedPos;
}
-
+
/**
* @return the position the collector was at while collecting
*/
public Position getCollectorPosition() {
return this.collectorPos;
}
-
+
@Override
public String getDescription() {
return this.getEntity() + " (at " + this.getCollectorPosition() + ") collected " + this.getCollectedEntity() + " at "
+ this.getCollectedEntityPosition();
}
-
+
}
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityDespawnAction.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityDespawnAction.java
index caa3a8da0..38d31591c 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityDespawnAction.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityDespawnAction.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -15,16 +15,16 @@
/**
* An entity action for when the entity is removed from a play field
- *
+ *
* @author Tim Neumann
*/
public class EntityDespawnAction extends EntityAction {
-
+
private final Playfield playfield;
-
+
/**
* Create an entity despawn action
- *
+ *
* @param tickNumber
* the tick the action happened at
* @param entity
@@ -36,14 +36,14 @@ public EntityDespawnAction(final long tickNumber, final Entity entity, final Pla
super(tickNumber, entity);
this.playfield = playfield;
}
-
+
/**
* @return the playfield the entity was removed from
*/
public Playfield getPlayfield() {
return this.playfield;
}
-
+
@Override
public String getDescription() {
return this.getEntity() + " despawned from " + this.getPlayfield();
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityDropAction.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityDropAction.java
index 44e39ee2f..50d03beba 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityDropAction.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityDropAction.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,18 +16,18 @@
/**
* An entity action for when an entity drops another entity.
- *
+ *
* @author Tim Neumann
*/
public class EntityDropAction extends EntityAction {
-
+
private final CollectableEntity dropped;
private final Position dropperPos;
private final Position dropppedPos;
-
+
/**
* Create an entity drop action.
- *
+ *
* @param tickNumber
* the tick the action happened at
* @param entity
@@ -38,7 +38,7 @@ public class EntityDropAction extends EntityAction {
* the position the dropper was at while collecting
* @param droppedPos
* the position the dropped entity was dropped to
- *
+ *
*/
public EntityDropAction(
final long tickNumber, final Entity entity, final CollectableEntity dropped, final Position dropperPos,
@@ -49,32 +49,32 @@ public EntityDropAction(
this.dropppedPos = droppedPos;
this.dropperPos = dropperPos;
}
-
+
/**
* @return the entity that was dropped
*/
public CollectableEntity getDroppedEntity() {
return this.dropped;
}
-
+
/**
* @return the position the dropped entity was dropped to
*/
public Position getDroppedEntityPosition() {
return this.dropppedPos;
}
-
+
/**
* @return the position the dropper was at while dropping
*/
public Position getDropperPosition() {
return this.dropperPos;
}
-
+
@Override
public String getDescription() {
return this.getEntity() + " (at " + this.getDropperPosition() + ") dropped " + this.getDroppedEntity() + " at "
+ this.getDroppedEntityPosition();
}
-
+
}
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityMoveAction.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityMoveAction.java
index 71368d8ed..3905273ae 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityMoveAction.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityMoveAction.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -15,19 +15,19 @@
/**
* An entity action for when a entity moved.
- *
+ *
* @author Tim Neumann
* @see EntityStepAction
* @see EntityTeleportAction
*/
public abstract class EntityMoveAction extends EntityAction {
-
+
private final Position from;
private final Position to;
-
+
/**
* Create an entity move action.
- *
+ *
* @param tickNumber
* the tick the action happened at
* @param entity
@@ -42,14 +42,14 @@ public EntityMoveAction(final long tickNumber, final Entity entity, final Positi
this.from = from;
this.to = to;
}
-
+
/**
* @return the position the entity was at before the move
*/
public Position from() {
return this.from;
}
-
+
/**
* @return the position the entity is after the move
*/
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntitySpawnAction.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntitySpawnAction.java
index 5acd8847f..73e3e0fa6 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntitySpawnAction.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntitySpawnAction.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,17 +16,17 @@
/**
* An entity action for when the entity is added to a play field
- *
+ *
* @author Tim Neumann
*/
public class EntitySpawnAction extends EntityAction {
-
+
private final Playfield playfield;
private final Position position;
-
+
/**
* Create an entity spawn action.
- *
+ *
* @param tickNumber
* the tick the action happened at
* @param entity
@@ -41,21 +41,21 @@ public EntitySpawnAction(final long tickNumber, final Entity entity, final Playf
this.playfield = playfield;
this.position = position;
}
-
+
/**
* @return the playfield the entity was added to
*/
public Playfield getPlayfield() {
return this.playfield;
}
-
+
/**
* @return the position the entity was added at
*/
public Position getPosition() {
return this.position;
}
-
+
@Override
public String getDescription() {
return this.getEntity() + " spawned in " + this.getPlayfield() + " at " + this.getPosition();
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityStepAction.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityStepAction.java
index 8db58f84d..9515ebd9b 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityStepAction.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityStepAction.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -15,14 +15,14 @@
/**
* An entity action for when the entity took a step
- *
+ *
* @author Tim Neumann
*/
public class EntityStepAction extends EntityMoveAction {
-
+
/**
* Create an entity step action.
- *
+ *
* @param tickNumber
* the tick the action happened at
* @param entity
@@ -35,7 +35,7 @@ public class EntityStepAction extends EntityMoveAction {
public EntityStepAction(final long tickNumber, final Entity entity, final Position from, final Position to) {
super(tickNumber, entity, from, to);
}
-
+
@Override
public String getDescription() {
return this.getEntity() + " stepped from " + this.from() + " to " + this.to();
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityTeleportAction.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityTeleportAction.java
index ba23e8d9a..f533be88c 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityTeleportAction.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityTeleportAction.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -15,13 +15,13 @@
/**
* An entity action for when the entity was just teleported on the playfield
- *
+ *
* @author Tim Neumann
*/
public class EntityTeleportAction extends EntityMoveAction {
/**
* Create an entity teleport action.
- *
+ *
* @param tickNumber
* the tick the action happened at
* @param entity
@@ -34,7 +34,7 @@ public class EntityTeleportAction extends EntityMoveAction {
public EntityTeleportAction(final long tickNumber, final Entity entity, final Position from, final Position to) {
super(tickNumber, entity, from, to);
}
-
+
@Override
public String getDescription() {
return this.getEntity() + " teleported from " + this.from() + " to " + this.to();
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityTurnAction.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityTurnAction.java
index 51df05271..5f219c83f 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityTurnAction.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/actions/EntityTurnAction.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -15,17 +15,17 @@
/**
* An entity action for when the entity turned
- *
+ *
* @author Tim Neumann
*/
public class EntityTurnAction extends EntityAction {
-
+
private final Direction from;
private final Direction to;
-
+
/**
* Create an entity turn action.
- *
+ *
* @param tickNumber
* the tick the action happened at
* @param entity
@@ -40,21 +40,21 @@ public EntityTurnAction(final long tickNumber, final Entity entity, final Direct
this.from = from;
this.to = to;
}
-
+
/**
* @return the direction the entity was facing before the turn
*/
public Direction from() {
return this.from;
}
-
+
/**
* @return the direction the entity is facing after the turn
*/
public Direction to() {
return this.to;
}
-
+
@Override
public String getDescription() {
return this.getEntity() + " turned from " + this.from() + " to " + this.to();
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/BasicEntity.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/BasicEntity.java
index f075bfd9c..04de18bbc 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/BasicEntity.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/BasicEntity.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -24,23 +24,23 @@
/**
* A basic implementation of {@link Entity}
- *
+ *
* @author Tim Neumann
*/
public abstract class BasicEntity implements Entity {
-
+
/** Lock object to make setting the Playfield threadsafe. */
private Object fieldLock = new Object();
/** The current (weak) reference to the playfield. */
private WeakReference field;
-
+
/**
* Lock object to ensure no two long running operations ({@code >= 1} clock tick) are scheduled at the same time.
*/
private Object operationQueueLock = new Object();
/** The completable future representing the completion of the last enqueued operation. */
protected CompletableFuture endOfLastEnqueuedOperation;
-
+
/**
* @throws EntityNotOnFieldException
* if this entity is not on a playfield
@@ -56,24 +56,24 @@ public Position getPosition() {
if (playfield == null) throw new EntityNotOnFieldException("This entity is not on a playfield");
return playfield.getEntityPosition(this);
}
-
+
/**
* Get the texture handle, with which to get the texture for this entity.
- *
+ *
* @return the texture handle for the texture of this entity
*/
protected abstract String getTextureHandle();
-
+
/**
* Get the z position of this entity.
*
* The z position is used to order entities on the same field.
*
- *
+ *
* @return the z position of this entity.
*/
protected abstract int getZPosition();
-
+
/**
* @throws EntityNotOnFieldException
* if this entity is not on a playfield
@@ -83,7 +83,7 @@ public Drawable getDrawInformation() {
final Position pos = this.getPosition();
return new BasicDrawable(pos.getX(), pos.getY(), this.getZPosition(), this.getTextureHandle());
}
-
+
@Override
public void initOnPlayfield(final Playfield playfield) {
if (playfield == null) throw new IllegalArgumentException("The given playfield is null.");
@@ -92,10 +92,10 @@ public void initOnPlayfield(final Playfield playfield) {
this.field = new WeakReference<>(playfield);
}
}
-
+
/**
* Check whether this entity is on a playfield
- *
+ *
* @return true if and only if this entity is on a playfield
*/
public boolean isOnPlayfield() {
@@ -114,10 +114,10 @@ public boolean isOnPlayfield() {
return true;
}
}
-
+
/**
* Get the playfield of this entity.
- *
+ *
* @return the playfield
* @throws EntityNotOnFieldException
* if this entity is not on a playfield
@@ -128,10 +128,10 @@ protected Playfield getPlayfield() {
return this.field.get();
}
}
-
+
/**
* Get the simulation of this entity.
- *
+ *
* @return the simulation
* @throws EntityNotOnFieldException
* if this entity is not on a playfield
@@ -143,12 +143,12 @@ protected Simulation getSimulation() {
return this.getPlayfield().getSimulation();
}
}
-
+
/**
* Prevent this entity from performing any long running operation for {@code ticks} simulation ticks.
*
* Only operations that take {@code >= 1} clock ticks to execute will be affected by this sleep.
- *
+ *
* @param ticks
* numberof simulation ticks to pause; must be {@code > 0}
* @throws IllegalArgumentException
@@ -164,7 +164,7 @@ public void sleep(final int ticks) {
endOfOperation.complete(null);
}
}
-
+
/**
* Wait for the last enqueued long running operation to finish before allowing the new Operation to perform.
*
@@ -181,7 +181,7 @@ public void sleep(final int ticks) {
*
* The field {@link #endOfLastEnqueuedOperation} keeps track of the operation that is currently performed by this
* entity.
- *
+ *
* @param endOfNewOperation
* The completable future representing the operation to be performed (must be completed when the operation is
* completed)
@@ -204,10 +204,10 @@ protected void enqueueToPerformNewOperation(CompletableFuture endOfNewOper
endOfLastEnqueuedOperation.join();
}
}
-
+
@Override
public String toString() {
return this.getClass().getSimpleName() + "@" + Integer.toHexString(this.hashCode());
}
-
+
}
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/CollectableEntity.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/CollectableEntity.java
index 389145ff8..892ea8f24 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/CollectableEntity.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/CollectableEntity.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -11,7 +11,7 @@
/**
* An entity, which can be collected by {@link EntityCollector}.
- *
+ *
* @author Tim Neumann
*/
public interface CollectableEntity extends Entity {
@@ -20,7 +20,7 @@ public interface CollectableEntity extends Entity {
*
* This can be used to make entities, that are not collectable all the time.
*
- *
+ *
* @return true if and only if this entity is currently collectable
*/
default boolean isCurrentlyCollectable() {
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/Entity.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/Entity.java
index 1ce9d8a4b..74b3ea471 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/Entity.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/Entity.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -17,7 +17,7 @@
/**
* The interface for an entity in the simulation of the ICGE.
- *
+ *
* @author Tim Neumann
*/
public interface Entity {
@@ -25,12 +25,12 @@ public interface Entity {
* @return the position of this entity
*/
Position getPosition();
-
+
/**
* @return the information required to draw this entity; must not be null
*/
Drawable getDrawInformation();
-
+
/**
* Method to initialize this entity after being added to the playfield.
*
@@ -39,15 +39,15 @@ public interface Entity {
*
* This method needs to be called by the playfield directly before adding the entity to the field.
*
- *
+ *
* @param playfield
* The playfield this entity was added to; must not be null
- *
+ *
* @throws IllegalArgumentException
* if the given playfield is null
* @throws EntityOnAnotherFieldException
* if the entity is already on a field
*/
void initOnPlayfield(Playfield playfield);
-
+
}
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/EntityCollector.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/EntityCollector.java
index ba46a13b5..b9752ac75 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/EntityCollector.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/EntityCollector.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,23 +16,23 @@
/**
* An entity which can collect {@link CollectableEntity}.
- *
+ *
* @author Tim Neumann
*/
public interface EntityCollector {
-
+
/**
* Check if this can collect and drop the given collectable entity type.
- *
+ *
* @param type
* The type to check; must not be null
* @return true if this entity collector can collect or drop the given entity type
*/
boolean canCarry(Class extends CollectableEntity> type);
-
+
/**
* Collect the given entity.
- *
+ *
* @param entity
* The entity to collect; must not be null; must be collectable by this
* @throws CannotCollectEntityException
@@ -41,10 +41,10 @@ public interface EntityCollector {
* if an argument is null
*/
void collect(CollectableEntity entity);
-
+
/**
* Drop the given entity.
- *
+ *
* @param entity
* The entity to drop;must not be null; must be droppable by this
* @param pos
@@ -55,5 +55,5 @@ public interface EntityCollector {
* if an argument is null
*/
void drop(CollectableEntity entity, Position pos);
-
+
}
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/EntityTypeRegistry.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/EntityTypeRegistry.java
index f3183135e..dd9739d38 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/EntityTypeRegistry.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/EntityTypeRegistry.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -21,7 +21,7 @@
* @author Fabian Bühler
*/
public interface EntityTypeRegistry {
-
+
/**
* Register a new entity type by name.
*
@@ -42,7 +42,7 @@ public interface EntityTypeRegistry {
* if the name is already used
*/
void registerEntityType(final String typeName, final String textureHandle, Class extends Entity> entityType);
-
+
/**
* Register a new entity type by name.
*
@@ -62,14 +62,14 @@ public interface EntityTypeRegistry {
* if the name is already used
*/
void registerEntityType(final String typeName, final String textureHandle, Supplier extends Entity> entityFactory);
-
+
/**
* Get a set of all currently registered entity types.
*
* @return registered entity types
*/
Set getRegisteredEntityTypes();
-
+
/**
* Get the texture handle of a registered entity type.
*
@@ -80,7 +80,7 @@ public interface EntityTypeRegistry {
* if an argument is null
*/
String getTextureHandleOfEntityType(final String typeName);
-
+
/**
* Get a new Entity instance of a registered entity type.
*
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/GreedyEntity.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/GreedyEntity.java
index 9d6a838dd..35c10a440 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/GreedyEntity.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/GreedyEntity.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -22,31 +22,31 @@
/**
* A movable entity collector.
- *
+ *
* @author Tim Neumann
*/
public abstract class GreedyEntity extends MovableEntity implements EntityCollector {
-
+
/** A lock to synchronize all operations involving the entities inventory. */
protected final Object inventoryOperationLock = new Object();
-
+
private final Inventory inventory = new Inventory();
-
+
/**
* @return the inventory of this greedy entity
*/
public Inventory getInventory() {
return this.inventory;
}
-
+
@Override
public boolean canCarry(final Class extends CollectableEntity> type) {
return true;
}
-
+
/**
* Get all the currently collectable entities of the given type
- *
+ *
* @param
* The generic type to return the entities as
* @param type
@@ -58,13 +58,13 @@ public boolean canCarry(final Class extends CollectableEntity> type) {
public List getCurrentlyCollectableEntities(final Class type, final boolean includeSubclasses) {
return this.getPlayfield().getEntitiesOfTypeAt(this.getPosition(), type, includeSubclasses);
}
-
+
@Override
public void collect(final CollectableEntity entity) {
if (entity == null) throw new IllegalArgumentException("An argument is null.");
Position myPos;
Position otherPos;
-
+
synchronized (this.inventoryOperationLock) {
try {
myPos = this.getPosition();
@@ -72,22 +72,22 @@ public void collect(final CollectableEntity entity) {
} catch (final EntityNotOnFieldException e) {
throw new CannotCollectEntityException(e);
}
-
+
if (!myPos.equals(otherPos)) throw new CannotCollectEntityException("Not on my field");
-
+
this.getSimulation().getPlayfield().removeEntity(entity);
this.getInventory().add(entity);
-
+
final Action action = new EntityCollectAction(
this.getSimulation().getSimulationClock().getLastTickNumber(), this, entity, myPos, otherPos
);
this.getSimulation().getActionLog().logAction(action);
}
}
-
+
/**
* Get all the currently droppable entities of the given type
- *
+ *
* @param
* The generic type to return the entities as
* @param type
@@ -99,7 +99,7 @@ public void collect(final CollectableEntity entity) {
public List getCurrentlyDroppableEntities(final Class type, final boolean includeSubclasses) {
return this.getInventory().get(type, includeSubclasses);
}
-
+
@Override
public void drop(final CollectableEntity entity, final Position pos) {
if ((entity == null) || (pos == null)) throw new IllegalArgumentException("An argument is null.");
@@ -110,22 +110,22 @@ public void drop(final CollectableEntity entity, final Position pos) {
} catch (final EntityNotOnFieldException e) {
throw new CannotCollectEntityException(e);
}
-
+
if (!myPos.equals(pos)) throw new CannotCollectEntityException("Not on my field");
-
+
this.getInventory().remove(entity);
this.getPlayfield().addEntity(pos, entity);
-
+
final Action action = new EntityDropAction(
this.getSimulation().getSimulationClock().getLastTickNumber(), this, entity, myPos, pos
);
this.getSimulation().getActionLog().logAction(action);
}
}
-
+
/**
* Drop the given entity at the current position.
- *
+ *
* @param entity
* The entity to drop;must not be null; must be droppable by this *
* @throws CannotDropEntityException
@@ -136,5 +136,5 @@ public void drop(final CollectableEntity entity, final Position pos) {
public void drop(final CollectableEntity entity) {
this.drop(entity, this.getPosition());
}
-
+
}
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/Inventory.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/Inventory.java
index f0d4e422e..9698fd6fd 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/Inventory.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/Inventory.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -14,7 +14,7 @@
/**
* An inventory of a entity.
- *
+ *
* @author Tim Neumann
*/
public class Inventory extends MultiTypedList {
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/MovableEntity.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/MovableEntity.java
index 1d686d3f5..d54e68555 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/MovableEntity.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/MovableEntity.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -27,17 +27,17 @@
/**
* A movable entity
- *
+ *
* @author Tim Neumann
*/
public abstract class MovableEntity extends BasicEntity {
-
+
private Direction lookingDirection = Direction.EAST;
-
+
private AnimatedDrawable movingDrawable = null;
-
+
private Direction directionOfAlmostArrivedMove;
-
+
@Override
public Drawable getDrawInformation() {
final AnimatedDrawable movingDrawable = this.movingDrawable;
@@ -45,7 +45,7 @@ public Drawable getDrawInformation() {
final Position pos = this.getPosition();
return new UntilableDrawable(pos.getX(), pos.getY(), this.getZPosition(), this.getTextureHandle());
}
-
+
/**
* Turn this entity for 90 degrees in clock wise direction.
*/
@@ -59,53 +59,53 @@ public void turnClockWise() {
endOfOperation.complete(null);
}
}
-
+
private void turnClockWiseInternal() {
final Direction oldLookingDirection = this.lookingDirection;
this.lookingDirection = this.lookingDirection.clockWiseNext();
final long tick = this.getSimulation().getSimulationClock().getLastTickNumber();
this.getSimulation().getActionLog().logAction(new EntityTurnAction(tick, this, oldLookingDirection, this.lookingDirection));
}
-
+
@InspectionMethod(name = "turnClockwise")
private void turnClockWiseInspector() {
this.turnClockWiseInternal();
this.recalculateAnimationAfterInspector();
}
-
+
private void recalculateAnimationAfterInspector() {
if (this.movingDrawable != null) {
-
+
final long tickStart = this.movingDrawable.getTickStart();
final long duration = this.movingDrawable.getDuration();
-
+
Direction movingDir;
if (this.directionOfAlmostArrivedMove == null) {
movingDir = this.lookingDirection;
} else {
movingDir = this.directionOfAlmostArrivedMove;
}
-
+
final Position currentPos = this.getPosition();
final Position nextPos = currentPos.adjacentPosition(movingDir);
-
+
this.movingDrawable = new AnimatedDrawable(
tickStart, currentPos.getX(), currentPos.getY(), duration, nextPos.getX(), nextPos.getY(), this.getZPosition(),
this.getTextureHandle()
);
}
}
-
+
/**
* @return the current looking direction of this entity
*/
public Direction getLookingDirection() {
return this.lookingDirection;
}
-
+
/**
* Set the looking direction
- *
+ *
* @param direction
* the name of the new direction
*/
@@ -114,7 +114,7 @@ private void setLookingDirectionByString(final String direction) {
this.lookingDirection = Direction.valueOf(direction.toUpperCase());
this.recalculateAnimationAfterInspector();
}
-
+
/**
* @return the looking direction as a string
*/
@@ -122,14 +122,14 @@ private void setLookingDirectionByString(final String direction) {
public String getLookingDirectionString() {
return this.getLookingDirection().toString();
}
-
+
private boolean isSolidEntityAt(final Position pos) {
return this.getPlayfield().isSolidEntityAt(pos);
}
-
+
/**
* Move this entity forward one field.
- *
+ *
* @throws EntityNotOnFieldException
* if this entity is not on a playfield
* @throws IllegalMoveException
@@ -139,7 +139,7 @@ public void move() {
// use extra future for whole operation as it is split amongst two futures
final CompletableFuture endOfOperation = new CompletableFuture<>();
this.enqueueToPerformNewOperation(endOfOperation);
-
+
// setup move
final int duration = 4;
final int renderTickDuration = duration * SimulationClock.RENDER_TICKS_PER_SIMULATION_TICK;
@@ -152,7 +152,7 @@ public void move() {
currentTick, currentPos.getX(), currentPos.getY(), renderTickDuration, nextPos.getX(), nextPos.getY(), this.getZPosition(),
this.getTextureHandle()
);
-
+
final CompletableFuture endOfOperation1 = new CompletableFuture<>();
try {
clock.scheduleOperationInTicks(duration / 2, endOfOperation1);
@@ -162,7 +162,7 @@ public void move() {
} finally {
endOfOperation1.complete(null);
}
-
+
final CompletableFuture endOfOperation2 = new CompletableFuture<>();
try {
clock.scheduleOperationInTicks(duration / 2, endOfOperation2);
@@ -175,16 +175,16 @@ public void move() {
this.movingDrawable = null;
}
}
-
+
@InspectionMethod(name = "move")
private void moveInspector() {
final Position currentPos = this.getPosition();
final Position nextPos = currentPos.adjacentPosition(this.lookingDirection);
-
+
this.internalMove(currentPos, nextPos);
this.recalculateAnimationAfterInspector();
}
-
+
private void internalMove(final Position currentPos, final Position nextPos) {
if (this.isSolidEntityAt(nextPos)) throw new IllegalMoveException("Solid Entity in the way");
final EntityMoveAction action = new EntityStepAction(
@@ -192,7 +192,7 @@ private void internalMove(final Position currentPos, final Position nextPos) {
);
this.getPlayfield().moveEntity(this, nextPos, action);
}
-
+
/**
* @return whether this entity can move forward one field.
*/
@@ -200,7 +200,7 @@ public boolean canMove() {
final Position nextPos = this.getPosition().adjacentPosition(this.lookingDirection);
return this.isOnPlayfield() && !this.isSolidEntityAt(nextPos);
}
-
+
/**
* Move this entity forward one field if that is possible.
*/
@@ -208,7 +208,7 @@ public void moveIfPossible() {
try {
if (this.canMove()) this.move();
} catch (@SuppressWarnings("unused") EntityNotOnFieldException | IllegalMoveException e) {
- // do nothing just catch exeptions if move was made illegal by an operation
+ // do nothing just catch exeptions if move was made illegal by an operation
// in another thread
}
}
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/SolidEntity.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/SolidEntity.java
index 045fdf063..227b4bdcb 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/SolidEntity.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/SolidEntity.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -11,17 +11,17 @@
/**
* A solid entity, through which a movable entity cannot move.
- *
+ *
* @author Tim Neumann
*/
public interface SolidEntity extends Entity {
-
+
/**
* Get whether this entity is really solid at the moment.
*
* This can be used to make entities, that are not solid all the time.
*
- *
+ *
* @return true if and only if this entity is currently solid
*/
default boolean isCurrentlySolid() {
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/UntilableDrawable.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/UntilableDrawable.java
index 5720e34fb..11dccaa7c 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/UntilableDrawable.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/entity/UntilableDrawable.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,10 +16,10 @@
* Same as {@link BasicDrawable} but won't tile.
*/
public class UntilableDrawable extends BasicDrawable {
-
+
/**
* Create a new untilable Drawable.
- *
+ *
* @param x
* @param y
* @param z
@@ -28,7 +28,7 @@ public class UntilableDrawable extends BasicDrawable {
public UntilableDrawable(final double x, final double y, final int z, final String textureHandle) {
super(x, y, z, textureHandle);
}
-
+
@Override
public boolean isTilable() {
return false;
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/CannotCollectEntityException.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/CannotCollectEntityException.java
index 05357c463..140d7b2f1 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/CannotCollectEntityException.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/CannotCollectEntityException.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -11,16 +11,16 @@
/**
* This exception indicates that an entity program cannot be run.
- *
+ *
* @author Tim Neumann
*/
public class CannotCollectEntityException extends SimulationExcpetion {
-
+
/**
* generated
*/
private static final long serialVersionUID = 6758366706458330276L;
-
+
/**
* Constructs a new CannotCollectEntityException with {@code null} as its detail message. The cause is not
* initialized, and may subsequently be initialized by a call to {@link #initCause}.
@@ -28,7 +28,7 @@ public class CannotCollectEntityException extends SimulationExcpetion {
public CannotCollectEntityException() {
super();
}
-
+
/**
* Constructs a new CannotCollectEntityException with the specified detail message. The cause is not initialized,
* and may subsequently be initialized by a call to {@link #initCause}.
@@ -39,7 +39,7 @@ public CannotCollectEntityException() {
public CannotCollectEntityException(final String message) {
super(message);
}
-
+
/**
* Constructs a new CannotCollectEntityException with the specified cause and a detail message of
* {@code (cause==null ? null : cause.toString())} (which typically contains the class and detail message of
@@ -54,7 +54,7 @@ public CannotCollectEntityException(final String message) {
public CannotCollectEntityException(final Throwable cause) {
super(cause);
}
-
+
/**
* Constructs a new CannotCollectEntityException with the specified detail message and cause.
*
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/CannotDropEntityException.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/CannotDropEntityException.java
index b111e60ff..cb8687bcc 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/CannotDropEntityException.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/CannotDropEntityException.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -11,16 +11,16 @@
/**
* This exception indicates that an entity program cannot be run.
- *
+ *
* @author Tim Neumann
*/
public class CannotDropEntityException extends SimulationExcpetion {
-
+
/**
* generated
*/
private static final long serialVersionUID = 8237903756645049779L;
-
+
/**
* Constructs a new CannotDropEntityException with {@code null} as its detail message. The cause is not initialized,
* and may subsequently be initialized by a call to {@link #initCause}.
@@ -28,7 +28,7 @@ public class CannotDropEntityException extends SimulationExcpetion {
public CannotDropEntityException() {
super();
}
-
+
/**
* Constructs a new CannotDropEntityException with the specified detail message. The cause is not initialized, and
* may subsequently be initialized by a call to {@link #initCause}.
@@ -39,7 +39,7 @@ public CannotDropEntityException() {
public CannotDropEntityException(final String message) {
super(message);
}
-
+
/**
* Constructs a new CannotDropEntityException with the specified cause and a detail message of
* {@code (cause==null ? null : cause.toString())} (which typically contains the class and detail message of
@@ -54,7 +54,7 @@ public CannotDropEntityException(final String message) {
public CannotDropEntityException(final Throwable cause) {
super(cause);
}
-
+
/**
* Constructs a new CannotDropEntityException with the specified detail message and cause.
*
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/CannotRunProgramException.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/CannotRunProgramException.java
index d4202f2c3..82bdd010f 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/CannotRunProgramException.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/CannotRunProgramException.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -11,23 +11,23 @@
/**
* This exception indicates that an entity program cannot be run.
- *
+ *
* @author Tim Neumann
*/
public class CannotRunProgramException extends IllegalArgumentException {
-
+
/**
* generated
*/
private static final long serialVersionUID = -5283363131395011240L;
-
+
/**
* Constructs an CannotRunProgramException
with no detail message.
*/
public CannotRunProgramException() {
super();
}
-
+
/**
* Constructs an CannotRunProgramException
with the specified detail message.
*
@@ -37,7 +37,7 @@ public CannotRunProgramException() {
public CannotRunProgramException(final String s) {
super(s);
}
-
+
/**
* Constructs a new exception with the specified detail message and cause.
*
@@ -55,7 +55,7 @@ public CannotRunProgramException(final String s) {
public CannotRunProgramException(final String message, final Throwable cause) {
super(message, cause);
}
-
+
/**
* Constructs a new exception with the specified cause and a detail message of
* {@code (cause==null ? null : cause.toString())} (which typically contains the class and detail message of
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/ElementExistsException.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/ElementExistsException.java
index 5fb8b4554..848418cd3 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/ElementExistsException.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/ElementExistsException.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -11,23 +11,23 @@
/**
* This exception indicates that the element already exists.
- *
+ *
* @author Tim Neumann
*/
public class ElementExistsException extends IllegalArgumentException {
-
+
/**
* generated
*/
private static final long serialVersionUID = -564159508677510779L;
-
+
/**
* Constructs an ElementExistsException
with no detail message.
*/
public ElementExistsException() {
super();
}
-
+
/**
* Constructs an ElementExistsException
with the specified detail message.
*
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/EntityAlreadyOnFieldExcpetion.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/EntityAlreadyOnFieldExcpetion.java
index 475d686fa..1cfcc701c 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/EntityAlreadyOnFieldExcpetion.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/EntityAlreadyOnFieldExcpetion.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -12,7 +12,7 @@
/**
* This exception indicates that an action is illegal, because the subject entity is already in on the relevant
* playfield.
- *
+ *
* @author Tim Neumann
*/
public class EntityAlreadyOnFieldExcpetion extends SimulationExcpetion {
@@ -20,7 +20,7 @@ public class EntityAlreadyOnFieldExcpetion extends SimulationExcpetion {
* generated
*/
private static final long serialVersionUID = 3177203739377160043L;
-
+
/**
* Constructs a new EntityAlreadyOnFieldExcpetion with {@code null} as its detail message. The cause is not
* initialized, and may subsequently be initialized by a call to {@link #initCause}.
@@ -28,7 +28,7 @@ public class EntityAlreadyOnFieldExcpetion extends SimulationExcpetion {
public EntityAlreadyOnFieldExcpetion() {
super();
}
-
+
/**
* Constructs a new EntityAlreadyOnFieldExcpetion with the specified detail message. The cause is not initialized,
* and may subsequently be initialized by a call to {@link #initCause}.
@@ -39,7 +39,7 @@ public EntityAlreadyOnFieldExcpetion() {
public EntityAlreadyOnFieldExcpetion(final String message) {
super(message);
}
-
+
/**
* Constructs a new EntityAlreadyOnFieldExcpetion with the specified detail message and cause.
*
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/EntityNotOnFieldException.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/EntityNotOnFieldException.java
index 9770a36b2..c36fd3cb6 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/EntityNotOnFieldException.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/EntityNotOnFieldException.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -11,7 +11,7 @@
/**
* This exception indicates that an action was illegal, because the subject entity is not the the relevant playfield.
- *
+ *
* @author Tim Neumann
*/
public class EntityNotOnFieldException extends SimulationExcpetion {
@@ -19,7 +19,7 @@ public class EntityNotOnFieldException extends SimulationExcpetion {
* generated
*/
private static final long serialVersionUID = -8786124964224174226L;
-
+
/**
* Constructs a new EntityAlreadyOnFieldExcpetion with {@code null} as its detail message. The cause is not
* initialized, and may subsequently be initialized by a call to {@link #initCause}.
@@ -27,7 +27,7 @@ public class EntityNotOnFieldException extends SimulationExcpetion {
public EntityNotOnFieldException() {
super();
}
-
+
/**
* Constructs a new EntityAlreadyOnFieldExcpetion with the specified detail message. The cause is not initialized,
* and may subsequently be initialized by a call to {@link #initCause}.
@@ -38,7 +38,7 @@ public EntityNotOnFieldException() {
public EntityNotOnFieldException(final String message) {
super(message);
}
-
+
/**
* Constructs a new EntityAlreadyOnFieldExcpetion with the specified detail message and cause.
*
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/EntityOnAnotherFieldException.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/EntityOnAnotherFieldException.java
index ef97bdd22..6378e6448 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/EntityOnAnotherFieldException.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/EntityOnAnotherFieldException.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -11,16 +11,16 @@
/**
* This exception indicates that an action is illegal, because the subject entity is already on another playfield.
- *
+ *
* @author Tim Neumann
*/
public class EntityOnAnotherFieldException extends SimulationExcpetion {
-
+
/**
* generated
*/
private static final long serialVersionUID = -2894368466373991151L;
-
+
/**
* Constructs a new EntityOnAnotherFieldException with {@code null} as its detail message. The cause is not
* initialized, and may subsequently be initialized by a call to {@link #initCause}.
@@ -28,7 +28,7 @@ public class EntityOnAnotherFieldException extends SimulationExcpetion {
public EntityOnAnotherFieldException() {
super();
}
-
+
/**
* Constructs a new EntityOnAnotherFieldException with the specified detail message. The cause is not initialized,
* and may subsequently be initialized by a call to {@link #initCause}.
@@ -39,7 +39,7 @@ public EntityOnAnotherFieldException() {
public EntityOnAnotherFieldException(final String message) {
super(message);
}
-
+
/**
* Constructs a new EntityOnAnotherFieldException with the specified detail message and cause.
*
@@ -48,7 +48,7 @@ public EntityOnAnotherFieldException(final String message) {
* @param cause
* the cause (which is saved for later retrieval by the {@link #getCause()} method). (A {@code null} value is
* permitted, and indicates that the cause is nonexistent or unknown.)
- *
+ *
* @since 1.4
*/
public EntityOnAnotherFieldException(final String message, final Throwable cause) {
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/IllegalMoveException.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/IllegalMoveException.java
index 9efb451c8..7856ef11d 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/IllegalMoveException.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/IllegalMoveException.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -14,7 +14,7 @@
*
* Possible reasons are: solid entity in the way
*
- *
+ *
* @author Tim Neumann
*/
public class IllegalMoveException extends SimulationExcpetion {
@@ -22,7 +22,7 @@ public class IllegalMoveException extends SimulationExcpetion {
* generated
*/
private static final long serialVersionUID = -4781899414191823139L;
-
+
/**
* Constructs a new IllegalMoveException with {@code null} as its detail message. The cause is not initialized, and
* may subsequently be initialized by a call to {@link #initCause}.
@@ -30,7 +30,7 @@ public class IllegalMoveException extends SimulationExcpetion {
public IllegalMoveException() {
super();
}
-
+
/**
* Constructs a new IllegalMoveException with the specified detail message. The cause is not initialized, and may
* subsequently be initialized by a call to {@link #initCause}.
@@ -41,10 +41,10 @@ public IllegalMoveException() {
public IllegalMoveException(final String message) {
super(message);
}
-
+
/**
* Constructs a new IllegalMoveException with the specified detail message and cause. *
- *
+ *
* @param message
* the detail message (which is saved for later retrieval by the {@link #getMessage()} method).
* @param cause
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/SimulationExcpetion.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/SimulationExcpetion.java
index 0cad214ff..085bb0fa4 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/SimulationExcpetion.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/SimulationExcpetion.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -11,16 +11,16 @@
/**
* The parent of all exceptions thrown by the simulation.
- *
+ *
* @author Tim Neumann
*/
public class SimulationExcpetion extends RuntimeException {
-
+
/**
* generated
*/
private static final long serialVersionUID = 8969492057602725022L;
-
+
/**
* Constructs a new SimulationExcpetion with {@code null} as its detail message. The cause is not initialized, and
* may subsequently be initialized by a call to {@link #initCause}.
@@ -28,7 +28,7 @@ public class SimulationExcpetion extends RuntimeException {
public SimulationExcpetion() {
super();
}
-
+
/**
* Constructs a new SimulationExcpetion with the specified detail message. The cause is not initialized, and may
* subsequently be initialized by a call to {@link #initCause}.
@@ -39,7 +39,7 @@ public SimulationExcpetion() {
public SimulationExcpetion(final String message) {
super(message);
}
-
+
/**
* Constructs a new SimulationExcpetion with the specified cause and a detail message of
* {@code (cause==null ? null : cause.toString())} (which typically contains the class and detail message of
@@ -54,10 +54,10 @@ public SimulationExcpetion(final String message) {
public SimulationExcpetion(final Throwable cause) {
super(cause);
}
-
+
/**
* Constructs a new SimulationExcpetion with the specified detail message and cause. *
- *
+ *
* @param message
* the detail message (which is saved for later retrieval by the {@link #getMessage()} method).
* @param cause
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/TimerAlreadyRunning.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/TimerAlreadyRunning.java
index 6790b3647..c94f941e3 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/TimerAlreadyRunning.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/TimerAlreadyRunning.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -20,7 +20,7 @@
*/
public class TimerAlreadyRunning extends IllegalStateException {
private static final long serialVersionUID = 1715637086603245424L;
-
+
/**
* Default constructor
*/
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/UncheckedInterruptedException.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/UncheckedInterruptedException.java
index 15b79cd74..18ae81a10 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/UncheckedInterruptedException.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/exception/UncheckedInterruptedException.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -11,23 +11,23 @@
/**
* This exception indicates that an entity program cannot be run.
- *
+ *
* @author Tim Neumann
*/
public class UncheckedInterruptedException extends IllegalArgumentException {
-
+
/**
* generated
*/
private static final long serialVersionUID = -8407441370711369840L;
-
+
/**
* Constructs an EntityProgramInterruptedException
with no detail message.
*/
public UncheckedInterruptedException() {
super();
}
-
+
/**
* Constructs an EntityProgramInterruptedException
with the specified detail message.
*
@@ -37,7 +37,7 @@ public UncheckedInterruptedException() {
public UncheckedInterruptedException(final String s) {
super(s);
}
-
+
/**
* Constructs a new exception with the specified detail message and cause.
*
@@ -55,7 +55,7 @@ public UncheckedInterruptedException(final String s) {
public UncheckedInterruptedException(final String message, final Throwable cause) {
super(message, cause);
}
-
+
/**
* Constructs a new exception with the specified cause and a detail message of
* {@code (cause==null ? null : cause.toString())} (which typically contains the class and detail message of
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/AnnotationReader.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/AnnotationReader.java
index 1c78c5930..4e4e5d84e 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/AnnotationReader.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/AnnotationReader.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -18,17 +18,17 @@
/**
* Class responsible for reading annotations.
- *
+ *
* @author Tim Neumann
*/
public class AnnotationReader {
private AnnotationReader() {
//hide constructor
}
-
+
/**
* Get all methods with the given annotation in the given class and all parent classes.
- *
+ *
* @param cls
* The class to get the methods from
* @param annotation
@@ -38,23 +38,23 @@ private AnnotationReader() {
public static List getAllMethodsWithAnnotationRecursively(final Class> cls, final Class extends Annotation> annotation) {
final Method[] methods = cls.getDeclaredMethods();
final List ret = new ArrayList<>();
-
+
for (final Method m : methods) {
if (m.isAnnotationPresent(annotation)) {
ret.add(m);
}
}
-
+
final Class> superCls = cls.getSuperclass();
if (superCls != null) {
ret.addAll(AnnotationReader.getAllMethodsWithAnnotationRecursively(superCls, annotation));
}
return ret;
}
-
+
/**
* Get all attributes with the given annotation in the given class and all parent classes.
- *
+ *
* @param cls
* The class to get the attributes from
* @param annotation
@@ -64,13 +64,13 @@ public static List getAllMethodsWithAnnotationRecursively(final Class>
public static List getAllAttributesWithAnnotationRecursively(final Class> cls, final Class extends Annotation> annotation) {
final Field[] fields = cls.getDeclaredFields();
final List ret = new ArrayList<>();
-
+
for (final Field f : fields) {
if (f.isAnnotationPresent(annotation)) {
ret.add(f);
}
}
-
+
final Class> superCls = cls.getSuperclass();
if (superCls != null) {
ret.addAll(AnnotationReader.getAllAttributesWithAnnotationRecursively(superCls, annotation));
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/ClassFinder.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/ClassFinder.java
index e6c406552..e1df282e5 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/ClassFinder.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/ClassFinder.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -23,17 +23,17 @@
/**
* A class for finding classes in the class loader
- *
+ *
* @author Tim Neumann
*/
public class ClassFinder {
private ClassFinder() {
//hide constructor
}
-
+
/**
* Get all classes in the current context class loader, which match the filter.
- *
+ *
* @param filter
* The filter to check each class against.
* @return A list of classes
@@ -43,9 +43,9 @@ private ClassFinder() {
public static List> getClassesInClassLoader(final Predicate> filter) throws IOException {
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
final List urls = Collections.list(loader.getResources("de"));
-
+
final List> classes = new ArrayList<>();
-
+
for (final URL url : urls) {
if (url.getProtocol().equals("jar")) {
ClassFinder.loadClassesFromJar(url, filter, classes);
@@ -53,10 +53,10 @@ public static List> getClassesInClassLoader(final Predicate> f
ClassFinder.loadClassesFromFS(url, filter, classes, loader);
}
}
-
+
return classes;
}
-
+
private static void loadClassesFromJar(final URL url, final Predicate> filter, final List> classes)
throws IOException {
final String urlS = url.getPath();
@@ -83,7 +83,7 @@ private static void loadClassesFromJar(final URL url, final Predicate>
throw new IOException(e2);
}
}
-
+
private static void loadClassesFromFS(
final URL url, final Predicate> filter, final List> classes, final ClassLoader loader
) throws IOException {
@@ -94,7 +94,7 @@ private static void loadClassesFromFS(
throw new IOException(e);
}
}
-
+
private static void loadClassInFile(
final File file, final List> classes, final ClassLoader loader, final String rootDir, final Predicate> filter
) throws ClassNotFoundException {
@@ -116,7 +116,7 @@ private static void loadClassInFile(
}
}
}
-
+
private static String convertPathToClassName(final String path, final String rootDir) {
if (!path.startsWith(rootDir)) throw new IllegalStateException("File not starting with root dir!");
final String[] fileSeps = new String[] { System.getProperty("file.separator"), "/" };
@@ -128,6 +128,6 @@ private static String convertPathToClassName(final String path, final String roo
relPath = relPath.replace(fileSep, ".");
}
return relPath;
-
+
}
}
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionAttribute.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionAttribute.java
index 945327fb8..6a0703432 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionAttribute.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionAttribute.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -22,7 +22,7 @@
* A annotation specifying that the annotated element should be displayed as a attribute in the inspector.
*
* This can be used for attributes or for getters and setters.
- *
+ *
* @author Tim Neumann
*/
@Documented
@@ -31,7 +31,7 @@
public @interface InspectionAttribute {
/** @return The optional name of the attribute, to be displayed in the front end. */
String name() default "";
-
+
/** @return Optional argument setting this attribute to read only. */
boolean readOnly() default false;
}
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionData.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionData.java
index c20f43d84..f98a59fa9 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionData.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionData.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -22,18 +22,18 @@
/**
* Represents all data available for the inspection for a class
- *
+ *
* @author Tim Neumann
*/
public class InspectionData {
private final Class> c;
-
+
private final Map inspectableAttributes;
private final Map inspectableMethods;
-
+
/**
* Creates a new inspection data object for the given class
- *
+ *
* @param cls
* The class to create a inspection data object for.
*/
@@ -44,10 +44,10 @@ public InspectionData(final Class> cls) {
this.initAttributes();
this.initMethods();
}
-
+
/**
* Get the value of the attribute with the given name from the given object.
- *
+ *
* @param obj
* The object to get the value from
* @param name
@@ -63,15 +63,15 @@ public Object getAttributeValue(final Object obj, final String name) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
- // InvocationTargetException is suppressed to prevent crashes from methods that throw an exception when the value is null, e.g. getPosition();
+ // InvocationTargetException is suppressed to prevent crashes from methods that throw an exception when the value is null, e.g. getPosition();
}
}
return null;
}
-
+
/**
* Set's the value of the attribute with the given name for the given object
- *
+ *
* @param obj
* The object to set the value in.
* @param name
@@ -92,19 +92,19 @@ public boolean setAttributeValue(final Object obj, final String name, final Obje
}
return false;
}
-
+
/**
* Get the attribute names of the class for this inspection data.
- *
+ *
* @return A list of attribute names.
*/
public List getAttributeNames() {
return Collections.unmodifiableList(new ArrayList<>(this.inspectableAttributes.keySet()));
}
-
+
/**
* Get the type of the attribute with the given name.
- *
+ *
* @param attributeName
* The name of the attribute
* @return The type of the attribute.
@@ -114,10 +114,10 @@ public Class> getAttributeType(final String attributeName) {
if (p == null) return null;
return p.getType();
}
-
+
/**
* Check whether the attribute with the given name is read only.
- *
+ *
* @param attributeName
* The name of the attribute.
* @return Whether the attribute is read only.
@@ -127,26 +127,26 @@ public boolean isAttributeReadOnly(final String attributeName) {
if (p == null) return true;
return p.isReadOnly();
}
-
+
/**
* @return Whether this inspection data has any inspectable elements.
*/
public boolean hasAnyInspectableElements() {
return !(this.inspectableAttributes.isEmpty() && this.inspectableMethods.isEmpty());
}
-
+
/**
* Get the mathod names of the class for this inspection data.
- *
+ *
* @return A list of method names.
*/
public List getMethodNames() {
return Collections.unmodifiableList(new ArrayList<>(this.inspectableMethods.keySet()));
}
-
+
/**
* Get the method detail for the method with the given name
- *
+ *
* @param methodName
* The name of the method to get the detail for
* @return The method detail.
@@ -154,10 +154,10 @@ public List getMethodNames() {
public Method getMethodByName(final String methodName) {
return this.inspectableMethods.get(methodName);
}
-
+
/**
* Invoke the method with the given name in the given object, using the given arguments
- *
+ *
* @param obj
* The object to call the method on
* @param methodName
@@ -176,38 +176,38 @@ public Object invokeMethod(final Object obj, final String methodName, final Obje
throw new IllegalStateException("Invokation didn't work", e);
}
}
-
+
private void initMethods() {
final List methods = AnnotationReader.getAllMethodsWithAnnotationRecursively(this.c, InspectionMethod.class);
-
+
for (final Method m : methods) {
m.setAccessible(true);
this.inspectableMethods.put(this.getDsiplayNameForInspectionMethod(m), m);
}
}
-
+
private void initAttributes() {
final List fields = AnnotationReader.getAllAttributesWithAnnotationRecursively(this.c, InspectionAttribute.class);
final List methods = AnnotationReader.getAllMethodsWithAnnotationRecursively(this.c, InspectionAttribute.class);
-
+
for (final Field f : fields) {
f.setAccessible(true);
this.inspectableAttributes.put(this.getDisplayNameForField(f), new AttributeInspectionPoint(f));
}
-
+
final Map getters = new HashMap<>();
final Map setters = new HashMap<>();
-
+
for (int i = 0; i < methods.size(); i++) {
final Method m = methods.get(i);
-
+
if (this.isGetter(m)) {
getters.put(this.getDisplayNameForMethod(m, "get"), m);
} else if (this.isSetter(m)) {
setters.put(this.getDisplayNameForMethod(m, "set"), m);
} else throw new InspectionPointException("Method is neither a getter nor a setter! : " + m.getName());
}
-
+
for (final Entry entry : getters.entrySet()) {
final String name = entry.getKey();
final Method setter = setters.remove(name);
@@ -218,61 +218,56 @@ private void initAttributes() {
this.validateReadOnlyGetter(getter);
getter.setAccessible(true);
this.inspectableAttributes.put(name, new AttributeInspectionPoint(getter));
-
+
} else {
this.validateMethodPair(getter, setter);
getter.setAccessible(true);
setter.setAccessible(true);
this.inspectableAttributes.put(name, new AttributeInspectionPoint(getter, setter));
}
-
+
}
-
+
if (setters.size() > 0) throw new InspectionPointException("No getter for setter! : " + setters.values().iterator().next());
-
+
}
-
+
private boolean isGetter(final Method met) {
return (met.getParameterTypes().length == 0) && (met.getReturnType() != Void.TYPE);
}
-
+
private boolean isSetter(final Method met) {
return (met.getParameterTypes().length == 1) && (met.getReturnType() == Void.TYPE);
}
-
+
private void validateMethodPair(final Method getter, final Method setter) {
final Class> type = getter.getReturnType();
-
+
if (type.equals(Void.TYPE)) throw new InspectionPointException("Getter should return something! : " + getter.getName());
-
- if (
- getter.getParameterTypes().length != 0
- ) throw new InspectionPointException("Getter should not have parameters! : " + getter.getName());
-
- if (
- !setter.getReturnType().equals(Void.TYPE)
- ) throw new InspectionPointException("Setter should not be return type null. : " + setter.getName());
-
+
+ if (getter.getParameterTypes().length != 0)
+ throw new InspectionPointException("Getter should not have parameters! : " + getter.getName());
+
+ if (!setter.getReturnType().equals(Void.TYPE))
+ throw new InspectionPointException("Setter should not be return type null. : " + setter.getName());
+
final Class>[] setterParas = setter.getParameterTypes();
-
+
if (setterParas.length != 1) throw new InspectionPointException("Setter should have exactly one parameter! : " + setter.getName());
-
- if (
- !setterParas[0].equals(type)
- ) throw new InspectionPointException("Getter parameter is not the same type as getter return value");
-
+
+ if (!setterParas[0].equals(type))
+ throw new InspectionPointException("Getter parameter is not the same type as getter return value");
+
}
-
+
private void validateReadOnlyGetter(final Method getter) {
- if (
- getter.getReturnType().equals(Void.TYPE)
- ) throw new InspectionPointException("Getter should return something! : " + getter.getName());
-
- if (
- getter.getParameterTypes().length != 0
- ) throw new InspectionPointException("Getter should not have parameters! : " + getter.getName());
+ if (getter.getReturnType().equals(Void.TYPE))
+ throw new InspectionPointException("Getter should return something! : " + getter.getName());
+
+ if (getter.getParameterTypes().length != 0)
+ throw new InspectionPointException("Getter should not have parameters! : " + getter.getName());
}
-
+
private String getDisplayNameForField(final Field f) {
final InspectionAttribute anno = f.getAnnotation(InspectionAttribute.class);
if (anno != null) {
@@ -281,7 +276,7 @@ private String getDisplayNameForField(final Field f) {
}
return f.getName();
}
-
+
private String getDsiplayNameForInspectionMethod(final Method m) {
final InspectionMethod anno = m.getAnnotation(InspectionMethod.class);
if (anno != null) {
@@ -290,23 +285,23 @@ private String getDsiplayNameForInspectionMethod(final Method m) {
}
return m.getName();
}
-
+
private String getDisplayNameForMethod(final Method m, final String possiblePrefixToRemove) {
final InspectionAttribute anno = m.getAnnotation(InspectionAttribute.class);
if (anno != null) {
final String name = anno.name();
if ((name != null) && !name.isEmpty()) return name;
}
-
+
String name = m.getName();
-
+
if (name.toLowerCase().startsWith(possiblePrefixToRemove)) {
name = name.substring(3);
name = name.substring(0, 1).toLowerCase() + name.substring(1);
}
return name;
}
-
+
private static class AttributeInspectionPoint {
private static final Map, Class>> primitiveToWrapperMap = new HashMap<>();
static {
@@ -326,10 +321,10 @@ private static class AttributeInspectionPoint {
private final Method setter;
private final Class> type;
private final boolean readOnly;
-
+
/**
* Creates a new attribute inspection point for a field
- *
+ *
* @param field
* The field for the inspection point.
*/
@@ -341,7 +336,7 @@ public AttributeInspectionPoint(final Field field) {
this.type = this.convertTypeToWrappers(field.getType());
this.readOnly = field.getAnnotation(InspectionAttribute.class).readOnly();
}
-
+
public AttributeInspectionPoint(final Method getter) {
this.usesField = false;
this.f = null;
@@ -350,7 +345,7 @@ public AttributeInspectionPoint(final Method getter) {
this.type = this.convertTypeToWrappers(getter.getReturnType());
this.readOnly = true;
}
-
+
public AttributeInspectionPoint(final Method getter, final Method setter) {
this.usesField = false;
this.f = null;
@@ -359,17 +354,17 @@ public AttributeInspectionPoint(final Method getter, final Method setter) {
this.type = this.convertTypeToWrappers(getter.getReturnType());
this.readOnly = false;
}
-
+
private Class> convertTypeToWrappers(final Class> cls) {
if (!cls.isPrimitive()) return cls;
return AttributeInspectionPoint.primitiveToWrapperMap.get(cls);
}
-
+
public Object getValue(final Object obj) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
if (this.usesField) return this.f.get(obj);
return this.getter.invoke(obj);
}
-
+
public void setValue(final Object obj, final Object value)
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
if (this.readOnly) throw new InspectionPointException("Attribute is read only.");
@@ -380,29 +375,29 @@ public void setValue(final Object obj, final Object value)
this.setter.invoke(obj, value);
}
}
-
+
/**
* Get's {@link #type type}
- *
+ *
* @return type
*/
public Class> getType() {
return this.type;
}
-
+
/**
* Get's {@link #readOnly readOnly}
- *
+ *
* @return readOnly
*/
public boolean isReadOnly() {
return this.readOnly;
}
}
-
+
/**
* A exception that is thrown when an error with a inspection point occurs.
- *
+ *
* @author Tim Neumann
*/
public static class InspectionPointException extends RuntimeException {
@@ -410,7 +405,7 @@ public static class InspectionPointException extends RuntimeException {
* generated
*/
private static final long serialVersionUID = 6324656121971704376L;
-
+
/**
* Constructs a new runtime exception with {@code null} as its detail message. The cause is not initialized, and
* may subsequently be initialized by a call to {@link #initCause}.
@@ -418,7 +413,7 @@ public static class InspectionPointException extends RuntimeException {
public InspectionPointException() {
super();
}
-
+
/**
* Constructs a new runtime exception with the specified detail message. The cause is not initialized, and may
* subsequently be initialized by a call to {@link #initCause}.
@@ -429,7 +424,7 @@ public InspectionPointException() {
public InspectionPointException(final String message) {
super(message);
}
-
+
/**
* Constructs a new runtime exception with the specified detail message and cause.
*
@@ -446,7 +441,7 @@ public InspectionPointException(final String message) {
public InspectionPointException(final String message, final Throwable cause) {
super(message, cause);
}
-
+
/**
* Constructs a new runtime exception with the specified cause and a detail message of
* {@code (cause==null ? null : cause.toString())} (which typically contains the class and detail message of
@@ -461,7 +456,7 @@ public InspectionPointException(final String message, final Throwable cause) {
public InspectionPointException(final Throwable cause) {
super(cause);
}
-
+
/**
* Constructs a new runtime exception with the specified detail message, cause, suppression enabled or disabled,
* and writable stack trace enabled or disabled.
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionManager.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionManager.java
index d109efd51..5fe7331e0 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionManager.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionManager.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -21,20 +21,20 @@
/**
* A class for managing the inspections
- *
+ *
* @author Tim Neumann
*/
public class InspectionManager {
-
+
private final Map, InspectionData> inspectableClasses = new HashMap<>();
-
+
/**
* Create a new inspection manager.
*/
public InspectionManager() {
try {
final List> classes = ClassFinder.getClassesInClassLoader(c -> true);
-
+
for (final Class> cls : classes) {
final InspectionData d = new InspectionData(cls);
if (d.hasAnyInspectableElements()) {
@@ -45,10 +45,10 @@ public InspectionManager() {
e.printStackTrace();
}
}
-
+
/**
* Get's all attribute names of the given entity.
- *
+ *
* @param entity
* The entity to get the names for
* @return A List of attribute names.
@@ -58,10 +58,10 @@ public List getAttributeNamesOfEntity(final Entity entity) {
if (d == null) return Collections.emptyList();
return d.getAttributeNames();
}
-
+
/**
* Get's all method names of the given entity.
- *
+ *
* @param entity
* The entity to get the names for
* @return A List of method names.
@@ -71,10 +71,10 @@ public List getMethodNamesOfEntity(final Entity entity) {
if (d == null) return Collections.emptyList();
return d.getMethodNames();
}
-
+
/**
* Checks whether the attribute with the given name in the given entity is writable.
- *
+ *
* @param entity
* The entity.
* @param attributeName
@@ -86,10 +86,10 @@ public boolean isAttributeEditable(final Entity entity, final String attributeNa
if (d == null) return false;
return !d.isAttributeReadOnly(attributeName);
}
-
+
/**
* Get's the type of the attribute with the given name in the given entity.
- *
+ *
* @param entity
* The entity.
* @param attributeName
@@ -101,10 +101,10 @@ public Class> getAttributeType(final Entity entity, final String attributeName
if (d == null) return null;
return d.getAttributeType(attributeName);
}
-
+
/**
* Get the value of the attribute with the given name from the given entity
- *
+ *
* @param entity
* The entity to get the value from
* @param attributeName
@@ -116,10 +116,10 @@ public Object getAttributeValue(final Entity entity, final String attributeName)
if (d == null) return null;
return d.getAttributeValue(entity, attributeName);
}
-
+
/**
* Set the value of the attribute with the given name in the given entity
- *
+ *
* @param entity
* The entity to set the value in
* @param attributeName
@@ -133,10 +133,10 @@ public boolean setAttributeValue(final Entity entity, final String attributeName
if (d == null) return false;
return d.setAttributeValue(entity, attributeName, value);
}
-
+
/**
* Get the detail of the method with the given name of the given name.
- *
+ *
* @param entity
* The entity to get the method of.
* @param methodName
@@ -148,10 +148,10 @@ public Method getMethodDetail(final Entity entity, final String methodName) {
if (d == null) return null;
return d.getMethodByName(methodName);
}
-
+
/**
* Invokes the method with the given name on the given entity. Uses the given arguments.
- *
+ *
* @param entity
* The entity to invoke the method in.
* @param methodName
@@ -167,5 +167,5 @@ public Object invokeMethod(final Entity entity, final String methodName, final O
if (d == null) throw new IllegalStateException("Not a known inspectable class");
return d.invokeMethod(entity, methodName, args);
}
-
+
}
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionMethod.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionMethod.java
index 24b225972..a8b540048 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionMethod.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/inspection/InspectionMethod.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -19,7 +19,7 @@
/**
* A annotation specifying that the annotated method should be displayed as a method in the inspector.
- *
+ *
* @author Tim Neumann
*/
@Documented
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulation.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulation.java
index c4e00d026..d023fec70 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulation.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulation.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -34,17 +34,17 @@
* @author Tim Neumann
*/
public class StandardSimulation implements Simulation {
-
+
private final StandardPlayfield playfield;
private final StandardSimulationClock simulationClock;
private final StandardActionLog actionLog;
private final StandardEntityTypeRegistry entityTypeRegistry;
private final TaskVerifier taskVerifier;
private final StandardSimulationProxy simulationProxy;
-
+
private StandardTaskRunner runningTask;
private final StandardProgramRunner programRunner;
-
+
/**
* Creates a new standard simulation with the given parameters.
*
@@ -71,60 +71,60 @@ public StandardSimulation(
this.actionLog = actionLog;
this.entityTypeRegistry = entityTypeRegistry;
this.taskVerifier = taskVerifier;
-
+
this.programRunner = new StandardProgramRunner();
-
+
this.playfield.initialize(this);
-
+
if (taskVerifier != null) {
taskVerifier.attachToSimulation(this);
}
-
+
this.simulationProxy = new StandardSimulationProxy(
this, simulationClock, inspectionManager, entityTypeRegistry, playfield, taskVerifier
);
}
-
+
@Override
public Playfield getPlayfield() {
return this.playfield;
}
-
+
@Override
public TaskVerifier getTaskVerifier() {
return this.taskVerifier;
}
-
+
@Override
public SimulationClock getSimulationClock() {
return this.simulationClock;
}
-
+
@Override
public ActionLog getActionLog() {
return this.actionLog;
}
-
+
@Override
public EntityTypeRegistry getEntityTypeRegistry() {
return this.entityTypeRegistry;
}
-
+
@Override
public SimulationProxy getSimulationProxyForWindow() {
return this.simulationProxy;
}
-
+
@Override
public void attachToWindow(final GameWindow window) {
this.attachToWindow(window, false);
}
-
+
@Override
public void attachToWindow(final GameWindow window, final boolean stopWithWindowClose) {
this.getSimulationProxyForWindow().attachToGameWindow(window, stopWithWindowClose);
}
-
+
@Override
public void stop() {
if (this.runningTask != null) {
@@ -134,7 +134,7 @@ public void stop() {
this.programRunner.stopAll();
this.simulationClock.shutdown(); // stop the clock for good
}
-
+
@Override
public void runTask(final Task taskToRun) {
if (this.runningTask != null) {
@@ -143,7 +143,7 @@ public void runTask(final Task taskToRun) {
this.runningTask = new StandardTaskRunner(taskToRun, this);
this.runningTask.runTask();
}
-
+
@Override
public void runProgram(Program program, S entity) {
this.programRunner.run(program, entity);
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulationClock.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulationClock.java
index 2b9ef6e1d..6ce7abac6 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulationClock.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulationClock.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -37,20 +37,20 @@
*/
public class StandardSimulationClock implements SimulationClock {
private final Object tickListenerLock = new Object();
-
+
private final List> tickListeners;
private final List> postTickListeners;
-
+
private final Set> operationBoundaries;
-
+
private Consumer animationTickListener;
private StateChangeListener stateChangeListener;
-
+
private TimerTask task;
private final Timer timer;
-
+
private volatile long tickCount;
-
+
/**
* Setting this to true will signal the clock that it is in shutdown mode.
*
@@ -64,9 +64,9 @@ public class StandardSimulationClock implements SimulationClock {
*
*/
private volatile boolean shuttingDown;
-
+
private int period;
-
+
/**
* Default constructor
*/
@@ -79,7 +79,7 @@ public StandardSimulationClock() {
this.shuttingDown = false;
this.operationBoundaries = Collections.synchronizedSet(new HashSet<>());
}
-
+
/**
* This internal start function actually starts the timer but does not notify the simulation proxy. If you don't
* know what you do use {@link SimulationClock#start()}
@@ -87,9 +87,9 @@ public StandardSimulationClock() {
public synchronized void startInternal() {
if (this.isRunning()) throw new TimerAlreadyRunning();
if (this.shuttingDown) return;
-
+
this.task = new TimerTask() {
-
+
@Override
public void run() {
StandardSimulationClock.this.tick();
@@ -97,7 +97,7 @@ public void run() {
};
this.timer.schedule(this.task, 0, this.period);
}
-
+
/**
* This internal stop function actually stops the timer but does not notify the simulation proxy. If you don't know
* what you do use {@link SimulationClock#stop()}
@@ -108,7 +108,7 @@ public synchronized void stopInternal() {
}
this.task = null;
}
-
+
/**
* Shuts down this clock.
*
@@ -131,62 +131,62 @@ public synchronized void shutdown() {
boundary.cancel(true);
}
}
-
+
@Override
public synchronized void setPeriod(final int millis) {
this.period = millis;
-
+
if (this.isRunning()) {
this.stop();
this.start();
}
}
-
+
@Override
public int getRenderTickPeriod() {
return this.period;
}
-
+
@Override
public int getGameTickPeriod() {
return this.period * SimulationClock.RENDER_TICKS_PER_SIMULATION_TICK;
}
-
+
@Override
public boolean isRunning() {
return this.task != null;
}
-
+
@Override
public synchronized void start() {
if (this.stateChangeListener != null) {
this.stateChangeListener.clockStarted();
}
-
+
this.startInternal();
}
-
+
@Override
public synchronized void stop() {
if (this.stateChangeListener != null) {
this.stateChangeListener.clockPaused();
}
-
+
this.stopInternal();
}
-
+
@Override
public synchronized void step() {
if (this.isRunning()) throw new TimerAlreadyRunning();
if (this.shuttingDown) return;
-
+
new Thread(() -> {
StandardSimulationClock.this.tickCount = ((StandardSimulationClock.this.tickCount
- (StandardSimulationClock.this.tickCount % 8)) + 7);
StandardSimulationClock.this.tick();
}, "single-step").start();
}
-
+
/**
* Process a tick
*/
@@ -205,7 +205,7 @@ private void tick() {
}
}
}
-
+
/**
* Process a simulation tick
*
@@ -220,7 +220,7 @@ private void tickSimulation(final long tickNumber) {
this.tickListeners.remove(listener);
}
}
-
+
for (final var listener : List.copyOf(this.postTickListeners)) {
//Don't continue to process tick when shutting down.
if (this.shuttingDown) return;
@@ -229,7 +229,7 @@ private void tickSimulation(final long tickNumber) {
}
}
}
-
+
/**
* Set the animation tick listener, that gets called every animation tick and is responsible for informing the UI.
*
@@ -243,7 +243,7 @@ public void setAnimationTickListener(final Consumer listener) {
this.animationTickListener = listener;
} else throw new ListenerSetException();
}
-
+
/**
* Set the state change listener, that gets called when the clock get's started or paused through public API and is
* responsible for informing the UI.
@@ -258,7 +258,7 @@ public void setStateChangeListener(final StateChangeListener listener) {
this.stateChangeListener = listener;
} else throw new ListenerSetException();
}
-
+
/**
* Remove the state change listener, that gets called when the clock get's started or paused through public API and
* is responsible for informing the UI.
@@ -266,7 +266,7 @@ public void setStateChangeListener(final StateChangeListener listener) {
public void removeStateChangeListener() {
this.stateChangeListener = null;
}
-
+
@Override
public void registerTickListener(final Function listener) {
if (this.shuttingDown) return;
@@ -274,7 +274,7 @@ public void registerTickListener(final Function listener) {
this.tickListeners.add(listener);
}
}
-
+
@Override
public void registerPostTickListener(final Function listener) {
if (this.shuttingDown) return;
@@ -282,18 +282,18 @@ public void registerPostTickListener(final Function listener) {
this.postTickListeners.add(listener);
}
}
-
+
@Override
public long getLastTickNumber() {
//not rounding is intended here as we'd need floor and casting is the same as floor for positive integers
return this.tickCount / SimulationClock.RENDER_TICKS_PER_SIMULATION_TICK;
}
-
+
@Override
public long getLastRenderTickNumber() {
return this.tickCount;
}
-
+
@Override
public void scheduleOperationAtTick(final long tick, final CompletableFuture endOfOperation) {
if (this.shuttingDown) return;
@@ -328,17 +328,17 @@ public void scheduleOperationAtTick(final long tick, final CompletableFuture endOfOperation) {
this.scheduleOperationAtTick(this.getLastTickNumber() + ticks, endOfOperation);
}
-
+
@Override
public void scheduleOperationAtNextTick(final CompletableFuture endOfOperation) {
this.scheduleOperationInTicks(1, endOfOperation);
}
-
+
/**
* The interface for a listener listening for simulation clock starts and stops. The listener is only informed when
* the state change is caused from the public API, not from UI interaction.
@@ -348,7 +348,7 @@ public interface StateChangeListener {
* The clock was started.
*/
void clockStarted();
-
+
/**
* The clock was paused/stopped.
*/
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulationProxy.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulationProxy.java
index bdc883a0c..20a493495 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulationProxy.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/StandardSimulationProxy.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -43,21 +43,21 @@
* @version 1.0
*/
public class StandardSimulationProxy implements SimulationProxy {
-
+
/** A lookup table for the simulation times */
public static final int[] SIMULATION_TIMES = {
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1000, 415, 200, 115, 75, 50, 42, 34, 26, 18, 10
// These values are aproximated by two functions originally by haslersn which where modified by waeltkts
};
-
+
// GAME WINDOW
private GameWindow gameWindow;
private boolean stopSimulationWithWindowClose = false;
-
+
// MANAGERS
private final InspectionManager inspectionManager;
-
+
// CURRENT SIMULATION
private final Simulation simulation;
private final StandardEntityTypeRegistry entityTypeRegistry;
@@ -65,9 +65,9 @@ public class StandardSimulationProxy implements SimulationProxy {
private final StandardPlayfield playfield;
private final TaskVerifier taskVerifier;
private final Map simualtionSidebarMap;
-
+
private Entity entityToInspect;
-
+
/**
* Create a new standard simulation proxy
*
@@ -95,7 +95,7 @@ public StandardSimulationProxy(
this.playfield = playfield;
this.taskVerifier = taskVerifier;
this.simualtionSidebarMap = new ConcurrentHashMap<>();
-
+
// attach tick listeners to simulation clock
// only do this once per SimulationProxy as unsetting these listeners is not possible atm
this.simulationClock.setAnimationTickListener(new Consumer() {
@@ -106,24 +106,24 @@ public void accept(final Long tickCount) {
}
}
});
-
+
this.simulationClock.registerPostTickListener(unused -> {
updateEntityInspector();
return true; // post tick listener could be removed by returning false here
});
}
-
+
@Override
public void attachToGameWindow(final GameWindow window) {
this.attachToGameWindow(window, false);
}
-
+
@Override
public void attachToGameWindow(final GameWindow window, final boolean stopWithWindowClose) {
if (this.gameWindow != null) throw new IllegalStateException("Already attached to a window!");
this.gameWindow = window;
this.stopSimulationWithWindowClose = stopWithWindowClose;
-
+
//Simulation Clock
if (this.simulationClock.isRunning()) {
this.gameWindow.getToolbar().setClockButtonState(ClockButtonState.PLAYING);
@@ -131,21 +131,21 @@ public void attachToGameWindow(final GameWindow window, final boolean stopWithWi
this.gameWindow.getToolbar().setClockButtonState(ClockButtonState.PAUSED);
}
this.simulationSpeedChange(this.gameWindow.getToolbar().getSpeedSliderPosition());
-
+
this.simulationClock.setStateChangeListener(new StateChangeListener() {
@Override
public void clockStarted() {
StandardSimulationProxy.this.gameWindow.getToolbar().setClockButtonState(ClockButtonState.PLAYING);
}
-
+
@Override
public void clockPaused() {
StandardSimulationProxy.this.gameWindow.getToolbar().setClockButtonState(ClockButtonState.PAUSED);
}
});
-
+
//EntityDrawing
-
+
this.playfield.setDrawablesChangedListener(new Consumer>() {
@Override
public void accept(final List drawables) {
@@ -154,10 +154,10 @@ public void accept(final List drawables) {
}
}
});
-
+
//ControlButtonState
this.gameWindow.getToolbar().setControlButtonState(ControlButtonState.VIEW);
-
+
//EntitySelection
this.entityTypeRegistry.setEntityRegisteredListener((entityName, textureHandle) -> {
if (StandardSimulationProxy.this.gameWindow != null) {
@@ -175,7 +175,7 @@ public void accept(final List drawables) {
} catch (@SuppressWarnings("unused") final NullPointerException e) {
// catching exception instead of checking before allows to avoid synchronization here
}
-
+
this.gameWindow.getEntitySidebar().setSimulationTreeRootNode(this.playfield.getSimulationTree());
this.gameWindow.getEntitySidebar().enableSimulationTree();
this.playfield.setSimulationTreeEntityAddedListener((node, entity) -> {
@@ -186,19 +186,19 @@ public void accept(final List drawables) {
this.simualtionSidebarMap.remove(node);
this.gameWindow.getEntitySidebar().updateSimulationTree();
});
-
+
this.gameWindow.getEntitySidebar().disableEntityInspector();
-
+
// taskState
TaskInformation task = null;
if (this.taskVerifier != null) {
task = this.taskVerifier.getTaskInformation();
}
this.gameWindow.getTaskStatusDisplay().setTaskInformation(task);
-
+
this.gameWindow.setSimulationProxy(this);
}
-
+
@Override
public void windowClosed() {
// clear listeners first
@@ -208,16 +208,16 @@ public void windowClosed() {
this.playfield.removeSimulationTreeEntityAddedListener();
this.playfield.removeSimulationTreeEntityRemovedListener();
this.entityTypeRegistry.removeEntityRegisteredListener();
-
+
// remove gameWindow reference
this.gameWindow = null;
-
+
// stop simulation
if (this.stopSimulationWithWindowClose) {
this.simulation.stop();
}
}
-
+
@Override
public void buttonPressed(final ButtonType type) {
switch (type) {
@@ -227,7 +227,7 @@ public void buttonPressed(final ButtonType type) {
}
this.gameWindow.getToolbar().setClockButtonState(ClockButtonState.PLAYING);
break;
-
+
case STEP:
if (!this.simulationClock.isRunning()) {
this.simulationClock.step();
@@ -236,48 +236,48 @@ public void buttonPressed(final ButtonType type) {
}
this.gameWindow.getToolbar().setClockButtonState(ClockButtonState.PAUSED);
break;
-
+
case PAUSE:
if (this.simulationClock.isRunning()) {
this.simulationClock.stopInternal();
}
this.gameWindow.getToolbar().setClockButtonState(ClockButtonState.PAUSED);
break;
-
+
case VIEW:
this.gameWindow.getToolbar().setControlButtonState(ControlButtonState.VIEW);
this.gameWindow.getPlayfieldDrawer().setSelectedTool(ControlButtonState.VIEW);
break;
-
+
case ADD:
this.gameWindow.getToolbar().setControlButtonState(ControlButtonState.ADD);
this.gameWindow.getPlayfieldDrawer().setSelectedTool(ControlButtonState.ADD);
break;
-
+
case SUB:
this.gameWindow.getToolbar().setControlButtonState(ControlButtonState.SUB);
this.gameWindow.getPlayfieldDrawer().setSelectedTool(ControlButtonState.SUB);
break;
-
+
default:
}
}
-
+
@Override
public void simulationSpeedChange(final int value) {
this.simulationClock.setPeriod(StandardSimulationProxy.SIMULATION_TIMES[value]);
}
-
+
@Override
public void selectedEntityChanged(final String name) {
String textureHandle = null;
if ((name != null) && !name.equals("")) {
textureHandle = this.entityTypeRegistry.getTextureHandleOfEntityType(name);
}
-
+
this.gameWindow.getPlayfieldDrawer().setSelectedEntityType(name, textureHandle);
}
-
+
@Override
public void refreshTaskInformation() {
TaskInformation task = null;
@@ -287,7 +287,7 @@ public void refreshTaskInformation() {
}
this.gameWindow.getTaskStatusDisplay().setTaskInformation(task);
}
-
+
@Override
public void spawnEntityAt(final String typeName, final int x, final int y) {
try {
@@ -302,11 +302,11 @@ public void spawnEntityAt(final String typeName, final int x, final int y) {
e.printStackTrace();
}
}
-
+
@Override
public void clearCell(final int x, final int y) {
final List toRemove = this.playfield.getEntitiesAt(new Position(x, y));
-
+
toRemove.forEach(entity -> {
try {
this.playfield.removeEntity(entity);
@@ -315,10 +315,10 @@ public void clearCell(final int x, final int y) {
}
});
}
-
+
private EntityInspectorEntry[] getEntries(final Entity e) {
final List result = new ArrayList<>();
-
+
for (final String name : this.inspectionManager.getAttributeNamesOfEntity(e)) {
String type = "string";
if (!this.inspectionManager.isAttributeEditable(e, name)) {
@@ -337,7 +337,7 @@ private EntityInspectorEntry[] getEntries(final Entity e) {
this.updateEntityInspector();
}));
}
-
+
for (final String name : this.inspectionManager.getMethodNamesOfEntity(e)) {
final String type = "function";
result.add(new EntityInspectorEntry(name, type, "", unused -> {
@@ -349,13 +349,13 @@ private EntityInspectorEntry[] getEntries(final Entity e) {
}
return result.toArray(new EntityInspectorEntry[result.size()]);
}
-
+
private void updateEntityInspector() {
if (this.gameWindow == null) return;
if (this.entityToInspect == null) return;
this.gameWindow.getEntitySidebar().setEntityInspectorEntries(this.getEntries(this.entityToInspect));
}
-
+
@Override
public void selectedSimulationEntityChange(final SimulationTreeNode node) {
if (node == null) {
@@ -363,7 +363,7 @@ public void selectedSimulationEntityChange(final SimulationTreeNode node) {
} else {
this.entityToInspect = this.simualtionSidebarMap.get(node);
}
-
+
if (this.entityToInspect != null) {
this.gameWindow.getEntitySidebar().enableEntityInspector();
this.gameWindow.getEntitySidebar().setEntityInspectorName(this.entityToInspect.toString());
@@ -374,7 +374,7 @@ public void selectedSimulationEntityChange(final SimulationTreeNode node) {
this.gameWindow.getEntitySidebar().disableEntityInspector();
}
}
-
+
@Override
public void entityValueChange(final String name, final String value) {
// Intentionally left blank
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/actions/StandardActionLog.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/actions/StandardActionLog.java
index 2915b9021..5ff023cef 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/actions/StandardActionLog.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/actions/StandardActionLog.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -27,30 +27,30 @@
* @author Tim Neumann
*/
public class StandardActionLog implements ActionLog {
-
+
private final Object actionsLock = new Object();
private final Object entityActionsLock = new Object();
-
+
private final MultiTypedList actions = new MultiTypedList<>();
-
+
private final Map> entityActions = new HashMap<>();
-
+
private boolean consoleLog = true;
-
+
@Override
public List getAllActions() {
synchronized (this.actionsLock) {
return this.actions.get(Action.class, true);
}
}
-
+
@Override
public List getActionsOfType(final Class extends T> type, final boolean includeSubclasses) {
synchronized (this.actionsLock) {
return this.actions.get(type, includeSubclasses);
}
}
-
+
@Override
public List getAllActionsOfEntity(final Entity entity) {
synchronized (this.entityActionsLock) {
@@ -59,7 +59,7 @@ public List getAllActionsOfEntity(final Entity entity) {
return list.get(EntityAction.class, true);
}
}
-
+
@Override
public List getActionsOfTypeOfEntity(
final Entity entity, final Class extends T> type, final boolean includeSubclasses
@@ -70,7 +70,7 @@ public List getActionsOfTypeOfEntity(
return list.get(type, includeSubclasses);
}
}
-
+
@Override
public void logAction(final Action actionToLog) {
if (actionToLog instanceof EntityAction) {
@@ -90,12 +90,12 @@ public void logAction(final Action actionToLog) {
System.out.println(actionToLog.getDescription());
}
}
-
+
@Override
public void setConsoleOutput(boolean enable) {
this.consoleLog = enable;
}
-
+
@Override
public boolean getConsoleOutput() {
return this.consoleLog;
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/entity/StandardEntityTypeRegistry.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/entity/StandardEntityTypeRegistry.java
index e0a9d6a7a..cb32e5870 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/entity/StandardEntityTypeRegistry.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/entity/StandardEntityTypeRegistry.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -27,12 +27,12 @@
* @author Fabian Bühler
*/
public class StandardEntityTypeRegistry implements EntityTypeRegistry {
-
+
private final Map> typeToEntityFactory = new HashMap<>();
private final Map typeToTextureHandle = new HashMap<>();
-
+
private EntityRegisteredListener entityRegisteredListener;
-
+
@Override
public void registerEntityType(final String typeName, final String textureHandle, final Class extends Entity> entityType) {
if (entityType == null) throw new IllegalArgumentException("Entity type class object cannot be null!");
@@ -50,37 +50,36 @@ public void registerEntityType(final String typeName, final String textureHandle
};
this.registerEntityType(typeName, textureHandle, entityFactory);
}
-
+
@Override
public synchronized void registerEntityType(
final String typeName, final String textureHandle, final Supplier extends Entity> entityFactory
) {
if ((typeName == null) || typeName.equals("")) throw new IllegalArgumentException("Type name cannot be null or empty!");
- if (
- (textureHandle == null) || textureHandle.equals("")
- ) throw new IllegalArgumentException("Texture handle cannot be null or empty!");
+ if ((textureHandle == null) || textureHandle.equals(""))
+ throw new IllegalArgumentException("Texture handle cannot be null or empty!");
if (entityFactory == null) throw new IllegalArgumentException("Entity factory cannot be null!");
if (entityFactory.get() == null) throw new IllegalArgumentException("Unable to instantiate a new entity!");
if (this.typeToEntityFactory.containsKey(typeName)) throw new ElementExistsException();
this.typeToEntityFactory.put(typeName, entityFactory);
this.typeToTextureHandle.put(typeName, textureHandle);
-
+
if (this.entityRegisteredListener != null) {
this.entityRegisteredListener.entityWasRegistered(typeName, textureHandle);
}
}
-
+
@Override
public Set getRegisteredEntityTypes() {
return this.typeToEntityFactory.keySet();
}
-
+
@Override
public String getTextureHandleOfEntityType(final String typeName) {
if ((typeName == null) || typeName.equals("")) throw new IllegalArgumentException("Type name cannot be null or empty!");
return this.typeToTextureHandle.get(typeName);
}
-
+
@Override
public Entity getNewEntity(final String typeName) {
if ((typeName == null) || typeName.equals("")) throw new IllegalArgumentException("Type name cannot be null or empty!");
@@ -88,7 +87,7 @@ public Entity getNewEntity(final String typeName) {
if (entityFactory == null) return null;
return entityFactory.get();
}
-
+
/**
* Set an entity selector listener that gets informed about all entity types added.
*
@@ -107,14 +106,14 @@ public synchronized void setEntityRegisteredListener(final EntityRegisteredListe
this.entityRegisteredListener = listener;
} else throw new ListenerSetException();
}
-
+
/**
* Remove the set entity selector listener that gets informed about all entity types added.
*/
public synchronized void removeEntityRegisteredListener() {
this.entityRegisteredListener = null;
}
-
+
/**
* The interface for when an entity is registered
*/
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/playfield/PlayfieldCell.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/playfield/PlayfieldCell.java
index 4b8663bb1..a42c37afc 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/playfield/PlayfieldCell.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/playfield/PlayfieldCell.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,15 +16,15 @@
/**
* Represents one cell on the playfield.
- *
+ *
* @author Tim Neumann
*/
public class PlayfieldCell extends MultiTypedList {
private final Position pos;
-
+
/**
* Create a new playfield cell,
- *
+ *
* @param pos
* The position of the cell
*/
@@ -32,7 +32,7 @@ public PlayfieldCell(final Position pos) {
super();
this.pos = pos;
}
-
+
/**
* @return the position of this cell
*/
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/playfield/StandardPlayfield.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/playfield/StandardPlayfield.java
index 6846a512a..5aa777a98 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/playfield/StandardPlayfield.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/playfield/StandardPlayfield.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -43,22 +43,22 @@
*/
public class StandardPlayfield implements Playfield {
private WeakReference sim;
-
+
private final Object playfieldLock = new Object();
-
+
private final Map cells = new HashMap<>();
private final Map entityPositions = new HashMap<>();
-
+
private SimulationTreeNode simualtionTreeRootNode;
-
+
private BiConsumer simulationTreeEntityAddedListener;
private Consumer simulationTreeEntityRemovedListener;
-
+
private Consumer> drawablesChangedListener;
-
+
private boolean awaitingEntityDraw = false;
private long timeBetweenDraws = 32; //the time between draw calls in milliseconds
-
+
/**
* Initialize the playfield for the given simulation
*
@@ -71,19 +71,19 @@ public void initialize(final StandardSimulation simulation) {
this.drawEntities();
return true;
});
-
+
this.simualtionTreeRootNode = new SimulationTreeNode("root", "Entities", "", false);
-
+
new Timer().scheduleAtFixedRate(new TimerTask() {
-
+
@Override
public void run() {
drawEntitiesInternal();
}
-
+
}, 0, this.timeBetweenDraws);
}
-
+
/**
* @throws IllegalStateException
* if this playfield is not part of any simulation
@@ -95,7 +95,7 @@ public Simulation getSimulation() {
if (simulation == null) throw new IllegalStateException("This playfield is not part of any simulation.");
return simulation;
}
-
+
/**
* Queues a draw update to the playfield drawer. Draw updates are sent to the playfield drawer automatically every
* 32ms.
@@ -103,7 +103,7 @@ public Simulation getSimulation() {
public void drawEntities() {
this.awaitingEntityDraw = true;
}
-
+
/**
* Converts all entities to drawables and sends them to the playfield drawer.
*/
@@ -127,14 +127,14 @@ private void drawEntitiesInternal() {
} catch (@SuppressWarnings("unused") final IllegalStateException e) {
//If we are not attached to a simultion we do not need to draw anything
}
-
+
}
-
+
@Override
public List getAllEntities() {
return this.getAllEntitiesOfType(Entity.class, true);
}
-
+
@Override
public List getAllEntitiesOfType(final Class extends T> type, final boolean includeSubclasses) {
if (type == null) throw new IllegalArgumentException("The given type is null.");
@@ -146,13 +146,13 @@ public List getAllEntitiesOfType(final Class extends T>
}
return result;
}
-
+
@Override
public List getEntitiesAt(final Position pos) {
if (pos == null) throw new IllegalArgumentException("The given pos is null.");
return this.getEntitiesOfTypeAt(pos, Entity.class, true);
}
-
+
@Override
public List getEntitiesOfTypeAt(
final Position pos, final Class extends T> type, final boolean includeSubclasses
@@ -168,7 +168,7 @@ public List getEntitiesOfTypeAt(
}
return result;
}
-
+
private void addEntityToCell(final Position pos, final Entity entity) {
synchronized (this.playfieldLock) {
PlayfieldCell cell = this.cells.get(pos);
@@ -179,7 +179,7 @@ private void addEntityToCell(final Position pos, final Entity entity) {
cell.add(entity);
}
}
-
+
private void removeEntityFromCell(final Position pos, final Entity entity) {
synchronized (this.playfieldLock) {
final PlayfieldCell cell = this.cells.get(pos);
@@ -193,31 +193,30 @@ private void removeEntityFromCell(final Position pos, final Entity entity) {
}
}
}
-
+
@Override
public void addEntity(final Position pos, final Entity entity) {
if (pos == null) throw new IllegalArgumentException("The given pos is null.");
if (entity == null) throw new IllegalArgumentException("The given entity is null.");
-
+
synchronized (this.playfieldLock) {
- if (
- this.entityPositions.containsKey(entity)
- ) throw new EntityAlreadyOnFieldExcpetion("The given entity" + entity + "is already on this playfield.");
-
+ if (this.entityPositions.containsKey(entity))
+ throw new EntityAlreadyOnFieldExcpetion("The given entity" + entity + "is already on this playfield.");
+
entity.initOnPlayfield(this);
-
+
this.addEntityToCell(pos, entity);
-
+
this.entityPositions.put(entity, pos);
-
+
this.getSimulation().getActionLog()
.logAction(new EntitySpawnAction(this.getSimulation().getSimulationClock().getLastTickNumber(), entity, this, pos));
-
+
this.addEntityToSimulationTree(entity);
}
this.drawEntities();
}
-
+
private SimulationTreeNode findNodeForEntity(final Entity entity, final boolean create) {
final List> classHiera = new ArrayList<>();
{
@@ -228,7 +227,7 @@ private SimulationTreeNode findNodeForEntity(final Entity entity, final boolean
} while (Entity.class.isAssignableFrom(clazz));
}
SimulationTreeNode node = this.simualtionTreeRootNode;
-
+
hieraLoop: for (final Class> clazz : classHiera) {
for (final SimulationTreeNode child : node.getChildren()) {
if (child.getElementId().equals(clazz.getName())) {
@@ -245,65 +244,62 @@ private SimulationTreeNode findNodeForEntity(final Entity entity, final boolean
}
return node;
}
-
+
private void addEntityToSimulationTree(final Entity entity) {
final SimulationTreeNode newNode = new SimulationTreeNode(
Integer.toHexString(entity.hashCode()), entity.toString(), entity.getDrawInformation().getTextureHandle()
);
this.findNodeForEntity(entity, true).appendChild(newNode);
-
+
if (this.simulationTreeEntityAddedListener != null) {
// TODO check for bugs with simulation tree when window is reattached or attached late
this.simulationTreeEntityAddedListener.accept(newNode, entity);
}
}
-
+
@Override
public void moveEntity(final Entity entity, final Position pos) {
this.moveEntity(entity, pos, null);
}
-
+
@Override
public void moveEntity(final Entity entity, final Position pos, final EntityMoveAction action) {
if (pos == null) throw new IllegalArgumentException("The given pos is null.");
if (entity == null) throw new IllegalArgumentException("The given entity is null.");
-
+
synchronized (this.playfieldLock) {
- if (
- !this.entityPositions.containsKey(entity)
- ) throw new EntityNotOnFieldException("The given entity" + entity + "is not on this playfield.");
-
+ if (!this.entityPositions.containsKey(entity))
+ throw new EntityNotOnFieldException("The given entity" + entity + "is not on this playfield.");
+
EntityMoveAction actionToLog = action;
-
+
final Position oldPos = this.entityPositions.get(entity);
-
+
if (actionToLog == null) {
actionToLog = new EntityTeleportAction(this.getSimulation().getSimulationClock().getLastTickNumber(), entity, oldPos, pos);
} else {
- if (
- !actionToLog.getEntity().equals(entity)
- ) throw new IllegalArgumentException("Given action wasn't caused by given entity.");
- if (
- !actionToLog.from().equals(oldPos)
- ) throw new IllegalArgumentException("Given action does not start at current position of given entity.");
+ if (!actionToLog.getEntity().equals(entity))
+ throw new IllegalArgumentException("Given action wasn't caused by given entity.");
+ if (!actionToLog.from().equals(oldPos))
+ throw new IllegalArgumentException("Given action does not start at current position of given entity.");
if (!actionToLog.to().equals(pos)) throw new IllegalArgumentException("Given action does not end at given pos.");
}
-
+
this.removeEntityFromCell(oldPos, entity);
this.addEntityToCell(pos, entity);
this.entityPositions.put(entity, pos);
-
+
this.getSimulation().getActionLog().logAction(actionToLog);
-
+
}
this.drawEntities();
}
-
+
private void removeEntityFromSimulationTree(final Entity entity) {
final SimulationTreeNode node = this.findNodeForEntity(entity, false);
-
+
if (node == null) return;
-
+
for (final SimulationTreeNode child : node.getChildren()) {
if (child.getElementId().equals(Integer.toHexString(entity.hashCode()))) {
node.removeChild(child);
@@ -314,29 +310,28 @@ private void removeEntityFromSimulationTree(final Entity entity) {
}
}
}
-
+
@Override
public void removeEntity(final Entity entity) {
if (entity == null) throw new IllegalArgumentException("The given entity is null.");
-
+
synchronized (this.playfieldLock) {
- if (
- !this.entityPositions.containsKey(entity)
- ) throw new EntityNotOnFieldException("The given entity" + entity + "is not on this playfield.");
-
+ if (!this.entityPositions.containsKey(entity))
+ throw new EntityNotOnFieldException("The given entity" + entity + "is not on this playfield.");
+
final Position pos = this.entityPositions.get(entity);
this.removeEntityFromCell(pos, entity);
this.entityPositions.remove(entity, pos);
-
+
this.getSimulation().getActionLog()
.logAction(new EntityDespawnAction(this.getSimulation().getSimulationClock().getLastTickNumber(), entity, this));
-
+
this.removeEntityFromSimulationTree(entity);
-
+
}
this.drawEntities();
}
-
+
@Override
public Position getEntityPosition(final Entity entity) {
if (entity == null) throw new IllegalArgumentException("The given entity is null.");
@@ -346,7 +341,7 @@ public Position getEntityPosition(final Entity entity) {
return pos;
}
}
-
+
@Override
public boolean containsEntity(final Entity entity) {
if (entity == null) throw new IllegalArgumentException("The given entity is null.");
@@ -354,7 +349,7 @@ public boolean containsEntity(final Entity entity) {
return this.entityPositions.containsKey(entity);
}
}
-
+
@Override
public boolean isSolidEntityAt(final Position pos) {
final List solidEntitiesAtPos = this.getEntitiesOfTypeAt(pos, SolidEntity.class, true);
@@ -363,14 +358,14 @@ public boolean isSolidEntityAt(final Position pos) {
}
return false;
}
-
+
/**
* @return the root node of the simulation tree
*/
public SimulationTreeNode getSimulationTree() {
return this.simualtionTreeRootNode;
}
-
+
/**
* Set the listener for when an entity is added to the simulation tree.
*
@@ -382,14 +377,14 @@ public void setSimulationTreeEntityAddedListener(final BiConsumer> listener)
this.drawablesChangedListener = listener;
} else throw new ListenerSetException();
}
-
+
/**
* Remove the listener for when the drawables on the playfield changed. This listener is responsible for informing
* the UI.
@@ -429,7 +424,7 @@ public void setDrawablesChangedListener(final Consumer> listener)
public void removeDrawablesChangedListener() {
this.drawablesChangedListener = null;
}
-
+
@Override
public String toString() {
return this.getClass().getSimpleName() + "@" + Integer.toHexString(this.hashCode());
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/programs/StandardProgramRunner.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/programs/StandardProgramRunner.java
index 9da1d2d93..55106863d 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/programs/StandardProgramRunner.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/programs/StandardProgramRunner.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -29,21 +29,21 @@
* @author Fabian Bühler
*/
public class StandardProgramRunner {
-
+
private ExecutorService executor;
-
+
private final Map> runningPrograms = new HashMap<>();
-
+
/**
* Standard constructor setting up the executor for the Futures.
*/
public StandardProgramRunner() {
this.executor = this.createExecutor();
}
-
+
/**
* Create an executor that uses named threads for a better debugging experience,
- *
+ *
* @return the executor service
*/
private ExecutorService createExecutor() {
@@ -53,15 +53,15 @@ private ExecutorService createExecutor() {
worker.setDaemon(true);
return worker;
};
-
+
return new ForkJoinPool(Runtime.getRuntime().availableProcessors(), factory, null, false);
}
-
+
/**
* Run a program for the given entity inside a completable future.
- *
+ *
* Only one program can bu run for a each entity.
- *
+ *
* @param
* The subtype of Entity that the Program accepts
* @param
@@ -79,7 +79,7 @@ public void run(final Program program, final
throw new IllegalStateException("Already running a program for entity " + entity.toString() + "!");
}
}
-
+
final CompletableFuture future = CompletableFuture.runAsync(() -> {
try {
program.run(entity);
@@ -94,11 +94,11 @@ public void run(final Program program, final
System.out.println("----------------------------------------------");
}
}, this.executor);
-
+
// set the running program in the entityMap
this.runningPrograms.put(entity, future);
}
-
+
/**
* Get the running program as a CompletableFuture.
*
@@ -109,7 +109,7 @@ public void run(final Program program, final
public CompletableFuture getRunningProgram(Entity entity) {
return this.runningPrograms.get(entity);
}
-
+
/**
* Stop all running programs.
*/
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/tasks/StandardTaskRunner.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/tasks/StandardTaskRunner.java
index 80dbd37c0..9be58f903 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/tasks/StandardTaskRunner.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/internal/tasks/StandardTaskRunner.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -26,14 +26,14 @@
* @author Tim Neumann
*/
public class StandardTaskRunner {
-
+
private final ExecutorService executor;
-
+
private final Task taskToRun;
private final Simulation sim;
-
+
private CompletableFuture taskResult;
-
+
/**
* Create a new task runner.
*
@@ -50,11 +50,11 @@ public StandardTaskRunner(final Task taskToRun, final Simulation sim) {
Thread worker = new Thread(runnable, "TaskThread-" + taskToRun.toString());
return worker;
};
-
+
// only one task can be run per task runner so parallelism of one is ok
this.executor = Executors.newSingleThreadExecutor(factory);
}
-
+
/**
* Run the given task.
*
@@ -66,10 +66,10 @@ public StandardTaskRunner(final Task taskToRun, final Simulation sim) {
public CompletableFuture runTask() {
if (this.taskResult != null) return this.taskResult;
this.taskResult = CompletableFuture.supplyAsync(this::executeTask, this.executor);
-
+
return this.taskResult;
}
-
+
private boolean executeTask() {
try {
this.taskToRun.run(this.sim);
@@ -95,7 +95,7 @@ private boolean executeTask() {
return false;
}
}
-
+
/**
* Cancel the completable future and intterupt the underlying thread.
*/
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/programs/Program.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/programs/Program.java
index 338c06bbe..49d8580c8 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/programs/Program.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/programs/Program.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -15,16 +15,16 @@
/**
* The interface for programs that operate on entities.
- *
+ *
* Programs can be run by using {@link Simulation#runProgram}.
- *
+ *
* @param
* The type of entities this program can operate on.
*/
public interface Program {
/**
* The entry method of the program.
- *
+ *
* @param entity
* The entity this program operates on.
*/
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/tasks/Task.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/tasks/Task.java
index a7fb0513e..276a88b7b 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/tasks/Task.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/tasks/Task.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
diff --git a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/tools/PlayfieldModifier.java b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/tools/PlayfieldModifier.java
index 69b91026c..ac0db9320 100644
--- a/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/tools/PlayfieldModifier.java
+++ b/ICGE-Simulation/src/main/java/de/unistuttgart/informatik/fius/icge/simulation/tools/PlayfieldModifier.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -18,25 +18,25 @@
/**
* A tool to modify a playfield and place entities on it.
- *
+ *
* @author Tim Neumann
*/
public class PlayfieldModifier {
private final Playfield playfield;
-
+
/**
* Create a new playfield modifier for the given playfield.
- *
+ *
* @param playfield
* The playfield to create the modifier for
*/
public PlayfieldModifier(final Playfield playfield) {
this.playfield = playfield;
}
-
+
/**
* Place the given entity at the given position on the playfield.
- *
+ *
* @param entity
* The entity to place
* @param position
@@ -45,10 +45,10 @@ public PlayfieldModifier(final Playfield playfield) {
public void placeEntityAt(final Entity entity, final Position position) {
this.playfield.addEntity(position, entity);
}
-
+
/**
* Place the given number of entities supplied by the given factory at the given location.
- *
+ *
* @param entityFactory
* The factory to get the entities from
* @param count
@@ -61,10 +61,10 @@ public void placeMultipleEntitiesAt(final Supplier extends Entity> entityFacto
placeEntityAt(entityFactory.get(), position);
}
}
-
+
/**
* Place an entity supplied by the given factory at each of the given positions
- *
+ *
* @param entityFactory
* The factory to get the entities from
* @param positions
diff --git a/ICGE-Simulation/src/main/java/module-info.java b/ICGE-Simulation/src/main/java/module-info.java
index 7b5bc416b..9117dd04f 100644
--- a/ICGE-Simulation/src/main/java/module-info.java
+++ b/ICGE-Simulation/src/main/java/module-info.java
@@ -1,15 +1,15 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
module de.unistuttgart.informatik.fius.icge.simulation {
requires transitive de.unistuttgart.informatik.fius.icge.ui;
-
+
exports de.unistuttgart.informatik.fius.icge.simulation;
exports de.unistuttgart.informatik.fius.icge.simulation.entity;
exports de.unistuttgart.informatik.fius.icge.simulation.exception;
diff --git a/ICGE-Ui/pom.xml b/ICGE-Ui/pom.xml
index ac1082fe3..18b9f3f7f 100644
--- a/ICGE-Ui/pom.xml
+++ b/ICGE-Ui/pom.xml
@@ -3,11 +3,14 @@
4.0.0
de.uni-stuttgart.informatik.fius
- ICGE
- 2.3.9-Snapshot
+ icge
+ 2.3.8
- ICGE-Ui
+ icge-ui
ICGE Ui
+
+ 2.3.8
+
org.junit.jupiter
@@ -15,7 +18,8 @@
de.uni-stuttgart.informatik.fius
- ICGE-Log
+ icge-log
+ ${icge.version}
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/AnimatedDrawable.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/AnimatedDrawable.java
index 4425ff478..400dbeec8 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/AnimatedDrawable.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/AnimatedDrawable.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -15,22 +15,22 @@
* @author Fabian Bühler
*/
public class AnimatedDrawable implements Drawable {
-
+
private final double xStart;
private final double yStart;
private final double xEnd;
private final double yEnd;
-
+
private final int z;
-
+
private final String textureHandle;
-
+
private final long tickStart;
private final long tickEnd;
private final long duration;
-
+
private long currentTick = 0;
-
+
/**
* Create a new animated Drawable.
*
@@ -66,12 +66,12 @@ public AnimatedDrawable(
this.z = z;
this.textureHandle = textureHandle;
}
-
+
@Override
public void setCurrentTick(final long renderTick) {
this.currentTick = renderTick;
}
-
+
@Override
public double getX() {
if (this.currentTick <= this.tickStart) return this.xStart;
@@ -79,7 +79,7 @@ public double getX() {
final double completion = (this.currentTick - this.tickStart) / (double) this.duration;
return ((this.xEnd - this.xStart) * completion) + this.xStart;
}
-
+
@Override
public double getY() {
if (this.currentTick <= this.tickStart) return this.yStart;
@@ -87,84 +87,84 @@ public double getY() {
final double completion = (this.currentTick - this.tickStart) / (double) this.duration;
return ((this.yEnd - this.yStart) * completion) + this.yStart;
}
-
+
@Override
public int getZ() {
return this.z;
}
-
+
@Override
public String getTextureHandle() {
return this.textureHandle;
}
-
+
@Override
public boolean isTilable() {
return false;
}
-
+
@Override
public boolean isAnimated() {
return this.currentTick <= this.tickEnd;
}
-
+
/**
* Get's {@link #xStart xStart}
- *
+ *
* @return xStart
*/
public double getxStart() {
return this.xStart;
}
-
+
/**
* Get's {@link #yStart yStart}
- *
+ *
* @return yStart
*/
public double getyStart() {
return this.yStart;
}
-
+
/**
* Get's {@link #xEnd xEnd}
- *
+ *
* @return xEnd
*/
public double getxEnd() {
return this.xEnd;
}
-
+
/**
* Get's {@link #yEnd yEnd}
- *
+ *
* @return yEnd
*/
public double getyEnd() {
return this.yEnd;
}
-
+
/**
* Get's {@link #tickStart tickStart}
- *
+ *
* @return tickStart
*/
public long getTickStart() {
return this.tickStart;
}
-
+
/**
* Get's {@link #tickEnd tickEnd}
- *
+ *
* @return tickEnd
*/
public long getTickEnd() {
return this.tickEnd;
}
-
+
/**
* Get's {@link #duration duration}
- *
+ *
* @return duration
*/
public long getDuration() {
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/BasicDrawable.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/BasicDrawable.java
index d9d080243..13766b9ec 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/BasicDrawable.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/BasicDrawable.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -15,35 +15,35 @@
* @author Tim Neumann
*/
public class BasicDrawable implements Drawable {
-
+
/**
* The x coordinate of the drawable.
*
* The coordinate system is based on cells where fractionals denote positions between cells.
*/
private final double x;
-
+
/**
* The y coordinate of the drawable.
*
* The coordinate system is based on cells where fractionals denote positions between cells.
*/
private final double y;
-
+
/**
* The z value of the drawable.
*
* The z value is used to decide the drawing order of Drawables in the same cell.
*/
private final int z;
-
+
/**
* The handle of the texture for this drawable.
*
* The texture must be registered in the TextureRegistry.
*/
private final String textureHandle;
-
+
/**
* Create a new Drawable.
*
@@ -62,22 +62,22 @@ public BasicDrawable(final double x, final double y, final int z, final String t
this.z = z;
this.textureHandle = textureHandle;
}
-
+
@Override
public double getX() {
return this.x;
}
-
+
@Override
public double getY() {
return this.y;
}
-
+
@Override
public int getZ() {
return this.z;
}
-
+
@Override
public String getTextureHandle() {
return this.textureHandle;
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/Console.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/Console.java
index 7ad3d95cd..5c20d0cca 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/Console.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/Console.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,7 +16,7 @@
* @version 2.0
*/
public interface Console {
-
+
/**
* Clears the console in the ui.
*/
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/Drawable.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/Drawable.java
index 89b241fdd..d90d8f088 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/Drawable.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/Drawable.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -17,7 +17,7 @@
* @version 1.0
*/
public interface Drawable extends Comparable {
-
+
/**
* Get the x coordinate of the drawable.
*
@@ -26,7 +26,7 @@ public interface Drawable extends Comparable {
* @return returns the X position as a double
*/
double getX();
-
+
/**
* Get the y coordinate of the drawable.
*
@@ -35,7 +35,7 @@ public interface Drawable extends Comparable {
* @return returns the Y position as a double
*/
double getY();
-
+
/**
* Get the z value of the drawable.
*
@@ -44,7 +44,7 @@ public interface Drawable extends Comparable {
* @return returns the Z position as a double
*/
int getZ();
-
+
/**
* Get the handle of the texture for this drawable.
*
@@ -53,7 +53,7 @@ public interface Drawable extends Comparable {
* @return returns the texture handle as a String
*/
String getTextureHandle();
-
+
/**
* Return wether this Drawable can be drawn tiled if multiple are present in the same cell.
*
@@ -62,26 +62,26 @@ public interface Drawable extends Comparable {
default boolean isTilable() {
return true;
}
-
+
/**
* Return wether the Drawable is animated.
- *
+ *
* @return true iff any property (x, y, z) is animated
*/
default boolean isAnimated() {
return false;
}
-
+
/**
* Set the current render tick for animated drawables.
- *
+ *
* @param renderTick
* The current render tick
*/
default void setCurrentTick(final long renderTick) {
return; // default to noop
}
-
+
@Override
default int compareTo(final Drawable o) {
double compareResult = 0;
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/EntityInspectorEntry.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/EntityInspectorEntry.java
index a4dd4b6c6..51c9203a2 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/EntityInspectorEntry.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/EntityInspectorEntry.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,18 +16,18 @@
* EntityInspectorEntry
*/
public class EntityInspectorEntry {
-
+
private final String name;
-
+
private final String type;
-
+
private final String value;
-
+
private final Consumer callback;
-
+
/**
* Default constructor
- *
+ *
* @param name
* The name of the setting
* @param type
@@ -43,37 +43,37 @@ public EntityInspectorEntry(final String name, final String type, final String v
this.value = value;
this.callback = callback;
}
-
+
/**
* Getter for the name
- *
+ *
* @return returns the name
*/
public String getName() {
return this.name;
}
-
+
/**
* Getter for the type
- *
+ *
* @return returns the type
*/
public String getType() {
return this.type;
}
-
+
/**
* Getter for the value
- *
+ *
* @return returns the value
*/
public String getValue() {
return this.value;
}
-
+
/**
* This function runs the callback of the item
- *
+ *
* @param arg
* The argument of the callback
*/
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/EntitySidebar.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/EntitySidebar.java
index 84d0c3e33..1a9d56f32 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/EntitySidebar.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/EntitySidebar.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,7 +16,7 @@
* @version 1.0
*/
public interface EntitySidebar {
-
+
/**
* Setter function to attach a SimulationTree to the entity sidebar.
*
@@ -24,12 +24,12 @@ public interface EntitySidebar {
* The root node of the simulation tree.
*/
void setSimulationTreeRootNode(SimulationTreeNode treeNode);
-
+
/**
* This function should be called if the simulation tree changes.
*/
void updateSimulationTree();
-
+
/**
* This function deletes all currently created ui elements and creates a new inspector
*
@@ -37,52 +37,52 @@ public interface EntitySidebar {
* The entries to create the inspector from
*/
void setEntityInspectorEntries(EntityInspectorEntry[] entries);
-
+
/**
* Get the selected element of the simulation tree.
- *
+ *
* @return the currently selected SimulationTreeNode
*/
SimulationTreeNode getSimulationTreeSelectedElement();
-
+
/**
* Set the selected element of the simulation tree.
- *
+ *
* @param node
* The SimulationTreeNode to select
*/
void setSimulationTreeSelectedElement(SimulationTreeNode node);
-
+
/**
* Enable the simulation tree.
*/
void enableSimulationTree();
-
+
/**
* Disable the simulation tree.
*/
void disbaleSimulationTree();
-
+
/**
* Set the name of the entity inspector.
- *
+ *
* @param name
* The name to set
*/
void setEntityInspectorName(String name);
-
+
/**
* Get the current name of the entity inspector.
- *
+ *
* @return The name
*/
String getEntityInspectorName();
-
+
/**
* Enable the entity inspector.
*/
void enableEntityInspector();
-
+
/**
* Disable the entity inspector.
*/
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/GameWindow.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/GameWindow.java
index 67ddb6e4b..52b7d0f22 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/GameWindow.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/GameWindow.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -21,42 +21,42 @@ public interface GameWindow {
* @return The texture registry used by this window.
*/
TextureRegistry getTextureRegistry();
-
+
/**
* Get the drawer responsible for drawing the playfield for this game window.
*
* @return The playfield drawer used by this window.
*/
PlayfieldDrawer getPlayfieldDrawer();
-
+
/**
* Get the toolbar for this game window.
*
* @return The toolbar used by this window.
*/
Toolbar getToolbar();
-
+
/**
* Get the entity sidebar for this game window
*
* @return The entity sidebar used by this window
*/
EntitySidebar getEntitySidebar();
-
+
/**
* Get the console for this game window
*
* @return The console used by this window
*/
Console getConsole();
-
+
/**
* Get the task status display for this game window.
*
* @return The task status display used by this window
*/
TaskStatusDisplay getTaskStatusDisplay();
-
+
/**
* Set the title of the window, in which the ICGE is displayed.
*
@@ -64,17 +64,17 @@ public interface GameWindow {
* The title to use.
*/
void setWindowTitle(String title);
-
+
/**
* Start and show the game window.
*/
void start();
-
+
/**
* Stop and close the game window. This action is equivalent with pressing the "X"-button of the window.
*/
void stop();
-
+
/**
* Set the simulation proxy instance used by multiple UI components to inform the Simulation of user actions.
*
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/PlayfieldDrawer.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/PlayfieldDrawer.java
index c5ea55708..83ac6e533 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/PlayfieldDrawer.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/PlayfieldDrawer.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -20,7 +20,7 @@
* @author Tim Neumann
*/
public interface PlayfieldDrawer {
-
+
/**
* Set the current list of Drawables to be rendered onto the playfield.
*
@@ -30,7 +30,7 @@ public interface PlayfieldDrawer {
* the list of Drawables to render
*/
void setDrawables(List drawables);
-
+
/**
* Draws the playfield.
*
@@ -38,25 +38,25 @@ public interface PlayfieldDrawer {
* The number of the current tick
*/
void draw(long tickCount);
-
+
/**
* Reset Zoom and Pan applied by the user to the default values.
*/
void resetZoomAndPan();
-
+
/**
* @param useDoubleBuffering
* true (default) uses doubleBuffering when rendering changes on the playfield.
*/
void setDoubleBuffering(boolean useDoubleBuffering);
-
+
/**
* @param syncToScreen
* true (default) actively tries to sync the updated graphics to the screen after rendering changes on the
* playfield.
*/
void setSyncToScreen(boolean syncToScreen);
-
+
/**
* Inform the playfield drawer about which tool is selected in the toolbar. This influences what happens when a user
* clicks on the playfield.
@@ -65,7 +65,7 @@ public interface PlayfieldDrawer {
* The currently selected tool
*/
void setSelectedTool(ControlButtonState selectedTool);
-
+
/**
* Inform the playfield drawer about which entity type is selected in the toolbar. This influences what entity is
* spawned when a user uses the entity creation tool.
@@ -76,5 +76,5 @@ public interface PlayfieldDrawer {
* The texture handle for the entity type selected.
*/
void setSelectedEntityType(String typeName, String textureHandle);
-
+
}
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/SimulationProxy.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/SimulationProxy.java
index 099a50921..3e056494e 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/SimulationProxy.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/SimulationProxy.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -21,7 +21,7 @@
* @version 1.0
*/
public interface SimulationProxy {
-
+
/**
* Attach this simulation proxy to a specific game window.
*
@@ -29,7 +29,7 @@ public interface SimulationProxy {
* The game window to attach to
*/
void attachToGameWindow(GameWindow gameWindow);
-
+
/**
* Attach this simulation proxy to a specific game window.
*
@@ -39,16 +39,16 @@ public interface SimulationProxy {
* If {@code true} the simulation will stop when the attached window is closed
*/
void attachToGameWindow(GameWindow gameWindow, boolean stopWithWindowClose);
-
+
/**
* Called when the window is closing.
*/
void windowClosed();
-
+
//
// Toolbar
//
-
+
/**
* This is to identify the buttons
*/
@@ -66,7 +66,7 @@ public enum ButtonType {
/** The sub button in the toolbar */
SUB
}
-
+
/**
* This is called when a button is pressed by the user
*
@@ -74,7 +74,7 @@ public enum ButtonType {
* The type of the pressed button
*/
void buttonPressed(ButtonType type);
-
+
/**
* This is called if the speed slider is changed by the user
*
@@ -82,7 +82,7 @@ public enum ButtonType {
* The new selected speed
*/
void simulationSpeedChange(int value);
-
+
/**
* This gets called when the user changes the selected element
*
@@ -90,18 +90,18 @@ public enum ButtonType {
* The name of the selected element
*/
void selectedEntityChanged(String name);
-
+
/**
* This gets called by the user to refresh task status information.
*
* Calling this must verify the task.
*/
void refreshTaskInformation();
-
+
//
// Entity placing
//
-
+
/**
* Spawn a new entity of the given type at the given position and bind the program to this entity.
*
@@ -113,7 +113,7 @@ public enum ButtonType {
* coordinate
*/
void spawnEntityAt(String typeName, int x, int y);
-
+
/**
* Clear all entities in the given cell.
*
@@ -123,11 +123,11 @@ public enum ButtonType {
* coordinate
*/
void clearCell(int x, int y);
-
+
//
// Sidebar - Simulation Tree
//
-
+
/**
* This function gets called when the user selects a different node
*
@@ -135,11 +135,11 @@ public enum ButtonType {
* The node with was selected
*/
void selectedSimulationEntityChange(SimulationTreeNode node);
-
+
//
// Entity Inspector
//
-
+
/**
* This function gets called when a user changes a value or fires a function in the ui
*
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/SimulationTreeNode.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/SimulationTreeNode.java
index fb6b7028b..bd15e2f9e 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/SimulationTreeNode.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/SimulationTreeNode.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -25,14 +25,14 @@
* @version 1.0
*/
public class SimulationTreeNode {
-
+
private ArrayList children;
-
+
private final String elementId;
private final String displayText;
private final String textureId;
private final boolean isLeaf;
-
+
/**
* Default constructor for leaf nodes
*
@@ -49,7 +49,7 @@ public SimulationTreeNode(final String elementId, final String displayText, fina
this.textureId = textureId;
this.isLeaf = true;
}
-
+
/**
* This constructor can be used to create non leaf nodes as well as leaf nodes.
*
@@ -66,13 +66,13 @@ public SimulationTreeNode(final String elementId, final String displayText, fina
if (!isLeaf) {
this.children = new ArrayList<>();
}
-
+
this.elementId = elementId;
this.displayText = displayText;
this.textureId = textureId;
this.isLeaf = isLeaf;
}
-
+
/**
* Getter for the element id the non visible string to better identify the selected entity.
*
@@ -81,7 +81,7 @@ public SimulationTreeNode(final String elementId, final String displayText, fina
public String getElementId() {
return this.elementId;
}
-
+
/**
* Getter for the display text which is the name of the entity which is displayed to the user.
*
@@ -90,7 +90,7 @@ public String getElementId() {
public String getDisplayText() {
return this.displayText;
}
-
+
/**
* Getter for the texture id the identifier of the texture which is rendered infront of the display text.
*
@@ -99,7 +99,7 @@ public String getDisplayText() {
public String getTextureId() {
return this.textureId;
}
-
+
/**
* This checks if node is a leaf node.
*
@@ -108,7 +108,7 @@ public String getTextureId() {
public boolean isLeaf() {
return this.isLeaf;
}
-
+
/**
* Function to check if the node has children.
*
@@ -116,10 +116,10 @@ public boolean isLeaf() {
*/
public boolean hasChildren() {
if (this.isLeaf) return false;
-
+
return !this.children.isEmpty();
}
-
+
/**
* Appends a child node to this node
*
@@ -129,10 +129,10 @@ public boolean hasChildren() {
*/
public boolean appendChild(final SimulationTreeNode node) {
if (this.isLeaf) throw new LeafNodeException();
-
+
return this.children.add(node);
}
-
+
/**
* Removes a child node from this node
*
@@ -142,17 +142,17 @@ public boolean appendChild(final SimulationTreeNode node) {
*/
public boolean removeChild(final SimulationTreeNode node) {
if (this.isLeaf) throw new LeafNodeException();
-
+
return this.children.remove(node);
}
-
+
/**
* @return a list of all children
*/
public List getChildren() {
return List.copyOf(this.children);
}
-
+
/**
* Runs a function for each added child node with the child node as a parameter
*
@@ -161,23 +161,23 @@ public List getChildren() {
*/
public void forEachChild(final Consumer lamda) {
if (this.isLeaf) throw new LeafNodeException();
-
+
for (final SimulationTreeNode child : this.children) {
lamda.accept(child);
}
}
-
+
@Override
public int hashCode() {
return this.elementId.hashCode();
}
-
+
@Override
public boolean equals(final Object obj) {
if (!(obj instanceof SimulationTreeNode)) return false;
return Objects.equals(this.elementId, ((SimulationTreeNode) obj).elementId);
}
-
+
@Override
public String toString() {
return this.getDisplayText();
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TaskInformation.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TaskInformation.java
index 0808f4e69..86ab147eb 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TaskInformation.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TaskInformation.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -19,28 +19,28 @@
* @version 1.0
*/
public interface TaskInformation {
-
+
/**
* Get the title of the task.
- *
+ *
* @return the task title (must not be {@code null}, without trailing newline)
*/
String getTaskTitle();
-
+
/**
* Get the description of the task.
*
* @return the task description (can be {@code null}, can contain newlines, without trailing newline)
*/
String getTaskDescription();
-
+
/**
* Get the verification status of the task.
- *
+ *
* @return the task status (must not be {@code null})
*/
TaskVerificationStatus getTaskStatus();
-
+
/**
* Get a list of child/sub tasks of this task.
*
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TaskStatusDisplay.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TaskStatusDisplay.java
index a89de65cb..a274b7416 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TaskStatusDisplay.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TaskStatusDisplay.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,10 +16,10 @@
* @version 1.0
*/
public interface TaskStatusDisplay {
-
+
/**
* Set the task information to be displayed.
- *
+ *
* @param task
* the information of the current task (and subtasks)
*/
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TaskVerificationStatus.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TaskVerificationStatus.java
index 584c9cfda..fd96eb55c 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TaskVerificationStatus.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TaskVerificationStatus.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TextureRegistry.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TextureRegistry.java
index 7f66bd77c..ee2a1eafe 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TextureRegistry.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/TextureRegistry.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -21,7 +21,7 @@
* @author Tim Neumann
*/
public interface TextureRegistry {
-
+
/**
* Load an image from an internal resource as texture and return the handle to the texture.
*
@@ -42,21 +42,21 @@ public interface TextureRegistry {
* the texture could not be loaded from the given resource location
*/
String loadTextureFromResource(String resourceName, final Function resourceProvider);
-
+
/**
* Create a new animated texture with the animation length in render ticks.
- *
+ *
* Use {@link #addAnimationFrameToTexture} to add animation frames to the animated texture.
- *
+ *
* @param loop
* if true the animation will loop after the last frame
* @return the handle to retrieve the texture
*/
String createAnimatedTexture(boolean loop);
-
+
/**
* Add a animation frame to an animated texture.
- *
+ *
* @param animatedTexture
* the animated texture to add the animation frame to
* @param frameTexture
@@ -65,16 +65,16 @@ public interface TextureRegistry {
* the number of frames to show this texture
*/
void addAnimationFrameToTexture(String animatedTexture, String frameTexture, long frames);
-
+
/**
* Check if a texture is animated.
- *
+ *
* @param textureHandle
* the texture to check
* @return true iff the texture is animated
*/
boolean isTextureAnimated(String textureHandle);
-
+
/**
* Load an image from a file path as texture and return the handle to the texture.
*
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/Toolbar.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/Toolbar.java
index b45318655..f40679b4e 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/Toolbar.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/Toolbar.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -20,7 +20,7 @@
* @version 1.0
*/
public interface Toolbar {
-
+
/**
* The clock button state represents the states of the clock buttons in the ui
*/
@@ -32,7 +32,7 @@ enum ClockButtonState {
/** Indicates an error or unavailable clock or simulation */
BLOCKED
}
-
+
/**
* The control button state represents the status of the control buttons in the ui
*/
@@ -46,7 +46,7 @@ enum ControlButtonState {
/** Indicates that the user input is blocked or unavailable */
BLOCKED
}
-
+
/**
* Append the list of entities with the given entry
*
@@ -57,58 +57,58 @@ enum ControlButtonState {
* @see DropdownSelector
*/
void addEntity(String displayName, String textureID);
-
+
/**
* Set the state of the control buttons.
- *
+ *
* @param controlButtonState
* The new state
*/
void setControlButtonState(ControlButtonState controlButtonState);
-
+
/**
* Set the state of the clock buttons.
- *
+ *
* @param clockButtonState
* The new state
*/
void setClockButtonState(ClockButtonState clockButtonState);
-
+
/**
* Get the current position of the speed slider.
- *
+ *
* @return The position from 0 to 10 (both inclusive)
*/
int getSpeedSliderPosition();
-
+
/**
* Set the position of the speed slider.
- *
+ *
* @param position
* The new position; can be from 0 to 10 (both inclusive)
*/
void setSpeedSliderPosition(int position);
-
+
/**
* Get the entity currently selected in the entity selection dropdown.
- *
+ *
* @return The name of the currently selected entity
*/
String getCurrentlySelectedEntity();
-
+
/**
* Set the entity selected in the entity selection dropdown.
- *
+ *
* @param entity
* The name of the entity to select
*/
void setCurrentlySelectedEntity(String entity);
-
+
/**
* Enable the entity selector
*/
void enableEntitySelector();
-
+
/**
* Disable the entity selector
*/
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/WindowBuilder.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/WindowBuilder.java
index 5a423921c..1c1339ec5 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/WindowBuilder.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/WindowBuilder.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -36,33 +36,33 @@
* @author Tim Neumann
*/
public class WindowBuilder {
-
+
private static boolean isDefaultLookAndFeelUpdated = false;
private static double dpiScale;
private static double fontScale;
-
+
private String windowTitle = "";
private boolean useDoubleBuffering;
private boolean syncToScreen;
private volatile GameWindow window;
-
+
/**
* Create a new WindowBuilder.
*/
public WindowBuilder() {
this(WindowBuilder.getDeviceDpiScale());
}
-
+
/**
* Create a new WindowBuilder.
- *
+ *
* @param dpiScale
* the scaling factor for high dpi screens, only effective for the very first WindowBuilder instantiation!
*/
public WindowBuilder(double dpiScale) {
if (dpiScale < 0.5) throw new IllegalArgumentException("A dpi scale < 0.5 is not supported!");
if (dpiScale > 3.0) throw new IllegalArgumentException("A dpi scale > 3.0 is not supported!");
-
+
if (!WindowBuilder.isDefaultLookAndFeelUpdated) { // only once
WindowBuilder.isDefaultLookAndFeelUpdated = true;
WindowBuilder.dpiScale = dpiScale;
@@ -70,22 +70,22 @@ public WindowBuilder(double dpiScale) {
this.setUiDefaults(dpiScale, WindowBuilder.fontScale);
}
}
-
+
/**
* Get the scaling factor from the default display device.
- *
+ *
* @return the dpi scale of the default display
*/
private static double getDeviceDpiScale() {
return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().getDefaultTransform()
.getScaleX();
}
-
+
/**
* Set the UI Manager defaults forlook and feeel and dpi scaling.
*
* This method must only be called once. Calling this twice may have undefined behaviur.
- *
+ *
* @param dpiScale
* The dpi scaling factor to use to scale all fonts.
* @param fontScale
@@ -111,7 +111,7 @@ private void setUiDefaults(double dpiScale, double fontScale) {
System.err.println("Can't set look and feel because of: " + e.toString());
}
}
-
+
/**
* Set the title of the new window.
*
@@ -124,13 +124,12 @@ private void setUiDefaults(double dpiScale, double fontScale) {
* The title to set
*/
public void setTitle(final String title) {
- if (
- this.hasBuiltWindow()
- ) throw new IllegalStateException("The window was already built! Use the methods of the Window Object to change its properties.");
-
+ if (this.hasBuiltWindow())
+ throw new IllegalStateException("The window was already built! Use the methods of the Window Object to change its properties.");
+
this.windowTitle = title;
}
-
+
/**
* Set the graphics settings of the playfield drawer.
*
@@ -146,14 +145,13 @@ public void setTitle(final String title) {
* playfield.
*/
public void setGraphicsSettings(final boolean useDoubleBuffering, final boolean syncToScreen) {
- if (
- this.hasBuiltWindow()
- ) throw new IllegalStateException("The window was already built! Use the methods of the Window Object to change its properties.");
-
+ if (this.hasBuiltWindow())
+ throw new IllegalStateException("The window was already built! Use the methods of the Window Object to change its properties.");
+
this.useDoubleBuffering = useDoubleBuffering;
this.syncToScreen = syncToScreen;
}
-
+
/**
* Actually build the window.
*
@@ -162,9 +160,8 @@ public void setGraphicsSettings(final boolean useDoubleBuffering, final boolean
*
*/
public void buildWindow() {
- if (
- this.hasBuiltWindow()
- ) throw new IllegalStateException("The window was already built! Use getBuiltWindow() to acess the built window.");
+ if (this.hasBuiltWindow())
+ throw new IllegalStateException("The window was already built! Use getBuiltWindow() to acess the built window.");
try {
SwingUtilities.invokeAndWait(this::buildWindowInternal);
} catch (final InterruptedException | InvocationTargetException e) {
@@ -172,7 +169,7 @@ public void buildWindow() {
System.err.println("Can't build the window because of: " + e.toString());
}
}
-
+
/**
* Build the window.
*
@@ -185,25 +182,25 @@ private void buildWindowInternal() {
final SwingEntitySidebar entitySidebar = new SwingEntitySidebar(textureRegistry, WindowBuilder.dpiScale);
final SwingConsole console = new SwingConsole(WindowBuilder.fontScale);
final SwingTaskStatusDisplay taskStatus = new SwingTaskStatusDisplay(WindowBuilder.fontScale);
-
+
playfieldDrawer.setDoubleBuffering(this.useDoubleBuffering);
playfieldDrawer.setSyncToScreen(this.syncToScreen);
-
+
this.window = new SwingGameWindow(textureRegistry, playfieldDrawer, toolbar, entitySidebar, console, taskStatus);
if (this.windowTitle != null) {
this.window.setWindowTitle(this.windowTitle);
}
}
-
+
/**
* Get whether the window has been built.
- *
+ *
* @return true if and only if the window has been built
*/
public boolean hasBuiltWindow() {
return this.window != null;
}
-
+
/**
* Get the window that was built.
*
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/exception/LeafNodeException.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/exception/LeafNodeException.java
index 9f68b20a3..144d389c8 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/exception/LeafNodeException.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/exception/LeafNodeException.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -18,7 +18,7 @@
*/
public class LeafNodeException extends UnsupportedOperationException {
private static final long serialVersionUID = 2227365905217962083L;
-
+
/**
* Default constructor
*/
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/exception/ListenerSetException.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/exception/ListenerSetException.java
index f15a93580..6a772cf81 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/exception/ListenerSetException.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/exception/ListenerSetException.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -11,13 +11,13 @@
/**
* The ListenerSetException is thrown if a set listener function in the SimulationProxy fails
- *
+ *
* @author Tobias Wältken
* @version 1.0
*/
public class ListenerSetException extends IllegalArgumentException {
private static final long serialVersionUID = -2620520061340158420L;
-
+
/**
* Default constructor
*/
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/exception/TextureNotFoundException.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/exception/TextureNotFoundException.java
index e398c0704..84728316f 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/exception/TextureNotFoundException.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/exception/TextureNotFoundException.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -13,12 +13,12 @@
* Exception thrown when a texture file or resource could not be found.
*/
public class TextureNotFoundException extends RuntimeException {
-
+
/**
* generated
*/
private static final long serialVersionUID = -6554875504029045378L;
-
+
/**
* Construct a new {@code TextureNotFoundException} with the given message.
*
@@ -28,7 +28,7 @@ public class TextureNotFoundException extends RuntimeException {
public TextureNotFoundException(final String message) {
super(message);
}
-
+
/**
* Construct a new {@code TextureNotFoundException} with the given message.
*
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/AnimatedTexture.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/AnimatedTexture.java
index 4db8ce81c..c75bca1ed 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/AnimatedTexture.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/AnimatedTexture.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,19 +16,19 @@
/**
* Class containing multiple textures of an animation.
- *
+ *
* @author Fabian Bühler
*/
public class AnimatedTexture implements Texture {
-
+
private final SwingTextureRegistry registry;
private final ArrayList animationFrames;
private long duration;
private final boolean loop;
-
+
/**
* Create a new animated Texture.
- *
+ *
* @param registry
* the texture registry.
* @param loop
@@ -40,10 +40,10 @@ public AnimatedTexture(final SwingTextureRegistry registry, final boolean loop)
this.duration = 0;
this.loop = loop;
}
-
+
/**
* Add a texture at the end of the animation.
- *
+ *
* @param frameTexture
* the texture handle of the texture to add.
* @param frames
@@ -57,10 +57,10 @@ public void addAnimationFrame(final String frameTexture, final long frames) {
final AnimationFrame frame = new AnimationFrame(last, last + (frames - 1), texture);
this.animationFrames.add(frame);
}
-
+
/**
* Get the texture for the current frame.
- *
+ *
* @param frame
* the current frame
* @return the texture for the frame
@@ -68,10 +68,10 @@ public void addAnimationFrame(final String frameTexture, final long frames) {
public Texture getTextureForTick(final long frame) {
return this.getTextureForTick(frame, 0);
}
-
+
/**
* Get the texture for the current frame.
- *
+ *
* @param frame
* the current frame
* @param animationStart
@@ -80,7 +80,7 @@ public Texture getTextureForTick(final long frame) {
*/
private Texture getTextureForTick(final long frame, final long animationStart) {
if (this.duration == 0) throw new IllegalStateException("AnimatedTexture is empty!");
-
+
long animationFrame = frame - animationStart;
if (this.loop) {
animationFrame = animationFrame % this.duration;
@@ -98,22 +98,22 @@ private Texture getTextureForTick(final long frame, final long animationStart) {
}
throw new IllegalStateException("This can only happen if the start and end frames of the animation frames were set wrong!");
}
-
+
@Override
public Image getTexture(final long frame) {
return this.getTextureForTick(frame).getTexture();
}
-
+
@Override
public void drawTexture(final long frame, final Graphics g, final int x, final int y, final int width, final int height) {
this.getTextureForTick(frame).drawTexture(frame, g, x, y, width, height);
}
-
+
private class AnimationFrame {
private final long startFrame;
private final long endFrame;
private final Texture texture;
-
+
private AnimationFrame(final long startFrame, final long endFrame, final Texture texture) {
this.startFrame = startFrame;
this.endFrame = endFrame;
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/ConsoleBufferedOutputStream.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/ConsoleBufferedOutputStream.java
index 4ae62dc38..57f2ff3f7 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/ConsoleBufferedOutputStream.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/ConsoleBufferedOutputStream.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -41,18 +41,18 @@
* @version 2.0
*/
public class ConsoleBufferedOutputStream extends OutputStream {
-
+
/** The maximum length of the line buffer. */
static final int DEFAULT_MAX_BUFFER_LENGTH = 4096;
private final int maxBufferLength;
-
+
private final Timer timer;
-
+
//TODO add actual buffer to avoid overflowing the textarea and cause lag
private final JTextPane textPane;
private final Style style;
private final StringBuilder lineBuffer;
-
+
/**
* Default Constructor
*
@@ -66,10 +66,10 @@ public class ConsoleBufferedOutputStream extends OutputStream {
public ConsoleBufferedOutputStream(final JTextPane textPane, final OutputStyle style) {
this(textPane, style, DEFAULT_MAX_BUFFER_LENGTH);
}
-
+
/**
* Constructor with maxBufferLenght included
- *
+ *
* @param textPane
* The text pane to place the stream data into
* @param style
@@ -81,10 +81,10 @@ public ConsoleBufferedOutputStream(final JTextPane textPane, final OutputStyle s
public ConsoleBufferedOutputStream(final JTextPane textPane, final OutputStyle style, int maxBufferLength) {
this.maxBufferLength = maxBufferLength;
this.lineBuffer = new StringBuilder(maxBufferLength * 2);
-
+
this.textPane = textPane;
this.style = this.textPane.addStyle(style.toString(), null);
-
+
switch (style) {
case STANDARD:
break;
@@ -94,7 +94,7 @@ public ConsoleBufferedOutputStream(final JTextPane textPane, final OutputStyle s
default:
throw new UnsupportedOperationException("With stye type " + style.toString());
}
-
+
this.timer = new Timer(32, (event) -> {
try {
// flush the line buffer in regular intervalls
@@ -106,44 +106,44 @@ public ConsoleBufferedOutputStream(final JTextPane textPane, final OutputStyle s
this.timer.setCoalesce(true);
this.timer.start(); // start timer after everything is initialized
}
-
+
@Override
public void flush() throws IOException {
super.flush();
this.flushLineBufferToTextPane();
}
-
+
@Override
public void close() throws IOException {
super.close();
this.timer.stop();
}
-
+
@Override
public void write(final int character) throws IOException {
final char symbol = (char) character;
-
+
synchronized (this.lineBuffer) {
this.lineBuffer.append(symbol);
}
-
+
if (this.lineBuffer.length() >= this.maxBufferLength) {
this.flushLineBufferToTextPane();
}
}
-
+
private void flushLineBufferToTextPane() throws IOException {
if (this.lineBuffer.length() == 0) { // fast exit as default without costly synchronized
return; // nothing to flush in the line buffer
}
-
+
String newText;
synchronized (this.lineBuffer) { // stringBuilder is not threadsafe
// get the current buffer and reset linebuffer
newText = this.lineBuffer.toString();
this.lineBuffer.setLength(0);
}
-
+
if (newText.length() > 0) { // new null check because previous check may be obsolete now
// print line to text pane
SwingUtilities.invokeLater(() -> {
@@ -158,14 +158,14 @@ private void flushLineBufferToTextPane() throws IOException {
});
}
}
-
+
/**
* Get's {@link #maxBufferLength maxBufferLength}
- *
+ *
* @return maxBufferLength
*/
public int getMaxBufferLength() {
return this.maxBufferLength;
}
-
+
}
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/OutputStyle.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/OutputStyle.java
index e8899560b..da399d887 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/OutputStyle.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/OutputStyle.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -11,14 +11,14 @@
/**
* Enum to identify different standard styles for the ConsoleBufferedOutputStream
- *
+ *
* @author David Ruff
*/
public enum OutputStyle {
-
+
/** Standard Style for text from stdout */
STANDARD,
-
+
/** Style for text from stderr (e.g. errors) */
ERROR
}
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/StaticTexture.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/StaticTexture.java
index b268e030d..9e99fdfb7 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/StaticTexture.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/StaticTexture.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -15,28 +15,28 @@
/**
* Class containing a texture image and methods to draw this image.
- *
+ *
* @author Fabian Bühler
*/
public class StaticTexture implements Texture {
-
+
private final Image texture;
-
+
/**
* Create a new Texture.
- *
+ *
* @param texture
* the image to use as texture.
*/
public StaticTexture(final Image texture) {
this.texture = texture;
}
-
+
@Override
public Image getTexture(final long frame) {
return this.texture;
}
-
+
@Override
public void drawTexture(final long frame, final Graphics g, final int x, final int y, final int width, final int height) {
g.drawImage(this.texture, x, y, width, height, null);
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/StaticUiTextures.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/StaticUiTextures.java
index eeaaf0f67..de64140a8 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/StaticUiTextures.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/StaticUiTextures.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -19,7 +19,7 @@
* @version 1.0
*/
public abstract class StaticUiTextures {
-
+
/** A play icon */
public static String playIcon;
/** A step icon */
@@ -29,14 +29,14 @@ public abstract class StaticUiTextures {
/** A stop icon */
@Deprecated
public static String stopIcon;
-
+
/** A arrow icon */
public static String arrowIcon;
/** A add icon */
public static String addIcon;
/** A sub icon */
public static String subIcon;
-
+
/**
* This function loads all textures into the given texture registry and stores the icon ids
*
@@ -48,7 +48,7 @@ public static void load(final TextureRegistry registry) {
StaticUiTextures.stepIcon = registry.loadTextureFromResource("textures/step.png", TextureRegistry.class::getResourceAsStream);
StaticUiTextures.pauseIcon = registry.loadTextureFromResource("textures/pause.png", TextureRegistry.class::getResourceAsStream);
StaticUiTextures.stopIcon = registry.loadTextureFromResource("textures/stop.png", TextureRegistry.class::getResourceAsStream);
-
+
StaticUiTextures.arrowIcon = registry.loadTextureFromResource("textures/arrow.png", TextureRegistry.class::getResourceAsStream);
StaticUiTextures.addIcon = registry.loadTextureFromResource("textures/add.png", TextureRegistry.class::getResourceAsStream);
StaticUiTextures.subIcon = registry.loadTextureFromResource("textures/sub.png", TextureRegistry.class::getResourceAsStream);
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingConsole.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingConsole.java
index 71fd8abbb..3b588be2a 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingConsole.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingConsole.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -31,40 +31,40 @@
*/
public class SwingConsole extends JTextPane implements Console {
private static final long serialVersionUID = 5100186594058483257L;
-
+
private ConsoleBufferedOutputStream systemOutputStream;
private ConsoleBufferedOutputStream systemErrorStream;
-
+
/**
* Default constructor
*
* This should only be called from the swing ui thread
- *
+ *
* @param fontScale
* the scaling value for the fontSize
*/
public SwingConsole(final double fontScale) {
super(new DefaultStyledDocument());
-
+
final int fontSize = (int) Math.floor(12 * fontScale);
final Font standardFont = new Font("monospaced", Font.PLAIN, fontSize);
-
+
this.setEditable(false);
this.setFont(standardFont);
final DefaultCaret caret = (DefaultCaret) this.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
this.systemOutputStream = new ConsoleBufferedOutputStream(this, OutputStyle.STANDARD);
this.systemErrorStream = new ConsoleBufferedOutputStream(this, OutputStyle.ERROR);
-
+
Logger.addOutOutputStream(this.systemOutputStream);
Logger.addErrorOutputStream(this.systemErrorStream);
}
-
+
@Override
public void clearConsole() {
SwingUtilities.invokeLater(() -> this.setText(""));
}
-
+
/**
* Detach the internal output streams from {@code Logger.out} and {@code Logger.error}.
*/
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingEntityInspector.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingEntityInspector.java
index 83a25ed31..395bf4dd9 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingEntityInspector.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingEntityInspector.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -36,66 +36,66 @@
*/
public class SwingEntityInspector extends JPanel {
private static final long serialVersionUID = 1L;
-
+
private final GridBagConstraints gbc;
-
+
/** The name at the top */
private final JLabel title;
-
+
/** The JPanel containing all the ui elements */
private JPanel inspector;
-
+
/** The user warning at the bottom */
private final JLabel warning;
-
+
private Object updateLock = new Object();
private EntityInspectorEntry[] currentEntries;
private List> uiValueUpdaters;
-
+
/**
* Default constructor
*
* This should only be called from the swing ui thread
- *
+ *
* @param textureRegistry
* The texture registry to get the images from
*/
public SwingEntityInspector(final SwingTextureRegistry textureRegistry) {
this.setLayout(new BorderLayout());
-
+
this.title = new JLabel("Empty");
this.add(this.title, BorderLayout.PAGE_START);
-
+
this.inspector = new JPanel();
this.inspector.setLayout(new GridBagLayout());
this.add(this.inspector, BorderLayout.CENTER);
-
+
this.warning = new JLabel("Pause the simulation to modify an entity!");
this.warning.setVisible(false);
this.add(this.warning, BorderLayout.PAGE_END);
-
+
this.gbc = new GridBagConstraints();
this.gbc.fill = GridBagConstraints.HORIZONTAL;
this.gbc.gridx = 0;
this.gbc.gridy = 0;
-
+
this.setEnabled(false);
this.warning.setVisible(false);
}
-
+
/**
* Getter for the inspector name wich is displayed at the top
- *
+ *
* @return the name
*/
@Override
public String getName() {
return this.title.getText();
}
-
+
/**
* Setter for the inspector name
- *
+ *
* @param name
* The new name
*/
@@ -105,7 +105,7 @@ public void setName(final String name) {
this.title.setText(name);
return;
}
-
+
// cannot call invokeAndWait when already in EventDispatchThread!
try {
SwingUtilities.invokeAndWait(() -> {
@@ -115,7 +115,7 @@ public void setName(final String name) {
System.err.println("Failed to set entity inspector name because of: " + e.toString());
}
}
-
+
/**
* Update the entity inspector to reflect the new Values.
*
@@ -131,15 +131,15 @@ public void updateEntityInspectorEntries(final EntityInspectorEntry[] entries) {
List> valueUpdaters = this.uiValueUpdaters;
if (valueUpdaters == null) return; // TODO throw exeptions here?
if (valueUpdaters.size() != entries.length) return;
-
+
// update values
for (int i = 0; i < entries.length; i++) {
valueUpdaters.get(i).accept(entries[i].getValue());
}
-
+
// change to new entries list
this.currentEntries = entries;
-
+
// update ui
this.revalidate();
this.repaint();
@@ -147,39 +147,39 @@ public void updateEntityInspectorEntries(final EntityInspectorEntry[] entries) {
});
return;
}
-
+
// completely update the view
SwingUtilities.invokeLater(() -> {
synchronized (this.updateLock) {
// clear old elements first, then update current entries list
this.clearUIElements();
-
+
// change to new entries list
this.uiValueUpdaters = null;
this.currentEntries = entries; // only do this after clearing old elements
-
+
// add new ui elements
List> newUiValueUpdaters = new ArrayList<>(entries.length);
for (int i = 0; i < entries.length; i++) {
newUiValueUpdaters.add(this.addUIElement(entries[i], i));
}
-
+
// set new value updaters
this.uiValueUpdaters = newUiValueUpdaters;
-
+
// update ui
this.revalidate();
this.repaint();
}
});
}
-
+
/**
* Check if the new list of entries matches the current entries structurally.
*
* @param entries
* The ne list of entries to check against currentEntries
- *
+ *
* @return true iff only the values need to be updated
*/
private boolean canUpdateValuesOnly(final EntityInspectorEntry[] entries) {
@@ -194,13 +194,13 @@ private boolean canUpdateValuesOnly(final EntityInspectorEntry[] entries) {
}
return true;
}
-
+
/**
* Callback to change the value of an entry.
- *
+ *
* This indirect callback is used to avoid changing the callback on the ui element when only the values of the
* entries have changed.
- *
+ *
* @param index
* the index of the entry to update
* @param name
@@ -214,28 +214,28 @@ private void updateValueOnEntity(int index, String name, String value) {
if (!entry.getName().equals(name)) return;
entry.runCallback(value);
}
-
+
/**
* Add a entry to the ui editor
*
* This should only be run from the swing ui thread
- *
+ *
* @param entry
* The entry to add a ui element for
* @param index
* The index of the entry in currentEntries
- *
+ *
* @return A consumer that updates the newly added ui element to the given string value
*/
private Consumer addUIElement(final EntityInspectorEntry entry, final int index) {
-
+
final String name = entry.getName();
this.inspector.add(new JLabel(name + ": "), this.gbc);
this.gbc.gridx = 1;
-
+
Consumer updateUiValueCallback = (newValue) -> {
/* Default is to update nothing. */};
-
+
switch (entry.getType()) {
case "integer": {
final NumberFormatter formatter = new NumberFormatter(NumberFormat.getInstance());
@@ -276,13 +276,13 @@ private Consumer addUIElement(final EntityInspectorEntry entry, final in
updateUiValueCallback = (newValue) -> label.setText(newValue);
this.inspector.add(label, this.gbc);
}
-
+
this.gbc.gridx = 0;
this.gbc.gridy += 1;
-
+
return updateUiValueCallback;
}
-
+
/**
* Clears the entity editor
*
@@ -293,23 +293,23 @@ private void clearUIElements() {
this.inspector = new JPanel();
this.inspector.setLayout(new GridBagLayout());
this.add(this.inspector, BorderLayout.CENTER);
-
+
this.gbc.gridx = 0;
this.gbc.gridy = 0;
}
-
+
@Override
public void setEnabled(final boolean enabled) {
super.setEnabled(enabled);
-
+
this.title.setEnabled(enabled);
SwingEntityInspector.setEnabledState(this.inspector, enabled);
this.warning.setVisible(!enabled);
}
-
+
/**
* Recursive method to enable and disable a JPanel and its children
- *
+ *
* @param panel
* The panel to traverse
* @param state
@@ -317,7 +317,7 @@ public void setEnabled(final boolean enabled) {
*/
private static void setEnabledState(final JPanel panel, final boolean state) {
panel.setEnabled(state);
-
+
for (final Component component : panel.getComponents()) {
if (component instanceof JPanel) {
SwingEntityInspector.setEnabledState((JPanel) component, state);
@@ -325,7 +325,7 @@ private static void setEnabledState(final JPanel panel, final boolean state) {
component.setEnabled(state);
}
}
-
+
@Override
public Dimension getPreferredSize() {
return new Dimension(300, 300);
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingEntitySidebar.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingEntitySidebar.java
index 176b1b692..cd9757672 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingEntitySidebar.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingEntitySidebar.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -36,17 +36,17 @@
* A swing implementation of the EntitySidebar
*
* @author Tobias Wältken
- *
+ *
* @version 1.0
*/
public class SwingEntitySidebar extends JPanel implements EntitySidebar {
private static final long serialVersionUID = -4409545257025298208L;
-
+
/** The simulation proxy */
private SimulationProxy simulationProxy;
/** The texture registry */
private final SwingTextureRegistry textureRegistry;
-
+
/** The root node of the entity list */
private SimulationTreeNode rootNode;
/** The hierarchical list of all entities */
@@ -55,7 +55,7 @@ public class SwingEntitySidebar extends JPanel implements EntitySidebar {
private DefaultTreeModel entityListModel;
/** The entity inspector in the sidebar */
private SwingEntityInspector entityInspector;
-
+
/**
* The default constructor
*
@@ -69,7 +69,7 @@ public class SwingEntitySidebar extends JPanel implements EntitySidebar {
public SwingEntitySidebar(final SwingTextureRegistry textureRegistry, final double dpiScale) {
// class setup
this.textureRegistry = textureRegistry;
-
+
// JTree setup
this.entityListModel = new DefaultTreeModel(null, true);
this.entityList = new JTree(this.entityListModel);
@@ -84,7 +84,7 @@ public SwingEntitySidebar(final SwingTextureRegistry textureRegistry, final doub
}
return;
}
-
+
if (SwingEntitySidebar.this.simulationProxy != null) {
SwingEntitySidebar.this.simulationProxy.selectedSimulationEntityChange(
(SimulationTreeNode) ((DefaultMutableTreeNode) SwingEntitySidebar.this.entityList.getLastSelectedPathComponent())
@@ -92,22 +92,22 @@ public SwingEntitySidebar(final SwingTextureRegistry textureRegistry, final doub
);
}
});
-
+
// Entity inspector setup
this.entityInspector = new SwingEntityInspector(this.textureRegistry);
-
+
// Sidebar layout
final JScrollPane pane = new JScrollPane(this.entityList);
pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
-
+
final JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pane, this.entityInspector);
jsp.setOneTouchExpandable(true);
jsp.setResizeWeight(0.4);
this.setLayout(new BorderLayout());
this.add(jsp, BorderLayout.CENTER);
}
-
+
/**
* TODO better doc
*
@@ -116,10 +116,10 @@ public SwingEntitySidebar(final SwingTextureRegistry textureRegistry, final doub
*/
public void setSimulationProxy(final SimulationProxy simulationProxy) {
if (this.simulationProxy != null) throw new IllegalStateException("SimulationProxy is already set and cannot be overwritten!");
-
+
this.simulationProxy = simulationProxy;
}
-
+
@Override
public void setSimulationTreeRootNode(final SimulationTreeNode treeNode) {
SwingUtilities.invokeLater(() -> {
@@ -130,7 +130,7 @@ public void setSimulationTreeRootNode(final SimulationTreeNode treeNode) {
// The order of execution is still correct, because calls to invokeLater are processes in the order the calls happen.
this.updateSimulationTree();
}
-
+
private void getExpandedTreePaths(final List expanded, final TreePath path) {
if (path == null) return;
for (final Enumeration e = this.entityList.getExpandedDescendants(path); e.hasMoreElements();) {
@@ -139,18 +139,18 @@ private void getExpandedTreePaths(final List expanded, final TreePath
this.getExpandedTreePaths(expanded, p);
}
}
-
+
private TreePath getRootPath() {
final Object root = this.entityList.getModel().getRoot();
if (root == null) return null;
return new TreePath(root);
}
-
+
@Override
public void updateSimulationTree() {
SwingUtilities.invokeLater(this::updateSimulationTreeInternal);
}
-
+
/**
* Update the simulation tree model.
*
@@ -167,30 +167,30 @@ private void updateSimulationTreeInternal() {
this.entityList.expandPath(p);
}
}
-
+
@Override
public void setEnabled(final boolean enabled) {
super.setEnabled(enabled);
this.entityList.setEnabled(enabled);
}
-
+
@Override
public void setEntityInspectorEntries(final EntityInspectorEntry[] entries) {
this.entityInspector.updateEntityInspectorEntries(entries);
}
-
+
@Override
public Dimension getPreferredSize() {
return new Dimension(300, 800);
}
-
+
private static void updateTreeNodeChildren(final DefaultMutableTreeNode node) {
if ((node == null) || !node.getAllowsChildren()) return;
final SimulationTreeNode data = (SimulationTreeNode) node.getUserObject();
-
+
final List toRemove = new ArrayList<>();
final List toAdd = new ArrayList<>();
-
+
outer: for (final SimulationTreeNode child : data.getChildren()) {
for (final Enumeration e = node.children(); e.hasMoreElements();) {
final DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) e.nextElement();
@@ -200,7 +200,7 @@ private static void updateTreeNodeChildren(final DefaultMutableTreeNode node) {
}
toAdd.add(child);
}
-
+
outer: for (final Enumeration e = node.children(); e.hasMoreElements();) {
final DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) e.nextElement();
for (final SimulationTreeNode child : data.getChildren()) {
@@ -210,58 +210,59 @@ private static void updateTreeNodeChildren(final DefaultMutableTreeNode node) {
}
toRemove.add(childNode);
}
-
+
for (final DefaultMutableTreeNode child : toRemove) {
node.remove(child);
}
-
+
for (final SimulationTreeNode child : toAdd) {
node.add(SwingEntitySidebar.generateDefaultMutableTreeNodeFromSimulationTreeNode(child));
}
-
+
for (final Enumeration e = node.children(); e.hasMoreElements();) {
final DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) e.nextElement();
SwingEntitySidebar.updateTreeNodeChildren(childNode);
}
}
-
+
/**
* Recursively generate a {@link DefaultMutableTreeNode} from a {@link SimulationTreeNode}
*
* @param node
* The {@link SimulationTreeNode} the Tree structure is generated from
- *
+ *
* @return Returns the corresponding {@link DefaultMutableTreeNode}
*/
private static DefaultMutableTreeNode generateDefaultMutableTreeNodeFromSimulationTreeNode(final SimulationTreeNode node) {
final DefaultMutableTreeNode returnNode = new DefaultMutableTreeNode(node);
-
+
if (node.isLeaf()) {
returnNode.setAllowsChildren(false);
} else {
node.forEachChild(
- (final SimulationTreeNode childNode) -> returnNode.add(SwingEntitySidebar.generateDefaultMutableTreeNodeFromSimulationTreeNode(childNode))
+ (final SimulationTreeNode childNode) -> returnNode
+ .add(SwingEntitySidebar.generateDefaultMutableTreeNodeFromSimulationTreeNode(childNode))
);
}
-
+
return returnNode;
}
-
+
@Override
public SimulationTreeNode getSimulationTreeSelectedElement() {
return (SimulationTreeNode) ((DefaultMutableTreeNode) this.entityList.getLastSelectedPathComponent()).getUserObject();
}
-
+
@Override
public void setSimulationTreeSelectedElement(final SimulationTreeNode node) {
//TODO implement
}
-
+
@Override
public void enableSimulationTree() {
SwingUtilities.invokeLater(() -> this.entityList.setEnabled(true));
}
-
+
@Override
public void disbaleSimulationTree() {
SwingUtilities.invokeLater(() -> {
@@ -269,22 +270,22 @@ public void disbaleSimulationTree() {
this.entityListModel.setRoot(null);
});
}
-
+
@Override
public void setEntityInspectorName(final String name) {
SwingUtilities.invokeLater(() -> this.entityInspector.setName(name));
}
-
+
@Override
public String getEntityInspectorName() {
return this.entityInspector.getName();
}
-
+
@Override
public void enableEntityInspector() {
SwingUtilities.invokeLater(() -> this.entityInspector.setEnabled(true));
}
-
+
@Override
public void disableEntityInspector() {
SwingUtilities.invokeLater(() -> SwingEntitySidebar.this.entityInspector.setEnabled(false));
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingGameWindow.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingGameWindow.java
index 01bf69421..a43a27610 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingGameWindow.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingGameWindow.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -45,16 +45,16 @@
*/
public class SwingGameWindow extends JFrame implements GameWindow {
private static final long serialVersionUID = -7215617949088643819L;
-
+
private final SwingTextureRegistry textureRegistry;
private final SwingPlayfieldDrawer playfieldDrawer;
private final SwingToolbar toolbar;
private final SwingEntitySidebar entitySidebar;
private final SwingConsole console;
private final SwingTaskStatusDisplay taskStatus;
-
+
private SimulationProxy simulationProxy;
-
+
/**
* Create a new Swing game window using the given submodules.
*
@@ -83,7 +83,7 @@ public SwingGameWindow(
this.taskStatus = taskStatus;
SwingUtilities.invokeLater(this::initGameWindow);
}
-
+
@Override
public void setSimulationProxy(final SimulationProxy simulationProxy) {
// contains no direct calls to any swing ui method
@@ -93,55 +93,55 @@ public void setSimulationProxy(final SimulationProxy simulationProxy) {
this.entitySidebar.setSimulationProxy(simulationProxy);
this.taskStatus.setSimulationProxy(simulationProxy);
}
-
+
@Override
public TextureRegistry getTextureRegistry() {
return this.textureRegistry;
}
-
+
@Override
public PlayfieldDrawer getPlayfieldDrawer() {
return this.playfieldDrawer;
}
-
+
@Override
public Toolbar getToolbar() {
return this.toolbar;
}
-
+
@Override
public EntitySidebar getEntitySidebar() {
return this.entitySidebar;
}
-
+
@Override
public Console getConsole() {
return this.console;
}
-
+
@Override
public TaskStatusDisplay getTaskStatusDisplay() {
return this.taskStatus;
}
-
+
@Override
public void setWindowTitle(final String title) {
// UI operations must happen in swing thread!
SwingUtilities.invokeLater(() -> this.setTitle(title));
}
-
+
@Override
public void start() {
// Asynchronously set visible to true
SwingUtilities.invokeLater(() -> this.setVisible(true));
}
-
+
@Override
public void stop() {
// programmatically close the window
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
}
-
+
/**
* Initialize window listeners and layout all child components.
*
@@ -150,7 +150,7 @@ public void stop() {
@SuppressWarnings("unused") // Suppress unused warnings on 'ClassCastException e'
private void initGameWindow() {
// init jFrame
-
+
//
// setup window closing
//
@@ -161,9 +161,9 @@ public void windowClosing(final WindowEvent e) {
SwingGameWindow.this.cleanup(); // stop simulation etc.
}
});
-
+
this.playfieldDrawer.initialize();
-
+
//
// convert toolbar
//
@@ -173,7 +173,7 @@ public void windowClosing(final WindowEvent e) {
} catch (ClassCastException | NullPointerException e) {
toolbarComponent = new JLabel("Toolbar not valid!", UIManager.getIcon("OptionPane.warningIcon"), SwingConstants.CENTER);
}
-
+
//
// convert sidebar
//
@@ -183,7 +183,7 @@ public void windowClosing(final WindowEvent e) {
} catch (ClassCastException | NullPointerException e) {
sidebarComponent = new JLabel(UIManager.getIcon("OptionPane.warningIcon"), SwingConstants.CENTER);
}
-
+
//
// convert console
//
@@ -193,7 +193,7 @@ public void windowClosing(final WindowEvent e) {
} catch (NullPointerException e) {
consoleComponent = new JLabel("Console not valid!", UIManager.getIcon("OptionPane.warningIcon"), SwingConstants.CENTER);
}
-
+
//
// setup bottom pane layout
//
@@ -201,7 +201,7 @@ public void windowClosing(final WindowEvent e) {
bottomPane.addTab("Console", new JScrollPane(consoleComponent));
bottomPane.addTab("Task Status", this.taskStatus);
bottomPane.setPreferredSize(new Dimension(400, 200));
-
+
//
// setup JFrame layout
//
@@ -212,13 +212,13 @@ public void windowClosing(final WindowEvent e) {
final JSplitPane jsp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jsp1, sidebarComponent);
jsp2.setOneTouchExpandable(true);
this.getContentPane().add(BorderLayout.CENTER, jsp2);
-
+
//
// finalize jFrame
//
this.pack();
}
-
+
/**
* Clean up all resources used by this window and tell the simulation that the window is now closed.
*/
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingPlayfieldDrawer.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingPlayfieldDrawer.java
index 230800db6..03217ab0a 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingPlayfieldDrawer.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingPlayfieldDrawer.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -36,34 +36,34 @@
* @author Tim Neumann
*/
public class SwingPlayfieldDrawer extends JPanel implements PlayfieldDrawer {
-
+
/**
* generated
*/
private static final long serialVersionUID = 1800137555269066525L;
-
+
/** Stretch factor for mapping row/column coordinates to screen coordinates. */
private final double CELL_SIZE;
-
+
private final int INFO_BAR_HEIGHT;
-
+
// Colors
private static final Color BACKGROUND_COLOR = new Color(255, 255, 255);
private static final Color BACKGROUND_COLOR_TRANSPARENT = new Color(255, 255, 255, 230);
private static final Color GRID_COLOR = new Color(46, 52, 54);
private static final Color OVERLAY_COLOR = new Color(0, 40, 255, 50);
-
+
private static final RenderingHints RENDERING_HINTS = new RenderingHints(
RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON
);
-
+
private final SwingTextureRegistry textureRegistry;
-
+
// current display offset and zoom
private double offsetX;
private double offsetY;
private double scale = 1.0;
-
+
// mouse events
private boolean mouseInWindow = false;
private int currentMouseX = 0;
@@ -71,29 +71,29 @@ public class SwingPlayfieldDrawer extends JPanel implements PlayfieldDrawer {
private int mouseStartX = 0;
private int mouseStartY = 0;
private boolean isDrag = false;
-
+
// current tool state
private ControlButtonState activeTool = ControlButtonState.BLOCKED;
private String selectedEntityType = null;
private String selectedEntityTexture = null;
private SimulationProxy simulationProxy;
-
+
private List drawables = List.of();
private List animatedDrawables = List.of();
private boolean fullRepaintNeeded = true;
private Rectangle lastRedrawArea = null;
private long currentFrame = 0;
-
+
// current graphic settings
private final RepaintManager repaintManager;
private boolean useDoubleBuffer = true;
private boolean syncToscreen = true;
-
+
private double dpiScale;
-
+
private Font scaleFont;
private Font font;
-
+
/**
* Create a new SwingPlayfieldDrawer.
*
@@ -106,22 +106,22 @@ public class SwingPlayfieldDrawer extends JPanel implements PlayfieldDrawer {
*/
public SwingPlayfieldDrawer(final SwingTextureRegistry textureRegistry, final double dpiScale) {
this.textureRegistry = textureRegistry;
-
+
this.setOpaque(true);
this.repaintManager = RepaintManager.currentManager(this);
-
+
this.INFO_BAR_HEIGHT = (int) Math.floor(25 * dpiScale);
this.CELL_SIZE = (int) Math.floor(32 * dpiScale);
this.offsetX = this.CELL_SIZE;
this.offsetY = this.CELL_SIZE;
this.dpiScale = dpiScale;
-
+
Font font = this.getFont();
final int newFontSize = (int) Math.floor(12 * dpiScale * this.scale);
this.font = new Font(font.getFontName(), font.getStyle(), newFontSize);
this.setFont(this.font);
}
-
+
/**
* Set the simulation proxy. TODO better doc
*
@@ -130,63 +130,63 @@ public SwingPlayfieldDrawer(final SwingTextureRegistry textureRegistry, final do
*/
public void setSimulationProxy(final SimulationProxy simulationProxy) {
if (this.simulationProxy != null) throw new IllegalStateException("SimulationProxy is already set and cannot be overwritten!");
-
+
this.simulationProxy = simulationProxy;
}
-
+
/**
* Initialize the PlayfieldDrawer.
*
* This should only be called from the swing ui thread
*/
public void initialize() {
-
+
this.addMouseListener(new MouseListener() {
-
+
@Override
public void mouseReleased(final MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
SwingPlayfieldDrawer.this.mouseReleased(e.getX(), e.getY());
}
}
-
+
@Override
public void mousePressed(final MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
SwingPlayfieldDrawer.this.mousePressed(e.getX(), e.getY());
}
}
-
+
@Override
public void mouseExited(final MouseEvent e) {
SwingPlayfieldDrawer.this.updateMouseInWindow(false);
}
-
+
@Override
public void mouseEntered(final MouseEvent e) {
SwingPlayfieldDrawer.this.updateMouseInWindow(true);
}
-
+
@Override
public void mouseClicked(final MouseEvent e) {
// ignore this for now
}
});
-
+
this.addMouseMotionListener(new MouseMotionListener() {
-
+
@Override
public void mouseMoved(final MouseEvent e) {
SwingPlayfieldDrawer.this.updateMousePosition(e.getX(), e.getY());
}
-
+
@Override
public void mouseDragged(final MouseEvent e) {
SwingPlayfieldDrawer.this.updateDrag(e.getX(), e.getY());
SwingPlayfieldDrawer.this.updateMousePosition(e.getX(), e.getY());
}
});
-
+
this.addMouseWheelListener(e -> {
final int rot = e.getWheelRotation();
final int x = e.getX();
@@ -194,17 +194,17 @@ public void mouseDragged(final MouseEvent e) {
SwingPlayfieldDrawer.this.updateZoom(rot, x, y);
});
}
-
+
@Override
public void setDrawables(final List drawables) {
this.drawables = drawables.stream().sorted(Comparator.naturalOrder()).collect(Collectors.toUnmodifiableList());
- this.animatedDrawables = drawables.stream().filter(
- d -> d.isAnimated() || this.textureRegistry.isTextureAnimated(d.getTextureHandle())
- ).collect(Collectors.toUnmodifiableList());
+ this.animatedDrawables = drawables.stream()
+ .filter(d -> d.isAnimated() || this.textureRegistry.isTextureAnimated(d.getTextureHandle()))
+ .collect(Collectors.toUnmodifiableList());
this.fullRepaintNeeded = true;
this.draw(this.currentFrame);
}
-
+
@Override
public void draw(final long tickCount) {
this.currentFrame = tickCount;
@@ -212,16 +212,16 @@ public void draw(final long tickCount) {
if (this.animatedDrawables.size() > 0) {
this.drawables = this.drawables.stream().sorted(Comparator.naturalOrder()).collect(Collectors.toUnmodifiableList());
}
-
+
SwingUtilities.invokeLater(() -> {
// synchronize this to fix possible null pointer when setting double buffer setting
-
+
final boolean bufferEnabled = this.repaintManager.isDoubleBufferingEnabled();
if (!this.useDoubleBuffer) {
// only change strategy to false since true should already be default
this.repaintManager.setDoubleBufferingEnabled(this.useDoubleBuffer);
}
-
+
if (this.fullRepaintNeeded) {
Rectangle visible = this.getVisibleRect();
if (visible == null) {
@@ -234,9 +234,9 @@ public void draw(final long tickCount) {
final Rectangle visible = this.getVisibleRect();
final double cellSize = this.CELL_SIZE * this.scale;
final int textureSize = Math.toIntExact(Math.round(cellSize));
- final Optional rectToDraw = this.animatedDrawables.stream().map(
- d -> this.getScreenPointFromCellCoordinates(d.getX(), d.getY(), cellSize)
- ).map(p -> SwingPlayfieldDrawer.getPaintRectFromPoint(p, textureSize)).filter(r -> r.intersects(visible))
+ final Optional rectToDraw = this.animatedDrawables.stream()
+ .map(d -> this.getScreenPointFromCellCoordinates(d.getX(), d.getY(), cellSize))
+ .map(p -> SwingPlayfieldDrawer.getPaintRectFromPoint(p, textureSize)).filter(r -> r.intersects(visible))
.reduce((final Rectangle r1, final Rectangle r2) -> {
r1.add(r2);
return r1;
@@ -269,11 +269,11 @@ public void draw(final long tickCount) {
}
});
// filter out finished animations
- this.animatedDrawables = this.drawables.stream().filter(
- d -> d.isAnimated() || this.textureRegistry.isTextureAnimated(d.getTextureHandle())
- ).collect(Collectors.toUnmodifiableList());
+ this.animatedDrawables = this.drawables.stream()
+ .filter(d -> d.isAnimated() || this.textureRegistry.isTextureAnimated(d.getTextureHandle()))
+ .collect(Collectors.toUnmodifiableList());
}
-
+
@Override
public void resetZoomAndPan() {
this.scale = 1.0;
@@ -283,42 +283,42 @@ public void resetZoomAndPan() {
final int newFontSize = (int) Math.floor(12 * this.dpiScale * this.scale);
this.scaleFont = new Font(font.getFontName(), font.getStyle(), newFontSize);
}
-
+
@Override
public void setDoubleBuffering(final boolean useDoubleBuffering) {
this.useDoubleBuffer = useDoubleBuffering;
}
-
+
@Override
public void setSyncToScreen(final boolean syncToScreen) {
this.syncToscreen = syncToScreen;
}
-
+
@Override
public Dimension getPreferredSize() {
return new Dimension(800, 600);
}
-
+
private int getColumnCoordinateFromScreenCoordinate(final int screenX) {
final double cellSize = this.CELL_SIZE * this.scale;
return (int) Math.floor((screenX - this.offsetX) / cellSize);
}
-
+
private int getRowCoordinateFromScreenCoordinate(final int screenY) {
final double cellSize = this.CELL_SIZE * this.scale;
return (int) Math.floor((screenY - this.offsetY) / cellSize);
}
-
+
private Point getScreenPointFromCellCoordinates(final double x, final double y, final double cellSize) {
final int screenX = Math.toIntExact(Math.round((x * cellSize) + this.offsetX));
final int screenY = Math.toIntExact(Math.round((y * cellSize) + this.offsetY));
return new Point(screenX, screenY);
}
-
+
private static Rectangle getPaintRectFromPoint(final Point upperLeftCorner, final int cellSize) {
return new Rectangle(upperLeftCorner.x, upperLeftCorner.y, cellSize, cellSize);
}
-
+
@Override
public void paintComponent(final Graphics g) {
if (g instanceof Graphics2D) {
@@ -330,7 +330,7 @@ public void paintComponent(final Graphics g) {
this.paintDrawableList(g, this.drawables);
this.paintOverlay(g);
}
-
+
private void paintGrid(final Graphics g) {
final Rectangle clipBounds = g.getClipBounds();
// cell size on screen (with zoom)
@@ -339,7 +339,7 @@ private void paintGrid(final Graphics g) {
// to the top left corner of e cell on screen)
final double firstX = (Math.IEEEremainder(this.offsetX - clipBounds.x, cellSize) + clipBounds.x) - cellSize;
final double firstY = (Math.IEEEremainder(this.offsetY - clipBounds.y, cellSize) + clipBounds.y) - cellSize;
-
+
final int width = this.getWidth();
final int height = this.getHeight();
g.setColor(SwingPlayfieldDrawer.GRID_COLOR);
@@ -354,7 +354,7 @@ private void paintGrid(final Graphics g) {
g.drawLine(0, iy, width, iy);
}
}
-
+
/**
* Compare two drawables and checks if they can be grouped together.
*
@@ -375,14 +375,14 @@ private static boolean canGroupDrawables(final Drawable a, final Drawable b) {
if (Math.abs(a.getY() - b.getY()) > 0.001) return false;
return true;
}
-
+
private void paintDrawableList(final Graphics g, final List drawablesList) {
if (drawablesList.size() <= 0) return;
final Iterator iter = drawablesList.iterator();
Drawable last = null;
int currentCount = 0;
boolean isTilable = true;
-
+
// group and count drawables
while (iter.hasNext()) {
final Drawable next = iter.next();
@@ -402,7 +402,7 @@ private void paintDrawableList(final Graphics g, final List drawablesL
this.paintDrawable(g, last, currentCount + 1, isTilable);
}
}
-
+
private void paintDrawable(final Graphics g, final Drawable drawable, final int count, final boolean isTilable) {
final double cellSize = this.CELL_SIZE * this.scale;
final int x = Math.toIntExact(Math.round((drawable.getX() * cellSize) + this.offsetX));
@@ -429,7 +429,7 @@ private void paintDrawable(final Graphics g, final Drawable drawable, final int
final Double scaleAdjust = third;
this.paintMultiCountDrawable(g, drawable, count, xOffsets, yOffsets, scaleAdjust);
}
-
+
private void paintMultiCountDrawable(
final Graphics g, final Drawable drawable, final int count, final Double[] xOffsets, final Double[] yOffsets,
final Double scaleAdjust
@@ -456,7 +456,7 @@ private void paintMultiCountDrawable(
}
}
}
-
+
private void drawNumber(int count, Graphics g, int x, int y) {
final double cellSize = this.CELL_SIZE * this.scale;
g.setFont(this.scaleFont);
@@ -475,19 +475,19 @@ private void drawNumber(int count, Graphics g, int x, int y) {
g.drawString("" + count, x + xOffset, y + yOffset);
g.setFont(this.font);
}
-
+
private void paintOverlay(final Graphics g) {
final int width = this.getWidth();
final int height = this.getHeight();
-
+
final int currentCellX = this.getColumnCoordinateFromScreenCoordinate(this.currentMouseX);
final int currentCellY = this.getRowCoordinateFromScreenCoordinate(this.currentMouseY);
-
+
final double cellSize = this.CELL_SIZE * this.scale;
final int roundedCellSize = Math.toIntExact(Math.round(cellSize));
final int screenX = Math.toIntExact(Math.round(this.offsetX + (currentCellX * cellSize)));
final int screenY = Math.toIntExact(Math.round(this.offsetY + (currentCellY * cellSize)));
-
+
// draw cell highlight
if (this.mouseInWindow && g.hitClip(screenX, screenY, roundedCellSize, roundedCellSize)) {
// draw current tool texture
@@ -508,44 +508,44 @@ private void paintOverlay(final Graphics g) {
g.setColor(SwingPlayfieldDrawer.OVERLAY_COLOR);
g.fillRect(screenX, screenY, roundedCellSize, roundedCellSize);
}
-
+
// draw info bar
if (this.mouseInWindow && g.hitClip(0, height - this.INFO_BAR_HEIGHT, width, this.INFO_BAR_HEIGHT)) {
-
+
g.setColor(SwingPlayfieldDrawer.BACKGROUND_COLOR);
g.fillRect(0, height - this.INFO_BAR_HEIGHT, width, this.INFO_BAR_HEIGHT);
g.setColor(SwingPlayfieldDrawer.GRID_COLOR);
-
+
// calculate baseline
final FontMetrics font = g.getFontMetrics();
final int heightAboveBaseline = font.getAscent();
final int heightBelowBaseline = font.getMaxDescent();
final int baselineCentered = Math.toIntExact(Math.round((this.INFO_BAR_HEIGHT / 2.0) - (heightAboveBaseline / 2.0)));
final int baseline = height - Math.max(baselineCentered, heightBelowBaseline);
-
+
// build string
final String infoText = "Cell (x=" + currentCellX + ", y=" + currentCellY + ")";
g.drawString(infoText, 5, baseline);
-
+
}
}
-
+
private void mousePressed(final int screenX, final int screenY) {
this.mouseStartX = screenX;
this.mouseStartY = screenY;
this.isDrag = false;
}
-
+
private void mouseReleased(final int screenX, final int screenY) {
if (!this.isDrag) {
this.mouseClick(this.mouseStartX, this.mouseStartY);
}
}
-
+
private void mouseClick(final int screenX, final int screenY) {
final int x = this.getColumnCoordinateFromScreenCoordinate(screenX);
final int y = this.getRowCoordinateFromScreenCoordinate(screenY);
-
+
if (this.activeTool == ControlButtonState.ADD) {
final String type = this.selectedEntityType;
if ((type == null) || type.equals("")) {
@@ -569,12 +569,12 @@ private void mouseClick(final int screenX, final int screenY) {
}
this.repaint();
}
-
+
private void updateMouseInWindow(final boolean mouseInWindow) {
this.mouseInWindow = mouseInWindow;
this.repaintMouseOverlay();
}
-
+
private void updateMousePosition(final int x, final int y) {
final int oldX = this.currentMouseX;
final int oldY = this.currentMouseY;
@@ -583,18 +583,18 @@ private void updateMousePosition(final int x, final int y) {
this.repaintCellHighlight(oldX, oldY);
this.repaintMouseOverlay();
}
-
+
private void repaintMouseOverlay() {
this.repaintCellHighlight(this.currentMouseX, this.currentMouseY);
this.repaint(0, this.getHeight() - this.INFO_BAR_HEIGHT, this.getWidth(), this.INFO_BAR_HEIGHT);
}
-
+
private void repaintCellHighlight(final int x, final int y) {
final double cellSize = this.CELL_SIZE * this.scale;
final int roundedCellSize = Math.toIntExact(Math.round(cellSize));
this.repaint(x - roundedCellSize, y - roundedCellSize, 2 * roundedCellSize, 2 * roundedCellSize);
}
-
+
private void updateDrag(final int x, final int y) {
this.isDrag = true;
// TODO change this later to support different tools...
@@ -604,7 +604,7 @@ private void updateDrag(final int x, final int y) {
this.mouseStartY = y;
this.repaint();
}
-
+
private void updateZoom(final int amount, final int x, final int y) {
final double zoomScaling = 0.1 * Math.ceil(this.scale);
double newScale = this.scale + (zoomScaling * -amount);
@@ -622,18 +622,18 @@ private void updateZoom(final int amount, final int x, final int y) {
this.scale = newScale;
this.offsetX += dx;
this.offsetY += dy;
-
+
Font font = this.getFont();
final int newFontSize = (int) Math.floor(12 * this.dpiScale * this.scale);
this.scaleFont = new Font(font.getFontName(), font.getStyle(), newFontSize);
this.repaint();
}
-
+
@Override
public void setSelectedTool(final ControlButtonState selectedTool) {
this.activeTool = selectedTool;
}
-
+
@Override
public void setSelectedEntityType(final String typeName, final String textureHandle) {
this.selectedEntityType = typeName;
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingTaskStatusDisplay.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingTaskStatusDisplay.java
index 263add095..be56839c3 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingTaskStatusDisplay.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingTaskStatusDisplay.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -37,49 +37,49 @@
* @version 1.0
*/
public class SwingTaskStatusDisplay extends JPanel implements TaskStatusDisplay {
-
+
private static final long serialVersionUID = -2711911902591163118L;
-
+
private final JTextPane textPane;
-
+
private final Style textStyle;
private final Style taskTitle;
private final Style taskSuccess;
private final Style taskFail;
-
+
private SimulationProxy simulationProxy;
-
+
/**
* Default constructor.
*
* This should only be called from the swing ui thread
- *
+ *
* @param fontScale
* the scaling value for the fontSize
*/
public SwingTaskStatusDisplay(final double fontScale) {
super(new BorderLayout());
-
+
// setup text pane
this.textPane = new JTextPane(new DefaultStyledDocument());
this.textPane.setEditable(false);
((DefaultCaret) this.textPane.getCaret()).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
-
+
// setup text styles
final int fontSize = (int) Math.floor(12 * fontScale);
this.textStyle = this.textPane.addStyle("Text", null);
StyleConstants.setFontFamily(this.textStyle, "serif");
StyleConstants.setFontSize(this.textStyle, fontSize);
-
+
this.taskTitle = this.textPane.addStyle("TaskTitle", this.textStyle);
StyleConstants.setBold(this.taskTitle, true);
-
+
this.taskSuccess = this.textPane.addStyle("TaskSuccess", this.taskTitle);
this.taskFail = this.textPane.addStyle("TaskFail", this.taskTitle);
-
+
StyleConstants.setForeground(this.taskSuccess, Color.GREEN);
StyleConstants.setForeground(this.taskFail, Color.RED);
-
+
// setup refresh button
final JButton refreshButton = new JButton("Refresh");
refreshButton.addActionListener(ae -> {
@@ -87,12 +87,12 @@ public SwingTaskStatusDisplay(final double fontScale) {
this.simulationProxy.refreshTaskInformation();
}
});
-
+
// pack component
this.add(new JScrollPane(this.textPane), BorderLayout.CENTER);
this.add(refreshButton, BorderLayout.LINE_END);
}
-
+
/**
* Set the simulation proxy. TODO better doc
*
@@ -101,10 +101,10 @@ public SwingTaskStatusDisplay(final double fontScale) {
*/
public void setSimulationProxy(final SimulationProxy simulationProxy) {
if (this.simulationProxy != null) throw new IllegalStateException("SimulationProxy is already set and cannot be overwritten!");
-
+
this.simulationProxy = simulationProxy;
}
-
+
@Override
public void setTaskInformation(final TaskInformation task) {
// invoke later to break out of event thread of the refresh button press handler
@@ -119,10 +119,10 @@ public void setTaskInformation(final TaskInformation task) {
}
});
}
-
+
/**
* Appends the task information of the task and all subtasks to the styled document.
- *
+ *
* @param task
* the task information to add
* @param document
@@ -131,14 +131,14 @@ public void setTaskInformation(final TaskInformation task) {
* the current task depth (starts with 0, may be used to indent subtasks later)
*/
private void appendTaskInformation(final TaskInformation task, final StyledDocument document, final int depth) {
-
+
// append title
String title = task.getTaskTitle();
if (title == null || title.length() == 0) {
title = "Unnamed Task";
}
this.appendText(document, indentText(title, depth), this.taskTitle);
-
+
// append task status
switch (task.getTaskStatus()) {
case SUCCESSFUL:
@@ -151,13 +151,13 @@ private void appendTaskInformation(final TaskInformation task, final StyledDocum
default:
this.appendText(document, " (pending)\n", this.taskTitle);
}
-
+
// append description
final String description = task.getTaskDescription();
if (description != null && description.length() > 0) {
this.appendText(document, indentText(description + '\n', depth + 2), this.textStyle);
}
-
+
// handle subtasks
final List childTasks = task.getChildTasks();
if (childTasks != null) {
@@ -167,7 +167,7 @@ private void appendTaskInformation(final TaskInformation task, final StyledDocum
}
}
}
-
+
/**
* Appends text to a styled document while silently dismissing {@link BadLocationException}.
*
@@ -185,7 +185,7 @@ private void appendText(final StyledDocument document, final String text, final
e.printStackTrace();
}
}
-
+
/**
* This function appends indentation spaces to a string
*
@@ -197,21 +197,21 @@ private void appendText(final StyledDocument document, final String text, final
*/
private static String indentText(final String text, final int depth) {
if (depth == 0) return text;
-
+
StringBuilder returnString = new StringBuilder();
String indention = "\u2003".repeat(depth);
-
+
for (String s : text.split("\n")) {
returnString.append(indention);
returnString.append(s);
returnString.append('\n');
}
-
+
// Delete the final new line character if needed to prevent additional unwanted newlines in the result string
if (!text.endsWith("\n")) {
returnString.deleteCharAt(returnString.length() - 1);
}
-
+
return returnString.toString();
}
}
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingTextureRegistry.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingTextureRegistry.java
index a503e6f7a..b77ee3c9d 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingTextureRegistry.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingTextureRegistry.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -40,23 +40,23 @@ public class SwingTextureRegistry implements TextureRegistry {
private final Map pathToHandle = new HashMap<>();
private final Set animatedTextures = new HashSet<>();
private final Map handleToTexture = new HashMap<>();
-
+
/**
* Default constructor
*/
public SwingTextureRegistry() {
StaticUiTextures.load(this);
}
-
+
/**
* Generate a new unique texture handle.
- *
+ *
* @return uuid texture handle
*/
private static String generateNewTextureHandle() {
return UUID.randomUUID().toString();
}
-
+
/**
* Load a texture from a local (ui module) resource.
*
@@ -68,7 +68,7 @@ private static String generateNewTextureHandle() {
public String loadTextureFromResource(final String resourceName) {
return this.loadTextureFromResource(resourceName, SwingTextureRegistry.class::getResourceAsStream);
}
-
+
@Override
public String loadTextureFromResource(final String resourceName, final Function resourceProvider) {
if (this.resourceToHandle.containsKey(resourceName)) return this.resourceToHandle.get(resourceName);
@@ -82,7 +82,7 @@ public String loadTextureFromResource(final String resourceName, final Function<
throw new TextureNotFoundException("The requested Resource could not be loaded!", e);
}
}
-
+
@Override
public String loadTextureFromFile(final String filePath) {
final Path resolvedPath = Path.of(filePath).toAbsolutePath();
@@ -99,18 +99,18 @@ public String loadTextureFromFile(final String filePath) {
}
return textureHandle;
}
-
+
@Override
public String createAnimatedTexture(final boolean loop) {
final String textureHandle = SwingTextureRegistry.generateNewTextureHandle();
-
+
final AnimatedTexture animTexture = new AnimatedTexture(this, loop);
this.handleToTexture.put(textureHandle, animTexture);
this.animatedTextures.add(textureHandle);
-
+
return textureHandle;
}
-
+
@Override
public void addAnimationFrameToTexture(final String animatedTexture, final String frameTexture, final long frames) {
try {
@@ -120,12 +120,12 @@ public void addAnimationFrameToTexture(final String animatedTexture, final Strin
throw new IllegalArgumentException("Texture handle was not a handle for an animated texture!", e);
}
}
-
+
@Override
public boolean isTextureAnimated(final String textureHandle) {
return this.animatedTextures.contains(textureHandle);
}
-
+
/**
* Get the texture for the given texture handle.
*
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingToolbar.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingToolbar.java
index 1e531617e..453fd6bd8 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingToolbar.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/SwingToolbar.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -39,32 +39,32 @@
*/
public class SwingToolbar extends JToolBar implements Toolbar {
private static final long serialVersionUID = -2525998620577603876L;
-
+
/** The simulation proxy */
private SimulationProxy simulationProxy;
/** The texture registry */
private final SwingTextureRegistry textureRegistry;
-
+
/** The play button in the toolbar */
private JButton play;
/** The step button in the toolbar */
private JButton step;
/** The pause button in the toolbar */
private JButton pause;
-
+
/** A slider to set the simulation time */
private JSlider simulationTime;
-
+
/** The button to change to view mode */
private JToggleButton view;
/** The button to change to add mode */
private JToggleButton add;
/** The button to change to sub mode */
private JToggleButton sub;
-
+
/** The selector which selects the entity for the user to place */
private DropdownSelector entitySelect;
-
+
/**
* The constructor of the toolbar
*
@@ -80,12 +80,12 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi
// class setup
//
this.textureRegistry = textureRegistry;
-
+
//
// toolbar setup
//
this.setFloatable(false);
-
+
//
// play button setup
//
@@ -97,7 +97,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi
});
this.play.setEnabled(false);
this.add(this.play);
-
+
//
// step button setup
//
@@ -109,7 +109,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi
});
this.step.setEnabled(false);
this.add(this.step);
-
+
//
// pause button setup
//
@@ -121,7 +121,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi
});
this.pause.setEnabled(false);
this.add(this.pause);
-
+
//
// simulation time slider setup
//
@@ -142,7 +142,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi
// setup change listener
this.simulationTime.addChangeListener(event -> {
final JSlider source = (JSlider) event.getSource();
-
+
if (!source.getValueIsAdjusting()) {
if (this.simulationProxy != null) {
this.simulationProxy.simulationSpeedChange(source.getValue());
@@ -152,12 +152,12 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi
this.simulationTime.setEnabled(false);
this.add(this.simulationTime);
this.addSeparator();
-
+
//
// add visual separator
//
this.add(new JSeparator(SwingConstants.VERTICAL));
-
+
//
// view button setup
//
@@ -169,7 +169,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi
});
this.view.setEnabled(false);
this.add(this.view);
-
+
//
// add button setup
//
@@ -181,7 +181,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi
});
this.add.setEnabled(false);
this.add(this.add);
-
+
//
// sub button setup
//
@@ -193,7 +193,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi
});
this.sub.setEnabled(false);
this.add(this.sub);
-
+
//
// entity selector setup
//
@@ -209,7 +209,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi
this.entitySelect.setEnabled(false);
this.add(this.entitySelect);
}
-
+
/**
*
* @param simulationProxy
@@ -217,17 +217,17 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi
*/
public void setSimulationProxy(final SimulationProxy simulationProxy) {
if (this.simulationProxy != null) throw new IllegalStateException("SimulationProxy is already set and cannot be overwritten!");
-
+
this.simulationProxy = simulationProxy;
}
-
+
@Override
public void addEntity(final String displayName, final String textureID) {
SwingUtilities.invokeLater(() -> {
this.entitySelect.addEntry(this.entitySelect.new DropdownEntry(displayName, textureID));
});
}
-
+
private void setControlButtonStateInternal(final ControlButtonState controlButtonState) {
switch (controlButtonState) {
case VIEW:
@@ -235,34 +235,34 @@ private void setControlButtonStateInternal(final ControlButtonState controlButto
this.add.setEnabled(true);
this.sub.setEnabled(true);
break;
-
+
case ADD:
this.view.setEnabled(true);
this.add.setEnabled(false);
this.sub.setEnabled(true);
break;
-
+
case SUB:
this.view.setEnabled(true);
this.add.setEnabled(true);
this.sub.setEnabled(false);
break;
-
+
case BLOCKED:
this.view.setEnabled(false);
this.add.setEnabled(false);
this.sub.setEnabled(false);
break;
-
+
default:
}
}
-
+
@Override
public void setControlButtonState(final ControlButtonState controlButtonState) {
SwingUtilities.invokeLater(() -> this.setControlButtonStateInternal(controlButtonState));
}
-
+
private void setClockButtonStateInternal(final ClockButtonState clockButtonState) {
switch (clockButtonState) {
case PLAYING:
@@ -286,17 +286,17 @@ private void setClockButtonStateInternal(final ClockButtonState clockButtonState
default:
}
}
-
+
@Override
public void setClockButtonState(final ClockButtonState clockButtonState) {
SwingUtilities.invokeLater(() -> this.setClockButtonStateInternal(clockButtonState));
}
-
+
@Override
public int getSpeedSliderPosition() {
return this.simulationTime.getValue();
}
-
+
@Override
public void setSpeedSliderPosition(final int position) {
if (
@@ -306,28 +306,28 @@ public void setSpeedSliderPosition(final int position) {
);
SwingUtilities.invokeLater(() -> this.simulationTime.setValue(position));
}
-
+
@Override
public String getCurrentlySelectedEntity() {
final DropdownEntry currentEntry = this.entitySelect.getCurrentEntry();
if (currentEntry == null) return "";
return currentEntry.displayName;
}
-
+
@Override
public void setCurrentlySelectedEntity(final String entity) {
SwingUtilities.invokeLater(() -> {
this.entitySelect.setCurrentEntry(this.entitySelect.new DropdownEntry(entity));
});
}
-
+
@Override
public void enableEntitySelector() {
SwingUtilities.invokeLater(() -> {
this.entitySelect.setEnabled(true);
});
}
-
+
@Override
public void disableEntitySelector() {
SwingUtilities.invokeLater(() -> {
@@ -335,5 +335,5 @@ public void disableEntitySelector() {
this.entitySelect.setEnabled(false);
});
}
-
+
}
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/Texture.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/Texture.java
index 36a0c3083..73e5cc517 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/Texture.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/Texture.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -15,34 +15,34 @@
/**
* Class containing a texture image and methods to draw this image.
- *
+ *
* @author Fabian Bühler
*/
public interface Texture {
-
+
/**
* Get the texture image.
- *
+ *
* @return the image
*/
default Image getTexture() {
return this.getTexture(0);
}
-
+
/**
* Get the texture image.
- *
+ *
* @param frame
* the current frame number
* @return the image
*/
Image getTexture(long frame);
-
+
/**
* Draw the texture onto the screen.
*
* This method should only be called from the swing ui thread.
- *
+ *
* @param frame
* the current frame number
* @param g
@@ -57,12 +57,12 @@ default Image getTexture() {
default void drawTexture(final long frame, final Graphics g, final int x, final int y, final int size) {
this.drawTexture(frame, g, x, y, size, size);
}
-
+
/**
* Draw the texture onto the screen.
*
* This method should only be called from the swing ui thread.
- *
+ *
* @param frame
* the current frame number
* @param g
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/dropdown/DropdownItemEditor.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/dropdown/DropdownItemEditor.java
index 361a68762..93cc766c2 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/dropdown/DropdownItemEditor.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/dropdown/DropdownItemEditor.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -32,14 +32,14 @@
* @version 1.0
*/
class DropdownItemEditor extends BasicComboBoxEditor {
-
+
/** The texture registry */
private final SwingTextureRegistry textureRegistry;
-
+
private final JPanel panel;
private final JLabel labelItem;
private DropdownEntry selectedValue;
-
+
/**
* Constructor for the DropdownItemEditor
*
@@ -50,7 +50,7 @@ class DropdownItemEditor extends BasicComboBoxEditor {
*/
public DropdownItemEditor(final SwingTextureRegistry textureRegistry) {
this.textureRegistry = textureRegistry;
-
+
this.panel = new JPanel();
this.panel.setBackground(Color.BLUE);
this.panel.setLayout(new GridBagLayout());
@@ -58,32 +58,32 @@ public DropdownItemEditor(final SwingTextureRegistry textureRegistry) {
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weightx = 1.0;
constraints.insets = new Insets(2, 5, 2, 2);
-
+
this.labelItem = new JLabel();
this.labelItem.setOpaque(false);
this.labelItem.setHorizontalAlignment(SwingConstants.LEFT);
this.labelItem.setForeground(Color.WHITE);
-
+
this.panel.add(this.labelItem, constraints);
}
-
+
@Override
public Component getEditorComponent() {
return this.panel;
}
-
+
@Override
public Object getItem() {
return this.selectedValue;
}
-
+
@Override
public void setItem(final Object item) {
if (item == null) return;
-
+
this.selectedValue = (DropdownEntry) item;
this.labelItem.setText(this.selectedValue.displayName);
-
+
if (!this.selectedValue.textureID.equals("")) {
this.labelItem.setIcon(new ImageIcon(this.textureRegistry.getTextureForHandle(this.selectedValue.textureID).getTexture()));
}
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/dropdown/DropdownItemRenderer.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/dropdown/DropdownItemRenderer.java
index d289f5b08..2a085d0a5 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/dropdown/DropdownItemRenderer.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/dropdown/DropdownItemRenderer.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -34,12 +34,12 @@
*/
class DropdownItemRenderer extends JPanel implements ListCellRenderer {
private static final long serialVersionUID = 2930839533138981414L;
-
+
/** The texture registry */
private final SwingTextureRegistry textureRegistry;
-
+
private final JLabel labelItem;
-
+
/**
* Constructor for the DropdownItemRenderer
*
@@ -50,21 +50,21 @@ class DropdownItemRenderer extends JPanel implements ListCellRenderer list, final DropdownEntry value, final int index, final boolean isSelected,
@@ -74,12 +74,12 @@ public Component getListCellRendererComponent(
this.labelItem.setText("∅");
} else {
this.labelItem.setText(value.displayName);
-
+
if (!value.textureID.equals("")) {
this.labelItem.setIcon(new ImageIcon(this.textureRegistry.getTextureForHandle(value.textureID).getTexture()));
}
}
-
+
return this;
}
}
diff --git a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/dropdown/DropdownSelector.java b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/dropdown/DropdownSelector.java
index 6a2183e3f..1d1f49312 100644
--- a/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/dropdown/DropdownSelector.java
+++ b/ICGE-Ui/src/main/java/de/unistuttgart/informatik/fius/icge/ui/internal/dropdown/DropdownSelector.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -28,7 +28,7 @@
*/
public class DropdownSelector extends JPanel {
private static final long serialVersionUID = -3898035206502504991L;
-
+
/**
* This class represents a single entry of the selector
*
@@ -40,7 +40,7 @@ public class DropdownEntry {
public String displayName;
/** The texture id of the icon which is rendert infront of the display name */
public String textureID;
-
+
/**
* The empty constructor
*/
@@ -48,7 +48,7 @@ public DropdownEntry() {
this.displayName = "";
this.textureID = "";
}
-
+
/**
* This constructor is used for text only entries
*
@@ -59,7 +59,7 @@ public DropdownEntry(final String name) {
this.displayName = name;
this.textureID = "";
}
-
+
/**
* The default constructor
*
@@ -73,16 +73,16 @@ public DropdownEntry(final String name, final String texture) {
this.textureID = texture;
}
}
-
+
/** The texture registry */
private final SwingTextureRegistry textureRegistry;
-
+
private final JLabel label;
private final JComboBox comboBox;
-
+
/** The data model of the DropdownSelector */
private final DefaultComboBoxModel model;
-
+
/**
* Constructor of the DropdownSelector
*
@@ -95,20 +95,20 @@ public DropdownEntry(final String name, final String texture) {
*/
public DropdownSelector(final SwingTextureRegistry textureRegistry, final String header) {
this.textureRegistry = textureRegistry;
-
+
this.label = new JLabel(header + ": ");
this.comboBox = new JComboBox<>();
-
+
this.model = new DefaultComboBoxModel<>();
this.comboBox.setModel(this.model);
this.comboBox.setRenderer(new DropdownItemRenderer(this.textureRegistry));
this.comboBox.setEditor(new DropdownItemEditor(this.textureRegistry));
-
+
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.add(this.label);
this.add(this.comboBox);
}
-
+
/**
* Getter for the currently selected entry
*
@@ -117,21 +117,21 @@ public DropdownSelector(final SwingTextureRegistry textureRegistry, final String
public DropdownEntry getCurrentEntry() {
return (DropdownEntry) this.comboBox.getEditor().getItem();
}
-
+
/**
* Setter for the currently selected entry
*
* This should only be called from the swing ui thread
*
* WARNING: This is not checked if it is available it can be ANY entry
- *
+ *
* @param entry
* The entry to set as selected
*/
public void setCurrentEntry(final DropdownEntry entry) {
this.comboBox.getEditor().setItem(entry);
}
-
+
/**
* This function adds an entry to the selector
*
@@ -143,13 +143,13 @@ public void setCurrentEntry(final DropdownEntry entry) {
public void addEntry(final DropdownEntry... entries) {
for (final DropdownEntry entry : entries) {
this.model.addElement(entry);
-
+
if (getCurrentEntry() == null) {
this.setCurrentEntry(entry);
}
}
}
-
+
/**
* This function removes all entries from the dropdown menu
*
@@ -158,19 +158,19 @@ public void addEntry(final DropdownEntry... entries) {
public void removeAllEntries() {
this.model.removeAllElements();
}
-
+
/**
* Adds a listener which reacts to the selection and deselection of items
*
* This should only be called from the swing ui thread
- *
+ *
* @param listener
* The listener which is added
*/
public void addSelectionListener(final ItemListener listener) {
this.comboBox.addItemListener(listener);
}
-
+
@Override
public void setEnabled(final boolean enabled) {
super.setEnabled(enabled);
diff --git a/ICGE-Ui/src/main/java/module-info.java b/ICGE-Ui/src/main/java/module-info.java
index 40ec1025d..2c89b3efa 100644
--- a/ICGE-Ui/src/main/java/module-info.java
+++ b/ICGE-Ui/src/main/java/module-info.java
@@ -1,16 +1,16 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
module de.unistuttgart.informatik.fius.icge.ui {
requires java.desktop;
requires de.unistuttgart.informatik.fius.icge.log;
-
+
exports de.unistuttgart.informatik.fius.icge.ui;
exports de.unistuttgart.informatik.fius.icge.ui.exception;
}
diff --git a/ICGE-Ui/src/test/java/de/unistuttgart/informatik/fius/icge/ui/SwingGameWindowUiTest.java b/ICGE-Ui/src/test/java/de/unistuttgart/informatik/fius/icge/ui/SwingGameWindowUiTest.java
index 015a8ffc6..336a8e855 100644
--- a/ICGE-Ui/src/test/java/de/unistuttgart/informatik/fius/icge/ui/SwingGameWindowUiTest.java
+++ b/ICGE-Ui/src/test/java/de/unistuttgart/informatik/fius/icge/ui/SwingGameWindowUiTest.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -33,12 +33,12 @@
* @author Tim Neumann
*/
class SwingGameWindowUiTest {
-
+
private SwingGameWindow window;
-
+
/**
* Setup the game window
- *
+ *
* @throws Exception
* When anything goes wrong
*/
@@ -51,11 +51,11 @@ public void setup() throws Exception {
final SwingEntitySidebar entitySidebar = new SwingEntitySidebar(textureRegistry, 1);
final SwingConsole console = new SwingConsole(1);
final SwingTaskStatusDisplay taskStatus = new SwingTaskStatusDisplay(1);
-
+
this.window = new SwingGameWindow(textureRegistry, playfieldDrawer, toolbar, entitySidebar, console, taskStatus);
});
}
-
+
/**
* Test {@link SwingGameWindow#start()}
*/
diff --git a/ICGE-archetype-module/pom.xml b/ICGE-archetype-module/pom.xml
index 3c2062ac3..09657aee4 100644
--- a/ICGE-archetype-module/pom.xml
+++ b/ICGE-archetype-module/pom.xml
@@ -2,7 +2,7 @@
4.0.0
de.uni-stuttgart.informatik.fius
- ICGE-archetype-module
+ icge-archetype-module
1.0.0
Archetype for FIUS ICGE Modules
http://maven.apache.org
diff --git a/ICGE-archetype-module/src/main/resources/archetype-resources/src/main/java/module-info.java b/ICGE-archetype-module/src/main/resources/archetype-resources/src/main/java/module-info.java
index fb954f885..fa19f3d93 100644
--- a/ICGE-archetype-module/src/main/resources/archetype-resources/src/main/java/module-info.java
+++ b/ICGE-archetype-module/src/main/resources/archetype-resources/src/main/java/module-info.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
diff --git a/ICGE-build-tools/pom.xml b/ICGE-build-tools/pom.xml
index 4fed6e481..635c17682 100644
--- a/ICGE-build-tools/pom.xml
+++ b/ICGE-build-tools/pom.xml
@@ -3,9 +3,9 @@
4.0.0
de.uni-stuttgart.informatik.fius
- ICGE
- 2.3.9-Snapshot
+ icge
+ 2.3.8
- ICGE-build-tools
+ icge-build-tools
ICGE build tools
diff --git a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/Main.java b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/Main.java
index 625433f85..475a208cf 100644
--- a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/Main.java
+++ b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/Main.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -18,7 +18,7 @@
/**
* Main class of the example
- *
+ *
* @author Tim Neumann
*/
public class Main {
diff --git a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/Texture.java b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/Texture.java
index dddd1129f..2bbbccef6 100644
--- a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/Texture.java
+++ b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/Texture.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,7 +16,7 @@
/**
* The enum for all builtin mario textures.
- *
+ *
* @author Tim Neumann
*/
public enum Texture {
diff --git a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/WalkingProgram.java b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/WalkingProgram.java
index 68c650677..54959e0f7 100644
--- a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/WalkingProgram.java
+++ b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/WalkingProgram.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -18,7 +18,7 @@
/**
* A program walking around mario a bit
- *
+ *
* @author Tim Neumann
*/
public class WalkingProgram extends MarioProgram {
diff --git a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/Coin.java b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/Coin.java
index fb4eb9ed1..fd60522b7 100644
--- a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/Coin.java
+++ b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/Coin.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,7 +16,7 @@
/**
* A coin
- *
+ *
* @author Tim Neumann
*/
public class Coin extends BasicEntity implements CollectableEntity {
diff --git a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/Mario.java b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/Mario.java
index 0fe7b6a9f..a76dfa84a 100644
--- a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/Mario.java
+++ b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/Mario.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -15,7 +15,7 @@
/**
* The mario entity
- *
+ *
* @author Tim Neumann
*/
public class Mario extends GreedyEntity {
diff --git a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/MarioProgram.java b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/MarioProgram.java
index 5b8963498..769704d08 100644
--- a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/MarioProgram.java
+++ b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/MarioProgram.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -15,7 +15,7 @@
/**
* A program for mario
- *
+ *
* @author Tim Neumann
*/
public abstract class MarioProgram implements EntityProgram {
diff --git a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/Wall.java b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/Wall.java
index f72ff14fe..6f2d69e8a 100644
--- a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/Wall.java
+++ b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/entity/Wall.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -16,7 +16,7 @@
/**
* The wall entity
- *
+ *
* @author Tim Neumann
*/
public class Wall extends BasicEntity implements SolidEntity {
diff --git a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Solution1.java b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Solution1.java
index bc2afe957..4cefb66d8 100644
--- a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Solution1.java
+++ b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Solution1.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -14,7 +14,7 @@
/**
* The example solution for Task1
- *
+ *
* @author Tim Neumann
*/
public class Solution1 extends Task1 {
diff --git a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Solution2.java b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Solution2.java
index c265a1a89..0985546bc 100644
--- a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Solution2.java
+++ b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Solution2.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -11,7 +11,7 @@
/**
* The solution for {@link Task2}
- *
+ *
* @author Tim Neumann
*/
public class Solution2 extends Task2 {
diff --git a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Task1.java b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Task1.java
index 06d8ab747..28f02600d 100644
--- a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Task1.java
+++ b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Task1.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -19,7 +19,7 @@
/**
* An example task
- *
+ *
* @author Tim Neumann
*/
public abstract class Task1 implements Task {
diff --git a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Task2.java b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Task2.java
index 477c1f62e..3d5dd17c1 100644
--- a/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Task2.java
+++ b/examples/mario/src/main/java/de/unistuttgart/informatik/fius/icge/example/mario/tasks/Task2.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
@@ -22,7 +22,7 @@
/**
* The Task 2
- *
+ *
* @author Tim Neumann
*/
public abstract class Task2 implements Task {
diff --git a/examples/mario/src/main/java/module-info.java b/examples/mario/src/main/java/module-info.java
index 8a83c363e..2ea432c61 100644
--- a/examples/mario/src/main/java/module-info.java
+++ b/examples/mario/src/main/java/module-info.java
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/
diff --git a/pom.xml b/pom.xml
index 1899269b6..c0c896f3e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,18 +2,20 @@
4.0.0
de.uni-stuttgart.informatik.fius
- ICGE
- 2.3.9-Snapshot
+ icge
+ 2.3.8
Introduction Course Game Engine
The game engine for the java intoduction course of FIUS
- https://fius.github.io/ICGE2
+ https://fius.github.io/icge2
pom
11
5.3.1
1.1.0
- 2.3.9-Snapshot
+ 2.3.8
UTF-8
+ ICGE2
+ project.groupId
@@ -30,8 +32,8 @@
maven-surefire-plugin
2.19.1
-
+
**/Test*.java
@@ -63,10 +65,24 @@
maven-deploy-plugin
- 2.8.2
+ 3.1.1
- true
+ ${project.artifactId}
+ ${project.groupId}
+ ${icge.version}
+ false
+
+
+ deploy-executable
+
+ deploy-file
+
+
+ target/*.jar
+
+
+
org.apache.maven.plugins
@@ -84,7 +100,7 @@
net.revelc.code.formatter
formatter-maven-plugin
- 2.10.0
+ 2.23.0
LF
build_tools/eclipse/ICGE-Formatter.xml
@@ -96,7 +112,7 @@
de.uni-stuttgart.informatik.fius
- ICGE-build-tools
+ icge-build-tools
${icge.version}
@@ -114,17 +130,17 @@
de.uni-stuttgart.informatik.fius
- ICGE-Ui
+ icge-ui
${icge.version}
de.uni-stuttgart.informatik.fius
- ICGE-Simulation
+ icge-simulation
${icge.version}
de.uni-stuttgart.informatik.fius
- ICGE-Log
+ icge-log
${icge.version}
@@ -132,15 +148,14 @@
github
- GitHub fius Apache Maven Packages
https://maven.pkg.github.com/FIUS/ICGE2
+ ICGE-Log
ICGE-Ui
ICGE-Simulation
ICGE-ManualStart
- ICGE-Log
ICGE-build-tools
diff --git a/scriptsAndTools/Unbenanntes Dokument b/scriptsAndTools/Unbenanntes Dokument
new file mode 100644
index 000000000..124c5b3ce
--- /dev/null
+++ b/scriptsAndTools/Unbenanntes Dokument
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+
+# This script fixes all java file comments
+# No arguments allowed
+
+dir="$(dirname "$(realpath "$0")")"
+
+function fail {
+ echo $1
+ exit $2
+}
+
+if [ $# -ne 0 ] ; then
+ fail "No argument expected" 2
+fi
+
+script="$dir/internalOrCiOnly/fixSingleJavaFileComment.sh"
+
+correctHeaderFile="$dir/correctJavaFileHeader.txt"
+
+#Fix all headers
+javaFiles=$($dir/checkJavaFileComments.sh | grep -o "\..*\.java")
+for file in $javaFiles
+do
+ echo "fixing $dir$file"
+ cat $correctHeaderFile $file > $file
+done
diff --git a/scriptsAndTools/correctJavaFileComment.txt b/scriptsAndTools/correctJavaFileComment.txt
index 5e1654e54..a7722c026 100644
--- a/scriptsAndTools/correctJavaFileComment.txt
+++ b/scriptsAndTools/correctJavaFileComment.txt
@@ -1,9 +1,9 @@
/*
* This source file is part of the FIUS ICGE project.
* For more information see github.com/FIUS/ICGE2
- *
+ *
* Copyright (c) 2019 the ICGE project authors.
- *
+ *
* This software is available under the MIT license.
* SPDX-License-Identifier: MIT
*/