|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpathfinder.JPFMap
public class JPFMap
Data structure holding map information
Constructor Summary | |
---|---|
JPFMap()
Creates a new instance of JPFMap |
|
JPFMap(java.io.File selFile)
Creates a new instance of JPFMap |
Method Summary | |
---|---|
void |
blockRoad(int roadId)
Blocks road roadId |
JMapPanel |
drawMap(int width,
int height)
draws the map |
void |
drawPath(int city1,
int city2)
draws path (=line) between 2 m_cityList using global path color |
void |
drawPath(int city1,
int city2,
java.awt.Color col)
draws path (=line) between 2 m_cityList using given path color |
java.awt.Color |
getCityColor()
returns color of the city symbol |
int[] |
getCityCoords(int city)
returns city coordinates |
int |
getCityCount()
|
double |
getCityDistance(int city1,
int city2)
returns double distance of given two m_cityList |
java.util.ArrayList<java.lang.String[]> |
getCityList()
returns list of m_cityList in the map |
int[] |
getCityNeighbours(int city)
returns array of city neighbours |
int |
getNearestCity(float x,
float y)
Returns id of the city that is nearest to given position |
int[] |
getNearestRoad(float x,
float y,
float minDist)
Returns id of the cities that are connected by road nearest to given position |
java.awt.Color |
getPathColor()
gets path highlight color |
java.util.ArrayList<java.lang.String[]> |
getRoadList()
returns list of m_roadList in the map |
int |
getRoadSpeed(int city1,
int city2)
returns road type (=max. allowed speed) between two m_cityList |
void |
highlightCities(int[] cities)
highlights given array of m_cityList |
void |
highlightCities(int[] cities,
java.awt.Color col)
highlights given array of cities |
void |
loadMapFromFile(java.io.File selFile)
Loads map from given csv file |
protected void |
processCoords(java.lang.String[] csvFields)
a function utilised for drawing purposes |
protected int[] |
remapCoords(double[] coords,
double windowW,
double windowH)
a function utilised for drawing purposes |
protected int[] |
remapCoords(int[] coords,
double windowW,
double windowH)
a function utilised for drawing purposes |
protected int[] |
remapCoordsBack(double[] windowCoords,
double windowW,
double windowH)
a function utilised for drawing purposes |
int[] |
remapCoordsBack(int[] windowCoords,
double windowW,
double windowH)
a function utilised for drawing purposes to map from panel to JPFMap |
protected double[] |
remapCoordsToDouble(double[] coords,
double windowW,
double windowH)
a function utilised for drawing purposes |
void |
setCityColor(java.awt.Color col)
sets color of the city symbol |
void |
setCityHeight(int h)
Sets height of the city symbol |
void |
setCityWidth(int w)
Sets width of the city symbol |
void |
setPathColor(java.awt.Color P)
Sets the path color used for drawing paths in the map |
void |
setRoadColors(java.awt.Color Hi,
java.awt.Color Mid,
java.awt.Color Lo)
Sets colors of the m_roadList |
void |
unblockRoads()
Removes road blocks |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JPFMap()
public JPFMap(java.io.File selFile)
selFile
- csv file with map dataMethod Detail |
---|
public int getCityCount()
public void loadMapFromFile(java.io.File selFile)
selFile
- - csv file containing the mappublic JMapPanel drawMap(int width, int height)
width
- - width of the outputheight
- - height of the outputpublic void setCityWidth(int w)
w
- - width of the symbolpublic void setCityHeight(int h)
h
- - height of the symbolpublic void setRoadColors(java.awt.Color Hi, java.awt.Color Mid, java.awt.Color Lo)
Hi
- Mid
- Lo
- - three colors of three road typespublic void setPathColor(java.awt.Color P)
public java.awt.Color getPathColor()
public void setCityColor(java.awt.Color col)
col
- colorpublic java.awt.Color getCityColor()
public java.util.ArrayList<java.lang.String[]> getCityList()
public java.util.ArrayList<java.lang.String[]> getRoadList()
public void drawPath(int city1, int city2)
city1
- id of 1st citycity2
- id of 2nd citypublic void drawPath(int city1, int city2, java.awt.Color col)
city1
- id of 1st citycity2
- id of 2nd citycol
- - highlight colorpublic void highlightCities(int[] cities)
cities
- - array of cities (defined as integers)public void highlightCities(int[] cities, java.awt.Color col)
cities
- - array of cities (defined as integers)col
- - highlighting colorpublic int[] getCityCoords(int city)
city
- - id of the city
public int[] getCityNeighbours(int city)
city
- - id of the city
public double getCityDistance(int city1, int city2)
city1
- id of 1st citycity2
- id of 2nd city
public int getNearestCity(float x, float y)
x
- x coordinatey
- y coordinate
public int[] getNearestRoad(float x, float y, float minDist)
x
- x coordinatey
- y coordinate
public void blockRoad(int roadId)
roadId
- public void unblockRoads()
public int getRoadSpeed(int city1, int city2)
city1
- id of 1st citycity2
- id of 2nd city
protected void processCoords(java.lang.String[] csvFields)
protected double[] remapCoordsToDouble(double[] coords, double windowW, double windowH)
protected int[] remapCoords(double[] coords, double windowW, double windowH)
protected int[] remapCoords(int[] coords, double windowW, double windowH)
protected int[] remapCoordsBack(double[] windowCoords, double windowW, double windowH)
public int[] remapCoordsBack(int[] windowCoords, double windowW, double windowH)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |