Verified Owner
Top Description Fields Constructors Methods
org.jabref.gui.preview

public Class PreviewViewer

extends ScrollPane
implements InvalidationListener
Class Inheritance
All Implemented Interfaces
javafx.beans.InvalidationListener
Imports
java.io.IOException, java.net.MalformedURLException, java.util.List, .Objects, .Optional, javafx.application.Platform, javafx.beans.InvalidationListener, .Observable, javafx.print.PrinterJob, javafx.scene.control.ScrollPane, javafx.scene.input.ClipboardContent, org.jabref.gui.DialogService, .StateManager, .WorkspacePreferences, org.jabref.gui.clipboard.ClipBoardManager, org.jabref.gui.desktop.os.NativeDesktop, org.jabref.gui.exporter.ExportToClipboardAction, org.jabref.gui.importer.BookCoverFetcher, org.jabref.gui.preferences.GuiPreferences, org.jabref.gui.search.Highlighter, org.jabref.gui.util.UiTaskExecutor, org.jabref.htmltonode.HtmlRenderOptions, org.jabref.htmltonode.rich.RichHtmlView, org.jabref.logic.l10n.Localization, org.jabref.logic.layout.format.Number, org.jabref.logic.preview.PreviewLayout, org.jabref.logic.util.BackgroundTask, .OptionalObjectProperty, .TaskExecutor, org.jabref.model.database.BibDatabaseContext, org.jabref.model.entry.BibEntry, org.jabref.model.search.query.SearchQuery, com.airhacks.afterburner.injection.Injector, org.jspecify.annotations.Nullable, org.slf4j.Logger, .LoggerFactory

Displays an BibEntry using the given layout format.

Rendering is done with the html-to-node library (plain JavaFX nodes, no javafx.web).

Field Summary

Modifier and TypeField and Description
private final org.jabref.logic.util.OptionalObjectProperty<SearchQuery>
private final BookCoverFetcher
private final ClipBoardManager
private static final String
private @Nullable BibDatabaseContext
private final DialogService
private @Nullable BibEntry
private double
private PreviewLayout
private String
private static final Logger
private final GuiPreferences
private final RichHtmlView
private final TaskExecutor
private long
private boolean
private final WorkspacePreferences

Constructor Summary

AccessConstructor and Description
public
PreviewViewer(DialogService dialogService, GuiPreferences preferences, TaskExecutor taskExecutor)

public
PreviewViewer(DialogService dialogService, GuiPreferences preferences, TaskExecutor taskExecutor, org.jabref.logic.util.OptionalObjectProperty<SearchQuery> activeSearchQueryProperty)

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
public void
private void
downloadCoverAndRefresh(BibEntry entry, String previewText, long currentUpdateSequence)

public void
private String
formatError(BibEntry entry, Throwable exception)

private Optional<String>
private Optional<String>
private String
public String
private void
public void
invalidated(Observable observable)

Implements javafx.beans.InvalidationListener.invalidated.

This method needs to be provided by an implementation of InvalidationListener.

public boolean
isPressOnSelection(double screenX, double screenY)

Returns: whether the given screen position lies on the current text selection (only then a drag gesture should drag the content instead of extending the selection)

private void
public void
private double
resolveBaseFontSize()

Returns: the base font size in CSS pixels (JavaFX user units), matching whatever org.jabref.gui.theme.ThemeManager applies to the rest of the UI via the scene root's "-fx-font-size".

public void
public void
public void
private void
private void
private void
private void
Inherited from javafx.scene.control.ScrollPane:
contentPropertycreateDefaultSkinfitToHeightPropertyfitToWidthPropertygetClassCssMetaDatagetContentgetControlCssMetaDatagetHbarPolicygetHmaxgetHmingetHvaluegetInitialFocusTraversablegetMinViewportHeightgetMinViewportWidthgetPrefViewportHeightgetPrefViewportWidthgetVbarPolicygetViewportBoundsgetVmaxgetVmingetVvaluehbarPolicyPropertyhmaxPropertyhminPropertyhvaluePropertyisFitToHeightisFitToWidthisPannableminViewportHeightPropertyminViewportWidthPropertypannablePropertyprefViewportHeightPropertyprefViewportWidthPropertyqueryAccessibleAttributesetContentsetFitToHeightsetFitToWidthsetHbarPolicysetHmaxsetHminsetHvaluesetMinViewportHeightsetMinViewportWidthsetPannablesetPrefViewportHeightsetPrefViewportWidthsetVbarPolicysetViewportBoundssetVmaxsetVminsetVvaluevbarPolicyPropertyviewportBoundsPropertyvmaxPropertyvminPropertyvvalueProperty

