diff --git a/ICGE-Log/src/main/java/de/unistuttgart/informatik/fius/icge/log/Logger.java b/ICGE-Log/src/main/java/de/unistuttgart/informatik/fius/icge/log/Logger.java index d9377281d..388697dd9 100644 --- a/ICGE-Log/src/main/java/de/unistuttgart/informatik/fius/icge/log/Logger.java +++ b/ICGE-Log/src/main/java/de/unistuttgart/informatik/fius/icge/log/Logger.java @@ -9,8 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.log; +* + import java.io.OutputStream; -import java.io.PrintStream; +import java.io.PrintStream;** /** @@ -23,27 +25,25 @@ * @version 2.0 */ public abstract class Logger { - + * /** The main logger printing to {@link System#out} */ - public static PrintStream out; + public static PrintStream out; /** The error logger printing to {@link System#err} */ - public static PrintStream error; - + public static PrintStream error;* private static OutputStreamMultiplier outStream; - private static OutputStreamMultiplier errorStream; - + private static OutputStreamMultiplier errorStream;* // This block intercepts {@link System.out} and {@link System.err} static { Logger.outStream = new OutputStreamMultiplier(); Logger.outStream.addOutputStream(System.out); Logger.out = new PrintStream(Logger.outStream); System.setOut(Logger.out); - + * Logger.errorStream = new OutputStreamMultiplier(); Logger.errorStream.addOutputStream(System.err); Logger.error = new PrintStream(Logger.errorStream); System.setErr(Logger.error); - } + }* /** * Function to add a {@link OutputStream} to the out logger @@ -55,7 +55,7 @@ public abstract class Logger { */ public static boolean addOutOutputStream(final OutputStream stream) { return Logger.outStream.addOutputStream(stream); - } + }* /** * Function to remove a {@link OutputStream} from the out logger @@ -67,7 +67,7 @@ public static boolean addOutOutputStream(final OutputStream stream) { */ public static boolean removeOutOutputStream(final OutputStream stream) { return Logger.outStream.removeOutputStream(stream); - } + }* /** * Clears the out OutputStreams @@ -76,7 +76,7 @@ public static boolean removeOutOutputStream(final OutputStream stream) { */ public static void clearOutOutputStream() { Logger.outStream.clearOutputStreams(); - } + }* /** * Function to add a {@link OutputStream} to the error logger @@ -88,7 +88,7 @@ public static void clearOutOutputStream() { */ public static boolean addErrorOutputStream(final OutputStream stream) { return Logger.errorStream.addOutputStream(stream); - } + }* /** * Function to remove a {@link OutputStream} from the error logger @@ -100,7 +100,7 @@ public static boolean addErrorOutputStream(final OutputStream stream) { */ public static boolean removeErrorOutputStream(final OutputStream stream) { return Logger.errorStream.removeOutputStream(stream); - } + }* /** * Clears the error OutputStreams diff --git a/ICGE-Log/src/main/java/de/unistuttgart/informatik/fius/icge/log/OutputStreamMultiplier.java b/ICGE-Log/src/main/java/de/unistuttgart/informatik/fius/icge/log/OutputStreamMultiplier.java index c7c7dc155..678bf3efa 100644 --- a/ICGE-Log/src/main/java/de/unistuttgart/informatik/fius/icge/log/OutputStreamMultiplier.java +++ b/ICGE-Log/src/main/java/de/unistuttgart/informatik/fius/icge/log/OutputStreamMultiplier.java @@ -9,9 +9,11 @@ */ package de.unistuttgart.informatik.fius.icge.log; +* + import java.io.IOException; import java.io.OutputStream; -import java.util.ArrayList; +import java.util.ArrayList;** /** @@ -21,15 +23,15 @@ * @version 1.0 */ public class OutputStreamMultiplier extends OutputStream { - - private final ArrayList listenerStreams; + * + private final ArrayList listenerStreams;* /** * Default Constructor */ public OutputStreamMultiplier() { this.listenerStreams = new ArrayList<>(); - } + }* /** * Add a output stream to also recieve everything this stream recieves @@ -40,7 +42,7 @@ public OutputStreamMultiplier() { */ public boolean addOutputStream(final OutputStream listenerStream) { return this.listenerStreams.add(listenerStream); - } + }* /** * Remove a output stream from recieving everything this stream recieves @@ -51,30 +53,30 @@ public boolean addOutputStream(final OutputStream listenerStream) { */ public boolean removeOutputStream(final OutputStream listenerStream) { return this.listenerStreams.remove(listenerStream); - } + }* /** * Clears all connected output streams */ public void clearOutputStreams() { this.listenerStreams.clear(); - } + }* @Override public void flush() throws IOException { super.flush(); - + * for (final OutputStream listenerStream : this.listenerStreams) { listenerStream.flush(); } - } + }* @Override public void write(final int arg0) throws IOException { for (final OutputStream listenerStream : this.listenerStreams) { listenerStream.write(arg0); } - } + }* @Override public void close() throws IOException { diff --git a/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/Coin.java b/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/Coin.java index 6c6950e44..20db316a7 100644 --- a/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/Coin.java +++ b/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/Coin.java @@ -9,8 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.manualstart; +* + import de.unistuttgart.informatik.fius.icge.simulation.entity.BasicEntity; -import de.unistuttgart.informatik.fius.icge.simulation.entity.CollectableEntity; +import de.unistuttgart.informatik.fius.icge.simulation.entity.CollectableEntity;** /** @@ -19,17 +21,17 @@ * @author Fabian Bühler */ public class Coin extends BasicEntity implements CollectableEntity { - + * /** * The texture handle used for the test entity. */ public static String TEXTURE_HANDLE; - + * @Override protected String getTextureHandle() { return TEXTURE_HANDLE; } - + * @Override protected int getZPosition() { return 0; diff --git a/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/ManualStartSimulation.java b/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/ManualStartSimulation.java index 80d9f4d37..e960d55b4 100644 --- a/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/ManualStartSimulation.java +++ b/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/ManualStartSimulation.java @@ -9,11 +9,13 @@ */ package de.unistuttgart.informatik.fius.icge.manualstart; +* + import de.unistuttgart.informatik.fius.icge.simulation.Simulation; import de.unistuttgart.informatik.fius.icge.simulation.SimulationBuilder; import de.unistuttgart.informatik.fius.icge.ui.GameWindow; import de.unistuttgart.informatik.fius.icge.ui.TextureRegistry; -import de.unistuttgart.informatik.fius.icge.ui.WindowBuilder; +import de.unistuttgart.informatik.fius.icge.ui.WindowBuilder;** /** @@ -22,10 +24,10 @@ * @author Tim Neumann */ public class ManualStartSimulation { - + * private static String textureHandleWall; private static String textureHandleCoin; - private static String animated; + private static String animated;* /** * @param args @@ -38,20 +40,20 @@ public static void main(final String[] args) { // wb.setDpiScale(1.0); wb.buildWindow(); final GameWindow w = wb.getBuiltWindow(); - + * ManualStartSimulation.prepareTextures(w.getTextureRegistry()); TestEntity.TEXTURE_HANDLE = ManualStartSimulation.animated; Coin.TEXTURE_HANDLE = textureHandleCoin; - + * final SimulationBuilder sb = new SimulationBuilder(); sb.setTaskVerifier(new TestTaskVerifier()); sb.buildSimulation(); final Simulation sim = sb.getBuiltSimulation(); - + * w.start(); sim.attachToWindow(w, true); sim.runTask(new TestTask()); - } + }* private static void prepareTextures(final TextureRegistry tr) { ManualStartSimulation.textureHandleWall = tr diff --git a/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/ManualStartUi.java b/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/ManualStartUi.java index 4510360bc..c891b53e1 100644 --- a/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/ManualStartUi.java +++ b/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/ManualStartUi.java @@ -9,8 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.manualstart; +* + import de.unistuttgart.informatik.fius.icge.ui.GameWindow; -import de.unistuttgart.informatik.fius.icge.ui.WindowBuilder; +import de.unistuttgart.informatik.fius.icge.ui.WindowBuilder;** /** @@ -19,7 +21,7 @@ * @author Tim Neumann */ public class ManualStartUi { - + * /** * Main entry point of the program * @@ -29,7 +31,7 @@ public class ManualStartUi { public static void main(final String[] args) { ManualStartUi.newStyleBuilder(); } - + * private static void newStyleBuilder() { final WindowBuilder wb = new WindowBuilder(); wb.setTitle("Window Builder start!"); diff --git a/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/TestEntity.java b/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/TestEntity.java index b5b2ca9c1..9815ab830 100644 --- a/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/TestEntity.java +++ b/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/TestEntity.java @@ -9,24 +9,26 @@ */ package de.unistuttgart.informatik.fius.icge.manualstart; -import de.unistuttgart.informatik.fius.icge.simulation.entity.GreedyEntity; +* + +import de.unistuttgart.informatik.fius.icge.simulation.entity.GreedyEntity;** /** * Basic test entity. */ public class TestEntity extends GreedyEntity { - + * /** * The texture handle used for the test entity. */ public static String TEXTURE_HANDLE; - + * @Override protected String getTextureHandle() { return TestEntity.TEXTURE_HANDLE; } - + * @Override protected int getZPosition() { return 0; diff --git a/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/TestTask.java b/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/TestTask.java index 458034ed5..2e639997c 100644 --- a/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/TestTask.java +++ b/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/TestTask.java @@ -9,27 +9,29 @@ */ package de.unistuttgart.informatik.fius.icge.manualstart; +* + import de.unistuttgart.informatik.fius.icge.simulation.Position; import de.unistuttgart.informatik.fius.icge.simulation.Simulation; import de.unistuttgart.informatik.fius.icge.simulation.entity.CollectableEntity; import de.unistuttgart.informatik.fius.icge.simulation.programs.Program; -import de.unistuttgart.informatik.fius.icge.simulation.tasks.Task; +import de.unistuttgart.informatik.fius.icge.simulation.tasks.Task;** /** * Test task for manual start. */ public class TestTask implements Task { - + * @Override public void run(final Simulation sim) { final TestEntity tE = new TestEntity(); - + * sim.getPlayfield().addEntity(new Position(3, 4), tE); - + * CollectableEntity coin = new Coin(); sim.getPlayfield().addEntity(new Position(3, 4), coin); - + * while (true) { tE.collect(coin); tE.drop(coin); @@ -44,7 +46,7 @@ public void run(final Simulation sim) { break; } } - + * sim.runProgram(new Program() { @Override public void run(TestEntity entity) { diff --git a/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/TestTaskVerifier.java b/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/TestTaskVerifier.java index 52704a591..c5a54d7d8 100644 --- a/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/TestTaskVerifier.java +++ b/ICGE-ManualStart/src/main/java/de/unistuttgart/informatik/fius/icge/manualstart/TestTaskVerifier.java @@ -9,16 +9,17 @@ */ package de.unistuttgart.informatik.fius.icge.manualstart; +* + import java.util.ArrayList; import java.util.Collections; -import java.util.List; - +import java.util.List;* import de.unistuttgart.informatik.fius.icge.simulation.Simulation; import de.unistuttgart.informatik.fius.icge.simulation.TaskVerifier; import de.unistuttgart.informatik.fius.icge.simulation.actions.ActionLog; import de.unistuttgart.informatik.fius.icge.simulation.actions.EntityMoveAction; import de.unistuttgart.informatik.fius.icge.ui.TaskInformation; -import de.unistuttgart.informatik.fius.icge.ui.TaskVerificationStatus; +import de.unistuttgart.informatik.fius.icge.ui.TaskVerificationStatus;** /** @@ -30,18 +31,18 @@ * @author Fabian Bühler */ public class TestTaskVerifier implements TaskVerifier, TaskInformation { - + * private ActionLog log; private TaskVerificationStatus taskIsValid = TaskVerificationStatus.UNDECIDED; private int minStepsToWalk = 4; private int maxStepsToWalk = 14; - private int stepsWalked = 0; + private int stepsWalked = 0;* @Override public void attachToSimulation(Simulation sim) { // get the log to verify if the required events did happen later this.log = sim.getActionLog(); - } + }* @Override public void verify() { @@ -50,32 +51,32 @@ public void verify() { } // check the number of steps/moves all entity have taken together this.stepsWalked = this.log.getActionsOfType(EntityMoveAction.class, true).size(); - + * // as long as task is still achievable use UNDECIDED status if (this.stepsWalked < this.minStepsToWalk) { this.taskIsValid = TaskVerificationStatus.UNDECIDED; return; } - + * // if task is failed irreversibly use FAILED status if (this.stepsWalked > this.maxStepsToWalk) { this.taskIsValid = TaskVerificationStatus.FAILED; return; } - + * // use SUCCESSFUL status if task is solved correctly this.taskIsValid = TaskVerificationStatus.SUCCESSFUL; - } + }* @Override public TaskInformation getTaskInformation() { return this; - } + }* @Override public String getTaskTitle() { return "Test Task"; - } + }* @Override public String getTaskDescription() { @@ -87,158 +88,157 @@ public String getTaskDescription() { description += " (1 step walked)"; } return description; - } + }* @Override public TaskVerificationStatus getTaskStatus() { return this.taskIsValid; - } + }* @Override public List getChildTasks() { ArrayList subTasks = new ArrayList<>(); - + * subTasks.add(new TaskInformation() { - + * @Override public String getTaskTitle() { return "a) Successful sub task"; } - + * @Override public String getTaskDescription() { return "Super basic sample description"; } - + * @Override public TaskVerificationStatus getTaskStatus() { return TaskVerificationStatus.SUCCESSFUL; } - + * @Override public List getChildTasks() { return Collections.emptyList(); } }); - + * subTasks.add(new TaskInformation() { - + * @Override public String getTaskTitle() { return "b) undecided sub task"; } - + * @Override public String getTaskDescription() { return "Super basic sample description"; } - + * @Override public TaskVerificationStatus getTaskStatus() { return TaskVerificationStatus.UNDECIDED; } - + * @Override public List getChildTasks() { ArrayList subTasks = new ArrayList<>(); - + * subTasks.add(new TaskInformation() { - + * @Override public String getTaskTitle() { return "b.1) Successful sub sub task"; } - + * @Override public String getTaskDescription() { return "Super basic sample description"; } - + * @Override public TaskVerificationStatus getTaskStatus() { return TaskVerificationStatus.SUCCESSFUL; } - + * @Override public List getChildTasks() { return Collections.emptyList(); } }); - + * subTasks.add(new TaskInformation() { - + * @Override public String getTaskTitle() { return "b.2) undecided sub sub task"; } - + * @Override public String getTaskDescription() { return "Super basic sample description"; } - + * @Override public TaskVerificationStatus getTaskStatus() { return TaskVerificationStatus.UNDECIDED; } - + * @Override public List getChildTasks() { return Collections.emptyList(); } }); - + * subTasks.add(new TaskInformation() { - + * @Override public String getTaskTitle() { return "b.3) failed sub sub task"; } - + * @Override public String getTaskDescription() { return "Super basic sample description"; } - + * @Override public TaskVerificationStatus getTaskStatus() { return TaskVerificationStatus.FAILED; } - + * @Override public List getChildTasks() { return Collections.emptyList(); } }); - + * return subTasks; } }); - + * subTasks.add(new TaskInformation() { - + * @Override public String getTaskTitle() { return "c) failed sub task"; } - + * @Override public String getTaskDescription() { return "Super basic sample description"; } - + * @Override public TaskVerificationStatus getTaskStatus() { return TaskVerificationStatus.FAILED; } - + * @Override public List getChildTasks() { return Collections.emptyList(); } }); - + * return subTasks; - } - + }* } 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 10d657617..1b885b5f0 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 @@ -9,6 +9,7 @@ */ package de.unistuttgart.informatik.fius.icge.simulation; +* /** * The four fundamental directions possible in the simulation. *

@@ -37,7 +38,7 @@ 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 * 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 d79aff19f..d0612c43b 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 @@ -9,11 +9,13 @@ */ package de.unistuttgart.informatik.fius.icge.simulation; +* + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Optional; -import java.util.Set; +import java.util.Set;** /** @@ -24,8 +26,8 @@ * The parent type of all types contained in this list. */ public class MultiTypedList

{ - - private final HashMap, List

> items = new HashMap<>(); + * + private final HashMap, List

> items = new HashMap<>();* /** * Get the relevant list for the given type. @@ -42,7 +44,7 @@ private Optional> getRelevantListGeneric(final Class) list; return Optional.ofNullable(listOfCorrectType); - } + }* private Class getClass(final P o) { //Actually a cast should not be necessary here. @@ -50,7 +52,7 @@ private Class getClass(final P o) { @SuppressWarnings("unchecked") final var type = (Class) o.getClass(); return type; - } + }* /** * Get the relevant list for the given object. @@ -61,7 +63,7 @@ private Class 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. @@ -73,11 +75,11 @@ 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. @@ -87,7 +89,7 @@ private List

getRelevantListAndCreate(final P o) { */ public synchronized void add(final P o) { this.getRelevantListAndCreate(o).add(o); - } + }* /** * Check whether this list contains the given object. @@ -100,7 +102,7 @@ public synchronized boolean contains(final P o) { final var opt = this.getRelevantList(o); if (opt.isEmpty()) return false; return opt.get().contains(o); - } + }* /** * Return {@code true} iff the list contains no objects. @@ -109,7 +111,7 @@ public synchronized boolean contains(final P o) { */ public synchronized boolean isEmpty() { return this.items.isEmpty(); - } + }* /** * Remove the given object from this list. @@ -122,7 +124,7 @@ public synchronized boolean remove(final P o) { final var opt = this.getRelevantList(o); if (opt.isEmpty()) return false; return opt.get().remove(o); - } + }* /** * Get all objects in this list of the given type. @@ -137,9 +139,9 @@ public synchronized boolean remove(final P o) { */ public synchronized List get(final Class type, final boolean includeSubclasses) { if (!includeSubclasses) return this.getRelevantListGeneric(type).orElse(List.of()); - + * final List result = new ArrayList<>(); - + * for (final Class storedType : this.items.keySet()) { if (type.isAssignableFrom(storedType)) { final Class storedTypeAsSubOfRequested = storedType.asSubclass(type); @@ -147,9 +149,9 @@ public synchronized List get(final Class 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 78f3f8279..4928b4460 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 @@ -9,14 +9,15 @@ */ package de.unistuttgart.informatik.fius.icge.simulation; -import java.util.List; +* +import java.util.List;* import de.unistuttgart.informatik.fius.icge.simulation.actions.EntityMoveAction; import de.unistuttgart.informatik.fius.icge.simulation.actions.EntityTeleportAction; import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; import de.unistuttgart.informatik.fius.icge.simulation.exception.EntityAlreadyOnFieldExcpetion; import de.unistuttgart.informatik.fius.icge.simulation.exception.EntityNotOnFieldException; -import de.unistuttgart.informatik.fius.icge.simulation.exception.EntityOnAnotherFieldException; +import de.unistuttgart.informatik.fius.icge.simulation.exception.EntityOnAnotherFieldException;** /** @@ -25,19 +26,19 @@ * @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. * @@ -52,7 +53,7 @@ public interface Playfield { * if the given type is null */ List getAllEntitiesOfType(Class type, boolean includeSubclasses); - + * /** * Get a list of all entities at the given position on this playfield. * @@ -63,7 +64,7 @@ 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. * @@ -80,7 +81,7 @@ public interface Playfield { * if the given pos or type is null */ List getEntitiesOfTypeAt(final Position pos, Class type, boolean includeSubclasses); - + * /** * Add a given entity to this simulation at a given position on this playfield. * @@ -97,7 +98,7 @@ 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. *

@@ -114,7 +115,7 @@ 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. * @@ -132,7 +133,7 @@ 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. * @@ -144,7 +145,7 @@ public interface Playfield { * if the given entity is null */ void removeEntity(Entity entity); - + * /** * Get the position of the specified entity on the playfield. * @@ -157,7 +158,7 @@ public interface Playfield { * if the given entity is null */ Position getEntityPosition(Entity entity); - + * /** * Check whether the specified entity is on this playfield. * @@ -168,7 +169,7 @@ public interface Playfield { * if the given entity is null */ boolean containsEntity(Entity entity); - + * /** * Check whether a solid entity is at the given 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 56f61ac3f..63cfde44d 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 @@ -9,7 +9,9 @@ */ package de.unistuttgart.informatik.fius.icge.simulation; -import java.util.Arrays; +* + +import java.util.Arrays;** /** @@ -34,7 +36,7 @@ public class Position { private final int x; private final int y; - + * /** * Create a new position from the given parameters. * @@ -47,21 +49,21 @@ 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. * @@ -83,20 +85,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 9c6828f9c..527ac721e 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 @@ -9,13 +9,15 @@ */ package de.unistuttgart.informatik.fius.icge.simulation; +* + import de.unistuttgart.informatik.fius.icge.simulation.actions.ActionLog; import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; import de.unistuttgart.informatik.fius.icge.simulation.entity.EntityTypeRegistry; import de.unistuttgart.informatik.fius.icge.simulation.programs.Program; import de.unistuttgart.informatik.fius.icge.simulation.tasks.Task; import de.unistuttgart.informatik.fius.icge.ui.GameWindow; -import de.unistuttgart.informatik.fius.icge.ui.SimulationProxy; +import de.unistuttgart.informatik.fius.icge.ui.SimulationProxy;** /** @@ -30,42 +32,42 @@ 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. * @@ -73,7 +75,7 @@ public interface Simulation { * The window to attach to */ void attachToWindow(GameWindow window); - + * /** * Attach this simulation to the given window. * @@ -83,14 +85,14 @@ public interface Simulation { * 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. * @@ -100,7 +102,7 @@ public interface Simulation { * The task to run */ void runTask(Task taskToRun); - + * /** * Run the given program for the given Entity in the background. * 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 f5fbdf2f2..2b22b2a98 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 @@ -9,12 +9,14 @@ */ package de.unistuttgart.informatik.fius.icge.simulation; +* + import de.unistuttgart.informatik.fius.icge.simulation.inspection.InspectionManager; import de.unistuttgart.informatik.fius.icge.simulation.internal.StandardSimulation; import de.unistuttgart.informatik.fius.icge.simulation.internal.StandardSimulationClock; import de.unistuttgart.informatik.fius.icge.simulation.internal.actions.StandardActionLog; import de.unistuttgart.informatik.fius.icge.simulation.internal.entity.StandardEntityTypeRegistry; -import de.unistuttgart.informatik.fius.icge.simulation.internal.playfield.StandardPlayfield; +import de.unistuttgart.informatik.fius.icge.simulation.internal.playfield.StandardPlayfield;** /** @@ -23,10 +25,9 @@ * @author Tim Neumann */ public class SimulationBuilder { - - private TaskVerifier taskVerifier; - - private Simulation simulation; + * + private TaskVerifier taskVerifier;* + private Simulation simulation;* /** * Set the task verifier to use with this simulation. @@ -46,7 +47,7 @@ public void setTaskVerifier(final TaskVerifier taskVerifier) { "The simulation was already built! Use the methods of the Simulation Object to change its properties." ); this.taskVerifier = taskVerifier; - } + }* /** * Actually build the simulation. @@ -60,17 +61,17 @@ public void buildSimulation() { 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. @@ -79,7 +80,7 @@ public void buildSimulation() { */ public boolean hasBuiltSimulation() { return this.simulation != null; - } + }* /** * Get the simulation that was built. @@ -92,7 +93,7 @@ public boolean hasBuiltSimulation() { public Simulation getBuiltSimulation() { 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 1857b9e1a..ffdb01adf 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 @@ -9,8 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.simulation; +* + import java.util.concurrent.CompletableFuture; -import java.util.function.Function; +import java.util.function.Function;** /** @@ -21,17 +23,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 +42,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 +76,12 @@ public interface SimulationClock { *

*/ void stop(); - + * /** * Execute one single tick */ void step(); - + * /** * Register a listener for simulation ticks. *

@@ -90,7 +92,7 @@ public interface SimulationClock { * The listener to be called. */ void registerTickListener(Function listener); - + * /** * Register a listener for the end of simulation ticks. *

@@ -101,17 +103,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 +129,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 +145,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 7e2bfa00e..3c771eeac 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 @@ -9,7 +9,9 @@ */ package de.unistuttgart.informatik.fius.icge.simulation; -import de.unistuttgart.informatik.fius.icge.ui.TaskInformation; +* + +import de.unistuttgart.informatik.fius.icge.ui.TaskInformation;** /** @@ -27,14 +29,14 @@ public interface TaskVerifier { * 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. *

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 94f49a22f..8e0d20102 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 @@ -9,15 +9,16 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.actions; +* /** * An action which happens during the execution of a simulation. * * @author Tim Neumann */ public abstract class Action { - + * private final long tickNumber; - + * /** * Create an action. * @@ -27,19 +28,19 @@ public abstract class Action { 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 29700b5f7..860ab933c 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 @@ -9,9 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.actions; -import java.util.List; +* -import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; +import java.util.List;* +import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity;** /** @@ -20,7 +21,7 @@ * @author Tim Neumann */ public interface ActionLog { - + * /** * Get all actions which were logged. *

@@ -30,7 +31,7 @@ public interface ActionLog { * @return A list of all actions logged */ List getAllActions(); - + * /** * Get all actions which were logged of the given type. * @@ -43,7 +44,7 @@ public interface ActionLog { * @return A list of all matching actions */ List getActionsOfType(final Class type, final boolean includeSubclasses); - + * /** * Get all actions which were logged and were caused by the given entity. * @@ -52,7 +53,7 @@ public interface ActionLog { * @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. * @@ -69,7 +70,7 @@ public interface ActionLog { List getActionsOfTypeOfEntity( Entity entity, final Class type, final boolean includeSubclasses ); - + * /** * Log an action. * @@ -77,7 +78,7 @@ List getActionsOfTypeOfEntity( * The action to log */ void logAction(Action actionToLog); - + * /** * Set ActionLog console output (default: {@code true}) * @@ -85,7 +86,7 @@ List getActionsOfTypeOfEntity( * true: log to console, false: do not log to console */ void setConsoleOutput(boolean enable); - + * /** * Get ActionLog console output status. *

@@ -93,5 +94,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 a0f45a739..6a3ffad6c 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 @@ -9,7 +9,9 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.actions; -import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; +* + +import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity;** /** @@ -18,9 +20,9 @@ * @author Tim Neumann */ public abstract class EntityAction extends Action { - + * private final Entity entity; - + * /** * Create an entity action. * @@ -33,7 +35,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 97db49de2..af69802af 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 @@ -9,9 +9,11 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.actions; +* + import de.unistuttgart.informatik.fius.icge.simulation.Position; import de.unistuttgart.informatik.fius.icge.simulation.entity.CollectableEntity; -import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; +import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity;** /** @@ -20,11 +22,11 @@ * @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. * @@ -49,32 +51,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 38d31591c..47c149784 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 @@ -9,8 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.actions; +* + import de.unistuttgart.informatik.fius.icge.simulation.Playfield; -import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; +import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity;** /** @@ -19,9 +21,9 @@ * @author Tim Neumann */ public class EntityDespawnAction extends EntityAction { - + * private final Playfield playfield; - + * /** * Create an entity despawn action * @@ -36,14 +38,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 50d03beba..9801fc769 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 @@ -9,9 +9,11 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.actions; +* + import de.unistuttgart.informatik.fius.icge.simulation.Position; import de.unistuttgart.informatik.fius.icge.simulation.entity.CollectableEntity; -import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; +import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity;** /** @@ -20,11 +22,11 @@ * @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. * @@ -49,32 +51,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 3905273ae..605f04a6d 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 @@ -9,8 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.actions; +* + import de.unistuttgart.informatik.fius.icge.simulation.Position; -import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; +import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity;** /** @@ -21,10 +23,10 @@ * @see EntityTeleportAction */ public abstract class EntityMoveAction extends EntityAction { - + * private final Position from; private final Position to; - + * /** * Create an entity move action. * @@ -42,14 +44,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 73e3e0fa6..efeafd410 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 @@ -9,9 +9,11 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.actions; +* + import de.unistuttgart.informatik.fius.icge.simulation.Playfield; import de.unistuttgart.informatik.fius.icge.simulation.Position; -import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; +import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity;** /** @@ -20,10 +22,10 @@ * @author Tim Neumann */ public class EntitySpawnAction extends EntityAction { - + * private final Playfield playfield; private final Position position; - + * /** * Create an entity spawn action. * @@ -41,21 +43,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 9515ebd9b..30f579a08 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 @@ -9,8 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.actions; +* + import de.unistuttgart.informatik.fius.icge.simulation.Position; -import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; +import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity;** /** @@ -19,7 +21,7 @@ * @author Tim Neumann */ public class EntityStepAction extends EntityMoveAction { - + * /** * Create an entity step action. * @@ -35,7 +37,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 f533be88c..572628a66 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 @@ -9,8 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.actions; +* + import de.unistuttgart.informatik.fius.icge.simulation.Position; -import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; +import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity;** /** @@ -34,7 +36,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 5f219c83f..b76b43607 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 @@ -9,8 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.actions; +* + import de.unistuttgart.informatik.fius.icge.simulation.Direction; -import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; +import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity;** /** @@ -19,10 +21,10 @@ * @author Tim Neumann */ public class EntityTurnAction extends EntityAction { - + * private final Direction from; private final Direction to; - + * /** * Create an entity turn action. * @@ -40,21 +42,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 04de18bbc..4760def93 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 @@ -9,9 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.entity; -import java.lang.ref.WeakReference; -import java.util.concurrent.CompletableFuture; +* +import java.lang.ref.WeakReference; +import java.util.concurrent.CompletableFuture;* import de.unistuttgart.informatik.fius.icge.simulation.Playfield; import de.unistuttgart.informatik.fius.icge.simulation.Position; import de.unistuttgart.informatik.fius.icge.simulation.Simulation; @@ -19,7 +20,7 @@ import de.unistuttgart.informatik.fius.icge.simulation.exception.EntityOnAnotherFieldException; import de.unistuttgart.informatik.fius.icge.simulation.inspection.InspectionAttribute; import de.unistuttgart.informatik.fius.icge.ui.BasicDrawable; -import de.unistuttgart.informatik.fius.icge.ui.Drawable; +import de.unistuttgart.informatik.fius.icge.ui.Drawable;** /** @@ -28,19 +29,19 @@ * @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,14 +57,14 @@ 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. *

@@ -73,7 +74,7 @@ public Position getPosition() { * @return the z position of this entity. */ protected abstract int getZPosition(); - + * /** * @throws EntityNotOnFieldException * if this entity is not on a playfield @@ -83,7 +84,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,7 +93,7 @@ public void initOnPlayfield(final Playfield playfield) { this.field = new WeakReference<>(playfield); } } - + * /** * Check whether this entity is on a playfield * @@ -114,7 +115,7 @@ public boolean isOnPlayfield() { return true; } } - + * /** * Get the playfield of this entity. * @@ -128,7 +129,7 @@ protected Playfield getPlayfield() { return this.field.get(); } } - + * /** * Get the simulation of this entity. * @@ -143,7 +144,7 @@ protected Simulation getSimulation() { return this.getPlayfield().getSimulation(); } } - + * /** * Prevent this entity from performing any long running operation for {@code ticks} simulation ticks. *

@@ -164,7 +165,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. *

@@ -204,10 +205,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 892ea8f24..3b8f60e73 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 @@ -8,7 +8,7 @@ * SPDX-License-Identifier: MIT */ package de.unistuttgart.informatik.fius.icge.simulation.entity; - + * /** * An entity, which can be collected by {@link EntityCollector}. * 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 74b3ea471..6e03ea963 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 @@ -9,10 +9,12 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.entity; +* + import de.unistuttgart.informatik.fius.icge.simulation.Playfield; import de.unistuttgart.informatik.fius.icge.simulation.Position; import de.unistuttgart.informatik.fius.icge.simulation.exception.EntityOnAnotherFieldException; -import de.unistuttgart.informatik.fius.icge.ui.Drawable; +import de.unistuttgart.informatik.fius.icge.ui.Drawable;** /** @@ -25,12 +27,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. *

@@ -49,5 +51,5 @@ public interface Entity { * 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 b9752ac75..f497dced9 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 @@ -9,9 +9,11 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.entity; +* + import de.unistuttgart.informatik.fius.icge.simulation.Position; import de.unistuttgart.informatik.fius.icge.simulation.exception.CannotCollectEntityException; -import de.unistuttgart.informatik.fius.icge.simulation.exception.CannotDropEntityException; +import de.unistuttgart.informatik.fius.icge.simulation.exception.CannotDropEntityException;** /** @@ -20,7 +22,7 @@ * @author Tim Neumann */ public interface EntityCollector { - + * /** * Check if this can collect and drop the given collectable entity type. * @@ -29,7 +31,7 @@ public interface EntityCollector { * @return true if this entity collector can collect or drop the given entity type */ boolean canCarry(Class type); - + * /** * Collect the given entity. * @@ -41,7 +43,7 @@ public interface EntityCollector { * if an argument is null */ void collect(CollectableEntity entity); - + * /** * Drop the given entity. * @@ -55,5 +57,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 dd9739d38..aa7e75877 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 @@ -9,10 +9,11 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.entity; -import java.util.Set; -import java.util.function.Supplier; +* -import de.unistuttgart.informatik.fius.icge.simulation.exception.ElementExistsException; +import java.util.Set; +import java.util.function.Supplier;* +import de.unistuttgart.informatik.fius.icge.simulation.exception.ElementExistsException;** /** @@ -21,7 +22,7 @@ * @author Fabian Bühler */ public interface EntityTypeRegistry { - + * /** * Register a new entity type by name. *

@@ -42,7 +43,7 @@ public interface EntityTypeRegistry { * if the name is already used */ void registerEntityType(final String typeName, final String textureHandle, Class entityType); - + * /** * Register a new entity type by name. *

@@ -62,14 +63,14 @@ public interface EntityTypeRegistry { * if the name is already used */ void registerEntityType(final String typeName, final String textureHandle, Supplier 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 +81,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 35c10a440..118a526f4 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 @@ -9,15 +9,16 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.entity; -import java.util.List; +* +import java.util.List;* import de.unistuttgart.informatik.fius.icge.simulation.Position; import de.unistuttgart.informatik.fius.icge.simulation.actions.Action; import de.unistuttgart.informatik.fius.icge.simulation.actions.EntityCollectAction; import de.unistuttgart.informatik.fius.icge.simulation.actions.EntityDropAction; import de.unistuttgart.informatik.fius.icge.simulation.exception.CannotCollectEntityException; import de.unistuttgart.informatik.fius.icge.simulation.exception.CannotDropEntityException; -import de.unistuttgart.informatik.fius.icge.simulation.exception.EntityNotOnFieldException; +import de.unistuttgart.informatik.fius.icge.simulation.exception.EntityNotOnFieldException;** /** @@ -26,23 +27,22 @@ * @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(); + 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 type) { return true; - } + }* /** * Get all the currently collectable entities of the given type @@ -57,14 +57,14 @@ public boolean canCarry(final Class 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,18 +72,18 @@ 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 @@ -98,7 +98,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) { @@ -110,18 +110,18 @@ 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. @@ -135,6 +135,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 9698fd6fd..b6ad89ffb 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 @@ -8,10 +8,10 @@ * SPDX-License-Identifier: MIT */ package de.unistuttgart.informatik.fius.icge.simulation.entity; - + * import de.unistuttgart.informatik.fius.icge.simulation.MultiTypedList; - - + * + * /** * An inventory of a entity. * 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 d54e68555..4e141afdf 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 @@ -9,8 +9,9 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.entity; -import java.util.concurrent.CompletableFuture; +* +import java.util.concurrent.CompletableFuture;* import de.unistuttgart.informatik.fius.icge.simulation.Direction; import de.unistuttgart.informatik.fius.icge.simulation.Position; import de.unistuttgart.informatik.fius.icge.simulation.SimulationClock; @@ -22,7 +23,7 @@ import de.unistuttgart.informatik.fius.icge.simulation.inspection.InspectionAttribute; import de.unistuttgart.informatik.fius.icge.simulation.inspection.InspectionMethod; import de.unistuttgart.informatik.fius.icge.ui.AnimatedDrawable; -import de.unistuttgart.informatik.fius.icge.ui.Drawable; +import de.unistuttgart.informatik.fius.icge.ui.Drawable;** /** @@ -31,12 +32,10 @@ * @author Tim Neumann */ public abstract class MovableEntity extends BasicEntity { - - private Direction lookingDirection = Direction.EAST; - - private AnimatedDrawable movingDrawable = null; - - private Direction directionOfAlmostArrivedMove; + * + private Direction lookingDirection = Direction.EAST;* + private AnimatedDrawable movingDrawable = null;* + private Direction directionOfAlmostArrivedMove;* @Override public Drawable getDrawInformation() { @@ -44,7 +43,7 @@ public Drawable getDrawInformation() { if (movingDrawable != null) return movingDrawable; 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. @@ -58,50 +57,50 @@ public void turnClockWise() { } finally { 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 @@ -113,7 +112,7 @@ public Direction getLookingDirection() { private void setLookingDirectionByString(final String direction) { this.lookingDirection = Direction.valueOf(direction.toUpperCase()); this.recalculateAnimationAfterInspector(); - } + }* /** * @return the looking direction as a string @@ -121,11 +120,11 @@ private void setLookingDirectionByString(final String direction) { @InspectionAttribute(name = "LookingDirection") public String getLookingDirectionString() { return this.getLookingDirection().toString(); - } + }* private boolean isSolidEntityAt(final Position pos) { return this.getPlayfield().isSolidEntityAt(pos); - } + }* /** * Move this entity forward one field. @@ -139,7 +138,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 +151,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 +161,7 @@ public void move() { } finally { endOfOperation1.complete(null); } - + * final CompletableFuture endOfOperation2 = new CompletableFuture<>(); try { clock.scheduleOperationInTicks(duration / 2, endOfOperation2); @@ -174,16 +173,16 @@ public void move() { endOfOperation.complete(null); // complete future for whole operation 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"); @@ -191,7 +190,7 @@ private void internalMove(final Position currentPos, final Position nextPos) { this.getSimulation().getSimulationClock().getLastTickNumber(), this, currentPos, nextPos ); this.getPlayfield().moveEntity(this, nextPos, action); - } + }* /** * @return whether this entity can move forward one field. @@ -199,7 +198,7 @@ private void internalMove(final Position currentPos, final Position nextPos) { 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. 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 227b4bdcb..53633fbbe 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 @@ -9,13 +9,14 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.entity; +* /** * 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. *

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 11dccaa7c..0b1ddb4ae 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 @@ -9,14 +9,16 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.entity; -import de.unistuttgart.informatik.fius.icge.ui.BasicDrawable; +* + +import de.unistuttgart.informatik.fius.icge.ui.BasicDrawable;** /** * Same as {@link BasicDrawable} but won't tile. */ public class UntilableDrawable extends BasicDrawable { - + * /** * Create a new untilable Drawable. * @@ -28,7 +30,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 140d7b2f1..826e4b900 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 @@ -9,18 +9,19 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.exception; +* /** * 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 +29,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 +40,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 +55,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 cb8687bcc..79c5f93e1 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 @@ -9,18 +9,19 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.exception; +* /** * 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 +29,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 +40,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 +55,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 82bdd010f..5c2e9303d 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 @@ -9,25 +9,26 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.exception; +* /** * 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 +38,7 @@ public CannotRunProgramException() { public CannotRunProgramException(final String s) { super(s); } - + * /** * Constructs a new exception with the specified detail message and cause. * @@ -55,7 +56,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 848418cd3..b3c64d996 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 @@ -9,25 +9,26 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.exception; +* /** * 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 1cfcc701c..8f340295d 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 @@ -9,6 +9,7 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.exception; +* /** * This exception indicates that an action is illegal, because the subject entity is already in on the relevant * playfield. @@ -20,7 +21,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 +29,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 +40,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 c36fd3cb6..2c5abf422 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 @@ -9,6 +9,7 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.exception; +* /** * This exception indicates that an action was illegal, because the subject entity is not the the relevant playfield. * @@ -19,7 +20,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 +28,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 +39,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 6378e6448..28a55d953 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 @@ -9,18 +9,19 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.exception; +* /** * 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 +29,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 +40,7 @@ public EntityOnAnotherFieldException() { public EntityOnAnotherFieldException(final String message) { super(message); } - + * /** * Constructs a new EntityOnAnotherFieldException with the specified detail message and 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 7856ef11d..b07df57c1 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 @@ -9,6 +9,7 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.exception; +* /** * This exception indicates, that a entity could not move. *

@@ -22,7 +23,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 +31,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,7 +42,7 @@ public IllegalMoveException() { public IllegalMoveException(final String message) { super(message); } - + * /** * Constructs a new IllegalMoveException with the specified detail message and 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 085bb0fa4..edd26ac2f 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 @@ -9,18 +9,19 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.exception; +* /** * 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 +29,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 +40,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,7 +55,7 @@ public SimulationExcpetion(final String message) { public SimulationExcpetion(final Throwable cause) { super(cause); } - + * /** * Constructs a new SimulationExcpetion with the specified detail message and 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 c94f941e3..d368f56e2 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 @@ -9,7 +9,9 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.exception; -import de.unistuttgart.informatik.fius.icge.simulation.SimulationClock; +* + +import de.unistuttgart.informatik.fius.icge.simulation.SimulationClock;** /** @@ -20,7 +22,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 18ae81a10..db67688ae 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 @@ -9,25 +9,26 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.exception; +* /** * 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 +38,7 @@ public UncheckedInterruptedException() { public UncheckedInterruptedException(final String s) { super(s); } - + * /** * Constructs a new exception with the specified detail message and cause. * @@ -55,7 +56,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 4e4e5d84e..be366738d 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 @@ -9,11 +9,13 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.inspection; +* + import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.List; +import java.util.List;** /** @@ -24,7 +26,7 @@ public class AnnotationReader { private AnnotationReader() { //hide constructor - } + }* /** * Get all methods with the given annotation in the given class and all parent classes. @@ -38,19 +40,19 @@ private AnnotationReader() { public static List getAllMethodsWithAnnotationRecursively(final Class cls, final Class 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. @@ -64,13 +66,13 @@ public static List getAllMethodsWithAnnotationRecursively(final Class public static List getAllAttributesWithAnnotationRecursively(final Class cls, final Class 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 e1df282e5..8767c5d40 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 @@ -9,6 +9,8 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.inspection; +* + import java.io.File; import java.io.IOException; import java.net.URISyntaxException; @@ -18,7 +20,7 @@ import java.util.List; import java.util.function.Predicate; import java.util.jar.JarEntry; -import java.util.jar.JarFile; +import java.util.jar.JarFile;** /** @@ -29,7 +31,7 @@ public class ClassFinder { private ClassFinder() { //hide constructor - } + }* /** * Get all classes in the current context class loader, which match the filter. @@ -43,9 +45,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,9 +55,9 @@ 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 { @@ -82,7 +84,7 @@ private static void loadClassesFromJar(final URL url, final Predicate> } catch (final URISyntaxException e2) { throw new IOException(e2); } - } + }* private static void loadClassesFromFS( final URL url, final Predicate> filter, final List> classes, final ClassLoader loader @@ -93,7 +95,7 @@ private static void loadClassesFromFS( } catch (URISyntaxException | ClassNotFoundException e) { throw new IOException(e); } - } + }* private static void loadClassInFile( final File file, final List> classes, final ClassLoader loader, final String rootDir, final Predicate> filter @@ -115,7 +117,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!"); @@ -128,6 +130,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 6a0703432..9fee02a8e 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 @@ -9,13 +9,14 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.inspection; +* + import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - +import static java.lang.annotation.RetentionPolicy.RUNTIME;* import java.lang.annotation.Documented; import java.lang.annotation.Retention; -import java.lang.annotation.Target; +import java.lang.annotation.Target;** /** @@ -31,7 +32,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 f98a59fa9..b5784eff1 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 @@ -9,6 +9,8 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.inspection; +* + import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -17,7 +19,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; +import java.util.Map.Entry;** /** @@ -26,10 +28,9 @@ * @author Tim Neumann */ public class InspectionData { - private final Class c; - + private final Class c;* private final Map inspectableAttributes; - private final Map inspectableMethods; + private final Map inspectableMethods;* /** * Creates a new inspection data object for the given class @@ -43,7 +44,7 @@ public InspectionData(final Class cls) { this.inspectableMethods = new HashMap<>(); this.initAttributes(); this.initMethods(); - } + }* /** * Get the value of the attribute with the given name from the given object. @@ -67,7 +68,7 @@ public Object getAttributeValue(final Object obj, final String name) { } } return null; - } + }* /** * Set's the value of the attribute with the given name for the given object @@ -91,7 +92,7 @@ public boolean setAttributeValue(final Object obj, final String name, final Obje } } return false; - } + }* /** * Get the attribute names of the class for this inspection data. @@ -100,7 +101,7 @@ public boolean setAttributeValue(final Object obj, final String name, final Obje */ public List getAttributeNames() { return Collections.unmodifiableList(new ArrayList<>(this.inspectableAttributes.keySet())); - } + }* /** * Get the type of the attribute with the given name. @@ -113,7 +114,7 @@ public Class getAttributeType(final String attributeName) { final AttributeInspectionPoint p = this.inspectableAttributes.get(attributeName); if (p == null) return null; return p.getType(); - } + }* /** * Check whether the attribute with the given name is read only. @@ -126,14 +127,14 @@ public boolean isAttributeReadOnly(final String attributeName) { final AttributeInspectionPoint p = this.inspectableAttributes.get(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. @@ -142,7 +143,7 @@ public boolean hasAnyInspectableElements() { */ public List getMethodNames() { return Collections.unmodifiableList(new ArrayList<>(this.inspectableMethods.keySet())); - } + }* /** * Get the method detail for the method with the given name @@ -153,7 +154,7 @@ 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 @@ -175,39 +176,39 @@ public Object invokeMethod(final Object obj, final String methodName, final Obje e.printStackTrace(); 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,55 +219,55 @@ 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()); - + * 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"); - - } + * + }* 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()); - } + }* private String getDisplayNameForField(final Field f) { final InspectionAttribute anno = f.getAnnotation(InspectionAttribute.class); @@ -275,7 +276,7 @@ private String getDisplayNameForField(final Field f) { if ((name != null) && !name.isEmpty()) return name; } return f.getName(); - } + }* private String getDsiplayNameForInspectionMethod(final Method m) { final InspectionMethod anno = m.getAnnotation(InspectionMethod.class); @@ -284,7 +285,7 @@ private String getDsiplayNameForInspectionMethod(final Method m) { if ((name != null) && !name.isEmpty()) return name; } return m.getName(); - } + }* private String getDisplayNameForMethod(final Method m, final String possiblePrefixToRemove) { final InspectionAttribute anno = m.getAnnotation(InspectionAttribute.class); @@ -292,15 +293,15 @@ private String getDisplayNameForMethod(final Method m, final String possiblePref 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<>(); @@ -321,7 +322,7 @@ 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 * @@ -336,7 +337,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; @@ -345,7 +346,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; @@ -354,17 +355,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."); @@ -375,7 +376,7 @@ public void setValue(final Object obj, final Object value) this.setter.invoke(obj, value); } } - + * /** * Get's {@link #type type} * @@ -384,7 +385,7 @@ public void setValue(final Object obj, final Object value) public Class getType() { return this.type; } - + * /** * Get's {@link #readOnly readOnly} * @@ -393,7 +394,7 @@ public Class getType() { public boolean isReadOnly() { return this.readOnly; } - } + }* /** * A exception that is thrown when an error with a inspection point occurs. @@ -405,7 +406,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}. @@ -413,7 +414,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}. @@ -424,7 +425,7 @@ public InspectionPointException() { public InspectionPointException(final String message) { super(message); } - + * /** * Constructs a new runtime exception with the specified detail message and cause. *

@@ -441,7 +442,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 @@ -456,7 +457,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 5fe7331e0..1337bb826 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 @@ -9,14 +9,15 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.inspection; +* + import java.io.IOException; import java.lang.reflect.Method; import java.util.Collections; import java.util.HashMap; import java.util.List; -import java.util.Map; - -import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; +import java.util.Map;* +import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity;** /** @@ -25,8 +26,8 @@ * @author Tim Neumann */ public class InspectionManager { - - private final Map, InspectionData> inspectableClasses = new HashMap<>(); + * + private final Map, InspectionData> inspectableClasses = new HashMap<>();* /** * Create a new inspection manager. @@ -34,7 +35,7 @@ public class InspectionManager { public InspectionManager() { try { final List> classes = ClassFinder.getClassesInClassLoader(c -> true); - + * for (final Class cls : classes) { final InspectionData d = new InspectionData(cls); if (d.hasAnyInspectableElements()) { @@ -44,7 +45,7 @@ public InspectionManager() { } catch (final IOException e) { e.printStackTrace(); } - } + }* /** * Get's all attribute names of the given entity. @@ -57,7 +58,7 @@ public List getAttributeNamesOfEntity(final Entity entity) { final InspectionData d = this.inspectableClasses.get(entity.getClass()); if (d == null) return Collections.emptyList(); return d.getAttributeNames(); - } + }* /** * Get's all method names of the given entity. @@ -70,7 +71,7 @@ public List getMethodNamesOfEntity(final Entity entity) { final InspectionData d = this.inspectableClasses.get(entity.getClass()); if (d == null) return Collections.emptyList(); return d.getMethodNames(); - } + }* /** * Checks whether the attribute with the given name in the given entity is writable. @@ -85,7 +86,7 @@ public boolean isAttributeEditable(final Entity entity, final String attributeNa final InspectionData d = this.inspectableClasses.get(entity.getClass()); if (d == null) return false; return !d.isAttributeReadOnly(attributeName); - } + }* /** * Get's the type of the attribute with the given name in the given entity. @@ -100,7 +101,7 @@ public Class getAttributeType(final Entity entity, final String attributeName final InspectionData d = this.inspectableClasses.get(entity.getClass()); if (d == null) return null; return d.getAttributeType(attributeName); - } + }* /** * Get the value of the attribute with the given name from the given entity @@ -115,7 +116,7 @@ public Object getAttributeValue(final Entity entity, final String attributeName) final InspectionData d = this.inspectableClasses.get(entity.getClass()); if (d == null) return null; return d.getAttributeValue(entity, attributeName); - } + }* /** * Set the value of the attribute with the given name in the given entity @@ -132,7 +133,7 @@ public boolean setAttributeValue(final Entity entity, final String attributeName final InspectionData d = this.inspectableClasses.get(entity.getClass()); 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. @@ -147,7 +148,7 @@ public Method getMethodDetail(final Entity entity, final String methodName) { final InspectionData d = this.inspectableClasses.get(entity.getClass()); if (d == null) return null; return d.getMethodByName(methodName); - } + }* /** * Invokes the method with the given name on the given entity. Uses the given arguments. @@ -166,6 +167,5 @@ public Object invokeMethod(final Entity entity, final String methodName, final O final InspectionData d = this.inspectableClasses.get(entity.getClass()); 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 a8b540048..b51ca5ee0 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 @@ -8,15 +8,15 @@ * SPDX-License-Identifier: MIT */ package de.unistuttgart.informatik.fius.icge.simulation.inspection; - + * import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; - + * import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; - - + * + * /** * A annotation specifying that the annotated method should be displayed as a method in the inspector. * 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 d023fec70..5b48e6ad3 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 @@ -9,6 +9,8 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.internal; +* + import de.unistuttgart.informatik.fius.icge.simulation.Playfield; import de.unistuttgart.informatik.fius.icge.simulation.programs.Program; import de.unistuttgart.informatik.fius.icge.simulation.Simulation; @@ -25,7 +27,7 @@ import de.unistuttgart.informatik.fius.icge.simulation.internal.tasks.StandardTaskRunner; import de.unistuttgart.informatik.fius.icge.simulation.tasks.Task; import de.unistuttgart.informatik.fius.icge.ui.GameWindow; -import de.unistuttgart.informatik.fius.icge.ui.SimulationProxy; +import de.unistuttgart.informatik.fius.icge.ui.SimulationProxy;** /** @@ -34,16 +36,15 @@ * @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; + private final StandardSimulationProxy simulationProxy;* + private StandardTaskRunner runningTask; + private final StandardProgramRunner programRunner;* /** * Creates a new standard simulation with the given parameters. @@ -71,59 +72,59 @@ 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() { @@ -133,7 +134,7 @@ public void stop() { } this.programRunner.stopAll(); this.simulationClock.shutdown(); // stop the clock for good - } + }* @Override public void runTask(final Task taskToRun) { @@ -142,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) { 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 6ce7abac6..7b149235f 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 @@ -9,6 +9,8 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.internal; +* + import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -20,12 +22,11 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; -import java.util.function.Function; - +import java.util.function.Function;* import de.unistuttgart.informatik.fius.icge.simulation.SimulationClock; import de.unistuttgart.informatik.fius.icge.simulation.exception.TimerAlreadyRunning; import de.unistuttgart.informatik.fius.icge.simulation.exception.UncheckedInterruptedException; -import de.unistuttgart.informatik.fius.icge.ui.exception.ListenerSetException; +import de.unistuttgart.informatik.fius.icge.ui.exception.ListenerSetException;** /** @@ -36,21 +37,15 @@ * @version 1.0 */ public class StandardSimulationClock implements SimulationClock { - private final Object tickListenerLock = new Object(); - + 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; - + 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. *

@@ -63,9 +58,8 @@ public class StandardSimulationClock implements SimulationClock { *

* */ - private volatile boolean shuttingDown; - - private int period; + private volatile boolean shuttingDown;* + private int period;* /** * Default constructor @@ -78,7 +72,7 @@ public StandardSimulationClock() { this.period = SimulationClock.DEFAULT_RENDER_TICK_PERIOD; 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 @@ -87,16 +81,16 @@ 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(); } }; 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 @@ -107,7 +101,7 @@ public synchronized void stopInternal() { this.task.cancel(); } this.task = null; - } + }* /** * Shuts down this clock. @@ -130,62 +124,62 @@ public synchronized void shutdown() { for (final var boundary : Set.copyOf(this.operationBoundaries)) { 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 @@ -204,7 +198,7 @@ private void tick() { this.animationTickListener.accept(this.tickCount); } } - } + }* /** * Process a simulation tick @@ -220,7 +214,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; @@ -228,7 +222,7 @@ private void tickSimulation(final long tickNumber) { this.postTickListeners.remove(listener); } } - } + }* /** * Set the animation tick listener, that gets called every animation tick and is responsible for informing the UI. @@ -242,7 +236,7 @@ public void setAnimationTickListener(final Consumer listener) { if ((this.animationTickListener == null) || (listener == null)) { 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 @@ -257,7 +251,7 @@ public void setStateChangeListener(final StateChangeListener listener) { if ((this.stateChangeListener == null) || (listener == null)) { 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 @@ -265,7 +259,7 @@ public void setStateChangeListener(final StateChangeListener listener) { */ public void removeStateChangeListener() { this.stateChangeListener = null; - } + }* @Override public void registerTickListener(final Function listener) { @@ -273,7 +267,7 @@ public void registerTickListener(final Function listener) { synchronized (this.tickListenerLock) { this.tickListeners.add(listener); } - } + }* @Override public void registerPostTickListener(final Function listener) { @@ -281,18 +275,18 @@ public void registerPostTickListener(final Function listener) { synchronized (this.tickListenerLock) { 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) { @@ -327,17 +321,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 @@ -348,7 +342,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 20a493495..7060924c1 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 @@ -9,12 +9,13 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.internal; +* + import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Consumer; - +import java.util.function.Consumer;* import de.unistuttgart.informatik.fius.icge.simulation.Position; import de.unistuttgart.informatik.fius.icge.simulation.Simulation; import de.unistuttgart.informatik.fius.icge.simulation.TaskVerifier; @@ -31,7 +32,7 @@ import de.unistuttgart.informatik.fius.icge.ui.SimulationTreeNode; import de.unistuttgart.informatik.fius.icge.ui.TaskInformation; import de.unistuttgart.informatik.fius.icge.ui.Toolbar.ClockButtonState; -import de.unistuttgart.informatik.fius.icge.ui.Toolbar.ControlButtonState; +import de.unistuttgart.informatik.fius.icge.ui.Toolbar.ControlButtonState;** /** @@ -43,30 +44,26 @@ * @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; - + private boolean stopSimulationWithWindowClose = false;* // MANAGERS - private final InspectionManager inspectionManager; - + private final InspectionManager inspectionManager;* // CURRENT SIMULATION - private final Simulation simulation; - private final StandardEntityTypeRegistry entityTypeRegistry; - private final StandardSimulationClock simulationClock; - private final StandardPlayfield playfield; - private final TaskVerifier taskVerifier; - private final Map simualtionSidebarMap; - - private Entity entityToInspect; + private final Simulation simulation; + private final StandardEntityTypeRegistry entityTypeRegistry; + private final StandardSimulationClock simulationClock; + private final StandardPlayfield playfield; + private final TaskVerifier taskVerifier; + private final Map simualtionSidebarMap;* + private Entity entityToInspect;* /** * Create a new standard simulation proxy @@ -95,7 +92,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 +103,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 +128,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 +151,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 +172,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,18 +183,18 @@ 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() { @@ -208,15 +205,15 @@ 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) { @@ -227,7 +224,7 @@ public void buttonPressed(final ButtonType type) { } this.gameWindow.getToolbar().setClockButtonState(ClockButtonState.PLAYING); break; - + * case STEP: if (!this.simulationClock.isRunning()) { this.simulationClock.step(); @@ -236,37 +233,37 @@ 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) { @@ -274,9 +271,9 @@ public void selectedEntityChanged(final String name) { if ((name != null) && !name.equals("")) { textureHandle = this.entityTypeRegistry.getTextureHandleOfEntityType(name); } - + * this.gameWindow.getPlayfieldDrawer().setSelectedEntityType(name, textureHandle); - } + }* @Override public void refreshTaskInformation() { @@ -286,7 +283,7 @@ public void refreshTaskInformation() { task = this.taskVerifier.getTaskInformation(); } this.gameWindow.getTaskStatusDisplay().setTaskInformation(task); - } + }* @Override public void spawnEntityAt(final String typeName, final int x, final int y) { @@ -301,12 +298,12 @@ public void spawnEntityAt(final String typeName, final int x, final int y) { System.out.println("Something went wrong while creating new entity."); 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); @@ -314,11 +311,11 @@ public void clearCell(final int x, final int y) { // nothing to do because entity was either null or already not on the field } }); - } + }* 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 +334,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 -> { @@ -348,13 +345,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) { @@ -363,7 +360,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()); @@ -373,7 +370,7 @@ public void selectedSimulationEntityChange(final SimulationTreeNode node) { this.gameWindow.getEntitySidebar().setEntityInspectorEntries(new EntityInspectorEntry[0]); this.gameWindow.getEntitySidebar().disableEntityInspector(); } - } + }* @Override public void entityValueChange(final String name, final String value) { 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 5ff023cef..9e0c2ee36 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 @@ -9,16 +9,17 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.internal.actions; +* + import java.util.Collections; import java.util.HashMap; import java.util.List; -import java.util.Map; - +import java.util.Map;* import de.unistuttgart.informatik.fius.icge.simulation.MultiTypedList; import de.unistuttgart.informatik.fius.icge.simulation.actions.Action; import de.unistuttgart.informatik.fius.icge.simulation.actions.ActionLog; import de.unistuttgart.informatik.fius.icge.simulation.actions.EntityAction; -import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; +import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity;** /** @@ -27,30 +28,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 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 +60,7 @@ public List getAllActionsOfEntity(final Entity entity) { return list.get(EntityAction.class, true); } } - + * @Override public List getActionsOfTypeOfEntity( final Entity entity, final Class type, final boolean includeSubclasses @@ -70,7 +71,7 @@ public List getActionsOfTypeOfEntity( return list.get(type, includeSubclasses); } } - + * @Override public void logAction(final Action actionToLog) { if (actionToLog instanceof EntityAction) { @@ -90,12 +91,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 cb32e5870..e55819f6d 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 @@ -9,16 +9,17 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.internal.entity; +* + import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; import java.util.Set; -import java.util.function.Supplier; - +import java.util.function.Supplier;* import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; import de.unistuttgart.informatik.fius.icge.simulation.entity.EntityTypeRegistry; import de.unistuttgart.informatik.fius.icge.simulation.exception.ElementExistsException; -import de.unistuttgart.informatik.fius.icge.ui.exception.ListenerSetException; +import de.unistuttgart.informatik.fius.icge.ui.exception.ListenerSetException;** /** @@ -27,11 +28,10 @@ * @author Fabian Bühler */ public class StandardEntityTypeRegistry implements EntityTypeRegistry { - + * private final Map> typeToEntityFactory = new HashMap<>(); - private final Map typeToTextureHandle = new HashMap<>(); - - private EntityRegisteredListener entityRegisteredListener; + private final Map typeToTextureHandle = new HashMap<>();* + private EntityRegisteredListener entityRegisteredListener;* @Override public void registerEntityType(final String typeName, final String textureHandle, final Class entityType) { @@ -49,7 +49,7 @@ public void registerEntityType(final String typeName, final String textureHandle } }; this.registerEntityType(typeName, textureHandle, entityFactory); - } + }* @Override public synchronized void registerEntityType( @@ -63,22 +63,22 @@ public synchronized void registerEntityType( 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) { @@ -86,7 +86,7 @@ public Entity getNewEntity(final String typeName) { final Supplier entityFactory = this.typeToEntityFactory.get(typeName); if (entityFactory == null) return null; return entityFactory.get(); - } + }* /** * Set an entity selector listener that gets informed about all entity types added. @@ -105,14 +105,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 a42c37afc..68469e60b 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 @@ -9,9 +9,11 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.internal.playfield; +* + import de.unistuttgart.informatik.fius.icge.simulation.MultiTypedList; import de.unistuttgart.informatik.fius.icge.simulation.Position; -import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; +import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity;** /** @@ -21,7 +23,7 @@ */ public class PlayfieldCell extends MultiTypedList { private final Position pos; - + * /** * Create a new playfield cell, * @@ -32,7 +34,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 5aa777a98..7bc9cc970 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 @@ -9,6 +9,8 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.internal.playfield; +* + import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; @@ -17,8 +19,7 @@ import java.util.Timer; import java.util.TimerTask; import java.util.function.BiConsumer; -import java.util.function.Consumer; - +import java.util.function.Consumer;* import de.unistuttgart.informatik.fius.icge.simulation.Playfield; import de.unistuttgart.informatik.fius.icge.simulation.Position; import de.unistuttgart.informatik.fius.icge.simulation.Simulation; @@ -33,7 +34,7 @@ import de.unistuttgart.informatik.fius.icge.simulation.internal.StandardSimulation; import de.unistuttgart.informatik.fius.icge.ui.Drawable; import de.unistuttgart.informatik.fius.icge.ui.SimulationTreeNode; -import de.unistuttgart.informatik.fius.icge.ui.exception.ListenerSetException; +import de.unistuttgart.informatik.fius.icge.ui.exception.ListenerSetException;** /** @@ -42,22 +43,17 @@ * @author Tim Neumann */ 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 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 + 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,18 +67,18 @@ 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 @@ -94,7 +90,7 @@ public Simulation getSimulation() { final Simulation simulation = this.sim.get(); 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 @@ -102,7 +98,7 @@ public Simulation getSimulation() { */ public void drawEntities() { this.awaitingEntityDraw = true; - } + }* /** * Converts all entities to drawables and sends them to the playfield drawer. @@ -127,13 +123,13 @@ 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 type, final boolean includeSubclasses) { @@ -145,13 +141,13 @@ public List getAllEntitiesOfType(final Class } } 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( @@ -167,7 +163,7 @@ public List getEntitiesOfTypeAt( } } return result; - } + }* private void addEntityToCell(final Position pos, final Entity entity) { synchronized (this.playfieldLock) { @@ -178,7 +174,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) { @@ -192,30 +188,30 @@ private void removeEntityFromCell(final Position pos, final Entity entity) { this.cells.remove(pos, cell); } } - } + }* @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."); - + * 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<>(); @@ -227,7 +223,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())) { @@ -243,38 +239,38 @@ private SimulationTreeNode findNodeForEntity(final Entity entity, final boolean } else return null; } 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."); - + * EntityMoveAction actionToLog = action; - + * final Position oldPos = this.entityPositions.get(entity); - + * if (actionToLog == null) { actionToLog = new EntityTeleportAction(this.getSimulation().getSimulationClock().getLastTickNumber(), entity, oldPos, pos); } else { @@ -284,22 +280,22 @@ public void moveEntity(final Entity entity, final Position pos, final EntityMove 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); @@ -309,28 +305,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."); - + * 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) { @@ -340,7 +336,7 @@ public Position getEntityPosition(final Entity entity) { if (pos == null) throw new EntityNotOnFieldException("The given entity" + entity + "is not on this playfield."); return pos; } - } + }* @Override public boolean containsEntity(final Entity entity) { @@ -348,7 +344,7 @@ public boolean containsEntity(final Entity entity) { synchronized (this.playfieldLock) { return this.entityPositions.containsKey(entity); } - } + }* @Override public boolean isSolidEntityAt(final Position pos) { @@ -357,14 +353,14 @@ public boolean isSolidEntityAt(final Position pos) { if (entity.isCurrentlySolid()) return true; } 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. @@ -376,14 +372,14 @@ public void setSimulationTreeEntityAddedListener(final BiConsumer> listener) if ((this.drawablesChangedListener == null) || (listener == null)) { this.drawablesChangedListener = listener; } else throw new ListenerSetException(); - } + }* /** * Remove the listener for when the drawables on the playfield changed. This listener is responsible for informing @@ -423,7 +419,7 @@ public void setDrawablesChangedListener(final Consumer> listener) */ public void removeDrawablesChangedListener() { this.drawablesChangedListener = null; - } + }* @Override public String toString() { 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 55106863d..5b6c6d82f 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 @@ -9,6 +9,8 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.internal.programs; +* + import java.util.HashMap; import java.util.Map; import java.util.concurrent.CancellationException; @@ -16,11 +18,10 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinWorkerThread; -import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory; - +import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory;* import de.unistuttgart.informatik.fius.icge.simulation.programs.Program; import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; -import de.unistuttgart.informatik.fius.icge.simulation.exception.UncheckedInterruptedException; +import de.unistuttgart.informatik.fius.icge.simulation.exception.UncheckedInterruptedException;** /** @@ -29,17 +30,16 @@ * @author Fabian Bühler */ public class StandardProgramRunner { - - private ExecutorService executor; - - private final Map> runningPrograms = new HashMap<>(); + * + 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, @@ -53,9 +53,9 @@ 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. @@ -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,10 +94,10 @@ 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. @@ -108,7 +108,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 9be58f903..b5c1365a0 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 @@ -9,15 +9,16 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.internal.tasks; +* + import java.util.concurrent.CancellationException; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; - +import java.util.concurrent.ThreadFactory;* import de.unistuttgart.informatik.fius.icge.simulation.Simulation; import de.unistuttgart.informatik.fius.icge.simulation.exception.UncheckedInterruptedException; -import de.unistuttgart.informatik.fius.icge.simulation.tasks.Task; +import de.unistuttgart.informatik.fius.icge.simulation.tasks.Task;** /** @@ -26,13 +27,11 @@ * @author Tim Neumann */ public class StandardTaskRunner { - - private final ExecutorService executor; - - private final Task taskToRun; - private final Simulation sim; - - private CompletableFuture taskResult; + * + private final ExecutorService executor;* + private final Task taskToRun; + private final Simulation sim;* + private CompletableFuture taskResult;* /** * Create a new task runner. @@ -50,10 +49,10 @@ 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,9 +65,9 @@ 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 { @@ -94,7 +93,7 @@ private boolean executeTask() { System.out.println("----------------------------------------------"); 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 49d8580c8..7ab37c2db 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 @@ -8,11 +8,11 @@ * SPDX-License-Identifier: MIT */ package de.unistuttgart.informatik.fius.icge.simulation.programs; - + * import de.unistuttgart.informatik.fius.icge.simulation.Simulation; import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; - - + * + * /** * The interface for programs that operate on entities. * 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 276a88b7b..7f9294f13 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 @@ -8,10 +8,10 @@ * SPDX-License-Identifier: MIT */ package de.unistuttgart.informatik.fius.icge.simulation.tasks; - + * import de.unistuttgart.informatik.fius.icge.simulation.Simulation; - - + * + * /** * The interface for a task to be solved by students. * 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 ac0db9320..da115587b 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 @@ -9,11 +9,12 @@ */ package de.unistuttgart.informatik.fius.icge.simulation.tools; -import java.util.function.Supplier; +* +import java.util.function.Supplier;* import de.unistuttgart.informatik.fius.icge.simulation.Playfield; import de.unistuttgart.informatik.fius.icge.simulation.Position; -import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity; +import de.unistuttgart.informatik.fius.icge.simulation.entity.Entity;** /** @@ -23,7 +24,7 @@ */ public class PlayfieldModifier { private final Playfield playfield; - + * /** * Create a new playfield modifier for the given playfield. * @@ -33,7 +34,7 @@ public class PlayfieldModifier { public PlayfieldModifier(final Playfield playfield) { this.playfield = playfield; } - + * /** * Place the given entity at the given position on the playfield. * @@ -45,7 +46,7 @@ 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. * @@ -61,7 +62,7 @@ public void placeMultipleEntitiesAt(final Supplier entityFacto placeEntityAt(entityFactory.get(), position); } } - + * /** * Place an entity supplied by the given factory at each of the given positions * diff --git a/ICGE-Simulation/src/main/java/module-info.java b/ICGE-Simulation/src/main/java/module-info.java index 9117dd04f..5e6027aba 100644 --- a/ICGE-Simulation/src/main/java/module-info.java +++ b/ICGE-Simulation/src/main/java/module-info.java @@ -9,7 +9,7 @@ */ 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/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 400dbeec8..ea67febaa 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 @@ -9,28 +9,29 @@ */ package de.unistuttgart.informatik.fius.icge.ui; +* /** * A class containing all information needed to draw a moving object onto the playfield by a {@link PlayfieldDrawer}. * * @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 +67,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 +80,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,27 +88,27 @@ 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} * @@ -116,7 +117,7 @@ public boolean isAnimated() { public double getxStart() { return this.xStart; } - + * /** * Get's {@link #yStart yStart} * @@ -125,7 +126,7 @@ public double getxStart() { public double getyStart() { return this.yStart; } - + * /** * Get's {@link #xEnd xEnd} * @@ -134,7 +135,7 @@ public double getyStart() { public double getxEnd() { return this.xEnd; } - + * /** * Get's {@link #yEnd yEnd} * @@ -143,7 +144,7 @@ public double getxEnd() { public double getyEnd() { return this.yEnd; } - + * /** * Get's {@link #tickStart tickStart} * @@ -152,7 +153,7 @@ public double getyEnd() { public long getTickStart() { return this.tickStart; } - + * /** * Get's {@link #tickEnd tickEnd} * @@ -161,7 +162,7 @@ public long getTickStart() { public long getTickEnd() { return this.tickEnd; } - + * /** * Get's {@link #duration duration} * 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 13766b9ec..bdcb01e2d 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 @@ -9,41 +9,42 @@ */ package de.unistuttgart.informatik.fius.icge.ui; +* /** * A class containing all information needed to draw an object onto the playfield by a {@link PlayfieldDrawer}. * * @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 +63,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 5c20d0cca..d8deb445e 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 @@ -9,6 +9,7 @@ */ package de.unistuttgart.informatik.fius.icge.ui; +* /** * A Console to show text output of the software * @@ -16,7 +17,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 d90d8f088..df80f6393 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 @@ -9,6 +9,7 @@ */ package de.unistuttgart.informatik.fius.icge.ui; +* /** * A interface providing all information needed to draw an object onto the playfield by a {@link PlayfieldDrawer}. * @@ -17,7 +18,7 @@ * @version 1.0 */ public interface Drawable extends Comparable { - + * /** * Get the x coordinate of the drawable. * @@ -26,7 +27,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 +36,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 +45,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 +54,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,7 +63,7 @@ public interface Drawable extends Comparable { default boolean isTilable() { return true; } - + * /** * Return wether the Drawable is animated. * @@ -71,7 +72,7 @@ default boolean isTilable() { default boolean isAnimated() { return false; } - + * /** * Set the current render tick for animated drawables. * @@ -81,7 +82,7 @@ default boolean isAnimated() { 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 51c9203a2..c1907c4c6 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 @@ -9,22 +9,24 @@ */ package de.unistuttgart.informatik.fius.icge.ui; -import java.util.function.Consumer; +* + +import java.util.function.Consumer;** /** * EntityInspectorEntry */ public class EntityInspectorEntry { - + * private final String name; - + * private final String type; - + * private final String value; - + * private final Consumer callback; - + * /** * Default constructor * @@ -43,7 +45,7 @@ public EntityInspectorEntry(final String name, final String type, final String v this.value = value; this.callback = callback; } - + * /** * Getter for the name * @@ -52,7 +54,7 @@ public EntityInspectorEntry(final String name, final String type, final String v public String getName() { return this.name; } - + * /** * Getter for the type * @@ -61,7 +63,7 @@ public String getName() { public String getType() { return this.type; } - + * /** * Getter for the value * @@ -70,7 +72,7 @@ public String getType() { public String getValue() { return this.value; } - + * /** * This function runs the callback of the item * 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 1a9d56f32..639bbb3ad 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 @@ -9,6 +9,7 @@ */ package de.unistuttgart.informatik.fius.icge.ui; +* /** * A sidebar showing all current entities * @@ -16,7 +17,7 @@ * @version 1.0 */ public interface EntitySidebar { - + * /** * Setter function to attach a SimulationTree to the entity sidebar. * @@ -24,12 +25,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,14 +38,14 @@ 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. * @@ -52,17 +53,17 @@ public interface EntitySidebar { * 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. * @@ -70,19 +71,19 @@ public interface EntitySidebar { * 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 52b7d0f22..db38e8b7e 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 @@ -9,6 +9,7 @@ */ package de.unistuttgart.informatik.fius.icge.ui; +* /** * The interface for a game window of the ICGE. * @@ -21,42 +22,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 +65,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 83ac6e533..86076278c 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 @@ -9,9 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.ui; -import java.util.List; +* -import de.unistuttgart.informatik.fius.icge.ui.Toolbar.ControlButtonState; +import java.util.List;* +import de.unistuttgart.informatik.fius.icge.ui.Toolbar.ControlButtonState;** /** @@ -20,7 +21,7 @@ * @author Tim Neumann */ public interface PlayfieldDrawer { - + * /** * Set the current list of Drawables to be rendered onto the playfield. * @@ -30,7 +31,7 @@ public interface PlayfieldDrawer { * the list of Drawables to render */ void setDrawables(List drawables); - + * /** * Draws the playfield. * @@ -38,25 +39,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 +66,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 +77,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 3e056494e..78103d378 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 @@ -9,6 +9,7 @@ */ package de.unistuttgart.informatik.fius.icge.ui; +* /** * The SimulationProxy interface. This is used for communication most between the UI and the simulation. *

@@ -21,7 +22,7 @@ * @version 1.0 */ public interface SimulationProxy { - + * /** * Attach this simulation proxy to a specific game window. * @@ -29,7 +30,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 +40,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 +67,7 @@ public enum ButtonType { /** The sub button in the toolbar */ SUB } - + * /** * This is called when a button is pressed by the user * @@ -74,7 +75,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 +83,7 @@ public enum ButtonType { * The new selected speed */ void simulationSpeedChange(int value); - + * /** * This gets called when the user changes the selected element * @@ -90,18 +91,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 +114,7 @@ public enum ButtonType { * coordinate */ void spawnEntityAt(String typeName, int x, int y); - + * /** * Clear all entities in the given cell. * @@ -123,11 +124,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 +136,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 bd15e2f9e..d9817fe84 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 @@ -9,12 +9,13 @@ */ package de.unistuttgart.informatik.fius.icge.ui; +* + import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.function.Consumer; - -import de.unistuttgart.informatik.fius.icge.ui.exception.LeafNodeException; +import java.util.function.Consumer;* +import de.unistuttgart.informatik.fius.icge.ui.exception.LeafNodeException;** /** @@ -25,13 +26,12 @@ * @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; + * + private ArrayList children;* + private final String elementId; + private final String displayText; + private final String textureId; + private final boolean isLeaf;* /** * Default constructor for leaf nodes @@ -48,7 +48,7 @@ public SimulationTreeNode(final String elementId, final String displayText, fina this.displayText = displayText; this.textureId = textureId; this.isLeaf = true; - } + }* /** * This constructor can be used to create non leaf nodes as well as leaf nodes. @@ -66,12 +66,12 @@ 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. @@ -80,7 +80,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. @@ -89,7 +89,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. @@ -98,7 +98,7 @@ public String getDisplayText() { */ public String getTextureId() { return this.textureId; - } + }* /** * This checks if node is a leaf node. @@ -107,7 +107,7 @@ public String getTextureId() { */ public boolean isLeaf() { return this.isLeaf; - } + }* /** * Function to check if the node has children. @@ -116,9 +116,9 @@ public boolean isLeaf() { */ public boolean hasChildren() { if (this.isLeaf) return false; - + * return !this.children.isEmpty(); - } + }* /** * Appends a child node to this node @@ -129,9 +129,9 @@ 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,16 +142,16 @@ 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,22 +161,22 @@ 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() { 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 86ab147eb..20aa8bfe3 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 @@ -9,7 +9,9 @@ */ package de.unistuttgart.informatik.fius.icge.ui; -import java.util.List; +* + +import java.util.List;** /** @@ -19,28 +21,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 a274b7416..6bf8f1a4c 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 @@ -9,6 +9,7 @@ */ package de.unistuttgart.informatik.fius.icge.ui; +* /** * The task status used by a {@link GameWindow} to show the current task status. * @@ -16,7 +17,7 @@ * @version 1.0 */ public interface TaskStatusDisplay { - + * /** * Set the task information to be displayed. * 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 fd96eb55c..e47e1a912 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 @@ -8,7 +8,7 @@ * SPDX-License-Identifier: MIT */ package de.unistuttgart.informatik.fius.icge.ui; - + * /** * Enum describing the verification status of a task. */ 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 ee2a1eafe..1cefebe00 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 @@ -9,10 +9,11 @@ */ package de.unistuttgart.informatik.fius.icge.ui; -import java.io.InputStream; -import java.util.function.Function; +* -import de.unistuttgart.informatik.fius.icge.ui.exception.TextureNotFoundException; +import java.io.InputStream; +import java.util.function.Function;* +import de.unistuttgart.informatik.fius.icge.ui.exception.TextureNotFoundException;** /** @@ -21,7 +22,7 @@ * @author Tim Neumann */ public interface TextureRegistry { - + * /** * Load an image from an internal resource as texture and return the handle to the texture. * @@ -42,7 +43,7 @@ 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. * @@ -53,7 +54,7 @@ public interface TextureRegistry { * @return the handle to retrieve the texture */ String createAnimatedTexture(boolean loop); - + * /** * Add a animation frame to an animated texture. * @@ -65,7 +66,7 @@ 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. * @@ -74,7 +75,7 @@ public interface TextureRegistry { * @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 f40679b4e..2984e1216 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 @@ -9,7 +9,9 @@ */ package de.unistuttgart.informatik.fius.icge.ui; -import de.unistuttgart.informatik.fius.icge.ui.internal.dropdown.DropdownSelector; +* + +import de.unistuttgart.informatik.fius.icge.ui.internal.dropdown.DropdownSelector;** /** @@ -20,7 +22,7 @@ * @version 1.0 */ public interface Toolbar { - + * /** * The clock button state represents the states of the clock buttons in the ui */ @@ -32,7 +34,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 +48,7 @@ enum ControlButtonState { /** Indicates that the user input is blocked or unavailable */ BLOCKED } - + * /** * Append the list of entities with the given entry * @@ -57,7 +59,7 @@ enum ControlButtonState { * @see DropdownSelector */ void addEntity(String displayName, String textureID); - + * /** * Set the state of the control buttons. * @@ -65,7 +67,7 @@ enum ControlButtonState { * The new state */ void setControlButtonState(ControlButtonState controlButtonState); - + * /** * Set the state of the clock buttons. * @@ -73,14 +75,14 @@ enum ControlButtonState { * 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. * @@ -88,14 +90,14 @@ enum ControlButtonState { * 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. * @@ -103,12 +105,12 @@ enum ControlButtonState { * 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 1c1339ec5..b58bc5c69 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 @@ -9,23 +9,23 @@ */ package de.unistuttgart.informatik.fius.icge.ui; +* + import java.awt.GraphicsEnvironment; import java.lang.reflect.InvocationTargetException; -import java.awt.Font; - +import java.awt.Font;* import javax.swing.SwingUtilities; import javax.swing.UIDefaults; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; -import javax.swing.plaf.FontUIResource; - +import javax.swing.plaf.FontUIResource;* import de.unistuttgart.informatik.fius.icge.ui.internal.SwingConsole; import de.unistuttgart.informatik.fius.icge.ui.internal.SwingEntitySidebar; import de.unistuttgart.informatik.fius.icge.ui.internal.SwingGameWindow; import de.unistuttgart.informatik.fius.icge.ui.internal.SwingPlayfieldDrawer; import de.unistuttgart.informatik.fius.icge.ui.internal.SwingTaskStatusDisplay; import de.unistuttgart.informatik.fius.icge.ui.internal.SwingTextureRegistry; -import de.unistuttgart.informatik.fius.icge.ui.internal.SwingToolbar; +import de.unistuttgart.informatik.fius.icge.ui.internal.SwingToolbar;** /** @@ -36,22 +36,21 @@ * @author Tim Neumann */ public class WindowBuilder { - - private static boolean isDefaultLookAndFeelUpdated = false; - private static double dpiScale; - private static double fontScale; - - private String windowTitle = ""; + * + 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; + private volatile GameWindow window;* /** * Create a new WindowBuilder. */ public WindowBuilder() { this(WindowBuilder.getDeviceDpiScale()); - } + }* /** * Create a new WindowBuilder. @@ -62,14 +61,14 @@ public WindowBuilder() { 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; WindowBuilder.fontScale = ((dpiScale - 1) * 0.75) + 1; this.setUiDefaults(dpiScale, WindowBuilder.fontScale); } - } + }* /** * Get the scaling factor from the default display device. @@ -79,7 +78,7 @@ public WindowBuilder(double dpiScale) { private static double getDeviceDpiScale() { return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().getDefaultTransform() .getScaleX(); - } + }* /** * Set the UI Manager defaults forlook and feeel and dpi scaling. @@ -110,7 +109,7 @@ private void setUiDefaults(double dpiScale, double fontScale) { } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { System.err.println("Can't set look and feel because of: " + e.toString()); } - } + }* /** * Set the title of the new window. @@ -126,9 +125,9 @@ private void setUiDefaults(double dpiScale, double fontScale) { 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."); - + * this.windowTitle = title; - } + }* /** * Set the graphics settings of the playfield drawer. @@ -147,10 +146,10 @@ public void setTitle(final String title) { 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."); - + * this.useDoubleBuffering = useDoubleBuffering; this.syncToScreen = syncToScreen; - } + }* /** * Actually build the window. @@ -168,7 +167,7 @@ public void buildWindow() { // TODO better exception handling System.err.println("Can't build the window because of: " + e.toString()); } - } + }* /** * Build the window. @@ -182,15 +181,15 @@ 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. @@ -199,7 +198,7 @@ private void buildWindowInternal() { */ 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 144d389c8..d462e5a2a 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 @@ -9,6 +9,7 @@ */ package de.unistuttgart.informatik.fius.icge.ui.exception; +* /** * The LeafNodeException is thrown when someone tries to add a child node to a leaf node or interact with the child * nodes of a leaf node. @@ -18,7 +19,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 6a772cf81..dfb85d75c 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 @@ -9,6 +9,7 @@ */ package de.unistuttgart.informatik.fius.icge.ui.exception; +* /** * The ListenerSetException is thrown if a set listener function in the SimulationProxy fails * @@ -17,7 +18,7 @@ */ 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 84728316f..3dfe64792 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 @@ -9,16 +9,17 @@ */ package de.unistuttgart.informatik.fius.icge.ui.exception; +* /** * 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 +29,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 c75bca1ed..e0ee595d0 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 @@ -9,9 +9,11 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal; +* + import java.awt.Graphics; import java.awt.Image; -import java.util.ArrayList; +import java.util.ArrayList;** /** @@ -20,11 +22,11 @@ * @author Fabian Bühler */ public class AnimatedTexture implements Texture { - + * private final SwingTextureRegistry registry; private final ArrayList animationFrames; private long duration; - private final boolean loop; + private final boolean loop;* /** * Create a new animated Texture. @@ -39,7 +41,7 @@ public AnimatedTexture(final SwingTextureRegistry registry, final boolean loop) this.animationFrames = new ArrayList<>(); this.duration = 0; this.loop = loop; - } + }* /** * Add a texture at the end of the animation. @@ -56,7 +58,7 @@ public void addAnimationFrame(final String frameTexture, final long frames) { this.duration += frames; final AnimationFrame frame = new AnimationFrame(last, last + (frames - 1), texture); this.animationFrames.add(frame); - } + }* /** * Get the texture for the current frame. @@ -67,7 +69,7 @@ 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. @@ -80,7 +82,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; @@ -97,23 +99,23 @@ private Texture getTextureForTick(final long frame, final long animationStart) { if ((animFrame.startFrame <= animationFrame) && (animFrame.endFrame >= animationFrame)) return animFrame.texture; } 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 57f2ff3f7..3b7665e30 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 @@ -9,17 +9,18 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal; +* + import java.awt.Color; import java.io.IOException; -import java.io.OutputStream; - +import java.io.OutputStream;* import javax.swing.JTextPane; import javax.swing.SwingUtilities; import javax.swing.Timer; import javax.swing.text.BadLocationException; import javax.swing.text.Style; import javax.swing.text.StyleConstants; -import javax.swing.text.StyledDocument; +import javax.swing.text.StyledDocument;** /** @@ -41,17 +42,15 @@ * @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; - + 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; + private final StringBuilder lineBuffer;* /** * Default Constructor @@ -65,7 +64,7 @@ public class ConsoleBufferedOutputStream extends OutputStream { */ public ConsoleBufferedOutputStream(final JTextPane textPane, final OutputStyle style) { this(textPane, style, DEFAULT_MAX_BUFFER_LENGTH); - } + }* /** * Constructor with maxBufferLenght included @@ -81,10 +80,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 +93,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 @@ -105,45 +104,45 @@ 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(() -> { @@ -157,7 +156,7 @@ private void flushLineBufferToTextPane() throws IOException { } }); } - } + }* /** * Get's {@link #maxBufferLength maxBufferLength} @@ -166,6 +165,5 @@ private void flushLineBufferToTextPane() throws IOException { */ 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 da399d887..756a072a2 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 @@ -9,16 +9,17 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal; +* /** * 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 9e99fdfb7..4d5f2d38a 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 @@ -9,8 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal; +* + import java.awt.Graphics; -import java.awt.Image; +import java.awt.Image;** /** @@ -19,9 +21,9 @@ * @author Fabian Bühler */ public class StaticTexture implements Texture { - + * private final Image texture; - + * /** * Create a new Texture. * @@ -31,12 +33,12 @@ public class StaticTexture implements 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 de64140a8..ba5b3162e 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 @@ -9,7 +9,9 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal; -import de.unistuttgart.informatik.fius.icge.ui.TextureRegistry; +* + +import de.unistuttgart.informatik.fius.icge.ui.TextureRegistry;** /** @@ -19,23 +21,22 @@ * @version 1.0 */ public abstract class StaticUiTextures { - + * /** A play icon */ - public static String playIcon; + public static String playIcon; /** A step icon */ - public static String stepIcon; + public static String stepIcon; /** A pause icon */ - public static String pauseIcon; + public static String pauseIcon; /** A stop icon */ @Deprecated - public static String stopIcon; - + public static String stopIcon;* /** A arrow icon */ - public static String arrowIcon; + public static String arrowIcon; /** A add icon */ - public static String addIcon; + public static String addIcon; /** A sub icon */ - public static String subIcon; + public static String subIcon;* /** * This function loads all textures into the given texture registry and stores the icon ids @@ -48,7 +49,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 3b588be2a..345b000e1 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 @@ -9,16 +9,16 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal; -import java.awt.Font; -import java.io.IOException; +* +import java.awt.Font; +import java.io.IOException;* import javax.swing.JTextPane; import javax.swing.SwingUtilities; import javax.swing.text.DefaultCaret; -import javax.swing.text.DefaultStyledDocument; - +import javax.swing.text.DefaultStyledDocument;* import de.unistuttgart.informatik.fius.icge.log.Logger; -import de.unistuttgart.informatik.fius.icge.ui.Console; +import de.unistuttgart.informatik.fius.icge.ui.Console;** /** @@ -30,10 +30,9 @@ * @version 2.0 */ public class SwingConsole extends JTextPane implements Console { - private static final long serialVersionUID = 5100186594058483257L; - + private static final long serialVersionUID = 5100186594058483257L;* private ConsoleBufferedOutputStream systemOutputStream; - private ConsoleBufferedOutputStream systemErrorStream; + private ConsoleBufferedOutputStream systemErrorStream;* /** * Default constructor @@ -45,25 +44,25 @@ public class SwingConsole extends JTextPane implements Console { */ 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 395bf4dd9..d7cd3c718 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 @@ -9,6 +9,8 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal; +* + import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; @@ -18,39 +20,32 @@ import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; -import java.util.function.Consumer; - +import java.util.function.Consumer;* import javax.swing.JButton; import javax.swing.JFormattedTextField; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingUtilities; -import javax.swing.text.NumberFormatter; - -import de.unistuttgart.informatik.fius.icge.ui.EntityInspectorEntry; +import javax.swing.text.NumberFormatter;* +import de.unistuttgart.informatik.fius.icge.ui.EntityInspectorEntry;** /** * EntityInspector */ public class SwingEntityInspector extends JPanel { - private static final long serialVersionUID = 1L; - - private final GridBagConstraints gbc; - + private static final long serialVersionUID = 1L;* + private final GridBagConstraints gbc;* /** The name at the top */ - private final JLabel title; - + private final JLabel title;* /** The JPanel containing all the ui elements */ - private JPanel inspector; - + private JPanel inspector;* /** The user warning at the bottom */ - private final JLabel warning; - - private Object updateLock = new Object(); - private EntityInspectorEntry[] currentEntries; - private List> uiValueUpdaters; + private final JLabel warning;* + private Object updateLock = new Object(); + private EntityInspectorEntry[] currentEntries; + private List> uiValueUpdaters;* /** * Default constructor @@ -62,26 +57,26 @@ public class SwingEntityInspector extends JPanel { */ 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 @@ -91,7 +86,7 @@ public SwingEntityInspector(final SwingTextureRegistry textureRegistry) { @Override public String getName() { return this.title.getText(); - } + }* /** * Setter for the inspector name @@ -105,7 +100,7 @@ public void setName(final String name) { this.title.setText(name); return; } - + * // cannot call invokeAndWait when already in EventDispatchThread! try { SwingUtilities.invokeAndWait(() -> { @@ -114,7 +109,7 @@ public void setName(final String name) { } catch (InvocationTargetException | InterruptedException e) { System.err.println("Failed to set entity inspector name because of: " + e.toString()); } - } + }* /** * Update the entity inspector to reflect the new Values. @@ -131,15 +126,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,32 +142,32 @@ 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. @@ -193,7 +188,7 @@ private boolean canUpdateValuesOnly(final EntityInspectorEntry[] entries) { // only value can differ for updates without complete redraws! } return true; - } + }* /** * Callback to change the value of an entry. @@ -213,7 +208,7 @@ private void updateValueOnEntity(int index, String name, String value) { EntityInspectorEntry entry = this.currentEntries[index]; if (!entry.getName().equals(name)) return; entry.runCallback(value); - } + }* /** * Add a entry to the ui editor @@ -228,14 +223,14 @@ private void updateValueOnEntity(int index, String name, String value) { * @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,12 +271,12 @@ 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,19 +288,19 @@ 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 @@ -317,14 +312,14 @@ 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); } component.setEnabled(state); } - } + }* @Override public Dimension getPreferredSize() { 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 cd9757672..aff1a118f 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 @@ -9,12 +9,13 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal; +* + import java.awt.BorderLayout; import java.awt.Dimension; import java.util.ArrayList; import java.util.Enumeration; -import java.util.List; - +import java.util.List;* import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; @@ -24,12 +25,11 @@ import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeNode; -import javax.swing.tree.TreePath; - +import javax.swing.tree.TreePath;* import de.unistuttgart.informatik.fius.icge.ui.EntityInspectorEntry; import de.unistuttgart.informatik.fius.icge.ui.EntitySidebar; import de.unistuttgart.informatik.fius.icge.ui.SimulationProxy; -import de.unistuttgart.informatik.fius.icge.ui.SimulationTreeNode; +import de.unistuttgart.informatik.fius.icge.ui.SimulationTreeNode;** /** @@ -40,21 +40,19 @@ * @version 1.0 */ public class SwingEntitySidebar extends JPanel implements EntitySidebar { - private static final long serialVersionUID = -4409545257025298208L; - + private static final long serialVersionUID = -4409545257025298208L;* /** The simulation proxy */ private SimulationProxy simulationProxy; /** The texture registry */ - private final SwingTextureRegistry textureRegistry; - + private final SwingTextureRegistry textureRegistry;* /** The root node of the entity list */ - private SimulationTreeNode rootNode; + private SimulationTreeNode rootNode; /** The hierarchical list of all entities */ - private JTree entityList; + private JTree entityList; /** The model of the JTree component */ - private DefaultTreeModel entityListModel; + private DefaultTreeModel entityListModel; /** The entity inspector in the sidebar */ - private SwingEntityInspector entityInspector; + private SwingEntityInspector entityInspector;* /** * The default constructor @@ -69,7 +67,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 +82,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,21 +90,21 @@ 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,9 +114,9 @@ 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) { @@ -129,7 +127,7 @@ public void setSimulationTreeRootNode(final SimulationTreeNode treeNode) { // As this method itself is using invoke later, it does not need to be in the block above. // 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; @@ -138,18 +136,18 @@ private void getExpandedTreePaths(final List expanded, final TreePath expanded.add(p); 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. @@ -166,31 +164,31 @@ private void updateSimulationTreeInternal() { for (final TreePath p : expanded) { 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 +198,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,20 +208,20 @@ 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} @@ -235,7 +233,7 @@ private static void updateTreeNodeChildren(final DefaultMutableTreeNode node) { */ private static DefaultMutableTreeNode generateDefaultMutableTreeNodeFromSimulationTreeNode(final SimulationTreeNode node) { final DefaultMutableTreeNode returnNode = new DefaultMutableTreeNode(node); - + * if (node.isLeaf()) { returnNode.setAllowsChildren(false); } else { @@ -244,24 +242,24 @@ private static DefaultMutableTreeNode generateDefaultMutableTreeNodeFromSimulati .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() { @@ -269,22 +267,22 @@ public void disbaleSimulationTree() { this.entityList.setEnabled(false); 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() { 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 a43a27610..d1e426ebb 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 @@ -9,12 +9,13 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal; +* + import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - +import java.awt.event.WindowEvent;* import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; @@ -24,8 +25,7 @@ import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.UIManager; -import javax.swing.WindowConstants; - +import javax.swing.WindowConstants;* import de.unistuttgart.informatik.fius.icge.ui.Console; import de.unistuttgart.informatik.fius.icge.ui.EntitySidebar; import de.unistuttgart.informatik.fius.icge.ui.GameWindow; @@ -33,7 +33,7 @@ import de.unistuttgart.informatik.fius.icge.ui.SimulationProxy; import de.unistuttgart.informatik.fius.icge.ui.TaskStatusDisplay; import de.unistuttgart.informatik.fius.icge.ui.TextureRegistry; -import de.unistuttgart.informatik.fius.icge.ui.Toolbar; +import de.unistuttgart.informatik.fius.icge.ui.Toolbar;** /** @@ -44,16 +44,14 @@ * @version 1.0 */ public class SwingGameWindow extends JFrame implements GameWindow { - private static final long serialVersionUID = -7215617949088643819L; - + 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; + private final SwingTaskStatusDisplay taskStatus;* + private SimulationProxy simulationProxy;* /** * Create a new Swing game window using the given submodules. @@ -82,7 +80,7 @@ public SwingGameWindow( this.console = console; this.taskStatus = taskStatus; SwingUtilities.invokeLater(this::initGameWindow); - } + }* @Override public void setSimulationProxy(final SimulationProxy simulationProxy) { @@ -92,55 +90,55 @@ public void setSimulationProxy(final SimulationProxy simulationProxy) { this.toolbar.setSimulationProxy(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 +148,7 @@ public void stop() { @SuppressWarnings("unused") // Suppress unused warnings on 'ClassCastException e' private void initGameWindow() { // init jFrame - + * // // setup window closing // @@ -161,9 +159,9 @@ public void windowClosing(final WindowEvent e) { SwingGameWindow.this.cleanup(); // stop simulation etc. } }); - + * this.playfieldDrawer.initialize(); - + * // // convert toolbar // @@ -173,7 +171,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 +181,7 @@ public void windowClosing(final WindowEvent e) { } catch (ClassCastException | NullPointerException e) { sidebarComponent = new JLabel(UIManager.getIcon("OptionPane.warningIcon"), SwingConstants.CENTER); } - + * // // convert console // @@ -193,7 +191,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 +199,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,12 +210,12 @@ 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 03217ab0a..b9245da5f 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 @@ -9,6 +9,8 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal; +* + import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -18,16 +20,14 @@ import java.util.List; import java.util.NoSuchElementException; import java.util.Optional; -import java.util.stream.Collectors; - +import java.util.stream.Collectors;* import javax.swing.JPanel; import javax.swing.RepaintManager; -import javax.swing.SwingUtilities; - +import javax.swing.SwingUtilities;* import de.unistuttgart.informatik.fius.icge.ui.Drawable; import de.unistuttgart.informatik.fius.icge.ui.PlayfieldDrawer; import de.unistuttgart.informatik.fius.icge.ui.SimulationProxy; -import de.unistuttgart.informatik.fius.icge.ui.Toolbar.ControlButtonState; +import de.unistuttgart.informatik.fius.icge.ui.Toolbar.ControlButtonState;** /** @@ -36,63 +36,51 @@ * @author Tim Neumann */ public class SwingPlayfieldDrawer extends JPanel implements PlayfieldDrawer { - + * /** * generated */ - private static final long serialVersionUID = 1800137555269066525L; - + 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; - + 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 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; - + );* + private final SwingTextureRegistry textureRegistry;* // current display offset and zoom private double offsetX; private double offsetY; - private double scale = 1.0; - + private double scale = 1.0;* // mouse events private boolean mouseInWindow = false; private int currentMouseX = 0; private int currentMouseY = 0; private int mouseStartX = 0; private int mouseStartY = 0; - private boolean isDrag = false; - + 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; - + 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; + private boolean syncToscreen = true;* + private double dpiScale;* + private Font scaleFont; + private Font font;* /** * Create a new SwingPlayfieldDrawer. @@ -106,21 +94,21 @@ 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,9 +118,9 @@ 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. @@ -140,60 +128,60 @@ public void setSimulationProxy(final SimulationProxy simulationProxy) { * 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(); final int y = e.getY(); SwingPlayfieldDrawer.this.updateZoom(rot, x, y); }); - } + }* @Override public void setDrawables(final List drawables) { @@ -203,7 +191,7 @@ public void setDrawables(final List drawables) { .collect(Collectors.toUnmodifiableList()); this.fullRepaintNeeded = true; this.draw(this.currentFrame); - } + }* @Override public void draw(final long tickCount) { @@ -212,16 +200,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) { @@ -272,7 +260,7 @@ public void draw(final long tickCount) { this.animatedDrawables = this.drawables.stream() .filter(d -> d.isAnimated() || this.textureRegistry.isTextureAnimated(d.getTextureHandle())) .collect(Collectors.toUnmodifiableList()); - } + }* @Override public void resetZoomAndPan() { @@ -282,42 +270,42 @@ public void resetZoomAndPan() { Font font = this.getFont(); 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) { @@ -329,7 +317,7 @@ public void paintComponent(final Graphics g) { this.paintGrid(g); this.paintDrawableList(g, this.drawables); this.paintOverlay(g); - } + }* private void paintGrid(final Graphics g) { final Rectangle clipBounds = g.getClipBounds(); @@ -339,7 +327,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); @@ -353,7 +341,7 @@ private void paintGrid(final Graphics g) { final int iy = (int) y; g.drawLine(0, iy, width, iy); } - } + }* /** * Compare two drawables and checks if they can be grouped together. @@ -374,7 +362,7 @@ private static boolean canGroupDrawables(final Drawable a, final Drawable b) { if (Math.abs(a.getX() - b.getX()) > 0.001) return false; 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; @@ -382,7 +370,7 @@ private void paintDrawableList(final Graphics g, final List drawablesL Drawable last = null; int currentCount = 0; boolean isTilable = true; - + * // group and count drawables while (iter.hasNext()) { final Drawable next = iter.next(); @@ -401,7 +389,7 @@ private void paintDrawableList(final Graphics g, final List drawablesL if (last != null) { 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; @@ -428,7 +416,7 @@ private void paintDrawable(final Graphics g, final Drawable drawable, final int final Double[] yOffsets = { 0.0, 0.0, 0.0, third, third, third, twoThird, twoThird, twoThird }; 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, @@ -455,7 +443,7 @@ private void paintMultiCountDrawable( texture.drawTexture(this.currentFrame, g, x, y, textureSize, textureSize); } } - } + }* private void drawNumber(int count, Graphics g, int x, int y) { final double cellSize = this.CELL_SIZE * this.scale; @@ -474,20 +462,20 @@ 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 +496,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("")) { @@ -568,12 +556,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; @@ -582,18 +570,18 @@ private void updateMousePosition(final int x, final int y) { this.currentMouseY = 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; @@ -603,7 +591,7 @@ private void updateDrag(final int x, final int y) { this.mouseStartX = x; 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); @@ -622,17 +610,17 @@ 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) { 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 be56839c3..6696dbc0d 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 @@ -9,10 +9,11 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal; +* + import java.awt.BorderLayout; import java.awt.Color; -import java.util.List; - +import java.util.List;* import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -23,11 +24,10 @@ import javax.swing.text.DefaultStyledDocument; import javax.swing.text.Style; import javax.swing.text.StyleConstants; -import javax.swing.text.StyledDocument; - +import javax.swing.text.StyledDocument;* import de.unistuttgart.informatik.fius.icge.ui.SimulationProxy; import de.unistuttgart.informatik.fius.icge.ui.TaskInformation; -import de.unistuttgart.informatik.fius.icge.ui.TaskStatusDisplay; +import de.unistuttgart.informatik.fius.icge.ui.TaskStatusDisplay;** /** @@ -37,17 +37,14 @@ * @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; + * + 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. @@ -59,27 +56,27 @@ public class SwingTaskStatusDisplay extends JPanel implements TaskStatusDisplay */ 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,11 +84,11 @@ 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,9 +98,9 @@ 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) { @@ -118,7 +115,7 @@ public void setTaskInformation(final TaskInformation task) { this.appendText(document, "You can set a task verifier in the SimulationBuilder.", this.textStyle); } }); - } + }* /** * Appends the task information of the task and all subtasks to the styled document. @@ -131,14 +128,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 +148,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) { @@ -166,7 +163,7 @@ private void appendTaskInformation(final TaskInformation task, final StyledDocum this.appendTaskInformation(subTask, document, depth + 1); } } - } + }* /** * Appends text to a styled document while silently dismissing {@link BadLocationException}. @@ -184,7 +181,7 @@ private void appendText(final StyledDocument document, final String text, final } catch (final BadLocationException e) { e.printStackTrace(); } - } + }* /** * This function appends indentation spaces to a string @@ -197,21 +194,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 b77ee3c9d..539c29d29 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 @@ -9,6 +9,8 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal; +* + import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; @@ -20,12 +22,10 @@ import java.util.NoSuchElementException; import java.util.Set; import java.util.UUID; -import java.util.function.Function; - -import javax.imageio.ImageIO; - +import java.util.function.Function;* +import javax.imageio.ImageIO;* import de.unistuttgart.informatik.fius.icge.ui.TextureRegistry; -import de.unistuttgart.informatik.fius.icge.ui.exception.TextureNotFoundException; +import de.unistuttgart.informatik.fius.icge.ui.exception.TextureNotFoundException;** /** @@ -36,17 +36,17 @@ * @version 1.0 */ public class SwingTextureRegistry implements TextureRegistry { - private final Map resourceToHandle = new HashMap<>(); - private final Map pathToHandle = new HashMap<>(); - private final Set animatedTextures = new HashSet<>(); - private final Map handleToTexture = new HashMap<>(); + private final Map resourceToHandle = new HashMap<>(); + 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. @@ -55,7 +55,7 @@ public SwingTextureRegistry() { */ private static String generateNewTextureHandle() { return UUID.randomUUID().toString(); - } + }* /** * Load a texture from a local (ui module) resource. @@ -67,7 +67,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) { @@ -81,7 +81,7 @@ public String loadTextureFromResource(final String resourceName, final Function< } catch (IllegalArgumentException | IOException e) { throw new TextureNotFoundException("The requested Resource could not be loaded!", e); } - } + }* @Override public String loadTextureFromFile(final String filePath) { @@ -98,18 +98,18 @@ public String loadTextureFromFile(final String filePath) { throw new TextureNotFoundException("The requested path could not be loaded!", e); } 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) { @@ -119,12 +119,12 @@ public void addAnimationFrameToTexture(final String animatedTexture, final Strin } catch (final ClassCastException e) { 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 453fd6bd8..2ef0991e0 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 @@ -9,9 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal; -import java.awt.event.ItemEvent; -import java.util.Hashtable; +* +import java.awt.event.ItemEvent; +import java.util.Hashtable;* import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; @@ -20,13 +21,12 @@ import javax.swing.JToggleButton; import javax.swing.JToolBar; import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; - +import javax.swing.SwingUtilities;* import de.unistuttgart.informatik.fius.icge.ui.SimulationProxy; import de.unistuttgart.informatik.fius.icge.ui.SimulationProxy.ButtonType; import de.unistuttgart.informatik.fius.icge.ui.Toolbar; import de.unistuttgart.informatik.fius.icge.ui.internal.dropdown.DropdownSelector; -import de.unistuttgart.informatik.fius.icge.ui.internal.dropdown.DropdownSelector.DropdownEntry; +import de.unistuttgart.informatik.fius.icge.ui.internal.dropdown.DropdownSelector.DropdownEntry;** /** @@ -38,32 +38,27 @@ * @version 1.0 */ public class SwingToolbar extends JToolBar implements Toolbar { - private static final long serialVersionUID = -2525998620577603876L; - + private static final long serialVersionUID = -2525998620577603876L;* /** The simulation proxy */ private SimulationProxy simulationProxy; /** The texture registry */ - private final SwingTextureRegistry textureRegistry; - + private final SwingTextureRegistry textureRegistry;* /** The play button in the toolbar */ - private JButton play; + private JButton play; /** The step button in the toolbar */ - private JButton step; + private JButton step; /** The pause button in the toolbar */ - private JButton pause; - + private JButton pause;* /** A slider to set the simulation time */ - private JSlider simulationTime; - + private JSlider simulationTime;* /** The button to change to view mode */ - private JToggleButton view; + private JToggleButton view; /** The button to change to add mode */ - private JToggleButton add; + private JToggleButton add; /** The button to change to sub mode */ - private JToggleButton sub; - + private JToggleButton sub;* /** The selector which selects the entity for the user to place */ - private DropdownSelector entitySelect; + private DropdownSelector entitySelect;* /** * The constructor of the toolbar @@ -80,12 +75,12 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi // class setup // this.textureRegistry = textureRegistry; - + * // // toolbar setup // this.setFloatable(false); - + * // // play button setup // @@ -97,7 +92,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi }); this.play.setEnabled(false); this.add(this.play); - + * // // step button setup // @@ -109,7 +104,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi }); this.step.setEnabled(false); this.add(this.step); - + * // // pause button setup // @@ -121,7 +116,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi }); this.pause.setEnabled(false); this.add(this.pause); - + * // // simulation time slider setup // @@ -142,7 +137,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 +147,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 +164,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi }); this.view.setEnabled(false); this.add(this.view); - + * // // add button setup // @@ -181,7 +176,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi }); this.add.setEnabled(false); this.add(this.add); - + * // // sub button setup // @@ -193,7 +188,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi }); this.sub.setEnabled(false); this.add(this.sub); - + * // // entity selector setup // @@ -208,7 +203,7 @@ public SwingToolbar(final SwingTextureRegistry textureRegistry, final double dpi }); this.entitySelect.setEnabled(false); this.add(this.entitySelect); - } + }* /** * @@ -217,16 +212,16 @@ 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) { @@ -235,33 +230,33 @@ 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) { @@ -285,17 +280,17 @@ private void setClockButtonStateInternal(final ClockButtonState clockButtonState break; 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) { @@ -305,28 +300,28 @@ public void setSpeedSliderPosition(final int position) { "Simulation Speed Value is out of bounds. Should be between 0 and 10 (both inclusive) but is: " + 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() { @@ -334,6 +329,5 @@ public void disableEntitySelector() { this.entitySelect.removeAllEntries(); 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 73e5cc517..4d88d7b80 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 @@ -9,8 +9,10 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal; +* + import java.awt.Graphics; -import java.awt.Image; +import java.awt.Image;** /** @@ -19,7 +21,7 @@ * @author Fabian Bühler */ public interface Texture { - + * /** * Get the texture image. * @@ -28,7 +30,7 @@ public interface Texture { default Image getTexture() { return this.getTexture(0); } - + * /** * Get the texture image. * @@ -37,7 +39,7 @@ default Image getTexture() { * @return the image */ Image getTexture(long frame); - + * /** * Draw the texture onto the screen. *

@@ -57,7 +59,7 @@ 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. *

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 93cc766c2..3aac87d24 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 @@ -9,20 +9,20 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal.dropdown; +* + import java.awt.Color; import java.awt.Component; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; -import java.awt.Insets; - +import java.awt.Insets;* import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; -import javax.swing.plaf.basic.BasicComboBoxEditor; - +import javax.swing.plaf.basic.BasicComboBoxEditor;* import de.unistuttgart.informatik.fius.icge.ui.internal.SwingTextureRegistry; -import de.unistuttgart.informatik.fius.icge.ui.internal.dropdown.DropdownSelector.DropdownEntry; +import de.unistuttgart.informatik.fius.icge.ui.internal.dropdown.DropdownSelector.DropdownEntry;** /** @@ -32,13 +32,12 @@ * @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; + private final SwingTextureRegistry textureRegistry;* + private final JPanel panel; + private final JLabel labelItem; + private DropdownEntry selectedValue;* /** * Constructor for the DropdownItemEditor @@ -50,7 +49,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 +57,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 2a085d0a5..83becc192 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 @@ -9,21 +9,21 @@ */ package de.unistuttgart.informatik.fius.icge.ui.internal.dropdown; +* + import java.awt.Color; import java.awt.Component; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; -import java.awt.Insets; - +import java.awt.Insets;* import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.ListCellRenderer; -import javax.swing.SwingConstants; - +import javax.swing.SwingConstants;* import de.unistuttgart.informatik.fius.icge.ui.internal.SwingTextureRegistry; -import de.unistuttgart.informatik.fius.icge.ui.internal.dropdown.DropdownSelector.DropdownEntry; +import de.unistuttgart.informatik.fius.icge.ui.internal.dropdown.DropdownSelector.DropdownEntry;** /** @@ -33,12 +33,10 @@ * @version 1.0 */ class DropdownItemRenderer extends JPanel implements ListCellRenderer { - private static final long serialVersionUID = 2930839533138981414L; - + private static final long serialVersionUID = 2930839533138981414L;* /** The texture registry */ - private final SwingTextureRegistry textureRegistry; - - private final JLabel labelItem; + private final SwingTextureRegistry textureRegistry;* + private final JLabel labelItem;* /** * Constructor for the DropdownItemRenderer @@ -50,20 +48,20 @@ class DropdownItemRenderer extends JPanel implements ListCellRenderer comboBox; - + private final SwingTextureRegistry textureRegistry;* + private final JLabel label; + private final JComboBox comboBox;* /** The data model of the DropdownSelector */ - private final DefaultComboBoxModel model; + private final DefaultComboBoxModel model;* /** * Constructor of the DropdownSelector @@ -95,19 +93,19 @@ 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 @@ -116,7 +114,7 @@ public DropdownSelector(final SwingTextureRegistry textureRegistry, final String */ public DropdownEntry getCurrentEntry() { return (DropdownEntry) this.comboBox.getEditor().getItem(); - } + }* /** * Setter for the currently selected entry @@ -130,7 +128,7 @@ public DropdownEntry getCurrentEntry() { */ public void setCurrentEntry(final DropdownEntry entry) { this.comboBox.getEditor().setItem(entry); - } + }* /** * This function adds an entry to the selector @@ -143,12 +141,12 @@ 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 @@ -157,7 +155,7 @@ public void addEntry(final DropdownEntry... entries) { */ public void removeAllEntries() { this.model.removeAllElements(); - } + }* /** * Adds a listener which reacts to the selection and deselection of items @@ -169,7 +167,7 @@ public void removeAllEntries() { */ public void addSelectionListener(final ItemListener listener) { this.comboBox.addItemListener(listener); - } + }* @Override public void setEnabled(final boolean enabled) { diff --git a/ICGE-Ui/src/main/java/module-info.java b/ICGE-Ui/src/main/java/module-info.java index 2c89b3efa..e334b157a 100644 --- a/ICGE-Ui/src/main/java/module-info.java +++ b/ICGE-Ui/src/main/java/module-info.java @@ -10,7 +10,7 @@ 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 336a8e855..e48a8391e 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 @@ -9,22 +9,21 @@ */ package de.unistuttgart.informatik.fius.icge.ui; -import java.lang.reflect.InvocationTargetException; - -import javax.swing.SwingUtilities; +* +import java.lang.reflect.InvocationTargetException;* +import javax.swing.SwingUtilities;* import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - +import org.junit.jupiter.api.Test;* import de.unistuttgart.informatik.fius.icge.ui.internal.SwingConsole; import de.unistuttgart.informatik.fius.icge.ui.internal.SwingEntitySidebar; import de.unistuttgart.informatik.fius.icge.ui.internal.SwingGameWindow; import de.unistuttgart.informatik.fius.icge.ui.internal.SwingPlayfieldDrawer; import de.unistuttgart.informatik.fius.icge.ui.internal.SwingTaskStatusDisplay; import de.unistuttgart.informatik.fius.icge.ui.internal.SwingTextureRegistry; -import de.unistuttgart.informatik.fius.icge.ui.internal.SwingToolbar; +import de.unistuttgart.informatik.fius.icge.ui.internal.SwingToolbar;** /** @@ -33,8 +32,8 @@ * @author Tim Neumann */ class SwingGameWindowUiTest { - - private SwingGameWindow window; + * + private SwingGameWindow window;* /** * Setup the game window @@ -51,10 +50,10 @@ 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/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/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..72d2fecf6 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 */ 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/scriptsAndTools/#correctJavaFileComment.txt# b/scriptsAndTools/#correctJavaFileComment.txt# new file mode 100644 index 000000000..ac876acd5 --- /dev/null +++ b/scriptsAndTools/#correctJavaFileComment.txt# @@ -0,0 +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 + */ \ No newline at end of file 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 */