// (c) MIT 2003.  All rights reserved.

// -*-Mode: Java-*- 
// $Id: Grounded.java,v 1.3 2003/03/06 00:40:49 moltmans Exp $
// Grounded.java -- 
// Author: Michael Oltmans <moltmans@ai.mit.edu> 
// Created: <Thu Jun 01 22:24:37 2000> 
// Time-stamp: <2000-07-19 16:55:43 moltmans> 
package rec.annotate.facts;

import rec.annotate.rules.*;
import java.util.*;
import rec.util.*;
import rec.sys.*;
import rec.tms.*;
import rec.geo.*;

/**
 **/
public class Grounded extends Annotation
{
  protected PartConstraint m_part;
  protected Body m_body;

  public Grounded( PartConstraint part, Body body )
  {
    super( part.getStartTime(), part.getEndTime() );
    m_part = part;
    m_body = body;
  }

  public Body getBody() 
  {
    return m_body;
  }

  public PartConstraint getPart() 
  {
    return m_part;
  }

  public GPoint getAttachmentPoint() 
  {
    return m_part.getConstraint().getAttachmentPoint( m_body.getBody() );
  }

  public String getFactType() 
  {
    return Type.GROUNDED;
  }

  public boolean sameFact( Fact fact ) 
  {
    if( fact instanceof Grounded ) {
      Grounded a = (Grounded)fact;
      return ( m_part.sameFact( a.m_part ) &&
	       m_body.sameFact( a.m_body ) );
    }
    return false;
  }

  public String toEnglish() 
  {
    return  m_part.toEnglish() + " attaches " + 
      m_body.toEnglish() + " to the background";
  }

  public String toString() 
  {
    return "<Grounded: " + m_part.getName() + " attaches " +
      m_body.getName() + " to background>";
  }
}
