def parseLineNode(node): s = getSettings(node) x1 = float(node.attributes['x1'].value) y1 = float(node.attributes['y1'].value) x2 = float(node.attributes['x2'].value) y2 = float(node.attributes['y2'].value) arrowhead = node.hasAttribute("marker-end") and node.attributes[ "marker-end"].value == "url(#Arrowhead)" arrowtail = node.hasAttribute("marker-start") and node.attributes[ "marker-start"].value == "url(#Arrowtail)" if arrowhead and arrowtail: s.arrow = 3 # Fixme: adjustment! elif arrowtail: s.arrow = 2 elif arrowhead: s.arrow = 1 # Adjust the arrow line end ( Fixme: More work required ) lineWidth = s.linewidth angle = rad_angle(x2, y2, x1, y1) x2, y2 = actual_line_end(x2, y2, angle, lineWidth) else: s.arrow = 0 return ["line", (x1, y1, x2, y2), s, parseNodeTransform(node)]
def parse_line_node(node, state): settings = get_settings(node, state) x1 = float(node.attributes['x1'].value) y1 = float(node.attributes['y1'].value) x2 = float(node.attributes['x2'].value) y2 = float(node.attributes['y2'].value) parse_marker_attribute(node, settings) if settings.arrow in ('front', 'both'): # Adjust the arrow line end ( Fixme: More work required ) line_width = settings.linewidth angle = rad_angle(x2, y2, x1, y1) x2, y2 = actual_line_end(x2, y2, angle, line_width) return ["line", (x1, y1, x2, y2), settings, parse_node_transform(node)]
def parse_polyline_node(node, state): settings = get_settings(node, state) parse_marker_attribute(node, settings) points = node.attributes['points'].value.strip() points = points.replace(" ", ",") # Fixme vals = [float(coord) for coord in points.split(',') if len(coord) > 0] if settings.arrow in ('front', 'both'): angle = rad_angle(vals[-2], vals[-1], vals[-4], vals[-3]) vals[-2], vals[-1] = actual_line_end(vals[-2], vals[-1], angle, settings.linewidth) return ["polyline", vals, settings, parse_node_transform(node)]
def parsePolyLineNode(node): s = getSettings(node) arrowhead = node.hasAttribute("marker-end") and node.attributes[ "marker-end"].value == "url(#Arrowhead)" arrowtail = node.hasAttribute("marker-start") and node.attributes[ "marker-start"].value == "url(#Arrowtail)" if arrowhead and arrowtail: s.arrow = 3 elif arrowtail: s.arrow = 2 elif arrowhead: s.arrow = 1 else: s.arrow = 0 points = node.attributes['points'].value.strip() points = points.replace(" ", ",") # Fixme vals = [float(coord) for coord in points.split(',') if len(coord) > 0] if arrowhead: angle = rad_angle(vals[-2], vals[-1], vals[-4], vals[-3]) vals[-2], vals[-1] = actual_line_end(vals[-2], vals[-1], angle, s.linewidth) return ["polyline", vals, s, parseNodeTransform(node)]