Changeset - 528140423e49
[Not reviewed]
default
0 4 0
volker - 10 years ago 2015-06-23 22:49:33
volker.jaenisch@inqbus.de
ALso change of the tickmark component
4 files changed with 24 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/graph/interfaces.py
Show inline comments
 
@@ -25,7 +25,7 @@ class IAxis(IBaseComponent):
 
        createed with knowledge of its parent component
 
        """
 

	
 
class ITickLabelAdapter(IBaseComponent):
 
class ITickLabel(IBaseComponent):
 
    """
 
    An adapter that produces tick labels for an axis
 
    """
src/graph_ZCA/app.py
Show inline comments
 

	
 
from zope.interface import implements
 

	
 
from graph_ZCA.components import BaseComponent, Image, Axis, AxisComponent, ViewBox
 
from graph_ZCA.components import BaseComponent, Image, Axis, AxisComponent, ViewBox, TickLabelComponent
 
from graph_ZCA.interfaces import IAxis, IViewBox, IBaseComponent
 

	
 
from zope.component import getGlobalSiteManager, adapts
 
@@ -49,6 +49,17 @@ class NewAxisComponent(AxisComponent):
 

	
 
gsm.registerAdapter(NewAxisComponent)
 

	
 

	
 
class NewTickLabelComponent(TickLabelComponent):
 
    adapts(IAxis)
 

	
 
    def render(self):
 
        return " ".join([ "q%i" % i for i in range(self.axis.start, self.axis.end)])
 

	
 
gsm.registerAdapter(NewTickLabelComponent)
 

	
 

	
 

	
 
image_data = [1,2,3,4]
 

	
 
plot =  PlotImage( None)
src/graph_ZCA/components.py
Show inline comments
 
@@ -4,14 +4,14 @@ from zope.component import adapts, getGl
 
gsm = getGlobalSiteManager()
 

	
 
from graph_ZCA.base import BaseAdapter, BaseComponent, BaseFactory
 
from graph_ZCA.interfaces import ITickLabelAdapter, IAxis, IViewBox, IImage
 
from graph_ZCA.interfaces import ITickLabel, IAxis, IViewBox, IImage
 

	
 

	
 
class TickLabelAdapter(BaseAdapter):
 
class TickLabelComponent(BaseComponent):
 
    """
 
    Generates Ticklabels for an axis
 
    """
 
    implementsOnly(ITickLabelAdapter)
 
    implementsOnly(ITickLabel)
 
    adapts(IAxis)
 

	
 
    def __init__(self, axis):
 
@@ -23,7 +23,12 @@ class TickLabelAdapter(BaseAdapter):
 
    def render(self):
 
        return map(str, range(self.axis.start, self.axis.end))
 

	
 
gsm.registerAdapter(TickLabelAdapter)
 
gsm.registerAdapter(TickLabelComponent)
 

	
 

	
 
class TickLabel(BaseFactory):
 

	
 
    target_interface = ITickLabel
 

	
 

	
 
class AxisComponent(BaseComponent):
 
@@ -41,7 +46,7 @@ class AxisComponent(BaseComponent):
 
        self.end = end
 

	
 
    def get_tick_labels(self):
 
        return ITickLabelAdapter(self).render()
 
        return TickLabel(self)().render()
 

	
 
    def render(self):
 
        return '%s: ' % self.__class__.__name__ + self.orientation + ':' + ' '.join(self.get_tick_labels())
src/graph_ZCA/interfaces.py
Show inline comments
 
@@ -25,7 +25,7 @@ class IAxis(IBaseComponent):
 
        createed with knowledge of its parent component
 
        """
 

	
 
class ITickLabelAdapter(IBaseComponent):
 
class ITickLabel(IBaseComponent):
 
    """
 
    An adapter that produces tick labels for an axis
 
    """
0 comments (0 inline, 0 general)