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

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

public abstract class AbstractControlPanel<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
extends java.lang.Object

This class represents the control panel (hud), which will contain selected entrys, actions, and many other infos. It supports differents types of axis, by auto blocking the selection if necessary. Panel has to be used with an entry handler, in order to control them all (use setEntryHandler).

See Also:
AbstractEntryHandler

Field Summary
protected  java.util.List<PanelComponent> components
           
protected  AbstractEntryHandler<TTile,TSkill,TAttr> entrys
          Entry handler reference.
protected  TiledSprite icons
          Available icons inside surface.
protected  Sprite panel
          Control panel image.
protected  AbstractPlayer player
          Player owning the control panel.
 
Constructor Summary
AbstractControlPanel(Sprite panel, TiledSprite icons)
          Create a new control panel.
 
Method Summary
 void addComponent(PanelComponent component)
           
 void checkCursor(StrategyCursor cursor)
          Check if cursor is inside or outside the panel (this avoid selection inside panel).
 java.awt.geom.Rectangle2D getArea()
          Get clickable area on map (out panel).
 java.util.List<PanelComponent> getComponents()
           
 void render(java.awt.Graphics2D g, StrategyCursor cursor)
          Panel rendering need to be defined here (list of selected entrys, informations...).
protected  void renderEntrySkills(java.awt.Graphics2D g, StrategyCursor cursor, AbstractEntry<TTile,TSkill,TAttr> entry, int isx, int isy, int mw, int mh, int ipl)
          Render entry skills icons (in case of a single entry selection).
protected  void renderEntrysSkills(java.awt.Graphics2D g, StrategyCursor cursor, java.util.Set<AbstractEntry<TTile,TSkill,TAttr>> entrys, int isx, int isy, int mw, int mh, int ipl, java.util.Set<java.lang.String> ignore)
          Render entrys skills icons (only common skills, in case of multiple entry selection).
protected abstract  void renderMultipleEntry(java.awt.Graphics2D g, StrategyCursor cursor, java.util.Set<AbstractEntry<TTile,TSkill,TAttr>> entrys)
          Rendering function in case of many selected unit.
protected abstract  void renderSingleEntry(java.awt.Graphics2D g, StrategyCursor cursor, AbstractEntry<TTile,TSkill,TAttr> entry)
          Rendering function in case of a single selected unit.
 void setClickableArea(int x, int y, int width, int height)
          Set clickable area on map (not on panel).
 void setEntryHandler(AbstractEntryHandler<TTile,TSkill,TAttr> entrys)
          Set entry handler reference.
 void setPlayer(AbstractPlayer player)
          Set player (player owning this panel).
protected  void updateSkill(java.awt.Graphics2D g, StrategyCursor cursor, TSkill skill, int ico, int ix, int iy, int iw, int ih)
          Rendering of a specific skill.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

icons

protected final TiledSprite icons
Available icons inside surface.


panel

protected final Sprite panel
Control panel image.


player

protected AbstractPlayer player
Player owning the control panel.


entrys

protected AbstractEntryHandler<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes> entrys
Entry handler reference.


components

protected final java.util.List<PanelComponent> components
Constructor Detail

AbstractControlPanel

public AbstractControlPanel(Sprite panel,
                            TiledSprite icons)
Create a new control panel.

Parameters:
panel - panel image.
icons - panel icons set.
Method Detail

setClickableArea

public void setClickableArea(int x,
                             int y,
                             int width,
                             int height)
Set clickable area on map (not on panel).

Parameters:
x - starting clickable location x.
y - starting clickable location y.
width - clickable area width.
height - clickable area height.

setEntryHandler

public void setEntryHandler(AbstractEntryHandler<TTile,TSkill,TAttr> entrys)
Set entry handler reference. Has to be defined before game loop.

Parameters:
entrys - entry handler reference.

render

public void render(java.awt.Graphics2D g,
                   StrategyCursor cursor)
