sun.awt.IconInfo Java Examples

The following examples show how to use sun.awt.IconInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XWindowPeer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected synchronized static java.util.List<IconInfo> getDefaultIconInfo() {
    if (defaultIconInfo == null) {
        defaultIconInfo = new ArrayList<IconInfo>();
        if (XlibWrapper.dataModel == 32) {
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon16_png.java_icon16_png));
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon24_png.java_icon24_png));
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon32_png.java_icon32_png));
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon48_png.java_icon48_png));
        } else {
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon16_png.java_icon16_png));
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon24_png.java_icon24_png));
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon32_png.java_icon32_png));
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon48_png.java_icon48_png));
        }
    }
    return defaultIconInfo;
}
 
Example #2
Source File: XWindowPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void recursivelySetIcon(java.util.List<IconInfo> icons) {
    dumpIcons(winAttr.icons);
    setIconHints(icons);
    Window target = (Window)this.target;
    Window[] children = target.getOwnedWindows();
    int cnt = children.length;
    for (int i = 0; i < cnt; i++) {
        ComponentPeer childPeer = children[i].getPeer();
        if (childPeer != null && childPeer instanceof XWindowPeer) {
            if (((XWindowPeer)childPeer).winAttr.iconsInherited) {
                ((XWindowPeer)childPeer).winAttr.icons = icons;
                ((XWindowPeer)childPeer).recursivelySetIcon(icons);
            }
        }
    }
}
 
Example #3
Source File: XWindowPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void recursivelySetIcon(java.util.List<IconInfo> icons) {
    dumpIcons(winAttr.icons);
    setIconHints(icons);
    Window target = (Window)this.target;
    Window[] children = target.getOwnedWindows();
    int cnt = children.length;
    for (int i = 0; i < cnt; i++) {
        ComponentPeer childPeer = children[i].getPeer();
        if (childPeer != null && childPeer instanceof XWindowPeer) {
            if (((XWindowPeer)childPeer).winAttr.iconsInherited) {
                ((XWindowPeer)childPeer).winAttr.icons = icons;
                ((XWindowPeer)childPeer).recursivelySetIcon(icons);
            }
        }
    }
}
 
Example #4
Source File: XWindowPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void recursivelySetIcon(java.util.List<IconInfo> icons) {
    dumpIcons(winAttr.icons);
    setIconHints(icons);
    Window target = (Window)this.target;
    Window[] children = target.getOwnedWindows();
    int cnt = children.length;
    for (int i = 0; i < cnt; i++) {
        ComponentPeer childPeer = children[i].getPeer();
        if (childPeer != null && childPeer instanceof XWindowPeer) {
            if (((XWindowPeer)childPeer).winAttr.iconsInherited) {
                ((XWindowPeer)childPeer).winAttr.icons = icons;
                ((XWindowPeer)childPeer).recursivelySetIcon(icons);
            }
        }
    }
}
 
Example #5
Source File: CWarningWindow.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static IconInfo getSecurityIconInfo(int size, int num) {
    synchronized (CWarningWindow.class) {
        if (icons == null) {
            icons = new IconInfo[4][3];
            icons[0][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw16_png.security_icon_bw16_png);
            icons[0][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim16_png.security_icon_interim16_png);
            icons[0][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow16_png.security_icon_yellow16_png);
            icons[1][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw24_png.security_icon_bw24_png);
            icons[1][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim24_png.security_icon_interim24_png);
            icons[1][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow24_png.security_icon_yellow24_png);
            icons[2][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw32_png.security_icon_bw32_png);
            icons[2][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim32_png.security_icon_interim32_png);
            icons[2][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow32_png.security_icon_yellow32_png);
            icons[3][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw48_png.security_icon_bw48_png);
            icons[3][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim48_png.security_icon_interim48_png);
            icons[3][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow48_png.security_icon_yellow48_png);
        }
    }
    final int sizeIndex = size % icons.length;
    return icons[sizeIndex][num % icons[sizeIndex].length];
}
 
