Beispiel #1
0
    def _set_edge_attributes(self, edge, gc):
        if len(self._edge_label_decorators()) > 0:
            gc.setText("\n".join(
                CollectionTools.flatten(
                    BaseGraphElementDecorator.decorations(
                        self._edge_label_decorators(), edge))))
        # TODO zu langes tooltip/edgetooltip führt bei Graphviz dazu, dass fehlerhaftes SVG erzeugt wird
        if len(self._edge_tooltip_decorators()) > 0:
            # TODO wie erzeuge ich einen Zeilenumbruch im Tooltip??
            gc.setTooltip(
                Label(", ".join(
                    CollectionTools.flatten(
                        BaseGraphElementDecorator.decorations(
                            self._edge_tooltip_decorators(), edge)))))

        edge_attrs = edge.get_attr_names()
        for (in_attr) in edge_attrs:
            in_value = edge.get_attr(in_attr)
            if in_attr == EdgeAttributes.COLOR:
                gc.setLineColor(self.map_swt_color(in_value))
            elif in_attr == EdgeAttributes.WEIGHT:
                gc.setLineWidth(in_value)
            elif in_attr == EdgeAttributes.STYLE:
                gc.setLineStyle(EdgeStyles.map(self.StyleMap, in_value))
            elif in_attr in [EdgeAttributes.GROUPED_EDGES]:
                pass
            else:
                logging.warning("Unknown edge attributes %s=%s" %
                                (in_attr, in_value))
Beispiel #2
0
    def _set_node_attributes(self, node, gn):
        if len(self._node_label_decorators()) > 0:
            gn.setText(
                str(node) + " " + " ".join(
                    CollectionTools.flatten(
                        BaseGraphElementDecorator.decorations(
                            self._node_label_decorators(), node))))
        else:
            gn.setText(str(node))
        # TODO zu langes tooltip/edgetooltip führt bei Graphviz dazu, dass fehlerhaftes SVG erzeugt wird
        if len(self._node_tooltip_decorators()) > 0:
            # TODO wie erzeuge ich einen Zeilenumbruch im Tooltip??
            gn.setTooltip(
                Label(", ".join(
                    CollectionTools.flatten(
                        BaseGraphElementDecorator.decorations(
                            self._node_tooltip_decorators(), node)))))

        height = None
        width = None
        node_attrs = self._graph().node_attr_names(node)
        for (in_attr) in node_attrs:
            in_value = self._graph().node_attr(node, in_attr)
            # TODO Mapping definieren
            if in_attr == NodeAttributes.SHAPE:
                pass
                #attrs[GraphvizConstants.GRAPHVIZ_ATTR_SHAPE] = GraphShapes.map(self.ShapeMap, in_value)
                #if attrs[GraphvizConstants.GRAPHVIZ_ATTR_SHAPE] == GraphvizConstants.GRAPHVIZ_SHAPE_TAB \
                #    and NodeAttributes.HEIGHT not in node_attrs:
                #attrs["width"] = str(4.0 * float(config_graphviz.get_node_scale()))
                #attrs["height"] = str(4.0 * float(config_graphviz.get_node_scale()))
            elif in_attr == NodeAttributes.HEIGHT:
                height = float(in_value)
                # str(float(in_value) * float(config_graphviz.get_node_scale()))
            elif in_attr == NodeAttributes.WIDTH:
                width = float(in_value)
                # str(float(in_value) * float(config_graphviz.get_node_scale()))
            elif in_attr == NodeAttributes.LINE_COLOR:
                gn.setBorderColor(self.map_swt_color(in_value,
                                                     SWT.COLOR_BLACK))
            elif in_attr == NodeAttributes.FILL_COLOR:
                gn.setBackgroundColor(
                    self.map_swt_color(in_value, SWT.COLOR_WHITE))
            elif in_attr == NodeAttributes.LINK:
                pass
                #attrs["href"] = in_value
            elif in_attr in [
                    NodeAttributes.GROUPED_NODES,
                    NodeAttributes.SKIPPED_FROM_EDGE,
                    NodeAttributes.SKIPPED_TO_EDGE, NodeAttributes.LABEL
            ]:
                pass
            else:
                self.__logger.warning("Unknown node attributes %s=%s" %
                                      (in_attr, in_value))
        if width:
            gn.setSize(width * 40, height * 40)
Beispiel #3
0
 def _edge_label(self, edge):
     if len(self._label_decorators()) > 0:
         return "\\n".join(
             CollectionTools.flatten(
                 BaseGraphElementDecorator.decorations(
                     self._label_decorators(), edge)))
     else:
         return None
Beispiel #4
0
 def _tooltip(self, graph_element):
     if len(self._tooltip_decorators()) > 0:
         # TODO wie erzeuge ich einen Zeilenumbruch im Tooltip??
         return ", ".join(
             CollectionTools.flatten(
                 BaseGraphElementDecorator.decorations(
                     self._tooltip_decorators(), graph_element)))
     else:
         return ""
Beispiel #5
0
 def _node_label(self, node):
     nodename = str(node)
     if self._graph().node_attr(node, NodeAttributes.LABEL) != None:
         label = self._render_node_name(self._graph().node_attr(node, NodeAttributes.LABEL))
     else:        
         label = self._render_node_name(nodename)
     if len(self._label_decorators()) > 0:
         if len(label):
             label += "\\n"
         label += "\\n".join(CollectionTools.flatten(BaseGraphElementDecorator.decorations(self._label_decorators(), node)))
     return label
Beispiel #6
0
 def attach_graph(self, graph):
     BaseGraphElementDecorator.attach_graph(self, graph)
     start_nodes = self.get_start_nodes()
     self.__subgraph_nodes = GraphAlgorithms.dependent_nodes(
         graph, start_nodes)
Beispiel #7
0
 def detach_graph(self):
     BaseGraphElementDecorator.detach_graph(self)
     self.__subgraph_nodes = None