Groovy Documentation

com.blogofbug.swing.components
[Java] Class ReflectedImageLabel

java.lang.Object
  java.awt.Component
      java.awt.Container
          javax.swing.JComponent
              javax.swing.JLabel
                  com.blogofbug.swing.components.ReflectedImageLabel
All Implemented Interfaces:
RichComponent

public class ReflectedImageLabel
extends JLabel

A RichComponent which takes the supplied image, adds on 50% to the height of the image and draws a graduated alpha-blended reflection below the top aligned original image. The text (set by setRichText()) is drawn dynamically over the reflection, below the original image.

Authors:
nigel


Field Summary
private AlphaComposite alphaComposite

The desired alpha composite

private BufferedImage bufferedImage

The image with reflection

private static Font reference

A font used for reference purposes when evaluating the size of the rendered component

private String text

The richtext associated with this component

 
Fields inherited from class JLabel
CENTER, TOP, LEFT, BOTTOM, RIGHT, NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST, HORIZONTAL, VERTICAL, LEADING, TRAILING, NEXT, PREVIOUS, 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
ReflectedImageLabel(Image image, int width, int height)

Creates a new instance from the supplied image object

ReflectedImageLabel(Image image, String text, int width, int height)

Creates a new instance of a reflected label for the supplied image, also setting the text to be associated with the image.

ReflectedImageLabel(Image image, String text)

Creates a new instance of a reflected label using the supplied image and text

ReflectedImageLabel(String imageURL)

See constructor for image label, this version of the constructor takes an image URL instead of the image object (the URL can be in string format).

ReflectedImageLabel(String imageURL, int width, int height)

Creates a new instance, setting the width and the height that may be used by the RichContainer

ReflectedImageLabel(String imageURL, String text, int width, int height)

Creates a new instance, using the image specified in the URL string, the prefered dimensions and sets the Rich text as well

 
Method Summary
Dimension getPreferredSize()

Overrides the default getPreferedSize() which has been controlled by the created image and adds 50% onto the height to allow for the reflection.

String getRichText()

See interface definition

void paintComponent(Graphics graphics)

Paints the component

void prePaintImage()

See interface definition

void setAlpha(float alphaLevel)

Sets the transparency of the component

void setImage(Image image)

Deprecated

void setLabel(String text)

Depricated.

void setRichImage(URL image)

Assigns an image to the component, the width and height taken from the supplied image

void setRichImage(File image)

See interface definition

void setRichImage(Image image)

See interface definition

void setRichText(String text)

See interface definition

private void setupImage(String imageURL)

Will accept a string URL for loading the image before calling the normal setupImage function after loading it.

protected void setupImage(Image image)

