support.graph
Class GraphCanvas

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by support.graph.GraphCanvas
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class GraphCanvas
extends java.awt.Canvas
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GraphCanvas(GraphViz main, java.lang.String graphClassName, java.lang.String kruskalClassName, java.lang.String primClassName)
           
 
Method Summary
 void addCloud(CS16Decorator<CS16Vertex,java.lang.Integer> cloud, CS16Decorator<CS16Vertex,CS16Vertex> parents)
          Adds another cloud to the cloud animations.
 void addEdge(CS16Vertex v1, CS16Vertex v2, int weight)
           
 void addMST(CS16Decorator<CS16Edge,java.lang.Boolean> edges)
          Adds another set of MST edges to the collection for animation.
 void addMST(CS16Edge[] edges)
          Adds another set of MST edges to the collection for animation.
 CS16Vertex addPoint(java.awt.event.MouseEvent e)
          Adds a vertex to the visualizer, and to the graph structure
 CS16Vertex addVertex(java.lang.String name, int x, int y)
          method to add a vertex to the visualizer and to the graph structure called when vertices input by either mouse clicks or file loading
 void areAdjacent()
           
 void cleanup()
           
 void clear()
           
 void clearMinSpanForest()
          Clears the minimum spanning tree.
 boolean clickedOnEdge(int x, int y, VizVertex v1, VizVertex v2)
           
 void connectingEdge()
           
 void displayEdge(java.awt.Graphics graphics, VizVertex u, VizVertex v, CS16Edge e)
           
 void displayEdgeStandalone(java.awt.Graphics g, VizVertex u, VizVertex v)
           
 void displayFocusEdgeLabel(java.awt.Graphics g, VizVertex u, VizVertex v)
           
 void displayLabel(java.awt.Graphics g, int string, VizVertex u, VizVertex v)
           
 void displayMarkedVertex(java.awt.Graphics g, java.lang.String string, VizVertex u)
          end draw() method
 void displayMessageAtPoint(java.awt.Graphics g, java.lang.String string, VizVertex u)
           
 void displayVertex(java.awt.Graphics g, VizVertex v)
           
 void displayVertexStandalone(java.awt.Graphics g, VizVertex v)
           
 void displayVertexWithColor(java.awt.Graphics g, VizVertex v, java.awt.Color col)
           
 VizVertex dominantVertex(VizVertex v, VizVertex u)
           
 void draw()
           
 void edges()
           
 void endVertices()
           
 int getDistance(VizVertex u, VizVertex v)
           
 java.util.Iterator<CS16Edge> getEdgeIterator()
          Returns an iterator of the edges in the graph
 int getEdgeLength(CS16Edge edge)
          Returns the length ("distance", NOT necessarily weight) of a given edge
 int getEdgeWeight(CS16Edge edge)
          Returns the weight (NOT necessarily length) of a given edge
 CS16Vertex[] getEndVertices(CS16Edge e)
          Returns the endpoints of an edge
 java.util.Iterator<CS16Vertex> getVertexIterator()
          Returns an itererator of the vertices in the graph
 void incidentEdges()
           
 void incrementNextVertName()
          Increments the next vert name
 boolean isWithinRange(long x, long y, long lx, long ly, long rx, long ry)
           
 void kruskal()
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void opposite()
           
 void paint(java.awt.Graphics g)
          Updates the visualizer graphically Also, checks to see whether an edge is selected, and updates the radio buttons accordingly
 void prim()
           
 void redraw()
           
 void setMSTdisplay(int step)
          Changes the currently selected set of MST edges for animation.
 void setNextVertName(java.lang.String name)
          Sets the next vertex name
 CS16Edge trappedEdge(int x, int y)
           
 CS16Vertex trappedVertex(int x, int y)
           
 void update(java.awt.Graphics g)
           
 void updateEdgeToLength()
          Change the weight of the selected edge to its length
 void updateSelectedEdge(int weight)
          Change the weight of the currently selected edge.
 void vertices()
           
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GraphCanvas

public GraphCanvas(GraphViz main,
                   java.lang.String graphClassName,
                   java.lang.String kruskalClassName,
                   java.lang.String primClassName)
Method Detail

updateSelectedEdge

public void updateSelectedEdge(int weight)
Change the weight of the currently selected edge.

Parameters:
weight - - The new weight for the currently selected edge

updateEdgeToLength

public void updateEdgeToLength()
Change the weight of the selected edge to its length


getEdgeLength

public int getEdgeLength(CS16Edge edge)
Returns the length ("distance", NOT necessarily weight) of a given edge

