edu.washington.cs.supple.render.utility
Class Factor

java.lang.Object
  extended byedu.washington.cs.supple.render.utility.Factor
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
BooleanFactor

public abstract class Factor
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Author:
kgajos This class represents factors in a utility model
See Also:
Serialized Form

Field Summary
protected  java.lang.Class[] applicableWidgetTypes
           
protected  java.lang.String name
           
protected  FactorWeight weight
           
 
Constructor Summary
Factor(java.lang.String name, FactorWeight weight, java.lang.Class widgetType)
          Initialize the factor with the type of widget that it applies to
Factor(java.lang.String name, FactorWeight weight, java.lang.Class[] widgetTypes)
          Initialize the factor with the type of widget that it applies to
 
Method Summary
 java.lang.Object clone()
           
 java.lang.String getName()
          Returns a descriptive name of this factor
abstract  double getValue(SuppleType type, UiObject object, WidgetDescriptor descriptor)
          Returns the value of this factor
 double getValue(Widget widget)
          Returns the value of this factor
 FactorWeight getWeight()
          Returns the weight object for this factor
protected  boolean isApplcableType(SuppleType type, UiObject object, WidgetDescriptor descriptor)
          An easy to override method that lets you finetune the applicability of a particular factor
 boolean isApplicable(java.util.Collection widgets)
          Checks if the factor is applicable for any element in a collection of widgets
 boolean isApplicable(SuppleType type, UiObject uiObject, java.util.Collection descriptors)
           
 boolean isApplicable(SuppleType type, UiObject object, WidgetDescriptor descriptor)
          Checks if the factor is applicable for a particular widget
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

applicableWidgetTypes

protected java.lang.Class[] applicableWidgetTypes

name

protected java.lang.String name

weight

protected FactorWeight weight
Constructor Detail

Factor

public Factor(java.lang.String name,
              FactorWeight weight,
              java.lang.Class widgetType)
Initialize the factor with the type of widget that it applies to

Parameters:
name - a descriptive name of this factor
weight - the weight for this factor
widgetType - the applicable wiget type

Factor

public Factor(java.lang.String name,
              FactorWeight weight,
              java.lang.Class[] widgetTypes)
Initialize the factor with the type of widget that it applies to

Parameters:
name - a descriptive name of this factor
weight - the weight for this factor
widgetTypes - the applicable wiget types
Method Detail

getValue

public double getValue(Widget widget)
Returns the value of this factor

Parameters:
widget - the widget to apply this factor to
Returns:
the value of this factor

getValue

public abstract double getValue(SuppleType type,
                                UiObject object,
                                WidgetDescriptor descriptor)
Returns the value of this factor

Parameters:
type - underlying supple type
object - underlying ui object
descriptor - descriptor of the widget to apply this factor to
Returns:
the value of this factor

getWeight

public FactorWeight getWeight()
Returns the weight object for this factor

Returns:
the weight for this factor

isApplicable

public boolean isApplicable(SuppleType type,
                            UiObject object,
                            WidgetDescriptor descriptor)
Checks if the factor is applicable for a particular widget

Parameters:
type - underlying supple type
object - underlying ui object
descriptor - a widget descriptor
Returns:
true if the factor is applicable, false otherwise

isApplcableType

protected boolean isApplcableType(SuppleType type,
                                  UiObject object,
                                  WidgetDescriptor descriptor)
An easy to override method that lets you finetune the applicability of a particular factor

Parameters:
type - underlying supple type
object - underlying ui object
descriptor - widget descriptor
Returns:
true if the factor is applicable, false otherwise

isApplicable

public boolean isApplicable(java.util.Collection widgets)
Checks if the factor is applicable for any element in a collection of widgets

Parameters:
widgets - a collection of widgets
Returns:
true if the factor is applicable for at leasst one widget in the collection, false otherwise

isApplicable

public boolean isApplicable(SuppleType type,
                            UiObject uiObject,
                            java.util.Collection descriptors)
Parameters:
type -
uiObject -
descriptors -
Returns:

getName

public java.lang.String getName()
Returns a descriptive name of this factor


toString

public java.lang.String toString()

clone

public java.lang.Object clone()