Interface NetworkImageFactory


public interface NetworkImageFactory

This service is used to create images for a given CyNetworkView.

This service can be used to create thumbnail images of a network without needing to create a RenderingEngine or Swing components. The images are generated by Cytoscape's default 2D renderer with the default set of VisualProperties and a high level of detail.

Note: Nested networks are not supported in the generated images.

Since:
3.9

Module: presentation-api

To use this in your app, include the following dependency in your POM:

<dependency>
    <groupId>org.cytoscape</groupId>
    <artifactId>presentation-api</artifactId>
</dependency>

Cytoscape Backwards Compatibility (API Interface): We expect that this interface will be used but not implemented by developers using this interface. As such, we reserve the right to add methods to the interface as part of minor version upgrades. We will not remove methods for any changes other than major version upgrades.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static String
    If true the network will be automatically centered and scaled to fit inside the image bounds.
    static String
    The height of the image, default: 100
    static String
    The width of the returned image, default: 100
  • Method Summary

    Modifier and Type
    Method
    Description
    default Image
    createImage​(CyNetworkView networkView, int width, int height)
    Creates a network image thumbnail with the given width and height.
    createImage​(CyNetworkView networkView, Collection<Annotation> annotations, Map<String,​Object> properties)
    Creates a network image thumbnail with the given properties.
  • Field Details

    • HEIGHT

      static final String HEIGHT
      The height of the image, default: 100
      See Also:
      Constant Field Values
    • WIDTH

      static final String WIDTH
      The width of the returned image, default: 100
      See Also:
      Constant Field Values
    • FIT_CONTENT

      static final String FIT_CONTENT

      If true the network will be automatically centered and scaled to fit inside the image bounds.

      If false then the network Visual Properties NETWORK_SCALE_FACTOR, NETWORK_CENTER_X_LOCATION, NETWORK_CENTER_Y_LOCATION will be used to position and scale the image. The origin for the image coordinates is at the center of the image.

      Default: true.
      See Also:
      Constant Field Values
  • Method Details

    • createImage

      Image createImage(CyNetworkView networkView, Collection<Annotation> annotations, Map<String,​Object> properties)
      Creates a network image thumbnail with the given properties.

      Example:
       Map<String,Object> properties = new HashMap<>();
       properties.put(WIDTH,  width);
       properties.put(HEIGHT, height);
       properties.put(FIT_CONTENT, true);
       Image image = thumbnailFactory.createThumbnail(networkView, null, properties);
       
      Parameters:
      networkView - A CyNetworkView that was created from Cytoscape's default CyNetworkViewFactory.
      annotations - A list of Annotations that will be included in the image. May be null.
      properties - A Map of key-value pairs where the keys are constants in this interface. May be null.
      Throws:
      NullPointerException - If networkView is null.
      IllegalArgumentException - If the given networkView was not created by Cytoscape's default CyNetworkViewFactory.
    • createImage

      default Image createImage(CyNetworkView networkView, int width, int height)
      Creates a network image thumbnail with the given width and height. The network will be centered and scaled to fit within the image bounds.

      Equivalent to:
       Map<String,Object> properties = new HashMap<>();
       properties.put(WIDTH,  width);
       properties.put(HEIGHT, height);
       properties.put(FIT_CONTENT, true);
       Image image = thumbnailFactory.createThumbnail(networkView, null, properties);