diff --git a/src/main/java/paintingcanvas/canvas/Canvas.java b/src/main/java/paintingcanvas/canvas/Canvas.java index 23e68db..36ab4c2 100644 --- a/src/main/java/paintingcanvas/canvas/Canvas.java +++ b/src/main/java/paintingcanvas/canvas/Canvas.java @@ -18,6 +18,10 @@ public class Canvas { * the fps of the canvas */ public static final int fps = 30; + /** + * Sync with drawables: Use when modifying a drawable + */ + public static final Object drawableSync = new Object(); public static Canvas globalInstance; /** * the initial size of the Canvas @@ -44,10 +48,6 @@ public class Canvas { * Sync with frame: Notifies on end of frame */ protected final Object frameSync = new Object(); - /** - * Sync with drawables: Use when modifying a drawable - */ - public static final Object drawableSync = new Object(); /** * The current frame */ diff --git a/src/main/java/paintingcanvas/canvas/CanvasOptions.java b/src/main/java/paintingcanvas/canvas/CanvasOptions.java index 230a8ba..41a3f8e 100644 --- a/src/main/java/paintingcanvas/canvas/CanvasOptions.java +++ b/src/main/java/paintingcanvas/canvas/CanvasOptions.java @@ -33,5 +33,6 @@ public class CanvasOptions { */ public Color backgroundColor = Color.WHITE; - public CanvasOptions() {} + public CanvasOptions() { + } } diff --git a/src/main/java/paintingcanvas/canvas/RenderLifecycle.java b/src/main/java/paintingcanvas/canvas/RenderLifecycle.java index 2f99935..0410d7e 100644 --- a/src/main/java/paintingcanvas/canvas/RenderLifecycle.java +++ b/src/main/java/paintingcanvas/canvas/RenderLifecycle.java @@ -6,19 +6,19 @@ /** *

- * Allows other classes to run code at different points during the rendering process. This is mainly useful for - * extensions / little widgets and things, but I'm sure you can find other uses. + * Allows other classes to run code at different points during the rendering process. This is mainly useful for + * extensions / little widgets and things, but I'm sure you can find other uses. *

*

- * Here's exactly how it works (sort of). First the {@link java.awt.image.BufferedImage image} is created, - * and the background is drawn. Next, {@link RenderLifecycle#preRender(Graphics)} is called, and all the - * {@link paintingcanvas.drawable.Drawable Drawables} get drawn. Then {@link RenderLifecycle#postRender(Graphics)} - * is called, {@link RenderLifecycle#renderStart(Graphics)} is called, and finally, the image is copied over to the - * screen, and {@link RenderLifecycle#renderEnd(Graphics)} is called. + * Here's exactly how it works (sort of). First the {@link java.awt.image.BufferedImage image} is created, + * and the background is drawn. Next, {@link RenderLifecycle#preRender(Graphics)} is called, and all the + * {@link paintingcanvas.drawable.Drawable Drawables} get drawn. Then {@link RenderLifecycle#postRender(Graphics)} + * is called, {@link RenderLifecycle#renderStart(Graphics)} is called, and finally, the image is copied over to the + * screen, and {@link RenderLifecycle#renderEnd(Graphics)} is called. *

*

- * Note that {@code preRender} / {@code postRender} are called on a different graphics context compared to - * {@code renderStart} / {@code renderEnd}. + * Note that {@code preRender} / {@code postRender} are called on a different graphics context compared to + * {@code renderStart} / {@code renderEnd}. *

*/ public interface RenderLifecycle { diff --git a/src/main/java/paintingcanvas/drawable/Drawable.java b/src/main/java/paintingcanvas/drawable/Drawable.java index 7915487..af54688 100644 --- a/src/main/java/paintingcanvas/drawable/Drawable.java +++ b/src/main/java/paintingcanvas/drawable/Drawable.java @@ -445,7 +445,7 @@ public T setColor(Color color) { return getThis(); } - /** + /** * Set the color of the object with a {@link Hue} object. *
{@code
      * Circle o = new Circle(100, 100, 20);
diff --git a/src/main/java/paintingcanvas/drawable/Image.java b/src/main/java/paintingcanvas/drawable/Image.java
index 1eba6e4..2a6e431 100644
--- a/src/main/java/paintingcanvas/drawable/Image.java
+++ b/src/main/java/paintingcanvas/drawable/Image.java
@@ -8,11 +8,11 @@
 
 /**
  * 

- * Draws an image from the specified path. + * Draws an image from the specified path. *

*

- * {@code setColor} and {@code getColor} don't do anything for this drawable as - * it is not a traditional solid color shape + * {@code setColor} and {@code getColor} don't do anything for this drawable as + * it is not a traditional solid color shape *

* *
{@code
@@ -28,8 +28,9 @@ public class Image extends Drawable {
 
     /**
      * Create a new Image element.
-     * @param x The X-position of the image
-     * @param y The Y-position of the image
+     *
+     * @param x   The X-position of the image
+     * @param y   The Y-position of the image
      * @param src The path to the image file
      */
     public Image(int x, int y, String src) {
@@ -51,13 +52,14 @@ public Image(int x, int y, String src) {
      * Image img = new Image(0, 0, "image.png");
      * img.setScale(2.0, 1.0); // the image is now stretched in the x direction
      * }
+ * * @param x The multiplier to scale x by * @param y The multiplier to scale y by * @return The original object to allow method chaining */ public Image setScale(double x, double y) { - this.width = (int)(image.getWidth() * x); - this.height = (int)(image.getHeight() * y); + this.width = (int) (image.getWidth() * x); + this.height = (int) (image.getHeight() * y); return this; } diff --git a/src/main/java/paintingcanvas/extensions/InfoDisplay.java b/src/main/java/paintingcanvas/extensions/InfoDisplay.java index 2b66070..e126568 100644 --- a/src/main/java/paintingcanvas/extensions/InfoDisplay.java +++ b/src/main/java/paintingcanvas/extensions/InfoDisplay.java @@ -23,9 +23,9 @@ public class InfoDisplay implements RenderLifecycle { 0f ); private final Stroke stroke = new BasicStroke(10); + private final Color textColor = Color.BLACK; private int fontSize = 12; private Font font = new Font(Font.DIALOG, Font.PLAIN, 12); - private final Color textColor = Color.BLACK; public InfoDisplay() { } diff --git a/src/main/java/paintingcanvas/misc/Hue.java b/src/main/java/paintingcanvas/misc/Hue.java index d0df5c9..8636c35 100644 --- a/src/main/java/paintingcanvas/misc/Hue.java +++ b/src/main/java/paintingcanvas/misc/Hue.java @@ -6,12 +6,12 @@ /** *

- * Colors (besides black and white) are taken from the - * Tailwind CSS Color Palette. + * Colors (besides black and white) are taken from the + * Tailwind CSS Color Palette. *

*

- * Not indented to be constructed directly in the public API. Internally, it's only use is - * {@link #getColor(String)} + * Not indented to be constructed directly in the public API. Internally, it's only use is + * {@link #getColor(String)} *

* * diff --git a/src/test/java/stress_tests/RotateTest.java b/src/test/java/stress_tests/RotateTest.java index 4d93010..82d398f 100644 --- a/src/test/java/stress_tests/RotateTest.java +++ b/src/test/java/stress_tests/RotateTest.java @@ -1,7 +1,6 @@ package stress_tests; import paintingcanvas.canvas.Canvas; -import paintingcanvas.drawable.Polygon; import paintingcanvas.drawable.Triangle; import paintingcanvas.extensions.FrameCounter; import paintingcanvas.extensions.InfoDisplay; diff --git a/src/test/java/stress_tests/SyncTest.java b/src/test/java/stress_tests/SyncTest.java index 95300b2..19237b6 100644 --- a/src/test/java/stress_tests/SyncTest.java +++ b/src/test/java/stress_tests/SyncTest.java @@ -1,11 +1,12 @@ package stress_tests; -import java.awt.*; - import paintingcanvas.canvas.Canvas; -import paintingcanvas.drawable.*; -import paintingcanvas.extensions.*; +import paintingcanvas.drawable.Circle; import paintingcanvas.drawable.Polygon; +import paintingcanvas.extensions.FrameCounter; +import paintingcanvas.extensions.InfoDisplay; + +import java.awt.*; @SuppressWarnings("unused") public class SyncTest {
{@link Hue} Variants