import java.awt.*;
import javax.swing.*;
import java.util.*;
class  LSpP extends JSplitPane
 {
  Te te;
  M parent;
  K bk= new K((double)120,(double)1,(double)1,(double)55);
  String name,host="",hosttype="",ori="horz",pos;
  dP s=new dP(400,400);
  int ldl=0;
  double div=0.5,rsw=0.5;
  LSpP lspp;
  LC lc;
  Hashtable kidstrh=new Hashtable();
  String[] kidsbla=new String[32];
  int nflayertr=1;
  int nflayerbl=1;
  public LSpP() { super(); }
  public LSpP(M p,String n,String o,double div,double rsw)
   {
    super();
    hosttype="other";
    init(p,n,o,div,rsw);
   }
  public LSpP(M p,String n,LF lf,String o,double div,double rsw)
   {
    super();
    init(p,n,o,div,rsw);
    host=lf.name;
    hosttype="LF";
    lf.getContentPane().add(this);
   }
  public LSpP(M p,String n,LSpP lspp,String pos,String o,double div,double rsw)
   {
    super();
    this.lspp=lspp;
    this.pos=pos;
    init(p,n,o,div,rsw);
    if(pos.equals("top")) lspp.setTopComponent(this);
    if(pos.equals("bottom")) lspp.setBottomComponent(this);
    if(pos.equals("right")) lspp.setRightComponent(this);
    if(pos.equals("left")) lspp.setLeftComponent(this);
    host=lspp.name;
    hosttype="LSpP";
   }
  public void init(M p,String n,String o,double div,double rsw)
   {
    this.setOpaque( false ) ;
    parent=p;
    te=parent.te;
    name=n;
    ori=o;
    this.div=div;
    this.rsw=rsw;
    Te.LSpPh.put(name,this);
    if(ori.equals("horz")) setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    else if(ori.equals("vert")) setOrientation(JSplitPane.VERTICAL_SPLIT);
    setOneTouchExpandable(true);
    setResizeWeight(rsw);
    setDiv(div);
    Te.LSpPh.put(name,this);
   }
  dP getSize(int mode) { return s=new dP(getSize().getWidth(),getSize().getHeight()); }
  void setDiv(double d) { divlib(d); }
  void setDivpc(double d) { divlib(d/100); }
  void ret() { setDividerLocation(ldl); }
  void max() { divlib(1.0); }
  void min() { divlib(0.0); }
  void divlib(double d)
   {
    ldl=getDividerLocation();
    setLastDividerLocation(ldl);
    if (d>1) setDividerLocation((int)d);
    // else setDividerLocation(.5); // fixme  AJLogo1040
    else setDividerLocation(d);  // machd
   }
  void dofin()
   {
    //try { finalize(); } catch (Throwable e) {}
    if(hosttype.equals("LSpP"))
     {
      lspp.remove(this);
      lspp.doLayout();
      lspp.repaint();
     }
   }
  void doLCnull()
   {
    lc=null;
   }
  void attach(LP lp,String pos,int l)
   {
    setlayer(lp,pos,l);
    if(pos.equals("left")) setLeftComponent(lp);
    else if(pos.equals("right")) setRightComponent(lp);
    else if(pos.equals("top")) setTopComponent(lp);
    else if(pos.equals("bottom")) setBottomComponent(lp);
   }
  void attach(LP lp,String pos)
   {
    setlayer(lp,pos);
    if(pos.equals("left")) setLeftComponent(lp);
    else if(pos.equals("right")) setRightComponent(lp);
    else if(pos.equals("top")) setTopComponent(lp);
    else if(pos.equals("bottom")) setBottomComponent(lp);
   }
  void detach(LP lp) { remove(lp); }
  void setlayer(LP lp,String p,int l) 
   {
    if(pos.equals("left")) setLeftComponent(lp);
    else if(pos.equals("right")) setRightComponent(lp);
    else if(pos.equals("top")) setTopComponent(lp);
    else if(pos.equals("bottom")) setBottomComponent(lp);
   }
  void setlayer(LP lp,String p) 
   {
    if(pos.equals("top") || pos.equals("right")) setlayer(lp,p,nflayertr++);
    else setlayer(lp,p,nflayerbl++);
   }
  int getlayer(LP lp) { return 42; }
  public void tta(String s) { parent.tta(s); }
  public void tta1(String s) { parent.tta1(s); }
  void ed()
   {
    double divpc=0;
    dP dp=getSize(1);
    div=getDividerLocation();
    int ds=getDividerSize();
    if(ori.equals("horz")) divpc=100*div/(dp.x-ds);
    else divpc=100*div/(dp.y-ds);
    tta1(name+".name "+name);
    tta1(name+".host "+host);
    tta1(name+".hosttype "+hosttype);
    tta1(name+".div "+div);
    tta1(name+".divpc "+divpc);
   }
 }
