nanomunchers.ui
Class GraphDrawing

java.lang.Object
  extended bynanomunchers.ui.GraphDrawing

public class GraphDrawing
extends java.lang.Object

All of the functions for drawing either Nanomunchers or the graph are done through this class.

Author:
David Kaplin

Constructor Summary
GraphDrawing()
           
 
Method Summary
 void drawBotAlive(java.awt.Graphics g, java.awt.Color c, int x, int y, int nextX, int nextY)
           
 void drawBotDead(java.awt.Graphics g, java.awt.Color c, int x, int y, int nextX, int nextY)
          Draws a bot that has exhausted the food supply.
 void drawBotSlain(java.awt.Graphics g, java.awt.Color c, int x, int y, int nextX, int nextY)
          Draws a bot that was killed by conflict
 void drawEdge(java.awt.Graphics g, java.awt.Color c, Edge e, int thickness)
           
 void drawGraph(java.awt.Graphics g, java.awt.Color c, int width, int height)
          May stretch the graph a bit out of proportion, tries to ensure the whole graph fitting.
 void highlightEdge(java.awt.Graphics g, java.awt.Color c, Edge e, int thickness)
          Similar to draw edge, but also draws the end nodes.
 void setGraph(Graph g)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphDrawing

public GraphDrawing()
Method Detail

setGraph

public void setGraph(Graph g)
Parameters:
g - Graph that may be drawn

drawGraph

public void drawGraph(java.awt.Graphics g,
                      java.awt.Color c,
                      int width,
                      int height)
May stretch the graph a bit out of proportion, tries to ensure the whole graph fitting.

Parameters:
g - Graphics context
c - color for the edges and nodes of the graph
width - maximum for drawing
height - maximum for drawing

drawEdge

public void drawEdge(java.awt.Graphics g,
                     java.awt.Color c,
                     Edge e,
                     int thickness)
Parameters:
g - Graphics context
c - Color for edge
e - being drawn
thickness - = 1 + 2*thickness pixels for the width of the edge.

highlightEdge

public void highlightEdge(java.awt.Graphics g,
                          java.awt.Color c,
                          Edge e,
                          int thickness)
Similar to draw edge, but also draws the end nodes.

Parameters:
g - Graphics context
c - Color for edge
e - being drawn
thickness - = 1 + 2*thickness pixels for the width of the edge.

drawBotAlive

public void drawBotAlive(java.awt.Graphics g,
                         java.awt.Color c,
                         int x,
                         int y,
                         int nextX,
                         int nextY)
Parameters:
g - Graphics context
c - color for the bot's body
x - position of the center of the bot's body
y - position of the center of the bot's body
nextX - future position for the bot's body
nextY - future position for the bot's body

drawBotDead

public void drawBotDead(java.awt.Graphics g,
                        java.awt.Color c,
                        int x,
                        int y,
                        int nextX,
                        int nextY)
Draws a bot that has exhausted the food supply.

Parameters:
g - Graphics context
c - color for the bot's body
x - position of the center of the bot's body
y - position of the center of the bot's body
nextX - future position for the bot's body.
nextY - future position for the bot's body.

drawBotSlain

public void drawBotSlain(java.awt.Graphics g,
                         java.awt.Color c,
                         int x,
                         int y,
                         int nextX,
                         int nextY)
Draws a bot that was killed by conflict

Parameters:
g - Graphics context
c - color for the bot's body
x - position of the center of the bot's body
y - position of the center of the bot's body
nextX - future position for the bot's body.
nextY - future position for the bot's body.