Skip to content

Commit

Permalink
refactor class and packages
Browse files Browse the repository at this point in the history
  • Loading branch information
GhostFoxSledgehammer committed Dec 6, 2021
1 parent 0e92241 commit 88229a6
Show file tree
Hide file tree
Showing 25 changed files with 105 additions and 131 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: GPL. For details, see LICENSE file.
package PanoViewer;
package org.panoviewer;

import org.joml.Matrix4f;
import org.joml.Vector3f;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: GPL. For details, see LICENSE file.
package PanoViewer;
package org.panoviewer;

import javax.imageio.ImageIO;
import javax.swing.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: GPL. For details, see LICENSE file.
package PanoViewer;
package org.panoviewer;

import java.awt.Window;
import javax.swing.SwingUtilities;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: GPL. For details, see LICENSE file.
package PanoViewer;
package org.panoviewer;

/*
@author - Rohan Babbar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: GPL. For details, see LICENSE file.
package PanoViewer;
package org.panoviewer;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: GPL. For details, see LICENSE file.
package PanoViewer;
package org.panoviewer;

/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: GPL. For details, see LICENSE file.
package PanoViewer;
package org.panoviewer;

import com.jogamp.opengl.GLProfile;

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: GPL. For details, see LICENSE file.
package PanoViewer.gui;
package org.panoviewer.gui;

import java.awt.image.BufferedImage;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: GPL. For details, see LICENSE file.
package PanoViewer.gui;
package org.panoviewer.gui;

/**
* Interface for panning.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.*;
Expand All @@ -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);
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: GPL. For details, see LICENSE file.
package PanoViewer.gui;
package org.panoviewer.gui;

/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: GPL. For details, see LICENSE file.
package PanoViewer.Utils;
package org.panoviewer.utils;

import javax.swing.*;
import java.awt.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
74 changes: 0 additions & 74 deletions src/test/java/cameraunittest.java

This file was deleted.

51 changes: 51 additions & 0 deletions src/test/java/org/panoviewer/CameraTest.java
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 88229a6

Please sign in to comment.