wikipathways/pathvisiojs — pull request #257 by bumbu (2014-05-19 15:45:38+00:00)
Title: Added selector and refactored/split renderers

_This is not the final version of how selector and renderers should look like, but it is a working version that is moving towards manipulating with drawn elements solely via selector._

Renderers are responsible solely for rendering, rerendering/altering and removing visible elements. They should implement at least init, addElement, updateElement, removeElement and getElementBBox methods.

Selectors are responsible solely for selecting, filtering pvjsonElements (data elements) and altering batches of elements (kind of jQuery). They do delegate rendering to renderers.

A usage scenario would be:
```js
var renderer = RendererSvg.init(pvjs)
, selector = Selector.init(pvjson.elements, renderer)

var cholesterolLabels = selector.filteredByLabel('Cholesterol')
cholesterolLabels.length // 2
cholesterolLabels.removeElements() // remove elements from selector and renderer
```

Later I'll expose selector via API and first thing that will use it will be highlighter plugin.

Right now I have few things I'm sure not about:
* How to update elements styles/positions. The now available get/setAttribute is ok in case of SVG but it does not really abstract renderer, so probably I'll replace them with `setStyle` and `getStyle` or `css`. Also here it is important to find out which styles are important to cover
* How to create new elements via selector
* Which events to handle via selector (click, double click, pan, drag...)

@ariutta what do you think about this change? Do you have any ideas about things I mentioned?