def __init__(self, id=None): super(Line, self).__init__() self.style = Style(Line.__style__) self._id = id self.fuzziness = 2 self._handles[0].connectable = False self._handles[-1].connectable = False
def __init__(self, attr, style=None, pattern=None, visible=None, editable=False): """ Create new text element with bounds (0, 0, 10, 10) and empty text. Parameters: - visible: function, which evaluates to True/False if text should be visible """ super(TextElement, self).__init__() self._bounds = Rectangle(0, 0, width=15, height=10) # create default style for a text element self._style = Style() self._style.add("text-padding", (2, 2, 2, 2)) self._style.add("text-align", (ALIGN_CENTER, ALIGN_TOP)) self._style.add("text-outside", False) self._style.add("text-rotated", False) self._style.add("text-align-str", None) self._style.add("font", DEFAULT_TEXT_FONT) if style: self._style.update(style) self.attr = attr self._text = "" if visible: self.is_visible = visible if pattern: self._pattern = pattern else: self._pattern = "%s" self.editable = editable
def set_style(self, data): """ Set item style information by merging provided information with style information from base classes. @param cls: new instance of diagram item class @param bases: base classes of an item @param data: metaclass data with style information """ style = Style() for c in self.__bases__: if hasattr(c, 'style'): for (name, value) in c.style.items(): style.add(name, value) if '__style__' in data: for (name, value) in six.iteritems(data['__style__']): style.add(name, value) self.style = style
def __init__(self, id=None): super(Box, self).__init__(10, 10) self.style = Style(Box.__style__) self._id = id
def __init__(self, id=None): super(Ellipse, self).__init__() self.style = Style(Ellipse.__style__) self._id = id