RectNode

class visualife.diagrams.RectNode(id, text, xc, yc, w, h, **attrs)

Bases: visualife.diagrams.NodeBase

Rectangular node of a diagram - a box with a text in it.

param id:

(string) id to be set to the SVG element of the rectangle

param text:

(string) text to be displayed in the box

param xc:

(number) X of the rectangle center

param yc:

(number) Y of the rectangle center

param w:

(number) width of the box

param h:

(number) height of the box

param attrs:

see below

Keyword Arguments:
 
  • text_style (string or dict) – a style for text placed at this node
  • node_style (string or dict) – a style for drawing the rectangle

The example below creates a RectNode . Four additional small dots mark its top(), left(), bottom() and right() position.

from browser import document
from visualife.core import HtmlViewport
from visualife.diagrams import RectNode, DotNode

drawing = HtmlViewport(document['svg-box'],200,100)
box = RectNode("box-0", "example box", 100, 40, 100, 50)
t = DotNode("dot-1", box.top.x, box.top.y, 5)
l = DotNode("dot-2", box.left.x, box.left.y, 5)
b = DotNode("dot-3", box.bottom.x, box.bottom.y, 5)
r = DotNode("dot-4", box.right.x, box.right.y, 5)
for shape in [box, t, l, b, r]:
  shape.draw(drawing)
drawing.close()

Attributes Summary

bottom Coordinates of the point in the middle of the bottom side of this rectangle
h Height of this rectangle
left Coordinates of the point in the middle of the left side of this rectangle
right Coordinates of the point in the middle of the right side of this rectangle
top Coordinates of the point in the middle of the top side of this rectangle
w Width of this rectangle

Methods Summary

draw(viewport, **kwargs) Draw this dot node on a viewport.

Attributes Documentation

bottom

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

Returns:(Point) middle coordinates of the bottom side
h

Height of this rectangle

Returns:(number) height
left

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

Returns:(Point) middle coordinates of the left side
right

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

Returns:(Point) middle coordinates of the right side
top

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

Returns:(Point) middle coordinates of the top side
w

Width of this rectangle

Returns:(number) width

Methods Documentation

draw(viewport, **kwargs)

Draw this dot node on a viewport.

Parameters: