: Class RSSViewerApplet


com.exploringxml.rss.applet
Class RSSViewerApplet

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--com.exploringxml.rss.applet.RSSViewerApplet

public class RSSViewerApplet
extends java.applet.Applet

Reads and displays Rich Site Summary (RSS) files; highly customizable look via applet parameters

currently depends on the Aelfred XML parser

See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
private  java.awt.Color boxBackground
           
private  int boxBorder
           
private  java.awt.Color boxForeground
           
private  boolean boxScroll
           
private  boolean boxScrollHorizontal
           
private  boolean boxScrollReverse
           
private  RSSChannel channel
           
private  int currentItem
           
private  java.lang.Exception initException
           
private  java.lang.String itemAlign
           
private  java.awt.Color itemBackground
           
private  java.awt.Color itemBackgroundOnMouseOver
           
private  java.awt.Font itemFont
           
private  java.lang.String itemFontFamily
           
private  int itemFontSize
           
private  int itemFontStyle
           
private  java.awt.Color itemForeground
           
private  java.awt.Color itemForegroundOnMouseOver
           
private  int itemLineBase
           
private  int itemLineHeight
           
private  int itemMargin
           
private  java.lang.String itemSeparator
           
private static int NO_CURRENT_ITEM
           
private  java.lang.String rssFileSrcURL
           
private static int TITLE_IS_CURRENT_ITEM
           
private  java.lang.String titleAlign
           
private  java.awt.Color titleBackground
           
private  java.awt.Color titleBackgroundOnMouseOver
           
private  java.awt.Font titleFont
           
private  java.lang.String titleFontFamily
           
private  int titleFontSize
           
private  int titleFontStyle
           
private  java.awt.Color titleForeground
           
private  java.awt.Color titleForegroundOnMouseOver
           
private  int titleLineBase
           
private  int titleLineHeight
           
 
Fields inherited from class java.applet.Applet
serialVersionUID, stub
 
Fields inherited from class java.awt.Panel
base, nameCounter, serialVersionUID
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, maxSize, ncomponents, serialVersionUID
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
RSSViewerApplet()
           
 
Method Summary
 void destroy()
          destroys applet
 java.lang.String getAppletInfo()
          gets applet's info
private  int getFontStyleParameter(java.lang.String key, java.lang.String defaultValue)
          gets a Font Style parameter from the applet's context
private  java.awt.Rectangle getItemBounds(int item)
          gets the bounding box of the corresponding item
private  int getItemFromCoordinates(int x, int y)
          gets the underlying item corresponding to the (x,y) coordinates
private  int getLineBase(java.awt.Font f)
          gets the base line of a Font
private  int getLineHeight(java.awt.Font font)
          gets the line height of a Font
private  boolean getParameter(java.lang.String key, boolean defaultValue)
          gets a boolean parameter from the applet's context
private  java.awt.Color getParameter(java.lang.String key, java.awt.Color defaultValue)
          gets a Color parameter from the applet's context
private  int getParameter(java.lang.String key, int defaultValue)
          gets an int parameter from the applet's context
private  java.lang.String getParameter(java.lang.String key, java.lang.String defaultValue)
          gets a String parameter from the applet's context
 java.lang.String[][] getParameterInfo()
          gets applet's parameter info
private  java.lang.String getPrunedString(java.lang.String line, java.awt.Font f, int width)
          gets a pruned version of a String to fit a certain width
private  int getStringStartPosX(java.lang.String line, java.awt.Font font, int width, java.lang.String align)
          gets the start pixel of a String with alignment
 void init()
          initializes applet
private  void initParameters()
          initializes applet's parameters by retrieving tags or setting defaults
 boolean mouseExit(java.awt.Event e, int x, int y)
          called on mouse exiting the applet
 boolean mouseMove(java.awt.Event e, int x, int y)
          called on mouse move
 boolean mouseUp(java.awt.Event e, int x, int y)
          called on mouse button up
private  void narrowBounds(java.awt.Rectangle bounds, int x, int y)
          narrows a bounding box Rectangle
 void paint(java.awt.Graphics g)
          paints applet
private  void paintBox(java.awt.Graphics g, java.awt.Rectangle bounds)
          paints the background box
private  void paintItem(java.awt.Graphics g, java.awt.Rectangle bounds, int item)
          paints a channel item
private  void paintLine(java.awt.Graphics g, java.awt.Rectangle bounds, java.awt.Color background, java.awt.Color backgroundOnMouseOver, java.awt.Color foreground, java.awt.Color foregroundOnMouseOver, java.lang.String line, java.awt.Font font, java.lang.String align, int item, int lineHeight, int lineBase)
          paints a line of text, either the title or an item
