Forums Register Login

2d arrays

+Pie Number of slices to send: Send

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
+Pie Number of slices to send: Send
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
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1222 times.
Similar Threads
Generate combination charts using Java
2d arrays
Restrict the User to Move a Column in a JTable Component
2d arrays
2d arrays
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 08:30:13.