From 88229a610b4bafa7b9122cfca374ae7c4fec0bbb Mon Sep 17 00:00:00 2001 From: Kishan Tripathi Date: Mon, 6 Dec 2021 14:14:43 +0530 Subject: [PATCH] refactor class and packages --- .../panoviewer}/Camera.java | 2 +- .../panoviewer}/FileChooser.java | 2 +- .../panoviewer}/LookFeel.java | 2 +- .../panoviewer}/MainScreen.java | 6 +- .../{PanoViewer => org/panoviewer}/Mode.java | 2 +- .../panoviewer}/ModeRecorder.java | 7 +- .../panoviewer}/PanoViewer.java | 2 +- .../panoviewer}/Settings.java | 2 +- .../panoviewer}/SwitchModes.java | 8 +- .../panoviewer}/gui/AboutDialog.java | 6 +- .../panoviewer}/gui/ImageViewer.java | 2 +- .../panoviewer}/gui/Menu.java | 10 +-- .../panoviewer}/gui/Pannable.java | 2 +- .../panoviewer}/gui/SettingsDialog.java | 8 +- .../panoviewer}/gui/ZoomPanLis.java | 4 +- .../panoviewer}/gui/Zoomable.java | 2 +- .../panoviewer}/gui/jogl/FlatPanel.java | 6 +- .../panoviewer}/gui/jogl/JOGLImageViewer.java | 4 +- .../panoviewer}/gui/jogl/PanoramicPanel.java | 12 +-- .../panoviewer}/math/Sphere.java | 4 +- .../panoviewer/utils}/IOUtils.java | 8 +- .../panoviewer/utils}/imageutils.java | 2 +- .../panoviewer/utils}/joglUtils.java | 8 +- src/test/java/cameraunittest.java | 74 ------------------- src/test/java/org/panoviewer/CameraTest.java | 51 +++++++++++++ 25 files changed, 105 insertions(+), 131 deletions(-) rename src/main/java/{PanoViewer => org/panoviewer}/Camera.java (99%) rename src/main/java/{PanoViewer => org/panoviewer}/FileChooser.java (97%) rename src/main/java/{PanoViewer => org/panoviewer}/LookFeel.java (98%) rename src/main/java/{PanoViewer => org/panoviewer}/MainScreen.java (95%) rename src/main/java/{PanoViewer => org/panoviewer}/Mode.java (86%) rename src/main/java/{PanoViewer => org/panoviewer}/ModeRecorder.java (88%) rename src/main/java/{PanoViewer => org/panoviewer}/PanoViewer.java (91%) rename src/main/java/{PanoViewer => org/panoviewer}/Settings.java (98%) rename src/main/java/{PanoViewer => org/panoviewer}/SwitchModes.java (91%) rename src/main/java/{PanoViewer => org/panoviewer}/gui/AboutDialog.java (94%) rename src/main/java/{PanoViewer => org/panoviewer}/gui/ImageViewer.java (92%) rename src/main/java/{PanoViewer => org/panoviewer}/gui/Menu.java (96%) rename src/main/java/{PanoViewer => org/panoviewer}/gui/Pannable.java (95%) rename src/main/java/{PanoViewer => org/panoviewer}/gui/SettingsDialog.java (92%) rename src/main/java/{PanoViewer => org/panoviewer}/gui/ZoomPanLis.java (95%) rename src/main/java/{PanoViewer => org/panoviewer}/gui/Zoomable.java (95%) rename src/main/java/{PanoViewer => org/panoviewer}/gui/jogl/FlatPanel.java (98%) rename src/main/java/{PanoViewer => org/panoviewer}/gui/jogl/JOGLImageViewer.java (82%) rename src/main/java/{PanoViewer => org/panoviewer}/gui/jogl/PanoramicPanel.java (96%) rename src/main/java/{PanoViewer => org/panoviewer}/math/Sphere.java (97%) rename src/main/java/{PanoViewer/Utils => org/panoviewer/utils}/IOUtils.java (94%) rename src/main/java/{PanoViewer/Utils => org/panoviewer/utils}/imageutils.java (98%) rename src/main/java/{PanoViewer/Utils => org/panoviewer/utils}/joglUtils.java (95%) delete mode 100644 src/test/java/cameraunittest.java create mode 100644 src/test/java/org/panoviewer/CameraTest.java diff --git a/src/main/java/PanoViewer/Camera.java b/src/main/java/org/panoviewer/Camera.java similarity index 99% rename from src/main/java/PanoViewer/Camera.java rename to src/main/java/org/panoviewer/Camera.java index 364f4c4..d6c5867 100644 --- a/src/main/java/PanoViewer/Camera.java +++ b/src/main/java/org/panoviewer/Camera.java @@ -1,5 +1,5 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer; +package org.panoviewer; import org.joml.Matrix4f; import org.joml.Vector3f; diff --git a/src/main/java/PanoViewer/FileChooser.java b/src/main/java/org/panoviewer/FileChooser.java similarity index 97% rename from src/main/java/PanoViewer/FileChooser.java rename to src/main/java/org/panoviewer/FileChooser.java index f50c417..bca5e22 100644 --- a/src/main/java/PanoViewer/FileChooser.java +++ b/src/main/java/org/panoviewer/FileChooser.java @@ -1,5 +1,5 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer; +package org.panoviewer; import javax.imageio.ImageIO; import javax.swing.*; diff --git a/src/main/java/PanoViewer/LookFeel.java b/src/main/java/org/panoviewer/LookFeel.java similarity index 98% rename from src/main/java/PanoViewer/LookFeel.java rename to src/main/java/org/panoviewer/LookFeel.java index 789dfd2..b58263a 100644 --- a/src/main/java/PanoViewer/LookFeel.java +++ b/src/main/java/org/panoviewer/LookFeel.java @@ -1,5 +1,5 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer; +package org.panoviewer; import java.awt.Window; import javax.swing.SwingUtilities; diff --git a/src/main/java/PanoViewer/MainScreen.java b/src/main/java/org/panoviewer/MainScreen.java similarity index 95% rename from src/main/java/PanoViewer/MainScreen.java rename to src/main/java/org/panoviewer/MainScreen.java index 0e50af6..69281eb 100644 --- a/src/main/java/PanoViewer/MainScreen.java +++ b/src/main/java/org/panoviewer/MainScreen.java @@ -1,8 +1,8 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer; +package org.panoviewer; -import PanoViewer.Utils.IOUtils; -import PanoViewer.gui.Menu; +import org.panoviewer.utils.IOUtils; +import org.panoviewer.gui.Menu; import javax.swing.*; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; diff --git a/src/main/java/PanoViewer/Mode.java b/src/main/java/org/panoviewer/Mode.java similarity index 86% rename from src/main/java/PanoViewer/Mode.java rename to src/main/java/org/panoviewer/Mode.java index e324c10..864d7c0 100644 --- a/src/main/java/PanoViewer/Mode.java +++ b/src/main/java/org/panoviewer/Mode.java @@ -1,5 +1,5 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer; +package org.panoviewer; /* @author - Rohan Babbar diff --git a/src/main/java/PanoViewer/ModeRecorder.java b/src/main/java/org/panoviewer/ModeRecorder.java similarity index 88% rename from src/main/java/PanoViewer/ModeRecorder.java rename to src/main/java/org/panoviewer/ModeRecorder.java index 54a10c8..79a12b2 100644 --- a/src/main/java/PanoViewer/ModeRecorder.java +++ b/src/main/java/org/panoviewer/ModeRecorder.java @@ -1,5 +1,5 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer; +package org.panoviewer; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; @@ -32,11 +32,8 @@ public void removePropertyChangeListener(PropertyChangeListener ls) { support.removePropertyChangeListener(ls); } /** - * @var-if mode md is Panoramic then flag is false else true hence a property change is propagated + * If mode is Panoramic then flag is false else true hence a property change is propagated * @param newMode -mode to be set - * - * - * */ public void setCurrentMode(Mode newMode) { Mode oldMode = getCurrentMode(); diff --git a/src/main/java/PanoViewer/PanoViewer.java b/src/main/java/org/panoviewer/PanoViewer.java similarity index 91% rename from src/main/java/PanoViewer/PanoViewer.java rename to src/main/java/org/panoviewer/PanoViewer.java index 211b8e4..03b3452 100644 --- a/src/main/java/PanoViewer/PanoViewer.java +++ b/src/main/java/org/panoviewer/PanoViewer.java @@ -1,5 +1,5 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer; +package org.panoviewer; /** * diff --git a/src/main/java/PanoViewer/Settings.java b/src/main/java/org/panoviewer/Settings.java similarity index 98% rename from src/main/java/PanoViewer/Settings.java rename to src/main/java/org/panoviewer/Settings.java index 7df05d3..88f11f1 100644 --- a/src/main/java/PanoViewer/Settings.java +++ b/src/main/java/org/panoviewer/Settings.java @@ -1,5 +1,5 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer; +package org.panoviewer; import com.jogamp.opengl.GLProfile; diff --git a/src/main/java/PanoViewer/SwitchModes.java b/src/main/java/org/panoviewer/SwitchModes.java similarity index 91% rename from src/main/java/PanoViewer/SwitchModes.java rename to src/main/java/org/panoviewer/SwitchModes.java index 320c7ab..aa5cc4a 100644 --- a/src/main/java/PanoViewer/SwitchModes.java +++ b/src/main/java/org/panoviewer/SwitchModes.java @@ -1,15 +1,15 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer; +package org.panoviewer; -import PanoViewer.gui.jogl.FlatPanel; -import PanoViewer.gui.jogl.PanoramicPanel; +import org.panoviewer.gui.jogl.FlatPanel; +import org.panoviewer.gui.jogl.PanoramicPanel; import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import static PanoViewer.Utils.imageutils.isRatio; +import static org.panoviewer.utils.imageutils.isRatio; /** * JPanel to switch modes between Flat and Panoramic. diff --git a/src/main/java/PanoViewer/gui/AboutDialog.java b/src/main/java/org/panoviewer/gui/AboutDialog.java similarity index 94% rename from src/main/java/PanoViewer/gui/AboutDialog.java rename to src/main/java/org/panoviewer/gui/AboutDialog.java index 3a16880..4c8f21a 100644 --- a/src/main/java/PanoViewer/gui/AboutDialog.java +++ b/src/main/java/org/panoviewer/gui/AboutDialog.java @@ -1,8 +1,8 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer.gui; +package org.panoviewer.gui; -import static PanoViewer.Utils.IOUtils.getFileFromResourceAsStream; -import static PanoViewer.Utils.imageutils.open; +import static org.panoviewer.utils.IOUtils.getFileFromResourceAsStream; +import static org.panoviewer.utils.imageutils.open; import java.awt.*; import java.io.IOException; diff --git a/src/main/java/PanoViewer/gui/ImageViewer.java b/src/main/java/org/panoviewer/gui/ImageViewer.java similarity index 92% rename from src/main/java/PanoViewer/gui/ImageViewer.java rename to src/main/java/org/panoviewer/gui/ImageViewer.java index 5176920..e74c49f 100644 --- a/src/main/java/PanoViewer/gui/ImageViewer.java +++ b/src/main/java/org/panoviewer/gui/ImageViewer.java @@ -1,5 +1,5 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer.gui; +package org.panoviewer.gui; import java.awt.image.BufferedImage; diff --git a/src/main/java/PanoViewer/gui/Menu.java b/src/main/java/org/panoviewer/gui/Menu.java similarity index 96% rename from src/main/java/PanoViewer/gui/Menu.java rename to src/main/java/org/panoviewer/gui/Menu.java index 87df202..125964e 100644 --- a/src/main/java/PanoViewer/gui/Menu.java +++ b/src/main/java/org/panoviewer/gui/Menu.java @@ -1,10 +1,10 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer.gui; +package org.panoviewer.gui; -import PanoViewer.MainScreen; -import PanoViewer.Mode; -import PanoViewer.ModeRecorder; -import PanoViewer.Utils.IOUtils; +import org.panoviewer.MainScreen; +import org.panoviewer.Mode; +import org.panoviewer.ModeRecorder; +import org.panoviewer.utils.IOUtils; import java.awt.event.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; diff --git a/src/main/java/PanoViewer/gui/Pannable.java b/src/main/java/org/panoviewer/gui/Pannable.java similarity index 95% rename from src/main/java/PanoViewer/gui/Pannable.java rename to src/main/java/org/panoviewer/gui/Pannable.java index 718db79..0d7fddb 100644 --- a/src/main/java/PanoViewer/gui/Pannable.java +++ b/src/main/java/org/panoviewer/gui/Pannable.java @@ -1,5 +1,5 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer.gui; +package org.panoviewer.gui; /** * Interface for panning. diff --git a/src/main/java/PanoViewer/gui/SettingsDialog.java b/src/main/java/org/panoviewer/gui/SettingsDialog.java similarity index 92% rename from src/main/java/PanoViewer/gui/SettingsDialog.java rename to src/main/java/org/panoviewer/gui/SettingsDialog.java index 491f8da..59c0d48 100644 --- a/src/main/java/PanoViewer/gui/SettingsDialog.java +++ b/src/main/java/org/panoviewer/gui/SettingsDialog.java @@ -1,6 +1,6 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer.gui; -import PanoViewer.LookFeel; +package org.panoviewer.gui; +import org.panoviewer.LookFeel; import javax.swing.*; import java.awt.*; @@ -17,7 +17,7 @@ public class SettingsDialog extends JPanel { private JButton restore = new JButton("Restore"); //private JButton ok = new JButton("OK"); - private static PanoViewer.gui.SettingsDialog instance; + private static org.panoviewer.gui.SettingsDialog instance; public SettingsDialog() { tabbedPane.add("General Look", themesPanel); @@ -78,7 +78,7 @@ public void actionPerformed(ActionEvent e) { this.setVisible(true); } - public static PanoViewer.gui.SettingsDialog getInstance() { + public static org.panoviewer.gui.SettingsDialog getInstance() { if (instance == null) { instance = new SettingsDialog(); //settings } diff --git a/src/main/java/PanoViewer/gui/ZoomPanLis.java b/src/main/java/org/panoviewer/gui/ZoomPanLis.java similarity index 95% rename from src/main/java/PanoViewer/gui/ZoomPanLis.java rename to src/main/java/org/panoviewer/gui/ZoomPanLis.java index ca1f8da..cd28b73 100644 --- a/src/main/java/PanoViewer/gui/ZoomPanLis.java +++ b/src/main/java/org/panoviewer/gui/ZoomPanLis.java @@ -1,7 +1,7 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer.gui; +package org.panoviewer.gui; -import static PanoViewer.Settings.*; +import static org.panoviewer.Settings.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; diff --git a/src/main/java/PanoViewer/gui/Zoomable.java b/src/main/java/org/panoviewer/gui/Zoomable.java similarity index 95% rename from src/main/java/PanoViewer/gui/Zoomable.java rename to src/main/java/org/panoviewer/gui/Zoomable.java index 39efa3f..2240c2d 100644 --- a/src/main/java/PanoViewer/gui/Zoomable.java +++ b/src/main/java/org/panoviewer/gui/Zoomable.java @@ -1,5 +1,5 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer.gui; +package org.panoviewer.gui; /** * diff --git a/src/main/java/PanoViewer/gui/jogl/FlatPanel.java b/src/main/java/org/panoviewer/gui/jogl/FlatPanel.java similarity index 98% rename from src/main/java/PanoViewer/gui/jogl/FlatPanel.java rename to src/main/java/org/panoviewer/gui/jogl/FlatPanel.java index bf3c013..85f954c 100644 --- a/src/main/java/PanoViewer/gui/jogl/FlatPanel.java +++ b/src/main/java/org/panoviewer/gui/jogl/FlatPanel.java @@ -1,8 +1,8 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer.gui.jogl; +package org.panoviewer.gui.jogl; -import static PanoViewer.Settings.getWheelSensitivity; -import static PanoViewer.Utils.joglUtils.getTextureData; +import static org.panoviewer.Settings.getWheelSensitivity; +import static org.panoviewer.utils.joglUtils.getTextureData; import static com.jogamp.opengl.GL.GL_TEXTURE_2D; import com.jogamp.opengl.GL; diff --git a/src/main/java/PanoViewer/gui/jogl/JOGLImageViewer.java b/src/main/java/org/panoviewer/gui/jogl/JOGLImageViewer.java similarity index 82% rename from src/main/java/PanoViewer/gui/jogl/JOGLImageViewer.java rename to src/main/java/org/panoviewer/gui/jogl/JOGLImageViewer.java index d18e887..396e0fd 100644 --- a/src/main/java/PanoViewer/gui/jogl/JOGLImageViewer.java +++ b/src/main/java/org/panoviewer/gui/jogl/JOGLImageViewer.java @@ -1,7 +1,7 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer.gui.jogl; +package org.panoviewer.gui.jogl; -import PanoViewer.gui.ImageViewer; +import org.panoviewer.gui.ImageViewer; import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.awt.GLJPanel; diff --git a/src/main/java/PanoViewer/gui/jogl/PanoramicPanel.java b/src/main/java/org/panoviewer/gui/jogl/PanoramicPanel.java similarity index 96% rename from src/main/java/PanoViewer/gui/jogl/PanoramicPanel.java rename to src/main/java/org/panoviewer/gui/jogl/PanoramicPanel.java index 6fe6240..e0a583a 100644 --- a/src/main/java/PanoViewer/gui/jogl/PanoramicPanel.java +++ b/src/main/java/org/panoviewer/gui/jogl/PanoramicPanel.java @@ -1,13 +1,13 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer.gui.jogl; +package org.panoviewer.gui.jogl; -import static PanoViewer.Settings.*; -import static PanoViewer.Utils.joglUtils.createShaderProgram; -import static PanoViewer.Utils.joglUtils.getTextureData; +import static org.panoviewer.Settings.*; +import static org.panoviewer.utils.joglUtils.createShaderProgram; +import static org.panoviewer.utils.joglUtils.getTextureData; import static com.jogamp.opengl.GL.*; -import PanoViewer.Camera; -import PanoViewer.math.Sphere; +import org.panoviewer.Camera; +import org.panoviewer.math.Sphere; import com.jogamp.common.nio.Buffers; import com.jogamp.opengl.GL4; import com.jogamp.opengl.GLAutoDrawable; diff --git a/src/main/java/PanoViewer/math/Sphere.java b/src/main/java/org/panoviewer/math/Sphere.java similarity index 97% rename from src/main/java/PanoViewer/math/Sphere.java rename to src/main/java/org/panoviewer/math/Sphere.java index 0011056..ec0a905 100644 --- a/src/main/java/PanoViewer/math/Sphere.java +++ b/src/main/java/org/panoviewer/math/Sphere.java @@ -1,7 +1,7 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer.math; +package org.panoviewer.math; -import static PanoViewer.Settings.invertImage; +import static org.panoviewer.Settings.invertImage; import static java.lang.Math.*; import org.joml.Vector2f; diff --git a/src/main/java/PanoViewer/Utils/IOUtils.java b/src/main/java/org/panoviewer/utils/IOUtils.java similarity index 94% rename from src/main/java/PanoViewer/Utils/IOUtils.java rename to src/main/java/org/panoviewer/utils/IOUtils.java index 57ebdde..50a0db0 100644 --- a/src/main/java/PanoViewer/Utils/IOUtils.java +++ b/src/main/java/org/panoviewer/utils/IOUtils.java @@ -1,5 +1,5 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer.Utils; +package org.panoviewer.utils; import java.io.File; import java.io.IOException; @@ -10,9 +10,9 @@ import javax.swing.JOptionPane; import java.awt.image.BufferedImage; -import PanoViewer.FileChooser; -import PanoViewer.MainScreen; -import PanoViewer.SwitchModes; +import org.panoviewer.FileChooser; +import org.panoviewer.MainScreen; +import org.panoviewer.SwitchModes; /** * diff --git a/src/main/java/PanoViewer/Utils/imageutils.java b/src/main/java/org/panoviewer/utils/imageutils.java similarity index 98% rename from src/main/java/PanoViewer/Utils/imageutils.java rename to src/main/java/org/panoviewer/utils/imageutils.java index d3e6d29..8bc6cc9 100644 --- a/src/main/java/PanoViewer/Utils/imageutils.java +++ b/src/main/java/org/panoviewer/utils/imageutils.java @@ -1,5 +1,5 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer.Utils; +package org.panoviewer.utils; import javax.swing.*; import java.awt.*; diff --git a/src/main/java/PanoViewer/Utils/joglUtils.java b/src/main/java/org/panoviewer/utils/joglUtils.java similarity index 95% rename from src/main/java/PanoViewer/Utils/joglUtils.java rename to src/main/java/org/panoviewer/utils/joglUtils.java index c3898bf..d822238 100644 --- a/src/main/java/PanoViewer/Utils/joglUtils.java +++ b/src/main/java/org/panoviewer/utils/joglUtils.java @@ -1,9 +1,9 @@ // License: GPL. For details, see LICENSE file. -package PanoViewer.Utils; +package org.panoviewer.utils; -import static PanoViewer.Settings.invertImage; -import static PanoViewer.Utils.IOUtils.getFileFromResourceAsStream; -import static PanoViewer.Utils.imageutils.getFlipedImage; +import static org.panoviewer.Settings.invertImage; +import static org.panoviewer.utils.IOUtils.getFileFromResourceAsStream; +import static org.panoviewer.utils.imageutils.getFlipedImage; import static com.jogamp.opengl.GL.GL_NO_ERROR; import static com.jogamp.opengl.GL2ES2.GL_COMPILE_STATUS; import static com.jogamp.opengl.GL2ES2.GL_FRAGMENT_SHADER; diff --git a/src/test/java/cameraunittest.java b/src/test/java/cameraunittest.java deleted file mode 100644 index 8fcb9a8..0000000 --- a/src/test/java/cameraunittest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template - */ - -import PanoViewer.Camera; -import org.junit.Test; -import static org.junit.Assert.*; -/** - * - * - */ -public class cameraunittest { - - public cameraunittest() {} - - - @Test - public void Camera_test(){ - Camera camera_new= new Camera(); - double epsilon = 0.00001; - assertEquals(true,camera_new.getYaw()-(0)=0 && yaw<=2*Math.PI); -// } -// -// @Test -// public void rotateAlongPitchAxis_test(){ -// Camera rotatealongpitchaxis = new Camera(); -// rotatealongpitchaxis.rotateAlongPitchAxis(9.6f,8.9f); -// double outputaxis = rotatealongpitchaxis.getPitch(); -// assertEquals(1.57,outputaxis,0.001); -// } - - @Test - public void rotate_test(){ - Camera rotate_test = new Camera(); - double epsilon = 1e-5; - double yaw = rotate_test.getYaw(); - - rotate_test.rotate((float) (Math.PI/4), (float) (Math.PI/4)); - assertTrue(rotate_test.getYaw() <= 2*Math.PI+epsilon ); - assertTrue(rotate_test.getYaw() >= 0 -epsilon ); - assertEquals((float)(Math.PI/4),rotate_test.getYaw(),epsilon); - assertTrue(Math.abs(rotate_test.getPitch()-Math.PI/4)= 0 -epsilon ); - assertTrue(rotate_test.getPitch() <= Math.PI/2+epsilon); - assertTrue(rotate_test.getPitch() >= -Math.PI/2-epsilon ); - assertTrue(rotate_test.getYaw()+epsilon>=(float)(3/2*Math.PI)); - assertTrue(rotate_test.getYaw()-epsilon<=(float)(3/2*Math.PI)); - assertTrue(rotate_test.getPitch()+epsilon>=(float)(Math.PI/2)); - assertTrue(rotate_test.getPitch()-epsilon<=(float)(Math.PI/2)); - - rotate_test.rotate((float) (4/3*Math.PI), (float) (7/4*Math.PI)); - assertTrue(rotate_test.getYaw() <= 2*Math.PI+epsilon ); - assertTrue(rotate_test.getYaw() >= 0 -epsilon ); - assertTrue(rotate_test.getYaw()+epsilon>=(float)(4/6*Math.PI)); - assertTrue(rotate_test.getYaw()-epsilon<=(float)(4/6*Math.PI)); - assertTrue(rotate_test.getPitch() <= Math.PI/2+epsilon ); - assertTrue(rotate_test.getPitch() >= -Math.PI/2-epsilon ); - - - - } -} diff --git a/src/test/java/org/panoviewer/CameraTest.java b/src/test/java/org/panoviewer/CameraTest.java new file mode 100644 index 0000000..e5ba4ef --- /dev/null +++ b/src/test/java/org/panoviewer/CameraTest.java @@ -0,0 +1,51 @@ +// License: GPL. For details, see LICENSE file. +package org.panoviewer; + +import junit.framework.TestCase; +import org.junit.Test; + +/** + * Tests {@link Camera} + */ +public class CameraTest extends TestCase { + + public CameraTest() { + } + + @Test + public void Camera_test() { + Camera camera_new = new Camera(); + double epsilon = 0.00001; + assertEquals(true, camera_new.getYaw() - (0) < epsilon); + } + + @Test + public void rotate_test() { + Camera rotate_test = new Camera(); + double epsilon = 1e-5; + + rotate_test.rotate((float) (Math.PI / 4), (float) (Math.PI / 4)); + assertTrue(rotate_test.getYaw() <= 2 * Math.PI + epsilon); + assertTrue(rotate_test.getYaw() >= 0 - epsilon); + assertEquals((float) (Math.PI / 4), rotate_test.getYaw(), epsilon); + assertTrue(Math.abs(rotate_test.getPitch() - Math.PI / 4) < epsilon); + + rotate_test.rotate((float) (3 * Math.PI / 4), (float) (Math.PI / 2)); + assertTrue(rotate_test.getYaw() <= 2 * Math.PI + epsilon); + assertTrue(rotate_test.getYaw() >= 0 - epsilon); + assertTrue(rotate_test.getPitch() <= Math.PI / 2 + epsilon); + assertTrue(rotate_test.getPitch() >= -Math.PI / 2 - epsilon); + assertTrue(rotate_test.getYaw() + epsilon >= (float) (3 / 2 * Math.PI)); + assertTrue(rotate_test.getYaw() - epsilon <= (float) (3 / 2 * Math.PI)); + assertTrue(rotate_test.getPitch() + epsilon >= (float) (Math.PI / 2)); + assertTrue(rotate_test.getPitch() - epsilon <= (float) (Math.PI / 2)); + + rotate_test.rotate((float) (4 / 3 * Math.PI), (float) (7 / 4 * Math.PI)); + assertTrue(rotate_test.getYaw() <= 2 * Math.PI + epsilon); + assertTrue(rotate_test.getYaw() >= 0 - epsilon); + assertTrue(rotate_test.getYaw() + epsilon >= (float) (4 / 6 * Math.PI)); + assertTrue(rotate_test.getYaw() - epsilon <= (float) (4 / 6 * Math.PI)); + assertTrue(rotate_test.getPitch() <= Math.PI / 2 + epsilon); + assertTrue(rotate_test.getPitch() >= -Math.PI / 2 - epsilon); + } +}