Package adams.gui.tools.previewbrowser
Class PreviewDisplay
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.tools.previewbrowser.PreviewDisplay
-
- All Implemented Interfaces:
CleanUpHandler,ImageObserver,MenuContainer,Serializable,Accessible
public class PreviewDisplay extends BasePanel implements CleanUpHandler
Displays aPreviewPaneland a combobox to switch views.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
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
Fields Modifier and Type Field Description static StringDISPLAY_FAVORITEplaceholder string when a favorite was selected.static StringDISPLAY_NO_FAVORITESplaceholder string when no favorites are available.protected BaseButtonm_ButtonContentHandlerthe button for displaying the options for the content handler.protected BaseButtonWithDropDownMenum_ButtonFavoritesthe button with the favorites.protected BaseComboBoxm_ComboBoxContentHandlersthe combobox with the content handlers (if more than one available).protected Stringm_CurrentExtensionthe current extension.protected ContentHandlerFavorites.ContentHandlerFavoritem_CurrentFavoritethe currently selected favorite.protected File[]m_CurrentFilesthe currently selected files.protected booleanm_DisplayInProgresswhether a display is currently in progress.protected Map<String,ContentHandlerFavorites.ContentHandlerFavorite>m_Favoritesthe favorites per extension.protected booleanm_IgnoreContentHandlerChangeswhether to ignore selections of the content handler combobox temporarily.protected ContentHandlerm_LastContentHandlerthe last content handler.protected SearchPanelm_LastSearchthe last search panel that was encountered.protected List<ContentHandler>m_ListContentHandlersthe list of content handler objects (aligned with combobox).protected DefaultComboBoxModel<String>m_ModelContentHandlersthe model of the combobox.protected BasePanelm_PanelContentHandlersthe panel with the content handlers.protected BasePanelm_PanelViewthe panel for the view.protected LRUCache<String,PreviewPanel>m_PreviewCachethe cached previews (content handler -> preview).protected booleanm_ReusePreviewswhether to reuse previews.protected booleanm_UseFixedContentHandlerwhether to fix the handler.-
Fields inherited from class adams.gui.core.BasePanel
m_FileChooser
-
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
Constructors Constructor Description PreviewDisplay()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanUp()Cleans up data structures, frees up memory.voidclear()Clears the view.protected JPanelcreatePreview(File[] localFiles)Creates a preview for the files.protected StringdetermineExtension(File[] localFiles)Determines the extension from the file(s) for the favorites.voiddisplay(File[] localFiles, boolean wait)Displays the content from the specified files.voiddisplayCreatingView()Displays "Creating view...".voiddisplayView(JPanel panel)Displays the given view in the content panel.protected voideditContentHandler()Displays GOE for current content handler.ContentHandlergetActualContentHandler()Returns the actual content handler in use.JComponentgetComponent()Returns the component for sendto.ContentHandlergetContentHandler()Returns the current handler.StringgetCurrentExtension()Returns the current extension.intgetPreviewCacheSize()Returns the size of the preview cache.booleangetReusePreviews()Returns whether to reuse previews.booleangetUseFixedContentHandler()Returns whether to use a fixed content handler.protected voidinitGUI()Initializes the widgets.protected voidinitialize()Initializes the members.voidselectFavorite(ContentHandlerFavorites.ContentHandlerFavorite favorite)Selects the favorite instead of the selected content handlervoidsetPreviewCacheSize(int value)Sets the size of the preview cache.voidsetReusePreviews(boolean value)Sets whether to reuse previews.voidsetUseFixedContentHandler(boolean value)Sets whether to use a fixed content handler.voidupdateFavorite(String ext, ContentHandlerFavorites.ContentHandlerFavorite favorite)Updates the favorite to use.protected voidupdatePreferredContentHandler()Updates the preferred handler.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, finishInit, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, 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, 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, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
DISPLAY_FAVORITE
public static final String DISPLAY_FAVORITE
placeholder string when a favorite was selected.- See Also:
- Constant Field Values
-
DISPLAY_NO_FAVORITES
public static final String DISPLAY_NO_FAVORITES
placeholder string when no favorites are available.- See Also:
- Constant Field Values
-
m_PanelView
protected BasePanel m_PanelView
the panel for the view.
-
m_PanelContentHandlers
protected BasePanel m_PanelContentHandlers
the panel with the content handlers.
-
m_ComboBoxContentHandlers
protected BaseComboBox m_ComboBoxContentHandlers
the combobox with the content handlers (if more than one available).
-
m_ModelContentHandlers
protected DefaultComboBoxModel<String> m_ModelContentHandlers
the model of the combobox.
-
m_ListContentHandlers
protected List<ContentHandler> m_ListContentHandlers
the list of content handler objects (aligned with combobox).
-
m_ButtonFavorites
protected BaseButtonWithDropDownMenu m_ButtonFavorites
the button with the favorites.
-
m_PreviewCache
protected LRUCache<String,PreviewPanel> m_PreviewCache
the cached previews (content handler -> preview).
-
m_ButtonContentHandler
protected BaseButton m_ButtonContentHandler
the button for displaying the options for the content handler.
-
m_IgnoreContentHandlerChanges
protected boolean m_IgnoreContentHandlerChanges
whether to ignore selections of the content handler combobox temporarily.
-
m_CurrentFiles
protected File[] m_CurrentFiles
the currently selected files.
-
m_CurrentExtension
protected String m_CurrentExtension
the current extension.
-
m_LastSearch
protected SearchPanel m_LastSearch
the last search panel that was encountered.
-
m_DisplayInProgress
protected boolean m_DisplayInProgress
whether a display is currently in progress.
-
m_ReusePreviews
protected boolean m_ReusePreviews
whether to reuse previews.
-
m_Favorites
protected Map<String,ContentHandlerFavorites.ContentHandlerFavorite> m_Favorites
the favorites per extension.
-
m_CurrentFavorite
protected ContentHandlerFavorites.ContentHandlerFavorite m_CurrentFavorite
the currently selected favorite.
-
m_UseFixedContentHandler
protected boolean m_UseFixedContentHandler
whether to fix the handler.
-
m_LastContentHandler
protected ContentHandler m_LastContentHandler
the last content handler.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classBasePanel
-
updateFavorite
public void updateFavorite(String ext, ContentHandlerFavorites.ContentHandlerFavorite favorite)
Updates the favorite to use.- Parameters:
ext- the extension this favorite is to be used withfavorite- the favorite itself
-
selectFavorite
public void selectFavorite(ContentHandlerFavorites.ContentHandlerFavorite favorite)
Selects the favorite instead of the selected content handler- Parameters:
favorite- the favorite instance
-
getActualContentHandler
public ContentHandler getActualContentHandler()
Returns the actual content handler in use.- Returns:
- the handler in use
-
getContentHandler
public ContentHandler getContentHandler()
Returns the current handler.- Returns:
- the handler, null if a favorite was selected
-
editContentHandler
protected void editContentHandler()
Displays GOE for current content handler.
-
displayView
public void displayView(JPanel panel)
Displays the given view in the content panel.- Parameters:
panel- the view to display
-
displayCreatingView
public void displayCreatingView()
Displays "Creating view...".
-
createPreview
protected JPanel createPreview(File[] localFiles)
Creates a preview for the files.- Parameters:
localFiles- the files to create the preview for- Returns:
- the preview
-
getCurrentExtension
public String getCurrentExtension()
Returns the current extension.- Returns:
- the extension, null if none determined
-
determineExtension
protected String determineExtension(File[] localFiles)
Determines the extension from the file(s) for the favorites.- Parameters:
localFiles- the files to inspect- Returns:
- the extension, null if failed to determine
-
display
public void display(File[] localFiles, boolean wait)
Displays the content from the specified files.- Parameters:
localFiles- the files to displaywait- wait for worker thread to finish
-
updatePreferredContentHandler
protected void updatePreferredContentHandler()
Updates the preferred handler.
-
getComponent
public JComponent getComponent()
Returns the component for sendto.- Returns:
- the component
-
setReusePreviews
public void setReusePreviews(boolean value)
Sets whether to reuse previews.- Parameters:
value- true if to reuse
-
getReusePreviews
public boolean getReusePreviews()
Returns whether to reuse previews.- Returns:
- true if to reuse
-
setPreviewCacheSize
public void setPreviewCacheSize(int value)
Sets the size of the preview cache.- Parameters:
value- the size of the cache
-
getPreviewCacheSize
public int getPreviewCacheSize()
Returns the size of the preview cache.- Returns:
- the size of the cache
-
setUseFixedContentHandler
public void setUseFixedContentHandler(boolean value)
Sets whether to use a fixed content handler.- Parameters:
value- true if to use fixed handler
-
getUseFixedContentHandler
public boolean getUseFixedContentHandler()
Returns whether to use a fixed content handler.- Returns:
- true if to use fixed handler
-
clear
public void clear()
Clears the view.
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUpin interfaceCleanUpHandler
-
-