ch.tatool.core.element.handler.score
Class AbstractPointsAndLevelHandler

java.lang.Object
  extended by ch.tatool.core.element.AbstractPropertyHolder
      extended by ch.tatool.core.element.NodeImpl
          extended by ch.tatool.core.element.handler.score.AbstractPointsAndLevelHandler
All Implemented Interfaces:
PointsAndLevelHandler, PropertyHolder, Node, ExecutionPhaseListener
Direct Known Subclasses:
AdaptiveScoreAndLevelHandler, BoundaryPointsAndLevelHandler, DefaultPointsAndLevelHandler

public abstract class AbstractPointsAndLevelHandler
extends NodeImpl
implements ExecutionPhaseListener, PointsAndLevelHandler

Abstract store and level handler. Implements the PointAdapter logic and provides utility methods for subclasses.

Author:
Michael Ruflin

Nested Class Summary
 
Nested classes/interfaces inherited from interface ch.tatool.core.element.handler.score.PointsAndLevelHandler
PointsAndLevelHandler.LevelListener, PointsAndLevelHandler.PointAdaptor
 
Field Summary
 int startLevel
           
 int startMaxPoints
           
 int startMinPoints
           
 int startPoints
           
protected static int ZERO_POINTS
           
 
Constructor Summary
AbstractPointsAndLevelHandler()
           
AbstractPointsAndLevelHandler(String id)
           
 
Method Summary
protected abstract  int checkLevelChange(ExecutionContext context, int currentLevel)
          Overwrite to implement a different level/points logic.
 String getDescription()
           
protected  void informLevelChangeListeners(ExecutionContext context)
          Informs all listeners in the execution stack about a level change.
protected abstract  void initializeHandler(ExecutionContext context)
           
 void processExecutionPhase(ExecutionContext context)
          Called by the Executor to signal a new phase in the execution
protected  void processLevel(ExecutionContext context)
          Checks for level changes.
protected  void processPoints(ExecutionContext context)
          Processes the points set by the executable element.
 void setDescription(String description)
           
protected  void updateStatusRegion(ExecutionContext context)
          Updates the level status panel.
protected  void updateTotals(ExecutionContext context)
           
 
Methods inherited from class ch.tatool.core.element.NodeImpl
assignParent, assignParent, assignParents, getId, getLocalId, getParent, setId, setLocalId, setParent
 
Methods inherited from class ch.tatool.core.element.AbstractPropertyHolder
clearProperties, getKeys, getProperty, removeProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ch.tatool.element.Node
getParent, setParent
 
Methods inherited from interface ch.tatool.data.PropertyHolder
clearProperties, getId, getKeys, getProperty, removeProperty, setProperty
 

Field Detail

ZERO_POINTS

protected static final int ZERO_POINTS
See Also:
Constant Field Values

startLevel

public int startLevel

startMinPoints

public int startMinPoints

startMaxPoints

public int startMaxPoints

startPoints

public int startPoints
Constructor Detail

AbstractPointsAndLevelHandler

public AbstractPointsAndLevelHandler()

AbstractPointsAndLevelHandler

public AbstractPointsAndLevelHandler(String id)
Method Detail

getDescription

public String getDescription()

setDescription

public void setDescription(String description)

processExecutionPhase

public void processExecutionPhase(ExecutionContext context)
Called by the Executor to signal a new phase in the execution

Specified by:
processExecutionPhase in interface ExecutionPhaseListener
Parameters:
context -

updateStatusRegion

protected void updateStatusRegion(ExecutionContext context)
Updates the level status panel.


processPoints

protected void processPoints(ExecutionContext context)
Processes the points set by the executable element. This default implementation first mirrors the points as set by the executable element, followed by letting all PointAdaptors set on the executable element as aspects adapt the points as they wish.


updateTotals

protected void updateTotals(ExecutionContext context)

processLevel

protected void processLevel(ExecutionContext context)
Checks for level changes. The actual level check is done by checkLevelChange. This method merely takes care of informing the LevelChangeListeners in case a level change happened.


informLevelChangeListeners

protected void informLevelChangeListeners(ExecutionContext context)
Informs all listeners in the execution stack about a level change.


checkLevelChange

protected abstract int checkLevelChange(ExecutionContext context,
                                        int currentLevel)
Overwrite to implement a different level/points logic. Default logic simply uses += level = > +- 100.

Returns:
the new level. This can be the old level value

initializeHandler

protected abstract void initializeHandler(ExecutionContext context)


Copyright © 2012. All Rights Reserved.