Subgraphs

A Subgraph is a type of ‘Group’ that can be expanded and collapsed to show or hide its contents.

cnvs = document.windows[0].selection.canvas subgraphs = new Array() cnvs.graphics.forEach(function(graphic){ if(graphic instanceof Subgraph){subgraphs.push(graphic)} })
var subgraphs = new Array() canvases.forEach(function(cnvs){ cnvs.graphics.forEach(function(graphic){ if(graphic instanceof Subgraph){subgraphs.push(graphic)} }) })

Creating a Subgraph from Selected Graphics

Here’s a simple example script demonstrating how to create a new subgraph using the selected graphics:

var grphx = document.windows[0].selection.graphics var sg = new Subgraph(grphx)

Instance Properties

Here are the properties of the Subgraph class:

Here is an example script that creates new subgraphs containing newly created graphics. The example shows letters using International Morse Code.

var canvas = document.windows[0].selection.canvas; var g1 = canvas.newShape(); g1.shape = "Circle"; g1.fillColor = Color.black; g1.geometry = new Rect(100, 100, 24.00, 24.00); g1.shadowColor = null; var g2 = canvas.newShape(); g2.shape = "Rectangle"; g2.fillColor = Color.black; g2.geometry = new Rect(148, 100, 72.00, 24.00); g2.shadowColor = null; subgraph = new Subgraph([g1,g2]); subgraph.background.text = "A"; subgraph.collapsed = true; var g3 = canvas.newShape(); g3.shape = "Rectangle"; g3.fillColor = Color.black; g3.geometry = new Rect(100, 200, 72.00, 24.00); g3.shadowColor = null; var g4 = canvas.newShape(); g4.shape = "Circle"; g4.fillColor = Color.black; g4.geometry = new Rect(196, 200, 24.00, 24.00); g4.shadowColor = null; var g5 = canvas.newShape(); g5.shape = "Circle"; g5.fillColor = Color.black; g5.geometry = new Rect(244, 200, 24.00, 24.00); g5.shadowColor = null; var g6 = canvas.newShape(); g6.shape = "Circle"; g6.fillColor = Color.black; g6.geometry = new Rect(292, 200, 24.00, 24.00); g6.shadowColor = null; subgraph = new Subgraph([g3,g4,g5,g6]); subgraph.background.text = "B"; subgraph.collapsed = true;
subgraphs

And here’s a script for expanding all subgraphs in the current canvas:

cnvs = document.windows[0].selection.canvas cnvs.graphics.forEach(function(graphic){ if(graphic instanceof Subgraph){graphic.collapsed = false} })

And here’s a script for collapsing all subgraphs in the current canvas:

cnvs = document.windows[0].selection.canvas cnvs.graphics.forEach(function(graphic){ if(graphic instanceof Subgraph){graphic.collapsed = true} })
UNDER CONSTRUCTION

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.

DISCLAIMER