From 900a2d167991fa6e6629e2aa71b036bf074db235 Mon Sep 17 00:00:00 2001 From: jlaw9 Date: Thu, 20 Jul 2017 08:50:55 -0400 Subject: [PATCH 1/3] Modified the set_node_bubble_effect_property() function so it will only set the 'text-outline-color' and 'text-outline-width'. Other attributes are already set by set_node_style() --- graphspace_python/graphs/classes/gsgraph.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/graphspace_python/graphs/classes/gsgraph.py b/graphspace_python/graphs/classes/gsgraph.py index b4c43ad..ab14017 100644 --- a/graphspace_python/graphs/classes/gsgraph.py +++ b/graphspace_python/graphs/classes/gsgraph.py @@ -203,9 +203,9 @@ def add_node_style(self, node_name, attr_dict=None, content=None, shape='ellipse bubble: string -- color of the text outline. Using this option gives a "bubble" effect; see the bubbleeffect() function. Optional. valign: string -- vertical alignment. Default = center. halign: string -- horizontal alignment. Default = center. - style: string -- style of border. Default is "solid". If Bubble is specified, then style is overwritten. - border_color: string -- color of border. Default is #000000. If Bubble is specified, then style is overwritten. - border_width: int -- width of border. Default is 4. If Bubble is specified, then style is overwritten. + style: string -- style of border. Default is "solid". + border_color: string -- color of border. Default is #000000. + border_width: int -- width of border. Default is 4. Returns @@ -233,7 +233,10 @@ def add_node_style(self, node_name, attr_dict=None, content=None, shape='ellipse if bubble: style_properties = GSGraph.set_node_bubble_effect_property(style_properties, bubble, whitetext=False) - attr_dict.update(style_properties) + # if any of the properties were specified in the attr_dict, + # then overwrite the default style_properties with the given attr_dict value + style_properties.update(attr_dict) + attr_dict = style_properties self.set_style_json({ 'style': self.get_style_json().get('style') + [{ @@ -437,8 +440,8 @@ def set_node_width_property(node_properties, width): @staticmethod def set_node_bubble_effect_property(node_properties, color, whitetext=False): """ - Add a "bubble effect" to the node by making the - border color the same as the text outline color. + Add a "bubble effect" to the node by adding a border or outline + around the text ('text-outline-width': 4) with the given color ('text-outline-color': color) Parameters ---------- @@ -452,8 +455,7 @@ def set_node_bubble_effect_property(node_properties, color, whitetext=False): """ node_properties.update({'text-outline-color': color}) - node_properties = GSGraph.set_node_border_color_property(node_properties, color) - # also make outline thicker and text larger + # also make outline thicker making the text look larger node_properties.update({'text-outline-width': 4}) if whitetext: node_properties.update({'color': 'white'}) From f987479d919492c39da2d67db15ed6066b11c30e Mon Sep 17 00:00:00 2001 From: jlaw9 Date: Thu, 20 Jul 2017 08:56:16 -0400 Subject: [PATCH 2/3] Modified set_node_style() and set_edge_style() so the attr_dict will not be overwritten by default values --- graphspace_python/graphs/classes/gsgraph.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/graphspace_python/graphs/classes/gsgraph.py b/graphspace_python/graphs/classes/gsgraph.py index ab14017..8a400f9 100644 --- a/graphspace_python/graphs/classes/gsgraph.py +++ b/graphspace_python/graphs/classes/gsgraph.py @@ -277,7 +277,10 @@ def add_edge_style(self, source, target, attr_dict=None, directed=False, color=' selector = 'edge[source="%s"][target="%s"]' % (source, target) - attr_dict.update(style_properties) + # if any of the properties were specified in the attr_dict, + # then overwrite the default style_properties with the given attr_dict value + style_properties.update(attr_dict) + attr_dict = style_properties self.set_style_json({ 'style': self.get_style_json().get('style') + [{ From a03b0aff2499aecc4485aa66373747aeb931c393 Mon Sep 17 00:00:00 2001 From: jlaw9 Date: Tue, 15 Aug 2017 11:51:30 -0400 Subject: [PATCH 3/3] fixed merge --- graphspace_python/graphs/classes/gsgraph.py | 54 +-------------------- 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/graphspace_python/graphs/classes/gsgraph.py b/graphspace_python/graphs/classes/gsgraph.py index cbfad5a..ddb09f0 100644 --- a/graphspace_python/graphs/classes/gsgraph.py +++ b/graphspace_python/graphs/classes/gsgraph.py @@ -520,32 +520,6 @@ def add_node(self, node_name, attr_dict=None, label=None, popup=None, k=None, ** super(GSGraph, self).add_node(node_name, attr_dict) def add_node_style(self, node_name, attr_dict=None, content=None, shape='ellipse', color='#FFFFFF', height=None, -<<<<<<< HEAD - width=None, bubble=None, valign='center', halign='center', style="solid", - border_color='#000000', border_width=1): - """ - Add the style for the given node in the style json. - - Parameters - ---------- - node_name: string - name of the node. - shape: string -- shape of node. Default = "ellipse". - color: string -- hexadecimal representation of the color (e.g., #FFFFFF) or color name. Default = white. - height: int -- height of the node's body. Use None to determine height from the number of lines in the label. Default = None. - width: int -- width of the node's body, or None to determine width from length of label. Default=None. - bubble: string -- color of the text outline. Using this option gives a "bubble" effect; see the bubbleeffect() function. Optional. - valign: string -- vertical alignment. Default = center. - halign: string -- horizontal alignment. Default = center. - style: string -- style of border. Default is "solid". - border_color: string -- color of border. Default is #000000. - border_width: int -- width of border. Default is 4. - - - Returns - ------- - None - -======= width=None, bubble=None, valign='center', halign='center', style="solid", border_color='#000000', border_width=1): """Add the style for the given node in the style json. @@ -579,7 +553,6 @@ def add_node_style(self, node_name, attr_dict=None, content=None, shape='ellipse 'height': 90, 'width': 90, 'shape': 'ellipse', 'border-style': 'solid', 'text-wrap': 'wrap', 'text-halign': 'center', 'text-valign': 'center', 'background-color': 'blue'}, 'selector': 'node[name="b"]'}]} ->>>>>>> upstream/master """ attr_dict = attr_dict if attr_dict is not None else dict() @@ -601,14 +574,7 @@ def add_node_style(self, node_name, attr_dict=None, content=None, shape='ellipse if bubble: style_properties = GSGraph.set_node_bubble_effect_property(style_properties, bubble, whitetext=False) -<<<<<<< HEAD - # if any of the properties were specified in the attr_dict, - # then overwrite the default style_properties with the given attr_dict value - style_properties.update(attr_dict) - attr_dict = style_properties -======= style_properties.update(attr_dict) ->>>>>>> upstream/master self.set_style_json({ 'style': self.get_style_json().get('style') + [{ @@ -657,14 +623,7 @@ def add_edge_style(self, source, target, attr_dict=None, directed=False, color=' selector = 'edge[source="%s"][target="%s"]' % (source, target) -<<<<<<< HEAD - # if any of the properties were specified in the attr_dict, - # then overwrite the default style_properties with the given attr_dict value style_properties.update(attr_dict) - attr_dict = style_properties -======= - style_properties.update(attr_dict) ->>>>>>> upstream/master self.set_style_json({ 'style': self.get_style_json().get('style') + [{ @@ -833,20 +792,10 @@ def set_node_width_property(node_properties, width): @staticmethod def set_node_bubble_effect_property(node_properties, color, whitetext=False): -<<<<<<< HEAD """ Add a "bubble effect" to the node by adding a border or outline around the text ('text-outline-width': 4) with the given color ('text-outline-color': color) - Parameters - ---------- - whitetext - Boolean -- if True, text is colored white instead of black. Default is False. - color - string -- hexadecimal representation of the text outline color (e.g., #FFFFFF) or a color name. - node_properties - Dictionary of node attributes. Key/value pairs will be used to set data associated with the node. -======= - """Add a "bubble effect" to the node by making the border color the same as the text outline color. ->>>>>>> upstream/master - Args: node_properties (dict): Dictionary of node attributes. Key-value pairs will be used to set data associated with the node. color (str): Hexadecimal representation of the text outline color (e.g., #FFFFFF) or a color name. @@ -856,7 +805,8 @@ def set_node_bubble_effect_property(node_properties, color, whitetext=False): dict: Dictionary of node attributes. """ node_properties.update({'text-outline-color': color}) - # also make outline thicker making the text look larger + #node_properties = GSGraph.set_node_border_color_property(node_properties, color) + # also make outline thicker and text larger node_properties.update({'text-outline-width': 4}) if whitetext: node_properties.update({'color': 'white'})