Okay, first off. Please post the whole code, preferably in a runnable example.
There are many things you can do to improve performance.
Prefer Contiguous Arrays
Defining a 2D array as int[][] is not optimal as it is "arrays inside of arrays" (i.e. the outer array is an array of pointers to the inner rows/columns) meaning that you will get an extra indirection and possibly a cache miss on each element access. You should create one contiguous 1D array and index into it based on x,y. Like this:
int[][] slow = new int[width][height];
int[] fast = new int[width*height];
slow[x][y] == fast[x + y * width];
This also goes for your visited list.
For the love of ${DEITY}, don't encode coordinates into strings
Instead of String pos = x+"."+y; simply use `Point pos = new Point(x,y)"Point pos = new Point(x,y). Much faster, especially since you don't have to parse out the x and y values when you use it.
Use the correct data structure and algorithm for unvisited nodes
You are storing your unvisited nodes in a list and doing a linear search through it for the next unvisited node. This is what is ruining your algorithm performance of Dijkstra, going from O(E + VlogV) to O(E + V^2) and why it takes 30 seconds for your machine.
First off you only need to store the currently accessible, unvisited nodes. This alone would significantly speed up your search for the unvisited node with smallest cost. You can do this by adding the neighbours of the current node to the unvisited nodes set only if they don't already exist in the set. (You can keep an additional matrix with nodes that have been added or you can query the set if it contains the node provided you have O(logn) lookup).
Next as you will be taking the smallest element as the next node, it makes sense to use an ordered data structure such as a heap or also known as a PriorityQueue in Java. Note that if you do use the priority queue you need to remove and re-add elements as you change their cost so that they get re-sorted in the queue.
Use an Object Oriented Solution
You have many matrixes (arrays) of the same size that represent different properties of each node. It makes sense to just consolidate these arrays into one array of nodes where each node has properties.
Like this:
class DijkstraNode{
double value;
double bestCostThisFar = Double.PositiveInfinity();
boolean visited = false;
boolean addedToUnvisited = false;
int x;
int y;
}
DijkstraNode graph[] = new DijkstraNode[mEdge*mEdge];
PriorityQueue<DijkstraNode> unvisited = new PriorityQueue<>(mEdge*mEdge, comparator);
Where you implement a suitable Comparator.
This means that your data will have a much better cache coherency as the data you will be using will fit on the same cache line.