|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectedu.washington.cs.supple.render.WidgetBag
| Field Summary | |
protected java.util.Vector |
availableWidgets
|
protected java.util.Vector |
changedWidgets
|
protected java.util.Hashtable |
children
|
protected static float |
costConstraint
|
protected java.util.Vector |
currentWidgets
|
protected UiObject |
object
|
protected WidgetBag |
parent
|
protected java.util.Collection |
relevantFactors
|
protected java.util.Vector |
renderingConstraintEnforcers
|
protected java.util.Vector |
renderingHintEnforcers
|
protected SearchParameters |
searchParameters
|
protected static java.awt.Dimension |
sizeConstraint
|
protected Solution |
solution
|
protected java.util.Stack |
stack
|
protected SuppleType |
type
|
| Constructor Summary | |
WidgetBag(UiObject object,
WidgetBag parent,
java.util.Collection widgets,
SearchParameters searchParameters)
|
|
| Method Summary | |
void |
addChild(WidgetBag child)
Adds a bew child bag to this bag. |
protected void |
addRenderingConstraintEnforcer(RenderingConstraintEnforcer enforcer)
Adds a new rendering constraint enforcer (provided it hasn't been added already) |
protected void |
addRenderingHintEnforcer(RenderingHintEnforcer enforcer)
Adds a new rendering hint enforcer (provided it hasn't been added already) |
protected void |
changed()
Called by the object itself when a significant change occurs (though when a membership change happens, the membershipChanged() method should be called instead). |
protected void |
childChanged()
Clears all the children-related cache data structures and then forwards the call to its parent if it has one |
java.util.Enumeration |
children()
|
java.lang.Object |
clone()
Returns a clone of this WidgetBag (we probably need a deep clone operations so the children hashtable should be populated with clones of the children - KZG) |
boolean |
equals(java.lang.Object o)
Two bags are considered equal if they correspond to the same type |
java.util.Vector |
getAvailableWidgets()
|
java.util.Collection |
getBagCollection()
Returns this widget bag subtree as a collection |
WidgetBag |
getChild(UiObject object)
|
java.util.Vector |
getChildren()
|
float |
getCost()
|
static float |
getCostConstraint()
|
java.util.Vector |
getCurrentWidgets()
|
float |
getEffortEstimate(ActionDescription a)
Computes the worst case effort estimate based on the effort estimates for all possible widgets |
protected float |
getHintCost(Widget w)
Calculates the cost added by all the rendering hints for a given widget |
java.awt.Dimension |
getMaxChildSize(int hints)
|
java.awt.Dimension |
getMaxChildSize(int hints,
java.util.Collection objects)
Returns the max size of the specified subset of children |
java.awt.Dimension |
getMinChildSize(int hints,
UiObject child)
Returns the min size of the specified child |
java.awt.Dimension[] |
getMinCombinedChildSize(int hints,
UiObject child,
AlignedLayoutHelper helper)
|
java.awt.Dimension[] |
getMinCombinedSize(int hints,
AlignedLayoutHelper helper)
Calculates the minimum size of this element assuming that it is going to end up in an aligned container |
java.awt.Dimension |
getMinSize(int hints)
|
int |
getNumChildren()
|
int |
getNumCurrentWidgets()
|
WidgetBag |
getParent()
|
java.util.Vector |
getRenderingConstraintEnforcers()
|
Solution |
getSolution()
returns the widget tree reflecting the current solution (in fact, it will return the cached solution, care needs to be taken to call resetSolution when search restarts) |
protected float |
getSumChildCost()
|
java.awt.Dimension |
getSumChildSize(int hints)
|
java.awt.Dimension |
getSumChildSize(int hints,
java.util.Collection objects)
Returns the sum of the sizes of the specified subset of children |
SuppleType |
getType()
|
UiObject |
getUiObject()
|
Widget |
getWidget()
If the bag is set (i.e. |
boolean |
hasChildren()
|
boolean |
hasCurrentWidgetsOtherThan(java.lang.Class widgetClass)
Checks if the bag is currently considering widgets of types other than the one specified |
boolean |
hasCurrentWidgetsOtherThan(java.lang.Class[] widgetClasses)
Checks if the bag is currently considering widgets of types other than the ones specified |
int |
hashCode()
uses the hashcode of the corresponding type |
boolean |
isLeaf()
|
boolean |
isRoot()
|
boolean |
isSet()
This method lets you check if this bag has been assigned a widget |
protected void |
membershipChanged()
Called when the list of currentWidgets changes; it first calls the changed() method on this bag and then informs all bags linked to this one by rendering hints of the change |
int |
numChildren()
|
protected void |
popTheStack()
Pops the most recent value of current widgets from the stack; if it's different from what we currently have, changed() is called |
boolean |
propagate(int levels)
Prunes the list of current widgets (if necessary); if no widgets are left, failure is reported. |
boolean |
propagate(int levels,
boolean withConstraints)
Prunes the list of current widgets (if necessary); it than propagates through the constraints. |
boolean |
propagate(int levels,
boolean withConstraints,
boolean pruneByCost)
Prunes the list of current widgets (if necessary); it than propagates through the constraints. |
protected boolean |
propagateConstraints(int levels)
propagates explicit rendering constraints (as opposed to the size and cost constraints which are built into the structure of the problem) |
protected boolean |
prune(boolean pruneByCost)
Does prunning of widgets within this bag; if something gets prunned, it calls changed(); If it ends up with an empty set of current widets, it returns false to indicate failure |
float |
recomputeCost(boolean updateWidgetCosts)
Discards the cached cost throughout the subtree rooted at this bag and returns freshly computed cost |
void |
reset()
Prepares all data structures of this bag for a new search |
protected void |
resetCostCache(boolean updateWidgetCosts)
resets the cost cache for this bag and for all of its children |
void |
resetSolution()
forgetting the most recently created solution |
void |
restoreCurrentWidgets()
Restores the list of current widgets to the full set of available widgets |
void |
restoreCurrentWidgets(java.util.Vector v)
Used when the search backtracks and needs to restore the pool of legal widgets |
protected boolean |
satisfiesConstraints(Widget w)
|
static void |
setCostConstraint(float c)
Sets a static variable indicating the maximum allowed cost for the solution |
void |
setCurrentWidget(Widget w)
Used during search process to set the current widget |
void |
setParent(WidgetBag parent)
Sets the parent of this widget bag |
static void |
setSizeConstraint(java.awt.Dimension constr)
For now we shall assume that there is a single size constraint on all components |
java.lang.String |
toPrettyString(java.lang.String pref)
|
java.lang.String |
toString()
|
void |
undoPropagate(int levels)
pops the old state from the stack and asks the parent to do the same |
void |
undoPropagate(int levels,
boolean withConstraints)
|
void |
updateWidgetCosts()
Causes the widget bag to recompute costs for all of the widgets (called, for example, when the usage counts are recomputed) |
void |
widgetCostChanged(Widget w)
Called by a widget if its cost changes |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected WidgetBag parent
protected java.util.Hashtable children
protected UiObject object
protected SuppleType type
protected java.util.Vector availableWidgets
protected java.util.Vector currentWidgets
protected java.util.Vector changedWidgets
protected java.util.Stack stack
protected java.util.Vector renderingHintEnforcers
protected java.util.Vector renderingConstraintEnforcers
protected SearchParameters searchParameters
protected java.util.Collection relevantFactors
protected static java.awt.Dimension sizeConstraint
protected static float costConstraint
protected Solution solution
| Constructor Detail |
public WidgetBag(UiObject object,
WidgetBag parent,
java.util.Collection widgets,
SearchParameters searchParameters)
parent - The parent bag (or null for root)widgets - possible widgets for this elementsearchParameters - the parameters of this search| Method Detail |
public java.lang.Object clone()
public void reset()
public static void setSizeConstraint(java.awt.Dimension constr)
constr - the max size any component can assumepublic static void setCostConstraint(float c)
c - maximum cost the entire solution is allowed to incurpublic static float getCostConstraint()
protected void addRenderingHintEnforcer(RenderingHintEnforcer enforcer)
enforcer - protected void addRenderingConstraintEnforcer(RenderingConstraintEnforcer enforcer)
enforcer - public java.util.Vector getRenderingConstraintEnforcers()
public boolean isRoot()
public int numChildren()
public boolean isSet()
public Widget getWidget()
public Solution getSolution()
java.lang.RuntimeException - if there is no solutionpublic void resetSolution()
public boolean isLeaf()
public WidgetBag getParent()
public java.util.Vector getChildren()
public void setParent(WidgetBag parent)
parent - the parent of this widget bagpublic SuppleType getType()
public UiObject getUiObject()
public java.util.Vector getAvailableWidgets()
public java.util.Vector getCurrentWidgets()
public boolean hasCurrentWidgetsOtherThan(java.lang.Class[] widgetClasses)
widgetClasses - a collection of class objects
public boolean hasCurrentWidgetsOtherThan(java.lang.Class widgetClass)
widgetClass - a class object
public int getNumCurrentWidgets()
public void setCurrentWidget(Widget w)
w - the current widgetpublic void restoreCurrentWidgets()
public void restoreCurrentWidgets(java.util.Vector v)
v - the old list of valid widgetspublic java.awt.Dimension getMinSize(int hints)
hints - Hints specifying the variant of the widgets to be taken into
account (see hint for Widget.getSize())
public java.awt.Dimension getMaxChildSize(int hints)
hints -
public java.awt.Dimension getMaxChildSize(int hints,
java.util.Collection objects)
hints - rendering hints that should be obeyed when calculating sizesobjects - the list of the subset of children
public java.awt.Dimension[] getMinCombinedSize(int hints,
AlignedLayoutHelper helper)
hints - extra hints that should be passed to the widgets when querying
their sizeshelper - a helper object that will help determine how to treat
different widets and how to calculate label size
public java.awt.Dimension[] getMinCombinedChildSize(int hints,
UiObject child,
AlignedLayoutHelper helper)
public java.awt.Dimension getMinChildSize(int hints,
UiObject child)
hints - rendering hints that should be obeyed when calculating sizeschild - the child
public java.awt.Dimension getSumChildSize(int hints)
hints -
public java.awt.Dimension getSumChildSize(int hints,
java.util.Collection objects)
hints - rendering hints that should be obeyed when calculating sizesobjects - the list of the subset of children
protected float getSumChildCost()
public float getCost()
public void updateWidgetCosts()
public float recomputeCost(boolean updateWidgetCosts)
protected void resetCostCache(boolean updateWidgetCosts)
protected float getHintCost(Widget w)
w - widget
public float getEffortEstimate(ActionDescription a)
a - an action description
public boolean propagate(int levels)
levels - how many levels to propagate
public boolean propagate(int levels,
boolean withConstraints)
levels - how many levels to propagatewithConstraints - set it to true if you want the explicit rendering constraints
to be propagated as well
public boolean propagate(int levels,
boolean withConstraints,
boolean pruneByCost)
levels - how many levels to propagatewithConstraints - set it to true if you want the explicit rendering constraints
to be propagated as wellpruneByCost - set it to true if it is safe to prune widgets that are too
expensive (it is generally not safe to do it with shortcuts
present)
protected boolean propagateConstraints(int levels)
levels - how far to propagate
protected boolean prune(boolean pruneByCost)
pruneByCost - set it to true if it is safe to prune widgets that are too
expensive (it is generally not safe to do it with shortcuts
present)
protected boolean satisfiesConstraints(Widget w)
protected void popTheStack()
public void undoPropagate(int levels)
public void undoPropagate(int levels,
boolean withConstraints)
protected void membershipChanged()
protected void changed()
protected void childChanged()
public void widgetCostChanged(Widget w)
w - the changed widgetpublic void addChild(WidgetBag child)
child - the child bag to be addedpublic WidgetBag getChild(UiObject object)
object - the UI object for which you want a child bag
public java.util.Enumeration children()
public boolean hasChildren()
public int getNumChildren()
public java.util.Collection getBagCollection()
public boolean equals(java.lang.Object o)
Object.equals(java.lang.Object)public int hashCode()
Object.hashCode()public java.lang.String toString()
public java.lang.String toPrettyString(java.lang.String pref)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||