diff --git a/src/nt.jardesc b/src/nt.jardesc new file mode 100644 index 0000000..82c9b60 --- /dev/null +++ b/src/nt.jardesc @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/nt/UI/chevron_left_icn.png b/src/nt/UI/chevron_left_icn.png new file mode 100644 index 0000000..a9a13ad Binary files /dev/null and b/src/nt/UI/chevron_left_icn.png differ diff --git a/src/nt/UI/chevron_right_icn.png b/src/nt/UI/chevron_right_icn.png new file mode 100644 index 0000000..3472317 Binary files /dev/null and b/src/nt/UI/chevron_right_icn.png differ diff --git a/src/nt/UI/util/IconResizer.java b/src/nt/UI/util/IconResizer.java index 45e4f18..87098e5 100644 --- a/src/nt/UI/util/IconResizer.java +++ b/src/nt/UI/util/IconResizer.java @@ -15,17 +15,21 @@ public class IconResizer { if(icon != null && ImageIcon.class.isInstance(icon) && (icon.getIconHeight() != height && icon.getIconWidth() != width)) { Image img = ((ImageIcon)icon).getImage(); - BufferedImage bImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - Graphics2D g2d = bImg.createGraphics(); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); - g2d.drawImage(img, 0, 0, width, height, null, null); - g2d.dispose(); - newIcon = new ImageIcon(bImg); + newIcon = new ImageIcon(resizeImage(img, width, height)); }else { newIcon = icon; } return newIcon; } + public static Image resizeImage(Image img, int width, int height) { + BufferedImage bImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = bImg.createGraphics(); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + g2d.drawImage(img, 0, 0, width, height, null, null); + g2d.dispose(); + return bImg; + } + } diff --git a/src/nt/UI/util/Icons.java b/src/nt/UI/util/Icons.java index 15cb153..a8c6d5c 100644 --- a/src/nt/UI/util/Icons.java +++ b/src/nt/UI/util/Icons.java @@ -14,9 +14,11 @@ public class Icons { public static final URL NUMBER_SYMBOL_URL = Icons.class.getResource("/nt/UI/number_icn.png"); public static final URL OBJECT_SYMBOL_URL = Icons.class.getResource("/nt/UI/object_icn.png"); public static final URL SUBMODULE_SYMBOL_URL = Icons.class.getResource("/nt/UI/submodule_icn.png"); + public static final URL CHEVRO_LEFT_SYMBOL_URL = Icons.class.getResource("/nt/UI/chevron_left_icn.png"); + public static final URL CHEVRO_RIGHT_SYMBOL_URL = Icons.class.getResource("/nt/UI/chevron_right_icn.png"); public static Icon getIcon(URL icn) { - return new ImageIcon(icn); + return new ResizeableImageIcon(icn); } } diff --git a/src/nt/UI/util/ResizeableImageIcon.java b/src/nt/UI/util/ResizeableImageIcon.java new file mode 100644 index 0000000..c2317b1 --- /dev/null +++ b/src/nt/UI/util/ResizeableImageIcon.java @@ -0,0 +1,73 @@ +package nt.UI.util; + +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.net.URL; + +import javax.swing.ImageIcon; +import javax.swing.JComponent; + +public class ResizeableImageIcon extends ImageIcon { + + private static final long serialVersionUID = 1L; + private Component component; + private boolean prepareResize = false; + + public ResizeableImageIcon(URL url) { + super(url); + } + + @Override + public synchronized void paintIcon(Component c, Graphics g, int x, int y) { + int width, height; + if(this.component == null) { + this.component = c; + c.addComponentListener(new IconParentListener()); + width = c.getWidth()-(2*Math.abs(x)); + height = c.getHeight()-(2*Math.abs(y)); + resizeIcon(width, height); + } + if(prepareResize) { + width = c.getWidth()-(2*Math.abs(x)); + height = c.getHeight()-(2*Math.abs(y)); + resizeIcon(width, height); + prepareResize=false; + } + + if(getImageObserver() == null) { + g.drawImage(getImage(), Math.abs(x), Math.abs(y), c); + } else { + g.drawImage(getImage(), Math.abs(x), Math.abs(y), getImageObserver()); + } + } + + protected void resizeIcon(int width, int height) { + if(this.component == null) { + return; + } + setImage(IconResizer.resizeImage(getImage(), width, height)); + } + + + private class IconParentListener implements ComponentListener { + + @Override + public void componentResized(ComponentEvent e) { + prepareResize=true; + } + + @Override + public void componentMoved(ComponentEvent e) {} + + @Override + public void componentShown(ComponentEvent e) {} + + @Override + public void componentHidden(ComponentEvent e) {} + + } + +}