Commit 9bb204d1 authored by Philipp Spohr's avatar Philipp Spohr
Browse files

Cosmetic changes

parent bb28c093
/*******************************************************************************
* 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));
}
......
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);
}
});
}
}
......@@ -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;
}
}
src/main/resources/graphics/Info.png

4.02 KB | W: | H:

src/main/resources/graphics/Info.png

1.89 KB | W: | H:

src/main/resources/graphics/Info.png
src/main/resources/graphics/Info.png
src/main/resources/graphics/Info.png
src/main/resources/graphics/Info.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -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
No preview for this file type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment