NodeBase

class visualife.diagrams.NodeBase(id, x, y)

Bases: visualife.diagrams.Point

A base class to all nodes.

A NodeBase is derived from the Point class to store coordinates for this node’s center.

Each node (except DotNode) may have a text written on it. The text and the shape of this node itself have a distinct IDs; they can be obtained from text_id() and shape_id() getters, respectively. Each node has also can draw itself on a viewport.

Parameters:
  • id – (string) unique identifier for this node
  • x – (number) X coordinate for this node’s center
  • y – (number) Y coordinate for this node’s center

Attributes Summary

bottom Coordinates of the point in the middle of the bottom side of this node
height The height of this node.
id Returns ID of this node
left Coordinates of the point in the middle of the left side of this node
right Coordinates of the point in the middle of the right side of this node
shape_id Returns ID of the shape element of this node.
text_id Returns ID of the text element of this node.
top Coordinates of the point in the middle of the top side of this node
width The width of this node.

Methods Summary

draw(viewport, **kwargs) Draw this node on a viewport
highlight([state]) Highlights this box or turns it back to normal.

Attributes Documentation

bottom

Coordinates of the point in the middle of the bottom side of this node

Abstract method, raises NotImplementedError

height

The height of this node.

This property is evaluated as self.bottom.y - self.top.y, so it relies on bottom() and top() implementation of a derived class :return: height of this node.

id

Returns ID of this node

Returns:unique ID of this node
left

Coordinates of the point in the middle of the left side of this node

Abstract method, raises NotImplementedError

right

Coordinates of the point in the middle of the right side of this node

Abstract method, raises NotImplementedError

shape_id

Returns ID of the shape element of this node.

Returns:(string) unique ID assigned to the shape element of this node (e.g. a <rect> or a <circle>)
text_id

Returns ID of the text element of this node.

Returns:(string) ID of the text part of this node
top

Coordinates of the point in the middle of the top side of this node

Abstract method, raises NotImplementedError

width

The width of this node.

This property is evaluated as self.right.x - self.left.x, so it relies on left() and right() implementation of a derived class :return: width of this node.

Methods Documentation

draw(viewport, **kwargs)

Draw this node on a viewport

Abstract method, raises NotImplementedError

Parameters:
highlight(state=True)

Highlights this box or turns it back to normal.

Highlighting this node will change it’s fill color to a reddish tint of its existing (standard) color The new color will be visible until clear() is called. This method works only when visualife.core.HtmlViewport is used to render the graphics; otherwise it has no effect.

Parameters:state – (boolean) if True, this node will be highlighted, otherwise any highlight effect

will be cancelled