TAREA_CFUENTE.java



// IMPLEMENTACINO DE LA CLASE FUENTE -IMAGEN-
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class CFUENTE extends Canvas
{
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Image F_00 = toolkit.getImage("Fuente_00.jpg");
    Image F_90 = toolkit.getImage("Fuente_90.jpg");
    Image Fuente = F_00;
    private boolean Orientacion = true; // horizontal = true
                                        // vertical   = false

    int PCXi = PosX,      PCYi = PosY+DimY/2;   // Punto de contacto inicial
    int PCXf = PosX+DimX, PCYf = PosY+DimY/2;   // Punto de contacto final

  // Constructores
  //____________________________________________________________________________
  public CFUENTE(int x, int y) { PosX = x; PosY = y; }
  public CFUENTE() { this(1, 1); }

  public void Dibuja(Graphics R, AreaGrafica AG) { R.drawImage(Fuente, PosX, PosY, AG); }

  void Posicion(int x, int y, Interfaz FRAME)
  {
      PosAX = PosX;
      PosAY = PosY;
      PosX = x;
      PosY = y;
  }

  void Rota()
  {
      Fuente = (Orientacion ? F_90 : F_00);
      Orientacion = (Orientacion ? false : true);
      if (Orientacion)    // Horizontal
      {
          DimX = DimX00; DimY = DimY00;
          PCXi = PosX;          PCYi = PosY + DimY/2;
          PCXf = PosX + DimX;   PCYf = PosY + DimY/2;
      }
      else                // Vertical
      {
          DimX = DimX90; DimY = DimY90;
          PCXi = PosX + DimX/2;     PCYi = PosY;
          PCXf = PosX + DimX/2;     PCYf = PosY + DimY;
      }
  }
}