diff --git a/src/main/java/com/github/creme332/controller/FrameController.java b/src/main/java/com/github/creme332/controller/FrameController.java index 3e6ecde5..a8ca7027 100644 --- a/src/main/java/com/github/creme332/controller/FrameController.java +++ b/src/main/java/com/github/creme332/controller/FrameController.java @@ -9,6 +9,7 @@ import java.awt.event.ActionEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.util.List; import javax.swing.*; @@ -158,7 +159,7 @@ public void actionPerformed(ActionEvent e) { // Open help center rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) - .put(KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.ALT_DOWN_MASK), "openHelpCenter"); + .put(KeyStroke.getKeyStroke(KeyEvent.VK_H, java.awt.event.InputEvent.ALT_DOWN_MASK), "openHelpCenter"); rootPane.getActionMap().put("openHelpCenter", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { @@ -168,7 +169,8 @@ public void actionPerformed(ActionEvent e) { // Toggle sidebar visibility rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( - KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK), + KeyStroke.getKeyStroke(KeyEvent.VK_S, + java.awt.event.InputEvent.CTRL_DOWN_MASK | java.awt.event.InputEvent.SHIFT_DOWN_MASK), "toggleSidebar"); rootPane.getActionMap().put("toggleSidebar", new AbstractAction() { @Override @@ -241,7 +243,7 @@ private void resizeEverything() { frame.repaint(); frame.revalidate(); - + /** * sync toolkit to prevent frame rate issues on linux. * @@ -251,26 +253,34 @@ private void resizeEverything() { Toolkit.getDefaultToolkit().sync(); } - public void playStartAnimation() { - final long animationDuration = 800; // ms + private class Task extends SwingWorker { + static final long ANIMATION_DURATION = 800; // ms - Thread th = new Thread() { - @Override - public void run() { - // Display the splash screen for 1 second - frame.setMenuBarVisibility(false); - frame.showScreen(Screen.SPLASH_SCREEN); - - try { - Thread.sleep(animationDuration); - } catch (InterruptedException e) { - e.printStackTrace(); - System.exit(0); - } - frame.showScreen(app.getCurrentScreen()); - } - }; - th.start(); + @Override + protected Void doInBackground() throws Exception { + // Display the splash screen for some time + frame.setMenuBarVisibility(false); + frame.showScreen(Screen.SPLASH_SCREEN); + Thread.sleep(ANIMATION_DURATION); + return null; + } + + @Override + protected void process(List chunks) { + // do nothing + } + + @Override + protected void done() { + // Close splash screen and proceed to main application + frame.showScreen(app.getCurrentScreen()); + } + } + + public void playStartAnimation() { + // Perform background loading task + Task task = new Task(); + task.execute(); } @Override diff --git a/src/main/java/com/github/creme332/controller/canvas/CanvasController.java b/src/main/java/com/github/creme332/controller/canvas/CanvasController.java index eac358a4..7fb9fce0 100644 --- a/src/main/java/com/github/creme332/controller/canvas/CanvasController.java +++ b/src/main/java/com/github/creme332/controller/canvas/CanvasController.java @@ -102,15 +102,14 @@ public void mouseReleased(MouseEvent arg0) { ShapeManager manager = model.getShapeManager(); // check if a shape was being dragged previously - if (app.getMode() == Mode.MOVE_CANVAS && model.getSelectedShapeIndex() > -1) { + if (app.getMode() == Mode.MOVE_CANVAS && + model.getSelectedShapeIndex() > -1 && + manager.getShapePreview() != null) { // edit previous shape with shape preview - - if (manager.getShapePreview() != null) { - manager.editShape(model.getSelectedShapeIndex(), manager.getShapePreview()); - manager.setShapePreview(null); - model.setSelectedShape(-1); - canvas.repaint(); - } + manager.editShape(model.getSelectedShapeIndex(), manager.getShapePreview()); + manager.setShapePreview(null); + model.setSelectedShape(-1); + canvas.repaint(); } } }); diff --git a/src/main/java/com/github/creme332/model/ShapeWrapper.java b/src/main/java/com/github/creme332/model/ShapeWrapper.java index a5314a76..526c72ab 100644 --- a/src/main/java/com/github/creme332/model/ShapeWrapper.java +++ b/src/main/java/com/github/creme332/model/ShapeWrapper.java @@ -78,7 +78,7 @@ public ShapeWrapper(ShapeWrapper wrapper) { } /** - * Finds the center of a given shape. + * Finds the center of the shape. * * @param shape the shape to find the center of * @return a Point2D representing the center of the shape diff --git a/src/main/java/com/github/creme332/model/TutorialModel.java b/src/main/java/com/github/creme332/model/TutorialModel.java index eb07a74d..b76f74ac 100644 --- a/src/main/java/com/github/creme332/model/TutorialModel.java +++ b/src/main/java/com/github/creme332/model/TutorialModel.java @@ -4,7 +4,7 @@ import java.util.Set; /** - * Information about a particular tutorialdraw. + * Information about a particular tutorial. */ public class TutorialModel { /**