java.lang.Object
org.jpo.gui.ThumbnailLayoutManager
- All Implemented Interfaces:
LayoutManager
A Layout Manager for the Thumbnail pane
-
Constructor Summary
ConstructorDescriptionThumbnailLayoutManager
(JComponent widthProvider) Constructs the LayoutManager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLayoutComponent
(String name, Component comp) Must-have for LayoutManager interfacevoid
Calculates the number of columns we have on the panel and saves the result.int
calculateCols
(int width) Calculates the number of columns we can show given a specified widthint
getCols()
Returns how many columns we are showing for the current layout.int
Returns the horizontal gutter between the thumbnails.static int
getParentComponentWidth
(Container parent) Returns the width of the parent component.int
Returns the thumbnail width.int
Returns the vertical gutter between the Thumbnails.void
layoutContainer
(Container parent) This method is called by the parent container when it wants to have the components laid out.minimumLayoutSize
(Container target) Returns the minimumLayoutSize for the managed componentpreferredLayoutSize
(Container parent) Returns the preferredLayoutSize for the managed componentvoid
Must-have for LayoutManager interfacevoid
setHorizontalGutter
(int newGutter) Sets the horizontal gutter between the thumbnails.void
setThumbnailWidth
(int newThumbnailWidth) Sets the width of the thumbnailsvoid
setVerticalGutter
(int newGutter) Sets the vertical gutter between the rows.
-
Constructor Details
-
ThumbnailLayoutManager
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
Must-have for LayoutManager interface- Specified by:
addLayoutComponent
in interfaceLayoutManager
- Parameters:
name
- namecomp
- component
-
removeLayoutComponent
Must-have for LayoutManager interface- Specified by:
removeLayoutComponent
in interfaceLayoutManager
- Parameters:
comp
- component
-
preferredLayoutSize
Returns the preferredLayoutSize for the managed component- Specified by:
preferredLayoutSize
in interfaceLayoutManager
- Parameters:
parent
- parent- Returns:
- preferred size
-
minimumLayoutSize
Returns the minimumLayoutSize for the managed component- Specified by:
minimumLayoutSize
in interfaceLayoutManager
- 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
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 interfaceLayoutManager
- 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
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 callcalculateCols()
first.- Returns:
- The number of columns in the layout
-