PenProfile 2.x

com.livescribe.ui
Class ScrollLabel

java.lang.Object
  extended by com.livescribe.display.Displayable
      extended by com.livescribe.display.Canvas
          extended by com.livescribe.ui.ScrollLabel
All Implemented Interfaces:
HorizontalFlickScrub
Direct Known Subclasses:
DateIndicator, DiskUsageIndicator, TimeIndicator

public class ScrollLabel
extends Canvas
implements HorizontalFlickScrub

ScrollLabel allows both text and images to be displayed on the screen. It also supports scrolling of the content horizontally.


Field Summary
static long DEFAULT_ANIMATION_DELAY
          Default animation delay : Set to 50L
static int DEFAULT_SHIFT_WIDTH
          Default Shift Width in pixels : Set to 1 Number of pixels to shift while scrolling
static int DEFAULT_SPACE_WIDTH
          Default Space Width in pixels : Set to 10 Space between the end of the content and the start of the content while scrolling.
protected  int displayableWidth
           
protected  Font font
           
static int SCROLL_UNIT_MILLIS
           
protected  int shiftWidth
          Number of pixels to shift while scrolling
protected  int spaceWidth
          Space between the end of the content and the start of the content while scrolling.
protected  Timer timer
           
 
Constructor Summary
ScrollLabel()
          Construct ScrollLable This constructs a ScrollLabel with the following defaults Animation delay : Repaint delay is set at 50L Space Width : width in terms of pixels that is used to space the end of the content and the beginning of the content while scrolling is set to 10 Shift Width : This is the width in terms of pixels that is used to shift the contents of the label is set to 1
ScrollLabel(long animDelay, int spaceWidth, int shiftWidth)
          Construct TextOutput
 
Method Summary
protected  void cancelFlickRepaintTask()
           
protected  void cancelRepaintTask()
           
 void draw(AttributedText attrText, boolean scroll)
          Draws the attributed text on the label.
 void draw(AttributedText attrText, Image image, int x, int y, int width, int height, boolean scroll)
           
 void draw(DisplayableResource res)
          Draw a DisplayableResource on the Scroll Label
 void draw(DisplayableResource res, boolean scroll)
          Draw a DisplayableResource on the Scroll Label and specify if it needs to be scrolled
 void draw(DisplayableResource res, int x, int y, boolean scroll)
           
 void draw(DisplayableResource res, int x, int y, int width, int height, boolean scroll)
           
 void draw(Image image, String text, boolean scroll)
          Draws the image followed by the text.
 void draw(Image image, String text, int x, int y, int width, int height, boolean scroll)
          Draws the image and the text at the specified x,y, width and height
 void draw(String text)
          Draw the text without scrolling.
 void draw(String text, boolean scroll)
          Draw the text.
 void draw(String text, Image image, boolean scroll)
          Draws the text followed by the image.
 void draw(String text, Image image, int x, int y, int width, int height, boolean scroll)
          Draws the text and the image at the specified x,y, width and height
 void draw(String text, int x, int y, boolean scroll)
           
 void draw(String text, int x, int y, int width, int height, boolean scroll)
           
 void drawRightJustified(AttributedText attrText)
           
 void drawRightJustified(String text)
          Draws the text with the alignment at the right
 void enableFlickScrub(boolean enable)
          Flick n Scrub should be disabled if you want to process hand writting recognition while this controll is visible
 void flickHorizontally(int deltaX)
           
protected  int getContentWidth()
           
protected  int getOffset()
           
protected  int getShiftWidth()
           
protected  int getViewportWidth()
           
 boolean hasScrollableContent()
          Indicates if the content that is supposed to be rendered by the label is scrollable or not.
 boolean isHorizontalFlickScrubEnabled()
           
protected  boolean isPauseEnabled()
           
protected  boolean isWrapEnabled()
           
protected  void notifyHidden(Display d)
          When called indicates that this Displayable is no longer shown on the display device due to another Displayable being set to current.
protected  boolean notifyScrollingPausedAtEnd()
          If the label scrolls content, this method would be called when the content is paused at the end.
protected  boolean notifyScrollingPausedAtStart()
          If the label scrolls content, this method would be called when the content is paused at the start.
protected  void notifyShown(Display d)
          When called by the system indicates that this Canvas is current.
protected  boolean onResize(int w)
           
protected  void paint(Graphics g)
          Invoked by the system to allow the Displayable to render contents using the graphics context.
protected  void scheduleFlickRepaintTask()
           
protected  void scheduleRepaintTask()
           
 void scrubHorizontally(int deltaX)
           
protected  void setContent(AttributedText attrText, Image image, int x, int y, int width, int height, boolean scroll, boolean renderTextFirst)
          Creates scrolling data or fixed data or both with the following params
 void setFont(Font font)
           
protected  void setViewportWidth(int width)
          Sets the width of the viewport which is the entire scrollable region of data that is viewed through a window.
 void stopScrolling()
          Stops the scrolling of content if the label is currently scrolling.
 
