Skip to content

Commit

Permalink
[cleanup] Fixed a many minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
meronbrouwer committed Sep 22, 2023
1 parent 2982929 commit f3dc301
Show file tree
Hide file tree
Showing 56 changed files with 177 additions and 233 deletions.
14 changes: 7 additions & 7 deletions docs/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ program will come to a grinding halt.
The debugger keeps track of the number of Entities that are present on the
scene.

| Entity | Explanation |
| :--------- | :------------------------------------------------- |
| **Dynamic Entities** | Number of entities that extend `DynamicEntity` |
| **Static Entities** | Number of entities that extend `StaticEntity` |
| **Suppliers** | Number of objects that are able to supply entities to the scene. This means all instances of `EntitySpawner`, but also the Scene itself. |
| **Garbage** | Number of Entities that have been marked as garbage, by calling the `remove()` method. The will be removed from the Scene during the next Game World Update, which should result in a drop of *total used memory*|
| **Key listening entities**| Number of entities that implement `KeyListener` |
| Entity | Explanation |
|:---------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Dynamic Entities** | Number of entities that extend `DynamicEntity` |
| **Static Entities** | Number of entities that extend `StaticEntity` |
| **Suppliers** | Number of objects that are able to supply entities to the scene. This means all instances of `EntitySpawner`, but also the Scene itself. |
| **Garbage** | Number of Entities that have been marked as garbage, by calling the `remove()` method. The will be removed from the Scene during the next Game World Update, which should result in a drop of *total used memory* |
| **Key listening entities** | Number of entities that implement `KeyListener` |

## Loaded files

Expand Down
16 changes: 8 additions & 8 deletions docs/entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ denotes downward and 180 logically means upward.
There are several Entities available, which can be divided into four different
types:

| Static Entity | Dynamic Entity | Type |
| :---------------- | :------------------------ |:------------------|
| `SpriteEntity` | `DynamicSpriteEntity` | Sprite entity |
| `CircleEntity` | `DynamicCircleEntity` | Shape entity |
| `EllipseEntity` | `DynamicEllipseEntity` | Shape entity |
| `RectangleEntity` | `DynamicRectangleEntity` | Shape entity |
| `TextEntity` | `DynamicTextEntity` | Text entity |
| `CompositeEntity` | `DynamicCompositeEntity` | Composite entity |
| Static Entity | Dynamic Entity | Type |
|:------------------|:-------------------------|:-----------------|
| `SpriteEntity` | `DynamicSpriteEntity` | Sprite entity |
| `CircleEntity` | `DynamicCircleEntity` | Shape entity |
| `EllipseEntity` | `DynamicEllipseEntity` | Shape entity |
| `RectangleEntity` | `DynamicRectangleEntity` | Shape entity |
| `TextEntity` | `DynamicTextEntity` | Text entity |
| `CompositeEntity` | `DynamicCompositeEntity` | Composite entity |

The sprite, shape and text-entity are basic entities. The composite entity
is of a different type. It should be used whenever the entity should
Expand Down
2 changes: 1 addition & 1 deletion docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trivially possible to use JavaFX within Yaeger. This is by design.

## Required Java version

