org.deken.game.component
Class GScrollingParagraph

java.lang.Object
  extended by org.deken.game.sprites.Sprite
      extended by org.deken.game.component.GComponent
          extended by org.deken.game.component.GScrollingParagraph
All Implemented Interfaces:
InputMouseListener, Updateable

public class GScrollingParagraph
extends GComponent

Title: GScrollingParagraph

Description: This container scrolls the large amount of text up the screen.

Copyright: Copyright (c) Mar 23, 2013

Version:
1.0
Author:
Gary Deken

Nested Class Summary
 
Nested classes/interfaces inherited from class org.deken.game.component.GComponent
GComponent.Alignment, GComponent.MouseActions
 
Field Summary
protected  java.lang.String indentString
           
protected  int startIndex
           
protected  double startSize
           
protected  java.util.List<java.lang.String> textList
           
protected  double yTextOffset
           
 
Fields inherited from class org.deken.game.component.GComponent
horizontalAlignment, id, invalid, keyPolling, mouseActions, parent, requestKeyPolling, screenHeight, screenWidth, verticalAlignment, xOffSet, yOffSet
 
Fields inherited from class org.deken.game.sprites.Sprite
boundingBox, collisionMap, location, size
 
Constructor Summary
GScrollingParagraph(java.lang.String text, int width, int height, double speed)
           
GScrollingParagraph(java.lang.String text, int width, int height, double speed, java.awt.Font font, java.awt.Color fontColor)
           
 
Method Summary
 void addBlankLine()
          Adds a Blank line, with no text.
 void addTextToSection(java.lang.String textOnNewLine)
          Adds text as a new section.
 GScrollingParagraph copy()
           
 void draw(java.awt.Graphics2D graphics, int xOffset, int yOffset)
          Draws the sprite with the current offset.
 void notifyListener(InputMouseAction inputMouseAction)
          notifyListener
 void setBackgroundColor(java.awt.Color backgroundColor)
           
 void setIndentNewSection(boolean indent, int spaces)
          Sets if new sections should be indented, and by how many spaces.
 void setLineSpacing(int lineSpacing)
          Sets the number of pixels to put between lines of text.
 void setMonitored(boolean active)
           
 void setText(java.lang.String text)
          Set the text value to be display in the paragraph.
protected  void spriteCollison(Sprite collideSprite)
          Handle the collision with another sprite.
 void update(long elapseTime)
          update
 void validate(java.awt.Graphics2D graphics)
           
 
Methods inherited from class org.deken.game.component.GComponent
addMouseAction, copyBase, getHorizontalAlignment, getMouseActions, getParent, getVerticalAlignment, getXLocation, getYLocation, isEnabled, positionHorizontalAlignment, positionVerticalAlignment, requestKeyPolling, setEnabled, setHorizontalAlignment, setInvalid, setKeyPolling, setParent, setVerticalAlignment
 
Methods inherited from class org.deken.game.sprites.Sprite
getBounds, getDepth, getHeight, getLocation, getName, getSize, getWidth, removeFromMap, setBoundingBox, setBoundingBox, setCollisionMap, setLocation, setName, setSize, toString, updateLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

textList

protected java.util.List<java.lang.String> textList

indentString

protected java.lang.String indentString

startIndex

protected int startIndex

startSize

protected double startSize

yTextOffset

protected double yTextOffset
Constructor Detail

GScrollingParagraph

public GScrollingParagraph(java.lang.String text,
                           int width,
                           int height,
                           double speed)

GScrollingParagraph

public GScrollingParagraph(java.lang.String text,
                           int width,
                           int height,
                           double speed,
                           java.awt.Font font,
                           java.awt.Color fontColor)
Method Detail

addBlankLine

public void addBlankLine()
Adds a Blank line, with no text.


addTextToSection

public void addTextToSection(java.lang.String textOnNewLine)
Adds text as a new section. A carriage return is added before the new text.

Parameters:
textOnNewLine -

copy

public GScrollingParagraph copy()
Specified by:
copy in class GComponent
Returns:
a copy of this GScrollingParagraph

draw

public void draw(java.awt.Graphics2D graphics,
                 int xOffset,
                 int yOffset)
Description copied from class: GComponent
Draws the sprite with the current offset.

Specified by:
draw in class GComponent
Parameters:
graphics -
xOffset -
yOffset -

notifyListener

public void notifyListener(InputMouseAction inputMouseAction)
Description copied from interface: InputMouseListener
notifyListener

This method is called when any Mouse Motion event occurs.

Parameters:
inputMouseAction - InputMouseAction

setBackgroundColor

public void setBackgroundColor(java.awt.Color backgroundColor)

setIndentNewSection

public void setIndentNewSection(boolean indent,
                                int spaces)
Sets if new sections should be indented, and by how many spaces. This only needs to be set once per GameParagraph

Parameters:
indent -
spaces -

setLineSpacing

public void setLineSpacing(int lineSpacing)
Sets the number of pixels to put between lines of text. The default is 0.

Parameters:
lineSpacing -

setMonitored

public void setMonitored(boolean active)
Specified by:
setMonitored in class GComponent

setText

public void setText(java.lang.String text)
Set the text value to be display in the paragraph. This over-rides any current text.

Parameters:
text -

update

public void update(long elapseTime)
Description copied from class: GComponent
update

This method takes the elapse time, and calculates the new current frame of the animation.

Specified by:
update in interface Updateable
Specified by:
update in class GComponent
Parameters:
elapseTime -

validate

public void validate(java.awt.Graphics2D graphics)
Specified by:
validate in class GComponent

spriteCollison

protected void spriteCollison(Sprite collideSprite)
Description copied from class: Sprite
Handle the collision with another sprite.

Specified by:
spriteCollison in class Sprite