|
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.JLabel
com.blogofbug.swing.components.ReflectedImageLabel
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.
| 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 |
| Field Detail |
|---|
private AlphaComposite alphaComposite
private BufferedImage bufferedImage
private static final Font reference
private String text
| Constructor Detail |
|---|
public ReflectedImageLabel(Image image, int width, int height)
image - The Image objectwidth - The prefered width of the image when rendered by a rich containerheight - The prefered heightof the image when rendered by a rich container
public ReflectedImageLabel(Image image, String text, int width, int height)
image - The imagetext - The text labelwidth - The prefered width of the image when rendered by a rich containerheight - The prefered height of the image when rendered by a rich container
public ReflectedImageLabel(Image image, String text)
image - The image to be usedtext - The text to be displayed
public ReflectedImageLabel(String imageURL)
imageURL - A URL (in string form) of the image.
public ReflectedImageLabel(String imageURL, int width, int height)
imageURL - The URL of the image (String form)width - The prefered width of the image when rendered by a rich containerheight - The prefered height of the image when rendered by a rich container
public ReflectedImageLabel(String imageURL, String text, int width, int height)
imageURL - The URL of the image in text formtext - The RichText to be displayedwidth - The prefered width of the image when rendered by a rich containerheight - The prefered height of the image when rendered by a rich container
| Method Detail |
|---|
public Dimension getPreferredSize()
public String getRichText()
public void paintComponent(Graphics graphics)
graphics - The graphics context
public void prePaintImage()
public void setAlpha(float alphaLevel)
alphaLevel - The alpha level of the object
public void setImage(Image image)
image - An image object to use (reflection will be added)
public void setLabel(String text)
text - The rich text
public void setRichImage(URL image)
image - The URL of the image
public void setRichImage(File image)
image - See interface definition
public void setRichImage(Image image)
image - See interface definition
public void setRichText(String text)
text - See interface definition
private void setupImage(String imageURL)
imageURL - The URL of the image (in a string)
protected void setupImage(Image image)
image - The image object to use to pre-render the reflection
Groovy Documentation