Kourend Library Plugin slight design tweak

- Spaced out the item panels vertically and slightly horizontally.
- Added a new header with the plugin's name, as it can be hard to know
what this plugin does/is.
- Restyled the reset button, it previously was a "Reset" text button, I
switched it to an icon with a darker version that activates
when clicked.
- Added the icon images to the resource folder.
- Added new method to SwingUtil that returns a darker version of an
image
- Used the image darkening method to give the refresh button a click
feedback effect
This commit is contained in:
Ruben Amendoeira
2018-04-22 04:44:13 +01:00
parent d0f708e26a
commit 4679bdad77
4 changed files with 112 additions and 10 deletions

View File

@@ -32,6 +32,7 @@ import java.awt.Frame;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
@@ -41,6 +42,8 @@ import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.image.LookupOp;
import java.awt.image.LookupTable;
import java.util.Enumeration;
import java.util.concurrent.Callable;
import java.util.function.BiConsumer;
@@ -95,6 +98,40 @@ public class SwingUtil
System.setProperty("sun.awt.noerasebackground", "true");
}
/**
* Offsets an image in the grayscale (darkens/brightens) by an offset
*/
public static BufferedImage grayscaleOffset(BufferedImage image, int offset)
{
int numComponents = image.getColorModel().getNumComponents();
int index = numComponents - 1;
LookupTable lookup = new LookupTable(0, numComponents)
{
@Override
public int[] lookupPixel(int[] src, int[] dest)
{
if (dest[index] != 0)
{
dest[index] = dest[index] + offset;
if (dest[index] < 0)
{
dest[index] = 0;
}
else if (dest[index] > 255)
{
dest[index] = 255;
}
}
return dest;
}
};
LookupOp op = new LookupOp(lookup, new RenderingHints(null));
return op.filter(image, null);
}
/**
* Converts a given color to it's hexidecimal equivalent.
*/