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]; }
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); } } } }
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; }
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; final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); for (int i = 0; i < cnt; i++) { final ComponentPeer childPeer = acc.getPeer(children[i]); if (childPeer != null && childPeer instanceof XWindowPeer) { if (((XWindowPeer)childPeer).winAttr.iconsInherited) { ((XWindowPeer)childPeer).winAttr.icons = icons; ((XWindowPeer)childPeer).recursivelySetIcon(icons); } } } }
protected static synchronized 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; }
/** * 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) { log.finer("Icon: {0}x{1}", min.getWidth(null), min.getHeight(null)); setIconImage(min); } }
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()); } } }
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); } } }
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]; }
/** * 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); } }
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()); } } }