se.liu.ida.critiquer.constraints
Class ActivityStructureCritic

java.lang.Object
  extended by se.liu.ida.critiquer.activities.AbstractParamChangedListener
      extended by se.liu.ida.critiquer.constraints.StandardConstraint
          extended by se.liu.ida.critiquer.constraints.ActivityStructureCritic
All Implemented Interfaces:
Serializable, Comparable<ActivityUpdateListener>, ActivityUpdateListener, ConstraintStatusListener, SingletonConstraint, TextCritic, VisualConstraint, ViewRenderingListener

public class ActivityStructureCritic
extends StandardConstraint
implements TextCritic, ConstraintStatusListener

If an activity needs to have some special properties in order to be considered completely specified, we can use this constraint to notify the user. For instance, we may require that there should be a top-level activity for each mission and therefore, all new activities except top-level activities should have a parent.

This critic can be considered to be a meta-level critic since it collects information from other critics. This information can be displayed in textual form, but more importantly it can be used by activities

Author:
olale
See Also:
Serialized Form

Field Summary
 
Fields inherited from class se.liu.ida.critiquer.constraints.StandardConstraint
applicableViews, statusListeners, violationActivities
 
Constructor Summary
ActivityStructureCritic()
           
 
Method Summary
 void activeStatusChanged(StandardConstraint c)
          Listen to when structure critics change active status.
 void addStructureCritic(StructureCritic critic)
          Add a critic to the map of structure critics
 int compareTo(ActivityUpdateListener l)
          Make sure the structure critics are processed before the ActivityStructureCritic
 String getDescription()
          Returns a description
static ActivityStructureCritic getSingleton()
           
 StructureCritic getStructureCritic(String name)
           
 String getText()
          Summarize the information collected from all the individual structure critics.
protected  void initApplicableViews()
          Set this critic visible in the graph view only
 boolean isConsistent(Activity activity)
           
<T> void
paramChanged(Activity activity, Parameter<T> p)
          If one of the structure critics returns false, our status should be "inconsistent", otherwise consistent.
 void viewUpdated(View v, Graphics2D g2)
          Present some graphical information
 void violationStatusChanged(StandardConstraint c)
          We are only interested in structure critics here, so we need to make sure we are not listening to other critics.
 
Methods inherited from class se.liu.ida.critiquer.constraints.StandardConstraint
addStatusListener, debug, error, getApplicableViews, getColor, info, isActive, isApplicableFor, isConsistent, removeStatusListener, setActive, setColor, setConsistent, warn
 
Methods inherited from class se.liu.ida.critiquer.activities.AbstractParamChangedListener
activityCreated, activityRemoved, activityUpdated, paramAdded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActivityStructureCritic

public ActivityStructureCritic()
Method Detail

addStructureCritic

public void addStructureCritic(StructureCritic critic)
Add a critic to the map of structure critics


getStructureCritic

public StructureCritic getStructureCritic(String name)

getText

public String getText()
Summarize the information collected from all the individual structure critics.

Specified by:
getText in interface TextCritic

isConsistent

public boolean isConsistent(Activity activity)

paramChanged

public <T> void paramChanged(Activity activity,
                             Parameter<T> p)
If one of the structure critics returns false, our status should be "inconsistent", otherwise consistent. This is handled by listening to when the structure critics change status and not here however.

Specified by:
paramChanged in interface ActivityUpdateListener
Specified by:
paramChanged in class AbstractParamChangedListener
See Also:
se.liu.ida.critiquer.activities.AbstractParamChangedListener#paramChanged(se.liu.ida.critiquer.activities.Activity, critiquer.activities.parameters.Parameter), violationStatusChanged(StandardConstraint)

getDescription

public String getDescription()
Returns a description

Specified by:
getDescription in interface SingletonConstraint
See Also:
SingletonConstraint.getDescription()

viewUpdated

public void viewUpdated(View v,
                        Graphics2D g2)
Present some graphical information

Specified by:
viewUpdated in interface ViewRenderingListener
See Also:
ViewRenderingListener.viewUpdated(se.liu.ida.critiquer.gui.View, java.awt.Graphics2D)

initApplicableViews

protected void initApplicableViews()
Set this critic visible in the graph view only

Overrides:
initApplicableViews in class StandardConstraint
See Also:
StandardConstraint.initApplicableViews()

getSingleton

public static ActivityStructureCritic getSingleton()
Returns:
Returns the singleton.

compareTo

public int compareTo(ActivityUpdateListener l)
Make sure the structure critics are processed before the ActivityStructureCritic

Specified by:
compareTo in interface Comparable<ActivityUpdateListener>
Overrides:
compareTo in class AbstractParamChangedListener
See Also:
java.lang.Comparable#compareTo(T)

activeStatusChanged

public void activeStatusChanged(StandardConstraint c)
Listen to when structure critics change active status. The active status is only supposed to indicate when a critic should show information graphically, so this should not be applicable to the text-only structure critics

Specified by:
activeStatusChanged in interface ConstraintStatusListener
See Also:
ConstraintStatusListener.activeStatusChanged(se.liu.ida.critiquer.constraints.StandardConstraint)

violationStatusChanged

public void violationStatusChanged(StandardConstraint c)
We are only interested in structure critics here, so we need to make sure we are not listening to other critics. We collect the information from all structure critics and set our consistency status depending on that, since it may be the case that this critic is inconsistent, but all structure critics have actually become consistent.

Specified by:
violationStatusChanged in interface ConstraintStatusListener
See Also:
ConstraintStatusListener.violationStatusChanged(se.liu.ida.critiquer.constraints.StandardConstraint)