Class VdIcon

java.lang.Object
com.android.ide.common.vectordrawable.VdIcon
All Implemented Interfaces:
java.lang.Comparable<VdIcon>, javax.swing.Icon

public class VdIcon
extends java.lang.Object
implements javax.swing.Icon, java.lang.Comparable<VdIcon>
VdIcon wraps every vector drawable from Material Library into an icon. All of them are shown in a table for developer to pick.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static int LABEL_GAP
    Distance between the icon and the label
  • Constructor Summary

    Constructors 
    Constructor Description
    VdIcon​(VdIcon icon, java.awt.Color background)  
    VdIcon​(java.net.URL url)  
    VdIcon​(java.net.URL url, int width, int height)  
  • Method Summary

    Modifier and Type Method Description
    static java.awt.image.BufferedImage adjustIconColor​(java.awt.Component component, java.awt.image.BufferedImage image)
    Adjust the icon color when the icon is intended to be painted on top of the given component.
    int compareTo​(VdIcon other)  
    void enableCheckerBoardBackground​(boolean enable)  
    java.lang.String getDisplayName()  
    int getIconHeight()  
    int getIconWidth()  
    java.lang.String getName()  
    java.net.URL getURL()  
    static void paintCheckeredBackground​(java.awt.Graphics g, java.awt.Color backgroundColor, java.awt.Color checkeredColor, java.awt.Shape clip, int cellSize)
    TODO: Merge this code back with GraphicsUtil in idea.
    void paintIcon​(java.awt.Component c, java.awt.Graphics gc, int x, int y)  
    java.awt.image.BufferedImage renderIcon​(int width, int height)
    Returns the icon image.
    void setShowName​(boolean showName)
    Whether we should show the title displayed below the image.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • VdIcon

      public VdIcon​(java.net.URL url) throws java.io.IOException
      Throws:
      java.io.IOException
    • VdIcon

      public VdIcon​(java.net.URL url, int width, int height) throws java.io.IOException
      Throws:
      java.io.IOException
    • VdIcon

      public VdIcon​(VdIcon icon, java.awt.Color background)
  • Method Details

    • getName

      public java.lang.String getName()
    • getDisplayName

      public java.lang.String getDisplayName()
    • getURL

      public java.net.URL getURL()
    • renderIcon

      public java.awt.image.BufferedImage renderIcon​(int width, int height)
      Returns the icon image.
      Parameters:
      width - the width of the image
      height - the height of the image
    • paintCheckeredBackground

      public static void paintCheckeredBackground​(java.awt.Graphics g, java.awt.Color backgroundColor, java.awt.Color checkeredColor, java.awt.Shape clip, int cellSize)
      TODO: Merge this code back with GraphicsUtil in idea. Paints a checkered board style background. Each grid square is cellSize pixels.
    • paintIcon

      public void paintIcon​(java.awt.Component c, java.awt.Graphics gc, int x, int y)
      Specified by:
      paintIcon in interface javax.swing.Icon
    • adjustIconColor

      public static java.awt.image.BufferedImage adjustIconColor​(java.awt.Component component, java.awt.image.BufferedImage image)
      Adjust the icon color when the icon is intended to be painted on top of the given component. This method will convert the black icons to a light gray icon if it's being painted on a component with a dark background.
      Parameters:
      component - the component the icon is intended to be painted on top of
      image - the icon image
      Returns:
      the converted image, or the original image if the background is light
    • getIconWidth

      public int getIconWidth()
      Specified by:
      getIconWidth in interface javax.swing.Icon
    • getIconHeight

      public int getIconHeight()
      Specified by:
      getIconHeight in interface javax.swing.Icon
    • compareTo

      public int compareTo​(VdIcon other)
      Specified by:
      compareTo in interface java.lang.Comparable<VdIcon>
    • enableCheckerBoardBackground

      public void enableCheckerBoardBackground​(boolean enable)
    • setShowName

      public void setShowName​(boolean showName)
      Whether we should show the title displayed below the image. When this is on, the icon is made smaller to fit the font height.