com.b3dgs.lionengine.game.strategy
Class AbstractEntryHandler<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>

java.lang.Object
  extended by com.b3dgs.lionengine.game.Handler<AbstractEntry<TTile,TSkill,TAttr>>
      extended by com.b3dgs.lionengine.game.strategy.AbstractEntryHandler<TTile,TSkill,TAttr>
Type Parameters:
TTile - tile type used.
TSkill - skill type used.
TAttr - attributes type used.

public abstract class AbstractEntryHandler<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
extends Handler<AbstractEntry<TTile,TSkill,TAttr>>

This class will handle a list of entrys, by updating and rendering them. All action are defined here, such as selection and orders. It need a control panel to work properly. Don't forget to call createLayers(map) after map creation (when its size is established).

See Also:
AbstractControlPanel

Field Summary
protected  boolean clicked
          Handler flags.
protected  boolean clickedFlag
          Handler flags.
protected  boolean ordered
          Handler flags.
protected  AbstractControlPanel<TTile,TSkill,TAttr> panel
          Control panel reference.
protected  AbstractPlayer player
          Player reference.
protected  boolean selected
          Handler flags.
protected  boolean selecting
          Handler flags.
 java.util.Set<AbstractEntry<TTile,TSkill,TAttr>> selection
          Current entry selection set.
 
Fields inherited from class com.b3dgs.lionengine.game.Handler
elements
 
Constructor Summary
AbstractEntryHandler(AbstractControlPanel<TTile,TSkill,TAttr> panel)
          Create a new entry handler.
 
Method Summary
 void add(AbstractEntry<TTile,TSkill,TAttr> entry)
          Add an element to the handler list.
protected abstract  boolean canBeSelected(AbstractEntry<TTile,TSkill,TAttr> entry)
          Check if entry is selectable.
 void createLayers(TileBasedMap<TTile> map)
          Prepare rendering layers, depending of the map height.
 java.util.Set<AbstractEntry<TTile,TSkill,TAttr>> getSelection()
          Get list of selected entrys during cursor selection.
 void remove(AbstractEntry<TTile,TSkill,TAttr> entry)
          Remove an entry from the handler list.
 void render(java.awt.Graphics2D g, StrategyCamera camera, StrategyCursor cursor)
          Main rendering routine; has to be called in a game loop.
 void renderCursorSelection(java.awt.Graphics2D g, java.awt.Color color, int x, int y, int w, int h)
          Rendering selection properties.
 void renderCursorSelection(java.awt.Graphics2D g, StrategyCamera camera)
          Render cursor selection routine.
 void renderEntry(java.awt.Graphics2D g, AbstractEntry<TTile,TSkill,TAttr> entry, StrategyCamera camera, StrategyCursor cursor)
          Rendering function for an entry.
 void renderEntryOver(java.awt.Graphics2D g, AbstractEntry<TTile,TSkill,TAttr> entry, StrategyCamera camera, java.awt.Color color)
          Rendering function concerning cursor over entry case.
 void renderEntrySelection(java.awt.Graphics2D g, AbstractEntry<TTile,TSkill,TAttr> entry, StrategyCamera camera, java.awt.Color color)
          Rendering function concerning selection state.
 void setOrdered(boolean state)
          Set the ordered state (true when an action [skill] is chosen).
 void setPlayer(AbstractPlayer player)
          Set player (player owning this panel).
 void update(Keyboard keyboard, StrategyCursor cursor, StrategyCamera camera, float extrp)
          Main routine; has to be called in main game loop.
 void updateCursorSelection(StrategyCursor cursor, StrategyCamera camera)
          Function handling cursor selection (preparing area transposed on the map).
 void updateEntry(Keyboard keyboard, StrategyCursor cursor, StrategyCamera camera, AbstractEntry<TTile,TSkill,TAttr> entry, float extrp)
          Update current entry, by handling mouse orders, over, and selection.
 
Methods inherited from class com.b3dgs.lionengine.game.Handler
list, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

selection

public final java.util.Set<AbstractEntry<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>> selection
Current entry selection set.


panel

protected final AbstractControlPanel<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes> panel
Control panel reference.


player

protected AbstractPlayer player
Player reference.


clicked

protected boolean clicked
Handler flags.


clickedFlag

protected boolean clickedFlag
Handler flags.


selecting

protected boolean selecting
Handler flags.


selected

protected boolean selected
Handler flags.


ordered

protected boolean ordered
Handler flags.

Constructor Detail

