java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
org.jpo.gui.swing.Thumbnail
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
This class extends a JComponent showing an ImageIcon. The ImageIcon can be
scaled down with the
setFactor(float)
method.- See Also:
-
Nested Class Summary
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 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
drawMailIcon
(boolean flag) indicates whether the mail icon should be drawn or not and calls repaint()void
drawOfflineIcon
(boolean flag) Indicates to the Thumbnail that it should or should not draw its Offline Status.Returns the maximum (scaled) size for the Thumbnail as a Dimension using the thumbnailSize as width and height.Returns the preferred size for the scaled Thumbnail as a Dimension using the thumbnailSize as width and height.Returns the maximum thumbnail dimensionint
Returns the maximum thumbnail sizevoid
paintComponent
(Graphics graphics) we are overriding the default paintComponent method, grabbing the Graphics handle and doing our own drawing here.void
setFactor
(float thumbnailSizeFactor) This method sets the scaling factor for the display of a thumbnail.void
setImageIcon
(@NotNull ImageIcon icon) sets the image the Thumbnail.void
Sets an icon showing a large yellow foldervoid
Sets an icon of a clock to indicate being on a queuevoid
Tells the thumbnail to render itself as a selected thumbnailvoid
setThumbnailSize
(int thumbnailSize) Sets the maximum Thumbnail sizevoid
setTimestamp
(String timestamp) Set the timestamp string to the supplied String.void
Tells the thumbnail to stop rendering itself as a selected thumbnailvoid
setVisible
(boolean visibility) Overridden method to allow the setting of the size when not visible.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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, updateUI
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, getAccessibleContext, 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
-
Constructor Details
-
Thumbnail
public Thumbnail()Constructor to be called on the EDT.
-
-
Method Details
-
setImageIcon
sets the image the Thumbnail. If we are not on the EDT this is submitted to the EDT.- Parameters:
icon
- The ImageIcon that should be displayed
-
setVisible
public void setVisible(boolean visibility) Overridden method to allow the setting of the size when not visible. This was a bit problematic as the Component which is showing the Thumbnails was not adjusting to the new image size. The revalidate() cured this.- Overrides:
setVisible
in classJComponent
- Parameters:
visibility
- true for visible, false for non visible.
-
setFactor
public void setFactor(float thumbnailSizeFactor) This method sets the scaling factor for the display of a thumbnail. 0..1- Parameters:
thumbnailSizeFactor
- factor
-
setThumbnailSize
public void setThumbnailSize(int thumbnailSize) Sets the maximum Thumbnail size- Parameters:
thumbnailSize
- the maximum thumbnail size
-
getThumbnailSize
public int getThumbnailSize()Returns the maximum thumbnail size- Returns:
- the thumbnail size
-
getThumbnailDimension
Returns the maximum thumbnail dimension- Returns:
- the thumbnail dimension
-
getPreferredSize
Returns the preferred size for the scaled Thumbnail as a Dimension using the thumbnailSize as width and height.- Overrides:
getPreferredSize
in classJComponent
- Returns:
- Returns the preferred size for the scaled Thumbnail as a Dimension using the thumbnailSize as width and height.
-
getMaximumSize
Returns the maximum (scaled) size for the Thumbnail as a Dimension using the thumbnailSize as width and height.- Overrides:
getMaximumSize
in classJComponent
- Returns:
- maximum size for the Thumbnail
-
setQueueIcon
public void setQueueIcon()Sets an icon of a clock to indicate being on a queue -
setLargeFolderIcon
public void setLargeFolderIcon()Sets an icon showing a large yellow folder -
drawOfflineIcon
public void drawOfflineIcon(boolean flag) Indicates to the Thumbnail that it should or should not draw its Offline Status. Calls repaint()- Parameters:
flag
- true if the little CD-rom icon should be drawn, false if not.
-
drawMailIcon
public void drawMailIcon(boolean flag) indicates whether the mail icon should be drawn or not and calls repaint()- Parameters:
flag
- true if it should be drawn, false if not
-
setSelected
public void setSelected()Tells the thumbnail to render itself as a selected thumbnail -
setUnSelected
public void setUnSelected()Tells the thumbnail to stop rendering itself as a selected thumbnail -
setTimestamp
Set the timestamp string to the supplied String. To suppress the timestamp set it to the empty String ""- Parameters:
timestamp
- the new timestamp string.
-
paintComponent
we are overriding the default paintComponent method, grabbing the Graphics handle and doing our own drawing here. Essentially this method draws a large white rectangle. A drawImage is then painted doing an affine transformation on the image to position it so the desired point is in the middle of the Graphics object.- Overrides:
paintComponent
in classJComponent
- Parameters:
graphics
- Graphics
-