Example #6
Source File: CWarningWindow.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static IconInfo getSecurityIconInfo(int size, int num) {
    synchronized (CWarningWindow.class) {
        if (icons == null) {
            icons = new IconInfo[4][3];
            icons[0][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw16_png.security_icon_bw16_png);
            icons[0][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim16_png.security_icon_interim16_png);
            icons[0][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow16_png.security_icon_yellow16_png);
            icons[1][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw24_png.security_icon_bw24_png);
            icons[1][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim24_png.security_icon_interim24_png);
            icons[1][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow24_png.security_icon_yellow24_png);
            icons[2][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw32_png.security_icon_bw32_png);
            icons[2][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim32_png.security_icon_interim32_png);
            icons[2][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow32_png.security_icon_yellow32_png);
            icons[3][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw48_png.security_icon_bw48_png);
            icons[3][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim48_png.security_icon_interim48_png);
            icons[3][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow48_png.security_icon_yellow48_png);
        }
    }
    final int sizeIndex = size % icons.length;
    return icons[sizeIndex][num % icons[sizeIndex].length];
}
 
Example #7
Source File: XWindowPeer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void recursivelySetIcon(java.util.List<IconInfo> icons) {
    dumpIcons(winAttr.icons);
    setIconHints(icons);
    Window target = (Window)this.target;
    Window[] children = target.getOwnedWindows();
    int cnt = children.length;
    for (int i = 0; i < cnt; i++) {
        ComponentPeer childPeer = children[i].getPeer();
        if (childPeer != null && childPeer instanceof XWindowPeer) {
            if (((XWindowPeer)childPeer).winAttr.iconsInherited) {
                ((XWindowPeer)childPeer).winAttr.icons = icons;
                ((XWindowPeer)childPeer).recursivelySetIcon(icons);
            }
        }
    }
}
 
Example #8
Source File: XWindowPeer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
protected synchronized static java.util.List<IconInfo> getDefaultIconInfo() {
    if (defaultIconInfo == null) {
        defaultIconInfo = new ArrayList<IconInfo>();
        if (XlibWrapper.dataModel == 32) {
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon16_png.java_icon16_png));
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon24_png.java_icon24_png));
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon32_png.java_icon32_png));
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon48_png.java_icon48_png));
        } else {
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon16_png.java_icon16_png));
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon24_png.java_icon24_png));
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon32_png.java_icon32_png));
            defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon48_png.java_icon48_png));
        }
    }
    return defaultIconInfo;
}
 
Example #9
Source File: CWarningWindow.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void updateIconSize() {
    int newSize = -1;

    if (ownerWindow != null) {
        Insets insets = ownerWindow.getInsets();
        int max = Math.max(insets.top, Math.max(insets.bottom,
                Math.max(insets.left, insets.right)));
        if (max < 24) {
            newSize = 0;
        } else if (max < 32) {
            newSize = 1;
        } else if (max < 48) {
            newSize = 2;
        } else {
            newSize = 3;
        }
    }
    // Make sure we have a valid size
    if (newSize == -1) {
        newSize = 0;
    }

    synchronized (lock) {
        if (newSize != currentSize) {
            currentSize = newSize;
            IconInfo ico = getSecurityIconInfo(currentSize, 0);
            AWTAccessor.getWindowAccessor().setSecurityWarningSize(
                ownerWindow, ico.getWidth(), ico.getHeight());
        }
    }
}
 
Example #10
Source File: XWindowPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void dumpIcons(java.util.List<IconInfo> icons) {
    if (iconLog.isLoggable(PlatformLogger.Level.FINEST)) {
        iconLog.finest(">>> Sizes of icon images:");
        for (Iterator<IconInfo> i = icons.iterator(); i.hasNext(); ) {
            iconLog.finest("    {0}", i.next());
        }
    }
}
 
Example #11
Source File: XDecoratedPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void setIconHints(java.util.List<IconInfo> icons) {
    if (!XWM.getWM().setNetWMIcon(this, icons)) {
        if (icons.size() > 0) {
            if (iconWindow == null) {
                iconWindow = new XIconWindow(this);
            }
            iconWindow.setIconImages(icons);
        }
    }
}
 