Parameters:
edge - the edge for which you want to calculate length
Returns:
the integer-valued length of edge

getEdgeWeight

public int getEdgeWeight(CS16Edge edge)
Returns the weight (NOT necessarily length) of a given edge

Parameters:
edge - the edge for which you want to get the weight
Returns:
the integer-valued weight of an edge

areAdjacent

public void areAdjacent()

connectingEdge

public void connectingEdge()

edges

public void edges()

endVertices

public void endVertices()

incidentEdges

public void incidentEdges()

opposite

public void opposite()

vertices

public void vertices()

getVertexIterator

public java.util.Iterator<CS16Vertex> getVertexIterator()
Returns an itererator of the vertices in the graph


getEdgeIterator

public java.util.Iterator<CS16Edge> getEdgeIterator()
Returns an iterator of the edges in the graph


getEndVertices

public CS16Vertex[] getEndVertices(CS16Edge e)
Returns the endpoints of an edge


clear

public void clear()

kruskal

public void kruskal()

prim

public void prim()

cleanup

public void cleanup()

clearMinSpanForest

public void clearMinSpanForest()
Clears the minimum spanning tree.


addMST

public void addMST(CS16Decorator<CS16Edge,java.lang.Boolean> edges)
Adds another set of MST edges to the collection for animation. This method takes a CS16Decorator that maps edges to a boolean indicating if they're in the MST.


addMST

public void addMST(CS16Edge[] edges)
Adds another set of MST edges to the collection for animation. This method takes an array of all the edges in the MST.


addCloud

public void addCloud(CS16Decorator<CS16Vertex,java.lang.Integer> cloud,
                     CS16Decorator<CS16Vertex,CS16Vertex> parents)
Adds another cloud to the cloud animations.


setMSTdisplay

public void setMSTdisplay(int step)
Changes the currently selected set of MST edges for animation.


paint

public void paint(java.awt.Graphics g)
Updates the visualizer graphically Also, checks to see whether an edge is selected, and updates the radio buttons accordingly

Overrides:
paint in class java.awt.Canvas

update

public void update(java.awt.Graphics g)
Overrides:
update in class java.awt.Canvas

draw

public void draw()

displayMarkedVertex

public void displayMarkedVertex(java.awt.Graphics g,
                                java.lang.String string,
                                VizVertex u)
end draw() method


displayMessageAtPoint

public void displayMessageAtPoint(java.awt.Graphics g,
                                  java.lang.String string,
                                  VizVertex u)

getDistance

public int getDistance(VizVertex u,
                       VizVertex v)

displayEdge

public void displayEdge(java.awt.Graphics graphics,
                        VizVertex u,
                        VizVertex v,
                        CS16Edge e)

displayEdgeStandalone

public void displayEdgeStandalone(java.awt.Graphics g,
                                  VizVertex u,
                                  VizVertex v)

displayVertexWithColor

public void displayVertexWithColor(java.awt.Graphics g,
                                   VizVertex v,
                                   java.awt.Color col)

displayVertex

public void displayVertex(java.awt.Graphics g,
                          VizVertex v)

displayVertexStandalone

public void displayVertexStandalone(java.awt.Graphics g,
                                    VizVertex v)

displayLabel

public void displayLabel(java.awt.Graphics g,
                         int string,
                         VizVertex u,
                         VizVertex v)

displayFocusEdgeLabel

public void displayFocusEdgeLabel(java.awt.Graphics g,
                                  VizVertex u,
                                  VizVertex v)

addEdge

public void addEdge(CS16Vertex v1,
                    CS16Vertex v2,
                    int weight)

addVertex

public CS16Vertex addVertex(java.lang.String name,
                            int x,
                            int y)
method to add a vertex to the visualizer and to the graph structure called when vertices input by either mouse clicks or file loading


addPoint

public CS16Vertex addPoint(java.awt.event.MouseEvent e)
Adds a vertex to the visualizer, and to the graph structure


setNextVertName

public void setNextVertName(java.lang.String name)
Sets the next vertex name


incrementNextVertName

public void incrementNextVertName()
Increments the next vert name


redraw

public void redraw()

trappedVertex

public CS16Vertex trappedVertex(int x,
                                int y)

dominantVertex

public VizVertex dominantVertex(VizVertex v,
                                VizVertex u)

trappedEdge

public CS16Edge trappedEdge(int x,
                            int y)

clickedOnEdge

public boolean clickedOnEdge(int x,
                             int y,
                             VizVertex v1,
                             VizVertex v2)

isWithinRange

public boolean isWithinRange(long x,
                             long y,
                             long lx,
                             long ly,
                             long rx,
                             long ry)

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener