com.bff.musicjukebox.ui.components
Class WatermarkPainter

java.lang.Object
  extended by com.bff.musicjukebox.ui.components.WatermarkPainter
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.HierarchyListener, java.util.EventListener
Direct Known Subclasses:
AnimPainter, FillPainter, GradientPainter, StampPainter

public abstract class WatermarkPainter
extends java.lang.Object
implements java.awt.event.ActionListener, java.awt.event.HierarchyListener

This class is the abstract base class for objects that know how to paint a WatermarkViewport. Minimally, subclasses must override the paint method.


Constructor Summary
WatermarkPainter()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ae)
          Perform the action given by the actionCommand of the specified ActionEvent.
 java.lang.String[] getCommands()
          Return the list of commands that can be sent to this painter.
protected  WatermarkViewport getComponent()
          Return the viewport associated with this painter.
protected static java.awt.Image getImage(java.net.URL imageURL)
          Convenience method to load an image from the given URL.
 void hierarchyChanged(java.awt.event.HierarchyEvent he)
          Listens for hierarchy events on the current viewport to start or stop this painter when the component's showing state changes.
static java.awt.Image loadImage(java.io.InputStream inStream)
          Loads an ImageIcon object from this archive.
protected abstract  void paint(java.awt.Graphics g)
          Paint onto the graphics object indicated by the parameter.
protected  void start()
          Starts any animation that this painter might perform.
protected  void stop()
          Stops any animation that this painter might be performing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WatermarkPainter

public WatermarkPainter()
Method Detail

getComponent

protected final WatermarkViewport getComponent()
Return the viewport associated with this painter.

Returns:
the viewport associated with this painter

getCommands

public java.lang.String[] getCommands()
Return the list of commands that can be sent to this painter. These commands will be sent in the form of an actionCommand on an java.awt.ActionEvent sent to actionPerformed.

Returns:
the commands which this painter understands

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ae)
Perform the action given by the actionCommand of the specified ActionEvent. Should support the command list returned by getCommands.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
ae - the ActionEvent containing a command to perform

start

protected void start()
Starts any animation that this painter might perform. This is called when this painter is registered with a new viewport, if the viewport's showing status is true. It will then be called every time that component's status changes to true.


stop

protected void stop()
Stops any animation that this painter might be performing. This is called when this painter is un-registered, or when the showing status of the current viewport changes to false.


paint

protected abstract void paint(java.awt.Graphics g)
Paint onto the graphics object indicated by the parameter. This method can query the component returned by getComponent for size information. The component returned is guaranteed to be non-null as setComponent will always be called with a non-null component before any painting is done.

Parameters:
g - the graphics object on which to paint

getImage

protected static java.awt.Image getImage(java.net.URL imageURL)
Convenience method to load an image from the given URL. This implementation uses ImageIO to load the image and thus returns BufferedImages.

Parameters:
imageURL - the URL to an image
Returns:
the image or null if the image couldn't be loaded

loadImage

public static java.awt.Image loadImage(java.io.InputStream inStream)
Loads an ImageIcon object from this archive. Note: This method is compatible under Java Web Start.

Parameters:
name - the name of the icon file
Returns:
the icon if loaded, null otherwise

hierarchyChanged

public void hierarchyChanged(java.awt.event.HierarchyEvent he)
Listens for hierarchy events on the current viewport to start or stop this painter when the component's showing state changes.

Specified by:
hierarchyChanged in interface java.awt.event.HierarchyListener