ImageUtil: Add getResourceStreamFromClass method
This replaces invocations of `Class.getResourceAsStream(path)` in order to relieve plugin/client code from managing synchronization and handling exceptions.
This commit is contained in:
@@ -25,11 +25,10 @@
|
||||
package net.runelite.client.game;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
@@ -48,21 +47,11 @@ public class SkillIconManager
|
||||
return imgCache[skillIdx];
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
String skillIconPath = (small ? "/skill_icons_small/" : "/skill_icons/")
|
||||
+ skill.getName().toLowerCase() + ".png";
|
||||
log.debug("Loading skill icon from {}", skillIconPath);
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
skillImage = ImageIO.read(SkillIconManager.class.getResourceAsStream(skillIconPath));
|
||||
}
|
||||
imgCache[skillIdx] = skillImage;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.debug("Error Loading skill icons {}", e);
|
||||
}
|
||||
String skillIconPath = (small ? "/skill_icons_small/" : "/skill_icons/")
|
||||
+ skill.getName().toLowerCase() + ".png";
|
||||
log.debug("Loading skill icon from {}", skillIconPath);
|
||||
skillImage = ImageUtil.getResourceStreamFromClass(getClass(), skillIconPath);
|
||||
imgCache[skillIdx] = skillImage;
|
||||
|
||||
return skillImage;
|
||||
}
|
||||
|
||||
@@ -26,9 +26,7 @@ package net.runelite.client.plugins.account;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.swing.JOptionPane;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -40,6 +38,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.client.util.RunnableExceptionLogger;
|
||||
|
||||
@PluginDescriptor(
|
||||
@@ -67,18 +66,8 @@ public class AccountPlugin extends Plugin
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
LOGIN_IMAGE = ImageIO.read(AccountPlugin.class.getResourceAsStream("login_icon.png"));
|
||||
LOGOUT_IMAGE = ImageIO.read(AccountPlugin.class.getResourceAsStream("logout_icon.png"));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
LOGIN_IMAGE = ImageUtil.getResourceStreamFromClass(AccountPlugin.class, "login_icon.png");
|
||||
LOGOUT_IMAGE = ImageUtil.getResourceStreamFromClass(AccountPlugin.class, "logout_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,6 @@ import java.awt.Font;
|
||||
import java.awt.Image;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
@@ -46,6 +45,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Barbarian Assault",
|
||||
@@ -87,10 +87,7 @@ public class BarbarianAssaultPlugin extends Plugin
|
||||
font = FontManager.getRunescapeFont()
|
||||
.deriveFont(Font.BOLD, 24);
|
||||
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
clockImage = ImageIO.read(getClass().getResourceAsStream("clock.png"));
|
||||
}
|
||||
clockImage = ImageUtil.getResourceStreamFromClass(getClass(), "clock.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.google.inject.Provides;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.Getter;
|
||||
@@ -49,6 +48,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Boosts Information",
|
||||
@@ -118,11 +118,8 @@ public class BoostsPlugin extends Plugin
|
||||
Arrays.fill(lastSkillLevels, -1);
|
||||
|
||||
// Add infoboxes for everything at startup and then determine inside if it will be rendered
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
infoBoxManager.addInfoBox(new StatChangeIndicator(true, ImageIO.read(getClass().getResourceAsStream("debuffed.png")), this, config));
|
||||
infoBoxManager.addInfoBox(new StatChangeIndicator(false, ImageIO.read(getClass().getResourceAsStream("buffed.png")), this, config));
|
||||
}
|
||||
infoBoxManager.addInfoBox(new StatChangeIndicator(true, ImageUtil.getResourceStreamFromClass(getClass(), "debuffed.png"), this, config));
|
||||
infoBoxManager.addInfoBox(new StatChangeIndicator(false, ImageUtil.getResourceStreamFromClass(getClass(), "buffed.png"), this, config));
|
||||
|
||||
for (final Skill skill : Skill.values())
|
||||
{
|
||||
|
||||
@@ -29,13 +29,11 @@ package net.runelite.client.plugins.cluescrolls;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -84,6 +82,7 @@ import net.runelite.client.plugins.cluescrolls.clues.ObjectClueScroll;
|
||||
import net.runelite.client.plugins.cluescrolls.clues.TextClueScroll;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
import net.runelite.client.util.Text;
|
||||
|
||||
@@ -403,17 +402,7 @@ public class ClueScrollPlugin extends Plugin
|
||||
return emoteImage;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
emoteImage = ImageIO.read(getClass().getResourceAsStream("emote.png"));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
emoteImage = ImageUtil.getResourceStreamFromClass(getClass(), "emote.png");
|
||||
|
||||
return emoteImage;
|
||||
}
|
||||
@@ -430,17 +419,7 @@ public class ClueScrollPlugin extends Plugin
|
||||
return mapArrow;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
mapArrow = ImageIO.read(getClass().getResourceAsStream("/util/clue_arrow.png"));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
mapArrow = ImageUtil.getResourceStreamFromClass(getClass(), "/util/clue_arrow.png");
|
||||
|
||||
return mapArrow;
|
||||
}
|
||||
|
||||
@@ -38,14 +38,12 @@ import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
@@ -124,20 +122,10 @@ public class ConfigPanel extends PluginPanel
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
BufferedImage backIcon = ImageIO.read(ConfigPanel.class.getResourceAsStream("config_back_icon.png"));
|
||||
BACK_ICON = new ImageIcon(backIcon);
|
||||
BACK_ICON_HOVER = new ImageIcon(ImageUtil.alphaOffset(backIcon, -100));
|
||||
SEARCH = new ImageIcon(ImageIO.read(IconTextField.class.getResourceAsStream("search.png")));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
final BufferedImage backIcon = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "config_back_icon.png");
|
||||
BACK_ICON = new ImageIcon(backIcon);
|
||||
BACK_ICON_HOVER = new ImageIcon(ImageUtil.alphaOffset(backIcon, -100));
|
||||
SEARCH = new ImageIcon(ImageUtil.getResourceStreamFromClass(IconTextField.class, "search.png"));
|
||||
}
|
||||
|
||||
ConfigPanel(PluginManager pluginManager, ConfigManager configManager, ScheduledExecutorService executorService,
|
||||
|
||||
@@ -27,7 +27,6 @@ package net.runelite.client.plugins.config;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.swing.SwingUtilities;
|
||||
import net.runelite.client.config.ChatColorConfig;
|
||||
@@ -39,6 +38,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.PluginManager;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Configuration",
|
||||
@@ -73,11 +73,7 @@ public class ConfigPlugin extends Plugin
|
||||
{
|
||||
configPanel = new ConfigPanel(pluginManager, configManager, executorService, runeLiteConfig, chatColorConfig);
|
||||
|
||||
BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(getClass().getResourceAsStream("config_icon.png"));
|
||||
}
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "config_icon.png");
|
||||
|
||||
navButton = NavigationButton.builder()
|
||||
.tooltip("Configuration")
|
||||
|
||||
@@ -29,12 +29,10 @@ import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
@@ -84,34 +82,27 @@ class PluginListItem extends JPanel
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
BufferedImage configIcon;
|
||||
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
configIcon = ImageIO.read(ConfigPanel.class.getResourceAsStream("config_edit_icon.png"));
|
||||
CONFIG_ICON = new ImageIcon(configIcon);
|
||||
ON_SWITCHER = new ImageIcon(ImageIO.read(ConfigPanel.class.getResourceAsStream("switcher_on.png")));
|
||||
ON_STAR = new ImageIcon(ImageIO.read(ConfigPanel.class.getResourceAsStream("star_on.png")));
|
||||
}
|
||||
|
||||
BufferedImage offSwitcherImage = ImageUtil.bufferedImageFromImage(ON_SWITCHER.getImage());
|
||||
offSwitcherImage = ImageUtil.grayscaleImage(offSwitcherImage);
|
||||
offSwitcherImage = ImageUtil.grayscaleOffset(offSwitcherImage, 0.61f);
|
||||
offSwitcherImage = ImageUtil.flipImage(offSwitcherImage, true, false);
|
||||
OFF_SWITCHER = new ImageIcon(offSwitcherImage);
|
||||
BufferedImage offStarImage = ImageUtil.bufferedImageFromImage(ON_STAR.getImage());
|
||||
offStarImage = ImageUtil.grayscaleImage(offStarImage);
|
||||
offStarImage = ImageUtil.grayscaleOffset(offStarImage, 0.77f);
|
||||
OFF_STAR = new ImageIcon(offStarImage);
|
||||
|
||||
CONFIG_ICON_HOVER = new ImageIcon(ImageUtil.alphaOffset(configIcon, -100));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
BufferedImage configIcon = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "config_edit_icon.png");
|
||||
BufferedImage onSwitcher = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "switcher_on.png");
|
||||
BufferedImage onStar = ImageUtil.getResourceStreamFromClass(ConfigPanel.class, "star_on.png");
|
||||
CONFIG_ICON = new ImageIcon(configIcon);
|
||||
ON_SWITCHER = new ImageIcon(onSwitcher);
|
||||
ON_STAR = new ImageIcon(onStar);
|
||||
CONFIG_ICON_HOVER = new ImageIcon(ImageUtil.grayscaleOffset(configIcon, -100));
|
||||
BufferedImage offSwitcherImage = ImageUtil.flipImage(
|
||||
ImageUtil.grayscaleOffset(
|
||||
ImageUtil.grayscaleImage(onSwitcher),
|
||||
0.61f
|
||||
),
|
||||
true,
|
||||
false
|
||||
);
|
||||
OFF_SWITCHER = new ImageIcon(offSwitcherImage);
|
||||
BufferedImage offStar = ImageUtil.grayscaleOffset(
|
||||
ImageUtil.grayscaleImage(onStar),
|
||||
0.77f
|
||||
);
|
||||
OFF_STAR = new ImageIcon(offStar);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,12 +28,10 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Set;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import static net.runelite.api.AnimationID.DEATH;
|
||||
@@ -53,6 +51,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
import net.runelite.client.ui.overlay.infobox.Timer;
|
||||
import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Death Indicator",
|
||||
@@ -333,17 +332,7 @@ public class DeathIndicatorPlugin extends Plugin
|
||||
return mapArrow;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
mapArrow = ImageIO.read(getClass().getResourceAsStream("/util/clue_arrow.png"));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
mapArrow = ImageUtil.getResourceStreamFromClass(getClass(), "/util/clue_arrow.png");
|
||||
|
||||
return mapArrow;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.google.inject.Provides;
|
||||
import java.awt.Font;
|
||||
import java.awt.image.BufferedImage;
|
||||
import static java.lang.Math.min;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
@@ -51,6 +50,7 @@ import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@PluginDescriptor(
|
||||
@@ -130,11 +130,7 @@ public class DevToolsPlugin extends Plugin
|
||||
|
||||
final DevToolsPanel panel = injector.getInstance(DevToolsPanel.class);
|
||||
|
||||
BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(getClass().getResourceAsStream("devtools_icon.png"));
|
||||
}
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "devtools_icon.png");
|
||||
|
||||
navButton = NavigationButton.builder()
|
||||
.tooltip("Developer Tools")
|
||||
|
||||
@@ -33,7 +33,6 @@ import java.time.temporal.ChronoUnit;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.runelite.api.Client;
|
||||
import static net.runelite.api.Constants.CHUNK_SIZE;
|
||||
import net.runelite.api.GameState;
|
||||
@@ -51,6 +50,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.client.util.LinkBrowser;
|
||||
|
||||
@PluginDescriptor(
|
||||
@@ -88,11 +88,7 @@ public class DiscordPlugin extends Plugin
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(getClass().getResourceAsStream("discord.png"));
|
||||
}
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "discord.png");
|
||||
|
||||
discordButton = NavigationButton.builder()
|
||||
.tab(false)
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.google.inject.Provides;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.swing.SwingUtilities;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -46,6 +45,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Farming Tracker",
|
||||
@@ -88,11 +88,7 @@ public class FarmingTrackerPlugin extends Plugin
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(getClass().getResourceAsStream("farming.png"));
|
||||
}
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "farming.png");
|
||||
|
||||
panel = new FarmingTrackerPanel(client, itemManager, configManager, config, farmingWorld);
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.PluginPanel;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.client.util.LinkBrowser;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import net.runelite.http.api.feed.FeedItem;
|
||||
@@ -102,18 +103,8 @@ class FeedPanel extends PluginPanel
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
RUNELITE_ICON = new ImageIcon(ImageIO.read(FeedPanel.class.getResourceAsStream("runelite.png")));
|
||||
OSRS_ICON = new ImageIcon(ImageIO.read(FeedPanel.class.getResourceAsStream("osrs.png")));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
RUNELITE_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(FeedPanel.class, "runelite.png"));
|
||||
OSRS_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(FeedPanel.class, "osrs.png"));
|
||||
}
|
||||
|
||||
private final FeedConfig config;
|
||||
|
||||
@@ -33,7 +33,6 @@ import java.time.temporal.ChronoUnit;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Supplier;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
@@ -43,6 +42,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.http.api.feed.FeedClient;
|
||||
import net.runelite.http.api.feed.FeedResult;
|
||||
|
||||
@@ -86,11 +86,7 @@ public class FeedPlugin extends Plugin
|
||||
{
|
||||
feedPanel = new FeedPanel(config, feedSupplier);
|
||||
|
||||
BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(getClass().getResourceAsStream("icon.png"));
|
||||
}
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "icon.png");
|
||||
|
||||
navButton = NavigationButton.builder()
|
||||
.tooltip("News Feed")
|
||||
|
||||
@@ -36,9 +36,7 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
@@ -84,18 +82,9 @@ public class GrandExchangeOfferSlot extends JPanel
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
RIGHT_ARROW_ICON = new ImageIcon(ImageUtil.alphaOffset(ImageIO.read(GrandExchangeOfferSlot.class.getResourceAsStream("/util/arrow_right.png")), 0.25f));
|
||||
LEFT_ARROW_ICON = new ImageIcon(ImageUtil.flipImage(ImageUtil.bufferedImageFromImage(RIGHT_ARROW_ICON.getImage()), true, false));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
final BufferedImage rightArrow = ImageUtil.alphaOffset(ImageUtil.getResourceStreamFromClass(GrandExchangeOfferSlot.class, "/util/arrow_right.png"), 0.25f);
|
||||
RIGHT_ARROW_ICON = new ImageIcon(rightArrow);
|
||||
LEFT_ARROW_ICON = new ImageIcon(ImageUtil.flipImage(rightArrow, true, false));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.google.inject.Provides;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.swing.SwingUtilities;
|
||||
import lombok.AccessLevel;
|
||||
@@ -66,6 +65,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.client.util.StackFormatter;
|
||||
import net.runelite.client.util.Text;
|
||||
import net.runelite.http.api.osbuddy.GrandExchangeClient;
|
||||
@@ -134,15 +134,11 @@ public class GrandExchangePlugin extends Plugin
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startUp() throws IOException
|
||||
protected void startUp()
|
||||
{
|
||||
panel = injector.getInstance(GrandExchangePanel.class);
|
||||
|
||||
BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(getClass().getResourceAsStream("ge_icon.png"));
|
||||
}
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "ge_icon.png");
|
||||
|
||||
button = NavigationButton.builder()
|
||||
.tooltip("Grand Exchange")
|
||||
|
||||
@@ -31,11 +31,9 @@ import java.awt.CardLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
@@ -96,19 +94,9 @@ class GrandExchangeSearchPanel extends JPanel
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
SEARCH_ICON = new ImageIcon(ImageUtil.alphaOffset(ImageUtil.grayscaleOffset(ImageIO.read(IconTextField.class.getResourceAsStream("search.png")), 0f), 1.75f));
|
||||
LOADING_ICON = new ImageIcon(IconTextField.class.getResource("loading_spinner.gif"));
|
||||
ERROR_ICON = new ImageIcon(ImageIO.read(IconTextField.class.getResourceAsStream("error.png")));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SEARCH_ICON = new ImageIcon(ImageUtil.alphaOffset(ImageUtil.grayscaleOffset(ImageUtil.getResourceStreamFromClass(IconTextField.class, "search.png"), 0f), 1.75f));
|
||||
LOADING_ICON = new ImageIcon(IconTextField.class.getResource("loading_spinner.gif"));
|
||||
ERROR_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(IconTextField.class, "error.png"));
|
||||
}
|
||||
|
||||
GrandExchangeSearchPanel(Client client, ItemManager itemManager, ScheduledExecutorService executor)
|
||||
|
||||
@@ -41,7 +41,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
@@ -57,6 +56,7 @@ import net.runelite.client.ui.PluginPanel;
|
||||
import net.runelite.client.ui.components.IconTextField;
|
||||
import net.runelite.client.ui.components.materialtabs.MaterialTab;
|
||||
import net.runelite.client.ui.components.materialtabs.MaterialTabGroup;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.client.util.RunnableExceptionLogger;
|
||||
import net.runelite.client.util.StackFormatter;
|
||||
import net.runelite.http.api.hiscore.HiscoreClient;
|
||||
@@ -146,19 +146,9 @@ public class HiscorePanel extends PluginPanel
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
SEARCH_ICON = new ImageIcon(ImageIO.read(IconTextField.class.getResourceAsStream("search.png")));
|
||||
LOADING_ICON = new ImageIcon(IconTextField.class.getResource("loading_spinner_darker.gif"));
|
||||
ERROR_ICON = new ImageIcon(ImageIO.read(IconTextField.class.getResourceAsStream("error.png")));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SEARCH_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(IconTextField.class, "search.png"));
|
||||
LOADING_ICON = new ImageIcon(IconTextField.class.getResource("loading_spinner_darker.gif"));
|
||||
ERROR_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(IconTextField.class, "error.png"));
|
||||
}
|
||||
|
||||
@Inject
|
||||
@@ -220,51 +210,39 @@ public class HiscorePanel extends PluginPanel
|
||||
|
||||
for (HiscoreEndpoint endpoint : HiscoreEndpoint.values())
|
||||
{
|
||||
try
|
||||
final BufferedImage iconImage = ImageUtil.getResourceStreamFromClass(getClass(), endpoint.name().toLowerCase() + ".png");
|
||||
|
||||
MaterialTab tab = new MaterialTab(new ImageIcon(iconImage), tabGroup, null);
|
||||
tab.setToolTipText(endpoint.getName() + " Hiscores");
|
||||
tab.setOnSelectEvent(() ->
|
||||
{
|
||||
BufferedImage iconImage;
|
||||
synchronized (ImageIO.class)
|
||||
if (loading)
|
||||
{
|
||||
iconImage = ImageIO.read(HiscorePanel.class.getResourceAsStream(
|
||||
endpoint.name().toLowerCase() + ".png"));
|
||||
return false;
|
||||
}
|
||||
|
||||
MaterialTab tab = new MaterialTab(new ImageIcon(iconImage), tabGroup, null);
|
||||
tab.setToolTipText(endpoint.getName() + " Hiscores");
|
||||
tab.setOnSelectEvent(() ->
|
||||
selectedEndPoint = endpoint;
|
||||
return true;
|
||||
});
|
||||
|
||||
// Adding the lookup method to a mouseListener instead of the above onSelectedEvent
|
||||
// Because sometimes you might want to switch the tab, without calling for lookup
|
||||
// Ex: selecting the normal hiscores as default
|
||||
tab.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mousePressed(MouseEvent mouseEvent)
|
||||
{
|
||||
if (loading)
|
||||
{
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
selectedEndPoint = endpoint;
|
||||
return true;
|
||||
});
|
||||
executor.execute(HiscorePanel.this::lookup);
|
||||
}
|
||||
});
|
||||
|
||||
// Adding the lookup method to a mouseListener instead of the above onSelectedEvent
|
||||
// Because sometimes you might want to switch the tab, without calling for lookup
|
||||
// Ex: selecting the normal hiscores as default
|
||||
tab.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mousePressed(MouseEvent mouseEvent)
|
||||
{
|
||||
if (loading)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
executor.execute(HiscorePanel.this::lookup);
|
||||
}
|
||||
});
|
||||
|
||||
tabGroup.addTab(tab);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
tabGroup.addTab(tab);
|
||||
}
|
||||
|
||||
// Default selected tab is normal hiscores
|
||||
@@ -343,19 +321,7 @@ public class HiscorePanel extends PluginPanel
|
||||
String skillIcon = directory + skillName + ".png";
|
||||
log.debug("Loading skill icon from {}", skillIcon);
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(HiscorePanel.class.getResourceAsStream(skillIcon));
|
||||
}
|
||||
label.setIcon(new ImageIcon(icon));
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
log.warn(null, ex);
|
||||
}
|
||||
label.setIcon(new ImageIcon(ImageUtil.getResourceStreamFromClass(getClass(), skillIcon)));
|
||||
|
||||
boolean totalLabel = skill == HiscoreSkill.OVERALL || skill == null; //overall or combat
|
||||
label.setIconTextGap(totalLabel ? 10 : 4);
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.awt.image.BufferedImage;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import javax.swing.SwingUtilities;
|
||||
@@ -49,6 +48,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.client.util.Text;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
@@ -98,11 +98,7 @@ public class HiscorePlugin extends Plugin
|
||||
{
|
||||
hiscorePanel = injector.getInstance(HiscorePanel.class);
|
||||
|
||||
BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(getClass().getResourceAsStream("normal.png"));
|
||||
}
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "normal.png");
|
||||
|
||||
navButton = NavigationButton.builder()
|
||||
.tooltip("Hiscore")
|
||||
|
||||
@@ -36,10 +36,8 @@ import java.awt.Font;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Singleton;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.ImageIcon;
|
||||
@@ -56,6 +54,7 @@ import net.runelite.client.account.SessionManager;
|
||||
import net.runelite.client.ui.ColorScheme;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.PluginPanel;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.client.util.LinkBrowser;
|
||||
import net.runelite.client.util.RunnableExceptionLogger;
|
||||
|
||||
@@ -92,21 +91,11 @@ public class InfoPanel extends PluginPanel
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
ARROW_RIGHT_ICON = new ImageIcon(ImageIO.read(InfoPanel.class.getResourceAsStream("/util/arrow_right.png")));
|
||||
GITHUB_ICON = new ImageIcon(ImageIO.read(InfoPanel.class.getResourceAsStream("github_icon.png")));
|
||||
DISCORD_ICON = new ImageIcon(ImageIO.read(InfoPanel.class.getResourceAsStream("discord_icon.png")));
|
||||
PATREON_ICON = new ImageIcon(ImageIO.read(InfoPanel.class.getResourceAsStream("patreon_icon.png")));
|
||||
WIKI_ICON = new ImageIcon(ImageIO.read(InfoPanel.class.getResourceAsStream("wiki_icon.png")));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
ARROW_RIGHT_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "/util/arrow_right.png"));
|
||||
GITHUB_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "github_icon.png"));
|
||||
DISCORD_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "discord_icon.png"));
|
||||
PATREON_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "patreon_icon.png"));
|
||||
WIKI_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "wiki_icon.png"));
|
||||
}
|
||||
|
||||
void init()
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
package net.runelite.client.plugins.info;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Info Panel",
|
||||
@@ -50,11 +50,7 @@ public class InfoPlugin extends Plugin
|
||||
final InfoPanel panel = injector.getInstance(InfoPanel.class);
|
||||
panel.init();
|
||||
|
||||
BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(getClass().getResourceAsStream("info_icon.png"));
|
||||
}
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "info_icon.png");
|
||||
|
||||
navButton = NavigationButton.builder()
|
||||
.tooltip("Info")
|
||||
|
||||
@@ -33,14 +33,12 @@ import java.awt.GridBagLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Singleton;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.GroupLayout;
|
||||
@@ -67,19 +65,9 @@ class KourendLibraryPanel extends PluginPanel
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
BufferedImage resetIcon = ImageIO.read(KourendLibraryPanel.class.getResourceAsStream("/util/reset.png"));
|
||||
RESET_ICON = new ImageIcon(resetIcon);
|
||||
RESET_CLICK_ICON = new ImageIcon(ImageUtil.alphaOffset(resetIcon, -100));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
final BufferedImage resetIcon = ImageUtil.getResourceStreamFromClass(KourendLibraryPanel.class, "/util/reset.png");
|
||||
RESET_ICON = new ImageIcon(resetIcon);
|
||||
RESET_CLICK_ICON = new ImageIcon(ImageUtil.alphaOffset(resetIcon, -100));
|
||||
}
|
||||
|
||||
void init()
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.google.inject.Provides;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.swing.SwingUtilities;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -53,6 +52,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Kourend Library",
|
||||
@@ -109,11 +109,7 @@ public class KourendLibraryPlugin extends Plugin
|
||||
panel = injector.getInstance(KourendLibraryPanel.class);
|
||||
panel.init();
|
||||
|
||||
BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(Book.class.getResourceAsStream("panel_icon.png"));
|
||||
}
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "panel_icon.png");
|
||||
|
||||
navButton = NavigationButton.builder()
|
||||
.tooltip("Kourend Library")
|
||||
|
||||
@@ -34,7 +34,6 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.swing.SwingUtilities;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -59,6 +58,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.client.util.Text;
|
||||
import net.runelite.http.api.item.ItemPrice;
|
||||
|
||||
@@ -125,11 +125,7 @@ public class LootTrackerPlugin extends Plugin
|
||||
panel = new LootTrackerPanel(itemManager);
|
||||
spriteManager.getSpriteAsync(SpriteID.UNUSED_TAB_INVENTORY, 0, panel::loadHeaderIcon);
|
||||
|
||||
final BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(LootTrackerPanel.class.getResourceAsStream("panel_icon.png"));
|
||||
}
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "panel_icon.png");
|
||||
|
||||
navButton = NavigationButton.builder()
|
||||
.tooltip("Loot Tracker")
|
||||
|
||||
@@ -25,12 +25,11 @@
|
||||
package net.runelite.client.plugins.mta.alchemy;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import javax.imageio.ImageIO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.ui.overlay.infobox.Timer;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@Slf4j
|
||||
public class AlchemyRoomTimer extends Timer
|
||||
@@ -51,17 +50,7 @@ public class AlchemyRoomTimer extends Timer
|
||||
return image;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
image = ImageIO.read(AlchemyRoomTimer.class.getResourceAsStream("/util/reset.png"));
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
log.warn(null, ex);
|
||||
}
|
||||
image = ImageUtil.getResourceStreamFromClass(AlchemyRoomTimer.class, "/util/reset.png");
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ package net.runelite.client.plugins.notes;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.events.SessionOpen;
|
||||
@@ -36,6 +35,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Notes",
|
||||
@@ -67,11 +67,7 @@ public class NotesPlugin extends Plugin
|
||||
panel = injector.getInstance(NotesPanel.class);
|
||||
panel.init(config);
|
||||
|
||||
BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(getClass().getResourceAsStream("notes_icon.png"));
|
||||
}
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "notes_icon.png");
|
||||
|
||||
navButton = NavigationButton.builder()
|
||||
.tooltip("Notes")
|
||||
|
||||
@@ -25,14 +25,13 @@
|
||||
package net.runelite.client.plugins.poh;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.imageio.ImageIO;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import static net.runelite.api.ObjectID.*;
|
||||
import static net.runelite.api.NullObjectID.*;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@Slf4j
|
||||
public enum PohIcons
|
||||
@@ -105,17 +104,7 @@ public enum PohIcons
|
||||
return image;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
image = ImageIO.read(PohIcons.class.getResourceAsStream(getImageResource() + ".png"));
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
log.warn("unable to load image", ex);
|
||||
}
|
||||
image = ImageUtil.getResourceStreamFromClass(getClass(), getImageResource() + ".png");
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
@@ -53,6 +52,7 @@ import net.runelite.client.plugins.screenmarkers.ui.ScreenMarkerPluginPanel;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Screen Markers",
|
||||
@@ -108,11 +108,7 @@ public class ScreenMarkerPlugin extends Plugin
|
||||
pluginPanel = injector.getInstance(ScreenMarkerPluginPanel.class);
|
||||
pluginPanel.rebuild();
|
||||
|
||||
BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream(ICON_FILE));
|
||||
}
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), ICON_FILE);
|
||||
|
||||
navigationButton = NavigationButton.builder()
|
||||
.tooltip(PLUGIN_NAME)
|
||||
|
||||
@@ -30,8 +30,6 @@ import java.awt.GridLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
@@ -56,18 +54,8 @@ public class ScreenMarkerCreationPanel extends JPanel
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
CONFIRM_ICON = new ImageIcon(ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("confirm_icon.png")));
|
||||
CANCEL_ICON = new ImageIcon(ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("cancel_icon.png")));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
CONFIRM_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "confirm_icon.png"));
|
||||
CANCEL_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "cancel_icon.png"));
|
||||
|
||||
final BufferedImage confirmIcon = ImageUtil.bufferedImageFromImage(CONFIRM_ICON.getImage());
|
||||
CONFIRM_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(confirmIcon, 0.54f));
|
||||
|
||||
@@ -34,8 +34,6 @@ import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JColorChooser;
|
||||
@@ -108,48 +106,38 @@ class ScreenMarkerPanel extends JPanel
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
BufferedImage borderImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("border_color_icon.png"));
|
||||
BORDER_COLOR_ICON = new ImageIcon(borderImg);
|
||||
BORDER_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(borderImg, -100));
|
||||
final BufferedImage borderImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "border_color_icon.png");
|
||||
BORDER_COLOR_ICON = new ImageIcon(borderImg);
|
||||
BORDER_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(borderImg, -100));
|
||||
|
||||
BufferedImage noBorderImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("no_border_color_icon.png"));
|
||||
NO_BORDER_COLOR_ICON = new ImageIcon(noBorderImg);
|
||||
NO_BORDER_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(noBorderImg, -100));
|
||||
final BufferedImage noBorderImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "no_border_color_icon.png");
|
||||
NO_BORDER_COLOR_ICON = new ImageIcon(noBorderImg);
|
||||
NO_BORDER_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(noBorderImg, -100));
|
||||
|
||||
BufferedImage fillImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("fill_color_icon.png"));
|
||||
FILL_COLOR_ICON = new ImageIcon(fillImg);
|
||||
FILL_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(fillImg, -100));
|
||||
final BufferedImage fillImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "fill_color_icon.png");
|
||||
FILL_COLOR_ICON = new ImageIcon(fillImg);
|
||||
FILL_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(fillImg, -100));
|
||||
|
||||
BufferedImage noFillImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("no_fill_color_icon.png"));
|
||||
NO_FILL_COLOR_ICON = new ImageIcon(noFillImg);
|
||||
NO_FILL_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(noFillImg, -100));
|
||||
final BufferedImage noFillImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "no_fill_color_icon.png");
|
||||
NO_FILL_COLOR_ICON = new ImageIcon(noFillImg);
|
||||
NO_FILL_COLOR_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(noFillImg, -100));
|
||||
|
||||
BufferedImage opacityImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("opacity_icon.png"));
|
||||
FULL_OPACITY_ICON = new ImageIcon(opacityImg);
|
||||
OPACITY_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(opacityImg, -100));
|
||||
NO_OPACITY_ICON = new ImageIcon(ImageUtil.alphaOffset(opacityImg, -150));
|
||||
final BufferedImage opacityImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "opacity_icon.png");
|
||||
FULL_OPACITY_ICON = new ImageIcon(opacityImg);
|
||||
OPACITY_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(opacityImg, -100));
|
||||
NO_OPACITY_ICON = new ImageIcon(ImageUtil.alphaOffset(opacityImg, -150));
|
||||
|
||||
BufferedImage visibleImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("visible_icon.png"));
|
||||
VISIBLE_ICON = new ImageIcon(visibleImg);
|
||||
VISIBLE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(visibleImg, -100));
|
||||
final BufferedImage visibleImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "visible_icon.png");
|
||||
VISIBLE_ICON = new ImageIcon(visibleImg);
|
||||
VISIBLE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(visibleImg, -100));
|
||||
|
||||
BufferedImage invisibleImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("invisible_icon.png"));
|
||||
INVISIBLE_ICON = new ImageIcon(invisibleImg);
|
||||
INVISIBLE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(invisibleImg, -100));
|
||||
final BufferedImage invisibleImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "invisible_icon.png");
|
||||
INVISIBLE_ICON = new ImageIcon(invisibleImg);
|
||||
INVISIBLE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(invisibleImg, -100));
|
||||
|
||||
BufferedImage deleteImg = ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("delete_icon.png"));
|
||||
DELETE_ICON = new ImageIcon(deleteImg);
|
||||
DELETE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(deleteImg, -100));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
final BufferedImage deleteImg = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "delete_icon.png");
|
||||
DELETE_ICON = new ImageIcon(deleteImg);
|
||||
DELETE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(deleteImg, -100));
|
||||
}
|
||||
|
||||
ScreenMarkerPanel(ScreenMarkerPlugin plugin, ScreenMarkerOverlay marker)
|
||||
|
||||
@@ -34,8 +34,7 @@ import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
@@ -81,19 +80,9 @@ public class ScreenMarkerPluginPanel extends PluginPanel
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
ADD_ICON = new ImageIcon(ImageIO.read(ScreenMarkerPlugin.class.getResourceAsStream("add_icon.png")));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
ADD_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(ImageUtil.bufferedImageFromImage(ADD_ICON.getImage()), 0.53f));
|
||||
final BufferedImage addIcon = ImageUtil.getResourceStreamFromClass(ScreenMarkerPlugin.class, "add_icon.png");
|
||||
ADD_ICON = new ImageIcon(addIcon);
|
||||
ADD_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(addIcon, 0.53f));
|
||||
}
|
||||
|
||||
public void init()
|
||||
|
||||
@@ -90,6 +90,7 @@ import net.runelite.client.ui.DrawManager;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.util.HotkeyListener;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.client.util.Text;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import okhttp3.Call;
|
||||
@@ -205,41 +206,30 @@ public class ScreenshotPlugin extends Plugin
|
||||
SCREENSHOT_DIR.mkdirs();
|
||||
keyManager.registerKeyListener(hotkeyListener);
|
||||
|
||||
try
|
||||
{
|
||||
BufferedImage iconImage;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
iconImage = ImageIO.read(ScreenshotPlugin.class.getResourceAsStream("screenshot.png"));
|
||||
}
|
||||
final BufferedImage iconImage = ImageUtil.getResourceStreamFromClass(getClass(), "screenshot.png");
|
||||
|
||||
titleBarButton = NavigationButton.builder()
|
||||
.tab(false)
|
||||
.tooltip("Take screenshot")
|
||||
.icon(iconImage)
|
||||
.onClick(() -> takeScreenshot(format(new Date())))
|
||||
.popup(ImmutableMap
|
||||
.<String, Runnable>builder()
|
||||
.put("Open screenshot folder...", () ->
|
||||
titleBarButton = NavigationButton.builder()
|
||||
.tab(false)
|
||||
.tooltip("Take screenshot")
|
||||
.icon(iconImage)
|
||||
.onClick(() -> takeScreenshot(format(new Date())))
|
||||
.popup(ImmutableMap
|
||||
.<String, Runnable>builder()
|
||||
.put("Open screenshot folder...", () ->
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
Desktop.getDesktop().open(SCREENSHOT_DIR);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
log.warn("Error opening screenshot dir", ex);
|
||||
}
|
||||
})
|
||||
.build())
|
||||
.build();
|
||||
Desktop.getDesktop().open(SCREENSHOT_DIR);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
log.warn("Error opening screenshot dir", ex);
|
||||
}
|
||||
})
|
||||
.build())
|
||||
.build();
|
||||
|
||||
clientToolbar.addNavigation(titleBarButton);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
log.warn("Error adding screenshot button to titlebar", ex);
|
||||
}
|
||||
clientToolbar.addNavigation(titleBarButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
package net.runelite.client.plugins.skillcalculator;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
@@ -37,6 +36,7 @@ import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Skill Calculator",
|
||||
@@ -69,11 +69,7 @@ public class SkillCalculatorPlugin extends Plugin
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(getClass().getResourceAsStream("calc.png"));
|
||||
}
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "calc.png");
|
||||
|
||||
SkillCalculator.spriteManager = spriteManager;
|
||||
SkillCalculator.itemManager = itemManager;
|
||||
|
||||
@@ -25,10 +25,9 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.worldmap;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import lombok.Getter;
|
||||
import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
class TeleportPoint extends WorldMapPoint
|
||||
{
|
||||
@@ -42,13 +41,6 @@ class TeleportPoint extends WorldMapPoint
|
||||
this.data = data;
|
||||
setTooltip(data.getTooltip());
|
||||
|
||||
try
|
||||
{
|
||||
setImage(ImageIO.read(WorldMapPlugin.class.getResourceAsStream(data.getIconPath())));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
setImage(ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, data.getIconPath()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,7 @@ import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Experience;
|
||||
import net.runelite.api.Skill;
|
||||
@@ -41,6 +39,7 @@ import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.overlay.worldmap.WorldMapPointManager;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "World Map",
|
||||
@@ -73,23 +72,13 @@ public class WorldMapPlugin extends Plugin
|
||||
|
||||
BLANK_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB);
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
FAIRY_TRAVEL_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB);
|
||||
final BufferedImage icon = ImageIO.read(WorldMapPlugin.class.getResourceAsStream("fairy_ring_travel.png"));
|
||||
FAIRY_TRAVEL_ICON.getGraphics().drawImage(icon, 1, 1, null);
|
||||
FAIRY_TRAVEL_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB);
|
||||
final BufferedImage fairyTravelIcon = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "fairy_ring_travel.png");
|
||||
FAIRY_TRAVEL_ICON.getGraphics().drawImage(fairyTravelIcon, 1, 1, null);
|
||||
|
||||
NOPE_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB);
|
||||
final BufferedImage nopeImage = ImageIO.read(WorldMapPlugin.class.getResourceAsStream("nope_icon.png"));
|
||||
NOPE_ICON.getGraphics().drawImage(nopeImage, 1, 1, null);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
NOPE_ICON = new BufferedImage(iconBufferSize, iconBufferSize, BufferedImage.TYPE_INT_ARGB);
|
||||
final BufferedImage nopeImage = ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, "nope_icon.png");
|
||||
NOPE_ICON.getGraphics().drawImage(nopeImage, 1, 1, null);
|
||||
}
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -33,7 +33,6 @@ import java.awt.image.BufferedImage;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
@@ -53,6 +52,7 @@ import static net.runelite.client.plugins.xptracker.XpWorldType.NORMAL;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.client.ui.ClientToolbar;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import net.runelite.http.api.xp.XpClient;
|
||||
|
||||
@PluginDescriptor(
|
||||
@@ -102,11 +102,7 @@ public class XpTrackerPlugin extends Plugin
|
||||
{
|
||||
xpPanel = new XpPanel(this, client, skillIconManager);
|
||||
|
||||
BufferedImage icon;
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(getClass().getResourceAsStream("/skill_icons/overall.png"));
|
||||
}
|
||||
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "/skill_icons/overall.png");
|
||||
|
||||
navButton = NavigationButton.builder()
|
||||
.tooltip("XP Tracker")
|
||||
|
||||
@@ -38,9 +38,7 @@ import java.awt.LayoutManager;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import javax.swing.BoxLayout;
|
||||
@@ -96,24 +94,8 @@ public class ClientUI
|
||||
|
||||
static
|
||||
{
|
||||
BufferedImage icon;
|
||||
BufferedImage sidebarOpen;
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
icon = ImageIO.read(ClientUI.class.getResourceAsStream("/runelite.png"));
|
||||
sidebarOpen = ImageIO.read(ClientUI.class.getResourceAsStream("open.png"));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
ICON = icon;
|
||||
SIDEBAR_OPEN = sidebarOpen;
|
||||
ICON = ImageUtil.getResourceStreamFromClass(ClientUI.class, "/runelite.png");
|
||||
SIDEBAR_OPEN = ImageUtil.getResourceStreamFromClass(ClientUI.class, "open.png");
|
||||
SIDEBAR_CLOSE = ImageUtil.flipImage(SIDEBAR_OPEN, true, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,9 @@ import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.AffineTransformOp;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.RescaleOp;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.GrayFilter;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -328,6 +330,30 @@ public class ImageUtil
|
||||
return outlinedImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an image resource from a given path relative to a given class.
|
||||
* This method is primarily shorthand for the synchronization and error handling required for
|
||||
* loading image resources from classes.
|
||||
*
|
||||
* @param c The class to be referenced for resource path.
|
||||
* @param path The path, relative to the given class.
|
||||
* @return A {@link BufferedImage} of the loaded image resource from the given path.
|
||||
*/
|
||||
public static BufferedImage getResourceStreamFromClass(final Class c, final String path)
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (ImageIO.class)
|
||||
{
|
||||
return ImageIO.read(c.getResourceAsStream(path));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills all non-transparent pixels of the given image with the given color.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user