I’m working on a tool for visualizing objects in Java. This tool provides some standard renderings, and I’d like to include some for matrices and tables.
What are the most used classes for such data? Are there any omnipresent frameworks?
Please list all used classes you know, not just the most common.
Not entirely clear on what you mean by “visualizing objects”, but I usually use
JTableto display tablesEDIT: I understand better now what you want. My answer was, accidentally, semi-relavent.
The most common method is to use a 2D array (e.g. int[][]). Another common method is to use a normal Array (int[]) with a field that defines the length of a row, giving a square matrix. Unfortunately there is no standard that I know of for this, but an example can be found here : Matrix.java
In the same way as an Array can be used, a Collection can be used. Just replace
int[]withjava.util.List<E>orint[][]withList<List<E>>to create 1D or 2D dynamic lists that can be used in the same way. I’ve never seen this done, but in theory it could be used.In terms of other classes that are used for tables, if Java has been connected to a database via JDBC (e.g. many forms of SQL) a
java.sql.ResultSetmay be returned by queries to represent tables in the database.Finally, for GUI components a table may be represented by some subclass of
javax.swing.table.TableModel. These are all I can think of at the moment.EDIT: another two possibilities, A single String with delimiters (e.g. commas and newlines as in CSV) can be used to represent a table.
A class that is not implemented in java but could be used would also be some form of linked grid (like a linked list but in 2 dimensions, as opposed to a linked list of linked lists)