calculation
Class Graph

java.lang.Object
  extended by calculation.Graph

public class Graph
extends java.lang.Object

This class presents the net of vertices.

Version:
1
Author:
Potkuri-group

Field Summary
private  Vertex airportVertex
          Vertex acting as airport.
private  java.util.ArrayList[] arcpoints
          Mergepoint candidates, that is arc points.
private  double cornerlat
          Variables for the corner of the map.
private  double cornerlon
          Variables for the corner of the map.
private  DataCollection dataCollection
          reference to dataCollection interface.
private  double end
          Arc point sector end angle.
private  Vertex[][] graph
          graph matrix has a point (0,0) at left bottom corner.
private  WeatherMap map
          Address of the WeatherMap class.
(package private) static int MAP_HEIGHT
          graph height.
(package private) static int MAP_WIDTH
          graph width.
private  int[][] mapMatrix
          Address of the weather matrix.
private  Vertex nullVertex
          Vertex to be null.
private  Parameters param
          reference to Parameters class.
private  int safety
          Safety zone distance for storms (how many graph nodes).
(package private) static int SCALE
          matrix scale to graph.
private  double start
          Arc point sector start angle.
private  double startPointCount
          Number of start points for planes.
(package private) static int STORM
          The storm limit of the weather matrix.
 
Constructor Summary
Graph(DataCollection data, int width, int height)
          This is the constructor for the graph.
Graph(Vertex[][] gRaph)
          a Constructor for testing purposes only.
 
Method Summary
 void calculateArcPoints(double start, double end, double startPointCount)
          Set merge points.
 boolean checkSquare(int size, int x, int y, int[][] matrix)
          Checks a certain size square in a two dimensional matrix, if it has a value larger than something (STORM).
 Vertex[][] createGraph(int width, int height)
          A graph creation method.
 Vertex getAirport()
          Return Airport vertex.
 java.util.ArrayList<Vertex>[] getArcPoints()
          Return ArcPoints.
 Vertex[][] getGraph()
          Returns the current graph.
 java.util.ArrayList<Vertex> getOuterArc()
          Returns ArcPoints of outermost arc.
 boolean graphUpdate(int scale, int[][] matrix, Vertex[][] graph, int safety)
          This method updates the graph, by the weatherdata included in the matrix.
 void printgraph()
          Ascii presentation of the graph!
 boolean resetGraph(Vertex[][] net)
          Resets the graph.
 void setArcPoints(java.util.ArrayList[] arcPoints)
          a Method to set self defined arc points for testing.
 void setSafezone(boolean state, Vertex node, int width)
          This method sets nodes around a storm not available, thus setting an unavailable perimeter around the bad weather.
 void testCalculateArcPoints(double start, double end, double num)
          Public method to test private method calculateArcPoints().
 boolean update()
          The update method for Graph class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

airportVertex

private Vertex airportVertex
Vertex acting as airport.


arcpoints

private java.util.ArrayList[] arcpoints
Mergepoint candidates, that is arc points.


cornerlat

private double cornerlat
Variables for the corner of the map.


cornerlon

private double cornerlon
Variables for the corner of the map.


dataCollection

private DataCollection dataCollection
reference to dataCollection interface.


end

private double end
Arc point sector end angle.


graph

private Vertex[][] graph
graph matrix has a point (0,0) at left bottom corner.


map

private WeatherMap map
Address of the WeatherMap class.


MAP_HEIGHT

static final int MAP_HEIGHT
graph height.

See Also:
Constant Field Values

MAP_WIDTH

static final int MAP_WIDTH
graph width.

See Also:
Constant Field Values

mapMatrix

private int[][] mapMatrix
Address of the weather matrix.


nullVertex

private Vertex nullVertex
Vertex to be null.


param

private Parameters param
reference to Parameters class.


safety

private int safety
Safety zone distance for storms (how many graph nodes).


SCALE

static final int SCALE
matrix scale to graph.

See Also:
Constant Field Values

start

private double start
Arc point sector start angle.


startPointCount

private double startPointCount
Number of start points for planes.


STORM

static final int STORM
The storm limit of the weather matrix.

See Also:
Constant Field Values
Constructor Detail

Graph

public Graph(DataCollection data,
             int width,
             int height)
This is the constructor for the graph. It creates the nodes, and sets the initial values.

Parameters:
data - the DataCollection address as as parameter.
width - is the weather matrix width.
height - is the weather matrix height.

Graph

public Graph(Vertex[][] gRaph)
a Constructor for testing purposes only.

Parameters:
gRaph - Self made graph to class.
Method Detail

calculateArcPoints

public void calculateArcPoints(double start,
                               double end,
                               double startPointCount)
Set merge points.

Parameters:
start - start angle of arrival tree sector.
end - angle of arrival tree sector.
startPointCount - number of startpoints in the secotr.

checkSquare

public boolean checkSquare(int size,
                           int x,
                           int y,
                           int[][] matrix)
Checks a certain size square in a two dimensional matrix, if it has a value larger than something (STORM).

Parameters:
size - the size of the square to check
x - coordinate in the matrix
y - coordinate in the matrix
matrix - a two dimensional matrix
Returns:
boolean value true if a storm is found, false if not.

createGraph

public Vertex[][] createGraph(int width,
                              int height)
A graph creation method. Creates vertices and sets them up.

Parameters:
width - width of graph.
height - heigth of graph.
Returns:
returns the address of created graph. Null if failure.

getAirport

public Vertex getAirport()
Return Airport vertex.

Returns:
address of the Vertex that is an airport

getArcPoints

public java.util.ArrayList<Vertex>[] getArcPoints()
Return ArcPoints.

Returns:
arcPoints

getGraph

public Vertex[][] getGraph()
Returns the current graph.

Returns:
two dimensional array of Vertexes

getOuterArc

public java.util.ArrayList<Vertex> getOuterArc()
Returns ArcPoints of outermost arc.

Returns:
ArrayList of Vertex instances in the outermost arc

graphUpdate

public boolean graphUpdate(int scale,
                           int[][] matrix,
                           Vertex[][] graph,
                           int safety)
This method updates the graph, by the weatherdata included in the matrix.

Parameters:
scale - The scale by which the map will be scaled to graph size.
matrix - a two dimensional matrix, holding the weather data.
graph - is the graph to update.
safety - safety border size to storms.
Returns:
returns true if graph was updated, else false.

printgraph

public void printgraph()
Ascii presentation of the graph!


resetGraph

public boolean resetGraph(Vertex[][] net)
Resets the graph.

Parameters:
net - The graph to reset.
Returns:
true if resetting went ok, else false.

setArcPoints

public void setArcPoints(java.util.ArrayList[] arcPoints)
a Method to set self defined arc points for testing.

Parameters:
arcPoints - An ArrayList[] of arc points to set.

setSafezone

public void setSafezone(boolean state,
                        Vertex node,
                        int width)
This method sets nodes around a storm not available, thus setting an unavailable perimeter around the bad weather.

Parameters:
state - boolean value to set to node.
node - node to start from
width - size of the unavailable zone

testCalculateArcPoints

public void testCalculateArcPoints(double start,
                                   double end,
                                   double num)
Public method to test private method calculateArcPoints().

Parameters:
start - start angle of arrival tree sector.
end - angle of arrival tree sector.
num - number of startpoints in the secotr.

update

public boolean update()
The update method for Graph class. Looks for new weatherdata, and updates the graph.

Returns:
true if update was successful