Class GivenGraph

Implemented Interfaces:
MouseListener, MouseMotionListener

public class GivenGraph
extends JPanel
implements MouseListener, MouseMotionListener

Field Summary

private char[]
alpabet
private JDialog
dialog
private Graph
graph
private boolean
lock
private int
mouseX
private int
mouseY
(package private) static BasicStroke
normalStroke
private ShortestPath
parent
private Node
startSelection
private UserData
userData
private UserGraph
userGraph
(package private) static BasicStroke
wideStroke

Constructor Summary

GivenGraph(ShortestPath parent, Graph graph)

Method Summary

private void
addVertex(Node startVertex, Node node)
Method addVertex.
private void
adjustArea(int height, int width)
Method getNodes.
private int
calculateNumNodes(int level, int successRatio)
private void
checkWeightsRoom()
private void
checkingEdges(matrix[][] )
private void
clearEgdes(int maxColumns, int maxRows, matrix[][] )
private Node
clickedOnNode(int x, int y)
Method clickedOnNode.
private void
createEdges(int numEdges, int numNodes)
void
createGraph()
private void
createNewNode(int i, int j)
Method createNewNode.
private String
createNodeName()
Method createNodeName.
private void
createNodes(int numOfNodes, int maxColumns, int maxRows, matrix[][] )
void
createTutorial()
private void
drawEdge(Graphics g, Vertex v, FontMetrics fm)
private void
drawNode(Graphics g, Node n, FontMetrics fm)
private void
drawTempLine(Node node, Graphics g)
private boolean
enoughRoom(int x, int y)
Method enoughRoom.
private void
findNewPlace(Node node, int maxColumns, int maxRows, matrix[][] )
private char[]
getAlpabet()
Returns the alpabet.
void
init(UserGraph ug, UserData ud)
private void
initWeights(Vertex v)
boolean
isLock()
private boolean
isWeightCloseBy(int x, int y)
void
mouseClicked(MouseEvent e)
Mouse Listener functions
void
mouseDragged(MouseEvent e)
void
mouseEntered(MouseEvent e)
void
mouseExited(MouseEvent e)
void
mouseMoved(MouseEvent e)
void
mousePressed(MouseEvent e)
void
mouseReleased(MouseEvent e)
void
paint(Graphics g)
private void
repairGraph(ArrayList unreachableNodes)
private Vertex
searchRedundantEgde(ArrayList al)
ArrayList
searchUnreachableNodes()
private void
setAlpabet(char[] alpabet)
Sets the alpabet.
private void
setGraph(Graph graph)
Method setGraph.
void
setLock(boolean lock)
private void
setNewPosWeight(Vertex v, int diff, boolean inMiddle)
private void
setWeights()

Field Details

alpabet

private char[] alpabet

dialog

private JDialog dialog

graph

private Graph graph

lock

private boolean lock

mouseX

private int mouseX

mouseY

private int mouseY

normalStroke

(package private) static final BasicStroke normalStroke

parent

private ShortestPath parent

startSelection

private Node startSelection

userData

private UserData userData

userGraph

private UserGraph userGraph

wideStroke

(package private) static final BasicStroke wideStroke

Constructor Details

GivenGraph

public GivenGraph(ShortestPath parent,
                  Graph graph)

Method Details

addVertex

private void addVertex(Node startVertex,
                       Node node)
Method addVertex.
Parameters:
startVertex -
node -

adjustArea

private void adjustArea(int height,
                        int width)
Method getNodes.

calculateNumNodes

private int calculateNumNodes(int level,
                              int successRatio)
Parameters:
level -
successRatio -
Returns:

checkWeightsRoom

private void checkWeightsRoom()

checkingEdges

private void checkingEdges(matrix[][] )

clearEgdes

private void clearEgdes(int maxColumns,
                        int maxRows,
                        matrix[][] )

clickedOnNode

private Node clickedOnNode(int x,
                           int y)
Method clickedOnNode.
Parameters:
x -
y -

createEdges

private void createEdges(int numEdges,
                         int numNodes)

createGraph

public void createGraph()

createNewNode

private void createNewNode(int i,
                           int j)
Method createNewNode.
Parameters:
i -
j -

createNodeName

private String createNodeName()
Method createNodeName.

createNodes

private void createNodes(int numOfNodes,
                         int maxColumns,
                         int maxRows,
                         matrix[][] )

createTutorial

public void createTutorial()

drawEdge

private void drawEdge(Graphics g,
                      Vertex v,
                      FontMetrics fm)

drawNode

private void drawNode(Graphics g,
                      Node n,
                      FontMetrics fm)

drawTempLine

private void drawTempLine(Node node,
                          Graphics g)
Parameters:
node -

enoughRoom

private boolean enoughRoom(int x,
                           int y)
Method enoughRoom.
Returns:
boolean

findNewPlace

private void findNewPlace(Node node,
                          int maxColumns,
                          int maxRows,
                          matrix[][] )

getAlpabet

private char[] getAlpabet()
Returns the alpabet.
Returns:
char[]

init

public void init(UserGraph ug,
                 UserData ud)

initWeights

private void initWeights(Vertex v)
Parameters:

isLock

public boolean isLock()
Returns:

isWeightCloseBy

private boolean isWeightCloseBy(int x,
                                int y)

mouseClicked

public void mouseClicked(MouseEvent e)
Mouse Listener functions

mouseDragged

public void mouseDragged(MouseEvent e)

mouseEntered

public void mouseEntered(MouseEvent e)

mouseExited

public void mouseExited(MouseEvent e)

mouseMoved

public void mouseMoved(MouseEvent e)

mousePressed

public void mousePressed(MouseEvent e)

mouseReleased

public void mouseReleased(MouseEvent e)

paint

public void paint(Graphics g)

repairGraph

private void repairGraph(ArrayList unreachableNodes)

searchRedundantEgde

private Vertex searchRedundantEgde(ArrayList al)

searchUnreachableNodes

public ArrayList searchUnreachableNodes()

setAlpabet

private void setAlpabet(char[] alpabet)
Sets the alpabet.
Parameters:
alpabet - The alpabet to set

setGraph

private void setGraph(Graph graph)
Method setGraph.
Parameters:
graph -

setLock

public void setLock(boolean lock)

setNewPosWeight

private void setNewPosWeight(Vertex v,
                             int diff,
                             boolean inMiddle)

setWeights

private void setWeights()