Files
@ 528140423e49
Branch filter:
Location: volker/graph_components/src/graph_ZCA/components.py - annotation
528140423e49
2.3 KiB
text/x-python
ALso change of the tickmark component
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 528140423e49 7aab6dba2515 7aab6dba2515 528140423e49 7aab6dba2515 7aab6dba2515 7aab6dba2515 528140423e49 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 528140423e49 528140423e49 528140423e49 528140423e49 528140423e49 528140423e49 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 528140423e49 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 7aab6dba2515 | from zope.interface import implementsOnly, implements, Interface
from zope.component import adapts, getGlobalSiteManager
gsm = getGlobalSiteManager()
from graph_ZCA.base import BaseAdapter, BaseComponent, BaseFactory
from graph_ZCA.interfaces import ITickLabel, IAxis, IViewBox, IImage
class TickLabelComponent(BaseComponent):
"""
Generates Ticklabels for an axis
"""
implementsOnly(ITickLabel)
adapts(IAxis)
def __init__(self, axis):
"""
Gets an Object to be adapted
"""
self.axis = axis
def render(self):
return map(str, range(self.axis.start, self.axis.end))
gsm.registerAdapter(TickLabelComponent)
class TickLabel(BaseFactory):
target_interface = ITickLabel
class AxisComponent(BaseComponent):
"""
Represents an axis
"""
implements(IAxis)
adapts(Interface)
def __init__(self, parent, orientation=None, start=None, end=None):
super(AxisComponent, self).__init__(parent)
self.orientation = orientation
self.start = start
self.end = end
def get_tick_labels(self):
return TickLabel(self)().render()
def render(self):
return '%s: ' % self.__class__.__name__ + self.orientation + ':' + ' '.join(self.get_tick_labels())
gsm.registerAdapter(AxisComponent)
class Axis(BaseFactory):
target_interface = IAxis
class ViewBoxComponent(BaseComponent):
"""
Drawing area of a plot. THe drawing ares may have an unlimited number of axis
"""
implements(IViewBox)
adapts(Interface)
def __init__(self, parent):
super(ViewBoxComponent, self).__init__(parent)
def render(self):
result = []
for item in self.items:
result.append(item.render())
return '\n'.join(result)
gsm.registerAdapter(ViewBoxComponent)
class ViewBox(BaseFactory):
target_interface = IViewBox
class ImageComponent(BaseComponent):
"""
A image representing f(x,y) values
"""
implements(IImage)
adapts(Interface)
def __init__(self, parent):
super(ImageComponent, self).__init__(parent)
def render(self):
return '%s:' % self.__class__.__name__ + str(self.data)
def setup(self, data, **kwargs):
self.data = data
gsm.registerAdapter(ImageComponent)
class Image(BaseFactory):
target_interface = IImage
|