| | | | Browse by category |
Question
How can I make the contents of a subgraph scrollable?
Answer
You can create your own custom IlvSubGraphRenderer containing a nested interactor that manages a property in the nodes used to determine which nodes will be visible or hidden in response to scrolling actions. The nested interactor will be a custom IlvSubGraphRenderer.ExpandCollapseInteractor. You can override the different mouse event handler methods like mousePressed(MouseEvent evt) to handle the scrolling actions for the scrollbar. To install this interactor in your IlvSubGraphRenderer, you will need to override addViewListeners(IlvManagerView view) then add the interactor as a mouse listener by calling view.addMouseListener(MouseListener l). To remove the interactor, you will need to override removeViewListeners(IlvManagerView view) then remove the interactor as a mouse listener by calling view.removeMouseListener(MouseListener l). Note that if you want to implement dragging capabilities for the scrollbar, you will need to implement a MouseMotionListener for your interactor then install and remove it by calling view.addMouseMotionListener(MouseMotionListener l) and view.removeMouseMotionListener(MouseMotionListener l). Next you can override the interactor's mouseDragged(MouseEvent e) event handler method.
However in order to use the custom renderer, you need to register it. To register in CSS, you set the Renderers property in the SDM rule like:
To register in Java code, you make a direct call to IlvRendererUtil.addRendererAlias(String alias, String rendererClassName).
As for creating the scrollbar in the subgraph, you will need to create your own custom graphic. You can perform this step by creating your own IlvCompositeGraphic. This class will also perform hit testing for your custom renderer to determine which part of the scrollbar has been pressed like the up and down button. To assign this graphic to an expanding/collapsing node, you can set it to a node who has a particular attribute in CSS like:
In this example, a "scrolling" attribute was added to the node.
Here is a sample you can download that demonstrates the above technique. However, note that this sample does not include dragging capabilities for the scrollbar.