com.levigo.jadice.swing.thumbnailview
Class ThumbnailView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.levigo.jadice.swing.ViewComponent
                  extended by com.levigo.jadice.swing.thumbnailview.ThumbnailView
All Implemented Interfaces:
PageSelection, MenuContributor, ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class ThumbnailView
extends ViewComponent
implements Scrollable, Accessible, PageSelection

UI-Properties used by this component

UI-Properties
Property Type Description Default value
ThumbnailView.background Color The color of the background Same as 'Panel.background'
ThumbnailView.foreground Color The color of foreground elements like labels etc. Same as 'List.foreground'
ThumbnailView.cellRenderer ThumbnailCellRenderer The cell renderer used to render the thumbnail images and their decoration DefaultThumbnailCellRenderer
ThumbnailView.pageBorder Border The border used to decorate a page thumbnail A compound border consisting of a drop shadow and a black line
ThumbnailView.visibleBoundsBorder Border The border used to designate the area visible in an associated PageView Red frame with semi-transparent inner frame
ThumbnailView.font Font The font used to render labels etc. Same as 'List.font'
ThumbnailView.selectionBackground Color The background color for selected pages Same as 'List.selectionBackground', but with alpha=120
ThumbnailView.selectionForeground Color The color of foreground elements like labels etc. for selected pages Same as 'List.foreground'
ThumbnailView.focusSelectedCellHighlightBorder Border The border used to indicate a focused and selected cell Same as 'List.focusSelectedCellHighlightBorder'
ThumbnailView.focusCellHighlightBorder Border The border used to indicate a focused cell Same as 'List.focusCellHighlightBorder'
ThumbnailView.useDropLocationAnimation boolean Whether to indicate the drop location by showing an animation of the pages "making room" for. the pages to be dropped. true
ThumbnailView.dropLocationShift integer The number of pixels to shift pages aside when using the drop location animation. 15
ThumbnailView.dropLocationRange integer The number of pages left and right of the drop location taking part in the animation. 3
ThumbnailView.useDropLocationIndicator boolean Whether to indicate the drop location by drawing a location indicator bar. where the pages would be dropped. false
ThumbnailView.dropLocationIndicatorWidth integer The width of the drop location indicator (pixels). 5
ThumbnailView.dropLocationIndicatorColorValid integer The color used to paint the drop location at a valid drop position. Color(100, 100, 100, 100)
ThumbnailView.dropLocationIndicatorColorInvalid integer The color used to paint the drop location at an invalid drop position. Color.DARK_GRAY
ThumbnailView.DnD.Autoscroll.gestureMotionThreshold integer The distance in pixels the mouse pointer must travel in order for a drag-and-drop gesture to be recognized. 10
ThumbnailView.DnD.Autoscroll.initialDelay integer The initial delay in ms before auto-scrolling commences. 50
ThumbnailView.DnD.Autoscroll.interval integer The interval in ms at which auto-scrolling progresses. 50
ThumbnailView.DnD.Autoscroll.cursorHysteresis integer The hysteresis in pixels for entering/exiting the auto-scrolling "hot-zone" with the mouse cursor. 10
ThumbnailView.DnD.Autoscroll.disableVisualRepresentation boolean Set to true to disable the visual representation of the dragged pages. false
ThumbnailView.focusInputMap InputMap The input map See section 'Input Map'

The default Input Map used by this component

This component inherits most actions from JList. The following table contains only the additional actions.
Input map
Key Action Name
ESCAPE clearSelection
SPACE navigate
ENTER navigate
DELETE remove

The Action Names recognized by this component

