Skip to content

Special Types

slaymaker1907 edited this page Apr 30, 2017 · 3 revisions

This document describes the types available to plugins with special meaning to the editor such as label, color, etc. Any code samples in this document use TypeScript conventions.

Custom Sinap property types

Most types have a straight forward mapping to programming language types, but some such as color are less intuitive.

Point

Points correspond to the following interface

interface Point {
  x: number;
  y: number;
}

Style

Style is one of the following strings:

  1. solid
  2. dotted
  3. dashed

Width

Width may either be a number for precise control or one of the following strings:

  1. thin
  2. medium
  3. thick

Node Types

  • parents(edge[]): Edges pointing to this node.
  • children(edge[]): Edges pointing away from this node.

General Properties

  • label(string): Name associated with the node.
  • color(color): Color of the node.
  • position(point): Physical position of the node.
  • shape(shape): Display shape of the node.
  • image(string): A relative path to an image from the plugin directory for display if node.shape == "image". This image should be an SVG graphic.
  • anchorPoints(point[]): A list of coordinates according to the image (i.e. not the graph coordinates, but from the SVG instead) which can have edges drawn to and from.
  • borderColor(color): Color of the border around the node.
  • borderStyle(style): The type of border around a node (such as dotted or straight).
  • borderWidth(width): The width of the border around the node.

Edge Types

  • source(node): Source node of this edge.
  • destination(node): Destination node of this edge.

General Properties

  • label(string): Name associated with the edge.
  • color(color): Color of the edge.
  • lineStyle(style): Style of line to draw such as dotted or straight.
  • lineWidth(width): Width of line to draw between the source and destination.
  • showSourceArrow(boolean): If true, display arrow pointing towards source (you generally don't want to do this). Default false.
  • showDestinationArrow(boolean): If true, display arrow pointing towards destination (this is much more common than the previous option). Default true.

Graph

  • nodes(node[]): All nodes in the graph.
  • edges(edge[]): All edges in the graph.

Core Semantic Properties

Properties such as source/destination can often be inferred for a plugin and need not be specified directly by the plugin, though the specific type specified by the plugin for these properties may be used to prevent connecting an edge between certain nodes.

class InputNode {
}
class OutputNode {
}
class GeneralNode {
}
class Edge {
  source: InputNode | GeneralNode;
  destination: OutputNode | GeneralNode;
}

For instance, in the above example, there can not be a node going from an OutputNode to an InputNode.

Further Reading

See plugin.ts for more information.