com.mamarce.mhp.mf.components
Class ScrollableText

java.lang.Object
  extended by java.awt.Component
      extended by com.mamarce.mhp.mf.components.ScrollableText
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class ScrollableText
extends java.awt.Component

ScrollableText.java A text component that can function as a stand-alone scrollable test displayer. Contains the neccessary methods for processing user input.

See Also:
Serialized Form

Field Summary
static int ALIGN_BOTTOM
          Align bottom.
static int ALIGN_CENTER
          Align center.
static int ALIGN_LEFT
          Align left.
static int ALIGN_RIGHT
          Align right.
static int ALIGN_TOP
          Align top.
static int DIR_DOWN
          Directional constants.
static int DIR_UP
          Directional constants.
static int POS_BEGINNING
          Position tokens.
static int POS_END
          Position tokens.
static int SIDESCROLLER_ALWAYS
          The sidescroller show-policy: sidescrolleer will be always shown.
static int SIDESCROLLER_AS_NEEDED
          The sidescroller show-policy: sidescrolleer will be shown onnly if necessary.
static int SIDESCROLLER_NEVER
          The sidescroller show- policy: sidescrolleer will be never shown.
 
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
ScrollableText(java.awt.Insets insets, int hAlign, int vAlign, int scrollerPolicy)
          The complete constructors.
 
Method Summary
 int getCurrentPage()
           
 int getHiddenBottomScrollBlocks()
          Returns the number of hidden rows below the visible area.
 int getHiddenTopScrollBlocks()
          Returns the number of hidden rows above the visible area.
 int getNumberOfPages()
           
 int getTotalScrollBlocks()
          Returns the total number of rows contained within the object.
 int getVisibleScrollBlocks()
          Returns the total number of rows that fits within the components boundaries.
 void jumpTo(int position)
          Jumps to the given position (in rows) within the contents.
 void paint(java.awt.Graphics g)
          Paints the text.
 void scrollContents(int direction)
          Scrolls the component one scrollunit in the given direction.
 void scrollPage(int direction)
          Scrolls the component one visible page (if available) in the given direction.
 void setBackground(java.awt.Color bg)
          Sets the background of the text - supports transparent by providing null.
 void setFont(java.awt.Font font)
          Changes the font of this component.
 void setHorizontalAlignment(int alignment)
          Changes the horizontal alignment of this component.
 void setPresentation(int x, int y, int width, int height, int hAlign, int vAlign, java.lang.String txt)
          Changes multiple properties of this component.
 void setScrollerColors(java.awt.Color bg, java.awt.Color tabBg, java.awt.Color activeArrow, java.awt.Color inactiveArrow, java.awt.Color arrowOutline, java.awt.Color highlight, java.awt.Color shadow)
          Sets the color scheme for the sidescroller.
 void setScrollRows(int rows)
          Sets the number or rows the component should be scrolled by with each scroll.
 void setSize(java.awt.Dimension dim)
          Changes the size of this component.
 void setSize(int width, int height)
          Changes the size of this component.
 void setText(java.lang.String txt)
          Changes the text within this component.
 void setVerticalAlignment(int alignment)
          Changes the vertical alignment of this component.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALIGN_LEFT

public static final int ALIGN_LEFT
Align left.

See Also:
Constant Field Values

ALIGN_RIGHT

public static final int ALIGN_RIGHT
Align right.

See Also:
Constant Field Values

ALIGN_CENTER

public static final int ALIGN_CENTER
Align center.

See Also:
Constant Field Values

ALIGN_TOP

public static final int ALIGN_TOP
Align top.

See Also:
Constant Field Values

ALIGN_BOTTOM

public static final int ALIGN_BOTTOM
Align bottom.

See Also:
Constant Field Values

DIR_UP

public static final int DIR_UP
Directional constants. Up direction.

See Also:
Constant Field Values

DIR_DOWN

public static final int DIR_DOWN
Directional constants. Down direction.

See Also:
Constant Field Values

POS_BEGINNING

public static final int POS_BEGINNING
Position tokens. Beginning.

See Also:
Constant Field Values

POS_END

public static final int POS_END
Position tokens. End.

See Also:
Constant Field Values

SIDESCROLLER_ALWAYS

public static final int SIDESCROLLER_ALWAYS
The sidescroller show-policy: sidescrolleer will be always shown.

See Also:
Constant Field Values

SIDESCROLLER_NEVER

public static final int SIDESCROLLER_NEVER
The sidescroller show- policy: sidescrolleer will be never shown.

See Also:
Constant Field Values

SIDESCROLLER_AS_NEEDED

public static final int SIDESCROLLER_AS_NEEDED
The sidescroller show-policy: sidescrolleer will be shown onnly if necessary.

See Also:
Constant Field Values
Constructor Detail

ScrollableText

public ScrollableText(java.awt.Insets insets,
                      int hAlign,
                      int vAlign,
                      int scrollerPolicy)
The complete constructors. Additional information should be set using the default java.awt.Component methods; setFont(), setForeground(), setBackground(), setSize(), setLocation();

Parameters:
insets - The margins
hAlign - The horizontal alignment of the text
vAlign - The vertical alignment of the text
scrollerPolicy - The sidescroller policy
Method Detail

setText

public void setText(java.lang.String txt)
Changes the text within this component.

Parameters:
txt - text content.

setSize

public void setSize(int width,
                    int height)
Changes the size of this component.

Overrides:
setSize in class java.awt.Component
Parameters:
width - width.
height - height.

setSize

public void setSize(java.awt.Dimension dim)
Changes the size of this component.

Overrides:
setSize in class java.awt.Component
Parameters:
dim - dimensions.

setFont

public void setFont(java.awt.Font font)
Changes the font of this component.

Overrides:
setFont in class java.awt.Component
Parameters:
font - font.

setBackground

public void setBackground(java.awt.Color bg)
Sets the background of the text - supports transparent by providing null.

Overrides:
setBackground in class java.awt.Component
Parameters:
bg - backgroundColor.

setScrollerColors

public void setScrollerColors(java.awt.Color bg,
                              java.awt.Color tabBg,
                              java.awt.Color activeArrow,
                              java.awt.Color inactiveArrow,
                              java.awt.Color arrowOutline,
                              java.awt.Color highlight,
                              java.awt.Color shadow)
Sets the color scheme for the sidescroller.

Parameters:
bg - backgrouncolor.
tabBg - tab color.
activeArrow - active arrow color.
inactiveArrow - inactive arrow color.
arrowOutline - outline arrow color.
highlight - highlight color.
shadow - shadow color.

setPresentation

public void setPresentation(int x,
                            int y,
                            int width,
                            int height,
                            int hAlign,
                            int vAlign,
                            java.lang.String txt)
Changes multiple properties of this component.

Parameters:
x - x coordiate.
y - y coordinate.
width - width.
height - height.
hAlign - horizzontal align.
vAlign - vertival align.
txt - The text to be contained within the component. If null, the old text will be preserved.

setHorizontalAlignment

public void setHorizontalAlignment(int alignment)
Changes the horizontal alignment of this component.

Parameters:
alignment - One of the Horizontal alignment constants; ALIGN_LEFT ALIGN_RIGHT ALIGN_CENTER.

setVerticalAlignment

public void setVerticalAlignment(int alignment)
Changes the vertical alignment of this component.

Parameters:
alignment - One of the Vertical alignment constants; ALIGN_TOP ALIGN_BOTTOM ALIGN_CENTER.

setScrollRows

public void setScrollRows(int rows)
Sets the number or rows the component should be scrolled by with each scroll.

Parameters:
rows - The number of rows

scrollContents

public void scrollContents(int direction)
Scrolls the component one scrollunit in the given direction.

Parameters:
direction - The direction; DIR_UP, DIR_DOWN

scrollPage

public void scrollPage(int direction)
Scrolls the component one visible page (if available) in the given direction.

Parameters:
direction - The direction of the scroll

jumpTo

public void jumpTo(int position)
Jumps to the given position (in rows) within the contents.

Parameters:
position - The position, or a special code: POS_BEGINNING, POS_END

getNumberOfPages

public int getNumberOfPages()

getCurrentPage

public int getCurrentPage()

getTotalScrollBlocks

public int getTotalScrollBlocks()
Returns the total number of rows contained within the object.

Returns:
The total number of rows

getVisibleScrollBlocks

public int getVisibleScrollBlocks()
Returns the total number of rows that fits within the components boundaries.

Returns:
The number of visible rows

getHiddenTopScrollBlocks

public int getHiddenTopScrollBlocks()
Returns the number of hidden rows above the visible area.

Returns:
The number of not- visible, scrolled by rows

getHiddenBottomScrollBlocks

public int getHiddenBottomScrollBlocks()
Returns the number of hidden rows below the visible area.

Returns:
The number of hidden, unviewed rows

paint

public void paint(java.awt.Graphics g)
Paints the text.

Overrides:
paint in class java.awt.Component
Parameters:
g - Graphics