Adds a reflection to the supplied image

 
Methods inherited from class JLabel
setText, getAccessibleContext, imageUpdate, setUI, updateUI, getUIClassID, getUI, getDisabledIcon, getDisplayedMnemonicIndex, setDisplayedMnemonicIndex, setHorizontalTextPosition, setVerticalTextPosition, getText, setIcon, setHorizontalAlignment, getIcon, setDisabledIcon, getVerticalAlignment, setVerticalAlignment, getHorizontalAlignment, getVerticalTextPosition, getHorizontalTextPosition, getIconTextGap, setIconTextGap, setDisplayedMnemonic, setDisplayedMnemonic, getDisplayedMnemonic, getLabelFor, setLabelFor, contains, getLocation, print, getSize, isOpaque, enable, disable, update, getY, getX, getInsets, getInsets, setFont, getPreferredSize, getMinimumSize, getMaximumSize, getAlignmentX, getAlignmentY, paint, getListeners, addNotify, removeNotify, setFocusTraversalKeys, requestFocus, requestFocus, firePropertyChange, firePropertyChange, firePropertyChange, setEnabled, isDoubleBuffered, setVisible, setForeground, setBackground, getBounds, reshape, getWidth, getHeight, setPreferredSize, setMinimumSize, setMaximumSize, getBaseline, getBaselineResizeBehavior, getGraphics, getFontMetrics, repaint, repaint, printAll, requestFocusInWindow, addAncestorListener, setInheritsPopupMenu, getInheritsPopupMenu, setComponentPopupMenu, getComponentPopupMenu, isPaintingTile, isPaintingForPrint, isManagingFocus, setNextFocusableComponent, getNextFocusableComponent, setRequestFocusEnabled, isRequestFocusEnabled, grabFocus, setVerifyInputWhenFocusTarget, getVerifyInputWhenFocusTarget, setBorder, getBorder, setAlignmentY, setAlignmentX, setInputVerifier, getInputVerifier, setDebugGraphicsOptions, getDebugGraphicsOptions, registerKeyboardAction, registerKeyboardAction, unregisterKeyboardAction, getRegisteredKeyStrokes, getConditionForKeyStroke, getActionForKeyStroke, resetKeyboardActions, setInputMap, getInputMap, getInputMap, setActionMap, getActionMap, requestDefaultFocus, getDefaultLocale, setDefaultLocale, setToolTipText, getToolTipText, getToolTipText, getToolTipLocation, getPopupLocation, createToolTip, scrollRectToVisible, setAutoscrolls, getAutoscrolls, setTransferHandler, getTransferHandler, getClientProperty, putClientProperty, isLightweightComponent, setOpaque, computeVisibleRect, getVisibleRect, addVetoableChangeListener, removeVetoableChangeListener, getVetoableChangeListeners, getTopLevelAncestor, removeAncestorListener, getAncestorListeners, revalidate, isValidateRoot, isOptimizedDrawingEnabled, paintImmediately, paintImmediately, setDoubleBuffered, getRootPane, add, add, add, add, add, remove, remove, list, list, removeAll, getComponent, invalidate, validate, getComponentCount, countComponents, getComponents, insets, setComponentZOrder, getComponentZOrder, getLayout, setLayout, doLayout, layout, preferredSize, minimumSize, paintComponents, printComponents, addContainerListener, removeContainerListener, getContainerListeners, deliverEvent, getComponentAt, getComponentAt, locate, getMousePosition, findComponentAt, findComponentAt, isAncestorOf, getFocusTraversalKeys, areFocusTraversalKeysSet, isFocusCycleRoot, isFocusCycleRoot, transferFocusBackward, setFocusTraversalPolicy, getFocusTraversalPolicy, isFocusTraversalPolicySet, setFocusCycleRoot, setFocusTraversalPolicyProvider, isFocusTraversalPolicyProvider, transferFocusDownCycle, applyComponentOrientation, addPropertyChangeListener, addPropertyChangeListener, add, toString, getName, contains, size, getParent, getLocation, remove, setName, list, list, list, getSize, resize, resize, setSize, setSize, enable, location, isValid, setLocale, action, getMousePosition, getGraphicsConfiguration, dispatchEvent, isVisible, isEnabled, isDisplayable, isFocusable, getTreeLock, isLightweight, getPeer, isFocusOwner, transferFocus, getFont, isPreferredSizeSet, isMinimumSizeSet, isMaximumSizeSet, isShowing, handleEvent, postEvent, getFocusCycleRootAncestor, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, setDropTarget, getDropTarget, getToolkit, enableInputMethods, show, show, hide, getForeground, isForegroundSet, getBackground, isBackgroundSet, isFontSet, getLocale, getColorModel, getLocationOnScreen, setLocation, setLocation, move, getBounds, bounds, setBounds, setBounds, setCursor, getCursor, isCursorSet, paintAll, repaint, repaint, repaint, createImage, createImage, createVolatileImage, createVolatileImage, prepareImage, prepareImage, checkImage, checkImage, setIgnoreRepaint, getIgnoreRepaint, inside, addComponentListener, removeComponentListener, getComponentListeners, addFocusListener, removeFocusListener, getFocusListeners, addHierarchyListener, removeHierarchyListener, getHierarchyListeners, addHierarchyBoundsListener, removeHierarchyBoundsListener, getHierarchyBoundsListeners, addKeyListener, removeKeyListener, getKeyListeners, addMouseListener, removeMouseListener, getMouseListeners, addMouseMotionListener, removeMouseMotionListener, getMouseMotionListeners, addMouseWheelListener, removeMouseWheelListener, getMouseWheelListeners, addInputMethodListener, removeInputMethodListener, getInputMethodListeners, getInputMethodRequests, getInputContext, mouseDown, mouseDrag, mouseUp, mouseMove, mouseEnter, mouseExit, keyDown, keyUp, gotFocus, lostFocus, isFocusTraversable, setFocusable, setFocusTraversalKeysEnabled, getFocusTraversalKeysEnabled, nextFocus, transferFocusUpCycle, hasFocus, removePropertyChangeListener, removePropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, setComponentOrientation, getComponentOrientation, wait, wait, wait, equals, hashCode, getClass, notify, notifyAll
 
