Updated readability of the code.
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / gui / RenderingContext.java
index b6417e5..c5c42f6 100644 (file)
@@ -4,6 +4,7 @@
  */
 package eu.svjatoslav.sixth.e3d.gui;
 
+import eu.svjatoslav.sixth.e3d.geometry.Point2D;
 import eu.svjatoslav.sixth.e3d.gui.humaninput.MouseEvent;
 import eu.svjatoslav.sixth.e3d.gui.humaninput.MouseInteractionController;
 
@@ -19,10 +20,21 @@ public class RenderingContext {
     public final byte[] pixels;
     public final int width;
     public final int height;
-    public final int xCenter;
-    public final int yCenter;
+    /**
+     * Center of the screen in screen space (pixels).
+     * This is the point where (0,0) coordinate of the world space is rendered.
+     */
+    public final Point2D centerCoordinate;
+
+    /**
+     * Zoom factor. The bigger the value, the more zoomed in the view is.
+     */
     public final double zoom;
     final BufferedImage bufferedImage;
+    /**
+     * Number of frame that is currently being rendered.
+     * Every frame has its own number.
+     */
     public int frameNumber = 0;
 
     /**
@@ -37,8 +49,13 @@ public class RenderingContext {
 
     /**
      * Mouse click event that needs to be processed.
+     * This event is processed only once per frame.
+     * If there are multiple objects under mouse cursor, the top-most object will receive the event.
+     * If there are no objects under mouse cursor, the event will be ignored.
+     * If there is no event, this field will be null.
+     * This field is set to null after the event is processed.
      */
-    private  MouseEvent mouseEvent;
+    private MouseEvent mouseEvent;
 
     public void setMouseEvent(MouseEvent mouseEvent) {
         this.mouseEvent = mouseEvent;
@@ -49,7 +66,7 @@ public class RenderingContext {
     }
 
     /**
-     * Item that user clicked on.
+     * UI component that mouse is currently hovering over.
      */
     private MouseInteractionController currentObjectUnderMouseCursor;
 
@@ -65,10 +82,7 @@ public class RenderingContext {
     public RenderingContext(final int width, final int height) {
         this.width = width;
         this.height = height;
-
-        this.xCenter = width / 2;
-        this.yCenter = height / 2;
-
+        this.centerCoordinate = new Point2D(width / 2d, height / 2d);
         this.zoom = width / 3d;
 
         bufferedImage = new BufferedImage(width, height, bufferedImageType);
@@ -83,7 +97,7 @@ public class RenderingContext {
     }
 
     /**
-     * @return <code>true</code> if view repaint is needed.
+     * @return <code>true</code> if view update is needed as a consequence of this mouse event.
      */
     public boolean handlePossibleComponentMouseEvent() {
         if (mouseEvent == null) return false;