File: graphviz_node.cpp

package info (click to toggle)
graphviz 14.0.5-2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 139,388 kB
  • sloc: ansic: 141,938; cpp: 11,957; python: 7,766; makefile: 4,043; yacc: 3,030; xml: 2,972; tcl: 2,495; sh: 1,388; objc: 1,159; java: 560; lex: 423; perl: 243; awk: 156; pascal: 139; php: 58; ruby: 49; cs: 31; sed: 1
file content (47 lines) | stat: -rw-r--r-- 1,744 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <string>

#include "graphviz_node.h"
#include "svg_element.h"

GraphvizNode::GraphvizNode(SVG::SVGElement &svg_element)
    : m_node_id(svg_element.graphviz_id), m_svg_g_element(svg_element) {}

void GraphvizNode::add_bbox() { m_svg_g_element.add_bbox(); }

void GraphvizNode::add_outline_bbox() { m_svg_g_element.add_outline_bbox(); }

SVG::SVGPoint GraphvizNode::center() const { return bbox().center(); }

std::string GraphvizNode::color() const {
  const auto stroke = m_svg_g_element.attribute_from_subtree<std::string>(
      &SVG::SVGAttributes::stroke, &SVG::SVGElement::is_shape_element, "");
  const auto stroke_opacity = m_svg_g_element.attribute_from_subtree<double>(
      &SVG::SVGAttributes::stroke_opacity, &SVG::SVGElement::is_shape_element,
      1);
  return SVG::to_dot_color(stroke, stroke_opacity);
}

std::string GraphvizNode::fillcolor() const {
  const auto fill = m_svg_g_element.attribute_from_subtree<std::string>(
      &SVG::SVGAttributes::fill, &SVG::SVGElement::is_shape_element, "");
  const auto fill_opacity = m_svg_g_element.attribute_from_subtree<double>(
      &SVG::SVGAttributes::fill_opacity, &SVG::SVGElement::is_shape_element, 1);
  return SVG::to_dot_color(fill, fill_opacity);
}

double GraphvizNode::penwidth() const {
  return m_svg_g_element.attribute_from_subtree<double>(
      &SVG::SVGAttributes::stroke_width, &SVG::SVGElement::is_shape_element, 1);
}

std::string_view GraphvizNode::node_id() const { return m_node_id; }

SVG::SVGRect GraphvizNode::bbox() const { return m_svg_g_element.bbox(); }

SVG::SVGRect GraphvizNode::outline_bbox() const {
  return m_svg_g_element.outline_bbox();
}

const SVG::SVGElement &GraphvizNode::svg_g_element() const {
  return m_svg_g_element;
}