Action names
Action Name Description
addToSelection Add the currently focused page to the selection
clearSelection Clear the current selection
extendTo Select all pages between the lead and the anchor selection index
moveSelectionTo
scrollDown
scrollDownChangeLead
scrollDownExtendSelection
scrollUp
scrollUpChangeLead
scrollUpExtendSelection
selectAll
selectFirstRow
selectFirstRowChangeLead
selectFirstRowExtendSelection
selectLastRow
selectLastRowChangeLead
selectLastRowExtendSelection
selectNextColumn
selectNextColumnChangeLead
selectNextColumnExtendSelection
selectNextRow
selectNextRowChangeLead
selectNextRowExtendSelection
selectPreviousColumn
selectPreviousColumnChangeLead
selectPreviousColumnExtendSelection
selectPreviousRow
selectPreviousRowChangeLead
selectPreviousRowExtendSelection
toggleAndAnchor Toggle the selected state of the lead page and move the anchor to it
navigate Navigate to the selected page
remove Remove the selected pages from the document

See Also:
Serialized Form

Nested Class Summary
protected  class ThumbnailView.AccessibleThumbnailView
          FIXME: Why Swing sucks - episode 4132: AccessibleJComponent is a non-static inner class of JComponent and can therefore only be sub-classed by an inner class of a descendant of JComponent.
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static Dimension DEFAULT_THUMBNAIL_SIZE
          The default thumbnail is 90 pixels wide.
static int[] DEFAULT_THUMBNAIL_WIDTHS
          A row of default thumbnail widths as used by the resizing-commands.
static String UI_CLASS_ID
           
 
Fields inherited from class com.levigo.jadice.swing.ViewComponent
toolManager
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ThumbnailView()
          Constructs a new ThumbnailView.
 
Method Summary
 void addNotify()
           
 void cleanup()
          Releases references to the Document currently referenced by this ViewComponent, if any.
 void clearSelection()
           
 void contribute(ContributionContext context, MenuBuilder menuBuilder)
          There are no default contributions of the ThumbnailView.AccessibleThumbnailView to its context menu.
 void ensureIndexIsVisible(int index)
          Scrolls the ThumbnailView within an enclosing JViewport to make the specified cell completely visible.
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
          We override this method, because the default implementation erroneously compares the old and new value for equality instead of identity.
 AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this JList.
 Rectangle getCellBounds(int from, int to)
          Returns the bounding rectangle, in the ThumbnailView's coordinate system, for the range of cells specified by the two indices.
 Rectangle getCellBounds(Page page)
           
 ThumbnailCellRenderer getCellRenderer()
           
 UIDocument<Component> getDocument()
          Return the document to which the pages belong or null if the pages are not (currently) associated with a document or the association is unknown.
 int getNextMatch(String prefix, int startIndex, Position.Bias bias)
          Look for pages matching a certain prefix, starting from the given index, searching with the given bias.
 ExportHandler<List<Page>> getPageExportHandler()
           
 ImportHandler getPageImportHandler()
           
 PageView getPageView()
          Gets the embedded page view holding the document to be displayed en miniature.
 Dimension getPreferredScrollableViewportSize()
           
 int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
           
 boolean getScrollableTracksViewportHeight()
           
 boolean getScrollableTracksViewportWidth()
           
 int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
           
 List<Page> getSelectedPages()
          Returns the list of selected pages.
 Color getSelectionBackground()
          Returns the color used to draw the background of selected pages.
 Color getSelectionForeground()
          Returns the color used to draw the foreground of selected pages.
 ListSelectionModel getSelectionModel()
           
 ThumbnailProvider getThumbnailProvider()
           
 RenderControls getThumbnailRenderControls(Page page)
          Calculates the zoom factor for the render context to fit into the thumbnail image size.
 Dimension getThumbnailSize()
          Returns the thumbnailSize.
 String getToolTipText(MouseEvent e)
          Returns the tooltip text to be used for the given event.
 ThumbnailViewUI getUI()
          Returns the ThumbnailViewUI (!) used to render this component.
 String getUIClassID()
          Returns "ThumbnailViewUI", the UIDefaults key used to look up the name of the ThumbnailViewUI class that defines the look and feel for this component.
 boolean isApplyPageViewRenderSettings()
          Returns an indicator whether the sorter render pages according to the PageView render settings or not.
 boolean isEnableTransientPageRendering()
          Returns whether thumbnail rendering shall be triggered, even during transient renderings.
 boolean isMovePagesAllowed(List<Page> pagesToMove, int target)
          Checks whether it is allowed to move the pages in the supplied vector to the given target position.
 int locationToIndex(Point location)
          Returns the cell index closest to the given location in the view's coordinate system.
 void removeNotify()
           
 void repaint(Page p)
          Repaint all of the given page.
 void repaint(Page p, Rectangle2D boundsDU)
          Repaint all of the given page.
 void setApplyPageViewRenderSettings(boolean apply)
          Changes the sorter render behavior whether the pages rendered according to the PageView render settings or not.
 void setCellRenderer(ThumbnailCellRenderer cellRenderer)
           
 void setDocument(Document doc)
           
 void setEnableTransientPageRendering(boolean renderPagesDuringTransientRenderings)
          Returns whether thumbnail rendering shall be triggered, even during transient renderings.
 void setExportHandler(ExportHandler<List<Page>> pageExportHandler)
           
 void setImportHandler(ImportHandler pageImportHandler)
           
 void setPageView(PageView pageView)
          Sets the page view holding the document to be displayed en miniature.
 void setSelectedIndex(int index)
          Selects a single page.
 void setSelectionBackground(Color selectionBackground)
          Sets the color used to draw the background of selected pages.
 void setSelectionForeground(Color selectionForeground)
          Sets the color used to draw the foreground of selected pages.
 void setSelectionModel(ListSelectionModel selectionModel)
           
 void setThumbnailProvider(ThumbnailProvider thumbnailProvider)
           
 void setThumbnailSize(Dimension thumbnailSize)
          Sets the thumbnail image size.
 void setUI(ThumbnailViewUI ui)
          Sets the ThumbnailViewUI, the look and feel object that renders this component.
 void updateUI()
          Resets the UI property with the value from the current look and feel.
 