Example #12
Source File: XDecoratedPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void setIconHints(java.util.List<IconInfo> icons) {
    if (!XWM.getWM().setNetWMIcon(this, icons)) {
        if (icons.size() > 0) {
            if (iconWindow == null) {
                iconWindow = new XIconWindow(this);
            }
            iconWindow.setIconImages(icons);
        }
    }
}
 
Example #13
Source File: XIconWindow.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets icon image by selecting one of the images from the list.
 * The selected image is the one having the best matching size.
 */
void setIconImages(java.util.List<IconInfo> icons) {
    if (icons == null || icons.size() == 0) return;

    int minDiff = Integer.MAX_VALUE;
    Image min = null;
    for (IconInfo iconInfo : icons) {
        if (iconInfo.isValid()) {
            Image image = iconInfo.getImage();
            Dimension dim = calcIconSize(image.getWidth(null), image.getHeight(null));
            int widthDiff = Math.abs(dim.width - image.getWidth(null));
            int heightDiff = Math.abs(image.getHeight(null) - dim.height);

            // "=" below allows to select the best matching icon
            if (minDiff >= (widthDiff + heightDiff)) {
                minDiff = (widthDiff + heightDiff);
                min = image;
            }
        }
    }
    if (min != null) {
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
            log.finer("Icon: {0}x{1}", min.getWidth(null), min.getHeight(null));
        }
        setIconImage(min);
    }
}
 
Example #14
Source File: XWarningWindow.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static IconInfo getSecurityIconInfo(int size, int num) {
    synchronized (XWarningWindow.class) {
        if (icons == null) {
            icons = new IconInfo[4][3];
            if (XlibWrapper.dataModel == 32) {
                icons[0][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw16_png.security_icon_bw16_png);
                icons[0][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim16_png.security_icon_interim16_png);
                icons[0][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow16_png.security_icon_yellow16_png);
                icons[1][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw24_png.security_icon_bw24_png);
                icons[1][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim24_png.security_icon_interim24_png);
                icons[1][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow24_png.security_icon_yellow24_png);
                icons[2][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw32_png.security_icon_bw32_png);
                icons[2][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim32_png.security_icon_interim32_png);
                icons[2][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow32_png.security_icon_yellow32_png);
                icons[3][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw48_png.security_icon_bw48_png);
                icons[3][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim48_png.security_icon_interim48_png);
                icons[3][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow48_png.security_icon_yellow48_png);
            } else {
                icons[0][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw16_png.security_icon_bw16_png);
                icons[0][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim16_png.security_icon_interim16_png);
                icons[0][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow16_png.security_icon_yellow16_png);
                icons[1][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw24_png.security_icon_bw24_png);
                icons[1][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim24_png.security_icon_interim24_png);
                icons[1][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow24_png.security_icon_yellow24_png);
                icons[2][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw32_png.security_icon_bw32_png);
                icons[2][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim32_png.security_icon_interim32_png);
                icons[2][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow32_png.security_icon_yellow32_png);
                icons[3][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw48_png.security_icon_bw48_png);
                icons[3][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim48_png.security_icon_interim48_png);
                icons[3][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow48_png.security_icon_yellow48_png);
            }
        }
    }
    final int sizeIndex = size % icons.length;
    return icons[sizeIndex][num % icons[sizeIndex].length];
}
 
Example #15
Source File: XIconWindow.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets icon image by selecting one of the images from the list.
 * The selected image is the one having the best matching size.
 */
void setIconImages(java.util.List<IconInfo> icons) {
    if (icons == null || icons.size() == 0) return;

    int minDiff = Integer.MAX_VALUE;
    Image min = null;
    for (IconInfo iconInfo : icons) {
        if (iconInfo.isValid()) {
            Image image = iconInfo.getImage();
            Dimension dim = calcIconSize(image.getWidth(null), image.getHeight(null));
            int widthDiff = Math.abs(dim.width - image.getWidth(null));
            int heightDiff = Math.abs(image.getHeight(null) - dim.height);

            // "=" below allows to select the best matching icon
            if (minDiff >= (widthDiff + heightDiff)) {
                minDiff = (widthDiff + heightDiff);
                min = image;
            }
        }
    }
    if (min != null) {
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
            log.finer("Icon: {0}x{1}", min.getWidth(null), min.getHeight(null));
        }
        setIconImage(min);
    }
}
 
Example #16
Source File: XDecoratedPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void setIconHints(java.util.List<IconInfo> icons) {
    if (!XWM.getWM().setNetWMIcon(this, icons)) {
        if (icons.size() > 0) {
            if (iconWindow == null) {
                iconWindow = new XIconWindow(this);
            }
            iconWindow.setIconImages(icons);
        }
    }
}
 
Example #17
Source File: CWarningWindow.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void updateIconSize() {
    int newSize = -1;

    if (ownerWindow != null) {
        Insets insets = ownerWindow.getInsets();
        int max = Math.max(insets.top, Math.max(insets.bottom,
                Math.max(insets.left, insets.right)));
        if (max < 24) {
            newSize = 0;
        } else if (max < 32) {
            newSize = 1;
        } else if (max < 48) {
            newSize = 2;
        } else {
            newSize = 3;
        }
    }
    // Make sure we have a valid size
    if (newSize == -1) {
        newSize = 0;
    }

    synchronized (lock) {
        if (newSize != currentSize) {
            currentSize = newSize;
            IconInfo ico = getSecurityIconInfo(currentSize, 0);
            AWTAccessor.getWindowAccessor().setSecurityWarningSize(
                ownerWindow, ico.getWidth(), ico.getHeight());
        }
    }
}
 
Example #18
Source File: XWarningWindow.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static IconInfo getSecurityIconInfo(int size, int num) {
    synchronized (XWarningWindow.class) {
        if (icons == null) {
            icons = new IconInfo[4][3];
            if (XlibWrapper.dataModel == 32) {
                icons[0][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw16_png.security_icon_bw16_png);
                icons[0][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim16_png.security_icon_interim16_png);
                icons[0][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow16_png.security_icon_yellow16_png);
                icons[1][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw24_png.security_icon_bw24_png);
                icons[1][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim24_png.security_icon_interim24_png);
                icons[1][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow24_png.security_icon_yellow24_png);
                icons[2][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw32_png.security_icon_bw32_png);
                icons[2][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim32_png.security_icon_interim32_png);
                icons[2][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow32_png.security_icon_yellow32_png);
                icons[3][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw48_png.security_icon_bw48_png);
                icons[3][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim48_png.security_icon_interim48_png);
                icons[3][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow48_png.security_icon_yellow48_png);
            } else {
                icons[0][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw16_png.security_icon_bw16_png);
                icons[0][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim16_png.security_icon_interim16_png);
                icons[0][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow16_png.security_icon_yellow16_png);
                icons[1][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw24_png.security_icon_bw24_png);
                icons[1][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim24_png.security_icon_interim24_png);
                icons[1][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow24_png.security_icon_yellow24_png);
                icons[2][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw32_png.security_icon_bw32_png);
                icons[2][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim32_png.security_icon_interim32_png);
                icons[2][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow32_png.security_icon_yellow32_png);
                icons[3][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw48_png.security_icon_bw48_png);
                icons[3][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim48_png.security_icon_interim48_png);
                icons[3][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow48_png.security_icon_yellow48_png);
            }
        }
    }
    final int sizeIndex = size % icons.length;
    return icons[sizeIndex][num % icons[sizeIndex].length];
}
 
Example #19
Source File: XWindowPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void dumpIcons(java.util.List<IconInfo> icons) {
    if (iconLog.isLoggable(PlatformLogger.Level.FINEST)) {
        iconLog.finest(">>> Sizes of icon images:");
        for (Iterator<IconInfo> i = icons.iterator(); i.hasNext(); ) {
            iconLog.finest("    {0}", i.next());
        }
    }
}
 
Example #20
Source File: XDecoratedPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
void setIconHints(java.util.List<IconInfo> icons) {
    if (!XWM.getWM().setNetWMIcon(this, icons)) {
        if (icons.size() > 0) {
            if (iconWindow == null) {
                iconWindow = new XIconWindow(this);
            }
            iconWindow.setIconImages(icons);
        }
    }
}
 
Example #21
Source File: XIconWindow.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets icon image by selecting one of the images from the list.
 * The selected image is the one having the best matching size.
 */
