diff --git a/.gitignore b/.gitignore index bf2a885..56a4081 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ *.class *~ DEADJOE -*.jar \ No newline at end of file +*.jar + +target/** +GiftedMotion.iml \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..5ddbe5b --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ad045e0 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..00cbcbf --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/build.xml b/build.xml deleted file mode 100644 index 4cd780f..0000000 --- a/build.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..6dc8732 --- /dev/null +++ b/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + + de.onysbits.giftedmotion + GiftedMotion + 1.3-SNAPSHOT + + + UTF-8 + 11 + 11 + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + src/main/resources/META-INF/MANIFEST.MF + + + + + + + \ No newline at end of file diff --git a/src/de/onyxbits/giftedmotion/AnimatedGifEncoder.java b/src/main/java/de/onyxbits/giftedmotion/AnimatedGifEncoder.java similarity index 96% rename from src/de/onyxbits/giftedmotion/AnimatedGifEncoder.java rename to src/main/java/de/onyxbits/giftedmotion/AnimatedGifEncoder.java index 327cd3c..d1bd540 100644 --- a/src/de/onyxbits/giftedmotion/AnimatedGifEncoder.java +++ b/src/main/java/de/onyxbits/giftedmotion/AnimatedGifEncoder.java @@ -25,6 +25,7 @@ * */ +@SuppressWarnings("PointlessBitwiseExpression") public class AnimatedGifEncoder { protected int width; // image size @@ -77,7 +78,6 @@ public void setDispose(int code) { * image is added. * * @param iter int number of iterations. - * @return */ public void setRepeat(int iter) { if (iter >= 0) { @@ -198,7 +198,6 @@ public void setFrameRate(float fps) { * than 20 do not yield significant improvements in speed. * * @param quality int greater than 0. - * @return */ public void setQuality(int quality) { if (quality < 1) quality = 1; diff --git a/src/de/onyxbits/giftedmotion/CatchOldJava.java b/src/main/java/de/onyxbits/giftedmotion/CatchOldJava.java similarity index 68% rename from src/de/onyxbits/giftedmotion/CatchOldJava.java rename to src/main/java/de/onyxbits/giftedmotion/CatchOldJava.java index a08ecda..bbf8b70 100644 --- a/src/de/onyxbits/giftedmotion/CatchOldJava.java +++ b/src/main/java/de/onyxbits/giftedmotion/CatchOldJava.java @@ -36,12 +36,12 @@ public static void openBrowser(String url) throws Exception { */ public static void decorateWindow(Window w) { try { - ArrayList icolst = new ArrayList(); - icolst.add(new ImageIcon(ClassLoader.getSystemResource("resources/logo-32x32.png")).getImage()); - icolst.add(new ImageIcon(ClassLoader.getSystemResource("resources/logo-48x48.png")).getImage()); - icolst.add(new ImageIcon(ClassLoader.getSystemResource("resources/logo-64x64.png")).getImage()); - icolst.add(new ImageIcon(ClassLoader.getSystemResource("resources/logo-96x96.png")).getImage()); - w.setIconImages(icolst); + var iconList = new ArrayList(); + iconList.add(new ImageIcon(ClassLoader.getSystemResource("resources/logo-32x32.png")).getImage()); + iconList.add(new ImageIcon(ClassLoader.getSystemResource("resources/logo-48x48.png")).getImage()); + iconList.add(new ImageIcon(ClassLoader.getSystemResource("resources/logo-64x64.png")).getImage()); + iconList.add(new ImageIcon(ClassLoader.getSystemResource("resources/logo-96x96.png")).getImage()); + w.setIconImages(iconList); } catch (Throwable t) { // Really don't care. Its just deco diff --git a/src/de/onyxbits/giftedmotion/ColorIcon.java b/src/main/java/de/onyxbits/giftedmotion/ColorIcon.java similarity index 79% rename from src/de/onyxbits/giftedmotion/ColorIcon.java rename to src/main/java/de/onyxbits/giftedmotion/ColorIcon.java index a409650..95e27e0 100644 --- a/src/de/onyxbits/giftedmotion/ColorIcon.java +++ b/src/main/java/de/onyxbits/giftedmotion/ColorIcon.java @@ -7,10 +7,9 @@ */ public class ColorIcon implements Icon { - private Color color; - - private int width; - private int height; + private final Color color; + private final int width; + private final int height; public ColorIcon(Color c, int w, int h) { color=c; @@ -24,16 +23,16 @@ public ColorIcon(Color c, int w, int h) { public Color getColor() { return color;} public void paintIcon(Component c, Graphics g, int x, int y) { + Color tmp = g.getColor(); + if (color==null) { - Color tmp = g.getColor(); IO.createIcon("Tango/16x16/actions/process-stop.png","").paintIcon(c,g,x,y); - g.setColor(tmp); } else { - Color tmp = g.getColor(); g.setColor(color); g.fillRect(x,y,width,height); - g.setColor(tmp); } + + g.setColor(tmp); } } \ No newline at end of file diff --git a/src/de/onyxbits/giftedmotion/Core.java b/src/main/java/de/onyxbits/giftedmotion/Core.java similarity index 74% rename from src/de/onyxbits/giftedmotion/Core.java rename to src/main/java/de/onyxbits/giftedmotion/Core.java index 0727746..2a6013b 100644 --- a/src/de/onyxbits/giftedmotion/Core.java +++ b/src/main/java/de/onyxbits/giftedmotion/Core.java @@ -1,127 +1,83 @@ package de.onyxbits.giftedmotion; + +import javax.swing.*; +import javax.swing.border.BevelBorder; import java.awt.*; -import java.io.*; -import java.util.*; import java.awt.event.*; -import javax.swing.*; -import javax.swing.border.*; -import java.net.*; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; + +import static de.onyxbits.giftedmotion.IO.*; /** * Core class */ -public class Core extends JFrame implements WindowListener, ActionListener, -ComponentListener, MouseMotionListener, MouseListener { +public class Core extends JFrame implements WindowListener, ActionListener, + ComponentListener, MouseMotionListener, MouseListener { - /** - * Program version as shown in the title - */ - public static final String VERSION="GiftedMotion "+Package.getPackage("de.onyxbits.giftedmotion").getImplementationVersion(); - - /** - * Back reference to the running program - */ - public static Core app; + /** Program version as shown in the title */ + public static final String VERSION="GiftedMotion "+ Core.class.getClassLoader().getDefinedPackage("de.onyxbits.giftedmotion").getImplementationVersion(); + + /** Quit program */ + private final JMenuItem quit = new JMenuItem(Dict.get("core.quit"),KeyEvent.VK_Q); - /** - * Quit program - */ - private JMenuItem quit = new JMenuItem(Dict.get("core.quit"),KeyEvent.VK_Q); + /** Load files */ + private final JMenuItem load = new JMenuItem(Dict.get("core.load"),KeyEvent.VK_L); - /** - * Load files - */ - private JMenuItem load = new JMenuItem(Dict.get("core.load"),KeyEvent.VK_L); + /** Export as animated GIF */ + private final JMenuItem export = new JMenuItem(Dict.get("core.export"),KeyEvent.VK_S); - /** - * Export as animated GIF - */ - private JMenuItem export = new JMenuItem(Dict.get("core.export"),KeyEvent.VK_S); + /** Save the sequence as individual files */ + private final JMenuItem extract = new JMenuItem(Dict.get("core.extract"),KeyEvent.VK_E); - /** - * Save the sequence as individual files - */ - private JMenuItem extract = new JMenuItem(Dict.get("core.extract"),KeyEvent.VK_E); + /** Display license */ + private final JMenuItem license = new JMenuItem(Dict.get("core.license")); - /** - * Display license - */ - private JMenuItem license = new JMenuItem(Dict.get("core.license")); + /** Go to homepage */ + private final JMenuItem handbook = new JMenuItem(Dict.get("core.handbook")); - /** - * Go to homepage - */ - private JMenuItem handbook = new JMenuItem(Dict.get("core.handbook")); + /** Go to FAQ */ + private final JMenuItem faq = new JMenuItem(Dict.get("core.faq")); - /** - * Go to FAQ - */ - private JMenuItem faq = new JMenuItem(Dict.get("core.faq")); + /** Play animation */ + private final JButton play = new JButton(createIcon("Tango/22x22/actions/media-playback-start.png",Dict.get("core.play"))); - /** - * Play animation - */ - private JButton play = new JButton(IO.createIcon("Tango/22x22/actions/media-playback-start.png",Dict.get("core.play"))); + /** Pause animation */ + private final JButton pause = new JButton(createIcon("Tango/22x22/actions/media-playback-pause.png",Dict.get("core.pause"))); - /** - * Pause animation - */ - private JButton pause = new JButton(IO.createIcon("Tango/22x22/actions/media-playback-pause.png",Dict.get("core.pause"))); + /** Record (same as export) */ + private final JButton record = new JButton(createIcon("Tango/22x22/actions/media-record.png",Dict.get("core.record"))); - /** - * Record (same as export) - */ - private JButton record = new JButton(IO.createIcon("Tango/22x22/actions/media-record.png",Dict.get("core.record"))); + /** Import (same as load) */ + private final JButton open = new JButton(createIcon("Tango/22x22/actions/document-open.png",Dict.get("core.open"))); - /** - * Import (same as load) - */ - private JButton open = new JButton(IO.createIcon("Tango/22x22/actions/document-open.png",Dict.get("core.open"))); + /** Toggle displaying of the settings window */ + private final JButton togglesettings = new JButton(createIcon("Tango/22x22/categories/preferences-desktop.png",Dict.get("core.togglesettings"))); - /** - * Toggle displaying of the settings window - */ - private JButton togglesettings = new JButton(IO.createIcon("Tango/22x22/categories/preferences-desktop.png",Dict.get("core.togglesettings"))); - - /** - * Sequence Editor - */ + /** Sequence Editor */ private SequenceEditor seqedit; - /** - * Frame Display - */ + /** Frame Display */ private FrameDisplay display; - /** - * Settings editor - */ - private SettingsEditor setedit = new SettingsEditor(); + /** Settings editor */ + private final SettingsEditor setedit = new SettingsEditor(); - /** - * The main workspace - */ - private JDesktopPane workspace = new JDesktopPane(); + /** The main workspace */ + private final JDesktopPane workspace = new JDesktopPane(); - /** - * The framesequence being worked upon - */ + /** The framesequence being worked upon */ private FrameSequence seq; - /** - * Directory, to open filedialogs with - */ + /** Directory, to open filedialogs with */ private File directory = new File(System.getProperty("user.dir")); - /** - * Used for doing an animation preview - */ + /** Used for doing an animation preview */ private Player player; - /** - * For displaying status messages - */ - private JLabel status = new JLabel(); + /** For displaying status messages */ + private final JLabel status = new JLabel(); /** * Construct a new instance of the program. There may only be one object @@ -143,9 +99,9 @@ public Core() { togglesettings.addActionListener(this); // Fancy stuff - quit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,ActionEvent.CTRL_MASK)); - load.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,ActionEvent.CTRL_MASK)); - export.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,ActionEvent.CTRL_MASK)); + quit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK)); + load.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK)); + export.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)); handbook.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1,0)); open.setToolTipText(((ImageIcon)open.getIcon()).getDescription()); play.setToolTipText(((ImageIcon)play.getIcon()).getDescription()); @@ -206,7 +162,7 @@ public Core() { **/ public void windowClosing(WindowEvent e) { handleQuit(); } - public void focusLost(FocusEvent e) {} + public void windowOpened(WindowEvent e) {} public void windowClosed(WindowEvent e) {} public void windowIconified(WindowEvent e) {} @@ -235,9 +191,9 @@ public void componentShown(ComponentEvent e) {} public void componentResized(ComponentEvent e) { Component c = (Component)e.getSource(); - Integer size[] = { - new Integer(c.getWidth()), - new Integer(c.getHeight()) + Integer[] size = { + c.getWidth(), + c.getHeight() }; postStatus(Dict.get("core.componentresized",size)); } @@ -245,9 +201,9 @@ public void componentResized(ComponentEvent e) { public void mouseMoved(MouseEvent e) {} public void mouseDragged(MouseEvent e) { if (seq.selected==null) return; - Integer pos[] = { - new Integer(seq.selected.position.x), - new Integer(seq.selected.position.y) + Integer[] pos = { + seq.selected.position.x, + seq.selected.position.y }; postStatus(Dict.get("core.mousedragged",pos)); } @@ -258,9 +214,9 @@ public void mouseClicked(MouseEvent e) {} public void mousePressed(MouseEvent e) { if (seq.selected==null) return; - Integer pos[] = { - new Integer(seq.selected.position.x), - new Integer(seq.selected.position.y) + Integer[] pos = { + seq.selected.position.x, + seq.selected.position.y }; postStatus(Dict.get("core.mousepressed",pos)); } @@ -302,8 +258,8 @@ public void handleLoad() { return; } - SingleFrame[] frames = IO.load(selected); - if (frames==null || frames.length==0) { + SingleFrame[] frames = load(selected); + if (frames.length == 0) { postStatus(Dict.get("core.handleload.nothing")); return; } @@ -336,7 +292,7 @@ public void handleExtract() { if (jfc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) return; File dest=jfc.getSelectedFile(); directory=jfc.getCurrentDirectory(); - IO.extract(seq,dest); + extract(seq,dest); postStatus(Dict.get("core.handleextract.saved")); } catch (IOException e) { @@ -360,7 +316,7 @@ public void handleExport() { Cursor hourglassCursor = new Cursor(Cursor.WAIT_CURSOR); setCursor(hourglassCursor); postStatus(Dict.get("core.handleexport.saving")); // No idea why this does not show! - IO.export(dest,seq,display.getCanvas().getSize(),setedit.getSettings()); + export(dest,seq,display.getCanvas().getSize(),setedit.getSettings()); postStatus(Dict.get("core.handleexport.finished")); hourglassCursor = new Cursor(Cursor.DEFAULT_CURSOR); setCursor(hourglassCursor); @@ -391,7 +347,7 @@ public void handleLicense() { } public void handleHandbook() { - String url = "http://www.onyxbits.de/giftedmotion/handbook"; + String url = "https://www.onyxbits.de/giftedmotion/handbook"; try { // Wrap this CatchOldJava.openBrowser(url); @@ -403,7 +359,7 @@ public void handleHandbook() { public void handleFAQ() { - String url = "http://www.onyxbits.de/faq/giftedmotion"; + String url = "https://www.onyxbits.de/faq/giftedmotion"; try { // Wrap this CatchOldJava.openBrowser(url); @@ -434,14 +390,10 @@ public void handlePlayPause() { } public void handleTogglesettings() { - if (setedit.isVisible()) setedit.setVisible(false); - else setedit.setVisible(true); + setedit.setVisible(!setedit.isVisible()); } - /** - ** Utility functions - **/ - + /** * Dispatch a new FrameSequence to the application * @param seq the sequence to distribute to all gui elements @@ -484,16 +436,21 @@ public void postStatus(String message) { } - public static void main(String args[]) { - new Dict(); - app = new Core(); + public static void main(String[] args) { + Dict.init(); + + EventQueue.invokeLater(() -> startApp(args)); + } + + private static void startApp(String[] args) { + Core app = new Core(); app.setSize(new Dimension(800,600)); app.setTitle(VERSION); CatchOldJava.decorateWindow(app); - + app.setVisible(true); app.addWindowListener(app); - + // If commandlinearguments are given, try to load them as files // This feature is intended for developer use and may change or go // away in future versions. @@ -503,7 +460,7 @@ public static void main(String args[]) { f[i]=new File(args[i]); } try { - SingleFrame[] frames = IO.load(f); + SingleFrame[] frames = load(f); app.setFrameSequence(new FrameSequence(frames)); } catch (Exception exp) { diff --git a/src/de/onyxbits/giftedmotion/Dict.java b/src/main/java/de/onyxbits/giftedmotion/Dict.java similarity index 85% rename from src/de/onyxbits/giftedmotion/Dict.java rename to src/main/java/de/onyxbits/giftedmotion/Dict.java index d9c5c80..c1fe363 100644 --- a/src/de/onyxbits/giftedmotion/Dict.java +++ b/src/main/java/de/onyxbits/giftedmotion/Dict.java @@ -1,8 +1,6 @@ package de.onyxbits.giftedmotion; import java.util.*; import java.text.*; -import java.io.*; -import java.net.*; /** * This class is responsible for i18n @@ -12,20 +10,22 @@ public class Dict { /** * The "classname" of the resource containing the translations */ - public static final String RSRCNAME = "resources.i18n"; + public static final String RSRCNAME = "i18n"; /** * Contains the translations */ private static ResourceBundle trans; - - + /** * Load the bundle */ - public Dict() { + public static void init() { trans = ResourceBundle.getBundle(RSRCNAME); } + + private Dict() { + } /** * Fetch a key from the i18n file @@ -40,7 +40,7 @@ public static String get(String key) { * @param args the replacement values of the variables in the string */ public static String get(String key, Object[] args) { - String val=null; + String val; try { val = trans.getString(key); } @@ -58,7 +58,7 @@ public static String get(String key, Object[] args) { /** * Fetch a key from the i18n file and replace its variable with a value - * @param args the replacement value of the variable in the string + * @param arg the replacement value of the variable in the string */ public static String get(String key, Object arg) { Object[] tmp = {arg}; diff --git a/src/de/onyxbits/giftedmotion/FrameCanvas.java b/src/main/java/de/onyxbits/giftedmotion/FrameCanvas.java similarity index 93% rename from src/de/onyxbits/giftedmotion/FrameCanvas.java rename to src/main/java/de/onyxbits/giftedmotion/FrameCanvas.java index f925302..59f3649 100644 --- a/src/de/onyxbits/giftedmotion/FrameCanvas.java +++ b/src/main/java/de/onyxbits/giftedmotion/FrameCanvas.java @@ -1,8 +1,11 @@ package de.onyxbits.giftedmotion; + import javax.swing.*; import java.awt.*; -import java.awt.event.*; -import java.awt.image.*; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.image.BufferedImage; /** * The canvas on which to draw SingleFrames @@ -13,7 +16,7 @@ public class FrameCanvas extends JPanel implements FrameSequenceListener, /** * The sequence to draw */ - private FrameSequence seq; + private final FrameSequence seq; /** * Used for dragging -> Where the mousecursor is relative to the position diff --git a/src/de/onyxbits/giftedmotion/FrameDisplay.java b/src/main/java/de/onyxbits/giftedmotion/FrameDisplay.java similarity index 91% rename from src/de/onyxbits/giftedmotion/FrameDisplay.java rename to src/main/java/de/onyxbits/giftedmotion/FrameDisplay.java index ffe7027..a858371 100644 --- a/src/de/onyxbits/giftedmotion/FrameDisplay.java +++ b/src/main/java/de/onyxbits/giftedmotion/FrameDisplay.java @@ -1,6 +1,6 @@ package de.onyxbits.giftedmotion; + import javax.swing.*; -import java.awt.*; /** * Wrapper around the actual canvas class, to glue it into the workspace @@ -10,7 +10,7 @@ public class FrameDisplay extends JInternalFrame { /** * The canvas to draw upon */ - private FrameCanvas canvas; + private final FrameCanvas canvas; public FrameDisplay(FrameCanvas canvas) { diff --git a/src/de/onyxbits/giftedmotion/FrameSequence.java b/src/main/java/de/onyxbits/giftedmotion/FrameSequence.java similarity index 75% rename from src/de/onyxbits/giftedmotion/FrameSequence.java rename to src/main/java/de/onyxbits/giftedmotion/FrameSequence.java index 6d38b47..52948d8 100644 --- a/src/de/onyxbits/giftedmotion/FrameSequence.java +++ b/src/main/java/de/onyxbits/giftedmotion/FrameSequence.java @@ -1,6 +1,7 @@ package de.onyxbits.giftedmotion; import java.awt.*; import java.util.*; +import java.util.List; /** @@ -8,20 +9,14 @@ */ public class FrameSequence { - /** - * The frames, this sequence consists of. - */ + /** The frames, this sequence consists of. */ protected SingleFrame[] frames; - /** - * The frame, that is currently subject to editing; - */ + /** The frame, that is currently subject to editing. */ protected SingleFrame selected; - /** - * Eventlisteners - */ - private Vector listeners = new Vector(); + /** Eventlisteners */ + private final List listeners = new Vector<>(); /** * Create a new FrameSequence @@ -42,12 +37,11 @@ public void add(SingleFrame frame, int index) { if (index>=0 && index<=frames.length) { SingleFrame[] bigger = new SingleFrame[frames.length+1]; // Copy the first few old ones over - for(int i=0;i= 0) + System.arraycopy(frames, index + 1 - 1, bigger, index + 1, bigger.length - (index + 1)); frames=bigger; fireDataChanged(); } @@ -76,8 +70,8 @@ public void remove(SingleFrame frame) { return; } if (frames.length==0) return; - Vector tmp = new Vector(); - for(int i=0;i(); + Collections.addAll(tmp, frames); tmp.remove(frame); frames = new SingleFrame[tmp.size()]; tmp.copyInto(frames); @@ -94,10 +88,10 @@ public void remove(SingleFrame frame) { */ public Dimension getExpansion() { Dimension ret = new Dimension(1,1); - for (int i=0;iret.width) ret.width=d.width; - if (d.height>ret.height) ret.height=d.height; + for (SingleFrame frame : frames) { + Dimension d = frame.getSize(); + if (d.width > ret.width) ret.width = d.width; + if (d.height > ret.height) ret.height = d.height; } return ret; } @@ -115,13 +109,12 @@ public void move (SingleFrame frame, boolean sooner) { if (sooner) { tmp=frames[idx-1]; frames[idx-1]=frames[idx]; - frames[idx]=tmp; } else { tmp=frames[idx+1]; frames[idx+1]=frames[idx]; - frames[idx]=tmp; } + frames[idx]=tmp; fireDataChanged(); } catch (Exception e) { @@ -136,24 +129,13 @@ public void move (SingleFrame frame, boolean sooner) { public void addFrameSequenceListener(FrameSequenceListener fsl) { listeners.add(fsl); } - - /** - * Deregister listener - * @param fsl listener to remove - */ - public void removeFrameSequenceListener(FrameSequenceListener fsl) { - listeners.remove(fsl); - } - + /** * Notify Framesequencelisteners, that the data changed - */ protected void fireDataChanged() { - int size= listeners.size(); - for(int i=0;i(); + + for (File file : files) { + var it = ImageIO.getImageReadersBySuffix(getSuffix(file)); + if (!it.hasNext()) throw new IllegalArgumentException(file.getPath()); + ImageReader reader = it.next(); + reader.setInput(ImageIO.createImageInputStream(new FileInputStream(file))); int ub = reader.getNumImages(true); - - for (int x=0;x lo) { @@ -391,7 +391,7 @@ protected void alterneigh(int rad, int i, int b, int g, int r) { p[0] -= (a * (p[0] - b)) / alpharadbias; p[1] -= (a * (p[1] - g)) / alpharadbias; p[2] -= (a * (p[2] - r)) / alpharadbias; - } catch (Exception e) { + } catch (Exception ignored) { } } } diff --git a/src/de/onyxbits/giftedmotion/Player.java b/src/main/java/de/onyxbits/giftedmotion/Player.java similarity index 88% rename from src/de/onyxbits/giftedmotion/Player.java rename to src/main/java/de/onyxbits/giftedmotion/Player.java index 71da9de..a96e386 100644 --- a/src/de/onyxbits/giftedmotion/Player.java +++ b/src/main/java/de/onyxbits/giftedmotion/Player.java @@ -9,12 +9,12 @@ public class Player extends Thread { /** * The sequence to play */ - private FrameSequence seq; + private final FrameSequence seq; /** * How often to repeat the animation */ - private int repeat; + private final int repeat; /** * Needed to fire events from the event dispatcher thread @@ -23,7 +23,7 @@ public class Player extends Thread { /** * Construct a new Player - * @seq the framesequence to play. + * @param seq the framesequence to play. * @param repeat how often to repeat the animation (zero is infinite) */ public Player(FrameSequence seq, int repeat) { @@ -52,6 +52,6 @@ public void run() { if (repeat!=0 && count<=0) return; } } - catch (Exception exp) {} + catch (Exception ignored) {} } } \ No newline at end of file diff --git a/src/de/onyxbits/giftedmotion/PlayerHelper.java b/src/main/java/de/onyxbits/giftedmotion/PlayerHelper.java similarity index 84% rename from src/de/onyxbits/giftedmotion/PlayerHelper.java rename to src/main/java/de/onyxbits/giftedmotion/PlayerHelper.java index 6134f4b..2f4b844 100644 --- a/src/de/onyxbits/giftedmotion/PlayerHelper.java +++ b/src/main/java/de/onyxbits/giftedmotion/PlayerHelper.java @@ -2,7 +2,8 @@ class PlayerHelper implements Runnable { - private FrameSequence seq; + private final FrameSequence seq; + public PlayerHelper(FrameSequence seq) { this.seq = seq; } diff --git a/src/de/onyxbits/giftedmotion/Preview.java b/src/main/java/de/onyxbits/giftedmotion/Preview.java similarity index 83% rename from src/de/onyxbits/giftedmotion/Preview.java rename to src/main/java/de/onyxbits/giftedmotion/Preview.java index bfb0006..a5c75d0 100644 --- a/src/de/onyxbits/giftedmotion/Preview.java +++ b/src/main/java/de/onyxbits/giftedmotion/Preview.java @@ -1,11 +1,10 @@ package de.onyxbits.giftedmotion; -import java.awt.*; -import java.awt.image.*; -import java.awt.geom.*; + +import javax.imageio.ImageIO; import javax.swing.*; -import java.io.*; -import javax.imageio.*; -import java.util.*; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.File; /** * Preview an image file @@ -27,7 +26,7 @@ public Preview () {} /** * Display an image - * @param file the file to display. If it cannot be loaded, nothing will be + * @param f the file to display. If it cannot be loaded, nothing will be * displayed. */ public void show(File f) { diff --git a/src/de/onyxbits/giftedmotion/SequenceEditor.java b/src/main/java/de/onyxbits/giftedmotion/SequenceEditor.java similarity index 81% rename from src/de/onyxbits/giftedmotion/SequenceEditor.java rename to src/main/java/de/onyxbits/giftedmotion/SequenceEditor.java index 2e82f93..5e950d2 100644 --- a/src/de/onyxbits/giftedmotion/SequenceEditor.java +++ b/src/main/java/de/onyxbits/giftedmotion/SequenceEditor.java @@ -13,7 +13,7 @@ public class SequenceEditor extends JInternalFrame implements ActionListener, /** * Dispose codes in readable form */ - private String[] dcodes = { + private final String[] dcodes = { Dict.get("sequenceeditor.dcodes.0"), Dict.get("sequenceeditor.dcodes.1"), Dict.get("sequenceeditor.dcodes.2"), @@ -23,63 +23,63 @@ public class SequenceEditor extends JInternalFrame implements ActionListener, /** * Lists all frames in the sequence */ - private JList frlst; + private final JList frlst; /** * X Offset */ - private JSpinner xoff = new JSpinner(new SpinnerNumberModel(0,-1000000,1000000,1)); + private final JSpinner xoff = new JSpinner(new SpinnerNumberModel(0,-1000000,1000000,1)); /** * Y Offset */ - private JSpinner yoff = new JSpinner(new SpinnerNumberModel(0,-1000000,1000000,1)); + private final JSpinner yoff = new JSpinner(new SpinnerNumberModel(0,-1000000,1000000,1)); /** * Peer for SingleFrame.showtime */ - private JSpinner showtime = new JSpinner(new SpinnerNumberModel(100,1,1000000,10)); + private final JSpinner showtime = new JSpinner(new SpinnerNumberModel(100,1,1000000,10)); /** * Peer for SingleFrame.dispose */ - private JSpinner dispose = new JSpinner(new SpinnerListModel(dcodes)); + private final JSpinner dispose = new JSpinner(new SpinnerListModel(dcodes)); /** * Move frame in sequence */ - private JButton sooner = new JButton(IO.createIcon("Tango/22x22/actions/go-up.png",Dict.get("sequenceeditor.sooner"))); + private final JButton sooner = new JButton(IO.createIcon("Tango/22x22/actions/go-up.png",Dict.get("sequenceeditor.sooner"))); /** * Mode frame in sequence */ - private JButton later = new JButton(IO.createIcon("Tango/22x22/actions/go-down.png",Dict.get("sequenceeditor.later"))); + private final JButton later = new JButton(IO.createIcon("Tango/22x22/actions/go-down.png",Dict.get("sequenceeditor.later"))); /** * Duplicate current frame */ - private JButton duplicate = new JButton(IO.createIcon("Tango/22x22/actions/edit-copy.png",Dict.get("sequenceeditor.copy"))); + private final JButton duplicate = new JButton(IO.createIcon("Tango/22x22/actions/edit-copy.png",Dict.get("sequenceeditor.copy"))); /** * Trash current frame */ - private JButton delete = new JButton(IO.createIcon("Tango/22x22/actions/edit-delete.png",Dict.get("sequenceeditor.delete"))); + private final JButton delete = new JButton(IO.createIcon("Tango/22x22/actions/edit-delete.png",Dict.get("sequenceeditor.delete"))); /** * The checkbox to apply the changes to all frames */ - private JCheckBox apply = new JCheckBox(Dict.get("sequenceeditor.apply"),false); + private final JCheckBox apply = new JCheckBox(Dict.get("sequenceeditor.apply"),false); /** * The framesequence, displayed */ - private FrameSequence seq; + private final FrameSequence seq; public SequenceEditor(FrameSequence seq) { super(Dict.get("sequenceeditor.sequenceeditor.title"),false,false,false,false); this.seq=seq; - frlst = new JList(seq.frames); + frlst = new JList<>(seq.frames); setContentPane(getContent()); pack(); @@ -124,22 +124,6 @@ private JPanel getContent() { order.add(new JScrollPane(frlst)); order.add(buttons); - -/* - JPanel settings = new JPanel(); - settings.setBorder(BorderFactory.createTitledBorder(Dict.get("sequenceeditor.getcontent.settings"))); - settings.setLayout(new GridLayout(5,0)); - settings.add(new JLabel(Dict.get("sequenceeditor.getcontent.showtime"))); - settings.add(showtime); - settings.add(new JLabel(Dict.get("sequenceeditor.getcontent.dispose"))); - settings.add(dispose); - settings.add(new JLabel(Dict.get("sequenceeditor.getcontent.xoff"))); - settings.add(xoff); - settings.add(new JLabel(Dict.get("sequenceeditor.getcontent.yoff"))); - settings.add(yoff); - settings.add(apply); -*/ - JLabel label0 = new JLabel(Dict.get("sequenceeditor.getcontent.showtime")); JLabel label1 = new JLabel(Dict.get("sequenceeditor.getcontent.dispose")); @@ -325,11 +309,11 @@ public void stateChanged(ChangeEvent e) { Object src = e.getSource(); if (src==showtime) { - int val=((Integer)showtime.getValue()).intValue(); + int val= (Integer) showtime.getValue(); if (apply.isSelected()) { for (int i=0;i