Improved code readability
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 4 May 2023 20:11:23 +0000 (23:11 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 4 May 2023 20:11:23 +0000 (23:11 +0300)
src/main/java/eu/svjatoslav/sixth/e3d/gui/ViewFrame.java
src/main/java/eu/svjatoslav/sixth/e3d/gui/ViewPanel.java
src/main/java/eu/svjatoslav/sixth/e3d/gui/ViewUpdateTimerTask.java

index f71e0a5..6a824c8 100755 (executable)
@@ -129,11 +129,22 @@ public class ViewFrame extends JFrame implements WindowListener {
     public void windowDeactivated(final WindowEvent e) {
     }
 
+    /**
+     * Repaint the view when the window is deiconified.
+     *
+     * Deiconified means that the window is restored from minimized state.
+     */
     @Override
     public void windowDeiconified(final WindowEvent e) {
         viewPanel.repaintDuringNextViewUpdate();
     }
 
+    /**
+     * Do nothing when the window is iconified.
+     *
+     * Iconified means that the window is minimized.
+     * @param e the event to be processed
+     */
     @Override
     public void windowIconified(final WindowEvent e) {
     }
index f6603a0..184ddba 100755 (executable)
@@ -192,7 +192,7 @@ public class ViewPanel extends JPanel implements ComponentListener {
      * It tells view to update itself. View can decide if actual re-rendering of
      * graphics is needed.
      */
-    void updateView() {
+    void ensureThatViewIsUpToDate() {
         maintainRenderingContext();
 
         final int millisecondsPassedSinceLastUpdate = getMillisecondsPassedSinceLastUpdate();
@@ -221,6 +221,7 @@ public class ViewPanel extends JPanel implements ComponentListener {
             return;
         }
 
+        // create new rendering context if window size has changed
         if ((renderingContext == null)
                 || (renderingContext.width != panelWidth)
                 || (renderingContext.height != panelHeight)) {
index b86dc88..8594a2c 100755 (executable)
@@ -4,6 +4,11 @@
  */
 package eu.svjatoslav.sixth.e3d.gui;
 
+/**
+ * Timer task that updates view.
+ *
+ * Tries to keep constant FPS.
+ */
 public class ViewUpdateTimerTask extends java.util.TimerTask {
 
     public ViewPanel viewPanel;
@@ -14,9 +19,7 @@ public class ViewUpdateTimerTask extends java.util.TimerTask {
 
     @Override
     public void run() {
-
-        // update and possibly render view
-        viewPanel.updateView();
+        viewPanel.ensureThatViewIsUpToDate();
     }
 
 }