Java ImageIcon drawImageBorder(Graphics g, ImageIcon img, Rectangle rect, Insets ins, boolean drawCenter)

Here you can find the source of drawImageBorder(Graphics g, ImageIcon img, Rectangle rect, Insets ins, boolean drawCenter)

Description

draw Image Border

License

Open Source License

Declaration

public static void drawImageBorder(Graphics g,
                ImageIcon img, Rectangle rect, Insets ins, boolean drawCenter)
        

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Graphics;

import java.awt.Insets;

import java.awt.Rectangle;

import javax.swing.ImageIcon;

public class Main {
    public static void drawImageBorder(Graphics g, ImageIcon img,
            Rectangle rect, Insets ins, boolean drawCenter)
    /*      */{// ww  w  . j  a v  a  2s.c  o m
        /* 2894 */int left = ins.left;
        /* 2895 */int right = ins.right;
        /* 2896 */int top = ins.top;
        /* 2897 */int bottom = ins.bottom;
        /* 2898 */int x = rect.x;
        /* 2899 */int y = rect.y;
        /* 2900 */int w = rect.width;
        /* 2901 */int h = rect.height;
        /*      */
        /* 2904 */g.drawImage(img.getImage(), x, y, x + left, y + top, 0,
                0, left, top, null);
        /*      */
        /* 2906 */g.drawImage(img.getImage(), x + left, y, x + w - right,
                y + top, left, 0, img.getIconWidth() - right, top, null);
        /*      */
        /* 2908 */g.drawImage(img.getImage(), x + w - right, y, x + w, y
                + top, img.getIconWidth() - right, 0, img.getIconWidth(),
                top, null);
        /*      */
        /* 2912 */g.drawImage(img.getImage(), x, y + top, x + left, y + h
                - bottom, 0, top, left, img.getIconHeight() - bottom, null);
        /*      */
        /* 2914 */g.drawImage(img.getImage(), x + left, y + top, x + w
                - right, y + h - bottom, left, top, img.getIconWidth()
                - right, img.getIconHeight() - bottom, null);
        /*      */
        /* 2916 */g.drawImage(img.getImage(), x + w - right, y + top, x
                + w, y + h - bottom, img.getIconWidth() - right, top,
                img.getIconWidth(), img.getIconHeight() - bottom, null);
        /*      */
        /* 2920 */g.drawImage(img.getImage(), x, y + h - bottom, x + left,
                y + h, 0, img.getIconHeight() - bottom, left,
                img.getIconHeight(), null);
        /*      */
        /* 2922 */g.drawImage(img.getImage(), x + left, y + h - bottom, x
                + w - right, y + h, left, img.getIconHeight() - bottom,
                img.getIconWidth() - right, img.getIconHeight(), null);
        /*      */
        /* 2924 */g.drawImage(img.getImage(), x + w - right, y + h
                - bottom, x + w, y + h, img.getIconWidth() - right,
                img.getIconHeight() - bottom, img.getIconWidth(),
                img.getIconHeight(), null);
        /*      */
        /* 2927 */if (drawCenter)
            /* 2928 */g.drawImage(img.getImage(), x + left, y + top, x + w
                    - right, y + h - bottom, left, top, img.getIconWidth()
                    - right, img.getIconHeight() - bottom, null);
        /*      */}
}

Related

  1. createOverlayIcon(Icon baseIcon, ImageIcon overlayIcon)
  2. createScaledImageIcon(byte[] albumArtBytes)
  3. CreateSizedImageIconScaledSmooth(URL filePath, int width, int height)
  4. createTempImage(ImageIcon icon, File oldFile)
  5. displayImage(final ImageIcon ii)
  6. drawImageBorder(Graphics g, ImageIcon img, Rectangle rect, Insets ins, boolean drawCenter)
  7. fitIcon(ImageIcon icon, int containerWidth, int containerHeight)
  8. fitToSquare(ImageIcon icon, int newSize)
  9. generateImageIcon(Color color, int size, Insets insets)