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

// -*-Mode: Java-*- 
// $Id: Pulley.java,v 1.3 2003/03/06 00:40:49 moltmans Exp $
// Pulley.java -- 
// Author: Michael Oltmans <moltmans@ai.mit.edu> 
// Created: <Mon May 29 15:40:59 2000> 
// Time-stamp: <2000-07-19 17:00:17 moltmans> 
package rec.annotate.facts;

import rec.annotate.rules.*;
import java.util.*;
import rec.util.*;
import rec.simulate.widgets.*;
import rec.tms.*;

/**
 * This class is for storing information about pulleys
 **/
public class Pulley extends PartConstraint
{
  protected WSimPulley m_pulley;
  protected String m_name;

  public Pulley( WSimPulley pulley, String name )
  {
    super( pulley );
    Assert.notNull( pulley, "Cannot make Pulley with null pulley" );
    m_pulley = pulley;
    m_name = name;
  }

  public WSimPulley getPulley()
  {
    return m_pulley;
  }

  public String getName() 
  {
    return m_name;
  }

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

  public boolean sameFact( Fact fact ) 
  {
    if( fact instanceof Pulley ) {
      Pulley pulley = (Pulley)fact;
      return ( m_pulley.equals( pulley.m_pulley ) &&
	       m_name.equals( pulley.m_name ) );
    }
    return false;
  }

  public boolean isAttachedTo( Body body ) 
  {
    return ( m_pulley.getBodies().contains( body ) );
  }

  public String toEnglish() 
  {
    return m_name;
  }

  public String toString() 
  {
    return "<Pulley: [" + m_name + "]>";
  }
}
