MCPcopy Create free account
hub / github.com/daft-dev/daft / render

Method render

daft.py:625–781  ·  view source on GitHub ↗

Render the node. :param ctx: The :class:`_rendering_context` object.

(self, ctx)

Source from the content-addressed store, hash-verified

623 self.shape = "ellipse"
624
625 def render(self, ctx):
626 """
627 Render the node.
628
629 :param ctx:
630 The :class:`_rendering_context` object.
631
632 """
633 # Get the axes and default plotting parameters from the rendering
634 # context.
635 ax = ctx.ax()
636
637 # Resolve the plotting parameters.
638 plot_params = dict(self.plot_params)
639
640 plot_params["lw"] = _pop_multiple(
641 plot_params, ctx.line_width, "lw", "linewidth"
642 )
643
644 plot_params["ec"] = plot_params["edgecolor"] = _pop_multiple(
645 plot_params, ctx.node_ec, "ec", "edgecolor"
646 )
647
648 plot_params["fc"] = _pop_multiple(
649 plot_params, "none", "fc", "facecolor"
650 )
651 fc = plot_params["fc"]
652
653 plot_params["alpha"] = plot_params.get("alpha", 1)
654
655 # And the label parameters.
656 if self.label_params is None:
657 label_params = dict(ctx.label_params)
658 else:
659 label_params = dict(self.label_params)
660
661 label_params["va"] = _pop_multiple(
662 label_params, "center", "va", "verticalalignment"
663 )
664
665 label_params["ha"] = _pop_multiple(
666 label_params, "center", "ha", "horizontalalignment"
667 )
668
669 # Deal with ``fixed`` nodes.
670 scale = self.scale
671 if self.fixed:
672 # MAGIC: These magic numbers should depend on the grid/node units.
673 self.offset[1] += 6
674
675 label_params["va"] = "baseline"
676 label_params.pop("verticalalignment", None)
677 label_params.pop("ma", None)
678
679 if plot_params["fc"] == "none":
680 plot_params["fc"] = "k"
681
682 diameter = ctx.node_unit * scale

Callers

nothing calls this directly

Calls 3

_pop_multipleFunction · 0.85
convertMethod · 0.80
axMethod · 0.45

Tested by

no test coverage detected