Module org.jpo

Class Thumbnail

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class Thumbnail extends JComponent
This class extends a JComponent showing an ImageIcon. The ImageIcon can be scaled down with the setFactor(float) method.
See Also:
  • Constructor Details

    • Thumbnail

      public Thumbnail()
      Constructor to be called on the EDT.
  • Method Details

    • setImageIcon

      public void setImageIcon(@NotNull @NotNull ImageIcon icon)
      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 class JComponent
      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

      public Dimension getThumbnailDimension()
      Returns the maximum thumbnail dimension
      Returns:
      the thumbnail dimension
    • getPreferredSize

      public Dimension getPreferredSize()
      Returns the preferred size for the scaled Thumbnail as a Dimension using the thumbnailSize as width and height.
      Overrides:
      getPreferredSize in class JComponent
      Returns:
      Returns the preferred size for the scaled Thumbnail as a Dimension using the thumbnailSize as width and height.
    • getMaximumSize

      public Dimension getMaximumSize()
      Returns the maximum (scaled) size for the Thumbnail as a Dimension using the thumbnailSize as width and height.
      Overrides:
      getMaximumSize in class JComponent
      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

      public void setTimestamp(String timestamp)
      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

      public void paintComponent(Graphics graphics)
      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 class JComponent
      Parameters:
      graphics - Graphics