Class FontConfig
java.lang.Object
com.levigo.jadice.web.client.util.fonts.FontConfig
Used to configure the client that shall use standard 14 fonts for text annotation rendering.
The general idea is to have the standard 14 fonts Arimo, Tinos and Cousine in all 4 variants (normal, bold, italic, bold+italic) downloadable on the server.
Upon loading the application in the browser, the client downloads those fonts from the server and uses them for text + stamp annotation rendering. This class is a Singleton implementation. Access to the single instance of this class is only permitted using the #get() method.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
A standardWebFontLoader
implementation that has the main purpose to repaint the PageView when the loading operation has finished.static enum
These FontProperties help to improve the readability of the code below when there has to be defined whether a font shall be bold, italic, both, or plain. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.levigo.jadice.web.client.util.internal.fonts.WebFontLoader.WebFontHandler
theWebFontLoader.WebFontHandler
needed to determine when certain fonts are loaded and when all loading operations are done (successful or not)static final String
The URL where thecom.levigo.jadice.web.server.FontDownloadServlet
is registered.protected final com.levigo.jadice.web.client.util.internal.fonts.WebFontLoader.WebFonts
set of fontsToLoad that will be loaded into the clientprotected static FontConfig
The single instance of this class.static final String
The concatenation ofServerConnection.getServerAddress()
and this string leads to the URL where the webfontloader.js (formerly: webfonts.js) script is hosted. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of theFontConfig
.FontConfig
(boolean isLoadLevibats) Creates a new instance of theFontConfig
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addFontFamilyToLoad
(com.levigo.jadice.web.client.util.internal.fonts.DefaultFont font, String pathToFontManager) Loads a singleDefaultFont
in Plain, Italic, Bold and Bold-Italicprotected void
addFontToLoad
(String familyName, FontConfig.FontProperty fontProperty, String pathToFontManager) Adds the font defined in the given parameter to the list of fonts to be loaded by adding a stylesheet to the documentprotected void
addStandardFontsToLoad
(String pathToFontManager, boolean isLoadLevibats) Add the fonts for theWebFontLoader
to load.protected static String
createFontFacePath
(String pathToFontManager, String familyName, FontConfig.FontProperty fontProperty) Helper to improve readability in theaddFontToLoad(String, FontProperty, String)
method.static FontConfig
get()
Returns the only existing instance of this class.static FontConfig
get
(boolean isLoadLevibats) protected void
load the fontsToLoad that have been added tofontsToLoad
protected void
setFontHandler
(com.levigo.jadice.web.client.util.internal.fonts.WebFontLoader.WebFontHandler fontHandler) Set theWebFontLoader.WebFontHandler
to be used.
-
Field Details
-
fontHandler
protected com.levigo.jadice.web.client.util.internal.fonts.WebFontLoader.WebFontHandler fontHandlertheWebFontLoader.WebFontHandler
needed to determine when certain fonts are loaded and when all loading operations are done (successful or not) -
fontsToLoad
protected final com.levigo.jadice.web.client.util.internal.fonts.WebFontLoader.WebFonts fontsToLoadset of fontsToLoad that will be loaded into the client -
WEBFONTS_JS_URL
The concatenation ofServerConnection.getServerAddress()
and this string leads to the URL where the webfontloader.js (formerly: webfonts.js) script is hosted.- See Also:
-
FONTMANAGER_URL
The URL where thecom.levigo.jadice.web.server.FontDownloadServlet
is registered.- See Also:
-
instance
The single instance of this class.
-
-
Constructor Details
-
FontConfig
public FontConfig()Creates a new instance of theFontConfig
. Since this is a singleton implementation this constructor is only to be called from theget()
-method . -
FontConfig
public FontConfig(boolean isLoadLevibats) Creates a new instance of theFontConfig
. Since this is a singleton implementation this constructor is only to be called from theget()
-method .
-
-
Method Details
-
get
Returns the only existing instance of this class. If that instance does not yet exist it is created while calling this method. If the instance already exists that instance is returned.- Returns:
- the sole instance of this class
-
get
- Parameters:
isLoadLevibats
- do we want to load the Levibats-Regular font at the client start?
-
setFontHandler
protected void setFontHandler(com.levigo.jadice.web.client.util.internal.fonts.WebFontLoader.WebFontHandler fontHandler) Set theWebFontLoader.WebFontHandler
to be used.- Parameters:
fontHandler
- theWebFontLoader.WebFontHandler
to be used. This parameter must not benull
.
-
addFontToLoad
protected void addFontToLoad(String familyName, FontConfig.FontProperty fontProperty, String pathToFontManager) Adds the font defined in the given parameter to the list of fonts to be loaded by adding a stylesheet to the document- Parameters:
familyName
- the family name of the font to be loadedfontProperty
- defines whether the font shall be bold, italic, both or plain.pathToFontManager
- the path to the fontmanager to retrieve the font from
-
createFontFacePath
protected static String createFontFacePath(String pathToFontManager, String familyName, FontConfig.FontProperty fontProperty) Helper to improve readability in theaddFontToLoad(String, FontProperty, String)
method. This method creates a path to request the given familyName with the given style and weight from a fontManager.- Parameters:
pathToFontManager
- the path to the fontManager to retrieve the font fromfamilyName
- the family name of the font to be retrieved using the created pathfontProperty
- theFontConfig.FontProperty
to define whether the font shall be italic, plain, both, or plain- Returns:
- a path at which to request a font with the given family name in the given style and weight based on the given fontManager path.
-
addStandardFontsToLoad
Add the fonts for theWebFontLoader
to load. The standard fonts are Arimo, Cousine and Tinos in all 4 permutations(regular, bold, italic, bold + italic).- Parameters:
pathToFontManager
- path to thecom.levigo.jadice.web.server.FontDownloadServlet
as defined in the web.xml
-
addFontFamilyToLoad
protected void addFontFamilyToLoad(com.levigo.jadice.web.client.util.internal.fonts.DefaultFont font, String pathToFontManager) Loads a singleDefaultFont
in Plain, Italic, Bold and Bold-Italic- Parameters:
font
- the Font that will be loaded in Plain, Italic, Bold and Bold-ItalicpathToFontManager
- path to thecom.levigo.jadice.web.server.FontDownloadServlet
as defined in the web.xml
-
loadFonts
load the fontsToLoad that have been added tofontsToLoad
- Parameters:
pathToJs
- The path to the webfonts.js file
-