package cl.jtv;


//Title:        Proyecto Turing Visual

//Version:

//Copyright:    Copyright (c) 1998

//Author:       Marco Antonio Mora Godoy

//Company:      Your Company

//Description:  No admires, CREA!!!!...





import java.awt.*;

import java.lang.*;




public class L extends Maquina {



  L(int x,int y,Cinta c,Maquina prev,Maquina prox){



    super(x,y,c,prev,prox);
    this.setIconValue(JTV.MyRenderer.ICONO_L);
    this.setNombre("L");
  }
  
  L(int x,int y,int c,Maquina prev,Maquina prox){



    super(x,y,c,prev,prox);
    this.setIconValue(JTV.MyRenderer.ICONO_L);
    this.setNombre("L");
  }



  public void accion(){



    cinta.mover_L();

    super.accion();



  }
  
  
  public void accion(Cinta _cinta){
      
        _cinta.mover_L();
      
  }
  
  public boolean accion(Cinta[] _arrayOfTapes,DiccionarioMetavalores dicMetavalores){
    
        return _arrayOfTapes[this.getIndiceCinta()].mover_L();
  }



  public void dibujar(Graphics g){
    
    if(Maquina.selectedMachine!=null && this==Maquina.selectedMachine)
        g.setColor(Color.magenta);
    else if(JTV.searchedMachine!=null && this==JTV.searchedMachine)
        g.setColor(Color.pink);
    else if(Maquina.playMachine!=null && this==Maquina.playMachine)
        g.setColor(Color.red);
    else
        g.setColor(Color.black);
    
   
    

    //g.setFont(Maquina.FONT_TRI30);
    g.setFont(Maquina.FONT_TRI25);
    
    if(Maquina.oldNotation)
        g.drawString(getNombre(),x0,y0);
    else
        LHD.dibujar(g,x0,y0);
    
    if(this.isInicial()) g.drawString(Maquina.SIMBOLO_INICIAL,x0-(int)Maquina.RECT_INICIAL.getWidth(),y0);

    //g.setFont(Maquina.FONT_TRP19);
    //g.setFont(Maquina.FONT_TRP16);
    //g.drawRect((int)this.getBoundRectangle().getX(),(int)this.getBoundRectangle().getY(),(int)this.getBoundRectangle().getWidth(),(int)this.getBoundRectangle().getHeight());
    if(Maquina.displayIndex){
        g.setFont(Maquina.FONT_TRP13);
        g.drawString("(" + (this.getIndiceCinta()+1) + ")",x0+Maquina.delta_x,y0-Maquina.delta_y);
    }
    super.dibujar(g);

  }
  
  public int getIconValue(){
        
      if(Maquina.oldNotation)
        return iconValue;
      else
        return JTV.MyRenderer.ICONO_LHD;
  }

  public String getXML() {
      
      String xml = "";
      xml+="<L \n";
      xml+="    id=\""+this.idMaquina+"\"\n";
      xml+="    id-previa=\""+(this.previa==null?"null":Integer.toString(this.previa.idMaquina))+"\"\n";
      xml+="    id-proxima=\""+(this.proxima==null?"null":Integer.toString(this.proxima.idMaquina))+"\"\n";
      xml+="    x=\""+this.x0+"\"\n";
      xml+="    y=\""+this.y0+"\"\n";
      xml+="    cinta=\""+this.getIndiceCinta()+"\"\n";
      xml+="    inicial=\""+this.isInicial()+"\"\n";
      xml+="/>\n\n";
      
      return xml;
  }  
  
}