// IMPLEMENTACINO DE LA CLASE CAPACITOR -IMAGEN-
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CCAPACITOR extends Canvas
{
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image C_00 = toolkit.getImage("Capacitor_00.jpg");
Image C_90 = toolkit.getImage("Capacitor_90.jpg");
Image Capacitor = C_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 CCAPACITOR(int x, int y) { PosX = x; PosY = y; }
public CCAPACITOR() { this(1, 1); }
public void Dibuja(Graphics R, AreaGrafica AG) { R.drawImage(Capacitor, PosX, PosY, AG); }
void Posicion(int x, int y, Interfaz FRAME)
{
PosAX = PosX;
PosAY = PosY;
PosX = x;
PosY = y;
}
void Rota()
{
Capacitor = (Orientacion ? C_90 : C_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;
}
}
}