From e5c6fa634af92efce9ab7a1115c343770bb47190 Mon Sep 17 00:00:00 2001 From: "J. Neugebauer" Date: Wed, 20 Jul 2022 17:15:29 +0200 Subject: [PATCH] Anpassung der Package-Struktur --- CHANGELOG.md | 2 +- src/main/java/schule/ngb/zm/Gradient.java | 5 ---- .../java/schule/ngb/zm/Zeichenleinwand.java | 3 +-- .../java/schule/ngb/zm/Zeichenmaschine.java | 11 +++++---- .../java/schule/ngb/zm/anim/Animation.java | 4 +--- .../schule/ngb/zm/anim/AnimationListener.java | 2 +- .../java/schule/ngb/zm/anim/Animations.java | 6 ++--- .../ngb/zm/{ => layers}/ColorLayer.java | 6 ++++- .../ngb/zm/{ => layers}/DrawableLayer.java | 5 +++- .../ngb/zm/{ => layers}/DrawingLayer.java | 24 ++++++++++--------- .../ngb/zm/{ => layers}/ImageLayer.java | 3 ++- .../ngb/zm/{ => layers}/Shape2DLayer.java | 20 +++++++++------- .../zm/{shapes => layers}/ShapesLayer.java | 3 ++- .../zm/{turtle => layers}/TurtleLayer.java | 2 +- .../schule/ngb/zm/media/AudioListener.java | 2 +- src/main/java/schule/ngb/zm/media/Mixer.java | 2 +- src/main/java/schule/ngb/zm/media/Music.java | 6 ++--- .../ngb/zm/{ => shapes}/charts/BarChart.java | 2 +- .../{ => shapes}/charts/BasicChartValue.java | 2 +- .../ngb/zm/{ => shapes}/charts/ChartAxes.java | 3 +-- .../zm/{ => shapes}/charts/ChartValue.java | 2 +- .../ngb/zm/{ => shapes}/charts/LineChart.java | 3 +-- .../ngb/zm/{ => shapes}/charts/PieChart.java | 2 +- .../ngb/zm/{ => shapes}/charts/RingChart.java | 2 +- .../zm/{ => util}/events/EventDispatcher.java | 2 +- .../ngb/zm/{ => util}/events/Listener.java | 2 +- .../ngb/zm/{ => util}/tasks/DelayedTask.java | 5 +--- .../tasks/FrameSynchronizedTask.java | 2 +- .../tasks/FramerateLimitedTask.java | 2 +- .../zm/{ => util}/tasks/RateLimitedTask.java | 2 +- .../schule/ngb/zm/{ => util}/tasks/Task.java | 2 +- .../ngb/zm/{ => util}/tasks/TaskRunner.java | 3 +-- .../java/schule/ngb/zm/TestAttraction.java | 1 + src/test/java/schule/ngb/zm/TestTurtle.java | 4 ++-- .../schule/ngb/zm/anim/AnimationsTest.java | 1 + .../events/EventDispatcherTest.java | 2 +- 36 files changed, 77 insertions(+), 73 deletions(-) delete mode 100644 src/main/java/schule/ngb/zm/Gradient.java rename src/main/java/schule/ngb/zm/{ => layers}/ColorLayer.java (96%) rename src/main/java/schule/ngb/zm/{ => layers}/DrawableLayer.java (92%) rename src/main/java/schule/ngb/zm/{ => layers}/DrawingLayer.java (95%) rename src/main/java/schule/ngb/zm/{ => layers}/ImageLayer.java (94%) rename src/main/java/schule/ngb/zm/{ => layers}/Shape2DLayer.java (86%) rename src/main/java/schule/ngb/zm/{shapes => layers}/ShapesLayer.java (97%) rename src/main/java/schule/ngb/zm/{turtle => layers}/TurtleLayer.java (99%) rename src/main/java/schule/ngb/zm/{ => shapes}/charts/BarChart.java (99%) rename src/main/java/schule/ngb/zm/{ => shapes}/charts/BasicChartValue.java (99%) rename src/main/java/schule/ngb/zm/{ => shapes}/charts/ChartAxes.java (97%) rename src/main/java/schule/ngb/zm/{ => shapes}/charts/ChartValue.java (98%) rename src/main/java/schule/ngb/zm/{ => shapes}/charts/LineChart.java (98%) rename src/main/java/schule/ngb/zm/{ => shapes}/charts/PieChart.java (99%) rename src/main/java/schule/ngb/zm/{ => shapes}/charts/RingChart.java (99%) rename src/main/java/schule/ngb/zm/{ => util}/events/EventDispatcher.java (97%) rename src/main/java/schule/ngb/zm/{ => util}/events/Listener.java (51%) rename src/main/java/schule/ngb/zm/{ => util}/tasks/DelayedTask.java (94%) rename src/main/java/schule/ngb/zm/{ => util}/tasks/FrameSynchronizedTask.java (97%) rename src/main/java/schule/ngb/zm/{ => util}/tasks/FramerateLimitedTask.java (83%) rename src/main/java/schule/ngb/zm/{ => util}/tasks/RateLimitedTask.java (96%) rename src/main/java/schule/ngb/zm/{ => util}/tasks/Task.java (92%) rename src/main/java/schule/ngb/zm/{ => util}/tasks/TaskRunner.java (97%) rename src/test/java/schule/ngb/zm/{ => util}/events/EventDispatcherTest.java (97%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97a2d71..e6a7ff2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,7 @@ und diese Projekt folgt [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Changed - Neue Package-Struktur: - `schule.ngb.zm.media` für Audio-Klassen (und ggf. zukünftig Video). - - `schule.ngb.zm.tasks` für alles Rund um Parallelität. + - `schule.ngb.zm.util.tasks` für alles Rund um Parallelität. - `Zeichenthread` und `TaskRunner` setzen die Namen der Threads für besseres Debugging. ### Removed diff --git a/src/main/java/schule/ngb/zm/Gradient.java b/src/main/java/schule/ngb/zm/Gradient.java deleted file mode 100644 index 84c8ab6..0000000 --- a/src/main/java/schule/ngb/zm/Gradient.java +++ /dev/null @@ -1,5 +0,0 @@ -package schule.ngb.zm; - -public class Gradient { - -} diff --git a/src/main/java/schule/ngb/zm/Zeichenleinwand.java b/src/main/java/schule/ngb/zm/Zeichenleinwand.java index f4e8e4c..5f132ec 100644 --- a/src/main/java/schule/ngb/zm/Zeichenleinwand.java +++ b/src/main/java/schule/ngb/zm/Zeichenleinwand.java @@ -1,6 +1,6 @@ package schule.ngb.zm; -import schule.ngb.zm.shapes.Shape; +import schule.ngb.zm.layers.ColorLayer; import java.awt.Canvas; import java.awt.Graphics; @@ -8,7 +8,6 @@ import java.awt.Graphics2D; import java.awt.Toolkit; import java.awt.image.BufferStrategy; import java.util.ArrayList; -import java.util.Collections; import java.util.LinkedList; import java.util.List; diff --git a/src/main/java/schule/ngb/zm/Zeichenmaschine.java b/src/main/java/schule/ngb/zm/Zeichenmaschine.java index cf95942..ae49133 100644 --- a/src/main/java/schule/ngb/zm/Zeichenmaschine.java +++ b/src/main/java/schule/ngb/zm/Zeichenmaschine.java @@ -1,8 +1,11 @@ package schule.ngb.zm; import schule.ngb.zm.anim.Animation; -import schule.ngb.zm.shapes.ShapesLayer; -import schule.ngb.zm.tasks.TaskRunner; +import schule.ngb.zm.layers.ColorLayer; +import schule.ngb.zm.layers.DrawingLayer; +import schule.ngb.zm.layers.ImageLayer; +import schule.ngb.zm.layers.ShapesLayer; +import schule.ngb.zm.util.tasks.TaskRunner; import schule.ngb.zm.util.ImageLoader; import schule.ngb.zm.util.Log; @@ -1381,8 +1384,8 @@ public class Zeichenmaschine extends Constants { * // Next frame has started * *

- * Die {@link schule.ngb.zm.tasks.FrameSynchronizedTask} implementiert eine - * {@link schule.ngb.zm.tasks.Task}, die sich automatisch auf diese Wiese + * Die {@link schule.ngb.zm.util.tasks.FrameSynchronizedTask} implementiert eine + * {@link schule.ngb.zm.util.tasks.Task}, die sich automatisch auf diese Wiese * mit dem Zeichenthread synchronisiert. */ public static final Object globalSyncLock = new Object[0]; diff --git a/src/main/java/schule/ngb/zm/anim/Animation.java b/src/main/java/schule/ngb/zm/anim/Animation.java index 709fbaf..1303b47 100644 --- a/src/main/java/schule/ngb/zm/anim/Animation.java +++ b/src/main/java/schule/ngb/zm/anim/Animation.java @@ -2,9 +2,7 @@ package schule.ngb.zm.anim; import schule.ngb.zm.Constants; import schule.ngb.zm.Updatable; -import schule.ngb.zm.events.EventDispatcher; -import schule.ngb.zm.tasks.FrameSynchronizedTask; -import schule.ngb.zm.tasks.TaskRunner; +import schule.ngb.zm.util.events.EventDispatcher; import java.util.function.DoubleUnaryOperator; diff --git a/src/main/java/schule/ngb/zm/anim/AnimationListener.java b/src/main/java/schule/ngb/zm/anim/AnimationListener.java index 13e62da..093b08d 100644 --- a/src/main/java/schule/ngb/zm/anim/AnimationListener.java +++ b/src/main/java/schule/ngb/zm/anim/AnimationListener.java @@ -1,6 +1,6 @@ package schule.ngb.zm.anim; -import schule.ngb.zm.events.Listener; +import schule.ngb.zm.util.events.Listener; public interface AnimationListener extends Listener { diff --git a/src/main/java/schule/ngb/zm/anim/Animations.java b/src/main/java/schule/ngb/zm/anim/Animations.java index 682fb98..0c4d28a 100644 --- a/src/main/java/schule/ngb/zm/anim/Animations.java +++ b/src/main/java/schule/ngb/zm/anim/Animations.java @@ -3,9 +3,9 @@ package schule.ngb.zm.anim; import schule.ngb.zm.Color; import schule.ngb.zm.Constants; import schule.ngb.zm.Vector; -import schule.ngb.zm.tasks.FrameSynchronizedTask; -import schule.ngb.zm.tasks.FramerateLimitedTask; -import schule.ngb.zm.tasks.TaskRunner; +import schule.ngb.zm.util.tasks.FrameSynchronizedTask; +import schule.ngb.zm.util.tasks.FramerateLimitedTask; +import schule.ngb.zm.util.tasks.TaskRunner; import schule.ngb.zm.util.Log; import schule.ngb.zm.util.Validator; diff --git a/src/main/java/schule/ngb/zm/ColorLayer.java b/src/main/java/schule/ngb/zm/layers/ColorLayer.java similarity index 96% rename from src/main/java/schule/ngb/zm/ColorLayer.java rename to src/main/java/schule/ngb/zm/layers/ColorLayer.java index 5229c10..129d0bd 100644 --- a/src/main/java/schule/ngb/zm/ColorLayer.java +++ b/src/main/java/schule/ngb/zm/layers/ColorLayer.java @@ -1,4 +1,8 @@ -package schule.ngb.zm; +package schule.ngb.zm.layers; + +import schule.ngb.zm.Color; +import schule.ngb.zm.Layer; +import schule.ngb.zm.Options; import java.awt.GradientPaint; import java.awt.Paint; diff --git a/src/main/java/schule/ngb/zm/DrawableLayer.java b/src/main/java/schule/ngb/zm/layers/DrawableLayer.java similarity index 92% rename from src/main/java/schule/ngb/zm/DrawableLayer.java rename to src/main/java/schule/ngb/zm/layers/DrawableLayer.java index 6273c15..14fe775 100644 --- a/src/main/java/schule/ngb/zm/DrawableLayer.java +++ b/src/main/java/schule/ngb/zm/layers/DrawableLayer.java @@ -1,4 +1,7 @@ -package schule.ngb.zm; +package schule.ngb.zm.layers; + +import schule.ngb.zm.Drawable; +import schule.ngb.zm.Layer; import java.awt.Graphics2D; import java.util.Collections; diff --git a/src/main/java/schule/ngb/zm/DrawingLayer.java b/src/main/java/schule/ngb/zm/layers/DrawingLayer.java similarity index 95% rename from src/main/java/schule/ngb/zm/DrawingLayer.java rename to src/main/java/schule/ngb/zm/layers/DrawingLayer.java index b363f9c..6fe6ef4 100644 --- a/src/main/java/schule/ngb/zm/DrawingLayer.java +++ b/src/main/java/schule/ngb/zm/layers/DrawingLayer.java @@ -1,5 +1,7 @@ -package schule.ngb.zm; +package schule.ngb.zm.layers; +import schule.ngb.zm.Layer; +import schule.ngb.zm.Options; import schule.ngb.zm.util.ImageLoader; import java.awt.*; @@ -8,9 +10,9 @@ import java.util.Stack; public class DrawingLayer extends Layer { - protected Color fillColor = DEFAULT_FILLCOLOR; + protected schule.ngb.zm.Color fillColor = DEFAULT_FILLCOLOR; - protected Color strokeColor = DEFAULT_STROKECOLOR; + protected schule.ngb.zm.Color strokeColor = DEFAULT_STROKECOLOR; protected double strokeWeight = DEFAULT_STROKEWEIGHT; @@ -43,7 +45,7 @@ public class DrawingLayer extends Layer { fontMetrics = drawing.getFontMetrics(); } - public Color getColor() { + public schule.ngb.zm.Color getColor() { return fillColor; } @@ -51,7 +53,7 @@ public class DrawingLayer extends Layer { setFillColor(gray, gray, gray, 255); } - public void setFillColor( Color color ) { + public void setFillColor( schule.ngb.zm.Color color ) { fillColor = color; drawing.setColor(color.getJavaColor()); } @@ -69,10 +71,10 @@ public class DrawingLayer extends Layer { } public void setFillColor( int red, int green, int blue, int alpha ) { - setFillColor(new Color(red, green, blue, alpha)); + setFillColor(new schule.ngb.zm.Color(red, green, blue, alpha)); } - public Color getStrokeColor() { + public schule.ngb.zm.Color getStrokeColor() { return strokeColor; } @@ -80,7 +82,7 @@ public class DrawingLayer extends Layer { setStrokeColor(gray, gray, gray, 255); } - public void setStrokeColor( Color color ) { + public void setStrokeColor( schule.ngb.zm.Color color ) { strokeColor = color; drawing.setColor(color.getJavaColor()); } @@ -98,7 +100,7 @@ public class DrawingLayer extends Layer { } public void setStrokeColor( int red, int green, int blue, int alpha ) { - setStrokeColor(new Color(red, green, blue, alpha)); + setStrokeColor(new schule.ngb.zm.Color(red, green, blue, alpha)); } public void setStrokeWeight( double pWeight ) { @@ -169,10 +171,10 @@ public class DrawingLayer extends Layer { } public void clear( int red, int green, int blue, int alpha ) { - clear(new Color(red, green, blue, alpha)); + clear(new schule.ngb.zm.Color(red, green, blue, alpha)); } - public void clear( Color pColor ) { + public void clear( schule.ngb.zm.Color pColor ) { /*graphics.setBackground(pColor); graphics.clearRect(0, 0, canvas.getWidth(), canvas.getHeight());*/ java.awt.Color currentColor = drawing.getColor(); diff --git a/src/main/java/schule/ngb/zm/ImageLayer.java b/src/main/java/schule/ngb/zm/layers/ImageLayer.java similarity index 94% rename from src/main/java/schule/ngb/zm/ImageLayer.java rename to src/main/java/schule/ngb/zm/layers/ImageLayer.java index 83f3021..bb4eab4 100644 --- a/src/main/java/schule/ngb/zm/ImageLayer.java +++ b/src/main/java/schule/ngb/zm/layers/ImageLayer.java @@ -1,8 +1,9 @@ -package schule.ngb.zm; +package schule.ngb.zm.layers; import java.awt.Graphics2D; import java.awt.Image; +import schule.ngb.zm.Layer; import schule.ngb.zm.util.ImageLoader; public class ImageLayer extends Layer { diff --git a/src/main/java/schule/ngb/zm/Shape2DLayer.java b/src/main/java/schule/ngb/zm/layers/Shape2DLayer.java similarity index 86% rename from src/main/java/schule/ngb/zm/Shape2DLayer.java rename to src/main/java/schule/ngb/zm/layers/Shape2DLayer.java index c7b9cd5..33f6a51 100644 --- a/src/main/java/schule/ngb/zm/Shape2DLayer.java +++ b/src/main/java/schule/ngb/zm/layers/Shape2DLayer.java @@ -1,13 +1,17 @@ -package schule.ngb.zm; +package schule.ngb.zm.layers; + +import schule.ngb.zm.Color; +import schule.ngb.zm.Layer; +import schule.ngb.zm.Options; import java.awt.*; import java.util.LinkedList; public final class Shape2DLayer extends Layer { - protected Color strokeColor = DEFAULT_STROKECOLOR; + protected schule.ngb.zm.Color strokeColor = DEFAULT_STROKECOLOR; - protected Color fillColor = DEFAULT_FILLCOLOR; + protected schule.ngb.zm.Color fillColor = DEFAULT_FILLCOLOR; protected double strokeWeight = DEFAULT_STROKEWEIGHT; @@ -39,7 +43,7 @@ public final class Shape2DLayer extends Layer { this.instantDraw = instantDraw; } - public Color getFillColor() { + public schule.ngb.zm.Color getFillColor() { return fillColor; } @@ -47,7 +51,7 @@ public final class Shape2DLayer extends Layer { setFillColor(gray, gray, gray, 255); } - public void setFillColor( Color pColor ) { + public void setFillColor( schule.ngb.zm.Color pColor ) { fillColor = pColor; drawing.setColor(pColor.getJavaColor()); } @@ -65,10 +69,10 @@ public final class Shape2DLayer extends Layer { } public void setFillColor( int red, int green, int blue, int alpha ) { - setFillColor(new Color(red, green, blue, alpha)); + setFillColor(new schule.ngb.zm.Color(red, green, blue, alpha)); } - public Color getStrokeColor() { + public schule.ngb.zm.Color getStrokeColor() { return strokeColor; } @@ -76,7 +80,7 @@ public final class Shape2DLayer extends Layer { setStrokeColor(gray, gray, gray, 255); } - public void setStrokeColor( Color pColor ) { + public void setStrokeColor( schule.ngb.zm.Color pColor ) { strokeColor = pColor; drawing.setColor(pColor.getJavaColor()); } diff --git a/src/main/java/schule/ngb/zm/shapes/ShapesLayer.java b/src/main/java/schule/ngb/zm/layers/ShapesLayer.java similarity index 97% rename from src/main/java/schule/ngb/zm/shapes/ShapesLayer.java rename to src/main/java/schule/ngb/zm/layers/ShapesLayer.java index 1459ef3..4f719f6 100644 --- a/src/main/java/schule/ngb/zm/shapes/ShapesLayer.java +++ b/src/main/java/schule/ngb/zm/layers/ShapesLayer.java @@ -1,9 +1,10 @@ -package schule.ngb.zm.shapes; +package schule.ngb.zm.layers; import schule.ngb.zm.Layer; import schule.ngb.zm.anim.Animation; import schule.ngb.zm.anim.AnimationFacade; import schule.ngb.zm.anim.Easing; +import schule.ngb.zm.shapes.Shape; import java.awt.Graphics2D; import java.util.*; diff --git a/src/main/java/schule/ngb/zm/turtle/TurtleLayer.java b/src/main/java/schule/ngb/zm/layers/TurtleLayer.java similarity index 99% rename from src/main/java/schule/ngb/zm/turtle/TurtleLayer.java rename to src/main/java/schule/ngb/zm/layers/TurtleLayer.java index df915df..414833b 100644 --- a/src/main/java/schule/ngb/zm/turtle/TurtleLayer.java +++ b/src/main/java/schule/ngb/zm/layers/TurtleLayer.java @@ -1,4 +1,4 @@ -package schule.ngb.zm.turtle; +package schule.ngb.zm.layers; import schule.ngb.zm.Color; import schule.ngb.zm.Layer; diff --git a/src/main/java/schule/ngb/zm/media/AudioListener.java b/src/main/java/schule/ngb/zm/media/AudioListener.java index 1600e07..1ffe45d 100644 --- a/src/main/java/schule/ngb/zm/media/AudioListener.java +++ b/src/main/java/schule/ngb/zm/media/AudioListener.java @@ -1,6 +1,6 @@ package schule.ngb.zm.media; -import schule.ngb.zm.events.Listener; +import schule.ngb.zm.util.events.Listener; public interface AudioListener extends Listener