private  void paintTitle(java.awt.Graphics g, java.awt.Rectangle bounds)
          paints the RSS channel title
private  void showStatus()
          shows the applet's status
 void start()
          starts applet
 void stop()
          stops applet
 
Methods inherited from class java.applet.Applet
getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
, addNotify, constructComponentName
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyOrientation, countComponents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getCursorTarget, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, nextFocus, paintComponents, paramString, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printHeavyweightComponents, printOneComponent, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, readObject, remove, remove, removeAll, removeContainerListener, removeNotify, setCursor, setFocusOwner, setFont, setLayout, transferFocus, update, updateCursor, validate, validateTree, writeObject
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getIntrinsicCursor, getLocation, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, 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, registerNatives, wait, wait, wait
 

Field Detail

TITLE_IS_CURRENT_ITEM

private static final int TITLE_IS_CURRENT_ITEM

NO_CURRENT_ITEM

private static final int NO_CURRENT_ITEM

currentItem

private int currentItem

channel

private RSSChannel channel

initException

private java.lang.Exception initException

titleFont

private java.awt.Font titleFont

itemFont

private java.awt.Font itemFont

titleLineBase

private int titleLineBase

titleLineHeight

private int titleLineHeight

itemLineBase

private int itemLineBase

itemLineHeight

private int itemLineHeight

rssFileSrcURL

private java.lang.String rssFileSrcURL

boxForeground

private java.awt.Color boxForeground

boxBackground

private java.awt.Color boxBackground

boxBorder

private int boxBorder

boxScroll

private boolean boxScroll

boxScrollHorizontal

private boolean boxScrollHorizontal

boxScrollReverse

private boolean boxScrollReverse

titleForeground

private java.awt.Color titleForeground

titleBackground

private java.awt.Color titleBackground

titleForegroundOnMouseOver

private java.awt.Color titleForegroundOnMouseOver

titleBackgroundOnMouseOver

private java.awt.Color titleBackgroundOnMouseOver

titleFontFamily

private java.lang.String titleFontFamily

titleFontSize

private int titleFontSize

titleFontStyle

private int titleFontStyle

titleAlign

private java.lang.String titleAlign

itemForeground

private java.awt.Color itemForeground

itemBackground

private java.awt.Color itemBackground

itemForegroundOnMouseOver

private java.awt.Color itemForegroundOnMouseOver

itemBackgroundOnMouseOver

private java.awt.Color itemBackgroundOnMouseOver

itemFontFamily

private java.lang.String itemFontFamily

itemFontSize

private int itemFontSize

itemFontStyle

private int itemFontStyle

itemAlign

private java.lang.String itemAlign

itemMargin

private int itemMargin

itemSeparator

private java.lang.String itemSeparator
Constructor Detail

RSSViewerApplet

public RSSViewerApplet()
Method Detail

getParameter

private java.lang.String getParameter(java.lang.String key,
                                      java.lang.String defaultValue)
gets a String parameter from the applet's context
Parameters:
key - a String denoting the parameter's name
defaultValue - a String for parameters default value if key absent
Returns:
String denoting parameter's value, either retrieved or default

getParameter

private int getParameter(java.lang.String key,
                         int defaultValue)
gets an int parameter from the applet's context
Parameters:
key - a String denoting the parameter's name
defaultValue - an int for parameters default value if key absent
Returns:
int denoting parameter's value, either retrieved or default

getParameter

private boolean getParameter(java.lang.String key,
                             boolean defaultValue)
gets a boolean parameter from the applet's context
Parameters:
key - a String denoting the parameter's name
defaultValue - a boolean for parameters default value if key absent
Returns:
boolean denoting parameter's value, either retrieved or default

getParameter

private java.awt.Color getParameter(java.lang.String key,
                                    java.awt.Color defaultValue)
gets a Color parameter from the applet's context
Parameters:
key - a String denoting the parameter's name
defaultValue - a Color for parameters default value if key absent
Returns:
Color denoting parameter's value, either retrieved or default

getFontStyleParameter

private int getFontStyleParameter(java.lang.String key,
                                  java.lang.String defaultValue)
gets a Font Style parameter from the applet's context
Parameters:
key - a String denoting the parameter's name
defaultValue - a String for parameters default font style if key absent
Returns:
int denoting parameter's font style, either retrieved or default

initParameters

private void initParameters()
initializes applet's parameters by retrieving tags or setting defaults

init

public void init()
initializes applet
Overrides:
init in class java.applet.Applet
See Also:
Applet.init()

start

public void start()
starts applet
Overrides:
start in class java.applet.Applet
See Also:
Applet.start()

stop

public void stop()
stops applet
Overrides:
stop in class java.applet.Applet
See Also:
Applet.stop()

