NodeBase¶
-
class
visualife.diagrams.NodeBase(id, x, y)¶ Bases:
visualife.diagrams.PointA base class to all nodes.
A NodeBase is derived from the
Pointclass 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()andshape_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
bottomCoordinates of the point in the middle of the bottom side of this node heightThe height of this node. idReturns ID of this node leftCoordinates of the point in the middle of the left side of this node rightCoordinates of the point in the middle of the right side of this node shape_idReturns ID of the shape element of this node. text_idReturns ID of the text element of this node. topCoordinates of the point in the middle of the top side of this node widthThe 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 onbottom()andtop()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 onleft()andright()implementation of a derived class :return: width of this node.
Methods Documentation
-
draw(viewport, **kwargs)¶ Draw this node on a viewport
Abstract method, raises
NotImplementedErrorParameters: - viewport – (
visualife.core.HtmlViewportorvisualife.core.SvgViewport) where to draw this node - kwargs – node styling parameters
- viewport – (
-
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 whenvisualife.core.HtmlViewportis used to render the graphics; otherwise it has no effect.Parameters: state – ( boolean) ifTrue, this node will be highlighted, otherwise any highlight effectwill be cancelled
- id – (