Class ImagePanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants

public class ImagePanel extends JLabel

Title: ImagePanel

Description: A graphical component used to show a given IconImage. This panel is designed to auto-resize the image basing on width assigned by layout managers, maintaining aspect ratio. A maximum height can be specified too. Internal caching is used as long as width is not changed to avoid to recalculate images scaling continuously.

Author:
Bertoli Marco Date: 1-lug-2005 Time: 15.55.21
See Also:
  • Field Details

    • image

      protected ImageIcon image
    • maxheight

      protected int maxheight
    • currentWidth

      protected int currentWidth
    • maxCache

      protected int maxCache
      Maximum number of cached elements
    • cache

      protected HashMap<ImageIcon, ImageIcon> cache
  • Constructor Details

    • ImagePanel

      public ImagePanel()
      Construct a new ImagePanel
  • Method Details

    • setImage

      public void setImage(ImageIcon image)
      Sets image to be shown on this panel
      Parameters:
      image - image to be shown in IconImage format
    • setMaximumHeight

      public void setMaximumHeight(int height)
      Sets maximum height allowed for this component
      Parameters:
      height - maximum height allowed
    • resizeImage

      protected void resizeImage()
      Helper method used to resize input image and display it. If image was already resized to current size, take the copy from local cache.