Methods inherited from class com.levigo.jadice.swing.ViewComponent
findViewport, getToolManager
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UI_CLASS_ID

public static final String UI_CLASS_ID
See Also:
Constant Field Values

DEFAULT_THUMBNAIL_WIDTHS

public static final int[] DEFAULT_THUMBNAIL_WIDTHS
A row of default thumbnail widths as used by the resizing-commands.


DEFAULT_THUMBNAIL_SIZE

public static final Dimension DEFAULT_THUMBNAIL_SIZE
The default thumbnail is 90 pixels wide. The height is calculated as width * sqrt(2) which corresponds to the aspect ratio of the EN ISO 216 paper formats.

Constructor Detail

ThumbnailView

public ThumbnailView()
Constructs a new ThumbnailView.

Method Detail

getPageExportHandler

public ExportHandler<List<Page>> getPageExportHandler()
Returns:
the pageExportHandler

setExportHandler

public void setExportHandler(ExportHandler<List<Page>> pageExportHandler)
Parameters:
pageExportHandler - the pageExportHandler to set

getPageImportHandler

public ImportHandler getPageImportHandler()
Returns:
the pageImportHandler

setImportHandler

public void setImportHandler(ImportHandler pageImportHandler)
Parameters:
pageImportHandler - the pageImportHandler to set

addNotify

public void addNotify()
Overrides:
addNotify in class JComponent
See Also:
Component.addNotify()

clearSelection

public void clearSelection()

ensureIndexIsVisible

public void ensureIndexIsVisible(int index)
Scrolls the ThumbnailView within an enclosing JViewport to make the specified cell completely visible. This calls scrollRectToVisible with the bounds of the specified cell. For this method to work, the ThumbnailView must be within a JViewport.

If the given index is outside the list's range of cells, this method results in nothing.

Parameters:
index - the index of the cell to make visible
See Also:
JComponent.scrollRectToVisible(java.awt.Rectangle), JComponent.getVisibleRect()

getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JList. For JList, the AccessibleContext takes the form of an AccessibleJList.

A new AccessibleJList instance is created if necessary.

Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JComponent
Returns:
an AccessibleJList that serves as the AccessibleContext of this JList

getCellBounds

