コード例 #1
0
 public static Icon getEvenIcon(Icon icon) {
   LayeredIcon layeredIcon = new LayeredIcon(2);
   layeredIcon.setIcon(EMPTY_ICON, 0);
   if (icon != null
       && icon.getIconHeight() <= EMPTY_ICON.getIconHeight()
       && icon.getIconWidth() <= EMPTY_ICON.getIconWidth()) {
     layeredIcon.setIcon(
         icon,
         1,
         (-icon.getIconWidth() + EMPTY_ICON.getIconWidth()) / 2,
         (EMPTY_ICON.getIconHeight() - icon.getIconHeight()) / 2);
   }
   return layeredIcon;
 }
コード例 #2
0
  public static Icon augmentIcon(@Nullable Icon icon, @NotNull Icon standard) {
    if (icon == null) {
      return standard;
    }

    if (icon.getIconHeight() < standard.getIconHeight()
        || icon.getIconWidth() < standard.getIconWidth()) {
      final LayeredIcon layeredIcon = new LayeredIcon(2);
      layeredIcon.setIcon(icon, 0, 0, (standard.getIconHeight() - icon.getIconHeight()) / 2);
      layeredIcon.setIcon(standard, 1);
      return layeredIcon;
    }

    return icon;
  }