Field Detail

activeSearchQueryPropertyback to summary
private final org.jabref.logic.util.OptionalObjectProperty<SearchQuery> activeSearchQueryProperty
bookCoverFetcherback to summary
private final BookCoverFetcher bookCoverFetcher
clipBoardManagerback to summary
private final ClipBoardManager clipBoardManager
COVER_IMAGE_FORMAT_HTMLback to summary
private static final String COVER_IMAGE_FORMAT_HTML
databaseContextback to summary
private @Nullable BibDatabaseContext databaseContext
dialogServiceback to summary
private final DialogService dialogService
entryback to summary
private @Nullable BibEntry entry
latestContentHeightback to summary
private double latestContentHeight
layoutback to summary
private PreviewLayout layout
layoutTextback to summary
private String layoutText
LOGGERback to summary
private static final Logger LOGGER
preferencesback to summary
private final GuiPreferences preferences
previewViewback to summary
private final RichHtmlView previewView
taskExecutorback to summary
private final TaskExecutor taskExecutor
updateSequenceback to summary
private long updateSequence
viewportResetScheduledback to summary
private boolean viewportResetScheduled
workspacePreferencesback to summary
private final WorkspacePreferences workspacePreferences

Constructor Detail

PreviewViewerback to summary
public PreviewViewer(DialogService dialogService, GuiPreferences preferences, TaskExecutor taskExecutor)
PreviewViewerback to summary
public PreviewViewer(DialogService dialogService, GuiPreferences preferences, TaskExecutor taskExecutor, org.jabref.logic.util.OptionalObjectProperty<SearchQuery> activeSearchQueryProperty)

Method Detail

clearEntryback to summary
public void clearEntry()
copyPreviewHtmlToClipBoardback to summary
public void copyPreviewHtmlToClipBoard()
copyPreviewPlainTextToClipBoardback to summary
public void copyPreviewPlainTextToClipBoard()
copySelectionToClipBoardback to summary
public void copySelectionToClipBoard()
downloadCoverAndRefreshback to summary
private void downloadCoverAndRefresh(BibEntry entry, String previewText, long currentUpdateSequence)
exportToClipBoardback to summary
public void exportToClipBoard(StateManager stateManager)
formatErrorback to summary
private String formatError(BibEntry entry, Throwable exception)
getBaseURLback to summary
private Optional<String> getBaseURL()
getCoverImageURLback to summary
private Optional<String> getCoverImageURL()
getHighlightedLayoutTextback to summary
private String getHighlightedLayoutText()
getSelectionHtmlContentback to summary
public String getSelectionHtmlContent()
highlightLayoutTextback to summary
private void highlightLayoutText()
invalidatedback to summary
public void invalidated(Observable observable)

Implements javafx.beans.InvalidationListener.invalidated.

Doc from javafx.beans.InvalidationListener.invalidated.

This method needs to be provided by an implementation of InvalidationListener. It is called if an Observable becomes invalid.

In general, it is considered bad practice to modify the observed value in this method.

Annotations
@Override
isPressOnSelectionback to summary
public boolean isPressOnSelection(double screenX, double screenY)
Returns:boolean

whether the given screen position lies on the current text selection (only then a drag gesture should drag the content instead of extending the selection)

renderLayoutTextWithCurrentOptionsback to summary
private void renderLayoutTextWithCurrentOptions()
resizeForTooltipContentback to summary
public void resizeForTooltipContent()
resolveBaseFontSizeback to summary
private double resolveBaseFontSize()
Returns:double

the base font size in CSS pixels (JavaFX user units), matching whatever org.jabref.gui.theme.ThemeManager applies to the rest of the UI via the scene root's "-fx-font-size". ThemeManager expresses the size in CSS pt (-fx-font-size: Xpt), but Font.font(size) in the JavaFX Font API takes CSS pixels (user units), not typographic points — so the stored pt value must be converted (1pt = 96/72 px).

setDatabaseContextback to summary
public void setDatabaseContext(BibDatabaseContext newDatabaseContext)
setEntryback to summary
public void setEntry(@Nullable BibEntry newEntry)
setLayoutback to summary
public void setLayout(PreviewLayout newLayout)
setPreviewTextback to summary
private void setPreviewText(String text)
updateback to summary
private void update()
updateBaseFontSizeback to summary
private void updateBaseFontSize()
updateOnFxThreadback to summary
private void updateOnFxThread()