public Rectangle getCellBounds(int from,
                               int to)
Returns the bounding rectangle, in the ThumbnailView's coordinate system, for the range of cells specified by the two indices. These indices can be supplied in any order.

If the smaller index is outside the list's range of cells, this method returns null. If the smaller index is valid, but the larger index is outside the list's range, the bounds of just the first index is returned. Otherwise, the bounds of the valid range is returned.

This is a cover method that delegates to the method of the same name in the list's ListUI. It returns null if the list has no ListUI.

Parameters:
from - the first index in the range
to - the second index in the range
Returns:
the bounding rectangle for the range of cells, or null

getCellBounds

public Rectangle getCellBounds(Page page)

getCellRenderer

public ThumbnailCellRenderer getCellRenderer()
Returns:
the cellRenderer

getDocument

public UIDocument<Component> getDocument()
Description copied from interface: PageSelection
Return the document to which the pages belong or null if the pages are not (currently) associated with a document or the association is unknown.

Specified by:
getDocument in interface PageSelection
Specified by:
getDocument in class ViewComponent
Returns:
the document

getNextMatch

public int getNextMatch(String prefix,
                        int startIndex,
                        Position.Bias bias)
Look for pages matching a certain prefix, starting from the given index, searching with the given bias. This method currently considers only the page index represented as a decimal number when looking for matches.

Parameters:
prefix -
startIndex -
bias -
Returns:
a matching index or -1 if not match was found
See Also:
JList.getNextMatch(String, int, Position.Bias)

getPreferredScrollableViewportSize

public Dimension getPreferredScrollableViewportSize()
Specified by:
getPreferredScrollableViewportSize in interface Scrollable

getScrollableBlockIncrement

