com.webcab.chat.gui
Class RotatingBanner

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--com.webcab.chat.gui.RotatingBanner
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.io.Serializable

public class RotatingBanner
extends java.awt.Panel
implements java.io.Serializable, java.awt.event.MouseListener

This bean displays a banner which rotates image after image and sends the user to specified URL addresses. RotatingBanner gets the images and the links to point to from banner servers which wait on specific ports a banner image request. Initially, the component should be given a default server and port and an additional list of other servers. The bean will take one image from the default server and another one from the other servers, in ascending order. The list of servers is read from a banner-list url file.

For displaying images, the ImageCache class has been used.

Author:
WebCab Components
See Also:
ImageCache, Serialized Form

Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
RotatingBanner()
          Initializes the timer which calls a new banner every getTimerDelay seconds.
 
Method Summary
 void addNotify()
           
 void addToBannerList(java.lang.String fileName)
          Defines the additional servers wherefrom to load the banners and adds them to the existing list.
 java.applet.Applet getApplet()
          If an applet has been specified in the setApplet method, then it returns its pointer.
 java.lang.String getBannerFile()
          Returns the name of the banner file.
 int getDefaultPort()
          Gets the port where the connection is made to the default banner server.
 java.lang.String getDefaultServer()
          Gets the name of the default server.
 int getDisplayFlag()
           
 java.awt.Dimension getMinimumSize()
           
 void getNewBanner()
          Asks for a new banner to be displayed, according to the 50 percent algorithm.
 java.awt.Dimension getPreferredSize()
           
 java.lang.String getRequestKey()
          Gets the request key to send to each of the banner servers.
 int getTimerDelay()
          Gets the delay between two consecurive banners.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void removeNotify()
           
 void setApplet(java.applet.Applet applet)
          Specifies an applet to open any links where the images might point to.
 void setBackground(java.awt.Color c)
          Defines the background color that surrounds the image.
 void setBannerFile(java.lang.String bannerFileName)
          This method provides a file where all the images are defined.
 void setBannerList(java.lang.String fileName)
          Defines the additional servers wherefrom to load the banners.
 void setDefaultPort(int defaultPort)
          The port where to connect to the default banner server.
 void setDefaultServer(java.lang.String defaultServer)
          Defines the default server.
 void setDimensions(java.awt.Dimension dim)
          Defines the minimum size this banner can have in a normal layout.
 void setDisplayFlag(int flag)
          Sets whether the image should be stretched or centered.
 void setRequestKey(java.lang.String key)
          The string to send to each of the banner servers in order to retrieve an image and a web link.
 void setTimerDelay(int delay)
          Sets the delay between two consecutive banners.
 
Methods inherited from class java.awt.Panel
getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RotatingBanner

public RotatingBanner()
Initializes the timer which calls a new banner every getTimerDelay seconds.
See Also:
getTimerDelay()
Method Detail

setApplet

public void setApplet(java.applet.Applet applet)
Specifies an applet to open any links where the images might point to. Whenever a mouse click is encountered on the active banner area, the applet displays the URL into another browsing window. Also, the link is shown in the status bar of the loading browser.
See Also:
getApplet()

getApplet

public java.applet.Applet getApplet()
If an applet has been specified in the setApplet method, then it returns its pointer.
See Also:
setApplet(java.applet.Applet)

setBackground

public void setBackground(java.awt.Color c)
Defines the background color that surrounds the image.
Overrides:
setBackground in class java.awt.Component
Parameters:
c - The background color

setDimensions

public void setDimensions(java.awt.Dimension dim)
Defines the minimum size this banner can have in a normal layout.
See Also:
getMinimumSize()

getMinimumSize

public java.awt.Dimension getMinimumSize()
Overrides:
getMinimumSize in class java.awt.Container

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class java.awt.Container

setTimerDelay

public void setTimerDelay(int delay)
Sets the delay between two consecutive banners.
Parameters:
delay - Time in seconds.
See Also:
getTimerDelay()

getTimerDelay

public int getTimerDelay()
Gets the delay between two consecurive banners.
Returns:
The delay in seconds

setRequestKey

public void setRequestKey(java.lang.String key)
The string to send to each of the banner servers in order to retrieve an image and a web link.
Parameters:
key - The key string
See Also:
getRequestKey()

getRequestKey

public java.lang.String getRequestKey()
Gets the request key to send to each of the banner servers.
Returns:
The key string.

setDefaultServer

public void setDefaultServer(java.lang.String defaultServer)
Defines the default server. This server will get 50 percent of the banners displayed.
Parameters:
defaultServer - A string representing the host name.
See Also:
getDefaultServer()

getDefaultServer

public java.lang.String getDefaultServer()
Gets the name of the default server.
Returns:
The string representing the host name of the server.

setDefaultPort

public void setDefaultPort(int defaultPort)
The port where to connect to the default banner server.
Parameters:
defaultPort - The integer representing the port number.
See Also:
getDefaultPort()

getDefaultPort

public int getDefaultPort()
Gets the port where the connection is made to the default banner server.
Returns:
The integer representing the port number.
See Also:
setDefaultPort(int)

addNotify

public void addNotify()
Overrides:
addNotify in class java.awt.Panel

removeNotify

public void removeNotify()
Overrides:
removeNotify in class java.awt.Container

setBannerFile

public void setBannerFile(java.lang.String bannerFileName)
This method provides a file where all the images are defined. It is a substitute in case you are unable to use a banner server or do not wish to. The format of the file is 'text' and reads the name of the image and that of the link, separated by a blank. If you have already defined a banner server list, then this file will not be used.
Parameters:
bannerFileName - The name of the text file that contains all images and links.

getBannerFile

public java.lang.String getBannerFile()
Returns the name of the banner file.
See Also:
setBannerFile(java.lang.String)

setDisplayFlag

public void setDisplayFlag(int flag)
Sets whether the image should be stretched or centered.

getDisplayFlag

public int getDisplayFlag()
See Also:
setDisplayFlag(int)

setBannerList

public void setBannerList(java.lang.String fileName)
Defines the additional servers wherefrom to load the banners. All of these servers are written inside a text file in the following format: each line contains the host name and the port number, separated by a blank space.
Parameters:
fileName - The URL of the banner-list file.
See Also:
addToBannerList(java.lang.String)

addToBannerList

public void addToBannerList(java.lang.String fileName)
Defines the additional servers wherefrom to load the banners and adds them to the existing list. All of these servers are written inside a text file in the following format: each line contains the host name and the port number, separated by a blank space.
Parameters:
fileName - The URL of the banner-list file.
See Also:
setBannerList(java.lang.String)

getNewBanner

public void getNewBanner()
Asks for a new banner to be displayed, according to the 50 percent algorithm.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener