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.chipstuff.Port; public class Node extends Device { public static final int TYPE_STRAIGHT = 0; public static final int TYPE_RIGHT = 1; public static final int TYPE_THREE = 2; transient ImageIcon images[]; int type; public Node(int X, int Y, Room r, int t) { x=X; y=Y; room =r; width=36; height=32; type=t; 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 (ports[0].value) 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) { switch(type) { case TYPE_STRAIGHT: ports = new Port[3]; ports[0] = new Port(16,14,Port.TYPE_INPUT,0,Port.ROT_UP,this); ports[1] = new Port(16,0,Port.TYPE_OUTPUT,12,Port.ROT_UP,this); ports[2] = new Port(19,31,Port.TYPE_OUTPUT,12,Port.ROT_DOWN,this); break; case TYPE_RIGHT: ports = new Port[3]; ports[0] = new Port(16,14,Port.TYPE_INPUT,0,Port.ROT_UP,this); ports[1] = new Port(16,0,Port.TYPE_OUTPUT,12,Port.ROT_UP,this); ports[2] = new Port(35,14,Port.TYPE_OUTPUT,12,Port.ROT_RIGHT,this); break; case TYPE_THREE: ports = new Port[4]; ports[0] = new Port(16,14,Port.TYPE_INPUT,0,Port.ROT_UP,this); ports[1] = new Port(16,0,Port.TYPE_OUTPUT,12,Port.ROT_UP,this); ports[2] = new Port(35,14,Port.TYPE_OUTPUT,12,Port.ROT_RIGHT,this); ports[3] = new Port(19,31,Port.TYPE_OUTPUT,12,Port.ROT_DOWN,this); break; } if (rotation > 0) { int rot = rotation; if (rotation%2==1) { int temp = width; width = height; height = temp; } rotation = 0; for (int r=0; r