de.lessvoid.nifty.controls.chatcontrol
Class ChatControl

java.lang.Object
  extended by de.lessvoid.nifty.controls.AbstractController
      extended by de.lessvoid.nifty.controls.chatcontrol.ChatControl
All Implemented Interfaces:
Chat, Controller, NiftyControl, KeyInputHandler

public class ChatControl
extends AbstractController
implements Chat, KeyInputHandler

This is the main controller for the chat control.

Version:
0.1
Author:
Mark

Constructor Summary
ChatControl()
          Default constructor.
 
Method Summary
 void addPlayer(String playerName, NiftyImage playerIcon)
          {@inheritDoc
 void addPlayer(String playerName, NiftyImage playerIcon, String style)
          {@inheritDoc
 void bind(Nifty niftyParam, Screen screenParam, Element newElement, Properties properties, Attributes controlDefinitionAttributes)
          
 List<ChatEntryModelClass> getLines()
          This method returns all the chatlines in the chat.
 List<ChatEntryModelClass> getPlayers()
          This method returns the current list of players in the chat.
 boolean inputEvent(NiftyInputEvent inputEvent)
          
 boolean keyEvent(NiftyInputEvent inputEvent)
          
 void onFocus(boolean arg0)
          
 void onStartScreen()
          
 void receivedChatLine(String text, NiftyImage icon)
          {@inheritDoc
 void receivedChatLine(String text, NiftyImage icon, String style)
          This method is called when a chat line is received which should be displayed in the chat control.
 void removePlayer(String playerName)
          {@inheritDoc
 void sendText()
          This method is called when the player either presses the send button or the Return key.
 void update()
          Updates the lists to reflecct any changes made to them, outside of the addPlayer, removePlayer and
 
Methods inherited from class de.lessvoid.nifty.controls.AbstractController
bind, disable, enable, getElement, getHeight, getId, getStyle, getWidth, hasFocus, init, isBound, isEnabled, layoutCallback, setEnabled, setFocus, setFocusable, setHeight, setId, setStyle, setWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.lessvoid.nifty.controls.NiftyControl
disable, enable, getElement, getHeight, getId, getStyle, getWidth, hasFocus, isBound, isEnabled, layoutCallback, setEnabled, setFocus, setFocusable, setHeight, setId, setStyle, setWidth
 

Constructor Detail

ChatControl

public ChatControl()
Default constructor.

Method Detail

bind

public final void bind(Nifty niftyParam,
                       Screen screenParam,
                       Element newElement,
                       Properties properties,
                       Attributes controlDefinitionAttributes)

Specified by:
bind in interface Controller

onFocus

public void onFocus(boolean arg0)

Specified by:
onFocus in interface Controller
Overrides:
onFocus in class AbstractController

onStartScreen

public final void onStartScreen()

Specified by:
onStartScreen in interface Controller

receivedChatLine

public final void receivedChatLine(String text,
                                   NiftyImage icon)
{@inheritDoc

Specified by:
receivedChatLine in interface Chat
Parameters:
text - The text to display.
icon - Optionally, an icon can be supplied which is then displayed at the start of the chat line.

receivedChatLine

public void receivedChatLine(String text,
                             NiftyImage icon,
                             String style)
This method is called when a chat line is received which should be displayed in the chat control. This method has one extra parameter. This parameter allows for a custom style to be set per chat line.

Specified by:
receivedChatLine in interface Chat
Parameters:
text - The text to display.
icon - Optionally, an icon can be supplied which is then displayed at the start of the chat line.
style - The custom style for this particular chatline.

addPlayer

public final void addPlayer(String playerName,
                            NiftyImage playerIcon)
{@inheritDoc

Specified by:
addPlayer in interface Chat
Parameters:
playerName - The player to add.
playerIcon - Optionally, an icon can be supplied which is then displayed in front of the player name.

addPlayer

public void addPlayer(String playerName,
                      NiftyImage playerIcon,
                      String style)
{@inheritDoc

Specified by:
addPlayer in interface Chat
Parameters:
playerName - The player to add.
playerIcon - Optionally, an icon can be supplied which is then displayed in front of the player name.
style - The custom style for this player. This style is depicted in the player list.

removePlayer

public final void removePlayer(String playerName)
{@inheritDoc

Specified by:
removePlayer in interface Chat
Parameters:
playerName - The player name to remove.

getPlayers

public List<ChatEntryModelClass> getPlayers()
This method returns the current list of players in the chat.

Specified by:
getPlayers in interface Chat
Returns:
The current list of players.

getLines

public List<ChatEntryModelClass> getLines()
This method returns all the chatlines in the chat.

Specified by:
getLines in interface Chat
Returns:
The current list of chatlines.

update

public void update()
Updates the lists to reflecct any changes made to them, outside of the addPlayer, removePlayer and

Specified by:
update in interface Chat

sendText

public final void sendText()
This method is called when the player either presses the send button or the Return key.


keyEvent

public boolean keyEvent(NiftyInputEvent inputEvent)

Specified by:
keyEvent in interface KeyInputHandler

inputEvent

public boolean inputEvent(NiftyInputEvent inputEvent)

Specified by:
inputEvent in interface Controller


Copyright © 2011. All Rights Reserved.