Wiki

Clone wiki

Tree Visualization API / reshape

Operator.js

connectTofillorderreshaperotatescalesetStrokeColorsetStrokeWidthslicesquarifystriptranslate

Function reshape

Transforms the drawing area/shape into a different one as specified in the parameter.
Recommended stage: INITIALIZE , PRELAYOUT, POSTLAYOUT
If applied in INITIALIZE stage: transform the entire drawing area for the tree
If applied in PRELAYOUT stage:transform the drawing area of the level of a tree
If applied in POSTLAYOUT stage: transform the node shape

Function definition


reshape(form, condition)       

Parameters details


form      = (CIRCLE|RECTANGLE|DOT) –- other shape is not supported yet
condition = optional condition if operator is to be carried out. If left out, it is assumed TRUE

Example


If called in INITIALIZE stage it transforms the entire drawing space for the tree into the specified shape, which can then be used iteratively for the layout.

......
INITIALIZE:
{
..
reshape(CIRCLE);
}
.....

reshape in ROOT_LAYOUT

If called in POSTLAYOUT stage it transforms each node shape into a defined initial shape. In the following code example it transform every node shape to a DOT base shape

.....
POSTLAYOUT:
{

..
reshape(DOT);

}

If we want every nodes to be rectangular shape, we make the following changes to the code

.......
POSTLAYOUT:
{

...
reshape(RECTANGLE);

}

reshape in POSTLAYOUT

Following code fragment do the conditional reshaping of the node. All leaf nodes are reshaped to circle and non leaf nodes are reshaped as rectangle.

POSTLAYOUT:
{
...
reshape(CIRCLE,"node.isLeaf()");
reshape(RECTANGLE,"!node.isLeaf()");

..
}

Sample Output Figure:

Conditional Reshape

Updated