How to update scroll bars and the scrollable area of a Graph2DView
TroubleshootingSummary
Description
One of the first things users learn when working with Graph2DView is the need to notify the view of changes in the underlying graph structure.
Usually this is done by invoking updateView(), but sometimes updateView() is not enough. For instance, when your graph aquires a new node, which lies outside of the view's world rectangle (i.e. the view's scrollable area). To be able to scroll to the newly added node, you need update Graph2DView's world rectangle to include said node. This can be done by simply calling updateWorldRect() prior to the usual call of updateView(). This will effectively union the view's old world rectangle with the underlying graph's bounding box. Another possibility is to set the view's world rectangle explicitly with public void setWorldRect(int x, int y, int w, int h) (again followed by a call to updateView()).