After a thorough survey of this and many other Internet communities I failed to solve my problem. It is about ControlP5 button and my aim of importing 2D array from previously formated text file with two columns and 19 rows and space separated values. Now my code works but the 2D arrray I designated to hold the values from the txt does not get all of the values but just the last pair in its first row. I know that for loops over all values but stores them only in the first row. I dont know how to push it in another row for reading. This is my code:
- if(theEvent.isController())
{
if(theEvent.controller().name() == "mean shape males")
{
String loadPath1 = selectInput();
reader = createReader(loadPath1); //new BufferedReader
int x=0; //rows
int y=0; //columns
String smaLine;
try
{
while ((smaLine = reader.readLine()) != null)
{
String[] values = smaLine.split(", ");
for(int i = 0; i < values.length; i++)
{
float[] testC = float(split(values[i], " "));
for (int j = 0; j < testC.length; j++)
{
mat1[j][i] = testC[j]; //THIS IS THE PROBLEMATIC MATRIX that I declared before setup() with good dimensionality
}
}
x = x+1;
}
}
catch (IOException e)
{
e.printStackTrace();
}
mat1max = maxRet(mat1);
mat1min = minRet(mat1);
inputMat = new Grid(2,19,10,130,22,mat1,mat1min,mat1max);
-
}
Thanks for all the help
1