se.liu.ida.critiquer.constraints
Class StandardConstraint

java.lang.Object
  extended by se.liu.ida.critiquer.activities.AbstractParamChangedListener
      extended by se.liu.ida.critiquer.constraints.StandardConstraint
All Implemented Interfaces:
Serializable, Comparable<ActivityUpdateListener>, ActivityUpdateListener, SingletonConstraint, VisualConstraint, ViewRenderingListener
Direct Known Subclasses:
ActivityStructureCritic, CorrectOrdering, NonSuitableAgent, ResourceUsageCritic, SimulationCritic, StructureCritic, TestActivityArea, TimeCalculator, TooLongTime

public abstract class StandardConstraint
extends AbstractParamChangedListener
implements SingletonConstraint, VisualConstraint

Abstract class for those constraints only interested in when parameter values are changed. Provide dummy implementations for all other methods. To use these constraints, we must make sure they are listed in the ReferenceHolder.constraintClasses list. These constraints, if created by the ConstraintFactory, use the default constructor in this class that adds them as ActivityUpdateListeners so they do NOT have to register themselves as activity update listeners.

This class also provides a dummy implementation of evaluateActivities since we would rather like to have constraints update themselves when parameter values change and not do it manually on request.

See Also:
Serialized Form

Field Summary
protected  ArrayList<Class<? extends View>> applicableViews
           
protected static HashSet<ConstraintStatusListener> statusListeners
           
protected  HashMap<Activity,Boolean> violationActivities
           
 
Constructor Summary
protected StandardConstraint()
           
 
Method Summary
static void addStatusListener(ConstraintStatusListener l)
          Add to the list of update listeners
 void debug(Object arg0)
          Create debugging information
 void error(Object arg0)
          Logs errors
 List<Class<? extends View>> getApplicableViews()
          By default, all constraints should be visible in all views
 Color getColor()
           
 void info(Object arg0)
          Create non-debuggning information
protected  void initApplicableViews()
           
 boolean isActive()
          Should this constraint be displayed?
 boolean isApplicableFor(View view)
           
 boolean isConsistent()
           
static void removeStatusListener(ConstraintStatusListener l)
          Remove from the list of update listeners
 void setActive(boolean active)
          Set active status and notify status listeners
 void setColor(Color c)
           
protected  void setConsistent(boolean consistent)
          Update violation status and notify status listeners
 void warn(Object arg0)
          Logs warnings
 
Methods inherited from class se.liu.ida.critiquer.activities.AbstractParamChangedListener
activityCreated, activityRemoved, activityUpdated, compareTo, paramAdded, paramChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface se.liu.ida.critiquer.constraints.SingletonConstraint
getDescription
 
Methods inherited from interface se.liu.ida.critiquer.gui.ViewRenderingListener
viewUpdated
 

Field Detail

applicableViews

protected ArrayList<Class<? extends View>> applicableViews

statusListeners

protected static HashSet<ConstraintStatusListener> statusListeners

violationActivities

protected HashMap<Activity,Boolean> violationActivities
Constructor Detail

StandardConstraint

protected StandardConstraint()
Method Detail

isApplicableFor

public boolean isApplicableFor(View view)
Specified by:
isApplicableFor in interface VisualConstraint

getColor

public Color getColor()
Specified by:
getColor in interface VisualConstraint

setColor

public void setColor(Color c)
Specified by:
setColor in interface VisualConstraint

getApplicableViews

public List<Class<? extends View>> getApplicableViews()
By default, all constraints should be visible in all views

Specified by:
getApplicableViews in interface VisualConstraint

initApplicableViews

protected void initApplicableViews()

isActive

public boolean isActive()
Description copied from interface: VisualConstraint
Should this constraint be displayed?

Specified by:
isActive in interface VisualConstraint
Returns:
true iff this constraint should be displayed
See Also:
VisualConstraint.isActive()

setActive

public void setActive(boolean active)
Set active status and notify status listeners

Specified by:
setActive in interface VisualConstraint
See Also:
VisualConstraint.setActive(boolean)

addStatusListener

public static void addStatusListener(ConstraintStatusListener l)
Add to the list of update listeners

See Also:
se.liu.ida.critiquer.constraints.VisualConstraint#addStatusListener(se.liu.ida.critiquer.constraints.ConstraintStatusListener)

removeStatusListener

public static void removeStatusListener(ConstraintStatusListener l)
Remove from the list of update listeners

See Also:
se.liu.ida.critiquer.constraints.VisualConstraint#removeStatusListener(se.liu.ida.critiquer.constraints.ConstraintStatusListener)

isConsistent

public boolean isConsistent()
Returns:
Returns the consistent.

setConsistent

protected void setConsistent(boolean consistent)
Update violation status and notify status listeners

Parameters:
consistent - The consistent to set.

debug

public void debug(Object arg0)
Create debugging information

See Also:
Category.debug(java.lang.Object)

info

public void info(Object arg0)
Create non-debuggning information

See Also:
Category.info(java.lang.Object)

error

public void error(Object arg0)
Logs errors

See Also:
Category.error(java.lang.Object)

warn

public void warn(Object arg0)
Logs warnings

See Also:
Category.warn(java.lang.Object)