Methods inherited from class com.livescribe.display.Canvas
repaint
 
Methods inherited from class com.livescribe.display.Displayable
getSurface, isCurrent, notifySystemTrayHidden, notifySystemTrayShown
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ANIMATION_DELAY

public static final long DEFAULT_ANIMATION_DELAY
Default animation delay : Set to 50L

See Also:
Constant Field Values

DEFAULT_SPACE_WIDTH

public static final int DEFAULT_SPACE_WIDTH
Default Space Width in pixels : Set to 10 Space between the end of the content and the start of the content while scrolling.

See Also:
Constant Field Values

DEFAULT_SHIFT_WIDTH

public static final int DEFAULT_SHIFT_WIDTH
Default Shift Width in pixels : Set to 1 Number of pixels to shift while scrolling

See Also:
Constant Field Values

SCROLL_UNIT_MILLIS

public static final int SCROLL_UNIT_MILLIS
See Also:
Constant Field Values

timer

protected Timer timer

spaceWidth

protected int spaceWidth
Space between the end of the content and the start of the content while scrolling.


shiftWidth

protected int shiftWidth
Number of pixels to shift while scrolling


font

protected Font font

displayableWidth

protected int displayableWidth
Constructor Detail

ScrollLabel

public ScrollLabel()
Construct ScrollLable This constructs a ScrollLabel with the following defaults Animation delay : Repaint delay is set at 50L Space Width : width in terms of pixels that is used to space the end of the content and the beginning of the content while scrolling is set to 10 Shift Width : This is the width in terms of pixels that is used to shift the contents of the label is set to 1


ScrollLabel

public ScrollLabel(long animDelay,
                   int spaceWidth,
                   int shiftWidth)
Construct TextOutput

Parameters:
animDelay - animation delay in milliseconds. This is used when the text is scrolled.
spaceWidth - this is width in terms of pixels that is used to space the end of the content and the beginning of the content while scrolling
shiftWidth - this is the width in terms of pixels that is used to shift the contents of the label.
Method Detail

getOffset

protected int getOffset()

getContentWidth

protected int getContentWidth()

getViewportWidth

protected int getViewportWidth()

isPauseEnabled

protected boolean isPauseEnabled()

isWrapEnabled

protected boolean isWrapEnabled()

paint

protected void paint(Graphics g)
Description copied from class: Displayable
Invoked by the system to allow the Displayable to render contents using the graphics context.

Specified by:
paint in class Displayable
Parameters:
g - the Graphics context to be used to render on the Displayable.

setViewportWidth

protected void setViewportWidth(int width)
Sets the width of the viewport which is the entire scrollable region of data that is viewed through a window.

Parameters:
width - this is width of the viewport

drawRightJustified

public void drawRightJustified(AttributedText attrText)

drawRightJustified

public void drawRightJustified(String text)
Draws the text with the alignment at the right

Parameters:
text - text that needs to be displayed on the scroll label

draw

public void draw(AttributedText attrText,
                 boolean scroll)
Draws the attributed text on the label.

Parameters:
attrText - attributed text to draw
scroll - true scroll the attributed text if it spans out of the viewport and false not to scroll.
Since:
0.5

draw

public void draw(DisplayableResource res)
Draw a DisplayableResource on the Scroll Label

Parameters:
res - - The DisplayableResource that needs to be rendered
Since:
0.4

draw

public void draw(String text)
Draw the text without scrolling. This is equivalent to calling draw(text, false).

Parameters:
text - text to render

draw

public void draw(DisplayableResource res,
                 boolean scroll)
Draw a DisplayableResource on the Scroll Label and specify if it needs to be scrolled

Parameters:
res - - The DisplayableResource that needs to be rendered
scroll - indicates if the text has to be scrolled or not. It does not have any effect of the text fits within the display size. true if it needs to scroll and false otherwise
Since:
0.4

draw

public void draw(String text,
                 boolean scroll)
Draw the text.

Parameters:
text - text to render
scroll - indicates if the text has to be scrolled or not. It does not have any effect of the text fits within the display size. true if it needs to scroll and false otherwise

draw

public void draw(DisplayableResource res,
                 int x,
                 int y,
                 boolean scroll)
Parameters:
res - - The DisplaybleResource that needs to be rendered
x - - The 'x' coordinate
y - - The 'y' coordinate
scroll - true if it needs to scroll and false otherwise
Since:
0.4

draw

public void draw(String text,
                 int x,
                 int y,
                 boolean scroll)
Parameters:
text - - The text that needs to be rendered
x - - The 'x' coordinate
y - - The 'y' coordinate
scroll - true if it needs to scroll and false otherwise
Since:
0.4

draw

public void draw(DisplayableResource res,
                 int x,
                 int y,
                 int width,
                 int height,
                 boolean scroll)
Parameters:
res - - The DisplaybleResource that needs to be rendered
x - - The 'x' coordinate
y - - The 'y' coordinate
width - - draw with the specified width
height - - draw with the specified height
scroll - true if it needs to scroll and false otherwise
Since:
0.4

draw