Methods inherited from class JComponent
contains, getLocation, print, getSize, isOpaque, enable, disable, update, getY, getX, getInsets, getInsets, setFont, getPreferredSize, getMinimumSize, getMaximumSize, getAlignmentX, getAlignmentY, paint, getListeners, addNotify, removeNotify, setFocusTraversalKeys, requestFocus, requestFocus, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, setEnabled, isDoubleBuffered, setVisible, setForeground, setBackground, getBounds, reshape, getWidth, getHeight, setPreferredSize, setMinimumSize, setMaximumSize, getBaseline, getBaselineResizeBehavior, getGraphics, getFontMetrics, repaint, repaint, printAll, requestFocusInWindow, updateUI, getUIClassID, addAncestorListener, setInheritsPopupMenu, getInheritsPopupMenu, setComponentPopupMenu, getComponentPopupMenu, isPaintingTile, isPaintingForPrint, isManagingFocus, setNextFocusableComponent, getNextFocusableComponent, setRequestFocusEnabled, isRequestFocusEnabled, grabFocus, setVerifyInputWhenFocusTarget, getVerifyInputWhenFocusTarget, setBorder, getBorder, setAlignmentY, setAlignmentX, setInputVerifier, getInputVerifier, setDebugGraphicsOptions, getDebugGraphicsOptions, registerKeyboardAction, registerKeyboardAction, unregisterKeyboardAction, getRegisteredKeyStrokes, getConditionForKeyStroke, getActionForKeyStroke, resetKeyboardActions, setInputMap, getInputMap, getInputMap, setActionMap, getActionMap, requestDefaultFocus, getDefaultLocale, setDefaultLocale, setToolTipText, getToolTipText, getToolTipText, getToolTipLocation, getPopupLocation, createToolTip, scrollRectToVisible, setAutoscrolls, getAutoscrolls, setTransferHandler, getTransferHandler, getClientProperty, putClientProperty, isLightweightComponent, setOpaque, computeVisibleRect, getVisibleRect, addVetoableChangeListener, removeVetoableChangeListener, getVetoableChangeListeners, getTopLevelAncestor, removeAncestorListener, getAncestorListeners, revalidate, isValidateRoot, isOptimizedDrawingEnabled, paintImmediately, paintImmediately, setDoubleBuffered, getRootPane, add, add, add, add, add, remove, remove, list, list, removeAll, getComponent, invalidate, validate, getComponentCount, countComponents, getComponents, insets, setComponentZOrder, getComponentZOrder, getLayout, setLayout, doLayout, layout, preferredSize, minimumSize, paintComponents, printComponents, addContainerListener, removeContainerListener, getContainerListeners, deliverEvent, getComponentAt, getComponentAt, locate, getMousePosition, findComponentAt, findComponentAt, isAncestorOf, getFocusTraversalKeys, areFocusTraversalKeysSet, isFocusCycleRoot, isFocusCycleRoot, transferFocusBackward, setFocusTraversalPolicy, getFocusTraversalPolicy, isFocusTraversalPolicySet, setFocusCycleRoot, setFocusTraversalPolicyProvider, isFocusTraversalPolicyProvider, transferFocusDownCycle, applyComponentOrientation, addPropertyChangeListener, addPropertyChangeListener, add, toString, getName, contains, size, getParent, getLocation, remove, setName, list, list, list, getSize, resize, resize, setSize, setSize, enable, location, isValid, setLocale, action, getMousePosition, getGraphicsConfiguration, dispatchEvent, isVisible, isEnabled, isDisplayable, isFocusable, getTreeLock, isLightweight, getPeer, isFocusOwner, transferFocus, getFont, isPreferredSizeSet, isMinimumSizeSet, isMaximumSizeSet, isShowing, handleEvent, postEvent, getFocusCycleRootAncestor, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, setDropTarget, getDropTarget, getToolkit, enableInputMethods, show, show, hide, getForeground, isForegroundSet, getBackground, isBackgroundSet, isFontSet, getLocale, getColorModel, getLocationOnScreen, setLocation, setLocation, move, getBounds, bounds, setBounds, setBounds, setCursor, getCursor, isCursorSet, paintAll, repaint, repaint, repaint, imageUpdate, createImage, createImage, createVolatileImage, createVolatileImage, prepareImage, prepareImage, checkImage, checkImage, setIgnoreRepaint, getIgnoreRepaint, inside, addComponentListener, removeComponentListener, getComponentListeners, addFocusListener, removeFocusListener, getFocusListeners, addHierarchyListener, removeHierarchyListener, getHierarchyListeners, addHierarchyBoundsListener, removeHierarchyBoundsListener, getHierarchyBoundsListeners, addKeyListener, removeKeyListener, getKeyListeners, addMouseListener, removeMouseListener, getMouseListeners, addMouseMotionListener, removeMouseMotionListener, getMouseMotionListeners, addMouseWheelListener, removeMouseWheelListener, getMouseWheelListeners, addInputMethodListener, removeInputMethodListener, getInputMethodListeners, getInputMethodRequests, getInputContext, mouseDown, mouseDrag, mouseUp, mouseMove, mouseEnter, mouseExit, keyDown, keyUp, gotFocus, lostFocus, isFocusTraversable, setFocusable, setFocusTraversalKeysEnabled, getFocusTraversalKeysEnabled, nextFocus, transferFocusUpCycle, hasFocus, removePropertyChangeListener, removePropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, setComponentOrientation, getComponentOrientation, wait, wait, wait, equals, hashCode, getClass, notify, notifyAll
 