destroy

public void destroy()
destroys applet
Overrides:
destroy in class java.applet.Applet
See Also:
Applet.destroy()

getAppletInfo

public java.lang.String getAppletInfo()
gets applet's info
Overrides:
getAppletInfo in class java.applet.Applet
See Also:
Applet.getAppletInfo()

getParameterInfo

public java.lang.String[][] getParameterInfo()
gets applet's parameter info
Overrides:
getParameterInfo in class java.applet.Applet
See Also:
Applet.getParameterInfo()

paint

public void paint(java.awt.Graphics g)
paints applet
Overrides:
paint in class java.awt.Container
See Also:
Container.paint(java.awt.Graphics)

paintBox

private void paintBox(java.awt.Graphics g,
                      java.awt.Rectangle bounds)
paints the background box
Parameters:
g - Graphics for painting
bounds - Rectangle to paint inside

paintTitle

private void paintTitle(java.awt.Graphics g,
                        java.awt.Rectangle bounds)
paints the RSS channel title
Parameters:
g - Graphics for painting
bounds - Rectangle to paint inside

paintItem

private void paintItem(java.awt.Graphics g,
                       java.awt.Rectangle bounds,
                       int item)
paints a channel item
Parameters:
g - Graphics for painting
bounds - Rectangle to paint inside
item - the item to paint

paintLine

private void paintLine(java.awt.Graphics g,
                       java.awt.Rectangle bounds,
                       java.awt.Color background,
                       java.awt.Color backgroundOnMouseOver,
                       java.awt.Color foreground,
                       java.awt.Color foregroundOnMouseOver,
                       java.lang.String line,
                       java.awt.Font font,
                       java.lang.String align,
                       int item,
                       int lineHeight,
                       int lineBase)
paints a line of text, either the title or an item
Parameters:
g - Graphics for painting
bounds - Rectangle to paint inside
background - the background color
backgroundOnMouseOver - the highlighted background color
foreground - the foreground color
foregroundOnMouseOver - the highlighted foreground color
line - the text line to paint
font - the font to paint the text line in
align - the alignment to paint the text line with
item - the item number of this line in the channel, to decide about highlighting
lineHeight - the height of this line as determined by the font
lineBase - the base line of this line as determined by the font

showStatus

private void showStatus()
shows the applet's status
See Also:
Applet.showStatus(java.lang.String)

mouseUp

public boolean mouseUp(java.awt.Event e,
                       int x,
                       int y)
called on mouse button up
Overrides:
mouseUp in class java.awt.Component
See Also:
Component.mouseUp(java.awt.Event, int, int)

mouseExit

public boolean mouseExit(java.awt.Event e,
                         int x,
                         int y)
called on mouse exiting the applet
Overrides:
mouseExit in class java.awt.Component
See Also:
Component.mouseExit(java.awt.Event, int, int)

mouseMove

public boolean mouseMove(java.awt.Event e,
                         int x,
                         int y)
called on mouse move
Overrides:
mouseMove in class java.awt.Component
See Also:
Component.mouseMove(java.awt.Event, int, int)

getItemFromCoordinates

private int getItemFromCoordinates(int x,
                                   int y)
gets the underlying item corresponding to the (x,y) coordinates
Parameters:
x - the horizontal coordinate
y - the vertical coordinate
Returns:
the item position

getItemBounds

private java.awt.Rectangle getItemBounds(int item)
gets the bounding box of the corresponding item
Parameters:
item - the RSS channel item number
Returns:
the bounding box Rectangle

narrowBounds

private void narrowBounds(java.awt.Rectangle bounds,
                          int x,
                          int y)
narrows a bounding box Rectangle
Parameters:
bounds - the Rectangle to narrow
x - the number of horizontal pixels
y - the number of vertical pixels

getLineHeight

private int getLineHeight(java.awt.Font font)
gets the line height of a Font
Parameters:
font - the Font to measure
Returns:
the line height in pixels

getLineBase

private int getLineBase(java.awt.Font f)
gets the base line of a Font
Parameters:
font - the Font to measure
Returns:
the base line in pixels

getPrunedString

private java.lang.String getPrunedString(java.lang.String line,
                                         java.awt.Font f,
                                         int width)
gets a pruned version of a String to fit a certain width
Parameters:
line - the String to prune
font - the Font to use
width - the width to prune to
Returns:
the pruned String

getStringStartPosX

private int getStringStartPosX(java.lang.String line,
                               java.awt.Font font,
                               int width,
                               java.lang.String align)
gets the start pixel of a String with alignment
Parameters:
line - the String to prune
font - the Font to use
width - the width available in pixels
align - the alignment to use
Returns:
the start position in horizontal pixels