Class GraphicGate

java.lang.Object
  |
  +--java.awt.Component
        |
        +--GraphicGate
Direct Known Subclasses:
AndGraphicGate, InputGraphicGate, NandGraphicGate, NodeGraphicGate, NorGraphicGate, NotGraphicGate, OrGraphicGate, XnorGraphicGate, XorGraphicGate

public abstract class GraphicGate
extends java.awt.Component

GraphicGate is an abstract class that is extended by each of the different types of gates, as well as the input object. For gates like not, (and for the input object) one or both of the input gates will be set so that the correct output is given.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
protected  java.awt.Graphics g
           
protected  Macro gateMacro
           
protected  int gateType
           
protected  int id
           
protected  java.awt.Image image
           
protected  java.lang.String imageLocation
           
protected  GraphicGate input1
           
protected  GraphicGate input2
           
protected  LogicGate logicGate
           
protected  java.util.Vector output
           
protected  boolean outputValue
           
protected  int x
           
protected  int y
           
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
(package private) GraphicGate(int x_, int y_, int id_, Macro gateMacro_, java.awt.Graphics g_)
          GraphicGate constructor - takes location and id, initializes those values, as well as setting up Vector for storing output gates
 
Method Summary
(package private)  void addOutputGate(GraphicGate gate)
          adds gate to the Vector of output gates
(package private)  void drawImage()
          draws the image at the gate location
(package private)  void drawOutput()
          draws the output value of the gate
(package private)  int getGateType()
          returns the gateType
(package private)  int getID()
          returns current gate id
(package private)  GraphicGate getInput1()
          returns the gate connected to input1 of current gate
(package private)  GraphicGate getInput2()
          returns the gate connected to input2 of current gate
(package private)  LogicGate getLogicGate()
          returns the LogicGate corresponding to current gate
(package private)  Macro getMacro()
          returns macro
(package private)  java.util.Vector getOutputGates()
          returns the vector of output gates
(package private)  boolean getOutputValue()
          returns the output value of a gate
(package private)  int getXCoor()
          returns the x coordinate of the gate
(package private)  int getYCoor()
          returns the y coordinate of the gate
protected  void loadImage()
          loads the image given by imageLocation into the gate image
(package private)  void remove()
          deletes a gate
(package private)  boolean removeOutputGate(GraphicGate gate)
          removes the given gate from the Vector of output gates
(package private)  void setGateLocation(int x_, int y_)
          sets the gate location - used to move gate as well
(package private)  void setInput1(GraphicGate input1_)
          sets input1 of the gate to the gate being connected
(package private)  void setInput2(GraphicGate input2_)
          sets input2 of the gate to the gate being connected
(package private)  void setLogicGate(LogicGate logicGate_)
          sets the logicGate variable - should be called in LogicGate constructor
(package private)  void setMacro(Macro gateMacro_)
          sets macro
(package private)  void setOutputGates(java.util.Vector outputGates)
          takes a vector of gates and sets it to the output gates vector
(package private)  void setOutputValue(boolean outputValue_)
          sets the output value of the gate - called by coresponding logic gate when calculate is run
 
Methods inherited from class java.awt.Component
, action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, constructComponentName, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventEnabled, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getIntrinsicCursor, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, lightweightPrint, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, postsOldMouseEvents, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

protected int x

y

protected int y

id

protected int id

gateType

protected int gateType

image

protected java.awt.Image image

g

protected java.awt.Graphics g

imageLocation

protected java.lang.String imageLocation

input1

protected GraphicGate input1

input2

protected GraphicGate input2

outputValue

protected boolean outputValue

output

protected java.util.Vector output

logicGate

protected LogicGate logicGate

gateMacro

protected Macro gateMacro
Constructor Detail

GraphicGate

GraphicGate(int x_,
            int y_,
            int id_,
            Macro gateMacro_,
            java.awt.Graphics g_)
GraphicGate constructor - takes location and id, initializes those values, as well as setting up Vector for storing output gates
Parameters:
x_ - x coordinate
y_ - y coordinate
id_ - gate id
g_ - Graphics object to be drawn on
Method Detail

loadImage

protected void loadImage()
loads the image given by imageLocation into the gate image

drawImage

void drawImage()
draws the image at the gate location

drawOutput

void drawOutput()
draws the output value of the gate

getGateType

int getGateType()
returns the gateType
Returns:
returns gateType

getMacro

Macro getMacro()
returns macro
Returns:
returns macro

setMacro

void setMacro(Macro gateMacro_)
sets macro
Parameters:
gateMacro_ - the new macro

setLogicGate

void setLogicGate(LogicGate logicGate_)
sets the logicGate variable - should be called in LogicGate constructor
Parameters:
logicGate_ - the coresponding logic gate to this graphic gate

getLogicGate

LogicGate getLogicGate()
returns the LogicGate corresponding to current gate
Returns:
returns corresponding logicGate

setGateLocation

void setGateLocation(int x_,
                     int y_)
sets the gate location - used to move gate as well
Parameters:
x_ - x coordinate
y_ - y coordinate

getXCoor

int getXCoor()
returns the x coordinate of the gate
Returns:
x coordinate as an int

getYCoor

int getYCoor()
returns the y coordinate of the gate
Returns:
y coordinate as an int

setOutputValue

void setOutputValue(boolean outputValue_)
sets the output value of the gate - called by coresponding logic gate when calculate is run
Parameters:
outputValue_ - output value of gate

getOutputValue

boolean getOutputValue()
returns the output value of a gate
Returns:
output value of gate

addOutputGate

void addOutputGate(GraphicGate gate)
adds gate to the Vector of output gates
Parameters:
gate - gate to be added

removeOutputGate

boolean removeOutputGate(GraphicGate gate)
removes the given gate from the Vector of output gates
Parameters:
gate - gate to be removed
Returns:
return true if gate is removed, false if not

getOutputGates

java.util.Vector getOutputGates()
returns the vector of output gates
Returns:
returns the Vector of output gates

setOutputGates

void setOutputGates(java.util.Vector outputGates)
takes a vector of gates and sets it to the output gates vector
Parameters:
outputGates - vector of gates

setInput1

void setInput1(GraphicGate input1_)
sets input1 of the gate to the gate being connected
Parameters:
input1_ - the gate being connected

getInput1

GraphicGate getInput1()
returns the gate connected to input1 of current gate
Returns:
returns gate connected on input1

setInput2

void setInput2(GraphicGate input2_)
sets input2 of the gate to the gate being connected
Parameters:
input2_ - the gate being connected

getInput2

GraphicGate getInput2()
returns the gate connected to input2 of current gate
Returns:
returns gate connected on input2

getID

int getID()
returns current gate id
Returns:
returns the current gate id

remove

void remove()
deletes a gate