public int getScrollableBlockIncrement(Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Specified by:
getScrollableBlockIncrement in interface Scrollable

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()
Specified by:
getScrollableTracksViewportHeight in interface Scrollable

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Specified by:
getScrollableTracksViewportWidth in interface Scrollable

getScrollableUnitIncrement

public int getScrollableUnitIncrement(Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Specified by:
getScrollableUnitIncrement in interface Scrollable

getSelectedPages

public List<Page> getSelectedPages()
Returns the list of selected pages. The list will contain a snapshot of the selected pages at the point when getSelectedPages() has been called. This list will not be updated on subsequent selection changes.

Specified by:
getSelectedPages in interface PageSelection
Returns:
the selected values, or an empty array if nothing is selected

getSelectionModel

public ListSelectionModel getSelectionModel()
Returns:
the selectionModel

getThumbnailProvider

public ThumbnailProvider getThumbnailProvider()

getThumbnailSize

public Dimension getThumbnailSize()
Returns the thumbnailSize.

Returns:
Dimension

getToolTipText

public String getToolTipText(MouseEvent e)
Returns the tooltip text to be used for the given event. This overrides JComponent's getToolTipText to first check the cell renderer component for the cell over which the event occurred, returning its tooltip text, if any. This implementation allows you to specify tooltip text on the cell level, by using setToolTipText on your cell renderer component.

Note: For JList to properly display the tooltips of its renderers in this manner, JList must be a registered component with the ToolTipManager. This registration is done automatically in the constructor. However, if at a later point JList is unregistered, by way of a call to setToolTipText(null), tips from the renderers will no longer display.

Overrides:
getToolTipText in class JComponent
Parameters:
e - the MouseEvent to fetch the tooltip text for
See Also:
JComponent.setToolTipText(java.lang.String), JComponent.getToolTipText()

getUI

public ThumbnailViewUI getUI()
Returns the ThumbnailViewUI (!) used to render this component.

Returns:
the ListUI object that renders this component

getUIClassID

public String getUIClassID()
Returns "ThumbnailViewUI", the UIDefaults key used to look up the name of the ThumbnailViewUI class that defines the look and feel for this component.

Overrides:
getUIClassID in class JComponent
Returns:
the string "ListUI"
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

getPageView

public PageView getPageView()
Gets the embedded page view holding the document to be displayed en miniature.

Returns:
PageView

isApplyPageViewRenderSettings

public boolean isApplyPageViewRenderSettings()
Returns an indicator whether the sorter render pages according to the PageView render settings or not.

Returns:
whether the viewer render settings are honored for page rendering

isMovePagesAllowed

public boolean isMovePagesAllowed(List<Page> pagesToMove,
                                  int target)
Checks whether it is allowed to move the pages in the supplied vector to the given target position.

The default implementation of this method always returns true. Integrators might overwrite this method to perform additional checks before actually moving the given pages.

In contrast to the global isSortingEnabled() setting, this method refers to a given collection of selected pages and is only applied if sorting is already enabled.

Parameters:
pagesToMove - the vector containing pages to be moved to a new location
target - the target index
Returns:
true if the move request is granted for the given page vector; false otherwise

locationToIndex

public int locationToIndex(Point location)
Returns the cell index closest to the given location in the view's coordinate system. To determine if the cell actually contains the specified location, compare the point against the cell's bounds, as provided by getCellBounds. This method returns -1 if the model is empty

This is a cover method that delegates to the method of the same name in the view's ThumbnailViewUI. It returns -1 if the list has no ThumbnailViewUI.

Parameters:
location - the coordinates of the point
Returns:
the cell index closest to the given location, or -1

removeNotify

public void removeNotify()
Overrides:
removeNotify in class JComponent
See Also:
Component.removeNotify()

repaint

public void repaint(Page p)
Repaint all of the given page.

Specified by:
repaint in class ViewComponent
Parameters:
p - the page to repaint

repaint

public void repaint(Page p,
                    Rectangle2D boundsDU)
Repaint all of the given page.

Specified by:
repaint in class ViewComponent
Parameters:
p - the page to repaint
boundsDU - the bounds within the page to repaint.

setApplyPageViewRenderSettings

public void setApplyPageViewRenderSettings(boolean apply)
Changes the sorter render behavior whether the pages rendered according to the PageView render settings or not.

Parameters:
apply - whether the PageView render settings are honored for page rendering or not

setCellRenderer

public void setCellRenderer(ThumbnailCellRenderer cellRenderer)
Parameters:
cellRenderer - the cellRenderer to set

setDocument

public void setDocument(Document doc)

cleanup

public void cleanup()
Description copied from class: ViewComponent
Releases references to the Document currently referenced by this ViewComponent, if any.

Specified by:
cleanup in class ViewComponent

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)
We override this method, because the default implementation erroneously compares the old and new value for equality instead of identity.

Overrides:
firePropertyChange in class Component
See Also:
Component.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)

setSelectedIndex

public void setSelectedIndex(int index)
Selects a single page. Does nothing if the given index is greater than or equal to the model size. This is a convenience method that uses setSelectionInterval on the selection model. Refer to the documentation for the selection model class being used for details on how values less than 0 are handled.

Parameters:
index - the index of the cell to select
See Also:
ListSelectionModel.setSelectionInterval(int, int)

setSelectionModel

public void setSelectionModel(ListSelectionModel selectionModel)
Parameters:
selectionModel - the selectionModel to set

setThumbnailProvider

public void setThumbnailProvider(ThumbnailProvider thumbnailProvider)
Parameters:
thumbnailProvider - the thumbnailProvider to set

setThumbnailSize

public void setThumbnailSize(Dimension thumbnailSize)
Sets the thumbnail image size.

Parameters:
thumbnailSize - The thumbnailSize to set

setUI

public void setUI(ThumbnailViewUI ui)
Sets the ThumbnailViewUI, the look and feel object that renders this component.

Parameters:
ui - the ThumbnailViewUI object
See Also:
UIDefaults.getUI(javax.swing.JComponent)

setPageView

public void setPageView(PageView pageView)
Sets the page view holding the document to be displayed en miniature.

Parameters:
pageView - the viewer holding the document

updateUI

public void updateUI()
Resets the UI property with the value from the current look and feel.

