Class BasicThumbnail



  • public class BasicThumbnail
    extends Thumbnail
    This provides a simple thumbnail format offering shadows, borders, and rotation. This object and its members are immutable.

    A BasicThumbnail consists of a series of z-ordered layers, where each layer is rendered above the previous. Each layer is a BasicThumbnail.Layer object, and has an associated set of insets. Although most layers support a variable degree of curvature (for rounded corners), the insets reflect the official size of the layer. When scaling an image to fit within a maximum thumbnail size: these insets are combined to calculate the size the source image has to be scaled to. (For example: if the maximum thumbnail size is 64x64, but each side of this thumbnail has 5 pixels of padding, then the image will be scaled to fit within a 54x54 area.)

    • Field Detail

      • Aqua

        public static BasicThumbnail Aqua
        A thumbnail format that resembles the icon observed on Mac 10.7.4 in the Finder for image thumbnails.

        Specifically: this consists of a light 2-pixel shadow, 1-pixel a gray frame, then 2 pixels of white, then another 1-pixel frame. This is not intended to be a perfect replica, but it is similar in appearance.

      • totalInsets

        protected final Insets totalInsets
        A cached record of the total insets of all the layers.
      • theta

        public final float theta
        The rotation (in radians) of this thumbnail.
    • Constructor Detail

      • BasicThumbnail

        public BasicThumbnail(BasicThumbnail.Layer[] e)
        Create a BasicThumbnail with no rotation.

        If there isn't an Image layer in the list of layers provided: then a plain Image layer (with no curvature and a white background) is added.

      • BasicThumbnail

        public BasicThumbnail(BasicThumbnail.Layer[] e,
                              float theta)
        Create a BasicThumbnail.

        If there isn't an Image layer in the list of layers provided: then a plain Image layer (with no curvature and a white background) is added.

        Parameters:
        theta - the rotation of this thumbnail.
      • BasicThumbnail

        public BasicThumbnail(BasicThumbnail.Layer[] e,
                              float theta,
                              boolean addImageIfMissing)
        Create a BasicThumbnail.
        Parameters:
        theta - the rotation of this thumbnail.
        addImageIfMissing - if an Image layer is missing and this boolean is true: a plain Image layer is added. This is generally to be true except in certain (rare) debugging instances.
    • Method Detail

      • getShadow

        public static BasicThumbnail getShadow(int thickness)
        Create a very simple thumbnail with a subtle shadow.
        Parameters:
        thickness - the width of the shadow.
        Returns:
        a thumbnail object with a simple shadow.
      • equals

        public boolean equals(Object obj)
      • create

        protected BufferedImage create(Thumbnail.ImageSource source,
                                       Dimension maxSize)
        Description copied from class: Thumbnail
        Create a thumbnail from an ImageSource.
        Specified by:
        create in class  Thumbnail
        Parameters:
        source - the image source.
        maxSize - the maximum dimensions of the thumbnail. Note the returned thumbnail may be smaller than these bounds. For example: if you have a 4:3 landscape-oriented picture and the maximum size is 64x64 pixels, then the return image will be 64 pixels wide and approximately 48 pixels tall. (It may not be exactly 48 pixels tall, depending on the decorations this thumbnail format may add.)

        If the source image is already smaller than the maxSize, then the source image is not scaled to create this thumbnail.

        Returns:
        an image that is at most maxSize dimensions.
      • hashCode

        public int hashCode()
      • toString

        public String toString()
      • getLayerCount

        public int getLayerCount()
        Return the number of layers in this thumbnail.
      • getLayers

        public BasicThumbnail.Layer[] getLayers()
        Returns a copy of all the layers in this object.