|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
griffon.coverflow.ui.ImageFlow
public class ImageFlow extends JPanel
About this Code
The original code is from Romain Guy's example "A Music Shelf in Java2D". It can be found here: http://www.curious-creature.org/2005/07/09/a-music-shelf-in-java2d/ Updated Code This code has been updated by Kevin Long (codebeach.com) to make it more generic and more component like. History: 2/17/2008 --------- - Changed name of class to ImageFlow from CDShelf - Removed hard coded strings for labels and images - Removed requirement for images to be included in the jar - Support for non-square images - Support for loading images from thumbnails - External methods to set and get currently selected item - Added support for ListSelectionListener2/9/2011 -------- - Removed fixed sizes - Fixed repaint behaviour when changing size
2/25/2011 -------- - Added listener to dataModel to repaint after a change| Nested Class Summary | |
|---|---|
private class |
ImageFlow.AutoScroller
|
private class |
ImageFlow.CursorChanger
|
private class |
ImageFlow.DamageManager
|
private class |
ImageFlow.DrawableItem
|
private class |
ImageFlow.FaderAction
|
private class |
ImageFlow.FocusGrabber
|
private class |
ImageFlow.ItemScroller
|
private class |
ImageFlow.KeyItemSelector
|
private class |
ImageFlow.KeyScroller
|
private class |
ImageFlow.MouseItemSelector
|
private class |
ImageFlow.MouseWheelScroller
|
private class |
ImageFlow.RepaintListDataListener
|
| Fields inherited from class JPanel | |
|---|---|
| WHEN_FOCUSED, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_IN_FOCUSED_WINDOW, UNDEFINED_CONDITION, TOOL_TIP_TEXT_KEY, TOP_ALIGNMENT, CENTER_ALIGNMENT, BOTTOM_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, WIDTH, HEIGHT, PROPERTIES, SOMEBITS, FRAMEBITS, ALLBITS, ERROR, ABORT |
| Fields inherited from class JComponent | |
|---|---|
| WHEN_FOCUSED, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_IN_FOCUSED_WINDOW, UNDEFINED_CONDITION, TOOL_TIP_TEXT_KEY, TOP_ALIGNMENT, CENTER_ALIGNMENT, BOTTOM_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, WIDTH, HEIGHT, PROPERTIES, SOMEBITS, FRAMEBITS, ALLBITS, ERROR, ABORT |
| Constructor Summary | |
ImageFlow()
Constructs a |
|
ImageFlow(ImageFlowItem[] listData)
Constructs a |
|
ImageFlow(List listData)
Constructs a |
|
ImageFlow(ListModel dataModel)
Constructs a ImageFlow that displays elements from the specified, non-null, model. |
|
| Method Summary | |
|---|---|
private void
|
addInputListeners()
|
void
|
addListSelectionListener(ListSelectionListener listener)
Adds a listener to the list that's notified each time a change to the selection occur |
private void
|
adjust()
|
private void
|
computeEquationParts()
|
private double
|
computeModifier(double x)
|
private double
|
computeModifierUnprotected(double x)
|
private void
|
drawItemName(Graphics2D g2)
|
private void
|
drawItems(Graphics2D g2, ImageFlow.DrawableItem[] drawableItems)
|
int
|
getAmount()
|
private ImageFlow.DrawableItem
|
getHitItem(int x, int y)
|
private ImageFlowItem
|
getItemAt(int index)
|
Font
|
getItemFont()
Returns the |
double
|
getItemSpacing()
|
Color
|
getItemTextColor()
Returns the |
int
|
getMaxSelectionIndex()
List Methods |
int
|
getMinSelectionIndex()
Returns the smallets selected cell index |
Dimension
|
getMinimumSize()
|
ListModel
|
getModel()
Returns the data model that holds the list of items displayed
by the |
Dimension
|
getPreferredSize()
|
int
|
getSelectedIndex()
Returns the first selected index; returns -1 if there is no selected item |
Object
|
getSelectedValue()
Returns the first selected value, or null if the selection is empty. |
double
|
getSigma()
|
private void
|
initInputListeners()
|
boolean
|
isFocusable()
|
boolean
|
isOpaque()
|
boolean
|
isSelectedIndex(int index)
Returns true if the specified index is selected. |
private Dimension
|
maximalImageSize()
|
void
|
next()
|
private void
|
notifyListSelectionListener()
Notify the listeners when a selection event has occured |
protected void
|
paintChildren(Graphics g)
|
protected void
|
paintComponent(Graphics g)
|
void
|
previous()
|
private void
|
promoteItemToDrawable(List drawables, int x, int y, int width, int height, int offset)
|
void
|
removeListSelectionListener(ListSelectionListener listener)
Removes a listener from the list that's notified each time a change to the selection occurs |
private void
|
scrollAndAnimate(ImageFlow.DrawableItem item)
|
private void
|
scrollAndAnimateBy(int increment)
|
private void
|
scrollBy(int increment)
|
void
|
setAmount(int amount)
|
void
|
setItemFont(Font itemFont)
Sets the |
private void
|
setItemIndex(int index)
|
private void
|
setItemPosition(double itemPosition)
|
void
|
setItemSpacing(double itemSpacing)
|
void
|
setItemTextColor(Color itemTextColor)
private static final int CD_SIZE = 148; private int displayWidth = CD_SIZE; private int displayHeight = (int) (CD_SIZE * 2 / 1.12); Sets theColor that is used for drawing an item's label,
notifies property change listeners.
|
void
|
setModel(ListModel model)
Sets the model that represents the contents or "value" of the list, notifies property change listeners. |
void
|
setSelectedIndex(int index)
Selects a single cell |
void
|
setSigma(double sigma)
|
private ImageFlow.DrawableItem[]
|
sortItemsByDepth(int x, int y, int width, int height)
|
private void
|
startFader()
|
| Field Detail |
|---|
private static final double ANIM_SCROLL_DELAY
private float alphaLevel
private int amount
private ImageFlow.CursorChanger cursorChanger
private boolean damaged
private ListModel dataModel
private ImageFlow.DrawableItem[] drawableItems
private double exp_member
private double exp_multiplier
private Timer faderTimer
private ImageFlow.FocusGrabber focusGrabber
private CrystalCaseFactory fx
private Font itemFont
private int itemIndex
private double itemPosition
private ImageFlow.ItemScroller itemScroller
private double itemSpacing
private String itemText
private Color itemTextColor
private ImageFlow.KeyItemSelector keyItemSelector
private ImageFlow.KeyScroller keyScroller
private List listSelectionListeners
private ImageFlow.MouseItemSelector mouseItemSelector
private ImageFlow.RepaintListDataListener repaintListDataListener
private double rho
private Timer scrollerTimer
private double sigma
private float textAlphaLevel
private float veilAlphaLevel
private ImageFlow.MouseWheelScroller wheelScroller
| Constructor Detail |
|---|
public ImageFlow()
ImageFlow with an empty, mutable, model.
public ImageFlow(ImageFlowItem[] listData)
ImageFlow that displays the elements in
the specified array. This constructor creates a read-only model
for the given array, and then delegates to the constructor that
takes a ListModel.
Attempts to pass a null value to this method results in
undefined behavior and, most likely, exceptions. The created model
references the given array directly. Attempts to modify the array
after constructing the list results in undefined behavior.
listData - the array of ImageFlowItems to be loaded into the data model,
non-null
public ImageFlow(List listData)
ImageFlow that displays the elements in
the specified List. This constructor creates a read-only
model for the given List, and then delegates to the constructor
that takes a ListModel.
Attempts to pass a null value to this method results in
undefined behavior and, most likely, exceptions. The created model
references the given List directly. Attempts to modify the
List after constructing the list results in undefined behavior.
listData - the List to be loaded into the
data model, non-null
public ImageFlow(ListModel dataModel)
dataModel - the model for the list
| Method Detail |
|---|
private void addInputListeners()
public void addListSelectionListener(ListSelectionListener listener)
listener - ListSelectionListener
private void adjust()
private void computeEquationParts()
private double computeModifier(double x)
private double computeModifierUnprotected(double x)
private void drawItemName(Graphics2D g2)
private void drawItems(Graphics2D g2, ImageFlow.DrawableItem[] drawableItems)
public int getAmount()
private ImageFlow.DrawableItem getHitItem(int x, int y)
private ImageFlowItem getItemAt(int index)
public Font getItemFont()
Font used for drawing an item's label.
Font used for drawing an item's label.
public double getItemSpacing()
public Color getItemTextColor()
Color used to draw an item's label.
Color used to draw an item's label.
public int getMaxSelectionIndex()
public int getMinSelectionIndex()
@Override public Dimension getMinimumSize()
public ListModel getModel()
ImageFlow component.
ListModel that provides the displayed
list of items
@Override public Dimension getPreferredSize()
public int getSelectedIndex()
public Object getSelectedValue()
public double getSigma()
private void initInputListeners()
@Override public boolean isFocusable()
@Override public boolean isOpaque()
public boolean isSelectedIndex(int index)
index - int
private Dimension maximalImageSize()
public void next()
private void notifyListSelectionListener()
@Override protected void paintChildren(Graphics g)
@Override protected void paintComponent(Graphics g)
public void previous()
private void promoteItemToDrawable(List drawables, int x, int y, int width, int height, int offset)
public void removeListSelectionListener(ListSelectionListener listener)
listener - ListSelectionListener
private void scrollAndAnimate(ImageFlow.DrawableItem item)
private void scrollAndAnimateBy(int increment)
private void scrollBy(int increment)
public void setAmount(int amount)
public void setItemFont(Font itemFont)
Font that is used for drawing an item's label,
notifies property change listeners.
This is a JavaBeans bound property.itemFont - the Font that will be used to draw
an item's label.
private void setItemIndex(int index)
private void setItemPosition(double itemPosition)
public void setItemSpacing(double itemSpacing)
public void setItemTextColor(Color itemTextColor)
Color that is used for drawing an item's label,
notifies property change listeners.
This is a JavaBeans bound property.itemTextColor - the Color that will be used to draw
an item's label.
public void setModel(ListModel model)
model is
nullmodel - the ListModel that provides the
list of items for display
public void setSelectedIndex(int index)
index - int
public void setSigma(double sigma)
private ImageFlow.DrawableItem[] sortItemsByDepth(int x, int y, int width, int height)
private void startFader()
Groovy Documentation