Module org.jpo
Package org.jpo.gui

Class ThumbnailLayoutManager

java.lang.Object
org.jpo.gui.ThumbnailLayoutManager
All Implemented Interfaces:
LayoutManager

public class ThumbnailLayoutManager extends Object implements LayoutManager
A Layout Manager for the Thumbnail pane
  • Constructor Details

    • ThumbnailLayoutManager

      public ThumbnailLayoutManager(JComponent widthProvider)
      Constructs the LayoutManager. We need a reference to the JComponent to query for the width to which we are supposed to lay out the thumbnails.
      Parameters:
      widthProvider - The width providing JComponent. Typically, the JViewport of the JScrollPane showing the thumbnails.
  • Method Details

    • addLayoutComponent

      public void addLayoutComponent(String name, Component comp)
      Must-have for LayoutManager interface
      Specified by:
      addLayoutComponent in interface LayoutManager
      Parameters:
      name - name
      comp - component
    • removeLayoutComponent

      public void removeLayoutComponent(Component comp)
      Must-have for LayoutManager interface
      Specified by:
      removeLayoutComponent in interface LayoutManager
      Parameters:
      comp - component
    • preferredLayoutSize

      public Dimension preferredLayoutSize(Container parent)
      Returns the preferredLayoutSize for the managed component
      Specified by:
      preferredLayoutSize in interface LayoutManager
      Parameters:
      parent - parent
      Returns:
      preferred size
    • minimumLayoutSize

      public Dimension minimumLayoutSize(Container target)
      Returns the minimumLayoutSize for the managed component
      Specified by:
      minimumLayoutSize in interface LayoutManager
      Parameters:
      target - Target
      Returns:
      preferred size
    • setThumbnailWidth

      public void setThumbnailWidth(int newThumbnailWidth)
      Sets the width of the thumbnails
      Parameters:
      newThumbnailWidth - The width of the thumbnails in the layout.
    • getThumbnailWidth

      public int getThumbnailWidth()
      Returns the thumbnail width.
      Returns:
      The width of the thumbnail in the layout
    • setHorizontalGutter

      public void setHorizontalGutter(int newGutter)
      Sets the horizontal gutter between the thumbnails.
      Parameters:
      newGutter - The amount of pixels to use as gutter.
    • getHorizontalGutter

      public int getHorizontalGutter()
      Returns the horizontal gutter between the thumbnails.
      Returns:
      The amount of pixels to used as gutter.
    • setVerticalGutter

      public void setVerticalGutter(int newGutter)
      Sets the vertical gutter between the rows.
      Parameters:
      newGutter - The amount of pixels to use as gutter.
    • getVerticalGutter

      public int getVerticalGutter()
      Returns the vertical gutter between the Thumbnails.
      Returns:
      The amount of pixels to used as gutter.
    • layoutContainer

      public void layoutContainer(Container parent)
      This method is called by the parent container when it wants to have the components laid out. This implementation runs through all the Thumbnail and Thumbnail Description objects and puts them to the right place.
      Specified by:
      layoutContainer in interface LayoutManager
      Parameters:
      parent - Parent
    • calculateCols

      public void calculateCols()
      Calculates the number of columns we have on the panel and saves the result.
    • calculateCols

      public int calculateCols(int width)
      Calculates the number of columns we can show given a specified width
      Parameters:
      width - Width
      Returns:
      the number of columns
    • getParentComponentWidth

      public static int getParentComponentWidth(Container parent)
      Returns the width of the parent component. This most likely is the JPanel and that is not interesting, so we go the parent's parent which is the JViewport and ask that for its width.
      Parameters:
      parent - Parent
      Returns:
      the width of the parent component.
    • getCols

      public int getCols()
      Returns how many columns we are showing for the current layout. If this needs to be adjusted call calculateCols() first.
      Returns:
      The number of columns in the layout