package com.droidquest.devices; import com.droidquest.devices.Device; import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.swing.ImageIcon; import com.droidquest.Room; import com.droidquest.Wire; import com.droidquest.chipstuff.Port; public class FlipFlop extends Device { public boolean state; public Color c1; public Color c2; public transient ImageIcon images[]; public FlipFlop(int X, int Y, Room r) { x=X; y=Y; room =r; width=48; height=32; GenerateIcons(); currentIcon = icons[rotation%2].getImage(); try { g = icons[0].getImage().getGraphics(); } catch (NullPointerException e) { System.out.println("Could not get Graphics pointer to ANDGate Image"); return; } } public void Decorate() { super.Decorate(); if (!state) g.drawImage(images[4+rotation].getImage(), 0, 0, level); else g.drawImage(images[rotation].getImage(), 0, 0, level); } public void GenerateIcons() { super.GenerateIcons(); if (ports==null) { ports = new Port[4]; ports[0] = new Port(11,29,Port.TYPE_INPUT,6,Port.ROT_DOWN,this); ports[1] = new Port(39,27,Port.TYPE_INPUT,4,Port.ROT_DOWN,this); ports[2] = new Port(8,2,Port.TYPE_OUTPUT,8,Port.ROT_UP,this); ports[3] = new Port(36,0,Port.TYPE_OUTPUT,10,Port.ROT_UP ,this); if (rotation > 0) { int rot = rotation; if (rotation%2==1) { int temp = width; width = height; height = temp; } rotation = 0; for (int r=0; r