6 Copyright (C) 2009-2010 8 RT-Synthesis Research Group 9 Intelligent Systems Research Institute, 10 National Institute of Advanced Industrial Science and Technology (AIST), 13 Licensed under the Eclipse Public License -v 1.0 (EPL) 14 http://www.opensource.org/licenses/eclipse-1.0.txt 18 Location object storing the position of components in a graphical view. 22 __version__ =
'$Revision: $' 26 from rtsprofile
import RTS_EXT_NS, RTS_EXT_NS_S
27 from rtsprofile
import direction
as dir
35 '''Stores the location of a component in a graphical view.''' 37 def __init__(self, x=0, y=0, height=0, width=0, direction=dir.DOWN):
40 @param x X position of the top-left of the component. 42 @param y Y position of the top-left of the component. 44 @param height Height of the component. 46 @param width Width of the component. 48 @param direction Direction the component faces. 49 @type direction direction.const_type 53 expected_type=int, required=
False)
56 expected_type=int, required=
False)
59 expected_type=int, required=
False)
62 expected_type=int, required=
False)
65 expected_type=dir.const_type, required=
False)
69 return 'Position: {0}, {1}\nSize: {2}x{3}\nDirection: {4}'.format(\
75 '''The X position of the component in a graphical tool.''' 81 expected_type=int, required=
False)
86 '''The Y position of the component in a graphical tool.''' 92 expected_type=int, required=
False)
97 '''The height of the component in a graphical tool.''' 103 expected_type=int, required=
False)
108 '''The width of the component in a graphical tool. 110 A value of -1 for this property indicates that the width should be as 111 wide as is necessary. 119 expected_type=int, required=
False)
124 '''The direction of the component in a graphical tool. 126 A value of -1 for this property indicates that the height should be as 127 wide as is necessary. 135 expected_type=dir.const_type, required=
False)
139 '''Parse an xml.dom Node object representing a location into this 143 self.
x = int(node.getAttributeNS(RTS_EXT_NS,
'x'))
144 self.
y = int(node.getAttributeNS(RTS_EXT_NS,
'y'))
145 self.
height = int(node.getAttributeNS(RTS_EXT_NS,
'height'))
146 self.
width = int(node.getAttributeNS(RTS_EXT_NS,
'width'))
147 self.
direction = dir.from_string(node.getAttributeNS(RTS_EXT_NS,
152 '''Parse a YAML specification of a location into this object.''' 155 self.
height = int(y[
'height'])
156 self.
width = int(y[
'width'])
157 self.
direction = dir.from_string(y[
'direction'])
161 '''Save this location into an xml.dom.Element object.''' 162 element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S +
'x', str(self.
x))
163 element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S +
'y', str(self.
y))
164 element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S +
'height',
166 element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S +
'width',
168 element.setAttributeNS(RTS_EXT_NS, RTS_EXT_NS_S +
'direction',
172 '''Save this location into a dictionary.''' 177 'direction': dir.to_string(self.
direction)}
def parse_xml_node(self, node)
def validate_attribute(attr, name, expected_type=None, required=False)
def save_xml(self, doc, element)
def __init__(self, x=0, y=0, height=0, width=0, direction=dir.DOWN)