I have this code stanza to parse the data from an xml file.
...
ins = new FileInputStream(new File(fileName));
parser.parse(ins, handler);
CategoryDataset bwDataset = handler.getDataset();
...
Two questions:
1) I don't want to parse the file again, can I some how loop through the CategoryDataset and get the data? (code example pls.)
2) Or better yet, can I output the CategoryDataset in a table format (legend...)?
Thanks
Getting the data from the dataset
Well, I don't have time for an extended code example, but I think I can get you along the right tracks pretty easily.
CategoryDataset is a tabular dataset. It basically has the data in column-row setup, and you can query those (getColumnCount I recall and similar for rows).
Of course (as it is in very many cases in jfc..) it depends a little on the actual flavor of categorydataset, you might have different data fields to go with, like in gantt charting..
But all and all: getColumnCount, getRowCount, getValue (int,int). Or getColumnKeys, getRowKeys, getValue(comparable, comparable), if that's what you are into.
It is not hard from that to wrap it into some CategoryDatasetTableModel (of your own design), put that into a JTable and presto! you've got what you are looking for. It's pretty easy to make automatically updating too.
CategoryDataset is a tabular dataset. It basically has the data in column-row setup, and you can query those (getColumnCount I recall and similar for rows).
Of course (as it is in very many cases in jfc..) it depends a little on the actual flavor of categorydataset, you might have different data fields to go with, like in gantt charting..
But all and all: getColumnCount, getRowCount, getValue (int,int). Or getColumnKeys, getRowKeys, getValue(comparable, comparable), if that's what you are into.
It is not hard from that to wrap it into some CategoryDatasetTableModel (of your own design), put that into a JTable and presto! you've got what you are looking for. It's pretty easy to make automatically updating too.