org.deken.game.component
Class GParagraph

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

public class GParagraph
extends GComponent

Title: GParagraph

Description: The GParagraph class stores and formats large amounts of text to be displayed to the screen. It has line spacing, indentation and allows multiple grammar paragraphs.

The paragraph is formated the first time the draw is called. Copyright: Copyright (c) Feb 17, 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
 
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
GParagraph(java.lang.String text, java.awt.Font font, java.awt.Color fontColor, int width)
           
GParagraph(java.lang.String text, int width)
           
 
Method Summary
 void addBlankLine()
          Adds a Blank line, with no text.
 void addTextToSection(java.lang.String textOnNewLine)
          Adds text as a new section.
 GComponent 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
 

Constructor Detail

GParagraph

public GParagraph(java.lang.String text,
                  int width)

GParagraph

public GParagraph(java.lang.String text,
                  java.awt.Font font,
                  java.awt.Color fontColor,
                  int width)
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 GComponent copy()
Specified by:
copy in class GComponent
Returns:
GComponent

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

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 - long

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