Example #1
0
	def createFromXml(node: QDomNode):
		if node.nodeName() != "distributor":
			return None
		if not (node.hasAttributes() and node.attributes().contains("id")):
			return None
		id = node.attributes().namedItem("id").nodeValue()
		childs = node.childNodes()
		graphics = None
		tags = []
		for i in range(childs.count()):
			child = childs.at(i)
			if child.nodeName() == "graphics":
				graphics = PFSXmlBase.getNode(child)
			if child.nodeName() == "tags":
				tags = PFSBasicElement.createFromXml(child)
		if graphics is not None:
			di = PFSDistributorContent()
			di._id = id
			di._x = graphics.rect.x()
			di._y = graphics.rect.y()
			di._width = graphics.rect.width()
			di._height = graphics.rect.height()
			if graphics.line is not None:
				di._pen = graphics.line
			if graphics.brush is not None:
				di._brush = graphics.brush
			di._tags = tags	
			return di			
		return None
Example #2
0
 def toolHasChild(node: QDomNode, value: str) -> bool:
     if node.nodeName() != "toolspecific":
         return False
     attr = node.attributes()
     if not (node.hasAttributes() and attr.contains("tool")
             and attr.namedItem("tool").nodeValue() == "PFS"):
         return False
     if not (node.hasAttributes() and attr.contains("version")
             and attr.namedItem("version").nodeValue() == "1.0.0"):
         return False
     if not node.hasChildNodes():
         return False
     childs = node.childNodes()
     for i in range(childs.count()):
         if childs.at(i).nodeName() == value:
             return True
     return False
Example #3
0
 def getFill(node: QDomNode):
     if node.nodeName() != "fill":
         return None
     attr = node.attributes()
     if not (node.hasAttributes() and attr.contains("color")):
         return None
     brush = QBrush(Qt.black, Qt.SolidPattern)
     brush.setColor(QColor(attr.namedItem("color").nodeValue()))
     return brush
Example #4
0
 def getPosition(node: QDomNode):
     if node.nodeName() not in ["position", "dimension", "offset"]:
         return None
     if not (node.hasAttributes() and node.attributes().contains("x")
             and node.attributes().contains("y")):
         return None
     ans = PFSAux()
     ans.x = float(node.attributes().namedItem("x").nodeValue())
     ans.y = float(node.attributes().namedItem("y").nodeValue())
     return ans
Example #5
0
 def getLine(node: QDomNode):
     if node.nodeName() not in ["line"]:
         return None
     attr = node.attributes()
     if not (node.hasAttributes() and attr.contains("color")):
         return None
     pen = QPen(QColor(attr.namedItem("color").nodeValue()))
     if attr.contains("width"):
         pen.setWidth(int(attr.namedItem("width").nodeValue()))
     if attr.contains("style"):
         if attr.namedItem("style").nodeValue() == "dash":
             pen.setStyle(Qt.DashLine)
         if attr.namedItem("style").nodeValue() == "dot":
             pen.setStyle(Qt.DotLine)
     return pen
Example #6
0
	def createFromXml(node: QDomNode):
		if node.nodeName() != "activity":
			return None
		if not (node.hasAttributes() and node.attributes().contains("id")):
			return None
		id = node.attributes().namedItem("id").nodeValue()
		childs = node.childNodes()
		graphics = None
		text = None
		if node.attributes().contains("inputnum"):
			inputNum =  int(node.attributes().namedItem("inputnum").nodeValue())
		else:
			inputNum = 1
		if node.attributes().contains("outputnum"):
			outputNum =  int(node.attributes().namedItem("outputnum").nodeValue())
		else:
			outputNum = 1
		tags = []
		for i in range(childs.count()):
			child = childs.at(i)
			if child.nodeName() == "graphics":
				graphics = PFSXmlBase.getNode(child)
			if child.nodeName() == "text":
				text = PFSXmlBase.getText(child)
			if child.nodeName() == "tags":
				tags = PFSBasicElement.createFromXml(child)
		if graphics is not None and text is not None:
			ac = PFSActivityContent()
			ac._id = id
			ac._x = graphics.rect.x()
			ac._y = graphics.rect.y()
			ac._text = text.annotation
			ac._width = graphics.rect.width()
			ac._height = graphics.rect.height()		
			if text.font is not None:
				ac._textFont = text.font
				ac._fontMetrics = QFontMetrics(text.font)
			if graphics.line is not None:
				ac._pen = graphics.line
			if graphics.brush is not None:
				ac._brush = graphics.brush
			ac._tags = tags
			ac._inputNum = inputNum
			ac._outputNum = outputNum
			return ac
		return None
