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

java.lang.Object
  extended byedu.washington.cs.supple.render.utility.OldFactor
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class OldFactor
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 applicableWidgetType
           
protected  float lowerBound
           
protected  java.lang.String name
           
protected  float upperBound
           
 
Constructor Summary
OldFactor(java.lang.String name, java.lang.Class widgetType, float lowerBound, float upperBound)
          Initialize the factor with the type of widget that it applies to
 
Method Summary
 java.lang.Object clone()
           
protected  float computeActualBound(float bound, SuppleType type, UiObject object, Widget w)
          An easy to override function that lets you scale the factor depending on the details of the underlying type, etc
 float getLowerBound(Widget w)
          Returns the lower bound on the cost of a widget
 java.lang.String getName()
          Returns a descriptive name of this factor
 float getUpperBound(Widget w)
          Returns the upper bound on the cost of a widget
protected  boolean isApplcableType(SuppleType type, UiObject object, Widget w)
          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(Widget w)
          Checks if the factor is applicable for a particular widget
 void scaleBothBounds(float scale)
          Scales both bounds on the factor's parameter
 void scaleLowerBound(float scale)
          Scales the lower bound on the factor's parameter
 void scaleUpperBound(float scale)
          Scales the upper bound on the factor's parameter
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

applicableWidgetType

protected java.lang.Class applicableWidgetType

name

protected java.lang.String name

lowerBound

protected float lowerBound

upperBound

protected float upperBound
Constructor Detail

OldFactor

public OldFactor(java.lang.String name,
                 java.lang.Class widgetType,
                 float lowerBound,
                 float upperBound)
Initialize the factor with the type of widget that it applies to

Parameters:
name - a descriptive name of this factor
widgetType - the applicable wiget type
lowerBound - lower bound on the factor's parameter
upperBound - upper bound on the factor's parameter
Method Detail

isApplicable

public boolean isApplicable(Widget w)
Checks if the factor is applicable for a particular widget

Parameters:
w - a widget
Returns:
true if the factor is applicable, false otherwise

isApplcableType

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

Parameters:
type - underlying supple type
object - underlying ui object
w - widget
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

getLowerBound

public float getLowerBound(Widget w)
Returns the lower bound on the cost of a widget

Parameters:
w - a widget to be evaluated
Returns:
the lower bound on the cost of a widget (or 0 if not applicable for the widget)

getUpperBound

public float getUpperBound(Widget w)
Returns the upper bound on the cost of a widget

Parameters:
w - a widget to be evaluated
Returns:
the upper bound on the cost of a widget (or 0 if not applicable for the widget)

computeActualBound

protected float computeActualBound(float bound,
                                   SuppleType type,
                                   UiObject object,
                                   Widget w)
An easy to override function that lets you scale the factor depending on the details of the underlying type, etc

Parameters:
bound - the bound to be scaled
type - underlying supple type
object - underlying UI object
w - widget
Returns:
scaled bound

scaleLowerBound

public void scaleLowerBound(float scale)
Scales the lower bound on the factor's parameter

Parameters:
scale - the scale

scaleUpperBound

public void scaleUpperBound(float scale)
Scales the upper bound on the factor's parameter

Parameters:
scale - the scale

scaleBothBounds

public void scaleBothBounds(float scale)
Scales both bounds on the factor's parameter

Parameters:
scale - the scale

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()