Monday, October 4, 2010

Working process of actions and renderers


Recently a prefuse user want to do some custom work. One of the tasks is to decide which items need to be shown. So I checked the TreeView demo writen by Heer.

There is a action, called fisheyefilter, which determines how many layers a tree structure will show from the node whose DOI is 0. Then I checked its source codes and finally figure out what the functions of the columns (_visible, _visible:start, _visible:end) in a VisualItem are. Here are some findings.

FishEyeTreeFilter class is one of the actions, determining the value of “_visible; _visible: start; _visible: end”

Renderers will check the _visible value (true or false) of a VisualItem to decide if they need to paint this VisualItem.

If need to paint it, the VisualItem will need to find actions that quantify its position, shape, colors, and orientation.


Renderers normally has to implement the render() method. And render() method will usually call GraphicsLib.paint() method to finally paint the item.


Summary

  1. If you want to customize your visualization, work closely with actions and renders.
  2. Override render() method carefully, and alway try to use GraphicsLib.paint() method if this can work for you.
  3. If the GraphicsLib.paint() method cannot work, create your own paint() method and use it in the render() method.