void setIconImages(java.util.List<IconInfo> icons) {
    if (icons == null || icons.size() == 0) return;

    int minDiff = Integer.MAX_VALUE;
    Image min = null;
    for (IconInfo iconInfo : icons) {
        if (iconInfo.isValid()) {
            Image image = iconInfo.getImage();
            Dimension dim = calcIconSize(image.getWidth(null), image.getHeight(null));
            int widthDiff = Math.abs(dim.width - image.getWidth(null));
            int heightDiff = Math.abs(image.getHeight(null) - dim.height);

            // "=" below allows to select the best matching icon
            if (minDiff >= (widthDiff + heightDiff)) {
                minDiff = (widthDiff + heightDiff);
                min = image;
            }
        }
    }
    if (min != null) {
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
            log.finer("Icon: {0}x{1}", min.getWidth(null), min.getHeight(null));
        }
        setIconImage(min);
    }
}
 
Example #22
Source File: CWarningWindow.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void updateIconSize() {
    int newSize = -1;

    if (ownerWindow != null) {
        Insets insets = ownerWindow.getInsets();
        int max = Math.max(insets.top, Math.max(insets.bottom,
                Math.max(insets.left, insets.right)));
        if (max < 24) {
            newSize = 0;
        } else if (max < 32) {
            newSize = 1;
        } else if (max < 48) {
            newSize = 2;
        } else {
            newSize = 3;
        }
    }
    // Make sure we have a valid size
    if (newSize == -1) {
        newSize = 0;
    }

    synchronized (lock) {
        if (newSize != currentSize) {
            currentSize = newSize;
            IconInfo ico = getSecurityIconInfo(currentSize, 0);
            AWTAccessor.getWindowAccessor().setSecurityWarningSize(
                ownerWindow, ico.getWidth(), ico.getHeight());
        }
    }
}
 
Example #23
Source File: XWarningWindow.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static IconInfo getSecurityIconInfo(int size, int num) {
    synchronized (XWarningWindow.class) {
        if (icons == null) {
            icons = new IconInfo[4][3];
            if (XlibWrapper.dataModel == 32) {
                icons[0][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw16_png.security_icon_bw16_png);
                icons[0][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim16_png.security_icon_interim16_png);
                icons[0][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow16_png.security_icon_yellow16_png);
                icons[1][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw24_png.security_icon_bw24_png);
                icons[1][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim24_png.security_icon_interim24_png);
                icons[1][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow24_png.security_icon_yellow24_png);
                icons[2][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw32_png.security_icon_bw32_png);
                icons[2][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim32_png.security_icon_interim32_png);
                icons[2][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow32_png.security_icon_yellow32_png);
                icons[3][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw48_png.security_icon_bw48_png);
                icons[3][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim48_png.security_icon_interim48_png);
                icons[3][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow48_png.security_icon_yellow48_png);
            } else {
                icons[0][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw16_png.security_icon_bw16_png);
                icons[0][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim16_png.security_icon_interim16_png);
                icons[0][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow16_png.security_icon_yellow16_png);
                icons[1][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw24_png.security_icon_bw24_png);
                icons[1][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim24_png.security_icon_interim24_png);
                icons[1][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow24_png.security_icon_yellow24_png);
                icons[2][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw32_png.security_icon_bw32_png);
                icons[2][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim32_png.security_icon_interim32_png);
                icons[2][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow32_png.security_icon_yellow32_png);
                icons[3][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw48_png.security_icon_bw48_png);
                icons[3][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim48_png.security_icon_interim48_png);
                icons[3][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow48_png.security_icon_yellow48_png);
            }
        }
    }
    final int sizeIndex = size % icons.length;
    return icons[sizeIndex][num % icons[sizeIndex].length];
}
 
Example #24
Source File: XIconWindow.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets icon image by selecting one of the images from the list.
 * The selected image is the one having the best matching size.
 */
