org.lyra.Widgets
Class TickerSimpleLabel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JLabel
                  extended by org.lyra.Widgets.TickerSimpleLabel
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.SwingConstants

public class TickerSimpleLabel
extends javax.swing.JLabel
implements java.awt.event.ActionListener

Provides a ticker tape capability to the javax.swing.JLabel display in order to permit them to display larger strings then they are physically able to display.

This variant is more efficient in situations where the display is not double buffered. However it will make its movements based on characters which may be more jarring an effect.

Version:
1.0.5, %Revision, 174%, %LastChangedDate, 27/10/12 3:33PM%
Author:
Martin Foster
See Also:
TickerBufferedLabel, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JLabel
javax.swing.JLabel.AccessibleJLabel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private static int BUFFER
           
private static int INITIAL_DELAY
           
private  int[] myCounts
           
private  int myHeight
           
private  int myLimit
           
private  int myPosition
           
private  java.lang.String mySeparator
           
private  char[] myString
           
private  javax.swing.Timer myTimer
           
private  int myWidth
           
private static int NORMAL_DELAY
           
private  boolean Reprocess
           
private static long serialVersionUID
           
private  java.lang.String tempString
           
 
Fields inherited from class javax.swing.JLabel
labelFor
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TickerSimpleLabel()
          Base constructor which initialises none of the elements.
TickerSimpleLabel(java.lang.String msg)
          Constructor which takes the initial message as the base.
TickerSimpleLabel(java.lang.String msg, java.awt.Font font)
          Constructor which takes the initial message and font for use as the base.
TickerSimpleLabel(java.lang.String msg, java.awt.Font font, int limit)
          Constructor which takes the initial message, font and limit for use as the base.
TickerSimpleLabel(java.lang.String msg, int limit)
          Constructor which takes the initial message and limit for use as the base.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
           
private  void fetchMetrics()
          Makes use of the FontMetrics methods to establish sizing elements in order to determine the needs for ticker functionality.
private  void fetchMetrics(java.awt.FontMetrics metrics)
          Makes use of the FontMetrics methods to establish sizing elements in order to determine the needs for ticker functionality.
private  void fetchMetrics(java.awt.Graphics g)
          Makes use of the FontMetrics methods to establish sizing elements in order to determine the needs for ticker functionality.
private  void fetchRedraw()
          Determines the requirement for the timer process to exist and process information.
private  void fetchSizes()
          Extracts the size of every character in the text to display in order to determine exactly how many characters can be displayed on the available space.
private  void fetchSizes(java.awt.FontMetrics metrics)
          Extracts the size of every character in the text to display in order to determine exactly how many characters can be displayed on the available space.
private  void fetchSizes(java.awt.Graphics g)
          Extracts the size of every character in the text to display in order to determine exactly how many characters can be displayed on the available space.
 int getHeight()
           
 int getLimit()
          Returns the established limit for message displays.
 java.lang.String getSeparator()
          Gets the separator section used to re-introduce the beginning of the string.
 java.lang.String getText()
           
 int getWidth()
           
 void paintComponent(java.awt.Graphics g)
           
 void setBorder(javax.swing.border.Border border)
           
 void setFont(java.awt.Font font)
           
 void setLimit(int limit)
          Establishes the limit for message display.
 void setMaximumSize(java.awt.Dimension maximumSize)
           
 void setMinimumSize(java.awt.Dimension minimumSize)
           
 void setPreferredSize(java.awt.Dimension preferredSize)
           
 void setSeparator(java.lang.String sep)
          Sets the separator section used to re-introduce the beginning of the string.
 void setText(java.lang.String msg)
           
 
Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

tempString

private java.lang.String tempString

myString

private char[] myString

myCounts

private int[] myCounts

myHeight

private int myHeight

myWidth

private int myWidth

myLimit

private int myLimit

myPosition

private int myPosition

Reprocess

private boolean Reprocess

myTimer

private javax.swing.Timer myTimer

mySeparator

private java.lang.String mySeparator

BUFFER

private static final int BUFFER
See Also:
Constant Field Values

INITIAL_DELAY

private static final int INITIAL_DELAY
See Also:
Constant Field Values

NORMAL_DELAY

private static final int NORMAL_DELAY
See Also:
Constant Field Values
Constructor Detail

TickerSimpleLabel

public TickerSimpleLabel()
Base constructor which initialises none of the elements.


TickerSimpleLabel

public TickerSimpleLabel(java.lang.String msg)
Constructor which takes the initial message as the base.

Parameters:
msg - String message for display in ticker format.

TickerSimpleLabel

public TickerSimpleLabel(java.lang.String msg,
                         java.awt.Font font)
Constructor which takes the initial message and font for use as the base.

Parameters:
msg - String message for display in ticker format.
font - Font for display.

TickerSimpleLabel

public TickerSimpleLabel(java.lang.String msg,
                         java.awt.Font font,
                         int limit)
Constructor which takes the initial message, font and limit for use as the base.

Parameters:
msg - String message for display in ticker format.
font - Font for display.
limit - Maximum width which will lead to a ticker incident.

TickerSimpleLabel

public TickerSimpleLabel(java.lang.String msg,
                         int limit)
Constructor which takes the initial message and limit for use as the base.

Parameters:
msg - String message for display in ticker format.
limit - Maximum width which will lead to a ticker incident.
Method Detail

fetchMetrics

private void fetchMetrics(java.awt.FontMetrics metrics)
Makes use of the FontMetrics methods to establish sizing elements in order to determine the needs for ticker functionality.

Parameters:
metrics - FontMetrics handle for information.

fetchMetrics

private void fetchMetrics()
Makes use of the FontMetrics methods to establish sizing elements in order to determine the needs for ticker functionality.


fetchMetrics

private void fetchMetrics(java.awt.Graphics g)
Makes use of the FontMetrics methods to establish sizing elements in order to determine the needs for ticker functionality.

Parameters:
g - java.awt.Graphics handle for display.

fetchSizes

private void fetchSizes(java.awt.FontMetrics metrics)
Extracts the size of every character in the text to display in order to determine exactly how many characters can be displayed on the available space.

Parameters:
metrics - Metrics processing capability to use for the calculation.

fetchSizes

private void fetchSizes()
Extracts the size of every character in the text to display in order to determine exactly how many characters can be displayed on the available space.


fetchSizes

private void fetchSizes(java.awt.Graphics g)
Extracts the size of every character in the text to display in order to determine exactly how many characters can be displayed on the available space.

Parameters:
g - Graphics handle for extracting screen metrics.

fetchRedraw

private void fetchRedraw()
Determines the requirement for the timer process to exist and process information.


setText

public void setText(java.lang.String msg)
Overrides:
setText in class javax.swing.JLabel

getText

public java.lang.String getText()
Overrides:
getText in class javax.swing.JLabel

setBorder

public void setBorder(javax.swing.border.Border border)
Overrides:
setBorder in class javax.swing.JComponent

setFont

public void setFont(java.awt.Font font)
Overrides:
setFont in class javax.swing.JComponent

setLimit

public void setLimit(int limit)
Establishes the limit for message display. Any item sized less then the message will not be displayed.

Parameters:
limit - Display limit for the message.

setSeparator

public void setSeparator(java.lang.String sep)
Sets the separator section used to re-introduce the beginning of the string.

Parameters:
sep - String containing separator section.

getSeparator

public java.lang.String getSeparator()
Gets the separator section used to re-introduce the beginning of the string.

Returns:
String containing separator section.

getLimit

public int getLimit()
Returns the established limit for message displays. Anything under the limit will not shift in position.

Returns:
Integer containing the display limit for the message.

getWidth

public int getWidth()
Overrides:
getWidth in class javax.swing.JComponent

getHeight

public int getHeight()
Overrides:
getHeight in class javax.swing.JComponent

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

setMinimumSize

public void setMinimumSize(java.awt.Dimension minimumSize)
Overrides:
setMinimumSize in class javax.swing.JComponent

setPreferredSize

public void setPreferredSize(java.awt.Dimension preferredSize)
Overrides:
setPreferredSize in class javax.swing.JComponent

setMaximumSize

public void setMaximumSize(java.awt.Dimension maximumSize)
Overrides:
setMaximumSize in class javax.swing.JComponent