Improved code readability
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sat, 29 Apr 2023 16:00:33 +0000 (19:00 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sat, 29 Apr 2023 16:00:33 +0000 (19:00 +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/humaninput/Connexion3D.java [new file with mode: 0644]
src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/HIDEventTracker.java [new file with mode: 0755]
src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/HIDInputTracker.java [deleted file]
src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/WorldNavigationUserInputTracker.java
src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/package-info.java [new file with mode: 0644]
src/main/java/eu/svjatoslav/sixth/e3d/gui/textEditorComponent/package-info.java [new file with mode: 0644]
src/main/java/eu/svjatoslav/sixth/e3d/io/Connexion3D.java [deleted file]

index 0c6ef51..bbae44c 100755 (executable)
@@ -85,6 +85,9 @@ public class ViewFrame extends JFrame implements WindowListener {
         });
     }
 
+    /**
+     * Exit the application.
+     */
     public void exit() {
         if (getViewPanel() != null) {
             getViewPanel().stop();
index 9c0681c..a511bc7 100755 (executable)
@@ -4,7 +4,7 @@
  */
 package eu.svjatoslav.sixth.e3d.gui;
 
-import eu.svjatoslav.sixth.e3d.gui.humaninput.HIDInputTracker;
+import eu.svjatoslav.sixth.e3d.gui.humaninput.HIDEventTracker;
 import eu.svjatoslav.sixth.e3d.gui.humaninput.KeyboardFocusStack;
 import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
 
@@ -21,7 +21,7 @@ import java.util.concurrent.ConcurrentHashMap;
  */
 public class ViewPanel extends JPanel implements ComponentListener {
     private static final long serialVersionUID = 1683277888885045387L;
-    private final HIDInputTracker HIDInputTracker = new HIDInputTracker(this);
+    private final HIDEventTracker HIDEventTracker = new HIDEventTracker(this);
     private final KeyboardFocusStack keyboardFocusStack;
     private final Avatar avatar = new Avatar();
     private final ShapeCollection rootShapeCollection = new ShapeCollection();
@@ -49,7 +49,7 @@ public class ViewPanel extends JPanel implements ComponentListener {
 
     public ViewPanel() {
         viewRenderListeners.add(avatar);
-        viewRenderListeners.add(HIDInputTracker);
+        viewRenderListeners.add(HIDEventTracker);
 
         keyboardFocusStack = new KeyboardFocusStack(this);
 
@@ -72,8 +72,8 @@ public class ViewPanel extends JPanel implements ComponentListener {
         return rootShapeCollection;
     }
 
-    public HIDInputTracker getHIDInputTracker() {
-        return HIDInputTracker;
+    public HIDEventTracker getHIDInputTracker() {
+        return HIDEventTracker;
     }
 
     public void addViewUpdateListener(final ViewRenderListener listener) {
@@ -145,13 +145,17 @@ public class ViewPanel extends JPanel implements ComponentListener {
     }
 
     /**
-     * Calling this methods tells 3D engine that current 3D view needs to be
+     * Calling these methods tells 3D engine that current 3D view needs to be
      * repainted on first opportunity.
      */
     public void repaintDuringNextViewUpdate() {
         viewRepaintNeeded = true;
     }
 
+    /**
+     * Set target frames per second rate for this view. Target FPS can be changed at runtime.
+     * @param frameRate target frames per second rate for this view.
+     */
     public void setFrameRate(final int frameRate) {
         if (canvasUpdateTimerTask != null) {
             canvasUpdateTimerTask.cancel();
@@ -163,25 +167,21 @@ public class ViewPanel extends JPanel implements ComponentListener {
 
         targetFPS = frameRate;
 
-        if (frameRate > 0) {
-            canvasUpdateTimer = new Timer();
-            canvasUpdateTimerTask = new ViewUpdateTimerTask(this);
+        if (frameRate <= 0) return;
 
-            canvasUpdateTimer.schedule(canvasUpdateTimerTask, 0,
-                    1000 / frameRate);
-        }
+        canvasUpdateTimer = new Timer();
+        canvasUpdateTimerTask = new ViewUpdateTimerTask(this);
+
+        // schedule timer task to run in frequency according to defined frame rate
+        canvasUpdateTimer.schedule(canvasUpdateTimerTask, 0,
+                1000 / frameRate);
     }
 
+    /**
+     * Stops rendering of this view.
+     */
     public void stop() {
-        if (canvasUpdateTimerTask != null) {
-            canvasUpdateTimerTask.cancel();
-            canvasUpdateTimerTask = null;
-        }
-
-        if (canvasUpdateTimer != null) {
-            canvasUpdateTimer.cancel();
-            canvasUpdateTimer = null;
-        }
+        setFrameRate(0);
     }
 
     /**
diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/Connexion3D.java b/src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/Connexion3D.java
new file mode 100644 (file)
index 0000000..027dbf0
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * This project is released under Creative Commons Zero (CC0) license.
+ */
+package eu.svjatoslav.sixth.e3d.gui.humaninput;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+
+/**
+ * I have Space Mouse Compact 3D Connexion mouse: https://3dconnexion.com/us/product/spacemouse-compact/
+ *
+ * I discovered that it is possible to read raw data from it by reading /dev/hidraw4 file.
+ *
+ * TODO: reverse engineer the data format and implement a driver for it.
+ */
+
+public class Connexion3D {
+
+    public static void main(final String[] args) throws IOException {
+
+        final BufferedReader in = new BufferedReader(new FileReader(
+                "/dev/hidraw4"));
+
+
+        // for testing purposes
+        while (true) {
+            System.out.print(in.read() + " ");
+            System.out.println("\n");
+        }
+
+        // in.close();
+
+    }
+}
diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/HIDEventTracker.java b/src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/HIDEventTracker.java
new file mode 100755 (executable)
index 0000000..19dee50
--- /dev/null
@@ -0,0 +1,271 @@
+/*
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * This project is released under Creative Commons Zero (CC0) license.
+ */
+package eu.svjatoslav.sixth.e3d.gui.humaninput;
+
+import eu.svjatoslav.sixth.e3d.geometry.Point2D;
+import eu.svjatoslav.sixth.e3d.gui.Avatar;
+import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
+import eu.svjatoslav.sixth.e3d.gui.ViewRenderListener;
+
+import javax.swing.*;
+import java.awt.event.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This class is responsible for tracking human input devices (keyboard, mouse, etc.) and
+ * forwarding those inputs to subsequent virtual components.
+ */
+public class HIDEventTracker implements
+        MouseMotionListener, KeyListener, MouseListener, MouseWheelListener, ViewRenderListener {
+
+    /**
+     * <p>  Map of pressed keys. </p>
+     * <p>  Key is mouse button code. </p>
+     * <p>  Value is system milliseconds when button was pressed. </p>
+     * <p>  So by reading the map one can determine currently pressed buttons as well as duration. </p>
+     */
+    private final Map<Integer, Long> pressedKeysToPressedTimeMap = new HashMap<>();
+    private final List<MouseEvent> detectedMouseEvents = new ArrayList<>();
+    private final List<KeyEvent> detectedKeyEvents = new ArrayList<>();
+    private final Point2D mouseDraggedDirection = new Point2D();
+    private final ViewPanel viewPanel;
+    private int wheelMovedDirection = 0;
+    private Point2D oldMouseCoordinatesWhenDragging;
+    private Point2D currentMouseLocation;
+    private boolean mouseMoved;
+    private boolean mouseWithinWindow = false;
+
+    /**
+     * Construct new tracker for specified panel.
+     */
+    public HIDEventTracker(final ViewPanel viewPanel) {
+        this.viewPanel = viewPanel;
+        bind(viewPanel);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean beforeRender(final ViewPanel viewPanel, final int millisecondsSinceLastFrame) {
+        boolean viewUpdateNeeded = handleKeyboardEvents();
+        viewUpdateNeeded |= handleMouseClicksAndHover(viewPanel);
+        viewUpdateNeeded |= handleMouseDragging();
+        viewUpdateNeeded |= handleMouseVerticalScrolling();
+        return viewUpdateNeeded;
+    }
+
+    /**
+     * Bind this tracker to specified panel.
+     * @param panel panel to bind to.
+     */
+    private void bind(final JPanel panel) {
+        panel.addMouseMotionListener(this);
+
+        panel.addKeyListener(this);
+
+        panel.addMouseListener(this);
+
+        panel.addMouseWheelListener(this);
+    }
+
+    /**
+     * @return <code>true</code> if view needs to be repainted.
+     */
+    private boolean handleKeyboardEvents() {
+        final KeyboardInputHandler currentFocusOwner = viewPanel.getKeyboardFocusStack().getCurrentFocusOwner();
+        ArrayList<KeyEvent> unprocessedKeyboardEvents = getUnprocessedKeyboardEvents();
+
+        return currentFocusOwner != null
+                && forwardKeyboardEventsToFocusOwner(currentFocusOwner, unprocessedKeyboardEvents);
+    }
+
+    private ArrayList<KeyEvent> getUnprocessedKeyboardEvents() {
+        synchronized (detectedKeyEvents) {
+            ArrayList<KeyEvent> result = new ArrayList<>(detectedKeyEvents);
+            detectedKeyEvents.clear();
+            return result;
+        }
+    }
+
+    /**
+     * @return <code>true</code> if view update is needed.
+     */
+    private boolean forwardKeyboardEventsToFocusOwner(
+            KeyboardInputHandler currentFocusOwner, ArrayList<KeyEvent> keyEvents) {
+        boolean viewUpdateNeeded = false;
+
+        for (KeyEvent keyEvent : keyEvents)
+            viewUpdateNeeded |= processKeyEvent(currentFocusOwner, keyEvent);
+
+        return viewUpdateNeeded;
+    }
+
+    private boolean processKeyEvent(KeyboardInputHandler currentFocusOwner, KeyEvent keyEvent) {
+        switch (keyEvent.getID()) {
+            case KeyEvent.KEY_PRESSED:
+                return currentFocusOwner.keyPressed(keyEvent, viewPanel);
+
+            case KeyEvent.KEY_RELEASED:
+                return currentFocusOwner.keyReleased(keyEvent, viewPanel);
+        }
+        return false;
+    }
+
+    /**
+     * @return <code>true</code> if view needs to be repainted.
+     */
+    private synchronized boolean handleMouseClicksAndHover(final ViewPanel viewPanel) {
+        boolean rerenderNeeded = false;
+        MouseEvent event = findClickLocationToTrace();
+        if (event != null) {
+            // process mouse clicks as a first priority
+            rerenderNeeded = true;
+        } else {
+            // when there are no mouse clicks, process mouse hovering
+
+            if (mouseMoved) {
+                mouseMoved = false;
+                // we would like to re-render frame when user moved mouse, to see what objects mouse is hovering over
+                rerenderNeeded = true;
+            }
+
+            if (currentMouseLocation != null) {
+                // mouse click with button 0 amounts to mouse hovering event
+                event = new MouseEvent(currentMouseLocation, 0);
+            }
+        }
+
+        if (viewPanel.getRenderingContext() != null)
+            viewPanel.getRenderingContext().setMouseEvent(event);
+
+        return rerenderNeeded;
+    }
+
+    private MouseEvent findClickLocationToTrace() {
+        synchronized (detectedMouseEvents) {
+            if (detectedMouseEvents.isEmpty())
+                return null;
+
+            return detectedMouseEvents.remove(0);
+        }
+    }
+
+    boolean isKeyPressed(final int keyCode) {
+        return pressedKeysToPressedTimeMap.containsKey(keyCode);
+    }
+
+    @Override
+    public void keyPressed(final KeyEvent evt) {
+        synchronized (detectedKeyEvents) {
+            pressedKeysToPressedTimeMap.put(evt.getKeyCode(), System.currentTimeMillis());
+            detectedKeyEvents.add(evt);
+        }
+    }
+
+    @Override
+    public void keyReleased(final KeyEvent evt) {
+        synchronized (detectedKeyEvents) {
+            pressedKeysToPressedTimeMap.remove(evt.getKeyCode());
+            detectedKeyEvents.add(evt);
+        }
+    }
+
+    @Override
+    public void keyTyped(final KeyEvent e) {
+    }
+
+    @Override
+    public void mouseClicked(final java.awt.event.MouseEvent e) {
+        synchronized (detectedMouseEvents) {
+            detectedMouseEvents.add(new MouseEvent(e.getX(), e.getY(), e.getButton()));
+        }
+    }
+
+    @Override
+    public void mouseDragged(final java.awt.event.MouseEvent evt) {
+        final Point2D mouseLocation = new Point2D(evt.getX(), evt.getY());
+
+        if (oldMouseCoordinatesWhenDragging == null) {
+            oldMouseCoordinatesWhenDragging = mouseLocation;
+            return;
+        }
+
+        mouseDraggedDirection.add(mouseLocation.clone().subtract(oldMouseCoordinatesWhenDragging));
+
+        oldMouseCoordinatesWhenDragging = mouseLocation;
+    }
+
+    @Override
+    public void mouseEntered(final java.awt.event.MouseEvent e) {
+        mouseWithinWindow = true;
+    }
+
+    @Override
+    public synchronized void mouseExited(final java.awt.event.MouseEvent e) {
+        mouseWithinWindow = false;
+        currentMouseLocation = null;
+    }
+
+    @Override
+    public synchronized void mouseMoved(final java.awt.event.MouseEvent e) {
+        currentMouseLocation = new Point2D(e.getX(), e.getY());
+        mouseMoved = true;
+    }
+
+    @Override
+    public void mousePressed(final java.awt.event.MouseEvent e) {
+    }
+
+    @Override
+    public void mouseReleased(final java.awt.event.MouseEvent evt) {
+        oldMouseCoordinatesWhenDragging = null;
+    }
+
+    @Override
+    public void mouseWheelMoved(final java.awt.event.MouseWheelEvent evt) {
+        wheelMovedDirection += evt.getWheelRotation();
+    }
+
+    /**
+     * @return <code>true</code> if view needs to be repainted.
+     */
+    private boolean handleMouseVerticalScrolling() {
+        final Avatar avatar = viewPanel.getAvatar();
+        final double actualAcceleration = 50 * avatar.avatarAcceleration * (1 + (avatar.getMovementSpeed() / 10));
+        avatar.getMovementVector().y += (wheelMovedDirection * actualAcceleration);
+        avatar.enforceSpeedLimit();
+        boolean repaintNeeded = wheelMovedDirection != 0;
+        wheelMovedDirection = 0;
+        return repaintNeeded;
+    }
+
+    /**
+     * @return <code>true</code> if view needs to be repainted.
+     */
+    private boolean handleMouseDragging() {
+        // TODO: It would be nice here to detect somehow whether user moved mouse or touch screen.
+        // in case of touch screen, we would like to reverse movement along X and Y axis.
+
+        final Avatar avatar = viewPanel.getAvatar();
+        // for mouse
+        avatar.setAngleXZ(avatar.getAngleXZ() - ((float) mouseDraggedDirection.x / 50));
+        avatar.setAngleYZ(avatar.getAngleYZ() - ((float) mouseDraggedDirection.y / 50));
+
+        // for touch screen
+        // avatar.setAngleXZ(avatar.getAngleXZ() + ((float)
+        // mouseDraggedDirection.x / 50));
+        // avatar.setAngleYZ(avatar.getAngleYZ() + ((float)
+        // mouseDraggedDirection.y / 50));
+
+        boolean viewUpdateNeeded = !mouseDraggedDirection.isZero();
+        mouseDraggedDirection.zero();
+        return viewUpdateNeeded;
+    }
+
+}
diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/HIDInputTracker.java b/src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/HIDInputTracker.java
deleted file mode 100755 (executable)
index c08fa8e..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
- * This project is released under Creative Commons Zero (CC0) license.
- */
-package eu.svjatoslav.sixth.e3d.gui.humaninput;
-
-import eu.svjatoslav.sixth.e3d.geometry.Point2D;
-import eu.svjatoslav.sixth.e3d.gui.Avatar;
-import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
-import eu.svjatoslav.sixth.e3d.gui.ViewRenderListener;
-
-import javax.swing.*;
-import java.awt.event.*;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * This class is responsible for tracking human input devices (keyboard, mouse, etc.) and
- * forwarding those inputs to subsequent virtual components.
- */
-public class HIDInputTracker implements
-        MouseMotionListener, KeyListener, MouseListener, MouseWheelListener, ViewRenderListener {
-
-    /**
-     * <p>  Map of pressed keys. </p>
-     * <p>  Key is mouse button code. </p>
-     * <p>  Value is system milliseconds when button was pressed. </p>
-     * <p>  So by reading the map one can determine currently pressed buttons as well as duration. </p>
-     */
-    private final Map<Integer, Long> pressedKeysToPressedTimeMap = new HashMap<>();
-    private final List<MouseEvent> detectedMouseEvents = new ArrayList<>();
-    private final List<KeyEvent> detectedKeyEvents = new ArrayList<>();
-    private final Point2D mouseDraggedDirection = new Point2D();
-    private final ViewPanel viewPanel;
-    private int wheelMovedDirection = 0;
-    private Point2D oldMouseCoordinatesWhenDragging;
-    private Point2D currentMouseLocation;
-    private boolean mouseMoved;
-    private boolean mouseWithinWindow = false;
-
-    public HIDInputTracker(final ViewPanel viewPanel) {
-        this.viewPanel = viewPanel;
-        bind(viewPanel);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean beforeRender(final ViewPanel viewPanel, final int millisecondsSinceLastFrame) {
-        boolean viewUpdateNeeded = handleKeyboardEvents();
-        viewUpdateNeeded |= handleMouseClicksAndHover(viewPanel);
-        viewUpdateNeeded |= handleMouseDragging();
-        viewUpdateNeeded |= handleMouseVerticalScrolling();
-        return viewUpdateNeeded;
-    }
-
-    private void bind(final JPanel panel) {
-        panel.addMouseMotionListener(this);
-
-        panel.addKeyListener(this);
-
-        panel.addMouseListener(this);
-
-        panel.addMouseWheelListener(this);
-    }
-
-    /**
-     * @return <code>true</code> if view needs to be repainted.
-     */
-    private boolean handleKeyboardEvents() {
-        final KeyboardInputHandler currentFocusOwner = viewPanel.getKeyboardFocusStack().getCurrentFocusOwner();
-        ArrayList<KeyEvent> unprocessedKeyboardEvents = getUnprocessedKeyboardEvents();
-
-        return currentFocusOwner != null
-                && forwardKeyboardEventsToFocusOwner(currentFocusOwner, unprocessedKeyboardEvents);
-    }
-
-    private ArrayList<KeyEvent> getUnprocessedKeyboardEvents() {
-        synchronized (detectedKeyEvents) {
-            ArrayList<KeyEvent> result = new ArrayList<>(detectedKeyEvents);
-            detectedKeyEvents.clear();
-            return result;
-        }
-    }
-
-    /**
-     * @return <code>true</code> if view update is needed.
-     */
-    private boolean forwardKeyboardEventsToFocusOwner(
-            KeyboardInputHandler currentFocusOwner, ArrayList<KeyEvent> keyEvents) {
-        boolean viewUpdateNeeded = false;
-
-        for (KeyEvent keyEvent : keyEvents)
-            viewUpdateNeeded |= processKeyEvent(currentFocusOwner, keyEvent);
-
-        return viewUpdateNeeded;
-    }
-
-    private boolean processKeyEvent(KeyboardInputHandler currentFocusOwner, KeyEvent keyEvent) {
-        switch (keyEvent.getID()) {
-            case KeyEvent.KEY_PRESSED:
-                return currentFocusOwner.keyPressed(keyEvent, viewPanel);
-
-            case KeyEvent.KEY_RELEASED:
-                return currentFocusOwner.keyReleased(keyEvent, viewPanel);
-        }
-        return false;
-    }
-
-    /**
-     * @return <code>true</code> if view needs to be repainted.
-     */
-    private synchronized boolean handleMouseClicksAndHover(final ViewPanel viewPanel) {
-        boolean rerenderNeeded = false;
-        MouseEvent event = findClickLocationToTrace();
-        if (event != null) {
-            // process mouse clicks as a first priority
-            rerenderNeeded = true;
-        } else {
-            // when there are no mouse clicks, process mouse hovering
-
-            if (mouseMoved) {
-                mouseMoved = false;
-                // we would like to re-render frame when user moved mouse, to see what objects mouse is hovering over
-                rerenderNeeded = true;
-            }
-
-            if (currentMouseLocation != null) {
-                // mouse click with button 0 amounts to mouse hovering event
-                event = new MouseEvent(currentMouseLocation, 0);
-            }
-        }
-
-        if (viewPanel.getRenderingContext() != null)
-            viewPanel.getRenderingContext().setMouseEvent(event);
-
-        return rerenderNeeded;
-    }
-
-    private MouseEvent findClickLocationToTrace() {
-        synchronized (detectedMouseEvents) {
-            if (detectedMouseEvents.isEmpty())
-                return null;
-
-            return detectedMouseEvents.remove(0);
-        }
-    }
-
-    boolean isKeyPressed(final int keyCode) {
-        return pressedKeysToPressedTimeMap.containsKey(keyCode);
-    }
-
-    @Override
-    public void keyPressed(final KeyEvent evt) {
-        synchronized (detectedKeyEvents) {
-            pressedKeysToPressedTimeMap.put(evt.getKeyCode(), System.currentTimeMillis());
-            detectedKeyEvents.add(evt);
-        }
-    }
-
-    @Override
-    public void keyReleased(final KeyEvent evt) {
-        synchronized (detectedKeyEvents) {
-            pressedKeysToPressedTimeMap.remove(evt.getKeyCode());
-            detectedKeyEvents.add(evt);
-        }
-    }
-
-    @Override
-    public void keyTyped(final KeyEvent e) {
-    }
-
-    @Override
-    public void mouseClicked(final java.awt.event.MouseEvent e) {
-        synchronized (detectedMouseEvents) {
-            detectedMouseEvents.add(new MouseEvent(e.getX(), e.getY(), e.getButton()));
-        }
-    }
-
-    @Override
-    public void mouseDragged(final java.awt.event.MouseEvent evt) {
-        final Point2D mouseLocation = new Point2D(evt.getX(), evt.getY());
-
-        if (oldMouseCoordinatesWhenDragging == null) {
-            oldMouseCoordinatesWhenDragging = mouseLocation;
-            return;
-        }
-
-        mouseDraggedDirection.add(mouseLocation.clone().subtract(oldMouseCoordinatesWhenDragging));
-
-        oldMouseCoordinatesWhenDragging = mouseLocation;
-    }
-
-    @Override
-    public void mouseEntered(final java.awt.event.MouseEvent e) {
-        mouseWithinWindow = true;
-    }
-
-    @Override
-    public synchronized void mouseExited(final java.awt.event.MouseEvent e) {
-        mouseWithinWindow = false;
-        currentMouseLocation = null;
-    }
-
-    @Override
-    public synchronized void mouseMoved(final java.awt.event.MouseEvent e) {
-        currentMouseLocation = new Point2D(e.getX(), e.getY());
-        mouseMoved = true;
-    }
-
-    @Override
-    public void mousePressed(final java.awt.event.MouseEvent e) {
-    }
-
-    @Override
-    public void mouseReleased(final java.awt.event.MouseEvent evt) {
-        oldMouseCoordinatesWhenDragging = null;
-    }
-
-    @Override
-    public void mouseWheelMoved(final java.awt.event.MouseWheelEvent evt) {
-        wheelMovedDirection += evt.getWheelRotation();
-    }
-
-    /**
-     * @return <code>true</code> if view needs to be repainted.
-     */
-    private boolean handleMouseVerticalScrolling() {
-        final Avatar avatar = viewPanel.getAvatar();
-        final double actualAcceleration = 50 * avatar.avatarAcceleration * (1 + (avatar.getMovementSpeed() / 10));
-        avatar.getMovementVector().y += (wheelMovedDirection * actualAcceleration);
-        avatar.enforceSpeedLimit();
-        boolean repaintNeeded = wheelMovedDirection != 0;
-        wheelMovedDirection = 0;
-        return repaintNeeded;
-    }
-
-    /**
-     * @return <code>true</code> if view needs to be repainted.
-     */
-    private boolean handleMouseDragging() {
-        // TODO: It would be nice here to detect somehow whether user moved mouse or touch screen.
-        // in case of touch screen, we would like to reverse movement along X and Y axis.
-
-        final Avatar avatar = viewPanel.getAvatar();
-        // for mouse
-        avatar.setAngleXZ(avatar.getAngleXZ() - ((float) mouseDraggedDirection.x / 50));
-        avatar.setAngleYZ(avatar.getAngleYZ() - ((float) mouseDraggedDirection.y / 50));
-
-        // for touch screen
-        // avatar.setAngleXZ(avatar.getAngleXZ() + ((float)
-        // mouseDraggedDirection.x / 50));
-        // avatar.setAngleYZ(avatar.getAngleYZ() + ((float)
-        // mouseDraggedDirection.y / 50));
-
-        boolean viewUpdateNeeded = !mouseDraggedDirection.isZero();
-        mouseDraggedDirection.zero();
-        return viewUpdateNeeded;
-    }
-
-}
index 9c8415e..f6af6d2 100644 (file)
@@ -16,7 +16,7 @@ public class WorldNavigationUserInputTracker implements KeyboardInputHandler, Vi
     public boolean beforeRender(final ViewPanel viewPanel,
                                 final int millisecondsSinceLastFrame) {
 
-        final HIDInputTracker inputTracker = viewPanel.getHIDInputTracker();
+        final HIDEventTracker inputTracker = viewPanel.getHIDInputTracker();
 
         final Avatar avatar = viewPanel.getAvatar();
 
diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/package-info.java b/src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/package-info.java
new file mode 100644 (file)
index 0000000..dfbbd22
--- /dev/null
@@ -0,0 +1,6 @@
+package eu.svjatoslav.sixth.e3d.gui.humaninput;
+
+/**
+ * This package is responsible for tracking human input devices (keyboard, mouse, etc.) and
+ * forwarding those inputs to subsequent virtual components.
+ */
\ No newline at end of file
diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/gui/textEditorComponent/package-info.java b/src/main/java/eu/svjatoslav/sixth/e3d/gui/textEditorComponent/package-info.java
new file mode 100644 (file)
index 0000000..3773a0a
--- /dev/null
@@ -0,0 +1,7 @@
+package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
+
+/**
+ * This package contains a text editor component.
+ *
+ * It is a simple text editor.
+ */
\ No newline at end of file
diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/io/Connexion3D.java b/src/main/java/eu/svjatoslav/sixth/e3d/io/Connexion3D.java
deleted file mode 100644 (file)
index 90e7306..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
- * This project is released under Creative Commons Zero (CC0) license.
- */
-package eu.svjatoslav.sixth.e3d.io;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-
-/**
- * 3D Connexion mouse adapter.
- * <p>
- * Idea is to read Linux device file and interpret resulting numbers.
- * <p>
- * TODO: unfinished
- */
-
-public class Connexion3D {
-
-    public static void main(final String[] args) throws IOException {
-
-        final BufferedReader in = new BufferedReader(new FileReader(
-                "/dev/hidraw4"));
-
-
-        while (true) {
-            System.out.print(in.read() + " ");
-            System.out.println("\n");
-        }
-
-        // in.close();
-
-    }
-}