[CLEANUP] Moved parts to internal API
@@ -73,7 +73,7 @@
|
||||
<dependency>
|
||||
<groupId>org.parabot</groupId>
|
||||
<artifactId>internal-api</artifactId>
|
||||
<version>1.03.2</version>
|
||||
<version>1.4.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -1,30 +1,9 @@
|
||||
package org.parabot.core.ui.images;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* Caches and loads images from resource
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
* @author Everel, JKetelaar
|
||||
*/
|
||||
public final class Images {
|
||||
private static final HashMap<String, BufferedImage> IMAGE_CACHE = new HashMap<String, BufferedImage>();
|
||||
|
||||
public static BufferedImage getResource(final String resource) {
|
||||
if(IMAGE_CACHE.containsKey(resource)) {
|
||||
return IMAGE_CACHE.get(resource);
|
||||
}
|
||||
try {
|
||||
final BufferedImage img = ImageIO.read(Images.class.getResourceAsStream(resource));
|
||||
IMAGE_CACHE.put(resource, img);
|
||||
return img;
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException("Failed to load image from resource. " + t.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public final class Images extends org.parabot.api.io.images.Images {
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 152 B |
|
Before Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 299 B |
|
Before Width: | Height: | Size: 332 B |
|
Before Width: | Height: | Size: 331 B |
|
Before Width: | Height: | Size: 325 B |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 489 B |
|
Before Width: | Height: | Size: 357 B |
|
Before Width: | Height: | Size: 371 B |
|
Before Width: | Height: | Size: 307 B |
|
Before Width: | Height: | Size: 311 B |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 611 B |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 343 B |
|
Before Width: | Height: | Size: 328 B |
|
Before Width: | Height: | Size: 431 B |
|
Before Width: | Height: | Size: 371 B |
|
Before Width: | Height: | Size: 452 B |
|
Before Width: | Height: | Size: 668 B |
|
Before Width: | Height: | Size: 354 B |
|
Before Width: | Height: | Size: 276 B |
|
Before Width: | Height: | Size: 310 B |
|
Before Width: | Height: | Size: 377 B |
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 155 B |
|
Before Width: | Height: | Size: 110 B |
|
Before Width: | Height: | Size: 3.5 KiB |
@@ -1,48 +1,8 @@
|
||||
package org.parabot.core.ui.utils;
|
||||
|
||||
import org.parabot.core.ui.images.Images;
|
||||
import org.parabot.environment.OperatingSystem;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
*
|
||||
* Holds various swing util based methods
|
||||
*
|
||||
* @author Dane
|
||||
*
|
||||
* @author JKetelaar
|
||||
*/
|
||||
public class SwingUtil {
|
||||
|
||||
/**
|
||||
* Packs, centers, and shows the frame.
|
||||
*
|
||||
* @param f
|
||||
*/
|
||||
public static void finalize(JFrame f) {
|
||||
f.pack();
|
||||
f.setLocationRelativeTo(null);
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
public static void setParabotIcons(JFrame f) {
|
||||
f.setIconImage(Images.getResource("/storage/images/icon.png"));
|
||||
|
||||
if(OperatingSystem.getOS() == OperatingSystem.MAC) {
|
||||
/** Adds the dock icon to mac users */
|
||||
try {
|
||||
Class<?> util = Class.forName("com.apple.eawt.Application");
|
||||
Object application = util.getMethod("getApplication", new Class[] { }).invoke(null);
|
||||
Method setDockIconImage = util.getMethod("setDockIconImage", new Class[] { Image.class });
|
||||
setDockIconImage.invoke(application, Images.getResource("/storage/images/icon.png"));
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException ignored) {
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
public class SwingUtil extends org.parabot.api.ui.SwingUtil {
|
||||
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 76 KiB |