edu.washington.cs.supple.render
Class AbstractCostFunction

java.lang.Object
  extended byedu.washington.cs.supple.render.AbstractCostFunction
All Implemented Interfaces:
CostFunction, VetoFunction
Direct Known Subclasses:
DesktopCostFunction, DesktopCostFunction, HtmlDesktopCostFunction, TouchCostFunction, WapCostFunction

public abstract class AbstractCostFunction
extends java.lang.Object
implements CostFunction, VetoFunction

Author:
kgajos The base implementation of some core functionality that many other implementations of the cost function may want to reuse

Field Summary
protected  TreeFrequencyCount frequencyCount
           
protected  UiObject lastRoot
           
protected  NavigationCostFunction navCost
           
protected  ShortcutCostFunction shortcutCost
           
protected  SimilarityCostFunction similarityCost
           
protected  Trace trace
           
protected  TransitionCount transitionCountFunction
           
 
Constructor Summary
AbstractCostFunction(Trace t)
           
 
Method Summary
protected  void ensureNavCostFunction(Widget w)
           
protected  void ensureShortcutCostFunction()
           
protected  void ensureSimilarityCostFunction()
           
 float getAssignmentCost(Widget widget)
           
 float getHintCost(RenderingHint hint, float fit)
          Used by RenderingHintEnforcer to convert widget's fit returned by a rendering hint to actual cost
protected abstract  float getMatchCost(Widget widget)
           
protected abstract  NavigationCostFunction getNewNavigationCostFunction(Trace t, UiObject root)
           
 float getShortcutCost(Shortcut shortcut)
          The signature for this method will probably change at some point; it computes the cost associated with a particular shortcut.
 ShortcutCostFunction getShortcutCostFunction()
          returns the currently used shortcut cost function
protected  SimilarityCostFunction getSimilarityCostFunction()
           
 TransitionCount getTransitionCountFunction()
          A transition count provides information on the usage of the container elements of a UI
protected  boolean hasPrimitiveChild(ContainerType type)
           
 boolean isAcceptable(Widget widget)
          provides yes/no information as to whether a widget is acceptable in a particular situation
 void setShortcutCostFunction(ShortcutCostFunction function)
          Sets the shortcut cost function to be used
 void setTransitionCountFunction(TransitionCount tc)
          A transition count provides information on the usage of the container elements of a UI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

trace

protected Trace trace

navCost

protected NavigationCostFunction navCost

similarityCost

protected SimilarityCostFunction similarityCost

shortcutCost

protected ShortcutCostFunction shortcutCost

frequencyCount

protected TreeFrequencyCount frequencyCount

transitionCountFunction

protected TransitionCount transitionCountFunction

lastRoot

protected UiObject lastRoot
Constructor Detail

AbstractCostFunction

public AbstractCostFunction(Trace t)
Method Detail

getMatchCost

protected abstract float getMatchCost(Widget widget)

getNewNavigationCostFunction

protected abstract NavigationCostFunction getNewNavigationCostFunction(Trace t,
                                                                       UiObject root)

getSimilarityCostFunction

protected SimilarityCostFunction getSimilarityCostFunction()

ensureNavCostFunction

protected void ensureNavCostFunction(Widget w)

ensureSimilarityCostFunction

protected void ensureSimilarityCostFunction()

ensureShortcutCostFunction

protected void ensureShortcutCostFunction()

getAssignmentCost

public float getAssignmentCost(Widget widget)
Specified by:
getAssignmentCost in interface CostFunction
Parameters:
widget - widget whose cost is to be analysed
Returns:
the cost of assigning this widget to its corresponding ui element; -1 if widget is not acceptable

getHintCost

public float getHintCost(RenderingHint hint,
                         float fit)
Description copied from interface: CostFunction
Used by RenderingHintEnforcer to convert widget's fit returned by a rendering hint to actual cost

Specified by:
getHintCost in interface CostFunction
Parameters:
fit - the fit (between 0.0 and 1.0
Returns:
the cost incurred by the widget based on its compliance with the hint

getShortcutCost

public float getShortcutCost(Shortcut shortcut)
Description copied from interface: CostFunction
The signature for this method will probably change at some point; it computes the cost associated with a particular shortcut. At the moment it assumes a fixed cost per access regardless of how the shortcut is rendered. This is clearly wrong but we will worry about it later

Specified by:
getShortcutCost in interface CostFunction
Parameters:
shortcut - shortcut to be evaluated
Returns:
the associated cost (which depends on how much traffic goes through the shortcut)

getShortcutCostFunction

public ShortcutCostFunction getShortcutCostFunction()
returns the currently used shortcut cost function

Returns:
a shortcut cost function

setShortcutCostFunction

public void setShortcutCostFunction(ShortcutCostFunction function)
Sets the shortcut cost function to be used

Parameters:
function - a shortcut cost function

getTransitionCountFunction

public TransitionCount getTransitionCountFunction()
Description copied from interface: CostFunction
A transition count provides information on the usage of the container elements of a UI

Specified by:
getTransitionCountFunction in interface CostFunction
Returns:
tc a transition count function

setTransitionCountFunction

public void setTransitionCountFunction(TransitionCount tc)
Description copied from interface: CostFunction
A transition count provides information on the usage of the container elements of a UI

Specified by:
setTransitionCountFunction in interface CostFunction
Parameters:
tc - a transition count function

isAcceptable

public boolean isAcceptable(Widget widget)
Description copied from interface: VetoFunction
provides yes/no information as to whether a widget is acceptable in a particular situation

Specified by:
isAcceptable in interface VetoFunction
Parameters:
widget - a widget to be tested
Returns:
true if the widget is acceptable, false otherwise

hasPrimitiveChild

protected boolean hasPrimitiveChild(ContainerType type)