Panel rendering need to be defined here (list of selected entrys, informations...). Due to some optimization, update function is not used, as main updates are directly done during rendering. Thoses updates include click over skills, by setting entry order (in renderSkill).

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

renderSingleEntry

protected abstract void renderSingleEntry(java.awt.Graphics2D g,
                                          StrategyCursor cursor,
                                          AbstractEntry<TTile,TSkill,TAttr> entry)
Rendering function in case of a single selected unit. It is usually used to render as much information as possible for this unit.

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

renderMultipleEntry

protected abstract void renderMultipleEntry(java.awt.Graphics2D g,
                                            StrategyCursor cursor,
                                            java.util.Set<AbstractEntry<TTile,TSkill,TAttr>> entrys)
Rendering function in case of many selected unit. It is usually used to render only common information (entrys icons + life only for example).

Parameters:
g - graphic output.
cursor - cursor reference.
entrys - list of selected entrys.

renderEntrySkills

protected void renderEntrySkills(java.awt.Graphics2D g,
                                 StrategyCursor cursor,
                                 AbstractEntry<TTile,TSkill,TAttr> entry,
                                 int isx,
                                 int isy,
                                 int mw,
                                 int mh,
                                 int ipl)
Render entry skills icons (in case of a single entry selection). This function will call skill rendering function for each of them (renderSkill). It is not recommended to override this method (or use super.renderEntrySkills).

Parameters:
g - graphic output.
cursor - cursor reference.
entry - current entry.
isx - icons starting location x.
isy - icons starting location y.
mw - horizontal margin bewteen icons.
mh - vertical margin bewteen icons.
ipl - number of icons per line.

renderEntrysSkills

protected void renderEntrysSkills(java.awt.Graphics2D g,
                                  StrategyCursor cursor,
                                  java.util.Set<AbstractEntry<TTile,TSkill,TAttr>> entrys,
                                  int isx,
                                  int isy,
                                  int mw,
                                  int mh,
                                  int ipl,
                                  java.util.Set<java.lang.String> ignore)
Render entrys skills icons (only common skills, in case of multiple entry selection). This function will call skill rendering function for each of them (renderSkill). It is not recommended to override this method (or use super.renderEntrysSkills).

Parameters:
g - graphic output.
cursor - cursor reference.
entrys - list of selected entrys.
isx - icons starting location x.
isy - icons starting location y.
mw - horizontal margin bewteen icons.
mh - vertical margin bewteen icons.
ipl - number of icons per line.
ignore - set of skill name to ignore on multiple selection.

updateSkill

protected void updateSkill(java.awt.Graphics2D g,
                           StrategyCursor cursor,
                           TSkill skill,
                           int ico,
                           int ix,
                           int iy,
                           int iw,
                           int ih)
Rendering of a specific skill. It is possible to override method, by improving rendering. Example (box over effect):
 super.renderSkill(g, cursor, entry, skill, ico, ix, iy, iw, ih);
 int cx = cursor.getX(), cy = cursor.getY();
 if (cx >= ix && cx <= ix + iw && cy >= iy && cy <= iy + ih) {
        g.setColor(Color.RED);
        g.drawRect(ix, iy, iw, ih);
 }
 

Parameters:
g - graphic output.
cursor - cursor reference.
skill - current skill.
ico - icon number.
ix - icon location x.
iy - icon location y.
iw - icon width.
ih - icon height.

checkCursor

public void checkCursor(StrategyCursor cursor)
Check if cursor is inside or outside the panel (this avoid selection inside panel).

Parameters:
cursor - cursor reference.

getArea

public java.awt.geom.Rectangle2D getArea()
Get clickable area on map (out panel).

Returns:
clickable map area from panel.

setPlayer

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

Parameters:
player - player reference.

addComponent

public void addComponent(PanelComponent component)

getComponents

public java.util.List<PanelComponent> getComponents()