import java.awt.*;
import java.awt.image.*;
import java.util.*;

public class FStick extends Stick {
  public static int TRANSLATE = 1;
  
  Vector children = new Vector();
  Hashtable cpoint = new Hashtable();
  public int constraint, endparent, endchild;

  FStick(double a, double b, double c, double d, double w,
	 ImageObserver im){
    super(a, b, c, d, w, im);
  }


  public void addChild (FStick child, int ep){
    children.addElement(child);
    cpoint.put(child, new Integer(ep));
  }

  public void applyConstraints() {
    int localend, remoteend;
    double lx, ly, rx, ry;

    for(Enumeration e = children.elements(); e.hasMoreElements();){
      FStick fs = (FStick) e.nextElement();
      localend = ((Integer) cpoint.get(fs)).intValue();
      remoteend = fs.endchild;
      if(localend == 1){
	lx = x1;
	ly = y1;
      }
      else{
	lx = x2;
	ly = y2;
      }

      if(remoteend == 1){
	rx = fs.x1;
	ry = fs.y1;
      }
      else{
	rx = fs.x2;
	ry = fs.y2;
      }

      fs.xMove(lx-rx);
      fs.yMove(ly-ry);
      
    }
  }
}
