ofc2_element.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # This program is free software; you can redistribute it and/or modify
  2. # it under the terms of the GNU General Public License as published by
  3. # the Free Software Foundation; version 2 of the License.
  4. #
  5. # This program is distributed in the hope that it will be useful,
  6. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. # GNU General Public License for more details.
  9. #
  10. # Author: Emanuel Fonseca
  11. # Email: emdfonseca<at>gmail<dot>com
  12. # Date: 25 August 2008
  13. class element(dict):
  14. def __init__(self, type=None, alpha=None, colour=None, text=None, fontsize=None, values=None):
  15. self.set_type(type)
  16. self.set_alpha(alpha)
  17. self.set_colour(colour)
  18. self.set_text(text)
  19. self.set_fontsize(fontsize)
  20. self.set_values(values)
  21. def set_type(self, type):
  22. if type:
  23. self['type'] = type
  24. def set_alpha(self, alpha):
  25. if alpha:
  26. self['alpha'] = alpha
  27. def set_colour(self, colour):
  28. if colour:
  29. self['colour'] = colour
  30. def set_text(self, text):
  31. if text:
  32. self['text'] = text
  33. def set_fontsize(self, fontsize):
  34. if fontsize:
  35. self['font-size'] = fontsize
  36. def set_values(self, values):
  37. if values:
  38. self['values'] = values
  39. class Line(element):
  40. def __init__(self, type=None, alpha=None, colour=None, text=None, fontsize=None, values=None):
  41. element.__init__(self, 'line', alpha, colour, text, fontsize, values)
  42. class Bar(element):
  43. def __init__(self, type=None, alpha=None, colour=None, text=None, fontsize=None, values=None):
  44. element.__init__(self, 'bar', alpha, colour, text, fontsize, values)
  45. class BarStack(element):
  46. def __init__(self, type=None, alpha=None, colour=None, text=None, fontsize=None, values=None):
  47. element.__init__(self, 'bar_stack', alpha, colour, text, fontsize, values)