Package org.ametys.plugins.core.ui.glyph
Class CssFontHelper
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.core.ui.glyph.CssFontHelper
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
public class CssFontHelper extends AbstractLogEnabled implements Component, Serviceable
Helper for parsing of CSS file and extract glyphs
-
-
Field Summary
Fields Modifier and Type Field Description private static Pattern
__CSS_CLASS_NAME
Pattern for CSS classprivate Map<String,Set<String>>
_glyphs
private Map<String,Long>
_lastUpdates
private SourceResolver
_resolver
static String
ROLE
The Avalon role
-
Constructor Summary
Constructors Constructor Description CssFontHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private CSSStyleSheet
_getCssStyleSheet(Source source)
private Set<String>
_getFontFamily(CSSStyleSheet styleSheet)
private boolean
_matchFontFamily(Set<String> fontFamilies, CSSStyleDeclaration style)
Set<String>
getFontClassNames(CSSStyleSheet styleSheet)
Get CSS class name to use for all icons.Set<String>
getGlyphClassNames(String cssURI, String prefix)
Get the CSS class names for glyphesboolean
hasFontFaceRule(String cssURI)
Determines if the CSS file has a 'font-face' rulevoid
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__CSS_CLASS_NAME
private static final Pattern __CSS_CLASS_NAME
Pattern for CSS class
-
_resolver
private SourceResolver _resolver
-
_lastUpdates
private Map<String,Long> _lastUpdates
-
-
Constructor Detail
-
CssFontHelper
public CssFontHelper()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getGlyphClassNames
public Set<String> getGlyphClassNames(String cssURI, String prefix)
Get the CSS class names for glyphes- Parameters:
cssURI
- The URI of CSS fileprefix
- The glyph prefix. Can be null.- Returns:
- The CSS class names for glyphes
-
hasFontFaceRule
public boolean hasFontFaceRule(String cssURI)
Determines if the CSS file has a 'font-face' rule- Parameters:
cssURI
- The URI of CSS file- Returns:
- cssURI The URI of CSS file
-
getFontClassNames
public Set<String> getFontClassNames(CSSStyleSheet styleSheet)
Get CSS class name to use for all icons. Can be empty if the icons contains the font-family to use.- Parameters:
styleSheet
- The CSS stylesheet to parse- Returns:
- The name of the common CSS class name for icons (ex: 'fa' for FontAwesome). Can be empty if the icons contains the font-family to use.
-
_matchFontFamily
private boolean _matchFontFamily(Set<String> fontFamilies, CSSStyleDeclaration style)
-
_getCssStyleSheet
private CSSStyleSheet _getCssStyleSheet(Source source) throws MalformedURLException, IOException
- Throws:
MalformedURLException
IOException
-
_getFontFamily
private Set<String> _getFontFamily(CSSStyleSheet styleSheet)
-
-