void setIconImages(java.util.List<IconInfo> icons) {
    if (icons == null || icons.size() == 0) return;

    int minDiff = Integer.MAX_VALUE;
    Image min = null;
    for (IconInfo iconInfo : icons) {
        if (iconInfo.isValid()) {
            Image image = iconInfo.getImage();
            Dimension dim = calcIconSize(image.getWidth(null), image.getHeight(null));
            int widthDiff = Math.abs(dim.width - image.getWidth(null));
            int heightDiff = Math.abs(image.getHeight(null) - dim.height);

            // "=" below allows to select the best matching icon
            if (minDiff >= (widthDiff + heightDiff)) {
                minDiff = (widthDiff + heightDiff);
                min = image;
            }
        }
    }
    if (min != null) {
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
            log.finer("Icon: {0}x{1}", min.getWidth(null), min.getHeight(null));
        }
        setIconImage(min);
    }
}
 
Example #25
Source File: XIconWindow.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets icon image by selecting one of the images from the list.
 * The selected image is the one having the best matching size.
 */
void setIconImages(java.util.List<IconInfo> icons) {
    if (icons == null || icons.size() == 0) return;

    int minDiff = Integer.MAX_VALUE;
    Image min = null;
    for (IconInfo iconInfo : icons) {
        if (iconInfo.isValid()) {
            Image image = iconInfo.getImage();
            Dimension dim = calcIconSize(image.getWidth(null), image.getHeight(null));
            int widthDiff = Math.abs(dim.width - image.getWidth(null));
            int heightDiff = Math.abs(image.getHeight(null) - dim.height);

            // "=" below allows to select the best matching icon
            if (minDiff >= (widthDiff + heightDiff)) {
                minDiff = (widthDiff + heightDiff);
                min = image;
            }
        }
    }
    if (min != null) {
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
            log.finer("Icon: {0}x{1}", min.getWidth(null), min.getHeight(null));
        }
        setIconImage(min);
    }
}
 
Example #26
Source File: XWarningWindow.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static IconInfo getSecurityIconInfo(int size, int num) {
    synchronized (XWarningWindow.class) {
        if (icons == null) {
            icons = new IconInfo[4][3];
            if (XlibWrapper.dataModel == 32) {
                icons[0][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw16_png.security_icon_bw16_png);
                icons[0][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim16_png.security_icon_interim16_png);
                icons[0][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow16_png.security_icon_yellow16_png);
                icons[1][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw24_png.security_icon_bw24_png);
                icons[1][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim24_png.security_icon_interim24_png);
                icons[1][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow24_png.security_icon_yellow24_png);
                icons[2][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw32_png.security_icon_bw32_png);
                icons[2][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim32_png.security_icon_interim32_png);
                icons[2][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow32_png.security_icon_yellow32_png);
                icons[3][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw48_png.security_icon_bw48_png);
                icons[3][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim48_png.security_icon_interim48_png);
                icons[3][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow48_png.security_icon_yellow48_png);
            } else {
                icons[0][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw16_png.security_icon_bw16_png);
                icons[0][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim16_png.security_icon_interim16_png);
                icons[0][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow16_png.security_icon_yellow16_png);
                icons[1][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw24_png.security_icon_bw24_png);
                icons[1][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim24_png.security_icon_interim24_png);
                icons[1][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow24_png.security_icon_yellow24_png);
                icons[2][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw32_png.security_icon_bw32_png);
                icons[2][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim32_png.security_icon_interim32_png);
                icons[2][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow32_png.security_icon_yellow32_png);
                icons[3][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw48_png.security_icon_bw48_png);
                icons[3][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim48_png.security_icon_interim48_png);
                icons[3][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow48_png.security_icon_yellow48_png);
            }
        }
    }
    final int sizeIndex = size % icons.length;
    return icons[sizeIndex][num % icons[sizeIndex].length];
}
 
Example #27
Source File: XDecoratedPeer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void setIconHints(java.util.List<IconInfo> icons) {
    if (!XWM.getWM().setNetWMIcon(this, icons)) {
        if (icons.size() > 0) {
            if (iconWindow == null) {
                iconWindow = new XIconWindow(this);
            }
            iconWindow.setIconImages(icons);
        }
    }
}
 
Example #28
Source File: XIconWindow.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets icon image by selecting one of the images from the list.
 * The selected image is the one having the best matching size.
 */
