Title : RFC Custom Graphics in the VizMapper

Editor(s): Mike Smoot KeiichiroOno

Date: 2/12/2010

Status: init

Status

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

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.

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

customNode1.png

http://www.mathworks.com/products/demos/shipping/bioinfo/biographdemo_10_thumbnail.png

http://www.yworks.com/img/gallery/autogen/yedscreen22_800x500.png

http://s3.amazonaws.com/data.tumblr.com/tumblr_kz1x6srsNR1qzbqezo1_1280.png?AWSAccessKeyId=0RYTHV9YYQ4W5Q3HQMG2&Expires=1268286166&Signature=Ul6yuhzrhK5XHaOaJtsui6UwwYE=

Implementation Plan

Specific Ideas

Mapping Problem

Simple use case is mapping to a static image.

 Attr value 1 = Image URL 1
 Attr value 2 = Image URL 2
 Attr value 3 = Image URL 1
 Attr value 4 = Image URL 3
 .
 .
 .

However, this is not efficient for the following case. Suppose a user has expression values as a list attribute. If there are N nodes in the network and he/she wants to map this attribute value to pi charts, the user needs to create N images and have to create a map like this:

 List 1 = Chart image URL 1
 List 2 = Chart image URL 2
 List 3 = Chart image URL 3
 
 .
 .
 .
 List N = Chart image URL N

In addition, in this case, images are bitmap and could not maintain the chart image quality when user export it as a vector image. To solve this issue, we can use CustomGraphicsBuilder interface.

   1 public interface CustomGraphicsBuilder<T> {
   2         public Collection<CustomGraphic> createCustomGraphics(final T constraint);
   3 }
   4 

And implementations look like the following:

   1 public class URLImageBuilder implements CustomGraphicsBuilder<URL> {
   2 
   3         @Override
   4         public Collection<CustomGraphic> createCustomGraphics(final URL constraint) {
   5                 
   6                 final Rectangle2D bound = new java.awt.geom.Rectangle2D.Double(-11.0, -15.0, 22.0, 30.0);
   7                 Paint paint = null;
   8                 try {
   9                         paint = new TexturePaint(ImageIO.read(constraint), bound);
  10                 } catch (IOException e) {
  11                         e.printStackTrace();
  12                 }
  13                 final List<CustomGraphic> graphics = new ArrayList<CustomGraphic>();
  14                 graphics.add(new CustomGraphic(bound, paint, NodeDetails.ANCHOR_WEST));
  15                 
  16                 return graphics;
  17         }
  18 }
  19 

   1 public class HistogramGraphicsBuilder implements CustomGraphicsBuilder<List<Double>> {
   2 
   3         @Override
   4         public Collection<CustomGraphic> createCustomGraphics(final List<Double> constraint) {
   5                 final List<CustomGraphic> graphics = new ArrayList<CustomGraphic>();
   6                 
   7                 // Draw histogram using double value here.
   8                 
   9                 return graphics;
  10         }
  11 }
  12 

This enables user maximum flexibility. They can mix multiple builders in a mapping when necessary.

By default, core provides URL image mapping and some very simple CustomGraphicsBuilder implementations. Plugin author can create their own builder if they need custom nodes.

In this design, mapping is attribute value to builder + constraint.

 Attr value 1 = (URLImageGraphicsBuilder, http://cytoscape.org/images/image1.png)

CustomGraphicBuilder

   1 
   2 

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