Example #7
0
 def getFont(node: QDomNode):
     if node.nodeName() != "font":
         return None
     attr = node.attributes()
     if not (node.hasAttributes() and attr.contains("family")
             and attr.contains("size")):
         return None
     ans = PFSAux()
     ans.font = QFont(
         attr.namedItem("family").nodeValue(),
         int(attr.namedItem("size").nodeValue()))
     if attr.contains("style"):
         if attr.namedItem("style").nodeValue() == "italic":
             ans.font.setStyle(QFont.StyleItalic)
         elif attr.namedItem("style").nodeValue() == "oblique":
             ans.font.setStyle(QFont.StyleOblique)
     if attr.contains("weight"):
         v = [
             "bold", "bolder", "lighter", "100", "200", "300", "400", "500",
             "600", "700", "800", "900", "900"
         ]
         if attr.namedItem("weight").nodeValue() in v:
             ans.font.setWeight(
                 v.index(attr.namedItem("weight").nodeValue()) * 4 + 50)
     if attr.contains("decoration"):
         decor = attr.namedItem("decoration").nodeValue()
         if decor.find("underline") > 0:
             ans.font.setUnderline(True)
         if decor.find("overline") > 0:
             ans.font.setOverline(True)
         if decor.find("line-through") > 0:
             ans.font.setStrikeOut(True)
     if attr.contains("align"):
         ans.align = attr.namedItem("align").nodeValue()
     else:
         ans.align = None
     if attr.contains("rotation"):
         ans.rotation = int(attr.namedItem("rotation").nodeValue())
     else:
         ans.rotation = None
     return ans
Example #8
0
 def createFromXml(node: QDomNode):
     if node.nodeName() != "relation":
         return None
     attr = node.attributes()
     if not (node.hasAttributes() and attr.contains("id")):
         return None
     id = attr.namedItem("id").nodeValue()
     if not (attr.contains("source") and attr.contains("target")):
         return None
     source = attr.namedItem("source").nodeValue()
     target = attr.namedItem("target").nodeValue()
     sourceNum = 0
     targetNum = 0
     if attr.contains("sourceport"):
         sourceNum = int(attr.namedItem("sourceport").nodeValue())
     if attr.contains("targetport"):
         targetNum = int(attr.namedItem("targetport").nodeValue())
     graphics = None
     tags = []
     childs = node.childNodes()
     for i in range(childs.count()):
         child = childs.at(i)
         if child.nodeName() == "graphics":
             graphics = PFSXmlBase.getArc(child)
         if child.nodeName() == "tags":
             tags = PFSBasicElement.createFromXml(child)
     re = PFSRelationContent()
     re._id = id
     re._source = source
     re._sourceNum = sourceNum
     re._target = target
     re._targetNum = targetNum
     if graphics is not None and graphics.line is not None:
         re._pen = graphics.line
     re._midPoints = []
     if graphics is not None and graphics.pos is not None:
         for pos in graphics.pos:
             re._midPoints.append(QPointF(pos.x, pos.y))
     re._tags = tags
     return re
Example #9
0
	def createFromXml(node: QDomNode):
		if node.nodeName() != "closeactivity":
			return None
		if not (node.hasAttributes() and node.attributes().contains("id")):
			return None
		id = node.attributes().namedItem("id").nodeValue()
		childs = node.childNodes()
		graphics = None
		tags = []
		for i in range(childs.count()):
			child = childs.at(i)
			if child.nodeName() == "graphics":
				graphics = PFSXmlBase.getNode(child)
			if child.nodeName() == "tags":
				tags = PFSBasicElement.createFromXml(child)
		if graphics is not None:
			ca = PFSCloseActivityContent()
			ca._id = id
			ca._x = graphics.rect.x() + 6
			ca._y = graphics.rect.y()
			ca._h = graphics.rect.height()
			ca._tags = tags
			return ca
		return None	
Example #10
0
 def createFromXml(node: QDomNode):
     if node.nodeName() != "secondaryflow":
         return None
     attr = node.attributes()
     if not (node.hasAttributes() and attr.contains("id")):
         return None
     id = attr.namedItem("id").nodeValue()
     if not (attr.contains("source") and attr.contains("target")):
         return None
     source = attr.namedItem("source").nodeValue()
     target = attr.namedItem("target").nodeValue()
     lineX = 0
     if attr.contains("linex"):
         lineX = float(attr.namedItem("linex").nodeValue())
     graphics = None
     tags = []
     childs = node.childNodes()
     for i in range(childs.count()):
         child = childs.at(i)
         if child.nodeName() == "graphics":
             graphics = PFSXmlBase.getArc(child)
         if child.nodeName() == "tags":
             tags = PFSBasicElement.createFromXml(child)
     re = PFSSecondaryFlowContent()
     re._id = id
     re._source = source
     re._target = target
     re._lineX = lineX
     if graphics is not None and graphics.line is not None:
         re._pen = graphics.line
     if graphics is not None and graphics.pos is not None:
         re._midPoints = graphics.pos
     else:
         re._midPoints = []
     re._tags = tags
     return re