diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/GraphicsLoader.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/GraphicsLoader.java index fe123b25f5c82f906b0ad13bf581c6b9268fa558..1e2307cc96cdf1760f8eee46985db28a061bb52c 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/GraphicsLoader.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/GraphicsLoader.java @@ -1,16 +1,16 @@ /******************************************************************************* * Copyright (C) 2017 Philipp Spohr - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -32,15 +32,19 @@ import javax.imageio.ImageIO; import javax.swing.ImageIcon; public class GraphicsLoader { + + //TODO: Organize Images in HashMap for better readability / flexibility + private static BufferedImage yoshikoLogo; private static BufferedImage yoshikoLogo_solved; private static BufferedImage yoshikoText; private static BufferedImage infoIcon; - + private static BufferedImage infoIcon_highlighted; + public final static Color yoshikoGreen = new Color(0,128,0); - + private final static ClassLoader classLoader = GraphicsLoader.class.getClassLoader(); - + private final static HashMap<Locale,BufferedImage> flags; static { flags = new HashMap<Locale,BufferedImage>(); @@ -53,11 +57,24 @@ public class GraphicsLoader { e.printStackTrace(); } } - + public static ImageIcon getFlag(Locale lcl, int width, int height) { return new ImageIcon(flags.get(lcl).getScaledInstance(width, height, Image.SCALE_SMOOTH)); } - + + public static ImageIcon getInfoIconHL(int size) { + if (infoIcon_highlighted == null) { + try { + infoIcon_highlighted = ImageIO.read( + classLoader.getResource("graphics/InfoHighlighted.png") + ); + } catch (IOException e) { + e.printStackTrace(); + } + } + return new ImageIcon(infoIcon_highlighted.getScaledInstance(size, size, Image.SCALE_SMOOTH)); + } + public static ImageIcon getInfoIcon(int size) { if (infoIcon == null) { try { @@ -70,7 +87,7 @@ public class GraphicsLoader { } return new ImageIcon(infoIcon.getScaledInstance(size, size, Image.SCALE_SMOOTH)); } - + public static ImageIcon getLogo(int size) { if (yoshikoLogo == null) { try { @@ -83,7 +100,7 @@ public class GraphicsLoader { } return new ImageIcon(yoshikoLogo.getScaledInstance(size, size, Image.SCALE_SMOOTH)); } - + public static ImageIcon getSolvedLogo(int size) { if (yoshikoLogo_solved == null) { try { @@ -96,8 +113,8 @@ public class GraphicsLoader { } return new ImageIcon(yoshikoLogo_solved.getScaledInstance(size, size, Image.SCALE_SMOOTH)); } - - + + public static ImageIcon getText(int height) { //Default dimension is 258x48 if (yoshikoText == null) { @@ -107,7 +124,7 @@ public class GraphicsLoader { ); } catch (IOException e) { e.printStackTrace(); - } + } } return new ImageIcon(yoshikoText.getScaledInstance((int)(height*258/48), height, Image.SCALE_SMOOTH)); } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/HelpButton.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/HelpButton.java index af91028102125b43aabee9f046ab51283cf5573f..efaeac18e9f5f4662cd8ac1a034637914333b27a 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/HelpButton.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/HelpButton.java @@ -1,11 +1,14 @@ package de.hhu.ba.yoshikoWrapper.swing.components; -import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.io.IOException; import java.net.URI; +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; import javax.swing.JButton; import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader; @@ -14,10 +17,16 @@ import de.hhu.ba.yoshikoWrapper.help.HelpLinks; @SuppressWarnings("serial") public class HelpButton extends JButton{ + + private static final int SIZE = 16; + + private static final ImageIcon defaultIcon = GraphicsLoader.getInfoIcon(SIZE); + private static final ImageIcon hlIcon = GraphicsLoader.getInfoIconHL(SIZE); + public HelpButton() { - super(GraphicsLoader.getInfoIcon(12)); - setMargin(new Insets(0,0,0,0)); + super(defaultIcon); setToolTipText(LocalizationManager.get("tooltip_helpButton")); + setBorder(BorderFactory.createEmptyBorder()); addActionListener( new ActionListener() { @Override @@ -31,9 +40,24 @@ public class HelpButton extends JButton{ } } } - } - ); + //Add mouse listener (cosmetic only) + addMouseListener(new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) {} + @Override + public void mousePressed(MouseEvent e) {} + @Override + public void mouseReleased(MouseEvent e) {} + @Override + public void mouseEntered(MouseEvent e) { + setIcon(hlIcon); + } + @Override + public void mouseExited(MouseEvent e) { + setIcon(defaultIcon); + } + }); } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/LanguageRenderer.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/LanguageRenderer.java index 3cabc956e19accbedc56bc36d3fab494cbaf41e1..60b3b3bf4650ce4855007f0917cce1a5129d0b1c 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/LanguageRenderer.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/LanguageRenderer.java @@ -13,20 +13,23 @@ import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader; @SuppressWarnings("serial") class LanguageRenderer extends JPanel implements ListCellRenderer<Locale>{ + private static final int FLAG_SIZE_X = 48; + private static final int FLAG_SIZE_Y = 24; + private final JLabel label; - + public LanguageRenderer() { label = new JLabel(); this.add(label); } - + @Override public Component getListCellRendererComponent( JList<? extends Locale> list, Locale value, int index, boolean isSelected, - boolean cellHasFocus) + boolean cellHasFocus) { if (isSelected) { @@ -36,11 +39,11 @@ class LanguageRenderer extends JPanel implements ListCellRenderer<Locale>{ setBackground(list.getBackground()); setForeground(list.getForeground()); } - - label.setIcon(GraphicsLoader.getFlag(value, 64, 32)); + + label.setIcon(GraphicsLoader.getFlag(value, FLAG_SIZE_X, FLAG_SIZE_Y)); label.setText(value.getDisplayLanguage()); return this; } - + } diff --git a/src/main/resources/graphics/Info.png b/src/main/resources/graphics/Info.png index 80c5ba866d94baf4db4ff95f6fc7e511dc6fd2ef..d132e02e8c52cf8526257f9975c039854a30cc8d 100644 Binary files a/src/main/resources/graphics/Info.png and b/src/main/resources/graphics/Info.png differ diff --git a/src/main/resources/graphics/InfoHighlighted.png b/src/main/resources/graphics/InfoHighlighted.png new file mode 100644 index 0000000000000000000000000000000000000000..41a6f251b6aed7c9f36b579d4f383ae43c8c7af6 Binary files /dev/null and b/src/main/resources/graphics/InfoHighlighted.png differ diff --git a/thesis/tex/Chapter/alg_overview.tex b/thesis/tex/Chapter/alg_overview.tex index 93e0b8f9e3d9afe12db429fce2289ea0bee05a51..c1570bc2bcf7eb0754ffe99389cd266a1630e9b9 100644 --- a/thesis/tex/Chapter/alg_overview.tex +++ b/thesis/tex/Chapter/alg_overview.tex @@ -26,3 +26,5 @@ \end{figure} +ROUGH IDEA: +COMPLETE GRAPH, CHOOSE EDGES SO THAT sum of C(E) is MAX while satisfying Triangle inequalities > Fully Disjunct Clique-Graph \ No newline at end of file diff --git a/thesis/tex/Thesis.pdf b/thesis/tex/Thesis.pdf index f9c75fd1151540217f7d930dd18c14850a899a3c..7b6bcf5b1fdd5424a288ea8ce0b3d40da9e427ee 100644 Binary files a/thesis/tex/Thesis.pdf and b/thesis/tex/Thesis.pdf differ