| | | | Browse by category |
Question
How can I display a JComponent as a node in a nested graph?
Answer
For displaying SWING components in a manager or grapher, JViews provides the class IlvJComponentGraphic.
IlvJComponentGraphic does not display the component in a nested graph. For some applications, the way IlvJComponentGraphic zooms is not ideal.
Two classes have been written in the following example to provide a graphic class that displays an image of a JComponent or JTable.
IlvJComponentImageNode is a graphic class that displays a JComponent as a bitmap. This will work for any JComponent, but for those such as JTable that have a separate data model, a separate model and view design is better.
Therefore, IlvJTableImageNode, an extension of IlvJComponentImageNode, is also provided.
IlvJTableImageNode and IlvJComponentImageNode work in nested graphs. Their content zooms with the view. IlvJTable contains a JTable and provides the methods setTableModel() and getTableModel().
These methods provide an interface for using the class through SDM. Set a property on the SDM nodes whose value is an instance of TableModel. If the name of the property were 'tablemodel', then the following CSS rule would produce an image of a JTable for each node:
node {
class :
ilog.views.contrib.sdmtablenode.IlvJTableImageNode;
tableModel : @tablemodel;
}
The following example provides these two new classes, as well as a sample program that uses them.
Download the attached sdmtablenode.zip file, extract it, and open readme.html to read instructions for using the sample.
Note: In order to run this sample with JViews 8.7 and later, you must call the ilog.views.util.IlvProductUtil.DeploymentLicenseRequired method with the appropriate argument. See the General information > Deployment licenses > Declaring the use of JViews services section in the documentation for more information.