summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java
diff options
context:
space:
mode:
authorSimon Rettberg2016-02-02 12:38:54 +0100
committerSimon Rettberg2016-02-02 12:38:54 +0100
commit2b18a8ec42ddc282bb176f25944983493ff37dd7 (patch)
treea31a29f181ab538c38b9000dc765d67c2b836934 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java
parent[client] Sanitize messy button-enabling-code in ImageListWindow (diff)
downloadtutor-module-2b18a8ec42ddc282bb176f25944983493ff37dd7.tar.gz
tutor-module-2b18a8ec42ddc282bb176f25944983493ff37dd7.tar.xz
tutor-module-2b18a8ec42ddc282bb176f25944983493ff37dd7.zip
[client] Add icons to lecture and image list buttons
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java
index 66e2fa60..dd9d8dc7 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/Gui.java
@@ -15,6 +15,7 @@ import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.atomic.AtomicReference;
import javax.management.monitor.Monitor;
+import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
@@ -22,6 +23,7 @@ import javax.swing.SwingUtilities;
import org.apache.log4j.Logger;
import org.openslx.dozmod.Config;
import org.openslx.dozmod.gui.helper.MessageType;
+import org.openslx.dozmod.util.ResourceLoader;
import org.openslx.util.QuickTimer;
public class Gui {
@@ -119,6 +121,21 @@ public class Gui {
int scale = Config.getFontScaling();
return new Dimension(width * scale / 100, height * scale / 100);
}
+
+ /**
+ * Load given icon resource, optionally scaling it while taking
+ * the user's zoom factor into account.
+ *
+ * @param path resource path
+ * @param description resource description
+ * @param maxHeight maximum height of image, which it will be scaled to
+ * @param context context component, for alpha blending
+ * @return scaled icon, if too large, otherwise the unmodified icon
+ */
+ public static Icon getScaledIconResource(String path, String description, int maxHeight, Component context) {
+ int height = maxHeight * Config.getFontScaling() / 100;
+ return ResourceLoader.getIcon(path, description, height, context);
+ }
/**
* Get the {@link GraphicsDevice} which the given {@link Point} lies in.