From 5d647d4b2fd2630c6439cf60d980901651f3d099 Mon Sep 17 00:00:00 2001 From: calculon102 Date: Wed, 1 Dec 2021 23:41:17 +0100 Subject: [PATCH 1/8] Fix compile errors --- src/de/onyxbits/giftedmotion/Core.java | 35 ++++++++++--------- src/de/onyxbits/giftedmotion/FrameCanvas.java | 7 ++-- .../onyxbits/giftedmotion/FrameDisplay.java | 2 +- .../giftedmotion/FrameSequenceListener.java | 3 +- src/de/onyxbits/giftedmotion/Settings.java | 3 +- .../onyxbits/giftedmotion/SettingsEditor.java | 20 ++++++----- src/de/onyxbits/giftedmotion/SingleFrame.java | 2 +- 7 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/de/onyxbits/giftedmotion/Core.java b/src/de/onyxbits/giftedmotion/Core.java index 0727746..7e6cbdd 100644 --- a/src/de/onyxbits/giftedmotion/Core.java +++ b/src/de/onyxbits/giftedmotion/Core.java @@ -1,17 +1,20 @@ 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 @@ -61,27 +64,27 @@ public class Core extends JFrame implements WindowListener, ActionListener, /** * Play animation */ - private JButton play = new JButton(IO.createIcon("Tango/22x22/actions/media-playback-start.png",Dict.get("core.play"))); + private JButton play = new JButton(createIcon("Tango/22x22/actions/media-playback-start.png",Dict.get("core.play"))); /** * Pause animation */ - private JButton pause = new JButton(IO.createIcon("Tango/22x22/actions/media-playback-pause.png",Dict.get("core.pause"))); + private JButton pause = new JButton(createIcon("Tango/22x22/actions/media-playback-pause.png",Dict.get("core.pause"))); /** * Record (same as export) */ - private JButton record = new JButton(IO.createIcon("Tango/22x22/actions/media-record.png",Dict.get("core.record"))); + private JButton record = new JButton(createIcon("Tango/22x22/actions/media-record.png",Dict.get("core.record"))); /** * Import (same as load) */ - private JButton open = new JButton(IO.createIcon("Tango/22x22/actions/document-open.png",Dict.get("core.open"))); + private JButton open = new JButton(createIcon("Tango/22x22/actions/document-open.png",Dict.get("core.open"))); /** * Toggle displaying of the settings window */ - private JButton togglesettings = new JButton(IO.createIcon("Tango/22x22/categories/preferences-desktop.png",Dict.get("core.togglesettings"))); + private JButton togglesettings = new JButton(createIcon("Tango/22x22/categories/preferences-desktop.png",Dict.get("core.togglesettings"))); /** * Sequence Editor @@ -302,7 +305,7 @@ public void handleLoad() { return; } - SingleFrame[] frames = IO.load(selected); + SingleFrame[] frames = load(selected); if (frames==null || frames.length==0) { postStatus(Dict.get("core.handleload.nothing")); return; @@ -336,7 +339,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 +363,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); @@ -503,7 +506,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/FrameCanvas.java b/src/de/onyxbits/giftedmotion/FrameCanvas.java index f925302..3033b5e 100644 --- a/src/de/onyxbits/giftedmotion/FrameCanvas.java +++ b/src/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 diff --git a/src/de/onyxbits/giftedmotion/FrameDisplay.java b/src/de/onyxbits/giftedmotion/FrameDisplay.java index ffe7027..4e5adca 100644 --- a/src/de/onyxbits/giftedmotion/FrameDisplay.java +++ b/src/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 diff --git a/src/de/onyxbits/giftedmotion/FrameSequenceListener.java b/src/de/onyxbits/giftedmotion/FrameSequenceListener.java index 72998c3..156c70c 100644 --- a/src/de/onyxbits/giftedmotion/FrameSequenceListener.java +++ b/src/de/onyxbits/giftedmotion/FrameSequenceListener.java @@ -1,5 +1,4 @@ package de.onyxbits.giftedmotion; -import java.awt.event.*; /** * Implementors of this class can request to be notified of changes in a @@ -11,5 +10,5 @@ public interface FrameSequenceListener { * Called, when the data of a FrameSequence changes * @param src the source FrameSequence */ - public void dataChanged(FrameSequence src); + void dataChanged(FrameSequence src); } \ No newline at end of file diff --git a/src/de/onyxbits/giftedmotion/Settings.java b/src/de/onyxbits/giftedmotion/Settings.java index 36c71a6..f2b9872 100644 --- a/src/de/onyxbits/giftedmotion/Settings.java +++ b/src/de/onyxbits/giftedmotion/Settings.java @@ -1,5 +1,6 @@ package de.onyxbits.giftedmotion; -import java.awt.*; + +import java.awt.Color; /** * The settings to use when rendering diff --git a/src/de/onyxbits/giftedmotion/SettingsEditor.java b/src/de/onyxbits/giftedmotion/SettingsEditor.java index 3d74181..f5d96ce 100644 --- a/src/de/onyxbits/giftedmotion/SettingsEditor.java +++ b/src/de/onyxbits/giftedmotion/SettingsEditor.java @@ -1,9 +1,11 @@ package de.onyxbits.giftedmotion; + import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import java.awt.*; -import java.beans.*; -import javax.swing.event.*; -import java.awt.event.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * Display settings to be used for exporting the frames into the actual @@ -15,23 +17,23 @@ public class SettingsEditor extends JInternalFrame implements ChangeListener, /** * How often to repeat */ - private JSpinner repeat = new JSpinner(new SpinnerNumberModel(0,-1,10000,1)); + private final JSpinner repeat = new JSpinner(new SpinnerNumberModel(0,-1,10000,1)); /** * Quality of the dithering */ - private JSpinner quality = new JSpinner(new SpinnerNumberModel(1,1,256,1)); + private final JSpinner quality = new JSpinner(new SpinnerNumberModel(1,1,256,1)); /** * The transparency color */ - private JButton trans = new JButton(new ColorIcon(Color.MAGENTA,16,16)); + private final JButton trans = new JButton(new ColorIcon(Color.MAGENTA,16,16)); /** * The colorchooser for the transparency color */ - private JColorChooser chooser = new JColorChooser(Color.MAGENTA); + private final JColorChooser chooser = new JColorChooser(Color.MAGENTA); public SettingsEditor() { super(Dict.get("settingseditor.settingseditor.title"),false,true,false,false); @@ -75,8 +77,8 @@ private JPanel getContent() { public Settings getSettings() { Settings ret = new Settings(); ret.transparent=((ColorIcon)trans.getIcon()).getColor(); - ret.quality=((Integer)quality.getValue()).intValue(); - ret.repeat=((Integer)repeat.getValue()).intValue(); + ret.quality= (Integer) quality.getValue(); + ret.repeat= (Integer) repeat.getValue(); return ret; } diff --git a/src/de/onyxbits/giftedmotion/SingleFrame.java b/src/de/onyxbits/giftedmotion/SingleFrame.java index 68755f8..cf755fa 100644 --- a/src/de/onyxbits/giftedmotion/SingleFrame.java +++ b/src/de/onyxbits/giftedmotion/SingleFrame.java @@ -70,7 +70,7 @@ public Dimension getSize() { /** * Specify position of the raw image on the canvas - * @param r the x and y coordinate of where to draw the raw image on the + * @param p the x and y coordinate of where to draw the raw image on the * canvas. */ public void setPosition(Point p) { position=p; } From 14bb5414fec05f979ad3010a7c3233af276a03fb Mon Sep 17 00:00:00 2001 From: calculon102 Date: Wed, 1 Dec 2021 23:51:08 +0100 Subject: [PATCH 2/8] Convert to maven structure --- .gitignore | 6 +++++- .../onyxbits/giftedmotion/AnimatedGifEncoder.java | 0 .../de/onyxbits/giftedmotion/CatchOldJava.java | 0 .../java}/de/onyxbits/giftedmotion/ColorIcon.java | 0 .../java}/de/onyxbits/giftedmotion/Core.java | 0 .../java}/de/onyxbits/giftedmotion/Dict.java | 2 +- .../java}/de/onyxbits/giftedmotion/FrameCanvas.java | 0 .../de/onyxbits/giftedmotion/FrameDisplay.java | 0 .../de/onyxbits/giftedmotion/FrameSequence.java | 0 .../giftedmotion/FrameSequenceListener.java | 0 .../java}/de/onyxbits/giftedmotion/IO.java | 2 +- .../de/onyxbits/giftedmotion/ImageFileFilter.java | 0 .../java}/de/onyxbits/giftedmotion/LZWEncoder.java | 0 .../de/onyxbits/giftedmotion/LoadAccessory.java | 0 .../java}/de/onyxbits/giftedmotion/NeuQuant.java | 0 .../java}/de/onyxbits/giftedmotion/Player.java | 0 .../de/onyxbits/giftedmotion/PlayerHelper.java | 0 .../java}/de/onyxbits/giftedmotion/Preview.java | 0 .../de/onyxbits/giftedmotion/SequenceEditor.java | 0 .../java}/de/onyxbits/giftedmotion/Settings.java | 0 .../de/onyxbits/giftedmotion/SettingsEditor.java | 0 .../java}/de/onyxbits/giftedmotion/SingleFrame.java | 0 {resources => src/main/resources}/LICENSE | 0 {resources => src/main/resources}/i18n.properties | 0 .../main/resources}/i18n_de.properties | 0 .../main/resources}/i18n_it.properties | 0 .../main/resources}/i18n_pl_PL.properties | 0 .../main/resources}/i18n_pt_BR.properties | 0 .../icons/Tango/16x16/actions/process-stop.png | Bin .../icons/Tango/22x22/actions/document-open.png | Bin .../icons/Tango/22x22/actions/edit-copy.png | Bin .../icons/Tango/22x22/actions/edit-delete.png | Bin .../icons/Tango/22x22/actions/go-down.png | Bin .../resources}/icons/Tango/22x22/actions/go-up.png | Bin .../Tango/22x22/actions/media-playback-pause.png | Bin .../Tango/22x22/actions/media-playback-start.png | Bin .../icons/Tango/22x22/actions/media-record.png | Bin .../Tango/22x22/categories/preferences-desktop.png | Bin {resources => src/main/resources}/logo-32x32.png | Bin {resources => src/main/resources}/logo-48x48.png | Bin {resources => src/main/resources}/logo-64x64.png | Bin {resources => src/main/resources}/logo-96x96.png | Bin {resources => src/main/resources}/logo.svg | 0 43 files changed, 7 insertions(+), 3 deletions(-) rename src/{ => main/java}/de/onyxbits/giftedmotion/AnimatedGifEncoder.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/CatchOldJava.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/ColorIcon.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/Core.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/Dict.java (96%) rename src/{ => main/java}/de/onyxbits/giftedmotion/FrameCanvas.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/FrameDisplay.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/FrameSequence.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/FrameSequenceListener.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/IO.java (98%) rename src/{ => main/java}/de/onyxbits/giftedmotion/ImageFileFilter.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/LZWEncoder.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/LoadAccessory.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/NeuQuant.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/Player.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/PlayerHelper.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/Preview.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/SequenceEditor.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/Settings.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/SettingsEditor.java (100%) rename src/{ => main/java}/de/onyxbits/giftedmotion/SingleFrame.java (100%) rename {resources => src/main/resources}/LICENSE (100%) rename {resources => src/main/resources}/i18n.properties (100%) rename {resources => src/main/resources}/i18n_de.properties (100%) rename {resources => src/main/resources}/i18n_it.properties (100%) rename {resources => src/main/resources}/i18n_pl_PL.properties (100%) rename {resources => src/main/resources}/i18n_pt_BR.properties (100%) rename {resources => src/main/resources}/icons/Tango/16x16/actions/process-stop.png (100%) rename {resources => src/main/resources}/icons/Tango/22x22/actions/document-open.png (100%) rename {resources => src/main/resources}/icons/Tango/22x22/actions/edit-copy.png (100%) rename {resources => src/main/resources}/icons/Tango/22x22/actions/edit-delete.png (100%) rename {resources => src/main/resources}/icons/Tango/22x22/actions/go-down.png (100%) rename {resources => src/main/resources}/icons/Tango/22x22/actions/go-up.png (100%) rename {resources => src/main/resources}/icons/Tango/22x22/actions/media-playback-pause.png (100%) rename {resources => src/main/resources}/icons/Tango/22x22/actions/media-playback-start.png (100%) rename {resources => src/main/resources}/icons/Tango/22x22/actions/media-record.png (100%) rename {resources => src/main/resources}/icons/Tango/22x22/categories/preferences-desktop.png (100%) rename {resources => src/main/resources}/logo-32x32.png (100%) rename {resources => src/main/resources}/logo-48x48.png (100%) rename {resources => src/main/resources}/logo-64x64.png (100%) rename {resources => src/main/resources}/logo-96x96.png (100%) rename {resources => src/main/resources}/logo.svg (100%) diff --git a/.gitignore b/.gitignore index bf2a885..4568865 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ *.class *~ DEADJOE -*.jar \ No newline at end of file +*.jar + +out/** +.idea +GiftedMotion.iml \ 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 100% rename from src/de/onyxbits/giftedmotion/AnimatedGifEncoder.java rename to src/main/java/de/onyxbits/giftedmotion/AnimatedGifEncoder.java diff --git a/src/de/onyxbits/giftedmotion/CatchOldJava.java b/src/main/java/de/onyxbits/giftedmotion/CatchOldJava.java similarity index 100% rename from src/de/onyxbits/giftedmotion/CatchOldJava.java rename to src/main/java/de/onyxbits/giftedmotion/CatchOldJava.java diff --git a/src/de/onyxbits/giftedmotion/ColorIcon.java b/src/main/java/de/onyxbits/giftedmotion/ColorIcon.java similarity index 100% rename from src/de/onyxbits/giftedmotion/ColorIcon.java rename to src/main/java/de/onyxbits/giftedmotion/ColorIcon.java diff --git a/src/de/onyxbits/giftedmotion/Core.java b/src/main/java/de/onyxbits/giftedmotion/Core.java similarity index 100% rename from src/de/onyxbits/giftedmotion/Core.java rename to src/main/java/de/onyxbits/giftedmotion/Core.java diff --git a/src/de/onyxbits/giftedmotion/Dict.java b/src/main/java/de/onyxbits/giftedmotion/Dict.java similarity index 96% rename from src/de/onyxbits/giftedmotion/Dict.java rename to src/main/java/de/onyxbits/giftedmotion/Dict.java index d9c5c80..141f8e8 100644 --- a/src/de/onyxbits/giftedmotion/Dict.java +++ b/src/main/java/de/onyxbits/giftedmotion/Dict.java @@ -12,7 +12,7 @@ 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 diff --git a/src/de/onyxbits/giftedmotion/FrameCanvas.java b/src/main/java/de/onyxbits/giftedmotion/FrameCanvas.java similarity index 100% rename from src/de/onyxbits/giftedmotion/FrameCanvas.java rename to src/main/java/de/onyxbits/giftedmotion/FrameCanvas.java diff --git a/src/de/onyxbits/giftedmotion/FrameDisplay.java b/src/main/java/de/onyxbits/giftedmotion/FrameDisplay.java similarity index 100% rename from src/de/onyxbits/giftedmotion/FrameDisplay.java rename to src/main/java/de/onyxbits/giftedmotion/FrameDisplay.java diff --git a/src/de/onyxbits/giftedmotion/FrameSequence.java b/src/main/java/de/onyxbits/giftedmotion/FrameSequence.java similarity index 100% rename from src/de/onyxbits/giftedmotion/FrameSequence.java rename to src/main/java/de/onyxbits/giftedmotion/FrameSequence.java diff --git a/src/de/onyxbits/giftedmotion/FrameSequenceListener.java b/src/main/java/de/onyxbits/giftedmotion/FrameSequenceListener.java similarity index 100% rename from src/de/onyxbits/giftedmotion/FrameSequenceListener.java rename to src/main/java/de/onyxbits/giftedmotion/FrameSequenceListener.java diff --git a/src/de/onyxbits/giftedmotion/IO.java b/src/main/java/de/onyxbits/giftedmotion/IO.java similarity index 98% rename from src/de/onyxbits/giftedmotion/IO.java rename to src/main/java/de/onyxbits/giftedmotion/IO.java index 1b55234..acf7209 100644 --- a/src/de/onyxbits/giftedmotion/IO.java +++ b/src/main/java/de/onyxbits/giftedmotion/IO.java @@ -121,7 +121,7 @@ public static void extract(FrameSequence seq, File dir) throws IOException { * @return the loaded icon */ public static ImageIcon createIcon(String fname,String desc) { - URL imgURL = new Object().getClass().getResource("/resources/icons/"+fname); + URL imgURL = IO.class.getResource("/icons/"+fname); return new ImageIcon(imgURL,desc); } diff --git a/src/de/onyxbits/giftedmotion/ImageFileFilter.java b/src/main/java/de/onyxbits/giftedmotion/ImageFileFilter.java similarity index 100% rename from src/de/onyxbits/giftedmotion/ImageFileFilter.java rename to src/main/java/de/onyxbits/giftedmotion/ImageFileFilter.java diff --git a/src/de/onyxbits/giftedmotion/LZWEncoder.java b/src/main/java/de/onyxbits/giftedmotion/LZWEncoder.java similarity index 100% rename from src/de/onyxbits/giftedmotion/LZWEncoder.java rename to src/main/java/de/onyxbits/giftedmotion/LZWEncoder.java diff --git a/src/de/onyxbits/giftedmotion/LoadAccessory.java b/src/main/java/de/onyxbits/giftedmotion/LoadAccessory.java similarity index 100% rename from src/de/onyxbits/giftedmotion/LoadAccessory.java rename to src/main/java/de/onyxbits/giftedmotion/LoadAccessory.java diff --git a/src/de/onyxbits/giftedmotion/NeuQuant.java b/src/main/java/de/onyxbits/giftedmotion/NeuQuant.java similarity index 100% rename from src/de/onyxbits/giftedmotion/NeuQuant.java rename to src/main/java/de/onyxbits/giftedmotion/NeuQuant.java diff --git a/src/de/onyxbits/giftedmotion/Player.java b/src/main/java/de/onyxbits/giftedmotion/Player.java similarity index 100% rename from src/de/onyxbits/giftedmotion/Player.java rename to src/main/java/de/onyxbits/giftedmotion/Player.java diff --git a/src/de/onyxbits/giftedmotion/PlayerHelper.java b/src/main/java/de/onyxbits/giftedmotion/PlayerHelper.java similarity index 100% rename from src/de/onyxbits/giftedmotion/PlayerHelper.java rename to src/main/java/de/onyxbits/giftedmotion/PlayerHelper.java diff --git a/src/de/onyxbits/giftedmotion/Preview.java b/src/main/java/de/onyxbits/giftedmotion/Preview.java similarity index 100% rename from src/de/onyxbits/giftedmotion/Preview.java rename to src/main/java/de/onyxbits/giftedmotion/Preview.java diff --git a/src/de/onyxbits/giftedmotion/SequenceEditor.java b/src/main/java/de/onyxbits/giftedmotion/SequenceEditor.java similarity index 100% rename from src/de/onyxbits/giftedmotion/SequenceEditor.java rename to src/main/java/de/onyxbits/giftedmotion/SequenceEditor.java diff --git a/src/de/onyxbits/giftedmotion/Settings.java b/src/main/java/de/onyxbits/giftedmotion/Settings.java similarity index 100% rename from src/de/onyxbits/giftedmotion/Settings.java rename to src/main/java/de/onyxbits/giftedmotion/Settings.java diff --git a/src/de/onyxbits/giftedmotion/SettingsEditor.java b/src/main/java/de/onyxbits/giftedmotion/SettingsEditor.java similarity index 100% rename from src/de/onyxbits/giftedmotion/SettingsEditor.java rename to src/main/java/de/onyxbits/giftedmotion/SettingsEditor.java diff --git a/src/de/onyxbits/giftedmotion/SingleFrame.java b/src/main/java/de/onyxbits/giftedmotion/SingleFrame.java similarity index 100% rename from src/de/onyxbits/giftedmotion/SingleFrame.java rename to src/main/java/de/onyxbits/giftedmotion/SingleFrame.java diff --git a/resources/LICENSE b/src/main/resources/LICENSE similarity index 100% rename from resources/LICENSE rename to src/main/resources/LICENSE diff --git a/resources/i18n.properties b/src/main/resources/i18n.properties similarity index 100% rename from resources/i18n.properties rename to src/main/resources/i18n.properties diff --git a/resources/i18n_de.properties b/src/main/resources/i18n_de.properties similarity index 100% rename from resources/i18n_de.properties rename to src/main/resources/i18n_de.properties diff --git a/resources/i18n_it.properties b/src/main/resources/i18n_it.properties similarity index 100% rename from resources/i18n_it.properties rename to src/main/resources/i18n_it.properties diff --git a/resources/i18n_pl_PL.properties b/src/main/resources/i18n_pl_PL.properties similarity index 100% rename from resources/i18n_pl_PL.properties rename to src/main/resources/i18n_pl_PL.properties diff --git a/resources/i18n_pt_BR.properties b/src/main/resources/i18n_pt_BR.properties similarity index 100% rename from resources/i18n_pt_BR.properties rename to src/main/resources/i18n_pt_BR.properties diff --git a/resources/icons/Tango/16x16/actions/process-stop.png b/src/main/resources/icons/Tango/16x16/actions/process-stop.png similarity index 100% rename from resources/icons/Tango/16x16/actions/process-stop.png rename to src/main/resources/icons/Tango/16x16/actions/process-stop.png diff --git a/resources/icons/Tango/22x22/actions/document-open.png b/src/main/resources/icons/Tango/22x22/actions/document-open.png similarity index 100% rename from resources/icons/Tango/22x22/actions/document-open.png rename to src/main/resources/icons/Tango/22x22/actions/document-open.png diff --git a/resources/icons/Tango/22x22/actions/edit-copy.png b/src/main/resources/icons/Tango/22x22/actions/edit-copy.png similarity index 100% rename from resources/icons/Tango/22x22/actions/edit-copy.png rename to src/main/resources/icons/Tango/22x22/actions/edit-copy.png diff --git a/resources/icons/Tango/22x22/actions/edit-delete.png b/src/main/resources/icons/Tango/22x22/actions/edit-delete.png similarity index 100% rename from resources/icons/Tango/22x22/actions/edit-delete.png rename to src/main/resources/icons/Tango/22x22/actions/edit-delete.png diff --git a/resources/icons/Tango/22x22/actions/go-down.png b/src/main/resources/icons/Tango/22x22/actions/go-down.png similarity index 100% rename from resources/icons/Tango/22x22/actions/go-down.png rename to src/main/resources/icons/Tango/22x22/actions/go-down.png diff --git a/resources/icons/Tango/22x22/actions/go-up.png b/src/main/resources/icons/Tango/22x22/actions/go-up.png similarity index 100% rename from resources/icons/Tango/22x22/actions/go-up.png rename to src/main/resources/icons/Tango/22x22/actions/go-up.png diff --git a/resources/icons/Tango/22x22/actions/media-playback-pause.png b/src/main/resources/icons/Tango/22x22/actions/media-playback-pause.png similarity index 100% rename from resources/icons/Tango/22x22/actions/media-playback-pause.png rename to src/main/resources/icons/Tango/22x22/actions/media-playback-pause.png diff --git a/resources/icons/Tango/22x22/actions/media-playback-start.png b/src/main/resources/icons/Tango/22x22/actions/media-playback-start.png similarity index 100% rename from resources/icons/Tango/22x22/actions/media-playback-start.png rename to src/main/resources/icons/Tango/22x22/actions/media-playback-start.png diff --git a/resources/icons/Tango/22x22/actions/media-record.png b/src/main/resources/icons/Tango/22x22/actions/media-record.png similarity index 100% rename from resources/icons/Tango/22x22/actions/media-record.png rename to src/main/resources/icons/Tango/22x22/actions/media-record.png diff --git a/resources/icons/Tango/22x22/categories/preferences-desktop.png b/src/main/resources/icons/Tango/22x22/categories/preferences-desktop.png similarity index 100% rename from resources/icons/Tango/22x22/categories/preferences-desktop.png rename to src/main/resources/icons/Tango/22x22/categories/preferences-desktop.png diff --git a/resources/logo-32x32.png b/src/main/resources/logo-32x32.png similarity index 100% rename from resources/logo-32x32.png rename to src/main/resources/logo-32x32.png diff --git a/resources/logo-48x48.png b/src/main/resources/logo-48x48.png similarity index 100% rename from resources/logo-48x48.png rename to src/main/resources/logo-48x48.png diff --git a/resources/logo-64x64.png b/src/main/resources/logo-64x64.png similarity index 100% rename from resources/logo-64x64.png rename to src/main/resources/logo-64x64.png diff --git a/resources/logo-96x96.png b/src/main/resources/logo-96x96.png similarity index 100% rename from resources/logo-96x96.png rename to src/main/resources/logo-96x96.png diff --git a/resources/logo.svg b/src/main/resources/logo.svg similarity index 100% rename from resources/logo.svg rename to src/main/resources/logo.svg From 27a787bcbaaf128290550045c5ff9804ad4f66f4 Mon Sep 17 00:00:00 2001 From: calculon102 Date: Thu, 2 Dec 2021 00:02:55 +0100 Subject: [PATCH 3/8] Fixed most warnings in Core --- .../java/de/onyxbits/giftedmotion/Core.java | 174 +++++++----------- .../java/de/onyxbits/giftedmotion/Dict.java | 12 +- 2 files changed, 71 insertions(+), 115 deletions(-) diff --git a/src/main/java/de/onyxbits/giftedmotion/Core.java b/src/main/java/de/onyxbits/giftedmotion/Core.java index 7e6cbdd..87edcb4 100644 --- a/src/main/java/de/onyxbits/giftedmotion/Core.java +++ b/src/main/java/de/onyxbits/giftedmotion/Core.java @@ -16,115 +16,68 @@ 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(); + /** 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); - /** - * Back reference to the running program - */ - public static Core app; + /** Load files */ + private final JMenuItem load = new JMenuItem(Dict.get("core.load"),KeyEvent.VK_L); - /** - * Quit program - */ - private JMenuItem quit = new JMenuItem(Dict.get("core.quit"),KeyEvent.VK_Q); + /** Export as animated GIF */ + private final JMenuItem export = new JMenuItem(Dict.get("core.export"),KeyEvent.VK_S); - /** - * Load files - */ - private JMenuItem load = new JMenuItem(Dict.get("core.load"),KeyEvent.VK_L); + /** Save the sequence as individual files */ + private final JMenuItem extract = new JMenuItem(Dict.get("core.extract"),KeyEvent.VK_E); - /** - * Export as animated GIF - */ - private JMenuItem export = new JMenuItem(Dict.get("core.export"),KeyEvent.VK_S); + /** Display license */ + private final JMenuItem license = new JMenuItem(Dict.get("core.license")); - /** - * Save the sequence as individual files - */ - private JMenuItem extract = new JMenuItem(Dict.get("core.extract"),KeyEvent.VK_E); - - /** - * 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(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(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(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(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(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 @@ -146,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_MASK)); + load.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_MASK)); + export.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); handbook.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1,0)); open.setToolTipText(((ImageIcon)open.getIcon()).getDescription()); play.setToolTipText(((ImageIcon)play.getIcon()).getDescription()); @@ -209,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) {} @@ -238,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)); } @@ -248,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)); } @@ -261,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)); } @@ -306,7 +259,7 @@ public void handleLoad() { } SingleFrame[] frames = load(selected); - if (frames==null || frames.length==0) { + if (frames.length == 0) { postStatus(Dict.get("core.handleload.nothing")); return; } @@ -437,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 @@ -487,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. diff --git a/src/main/java/de/onyxbits/giftedmotion/Dict.java b/src/main/java/de/onyxbits/giftedmotion/Dict.java index 141f8e8..d6bec65 100644 --- a/src/main/java/de/onyxbits/giftedmotion/Dict.java +++ b/src/main/java/de/onyxbits/giftedmotion/Dict.java @@ -18,14 +18,16 @@ public class Dict { * 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 +42,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 +60,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}; From 43ffae3b2fc35e4c241755bb5b1ff379d4a5ab9d Mon Sep 17 00:00:00 2001 From: calculon102 Date: Thu, 2 Dec 2021 00:12:03 +0100 Subject: [PATCH 4/8] Add Maven build and IDE-settings --- .gitignore | 3 +-- .idea/.gitignore | 8 +++++++ .idea/compiler.xml | 16 +++++++++++++ .idea/jarRepositories.xml | 20 ++++++++++++++++ .idea/misc.xml | 13 ++++++++++ .idea/modules.xml | 8 +++++++ .idea/runConfigurations.xml | 10 ++++++++ .idea/vcs.xml | 6 +++++ build.xml | 28 ---------------------- pom.xml | 32 +++++++++++++++++++++++++ src/main/resources/META-INF/MANIFEST.MF | 0 11 files changed, 114 insertions(+), 30 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/runConfigurations.xml create mode 100644 .idea/vcs.xml delete mode 100644 build.xml create mode 100644 pom.xml create mode 100644 src/main/resources/META-INF/MANIFEST.MF diff --git a/.gitignore b/.gitignore index 4568865..56a4081 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,5 @@ DEADJOE *.jar -out/** -.idea +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..904df38 --- /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/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..e69de29 From 1326a0df044b049d8f7b41adb396cb9ceb184574 Mon Sep 17 00:00:00 2001 From: calculon102 Date: Thu, 2 Dec 2021 00:15:36 +0100 Subject: [PATCH 5/8] Fixed warnings in IO --- pom.xml | 2 +- .../java/de/onyxbits/giftedmotion/IO.java | 76 ++++++++++--------- 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/pom.xml b/pom.xml index 904df38..6dc8732 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ de.onysbits.giftedmotion GiftedMotion 1.3-SNAPSHOT - + UTF-8 11 diff --git a/src/main/java/de/onyxbits/giftedmotion/IO.java b/src/main/java/de/onyxbits/giftedmotion/IO.java index acf7209..ff987f8 100644 --- a/src/main/java/de/onyxbits/giftedmotion/IO.java +++ b/src/main/java/de/onyxbits/giftedmotion/IO.java @@ -1,14 +1,20 @@ package de.onyxbits.giftedmotion; -import java.io.*; -import java.util.*; -import java.awt.*; -import java.awt.image.*; + +import org.w3c.dom.NodeList; + +import javax.imageio.ImageIO; +import javax.imageio.ImageReader; +import javax.imageio.metadata.IIOMetadata; +import javax.imageio.metadata.IIOMetadataNode; import javax.swing.*; -import java.net.*; -import javax.imageio.*; -import java.awt.image.*; -import javax.imageio.metadata.*; -import org.w3c.dom.*; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.util.Vector; /** * Responsible for doing all the disk IO related things @@ -27,47 +33,47 @@ private IO() { * thrown. * be loaded will be represented by an errorshape. */ - public static SingleFrame[] load(File[] files) throws IOException, FileNotFoundException, IllegalArgumentException { - Vector tmp = new Vector(); - 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 Date: Thu, 2 Dec 2021 00:29:08 +0100 Subject: [PATCH 6/8] Fixed most warnings and linter-errors --- .../giftedmotion/AnimatedGifEncoder.java | 2 - .../onyxbits/giftedmotion/CatchOldJava.java | 12 ++--- .../de/onyxbits/giftedmotion/ColorIcon.java | 15 +++--- .../java/de/onyxbits/giftedmotion/Dict.java | 2 - .../de/onyxbits/giftedmotion/FrameCanvas.java | 2 +- .../onyxbits/giftedmotion/FrameDisplay.java | 2 +- .../onyxbits/giftedmotion/FrameSequence.java | 44 ++++++----------- .../giftedmotion/ImageFileFilter.java | 10 ++-- .../de/onyxbits/giftedmotion/LZWEncoder.java | 9 ++-- .../onyxbits/giftedmotion/LoadAccessory.java | 13 +++-- .../java/de/onyxbits/giftedmotion/Player.java | 2 +- .../onyxbits/giftedmotion/PlayerHelper.java | 3 +- .../de/onyxbits/giftedmotion/Preview.java | 13 +++-- .../onyxbits/giftedmotion/SequenceEditor.java | 47 +++++++++---------- .../de/onyxbits/giftedmotion/SingleFrame.java | 3 +- 15 files changed, 78 insertions(+), 101 deletions(-) diff --git a/src/main/java/de/onyxbits/giftedmotion/AnimatedGifEncoder.java b/src/main/java/de/onyxbits/giftedmotion/AnimatedGifEncoder.java index 327cd3c..f0d3c66 100644 --- a/src/main/java/de/onyxbits/giftedmotion/AnimatedGifEncoder.java +++ b/src/main/java/de/onyxbits/giftedmotion/AnimatedGifEncoder.java @@ -77,7 +77,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 +197,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/main/java/de/onyxbits/giftedmotion/CatchOldJava.java b/src/main/java/de/onyxbits/giftedmotion/CatchOldJava.java index a08ecda..bbf8b70 100644 --- a/src/main/java/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/main/java/de/onyxbits/giftedmotion/ColorIcon.java b/src/main/java/de/onyxbits/giftedmotion/ColorIcon.java index a409650..95e27e0 100644 --- a/src/main/java/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/main/java/de/onyxbits/giftedmotion/Dict.java b/src/main/java/de/onyxbits/giftedmotion/Dict.java index d6bec65..c1fe363 100644 --- a/src/main/java/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 diff --git a/src/main/java/de/onyxbits/giftedmotion/FrameCanvas.java b/src/main/java/de/onyxbits/giftedmotion/FrameCanvas.java index 3033b5e..59f3649 100644 --- a/src/main/java/de/onyxbits/giftedmotion/FrameCanvas.java +++ b/src/main/java/de/onyxbits/giftedmotion/FrameCanvas.java @@ -16,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/main/java/de/onyxbits/giftedmotion/FrameDisplay.java b/src/main/java/de/onyxbits/giftedmotion/FrameDisplay.java index 4e5adca..a858371 100644 --- a/src/main/java/de/onyxbits/giftedmotion/FrameDisplay.java +++ b/src/main/java/de/onyxbits/giftedmotion/FrameDisplay.java @@ -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/main/java/de/onyxbits/giftedmotion/FrameSequence.java b/src/main/java/de/onyxbits/giftedmotion/FrameSequence.java index 6d38b47..4b23601 100644 --- a/src/main/java/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 @@ -76,8 +71,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 +89,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; } @@ -136,24 +131,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 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(); @@ -325,11 +325,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 Date: Thu, 2 Dec 2021 23:29:07 +0100 Subject: [PATCH 7/8] Fixed minor compiler & linter warnings --- .../giftedmotion/AnimatedGifEncoder.java | 1 + src/main/java/de/onyxbits/giftedmotion/Core.java | 10 +++++----- .../de/onyxbits/giftedmotion/FrameSequence.java | 12 +++++------- .../de/onyxbits/giftedmotion/LoadAccessory.java | 5 ----- .../java/de/onyxbits/giftedmotion/NeuQuant.java | 4 ++-- .../java/de/onyxbits/giftedmotion/Player.java | 6 +++--- .../de/onyxbits/giftedmotion/SequenceEditor.java | 16 ---------------- 7 files changed, 16 insertions(+), 38 deletions(-) diff --git a/src/main/java/de/onyxbits/giftedmotion/AnimatedGifEncoder.java b/src/main/java/de/onyxbits/giftedmotion/AnimatedGifEncoder.java index f0d3c66..d1bd540 100644 --- a/src/main/java/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 diff --git a/src/main/java/de/onyxbits/giftedmotion/Core.java b/src/main/java/de/onyxbits/giftedmotion/Core.java index 87edcb4..2a6013b 100644 --- a/src/main/java/de/onyxbits/giftedmotion/Core.java +++ b/src/main/java/de/onyxbits/giftedmotion/Core.java @@ -99,9 +99,9 @@ public Core() { togglesettings.addActionListener(this); // Fancy stuff - quit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_MASK)); - load.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_MASK)); - export.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.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()); @@ -347,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); @@ -359,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); diff --git a/src/main/java/de/onyxbits/giftedmotion/FrameSequence.java b/src/main/java/de/onyxbits/giftedmotion/FrameSequence.java index 4b23601..52948d8 100644 --- a/src/main/java/de/onyxbits/giftedmotion/FrameSequence.java +++ b/src/main/java/de/onyxbits/giftedmotion/FrameSequence.java @@ -16,7 +16,7 @@ public class FrameSequence { protected SingleFrame selected; /** Eventlisteners */ - private final List listeners = new Vector(); + private final List listeners = new Vector<>(); /** * Create a new FrameSequence @@ -37,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(); } @@ -110,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) { diff --git a/src/main/java/de/onyxbits/giftedmotion/LoadAccessory.java b/src/main/java/de/onyxbits/giftedmotion/LoadAccessory.java index 4ada53b..907ee4a 100644 --- a/src/main/java/de/onyxbits/giftedmotion/LoadAccessory.java +++ b/src/main/java/de/onyxbits/giftedmotion/LoadAccessory.java @@ -11,11 +11,6 @@ */ public class LoadAccessory extends JPanel implements PropertyChangeListener { - /** - * Lets the user pick a default showtime for each frame - */ - private JSpinner showtime = new JSpinner (new SpinnerNumberModel(100,0,1000000,10)); - /** * Image preview canvas */ diff --git a/src/main/java/de/onyxbits/giftedmotion/NeuQuant.java b/src/main/java/de/onyxbits/giftedmotion/NeuQuant.java index a6d20ac..3d81e19 100644 --- a/src/main/java/de/onyxbits/giftedmotion/NeuQuant.java +++ b/src/main/java/de/onyxbits/giftedmotion/NeuQuant.java @@ -382,7 +382,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) { } // prevents 1.3 miscompilation } if (k > 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/main/java/de/onyxbits/giftedmotion/Player.java b/src/main/java/de/onyxbits/giftedmotion/Player.java index 8fa542e..a96e386 100644 --- a/src/main/java/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) { diff --git a/src/main/java/de/onyxbits/giftedmotion/SequenceEditor.java b/src/main/java/de/onyxbits/giftedmotion/SequenceEditor.java index e015fea..5e950d2 100644 --- a/src/main/java/de/onyxbits/giftedmotion/SequenceEditor.java +++ b/src/main/java/de/onyxbits/giftedmotion/SequenceEditor.java @@ -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")); From 34eb45ccf19c3064d4e582b71cfefd1468c18e42 Mon Sep 17 00:00:00 2001 From: calculon102 Date: Thu, 2 Dec 2021 23:36:13 +0100 Subject: [PATCH 8/8] Add Core as main-class to manifest --- src/main/resources/META-INF/MANIFEST.MF | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF index e69de29..a13d758 100644 --- a/src/main/resources/META-INF/MANIFEST.MF +++ b/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1 @@ +Main-Class: de.onyxbits.giftedmotion.Core