diff --git a/pom.xml b/pom.xml index 3f471a7..edbf89e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,49 +1,51 @@ - - 4.0.0 + + 4.0.0 - fr.u-paris.gla - project - 2024.1.0.0-SNAPSHOT + fr.u-paris.gla + project + 2024.1.0.0-SNAPSHOT - Project Base + Project Base - - UTF-8 - 17 - 17 - + + UTF-8 + 17 + 17 + - - - org.junit.jupiter - junit-jupiter - 5.9.1 - - + + + org.junit.jupiter + junit-jupiter + 5.9.1 + + - - - - org.apache.maven.plugins - maven-jar-plugin - 3.3.0 - - - - true - fr.u_paris.gla.project.App - - - - - - - src/main/resources-filtered - true - - - + + + + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + true + fr.u_paris.gla.project.App + + + + + + + + src/main/resources-filtered + true + + + diff --git a/src/main/java/fr/u_paris/gla/project/App.java b/src/main/java/fr/u_paris/gla/project/App.java index 923e305..47d9a85 100644 --- a/src/main/java/fr/u_paris/gla/project/App.java +++ b/src/main/java/fr/u_paris/gla/project/App.java @@ -19,95 +19,96 @@ import javax.swing.WindowConstants; * * @author Emmanuel Bigeon */ public class App { - /** - * - */ - private static final String UNSPECIFIED = "Unspecified"; //$NON-NLS-1$ - /** The logo image name. */ - private static final String LOGO_NAME = "uparis_logo_rvb.png"; //$NON-NLS-1$ - /** Image height. */ - private static final int HEIGHT = 256; - /** Image width. */ - private static final int WIDTH = HEIGHT; + /** + * + */ + private static final String UNSPECIFIED = "Unspecified"; //$NON-NLS-1$ + /** The logo image name. */ + private static final String LOGO_NAME = "uparis_logo_rvb.png"; //$NON-NLS-1$ + /** Image height. */ + private static final int HEIGHT = 256; + /** Image width. */ + private static final int WIDTH = HEIGHT; - /** Resizes an image. - * - * @param src source image - * @param w width - * @param h height - * @return the resized image */ - private static Image getScaledImage(Image src, int w, int h) { - BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); - Graphics2D g2d = resizedImg.createGraphics(); - g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, - RenderingHints.VALUE_INTERPOLATION_BILINEAR); - g2d.drawImage(src, 0, 0, w, h, null); - g2d.dispose(); - return resizedImg; - } + /** Resizes an image. + * + * @param src source image + * @param w width + * @param h height + * @return the resized image */ + private static Image getScaledImage(Image src, int w, int h) { + BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + Graphics2D g2d = resizedImg.createGraphics(); + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BILINEAR); + g2d.drawImage(src, 0, 0, w, h, null); + g2d.dispose(); + return resizedImg; + } - /** Application entry point. - * - * @param args launching arguments */ - public static void main(String[] args) { - if (args.length > 0) { - for (String string : args) { - if ("--info".equals(string)) { //$NON-NLS-1$ - printAppInfos(System.out); - return; + /** Application entry point. + * + * @param args launching arguments */ + public static void main(String[] args) { + if (args.length > 0) { + for (String string : args) { + if ("--info".equals(string)) { //$NON-NLS-1$ + printAppInfos(System.out); + return; + } + if ("--gui".equals(string)) { //$NON-NLS-1$ + showLogo(); + } + } } - if ("--gui".equals(string)) { //$NON-NLS-1$ - showLogo(); + } + + /** @param out */ + public static void printAppInfos(PrintStream out) { + Properties props = new Properties(); + try (InputStream is = App.class.getResourceAsStream("application.properties")) { //$NON-NLS-1$ + props.load(is); + } catch (IOException e) { + throw new RuntimeException("Unable to read application informations", e); //$NON-NLS-1$ } - } - } - } - /** @param out */ - public static void printAppInfos(PrintStream out) { - Properties props = new Properties(); - try (InputStream is = App.class.getResourceAsStream("application.properties")) { //$NON-NLS-1$ - props.load(is); - } catch (IOException e) { - throw new RuntimeException("Unable to read application informations", e); //$NON-NLS-1$ + out.println("Application: " + props.getProperty("app.name", UNSPECIFIED)); //$NON-NLS-1$ //$NON-NLS-2$ + out.println("Version: " + props.getProperty("app.version", UNSPECIFIED)); //$NON-NLS-1$ //$NON-NLS-2$ + out.println("By: " + props.getProperty("app.team", UNSPECIFIED)); //$NON-NLS-1$ //$NON-NLS-2$ } - out.println("Application: " + props.getProperty("app.name", UNSPECIFIED)); //$NON-NLS-1$ //$NON-NLS-2$ - out.println("Version: " + props.getProperty("app.version", UNSPECIFIED)); //$NON-NLS-1$ //$NON-NLS-2$ - out.println("By: " + props.getProperty("app.team", UNSPECIFIED)); //$NON-NLS-1$ //$NON-NLS-2$ - } + /** Shows the logo in an image. */ + public static void showLogo() { + Properties props = new Properties(); + try (InputStream is = App.class.getResourceAsStream("application.properties")) { //$NON-NLS-1$ + props.load(is); + } catch (IOException e) { + throw new RuntimeException("Unable to read application informations", e); //$NON-NLS-1$ + } - /** Shows the logo in an image. */ - public static void showLogo() { - Properties props = new Properties(); - try (InputStream is = App.class.getResourceAsStream("application.properties")) { //$NON-NLS-1$ - props.load(is); - } catch (IOException e) { - throw new RuntimeException("Unable to read application informations", e); //$NON-NLS-1$ + JFrame frame = new JFrame(props.getProperty("app.name")); //$NON-NLS-1$ + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + + JLabel container = new JLabel(); + + try (InputStream is = App.class.getResourceAsStream(LOGO_NAME)) { + if (is == null) { + container.setText("Image Not Found"); + } else { + BufferedImage img = ImageIO.read(is); + ImageIcon icon = new ImageIcon(img); + ImageIcon resized = new ImageIcon( + getScaledImage(icon.getImage(), WIDTH, HEIGHT)); + + container.setIcon(resized); + } + } catch (IOException e) { + container.setText("Image Not Read: " + e.getLocalizedMessage()); + } + + frame.getContentPane().add(container); + + frame.pack(); + frame.setVisible(true); } - - JFrame frame = new JFrame(props.getProperty("app.name")); //$NON-NLS-1$ - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - - JLabel container = new JLabel(); - - try (InputStream is = App.class.getResourceAsStream(LOGO_NAME)) { - if (is == null) { - container.setText("Image Not Found"); - } else { - BufferedImage img = ImageIO.read(is); - ImageIcon icon = new ImageIcon(img); - ImageIcon resized = new ImageIcon(getScaledImage(icon.getImage(), WIDTH, HEIGHT)); - - container.setIcon(resized); - } - } catch (IOException e) { - container.setText("Image Not Read: "+e.getLocalizedMessage()); - } - - frame.getContentPane().add(container); - - frame.pack(); - frame.setVisible(true); - } } diff --git a/src/test/java/fr/u_paris/gla/project/AppTest.java b/src/test/java/fr/u_paris/gla/project/AppTest.java index 5e8873d..2943db5 100644 --- a/src/test/java/fr/u_paris/gla/project/AppTest.java +++ b/src/test/java/fr/u_paris/gla/project/AppTest.java @@ -6,9 +6,9 @@ import org.junit.jupiter.api.Test; /** Unit test for simple App. */ public class AppTest { - /** Rigorous Test :-) */ - @Test - public void shouldAnswerWithTrue() { - assertTrue(true); - } + /** Rigorous Test :-) */ + @Test + public void shouldAnswerWithTrue() { + assertTrue(true); + } }