Verified Owner
Top Fields Constructors Methods
org.jabref.gui.theme

pack-priv final Class StyleSheetFile

extends StyleSheet
Class Inheritance
Imports
java.io.IOException, .InputStream, java.net.URL, .URLConnection, java.nio.file.Files, .Path, java.util.Base64, .Optional, java.util.concurrent.atomic.AtomicReference, org.jabref.logic.util.URLUtil, com.google.common.base.Strings, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private final AtomicReference<String>
private static final Logger
pack-priv static final int
MAX_IN_MEMORY_CSS_LENGTH

A size limit above which Theme will not attempt to keep a data-embedded URL in memory for the CSS.

private final Path
private final URL
Inherited from org.jabref.gui.theme.StyleSheet:
DATA_URL_PREFIX

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static Optional<String>
public URL
pack-priv String

Returns:

the stylesheet location if the stylesheet is present and available. The location will be a local URL. Typically, it will be a 'data:' URL where the CSS is embedded. However, for large themes it can be 'file:'.
getSceneStylesheetLocation
()

Overrides org.jabref.gui.theme.StyleSheet.getSceneStylesheetLocation.

The location to put into Scene#getStylesheets.

private Optional<URL>
pack-priv Path
pack-priv void
public String
toString()

Overrides org.jabref.gui.theme.StyleSheet.toString.

Returns a string representation of the object.

Inherited from org.jabref.gui.theme.StyleSheet:
createequalsgetNamehashCode

Field Detail

dataUrlback to summary
private final AtomicReference<String> dataUrl
LOGGERback to summary
private static final Logger LOGGER

Hides org.jabref.gui.theme.StyleSheet.LOGGER.

MAX_IN_MEMORY_CSS_LENGTHback to summary
pack-priv static final int MAX_IN_MEMORY_CSS_LENGTH

A size limit above which Theme will not attempt to keep a data-embedded URL in memory for the CSS.

Embedding the CSS in a data: URL has two functional benefits: the theme survives removal of the CSS file while the application is running, and — since the URL changes with the content — JavaFX's stylesheet cache cannot serve stale content after a live reload.

If the CSS is over this limit, the plain file URL is used instead: nothing breaks as long as the file exists. Realistic custom themes fit comfortably within 48k (the dark custom theme in the JabRef documentation is 2k; jabref-theme.css is 33k). Note that Base-64 encoding increases the memory footprint of the URL by a third.

pathback to summary
private final Path path
urlback to summary
private final URL url

Constructor Detail

StyleSheetFileback to summary
pack-priv StyleSheetFile(String name, URL url)

Method Detail

getDataUrlback to summary
pack-priv static Optional<String> getDataUrl(URL url)
getSceneStylesheetback to summary
public URL getSceneStylesheet()

Implements abstract org.jabref.gui.theme.StyleSheet.getSceneStylesheet.

Annotations
@Override
getSceneStylesheetLocationback to summary
pack-priv String getSceneStylesheetLocation()

Overrides org.jabref.gui.theme.StyleSheet.getSceneStylesheetLocation.

Doc from org.jabref.gui.theme.StyleSheet.getSceneStylesheetLocation.

The location to put into Scene#getStylesheets. Typically a data: URL with the CSS embedded — that way the theme survives removal of the CSS file while the application is running, and JavaFX's stylesheet cache cannot serve stale content after a live reload (the URL changes with the content). Large stylesheets fall back to the plain URL.

Returns:String

the stylesheet location if the stylesheet is present and available. The location will be a local URL. Typically, it will be a 'data:' URL where the CSS is embedded. However, for large themes it can be 'file:'.

Annotations
@Override
getStylesheetURLback to summary
private Optional<URL> getStylesheetURL()
getWatchPathback to summary
pack-priv Path getWatchPath()

Overrides org.jabref.gui.theme.StyleSheet.getWatchPath.

Annotations
@Override
reloadback to summary
pack-priv void reload()

Implements abstract org.jabref.gui.theme.StyleSheet.reload.

Annotations
@Override
toStringback to summary
public String toString()

Overrides org.jabref.gui.theme.StyleSheet.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override