public void draw(String text,
                 int x,
                 int y,
                 int width,
                 int height,
                 boolean scroll)
Parameters:
text - the text that needs to be rendered
x - the 'x' coordinate
y - the 'y' coordinate
width - draw with the specified width
height - draw with the specified height
scroll - true if it needs to scroll and false otherwise
Since:
0.4

draw

public void draw(String text,
                 Image image,
                 boolean scroll)
Draws the text followed by the image.

Parameters:
text - text to render
image - image to render
scroll - indicates if the text and image has to be scrolled or not. It does not have any effect of the text and image fits within the display size.

draw

public void draw(Image image,
                 String text,
                 boolean scroll)
Draws the image followed by the text.

Parameters:
text - text to render
image - image to render
scroll - indicates if the text and image has to be scrolled or not. It does not have any effect of the text and image fits within the display size.

draw

public void draw(String text,
                 Image image,
                 int x,
                 int y,
                 int width,
                 int height,
                 boolean scroll)
Draws the text and the image at the specified x,y, width and height

Parameters:
text - to render
image - to render
x - draw at the specified x value
y - draw at the specified y value
width - draw with the specified width
height - draw with the specified height
scroll - indicates if the text and image has to be scrolled or not.

draw

public void draw(AttributedText attrText,
                 Image image,
                 int x,
                 int y,
                 int width,
                 int height,
                 boolean scroll)

draw

public void draw(Image image,
                 String text,
                 int x,
                 int y,
                 int width,
                 int height,
                 boolean scroll)
Draws the image and the text at the specified x,y, width and height

Parameters:
image - to render
text - to render
x - draw at the specified x value
y - draw at the specified y value
width - draw with the specified width
height - draw with the specified height
scroll - indicates if the text and image has to be scrolled or not.

setFont

public void setFont(Font font)

hasScrollableContent

public final boolean hasScrollableContent()
Indicates if the content that is supposed to be rendered by the label is scrollable or not. The event notifyScrollingPausedAtStart() and notifyScrollingPausedAtEnd() are delivered only if this returns true

Returns:
true if the content is scrollable and false if the content is static and not scrollable
Since:
0.4

stopScrolling

public void stopScrolling()
Stops the scrolling of content if the label is currently scrolling.

Since:
0.4

setContent

protected void setContent(AttributedText attrText,
                          Image image,
                          int x,
                          int y,
                          int width,
                          int height,
                          boolean scroll,
                          boolean renderTextFirst)
Creates scrolling data or fixed data or both with the following params

Parameters:
attrText - text to render
image - image to render
x - draw at the specified x value
y - draw at the specified y value
width - draw with the specified width
height - draw with the specified height
scroll - indicates if the text and image has to be scrolled or not.
renderTextFirst - if the text shall be rendered first

onResize

protected boolean onResize(int w)

notifyShown

protected void notifyShown(Display d)
When called by the system indicates that this Canvas is current.

Overrides:
notifyShown in class Displayable
Parameters:
d - The Display on which this Canvas is current.

notifyHidden

protected void notifyHidden(Display d)
When called indicates that this Displayable is no longer shown on the display device due to another Displayable being set to current.

Overrides:
notifyHidden in class Displayable
Parameters:
d - The Display on which this Canvas is current.

cancelRepaintTask

protected void cancelRepaintTask()

scheduleRepaintTask

protected void scheduleRepaintTask()

notifyScrollingPausedAtStart

protected boolean notifyScrollingPausedAtStart()
If the label scrolls content, this method would be called when the content is paused at the start. If subclass overrided this method to get notified, then it should not perform activities that are time consuming in this method.

Returns:
true if scrolling should terminate and false (the default) if scrolling should continue after pausing.
Since:
0.2

notifyScrollingPausedAtEnd

protected boolean notifyScrollingPausedAtEnd()
If the label scrolls content, this method would be called when the content is paused at the end. If subclass overrided this method to get notified, then it should not perform activities that are time consuming in this method.

Returns:
true if scrolling should terminate and false (the default) if scrolling should continue after pausing.
Since:
0.2

scrubHorizontally

public void scrubHorizontally(int deltaX)
Specified by:
scrubHorizontally in interface HorizontalFlickScrub

flickHorizontally

public void flickHorizontally(int deltaX)
Specified by:
flickHorizontally in interface HorizontalFlickScrub

enableFlickScrub

public void enableFlickScrub(boolean enable)
Flick n Scrub should be disabled if you want to process hand writting recognition while this controll is visible

Parameters:
enable -

isHorizontalFlickScrubEnabled

public boolean isHorizontalFlickScrubEnabled()
Specified by:
isHorizontalFlickScrubEnabled in interface HorizontalFlickScrub

getShiftWidth

protected int getShiftWidth()

scheduleFlickRepaintTask

protected void scheduleFlickRepaintTask()

cancelFlickRepaintTask

protected void cancelFlickRepaintTask()

PenProfile 2.x

Copyright © 2010 Livescribe Inc. All Rights Reserved.
Confidential and subject to NDA.