RectNode¶
-
class
visualife.diagrams.RectNode(id, text, xc, yc, w, h, **attrs)¶ Bases:
visualife.diagrams.NodeBaseRectangular node of a diagram - a box with a text in it.
param id: (
string) id to be set to the SVG element of the rectangleparam text: (
string) text to be displayed in the boxparam xc: (
number) X of the rectangle centerparam yc: (
number) Y of the rectangle centerparam w: (
number) width of the boxparam h: (
number) height of the boxparam attrs: see below
Keyword Arguments: - text_style (
stringordict) – a style for text placed at this node - node_style (
stringordict) – a style for drawing the rectangle
The example below creates a
RectNode. Four additional small dots mark itstop(),left(),bottom()andright()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
bottomCoordinates of the point in the middle of the bottom side of this rectangle hHeight of this rectangle leftCoordinates of the point in the middle of the left side of this rectangle rightCoordinates of the point in the middle of the right side of this rectangle topCoordinates of the point in the middle of the top side of this rectangle wWidth 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: - viewport – (
visualife.core.HtmlViewportorvisualife.core.SvgViewport) where to draw this node - kwargs – provide style to draw this dot with node_style and text_style keys
- viewport – (
- text_style (