void setIconImages(java.util.List<IconInfo> icons) {
    if (icons == null || icons.size() == 0) return;

    int minDiff = Integer.MAX_VALUE;
    Image min = null;
    for (IconInfo iconInfo : icons) {
        if (iconInfo.isValid()) {
            Image image = iconInfo.getImage();
            Dimension dim = calcIconSize(image.getWidth(null), image.getHeight(null));
            int widthDiff = Math.abs(dim.width - image.getWidth(null));
            int heightDiff = Math.abs(image.getHeight(null) - dim.height);

            // "=" below allows to select the best matching icon
            if (minDiff >= (widthDiff + heightDiff)) {
                minDiff = (widthDiff + heightDiff);
                min = image;
            }
        }
    }
    if (min != null) {
        if (log.isLoggable(PlatformLogger.Level.FINER)) {
            log.finer("Icon: {0}x{1}", min.getWidth(null), min.getHeight(null));
        }
        setIconImage(min);
    }
}
 
Example #29
Source File: CWarningWindow.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void updateIconSize() {
    int newSize = -1;

    if (ownerWindow != null) {
        Insets insets = ownerWindow.getInsets();
        int max = Math.max(insets.top, Math.max(insets.bottom,
                Math.max(insets.left, insets.right)));
        if (max < 24) {
            newSize = 0;
        } else if (max < 32) {
            newSize = 1;
        } else if (max < 48) {
            newSize = 2;
        } else {
            newSize = 3;
        }
    }
    // Make sure we have a valid size
    if (newSize == -1) {
        newSize = 0;
    }

    synchronized (lock) {
        if (newSize != currentSize) {
            currentSize = newSize;
            IconInfo ico = getSecurityIconInfo(currentSize, 0);
            AWTAccessor.getWindowAccessor().setSecurityWarningSize(
                ownerWindow, ico.getWidth(), ico.getHeight());
        }
    }
}
 
Example #30
Source File: XWarningWindow.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static IconInfo getSecurityIconInfo(int size, int num) {
    synchronized (XWarningWindow.class) {
        if (icons == null) {
            icons = new IconInfo[4][3];
            if (XlibWrapper.dataModel == 32) {
                icons[0][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw16_png.security_icon_bw16_png);
                icons[0][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim16_png.security_icon_interim16_png);
                icons[0][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow16_png.security_icon_yellow16_png);
                icons[1][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw24_png.security_icon_bw24_png);
                icons[1][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim24_png.security_icon_interim24_png);
                icons[1][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow24_png.security_icon_yellow24_png);
                icons[2][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw32_png.security_icon_bw32_png);
                icons[2][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim32_png.security_icon_interim32_png);
                icons[2][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow32_png.security_icon_yellow32_png);
                icons[3][0] = new IconInfo(sun.awt.AWTIcon32_security_icon_bw48_png.security_icon_bw48_png);
                icons[3][1] = new IconInfo(sun.awt.AWTIcon32_security_icon_interim48_png.security_icon_interim48_png);
                icons[3][2] = new IconInfo(sun.awt.AWTIcon32_security_icon_yellow48_png.security_icon_yellow48_png);
            } else {
                icons[0][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw16_png.security_icon_bw16_png);
                icons[0][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim16_png.security_icon_interim16_png);
                icons[0][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow16_png.security_icon_yellow16_png);
                icons[1][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw24_png.security_icon_bw24_png);
                icons[1][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim24_png.security_icon_interim24_png);
                icons[1][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow24_png.security_icon_yellow24_png);
                icons[2][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw32_png.security_icon_bw32_png);
                icons[2][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim32_png.security_icon_interim32_png);
                icons[2][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow32_png.security_icon_yellow32_png);
                icons[3][0] = new IconInfo(sun.awt.AWTIcon64_security_icon_bw48_png.security_icon_bw48_png);
                icons[3][1] = new IconInfo(sun.awt.AWTIcon64_security_icon_interim48_png.security_icon_interim48_png);
                icons[3][2] = new IconInfo(sun.awt.AWTIcon64_security_icon_yellow48_png.security_icon_yellow48_png);
            }
        }
    }
    final int sizeIndex = size % icons.length;
    return icons[sizeIndex][num % icons[sizeIndex].length];
}