• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

2d arrays

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,
I have a file of seven columns, each column contains approximately 100 numbers in length,
I need to take these seven columns of data into an array and then access the array accordingly in terms of the columns which I will then use to plot many graphs. At any one time I will access only two columns.
I already have the graph plotting program and the graph will be displayed on an applet in a web page on the WWW.
The person who accesses the web page will want certain columns plotting against other columns so the web page needs to take in this data (i.e. which column to plot against which), select the appropriate columns in the array and then plot the graph. All this has to be done using a gui. Any suggestions on appropriate code.
Have you got any idea on how to do this.
I appreciate the help
Andrew Stevenson
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew,
You will first need a method to read the contents of the file and store it in an array. The array should be two dimensional. First dimension is 7 and the second dimension can be 100 if you are sure that is as many items each column can contain, OR you can create the second dimension for each column at runtime for the required length.
The next thing you will need is a convenient interface to the graph-plotting routine which will take a two single dimension array as the argument representing the two sets of data for the graph ( I am hoping you already have such an interface ).
Once you have these two components, your program flow should look like this.
1. Create a two-dimensional array( lets assume they are all int )
int graphData[][] = new int[7][100]
2. Read contents of the file into the array.
3. Display GUI, get the two columns from the user, say
nFirstColToDraw, nSecondColToDraw
4. Call the method plotGraph( graphData[nFirstColToDraw],
graphData[nSecondColToDraw] )

If the plotting logic is also a part of the same class as the one that holds the graphData, then you might just want to pass the two integer values nFirstColToDraw, nSecondColToDraw to the method and retrieve the graphData[nFirstColToDraw] and graphData[nSecondColToDraw] inside the method. This is just a matter of how you design your classes.

Hope this helps,
Ajith
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic