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 intLABEL_GAPDistance between the icon and the label -
Constructor Summary
-
Method Summary
Modifier and Type Method Description static java.awt.image.BufferedImageadjustIconColor(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.intcompareTo(VdIcon other)voidenableCheckerBoardBackground(boolean enable)java.lang.StringgetDisplayName()intgetIconHeight()intgetIconWidth()java.lang.StringgetName()java.net.URLgetURL()static voidpaintCheckeredBackground(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.voidpaintIcon(java.awt.Component c, java.awt.Graphics gc, int x, int y)java.awt.image.BufferedImagerenderIcon(int width, int height)Returns the icon image.voidsetShowName(boolean showName)Whether we should show the title displayed below the image.
-
Field Details
-
LABEL_GAP
public static final int LABEL_GAPDistance between the icon and the label- See Also:
- Constant Field Values
-
-
Constructor Details
-
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 imageheight- 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 iscellSizepixels. -
paintIcon
public void paintIcon(java.awt.Component c, java.awt.Graphics gc, int x, int y)- Specified by:
paintIconin interfacejavax.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 ofimage- the icon image- Returns:
- the converted image, or the original image if the background is light
-
getIconWidth
public int getIconWidth()- Specified by:
getIconWidthin interfacejavax.swing.Icon
-
getIconHeight
public int getIconHeight()- Specified by:
getIconHeightin interfacejavax.swing.Icon
-
compareTo
- Specified by:
compareToin interfacejava.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.
-