Overrides:
updateUI in class JComponent
See Also:
UIManager.getUI(javax.swing.JComponent)

getThumbnailRenderControls

public RenderControls getThumbnailRenderControls(Page page)
Calculates the zoom factor for the render context to fit into the thumbnail image size.

Parameters:
page - the page whose scaled size will be used to fit into the thumbnail image size
Returns:
the render context with a calculated the zoom to fit value

getSelectionBackground

public Color getSelectionBackground()
Returns the color used to draw the background of selected pages. DefaultThumbnailCellRenderer uses this color to draw the background of selected pages.

Returns:
the color to draw the background of selected items
See Also:
setSelectionBackground(java.awt.Color), DefaultThumbnailCellRenderer

setSelectionBackground

public void setSelectionBackground(Color selectionBackground)
Sets the color used to draw the background of selected pages. DefaultThumbnailCellRenderer uses this color to fill the background of selected pages.

The default value of this property is defined as UI property:

UI-Properties
Property Type Description Default value
ThumbnailView.selectionBackground Color The background color for selected pages Same as 'List.selectionBackground', but with alpha=120

Parameters:
selectionBackground - the Color to use for the background of selected cells
See Also:
getSelectionBackground(), setSelectionForeground(java.awt.Color), JComponent.setForeground(java.awt.Color), JComponent.setBackground(java.awt.Color), JComponent.setFont(java.awt.Font), DefaultThumbnailCellRenderer

getSelectionForeground

public Color getSelectionForeground()
Returns the color used to draw the foreground of selected pages. DefaultThumbnailCellRenderer uses this color to draw the foreground of items in the selected state.

Returns:
the color to draw the foreground of selected items
See Also:
setSelectionForeground(java.awt.Color), DefaultThumbnailCellRenderer

setSelectionForeground

public void setSelectionForeground(Color selectionForeground)
Sets the color used to draw the foreground of selected pages. DefaultThumbnailCellRenderer uses this color to draw the foreground of items in the selected state.

The default value of this property is defined as UI property:

UI-Properties
Property Type Description Default value
ThumbnailView.selectionForeground Color The color of foreground elements like labels etc. for selected pages Same as 'List.foreground'

Parameters:
selectionForeground - the Color to use in the foreground for selected cells
See Also:
getSelectionForeground(), setSelectionBackground(java.awt.Color), JComponent.setForeground(java.awt.Color), JComponent.setBackground(java.awt.Color), JComponent.setFont(java.awt.Font), DefaultThumbnailCellRenderer

contribute

public void contribute(ContributionContext context,
                       MenuBuilder menuBuilder)
There are no default contributions of the ThumbnailView.AccessibleThumbnailView to its context menu.

Specified by:
contribute in interface MenuContributor
Overrides:
contribute in class ViewComponent
Parameters:
context - the ContributionContext which provides contribution context informations
menuBuilder - the MenuBuilder to which the tool may contribute entries.
See Also:
ViewComponent.contribute(com.levigo.util.swing.menu.ContributionContext, com.levigo.util.swing.menu.MenuBuilder)

setEnableTransientPageRendering

public void setEnableTransientPageRendering(boolean renderPagesDuringTransientRenderings)
Returns whether thumbnail rendering shall be triggered, even during transient renderings. Transient rendering means the rendering while a scroll bar was dragged.
During the rendering of the thumbnail view, thumbnail images are drawn if they previously have been rendered and still reside in the cache. If they are not already cached, they initially have to be created before the rendering can be done. The creation and rendering may cost a considerable processing time.
In some situations one may favour not to trigger thumbnail creation for rendering.

Parameters:
renderPagesDuringTransientRenderings - if enabled, all thumbnails are rendered, even during transient renderings.
See Also:
isEnableTransientPageRendering()

isEnableTransientPageRendering

public boolean isEnableTransientPageRendering()
Returns whether thumbnail rendering shall be triggered, even during transient renderings.

Returns:
true all thumbnails are always being rendered, even during transient renderings. Otherwise not.
See Also:
setEnableTransientPageRendering(boolean)


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.