[CLEANUP] Moved parts to internal API

This commit is contained in:
JKetelaar
2016-10-18 17:48:55 +02:00
parent 0e30396b7a
commit b737dfee12
37 changed files with 5 additions and 66 deletions
+1 -1
View File
@@ -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 {
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

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 {
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB