Presentation Layer
Updated on July 15, 2009 by KeiOno
Still under construction!
Introduction
Presentation layer is the set of actual classes which draws network graphics. From 3.0, Cytoscpae can have multiple presentation per view. This means multiple rendering engines can co-exist in an instance of Cytoscape.
Design
Definitions
Data Model
All kinds of data objects, including CyNetwork, CyDataTables, VisualStyles, etc.
View Model
- A map from Visual Property type to a value (color, size, ...)
- One View Model is always associated with a data model.
- A data model can have multiple View Models.
Presentation
Presentation is a visualization of View Model. A View Model can have multiple presentations. In reality, presentation represents a drawing on AWT Canvas or other Swing Components.
API
There are 3 interfaces in Presentation API bundle:
PresentationFactory - Provide a function to add Presentation as Swing Component to a given object.
VisualItemRenderer - Provide a VisualLexicon for
RenderingEngine - Render the scene
1 public interface PresentationFactory {
2 /*
3 * A presentation can contain multiple view models.
4 * This enable developers to render multiple View Models in the same display.
5 * For example, if View<CyNetwork> and View<Decoration> are passed to this,
6 * both of them will be rendered in a window, using same rendering engine.
7 */
8 public RenderingEngine addPresentation(Container container, View<?> viewModel);
9 public RenderingEngine addPresentation(Container container, List<View<?>> viewModels);
10 }
11
1 public interface VisualItemRenderer {
2 /**
3 * Provide a set of Visual Properties this renderer can visualize.
4 *
5 * @return Set of VP as a VisualLexicon
6 */
7 public VisualLexicon getVisualLexicon();
8 }
9
1 public interface RenderingEngine {
2
3 /**
4 * Returns backend View Models for this presentation.
5 *
6 * @return view models.
7 */
8 public List<View<?>> getViewModels();
9
10
11 /**
12 * Rendering engine dependent properties, like LOD
13 */
14 public void setProperties(Properties props);
15 public Properties getProperties();
16
17 /**
18 * For export image function.
19 *
20 * @return DOCUMENT ME!
21 */
22 public Printable getPrintable();
23
24 /**
25 * Render image from the current view model state.
26 *
27 * @return Image object created from current window.
28 */
29 public Image getImage(int width, int height);
30
31 /**
32 * For a given Visual Property, render an Icon based on the default value of
33 * the Visual Property.
34 *
35 * @param vp
36 * Visual Property.
37 *
38 * @return DOCUMENT ME!
39 *
40 * @exception IllegalArgumentException
41 * if vp is not in the lexicon.
42 */
43 public Icon getDefaultIcon(VisualProperty<?> vp);
44 }
45
Discussion
Our overall design (model-view-presentation) does not completely equivalent to typical scene graph used in many 3D visualizers. This design is inspired by Prefuse Visualization Toolkit. The rendering engine object can take any type of Views, but usually it takes Networks or data tables. For each View, render the object using proper VisualItemRenderer. VisualItemRenderer provides a Visual Lexicon, which is a set of Visual Properties that can be recognized by this rendering engine's drawing classes.
Relationship between Presentation Layer and Other Modules