Package org.jenkins.ui.icon
Class Icon
- java.lang.Object
-
- org.jenkins.ui.icon.Icon
-
- Direct Known Subclasses:
BuildStatusIcon,WeatherIcon
public class Icon extends Object
Simple icon metadata class.- Since:
- 2.0
- Author:
- tom.fennelly@gmail.com
-
-
Field Summary
Fields Modifier and Type Field Description static StringICON_LARGE_STYLEstatic StringICON_MEDIUM_STYLEstatic StringICON_SMALL_STYLEstatic StringICON_XLARGE_STYLE
-
Constructor Summary
Constructors Constructor Description Icon(String classSpec, String style)Creates acoreicon.Icon(String classSpec, String url, String style)Creates acoreicon.Icon(String classSpec, String url, String style, IconFormat iconFormat)Creates an icon.Icon(String classSpec, String url, String style, IconType iconType)Icon instance.Icon(String classSpec, String url, String style, IconType iconType, IconFormat iconFormat)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetClassSpec()Get the class specification for this Icon.StringgetNormalizedSelector()Get the icon's normalized CSS selector.StringgetQualifiedUrl(String resUrl)Get the qualified icon url.StringgetQualifiedUrl(org.apache.commons.jelly.JellyContext context)Get the qualified icon url.StringgetStyle()Get the icon style.StringgetUrl()Get the icon url.booleanisSvgSprite()Is the Icon an SVG?static StringtoNormalizedCSSSelector(String classNames)Generate a normalized CSS selector from the space separated list of icon class names.static StringtoNormalizedIconName(String string)Normalize the supplied string to an Icon name e.g.static StringtoNormalizedIconNameClass(String string)Normalize the supplied string to an Icon name class e.g.static StringtoNormalizedIconSizeClass(String string)Normalize the supplied string to an Icon size class e.g.static StringtoNormalizedIconUrl(String url)Normalize the supplied url.
-
-
-
Field Detail
-
ICON_SMALL_STYLE
public static final String ICON_SMALL_STYLE
- See Also:
- Constant Field Values
-
ICON_MEDIUM_STYLE
public static final String ICON_MEDIUM_STYLE
- See Also:
- Constant Field Values
-
ICON_LARGE_STYLE
public static final String ICON_LARGE_STYLE
- See Also:
- Constant Field Values
-
ICON_XLARGE_STYLE
public static final String ICON_XLARGE_STYLE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Icon
public Icon(String classSpec, String style)
Creates acoreicon.- Parameters:
classSpec- The icon class names. Expected to start with `icon-`.style- The icon style.
-
Icon
public Icon(String classSpec, String url, String style)
Creates acoreicon.- Parameters:
classSpec- The icon class names. Expected to start with `icon-`.url- The icon image url.style- The icon style.
-
Icon
public Icon(String classSpec, String url, String style, IconType iconType)
Icon instance.- Parameters:
classSpec- The icon class specification. Expected to start with `icon-`.url- The icon image url.style- The icon style.iconType- The icon type.
-
Icon
public Icon(String classSpec, String url, String style, IconFormat iconFormat)
Creates an icon.- Parameters:
classSpec- The icon class names. Expected to start with `icon-`.url- The icon image url.style- The icon style.iconFormat- theIconFormat.- Since:
- 2.283
-
Icon
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public Icon(String classSpec, String url, String style, IconType iconType, IconFormat iconFormat)
-
-
Method Detail
-
getClassSpec
public String getClassSpec()
Get the class specification for this Icon.- Returns:
- The class specification for this Icon.
-
isSvgSprite
public boolean isSvgSprite()
Is the Icon an SVG?- Since:
- 2.283
-
getNormalizedSelector
public String getNormalizedSelector()
Get the icon's normalized CSS selector.- Returns:
- The icon normalized CSS selector.
- See Also:
toNormalizedCSSSelector(String)
-
getUrl
public String getUrl()
Get the icon url.- Returns:
- The icon url.
-
getQualifiedUrl
public String getQualifiedUrl(org.apache.commons.jelly.JellyContext context)
Get the qualified icon url.
Qualifying the URL involves prefixing it depending on whether the icon is a core or plugin icon.- Parameters:
context- The JellyContext.- Returns:
- The qualified icon url.
-
getQualifiedUrl
public String getQualifiedUrl(String resUrl)
Get the qualified icon url.
Qualifying the URL involves prefixing it depending on whether the icon is a core or plugin icon.- Parameters:
resUrl- The url of resources.- Returns:
- The qualified icon url.
-
getStyle
public String getStyle()
Get the icon style.- Returns:
- The icon style.
-
toNormalizedIconNameClass
public static String toNormalizedIconNameClass(String string)
Normalize the supplied string to an Icon name class e.g. "blue_anime" to "icon-blue-anime".- Parameters:
string- The string to be normalized.- Returns:
- The normalized icon name class.
-
toNormalizedIconName
public static String toNormalizedIconName(String string)
Normalize the supplied string to an Icon name e.g. "blue_anime" to "blue-anime".- Parameters:
string- The string to be normalized.- Returns:
- The normalized icon name.
-
toNormalizedIconSizeClass
public static String toNormalizedIconSizeClass(String string)
Normalize the supplied string to an Icon size class e.g. "16x16" to "icon-sm".- Parameters:
string- The string to be normalized.- Returns:
- The normalized icon size class, or the unmodified
stringarg if it was an unrecognised icon size.
-
toNormalizedCSSSelector
public static String toNormalizedCSSSelector(String classNames)
Generate a normalized CSS selector from the space separated list of icon class names.
The normalized CSS selector is the list of class names, alphabetically sorted and dot separated. This means that "icon-help icon-xlg" and "icon-xlg icon-help" have the same normalized selector ".icon-help.icon-xlg". Spaces are not relevant etc.- Parameters:
classNames- The space separated list of icon class names.- Returns:
- The normalized CSS selector.
-
-