import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.util.EventListener;
import javax.swing.*;
class Sh  extends JComponent implements MouseListener
 {
  LC lc;
  dP dp=new dP(0,0);
  dP dp2;
  dP dp2c;
  double ang=0,sc=1;
  int f=2;
  static M parent;
  static Te te;
  GeneralPath gp=new GeneralPath();
  Rectangle bounds;
  double bh,bw;
  K pk= new K((double)1,(double)0,(double)0,(double)255);
  K fk= new K((double)240,(double)1,(double)1,(double)55);
  Rectangle hitRect = new Rectangle(0, 0, 3, 3);
  Tu tu;
  boolean stu;
  public Sh(M p,Tu tu,boolean boo)
   {
    super();
    parent=p;
    te=parent.te;
    this.tu=tu;
    stu=boo;
    gp.moveTo(20.f, 0.f);
    gp.lineTo(30.f, 0.f);
    gp.quadTo(30.f, 30.f, 50.f, 60.f);
    gp.lineTo(35.f, 60.f);
    gp.curveTo(35.f, 40.f, 15.f, 40.f, 15.f, 60.f);
    gp.lineTo(0.f, 60.f);
    gp.quadTo(20.f, 30.f, 20.f, 0.f);
    bounds = gp.getBounds();
    bh=bounds.height;
    bw=bounds.width;
    dp2=new dP(0,-bh);
    dp2c=new dP(-bw/2,-bh/2);
    if(stu) stu();
    addMouseListener(this);
   }
  void stu()
   {
    if(! stu) return;
    dp=new dP(tu.x,tu.y);
    ang=tu.gh();
    pk=new K(tu.pk);
    fk=new K(tu.fk);
   }
  void setx(double x) { dp=new dP(x,dp.y); }
  void sety(double y) { dp=new dP(dp.x,y); }
  void dSh() 
   {
    if(stu) stu();
    parent.lc.rSh(this,false,1);
   }
  void fSh() 
   {
    if(stu) stu();
    parent.lc.rSh(this,false,2);
   }
  void fpkSh() 
   {
    if(stu) stu();
    K k=new K(fk);
    fk=pk;
    parent.lc.rSh(this,false,2);
    fk=k;
   }
  void dfSh() 
   {
    if(stu) stu();
    parent.lc.rSh(this,false,3);
   }
  void dcSh() 
   {
    if(stu) stu();
    parent.lc.rSh(this,true,1);
   }
  void fcSh() 
   {
    if(stu) stu();
    parent.lc.rSh(this,true,2);
   }
  void fpkcSh() 
   {
    if(stu) stu();
    K k=new K(fk);
    fk=pk;
    parent.lc.rSh(this,true,2);
    fk=k;
   }
  void dfcSh() 
   {
    if(stu) stu();
    parent.lc.rSh(this,true,3);
   }
  public void mouseReleased(MouseEvent evt) {}
  public void mousePressed(MouseEvent evt) {}
  public void mouseEntered(MouseEvent evt) {}
  public void mouseExited(MouseEvent evt) {}
  public void mouseClicked(MouseEvent evt)
   {
    tta("mouseClicked");
    hitRect.x = evt.getX()-1;
    hitRect.y = evt.getY()-1;
    //Graphics2D g = (Graphics2D)getGraphics();
    //g.scale(scale, scale);
    //g.translate(margin, margin);
    //g.setStroke(dashStroke);
    //if(g.hit(hitRect,gp, true)) tta("g.hit");
    //if(parent.lc.onsg.hit(hitRect,gp, true)) tta("onsg.hit");
    if(parent.lc.offsg.hit(hitRect,gp, true)) tta("offsg.hit");
   }
  void com() { }
  void ed(String name) 
   {
    tta1(name+".x "+Te.Svo(dp.x));
    tta1(name+".y "+Te.Svo(dp.y));
    tta1(name+".dp "+Te.Svo(dp));
    tta1(name+".ang "+Te.Svo(ang));
    tta1(name+".sc "+Te.Svo(sc));
    tta1(name+".pk "+Te.Svo(pk)); 
    tta1(name+".fk "+Te.Svo(fk)); 
    tta1(name+".tu "+tu.name);
    tta1(name+".stu "+Te.Svo(stu));
   }
  public void dofin()
   {
    try { finalize(); }
    catch (Throwable e) {}
   }
  static void tta(String s) { parent.tta(s); }
  static void tta1(String s) { parent.tta1(s); }
 }