Although Yaeger only exposes a traditional Object Oriented API, internally its
Although Yaeger only exposes a traditional Object-Oriented API, internally its
based on modern Java. To see which specific version is required, please read
the [readme](https://github.com/han-yaeger/yaeger) on the project GitHub.

Expand Down
24 changes: 12 additions & 12 deletions docs/user-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ In case of a `ScrollableDynamicScene`, the instances of `Coordinate2D` that are
passed to the event handlers report the coordinates of the entire scene, not
only the viewport.

| Interface | EventHandler(s) |
| :-------------------------------- | :-------------------------------------------------------- |
| `KeyListener` | `void onPressedKeysChange(Set<KeyCode>)` | |
| `MouseButtonPressedListener` | `void onMouseButtonPressed(MouseButton, Coordinate2D)` |
| `MouseButtonReleasedListener` | `void onMouseButtonReleased(MouseButton, Coordinate2D)` |
| `MouseEnterListener` | `void onMouseEntered()` |
| `MouseExitListener` | `void onMouseExited()` |
| `MouseMovedListener` | `void onMouseMoved(Coordinate2D)` |
| `MouseMovedWhileDraggingListener` | `void onMouseMovedWhileDragging(Coordinate2D)` |
| Interface | EventHandler(s) |
|:----------------------------------|:--------------------------------------------------------------------|
| `KeyListener` | `void onPressedKeysChange(Set<KeyCode>)` | |
| `MouseButtonPressedListener` | `void onMouseButtonPressed(MouseButton, Coordinate2D)` |
| `MouseButtonReleasedListener` | `void onMouseButtonReleased(MouseButton, Coordinate2D)` |
| `MouseEnterListener` | `void onMouseEntered()` |
| `MouseExitListener` | `void onMouseExited()` |
| `MouseMovedListener` | `void onMouseMoved(Coordinate2D)` |
| `MouseMovedWhileDraggingListener` | `void onMouseMovedWhileDragging(Coordinate2D)` |
| `MouseDraggedListener` | `void onMouseDragged(Coordinate2D)`, `void onDropped(Coordinate2D)` |
| `MouseDragEnterListener` | `void onDragEntered(Coordinate2D, MouseDraggedListener)` |
| `MouseDragExitListener` | `void onDragExited(Coordinate2D, MouseDraggedListener)` |
| `MouseDropListener` | `void onDrop(Coordinate2D, MouseDraggedListener)` |
| `MouseDragEnterListener` | `void onDragEntered(Coordinate2D, MouseDraggedListener)` |
| `MouseDragExitListener` | `void onDragExited(Coordinate2D, MouseDraggedListener)` |
| `MouseDropListener` | `void onDrop(Coordinate2D, MouseDraggedListener)` |
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
*/
public abstract class CompositeEntity extends YaegerEntity {

List<YaegerEntity> entities = new ArrayList<>();
List<YaegerEntity> garbage = new ArrayList<>();
final List<YaegerEntity> entities = new ArrayList<>();
final List<YaegerEntity> garbage = new ArrayList<>();
Optional<Group> group = Optional.empty();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public double angleTo(final Coordinate2D otherLocation) {
* part of the {@link YaegerGame}. Since an {@link EntityCollection}
* contains different lists of Entities, a {@link YaegerEntity} itself is responsible for
* knowing to which list it should be added.
*
* <p>
* <b>Note that this method is for internal use only and should not be used when creating a {@link YaegerGame}</b>
*
* @param collection the {@link EntityCollection} to which this {@link YaegerEntity} should add itself
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* it can also be used to receive notification when the mouse is being moved while the mouse-button is down. In this it
* differs from a {@link MouseMovedListener}, which does not receive those events if the button is down.
* <p>
* On movement it will receive an event that contains a {@link Coordinate2D} of the x and y-coordinate.
* On movement, it will receive an event that contains a {@link Coordinate2D} of the x and y-coordinate.
*/
public interface MouseMovedWhileDraggingListener extends GameNode {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public @interface UpdatableProvider {
/**
* State whether the {@link Updatable} returned by the method annotated with this annotation should be added
* to the front of the list of instances of {@link Updatable}. By default it is placed at the end of the list,
* to the front of the list of instances of {@link Updatable}. By default, it is placed at the end of the list,
* which also means it is called last.
*
* @return a {@code boolean} that states whether the {@link Updatable} should be added at the front of the list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface Anchorable {
/**
* Set the {@link AnchorPoint} of this {@link Placeable}. The {@link AnchorPoint} can be used for aligning
* the {@link com.github.hanyaeger.api.entities.YaegerEntity}, and will be used
* to set the given x, y-coordinate. By default a {@link Placeable} will use the top-left as
* to set the given x, y-coordinate. By default, a {@link Placeable} will use the top-left as
* its anchor-point.
*
* @param anchorPoint the {@link AnchorPoint} of this {@link com.github.hanyaeger.api.entities.YaegerEntity}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void setStrokeColor(final Color strokeColor) {
/**
* Set the width of the stroke to be used.
*
* @param strokeWidth the with of the stroke as a {@code double}
* @param strokeWidth the width of the stroke as a {@code double}
*/
public void setStrokeWidth(final double strokeWidth) {
shape.ifPresentOrElse(s -> s.setStrokeWidth(strokeWidth), () -> this.strokeWidth = Optional.of(strokeWidth));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
public class InitializationBuffer {

private List<EventHandler> removeHandlers = new ArrayList<>();
private final List<EventHandler> removeHandlers = new ArrayList<>();
private double rotation;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public interface NewtonianModifier {
double getGravityConstant();

/**
* Set the gravitational direction used..
* Set the gravitational direction used.
*
* @param gravityDirection the gravitational direction as a {@code double}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/
public class KeyListenerDelegate {

Set<KeyCode> delayedInput = new HashSet<>();
Set<KeyCode> input = new HashSet<>();
final Set<KeyCode> delayedInput = new HashSet<>();
final Set<KeyCode> input = new HashSet<>();
private KeyListener keyListener;
private AnimationTimerFactory animationTimerFactory;
private AnimationTimer animationTimer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ class EntitySpawnerContainerTest {
public static final Long TIMESTAMP = 0L;
private EntitySpawnerContainerImpl sut;
private List<EntitySpawner> spawners;
private Injector injector;
private Pane pane;

@BeforeEach
void setup() {
sut = new EntitySpawnerContainerImpl();
spawners = mock(ArrayList.class);
injector = mock(Injector.class);
var injector = mock(Injector.class);
pane = mock(Pane.class);
sut.setSpawners(spawners);
sut.setInjector(injector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void multiplyPointWorksAsExpected() {
}

@Test
void multiplicationWithNullLeadsToNullpointer() {
void multiplicationWithNullLeadsToNullPointer() {
// Arrange
var position = new Coordinate2D(1D, 1D);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void updateOnUpdatableAddsToMotionIfGravitationalPullIsTrue() {
var updatable = sut.addSimplePhysics();

// Act
updatable.update(0l);
updatable.update(0L);

// Assert
verify(motionApplier).getGravityConstant();
Expand All @@ -181,15 +181,15 @@ void updateOnUpdatableAddsFrictionIfSpeedGTZero() {
var updatable = sut.addSimplePhysics();

// Act
updatable.update(0l);
updatable.update(0L);

// Assert
verify(motionApplier).getFrictionConstant();
verify(motionApplier).incrementSpeed(-1 * FRICTION_CONSTANT);
}
}

private class NewtonianImpl implements Newtonian {
private static class NewtonianImpl implements Newtonian {

private MotionApplier motionApplier;
private EntityMotionInitBuffer buffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,18 @@ class YaegerEntityTest {

private YaegerEntityImpl sut;
private Node node;
private Node otherNode;
private Injector injector;
private Scene scene;
private Pane pane;

@BeforeEach
void setup() {
sut = new YaegerEntityImpl(LOCATION);
injector = mock(Injector.class);
node = mock(Node.class, withSettings().withoutAnnotations());
otherNode = mock(Node.class, withSettings().withoutAnnotations());

sut.setNode(Optional.of(node));
scene = mock(Scene.class);
pane = mock(Pane.class);
var pane = mock(Pane.class);

var boundingBox = mock(BoundingBox.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void ifShapeNotYetSetRadiusIsStoredAndSetAtInit() {
verify(circle).setRadius(RADIUS);
}

private class CircleEntityImpl extends CircleEntity {
private static class CircleEntityImpl extends CircleEntity {

public CircleEntityImpl(Coordinate2D initialPosition) {
super(initialPosition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ class DynamicCircleEntityTest {

private DynamicCircleEntityImpl sut;
private Injector injector;
private Circle circle;

@BeforeEach
void setup() {
sut = new DynamicCircleEntityImpl(DEFAULT_LOCATION);
circle = mock(Circle.class);
var circle = mock(Circle.class);
sut.setShape(circle);
injector = mock(Injector.class);
}
Expand Down Expand Up @@ -160,7 +159,7 @@ void updateGetsDelegated() {
verify(updater).update(TIMESTAMP);
}

private class DynamicCircleEntityImpl extends DynamicCircleEntity {
private static class DynamicCircleEntityImpl extends DynamicCircleEntity {

/**
* Create a new {@link DynamicRectangleEntity} on the given {@code initialPosition}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

class DynamicEllipseEntityTest {

private final long TIMESTAMP = 0L;

private final static int X_POSITION = 37;
private final static int Y_POSITION = 37;
private final static Coordinate2D DEFAULT_LOCATION = new Coordinate2D(X_POSITION, Y_POSITION);
Expand Down Expand Up @@ -53,7 +51,7 @@ void bufferIsSetInConstructor() {
// Arrange

// Act
Optional<EntityMotionInitBuffer> buffer = sut.getBuffer();
var buffer = sut.getBuffer();

// Assert
assertTrue(buffer.isPresent());
Expand Down Expand Up @@ -164,13 +162,14 @@ void updateGetsDelegated() {
sut.setUpdater(updater);

// Act
long TIMESTAMP = 0L;
sut.update(TIMESTAMP);

// Assert
verify(updater).update(TIMESTAMP);
}

private class DynamicEllipsEntityImpl extends DynamicEllipseEntity {
private static class DynamicEllipsEntityImpl extends DynamicEllipseEntity {

public DynamicEllipsEntityImpl(Coordinate2D initialPosition) {
super(initialPosition);
Expand Down Expand Up @@ -205,7 +204,7 @@ void bufferIsSetInConstructor() {
assertTrue(buffer.isPresent());
}

private class DynamicEllipsEntityImpl extends DynamicEllipseEntity {
private static class DynamicEllipsEntityImpl extends DynamicEllipseEntity {

public DynamicEllipsEntityImpl(final Coordinate2D initialPosition, final Size size) {
super(initialPosition, size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

class DynamicRectangleEntityTest {

private final long TIMESTAMP = 0L;

private final static int X_POSITION = 37;
private final static int Y_POSITION = 37;
private final static Coordinate2D DEFAULT_LOCATION = new Coordinate2D(X_POSITION, Y_POSITION);
Expand Down Expand Up @@ -53,7 +51,7 @@ void bufferIsSetInConstructor() {
// Arrange

// Act
Optional<EntityMotionInitBuffer> buffer = sut.getBuffer();
var buffer = sut.getBuffer();

// Assert
assertTrue(buffer.isPresent());
Expand Down Expand Up @@ -164,13 +162,14 @@ void updateGetsDelegated() {
sut.setUpdater(updater);

// Act
long TIMESTAMP = 0L;
sut.update(TIMESTAMP);

// Assert
verify(updater).update(TIMESTAMP);
}

private class DynamicRectangleEntityImpl extends DynamicRectangleEntity {
private static class DynamicRectangleEntityImpl extends DynamicRectangleEntity {

public DynamicRectangleEntityImpl(final Coordinate2D initialPosition) {
super(initialPosition);
Expand Down Expand Up @@ -203,12 +202,11 @@ void bufferIsSetInConstructor() {
assertTrue(buffer.isPresent());
}

private class DynamicRectangleEntityImpl extends DynamicRectangleEntity {
private static class DynamicRectangleEntityImpl extends DynamicRectangleEntity {

public DynamicRectangleEntityImpl(final Coordinate2D initialPosition, final Size size) {
super(initialPosition, size);
}
}
}

}
Loading

0 comments on commit f3dc301

Please sign in to comment.