AbstractEntryHandler

public AbstractEntryHandler(AbstractControlPanel<TTile,TSkill,TAttr> panel)
Create a new entry handler. Don't forget to call createLayers(map) after map creation (when its size is established).

Parameters:
panel - control panel reference.
Method Detail

createLayers

public void createLayers(TileBasedMap<TTile> map)
Prepare rendering layers, depending of the map height. When an entry moved and its height changed, its layer is automatically adjusted.

Parameters:
map - map reference.

add

public void add(AbstractEntry<TTile,TSkill,TAttr> entry)
Description copied from class: Handler
Add an element to the handler list.

Overrides:
add in class Handler<AbstractEntry<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>>
Parameters:
entry - element to add.

remove

public void remove(AbstractEntry<TTile,TSkill,TAttr> entry)
Remove an entry from the handler list.

Parameters:
entry - entry to remove.

update

public void update(Keyboard keyboard,
                   StrategyCursor cursor,
                   StrategyCamera camera,
                   float extrp)
Main routine; has to be called in main game loop.

Parameters:
keyboard - keyboard reference.
cursor - cursor reference (used for selection).
camera - camera viewpoint.
extrp - extrapolation value.

updateCursorSelection

public void updateCursorSelection(StrategyCursor cursor,
                                  StrategyCamera camera)
Function handling cursor selection (preparing area transposed on the map).

Parameters:
cursor - cursor reference.
camera - camera reference.

updateEntry

public void updateEntry(Keyboard keyboard,
                        StrategyCursor cursor,
                        StrategyCamera camera,
                        AbstractEntry<TTile,TSkill,TAttr> entry,
                        float extrp)
Update current entry, by handling mouse orders, over, and selection.

Parameters:
keyboard - keyboard reference.
entry - current entry.
cursor - cursor reference.
camera - camera reference.
extrp - extrapolation value.

canBeSelected

protected abstract boolean canBeSelected(AbstractEntry<TTile,TSkill,TAttr> entry)
Check if entry is selectable.

Parameters:
entry - entry to check.
Returns:
true if selectable.

render

public void render(java.awt.Graphics2D g,
                   StrategyCamera camera,
                   StrategyCursor cursor)
Main rendering routine; has to be called in a game loop.

Parameters:
g - graphic output.
camera - camera reference.
cursor - cursor reference.

renderCursorSelection

public void renderCursorSelection(java.awt.Graphics2D g,
                                  StrategyCamera camera)
Render cursor selection routine.

Parameters:
g - graphic output.
camera - camera reference.

renderCursorSelection

public void renderCursorSelection(java.awt.Graphics2D g,
                                  java.awt.Color color,
                                  int x,
                                  int y,
                                  int w,
                                  int h)
Rendering selection properties.

Parameters:
g - graphic output.
color - selection color.
x - horizontal selection location (screen referential).
y - vertical selection location (screen referential).
w - selection width.
h - selection height.

renderEntry

public void renderEntry(java.awt.Graphics2D g,
                        AbstractEntry<TTile,TSkill,TAttr> entry,
                        StrategyCamera camera,
                        StrategyCursor cursor)
Rendering function for an entry.
Here are handled the entry rendering, such as sprite, border selection...

Parameters:
g - graphic output.
entry - current entry.
camera - camera reference.
cursor - cursor reference.

renderEntryOver

public void renderEntryOver(java.awt.Graphics2D g,
                            AbstractEntry<TTile,TSkill,TAttr> entry,
                            StrategyCamera camera,
                            java.awt.Color color)
Rendering function concerning cursor over entry case.

Parameters:
g - graphic output.
entry - current entry.
camera - camera reference.
color - box color.

renderEntrySelection

public void renderEntrySelection(java.awt.Graphics2D g,
                                 AbstractEntry<TTile,TSkill,TAttr> entry,
                                 StrategyCamera camera,
                                 java.awt.Color color)
Rendering function concerning selection state.

Parameters:
g - graphic output.
entry - current entry.
camera - camera reference.
color - box color.

setOrdered

public void setOrdered(boolean state)
Set the ordered state (true when an action [skill] is chosen).

Parameters:
state - ordered state.

getSelection

public java.util.Set<AbstractEntry<TTile,TSkill,TAttr>> getSelection()
Get list of selected entrys during cursor selection.

Returns:
list of selected entry.

setPlayer

public void setPlayer(AbstractPlayer player)
Set player (player owning this panel).

Parameters:
player - player reference.