Title : RFC Custom Graphics in the VizMapper and Dynamic Mapping

Editor(s): Mike Smoot KeiichiroOno

Date: 2/12/2010

Status: init

Status

3/9/2010 - KeiichiroOno: start working on actual design and implementation

4/9/2010 - KeiichiroOno: start designing dynamic graphics function.

4/13/2010 - KeiichiroOno: Static image custom graphics feature implemented in branch code.

Proposal

We would like to provide some mechanism for allowing users to specify custom graphic images that can be applied to a network using the VizMapper. This includes new mapping from attributes to custom graphics.

Background

The goal of this RFC is to explore ideas for bringing custom graphics out of the programmer-only domain and allow normal users to specify custom graphics for nodes using normal Cytoscape tools like the VizMapper.

Use Cases

Implementation Plan

Basic Mechanism

CyCustomGraphics Interface

To implement this function, I defined a new interface called CyCustomGraphics

   1 public interface CyCustomGraphics <T> {
   2         /**
   3          * Display name is a simple description of this image object.
   4          * 
   5          * May not be unique.
   6          * 
   7          * @return display name as String.
   8          */
   9         public String getDisplayName();
  10         public void setDisplayName(final String displayName);
  11         
  12         public Collection<T> getCustomGraphics();
  13         
  14         public Image getImage();
  15         public Image resizeImage(int width, int height);
  16         
  17         /**
  18          * List of properties, i.e., details of this object.
  19          * 
  20          * @return
  21          */
  22         public Collection<CustomGraphicsProperty<?>> getProps();
  23 }
  24 

and then we can define a new Visual Property NODE_CUSTOM_GRAPHICS:

NODE_CUSTOM_GRAPHICS("Node Custom Graphics", "nodeCustomGraphics", 
                                         "node.customGraphics", "defaultNodeCustomGraphics", 
                                         CyCustomGraphics.class, new NodeCustomGraphicsProp(),
                                         new GraphicsParser(), true, true)

By implementing CyCustomGraphics interface, plugin writers can use this framework to create their own version of Custom Graphics. In short, this is just a new Visual Property. Users can use current VizMap UI to map attributes to graphics.

Custom Graphics Types

There are two types of custom graphics.

Static image is just an mapping from an image object to custom graphics. However, a dynamic image is controlled by an associated node attribute. This requiers an additional layer to create CyCustomGraphics object on-the-fly (will be discussed later).

Static Custom Graphics Mapping

We can create discrete mapping from attribute value to URL image, but this type of mapping can be handled by an extended PassThroughMapping. Currently, Pass Through Mapping only supports String object to label. However, it can be extended to accept other objects including custom graphics. If a list of URL strings is mapped to NODE_CUSTOM_GRAPHICS, the Pass Through Mapping generates Image objects from the URL and wrap it with CyCustomGraphics.

Static Image Custom Graphics Pool

All Custom Graphics generated from static (bitmap) images will be stored in a manager object called CustomGraphicsPool. This collection of images will be saved to session or .cytoscape/images directory.

Dynamic Custom Graphics and Custom Mapping

Static images can be handled in the existing UI/framework of VizMapper. However, for graphics generated dynamically from attributes (Dynamic Graphics), we need an additional layer. This problem can be handled by adding new kind of Visual Mapping. Currently, we have three types of mappings: continuous, discrete, and passthrough. All of these implements the following interface:

If we need to add a new type of mapping, new editor component is necessary.

   1 public interface CustomGraphicsProperty<T> {
   2         
   3         public String getDisplayName();
   4         public T getDefaultValue();
   5         
   6         public T getValue();
   7         public void setValue(T value);
   8 }
   9 

To generate variety of custom graphics, we need a mechanism to map multiple attribute values to a graphics. For example, if user wants to generate histograms for nodes, it requires List attributes one for x-axis, and the other one for y-axis.

List Attr 1 = {t1, t2, ...., tn}
List Attr 2 = {0.21, 0.53, ..., m}

To solve this problem, we can define a new mapping type called CustomMapping:

   1 public interface CustomMapping<V> {
   2         
   3         public Component getEditor();
   4 }
   5 

Custom Mapping Editor

Each custom mapping should have a GUI editor component.

customEditor1.png

Project Management

Project Dependencies

Issues

Comments

Funding for Cytoscape is provided by a federal grant from the U.S. National Institute of General Medical Sciences (NIGMS) of the Na tional Institutes of Health (NIH) under award number GM070743-01. Corporate funding is provided through a contract from Unilever PLC.

MoinMoin Appliance - Powered by TurnKey Linux