Field Detail

alphaComposite

private AlphaComposite alphaComposite
The desired alpha composite


bufferedImage

private BufferedImage bufferedImage
The image with reflection


reference

private static final Font reference
A font used for reference purposes when evaluating the size of the rendered component


text

private String text
The richtext associated with this component


 
Constructor Detail

ReflectedImageLabel

public ReflectedImageLabel(Image image, int width, int height)
Creates a new instance from the supplied image object
deprecated:
This function will be removed, use setNeutralWidth() on JCarousel instead.
Parameters:
image - The Image object
width - The prefered width of the image when rendered by a rich container
height - The prefered heightof the image when rendered by a rich container


ReflectedImageLabel

public ReflectedImageLabel(Image image, String text, int width, int height)
Creates a new instance of a reflected label for the supplied image, also setting the text to be associated with the image.
deprecated:
This function will be removed, use setNeutralWidth() on JCarousel instead.
Parameters:
image - The image
text - The text label
width - The prefered width of the image when rendered by a rich container
height - The prefered height of the image when rendered by a rich container


ReflectedImageLabel

public ReflectedImageLabel(Image image, String text)
Creates a new instance of a reflected label using the supplied image and text
Parameters:
image - The image to be used
text - The text to be displayed


ReflectedImageLabel

public ReflectedImageLabel(String imageURL)
See constructor for image label, this version of the constructor takes an image URL instead of the image object (the URL can be in string format).
Parameters:
imageURL - A URL (in string form) of the image.


ReflectedImageLabel

public ReflectedImageLabel(String imageURL, int width, int height)
Creates a new instance, setting the width and the height that may be used by the RichContainer
deprecated:
This function will be removed, use setNeutralWidth() on JCarousel instead.
Parameters:
imageURL - The URL of the image (String form)
width - The prefered width of the image when rendered by a rich container
height - The prefered height of the image when rendered by a rich container


ReflectedImageLabel

public ReflectedImageLabel(String imageURL, String text, int width, int height)
Creates a new instance, using the image specified in the URL string, the prefered dimensions and sets the Rich text as well
deprecated:
This function will be removed, use setNeutralWidth() on JCarousel instead.
Parameters:
imageURL - The URL of the image in text form
text - The RichText to be displayed
width - The prefered width of the image when rendered by a rich container
height - The prefered height of the image when rendered by a rich container


 
Method Detail

getPreferredSize

public Dimension getPreferredSize()
Overrides the default getPreferedSize() which has been controlled by the created image and adds 50% onto the height to allow for the reflection.
Returns:
The prefered dimensions of the component


getRichText

public String getRichText()
See interface definition
Returns:
See interface definition
See Also:
RichComponent


paintComponent

public void paintComponent(Graphics graphics)
Paints the component
Parameters:
graphics - The graphics context


prePaintImage

public void prePaintImage()
See interface definition
See Also:
RichComponent


setAlpha

public void setAlpha(float alphaLevel)
Sets the transparency of the component
Parameters:
alphaLevel - The alpha level of the object
See Also:
RichComponent


setImage

public void setImage(Image image)
Deprecated
deprecated:
Please use setRichImage() instead from the RichComponent interface
Parameters:
image - An image object to use (reflection will be added)
See Also:
RichComponent


setLabel

public void setLabel(String text)
Depricated.
deprecated:
Use setRichText() instead
Parameters:
text - The rich text


setRichImage

public void setRichImage(URL image)
Assigns an image to the component, the width and height taken from the supplied image
Parameters:
image - The URL of the image


setRichImage

public void setRichImage(File image)
See interface definition
Parameters:
image - See interface definition
See Also:
RichComponent


setRichImage

public void setRichImage(Image image)
See interface definition
Parameters:
image - See interface definition
See Also:
RichComponent


setRichText

public void setRichText(String text)
See interface definition
Parameters:
text - See interface definition
See Also:
RichComponent


setupImage

private void setupImage(String imageURL)
Will accept a string URL for loading the image before calling the normal setupImage function after loading it.
Parameters:
imageURL - The URL of the image (in a string)


setupImage

protected void setupImage(Image image)
Adds a reflection to the supplied image
Parameters:
image - The image object to use to pre-render the reflection


 

Groovy Documentation