diff --git a/build.gradle b/build.gradle index 4f04824..489141e 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ apply plugin: 'jacoco' apply plugin: 'application' -mainClassName = "PanoViewer.PanoViewer" +mainClassName = "org.panoviewer.PanoViewer" configurations { // configuration that holds jars to include in the jar diff --git a/src/main/java/org/panoviewer/PanoViewer.java b/src/main/java/org/panoviewer/PanoViewer.java index 03b3452..310dc7f 100644 --- a/src/main/java/org/panoviewer/PanoViewer.java +++ b/src/main/java/org/panoviewer/PanoViewer.java @@ -1,6 +1,8 @@ // License: GPL. For details, see LICENSE file. package org.panoviewer; +import org.panoviewer.gui.MainScreen; + /** * * @author kshan diff --git a/src/main/java/org/panoviewer/MainScreen.java b/src/main/java/org/panoviewer/gui/MainScreen.java similarity index 82% rename from src/main/java/org/panoviewer/MainScreen.java rename to src/main/java/org/panoviewer/gui/MainScreen.java index 69281eb..3bf81ac 100644 --- a/src/main/java/org/panoviewer/MainScreen.java +++ b/src/main/java/org/panoviewer/gui/MainScreen.java @@ -1,29 +1,34 @@ // License: GPL. For details, see LICENSE file. -package org.panoviewer; +package org.panoviewer.gui; import org.panoviewer.utils.IOUtils; -import org.panoviewer.gui.Menu; import javax.swing.*; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.dnd.*; import java.awt.image.BufferedImage; import java.io.File; import java.util.List; import static java.awt.dnd.DnDConstants.ACTION_COPY; +import java.io.IOException; public class MainScreen extends JFrame implements DropTargetListener { - private JMenuBar menuBar = Menu.getInstance(); - private JPanel jPanel; - private static MainScreen instance = new MainScreen(); + private final JMenuBar menuBar; + private final JPanel jPanel; + private static MainScreen instance; public static MainScreen getInstance() { + if (instance == null) { + instance = new MainScreen(); + } return instance; } private MainScreen() { + this.menuBar = Menu.getInstance(); setSize(600, 600); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -70,8 +75,7 @@ public void drop(DropTargetDropEvent event) { List files = (List) transferable.getTransferData(df); displayImage(files.get(0)); } - } catch (Exception e) { - e.printStackTrace(); + } catch (UnsupportedFlavorException | IOException e) { } } } diff --git a/src/main/java/org/panoviewer/gui/Menu.java b/src/main/java/org/panoviewer/gui/Menu.java index 125964e..a745ce2 100644 --- a/src/main/java/org/panoviewer/gui/Menu.java +++ b/src/main/java/org/panoviewer/gui/Menu.java @@ -1,7 +1,6 @@ // License: GPL. For details, see LICENSE file. package org.panoviewer.gui; -import org.panoviewer.MainScreen; import org.panoviewer.Mode; import org.panoviewer.ModeRecorder; import org.panoviewer.utils.IOUtils; diff --git a/src/main/java/org/panoviewer/SwitchModes.java b/src/main/java/org/panoviewer/gui/SwitchModes.java similarity index 95% rename from src/main/java/org/panoviewer/SwitchModes.java rename to src/main/java/org/panoviewer/gui/SwitchModes.java index aa5cc4a..f749b50 100644 --- a/src/main/java/org/panoviewer/SwitchModes.java +++ b/src/main/java/org/panoviewer/gui/SwitchModes.java @@ -1,5 +1,5 @@ // License: GPL. For details, see LICENSE file. -package org.panoviewer; +package org.panoviewer.gui; import org.panoviewer.gui.jogl.FlatPanel; import org.panoviewer.gui.jogl.PanoramicPanel; @@ -8,6 +8,8 @@ import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import org.panoviewer.Mode; +import org.panoviewer.ModeRecorder; import static org.panoviewer.utils.imageutils.isRatio; diff --git a/src/main/java/org/panoviewer/utils/IOUtils.java b/src/main/java/org/panoviewer/utils/IOUtils.java index 50a0db0..7ba8a9c 100644 --- a/src/main/java/org/panoviewer/utils/IOUtils.java +++ b/src/main/java/org/panoviewer/utils/IOUtils.java @@ -11,8 +11,8 @@ import java.awt.image.BufferedImage; import org.panoviewer.FileChooser; -import org.panoviewer.MainScreen; -import org.panoviewer.SwitchModes; +import org.panoviewer.gui.MainScreen; +import org.panoviewer.gui.SwitchModes; /** * diff --git a/src/test/java/org/panoviewer/CameraTest.java b/src/test/java/org/panoviewer/CameraTest.java index e5ba4ef..7832929 100644 --- a/src/test/java/org/panoviewer/CameraTest.java +++ b/src/test/java/org/panoviewer/CameraTest.java @@ -1,13 +1,14 @@ // License: GPL. For details, see LICENSE file. package org.panoviewer; -import junit.framework.TestCase; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertTrue; import org.junit.Test; /** * Tests {@link Camera} */ -public class CameraTest extends TestCase { +public class CameraTest { public CameraTest() { }