import java.awt.*; import java.awt.geom.*; import java.lang.Math; /** * Clase ObjetoCondicion * Esta clase implementa el objeto condicion, como trozo de programa con * parametros genericos para definir ciclos y condicionales. * @author Patricio A. Castillo Pizarro - Eric C. Maldonado Olguin * @version 1.4 - Jun 26th, 2007 */ public class ObjetoCondicion extends Forma { //Parametros para definir el centro de la forma public double x; public double y; public Point centro_forma; //Parametros que definen el evento public String nombreObjeto = new String(); public String sensor = new String(); public String type = new String(); public int veces = 0; public String condicion = new String(); //Permite indicar si el bloque esta seleccionado public boolean selected; //Permite dibujar los cuadros de manipulacion. private boolean manipulable; //Arreglo de puntos que definen la forma del bloque private Point2D[] punto; //Cuadrados que dibujan el bloque private Rectangle2D manSquare; private Rectangle2D manSquare2; private Rectangle2D Block1; private Rectangle2D Block2; private Rectangle2D Block3; /** * Constructor. * Construye a partir de las coordenadas del centro del bloque. * @param x1 Horizontal del centro. * @param y1 Vertical del centro. */ public ObjetoCondicion(double x1, double y1) { x = x1; y = y1; centro_forma = new Point(); centro_forma.setLocation (x,y); selected = false; manipulable = false; punto = new Point2D[1]; punto[0] = new Point2D.Double(x1,y1); manSquare = new Rectangle2D.Double(); manSquare2 = new Rectangle2D.Double(); Block1 = new Rectangle2D.Double(); Block2 = new Rectangle2D.Double(); Block3 = new Rectangle2D.Double(); manSquare.setRect(x-30,y-20,60,50); manSquare2.setRect(x+25,y+15,5,5); Block1.setRect(x-30,y-20,60,40); Block2.setRect(x-20,y+20,10,10); Block3.setRect(x+10,y+20,10,10); } /** * Define como se dibuja el bloque. * @param g2d grafico en que se dibuja el bloque. */ public void paintComponent(Graphics2D g2d) { if (nombreObjeto.equals("CondicionFin")){ manSquare.setRect(x-30,y-20,60,50); manSquare2.setRect(x+25,y+15,5,5); Block1.setRect(x-30,y-10,60,40); Block2.setRect(x-15,y-20,10,10); Block3.setRect(x+5,y-20,10,10); } else{ if (nombreObjeto.equals("SiNo")){ manSquare.setRect(x-30,y-20,60,50); manSquare2.setRect(x+25,y+15,5,5); Block1.setRect(x-30,y-20,60,40); Block2.setRect(x-40,y+20,10,10); Block3.setRect(x+30,y+20,10,10); }else{ manSquare.setRect(x-30,y-20,60,50); manSquare2.setRect(x+25,y+15,5,5); Block1.setRect(x-30,y-20,60,40); Block2.setRect(x-20,y+20,10,10); Block3.setRect(x+10,y+20,10,10); } } g2d.setColor(Color.GREEN); g2d.fill3DRect( (int)Block1.getX(), (int)Block1.getY(), (int)Block1.getWidth(), (int)Block1.getHeight(), true); g2d.fill3DRect( (int)Block2.getX(), (int)Block2.getY(), (int)Block2.getWidth(), (int)Block2.getHeight(), true); g2d.fill3DRect( (int)Block3.getX(), (int)Block3.getY(), (int)Block3.getWidth(), (int)Block3.getHeight(), true); g2d.setColor(Color.BLACK); if (!nombreObjeto.equals("CondicionFin")) g2d.drawString (nombreObjeto, centro_forma.x-25, centro_forma.y-5); //if(manipulable) //g2d.draw(manSquare); } /** * Traslada el bloque. * @param dx desplazamiento horizontal. * @param dy desplazamiento vertical. */ public void trasladar(double dx, double dy) { for(int i=0; i