Changeset 615

Show
Ignore:
Timestamp:
07/12/03 21:21:18 (5 years ago)
Author:
sholloway
Message:

phase 2 of basic svg implementation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/Renderers/Abstract.py

    r613 r615  
    3737        raise NotImplementedError 
    3838 
     39    def DisplaySymbol(self, ri_symbol, rendercontext): 
     40        raise NotImplementedError 
     41 
     42    def DisplayPattern(self, ri_pattern, rendercontext): 
     43        raise NotImplementedError 
     44 
    3945    def DisplayLine(self, ri_line, rendercontext): 
    4046        raise NotImplementedError 
     
    5561        raise NotImplementedError 
    5662 
     63    def DisplayPath(self, ri_path, rendercontext): 
     64        raise NotImplementedError 
     65 
     66    def DisplayText(self, ri_text, rendercontext): 
     67        raise NotImplementedError 
     68 
     69    def DisplayTitle(self, ri_title, rendercontext): 
     70        raise NotImplementedError 
     71 
     72    def DisplayDescription(self, ri_desc, rendercontext): 
     73        raise NotImplementedError 
     74 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/Renderers/Logging.py

    r613 r615  
    4848        self.log.info('DisplayGroup: %r', ri_group) 
    4949 
     50    def DisplaySymbol(self, ri_symbol, rendercontext): 
     51        self.log.info('DisplaySymbol: %r', ri_symbol) 
     52 
     53    def DisplayPattern(self, ri_pattern, rendercontext): 
     54        self.log.info('DisplayPattern: %r', ri_pattern) 
     55 
    5056    def DisplayLine(self, ri_line, rendercontext): 
    5157        self.log.info('DisplayLine: %r', ri_line) 
     
    6672        self.log.info('DisplayPolyline: %r', ri_polyline) 
    6773 
     74    def DisplayPath(self, ri_path, rendercontext): 
     75        self.log.info('DisplayPath: %r', ri_path) 
     76 
     77    def DisplayText(self, ri_text, rendercontext): 
     78        self.log.info('DisplayText: %r', ri_text) 
     79 
     80    def DisplayTitle(self, ri_title, rendercontext): 
     81        self.log.info('DisplayTitle: %r', ri_title) 
     82 
     83    def DisplayDescription(self, ri_desc, rendercontext): 
     84        self.log.info('DisplayDescription: %r', ri_desc) 
     85 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/SVGRendering.py

    r613 r615  
     1#!/usr/bin/env python 
     2##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     3##~ License  
     4##~  
     5##- The RuneBlade Foundation library is intended to ease some  
     6##- aspects of writing intricate Jabber, XML, and User Interface (wxPython, etc.)  
     7##- applications, while providing the flexibility to modularly change the  
     8##- architecture. Enjoy. 
     9##~  
     10##~ Copyright (C) 2002  TechGame Networks, LLC. 
     11##~  
     12##~ This library is free software; you can redistribute it and/or 
     13##~ modify it under the terms of the BSD style License as found in the  
     14##~ LICENSE file included with this distribution. 
     15##~  
     16##~ TechGame Networks, LLC can be reached at: 
     17##~ 3578 E. Hartsel Drive #211 
     18##~ Colorado Springs, Colorado, USA, 80920 
     19##~ 
     20##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     21 
     22#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     23#~ Imports  
     24#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     25 
     26import warnings 
     27from RBFoundation.XMLUtilityFunctions import ColorStringToRGB 
     28 
     29#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     30#~ Definitions  
     31#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     32 
     33class SVGRenderContext(object): 
     34    def __init__(self): 
     35        self.items = [] 
     36 
     37    def push(self, SVGRenderItem): 
     38        self.items.append(SVGRenderItem) 
     39 
     40    def pop(self, SVGRenderItem=None): 
     41        result = self.items.pop() 
     42        if SVGRenderItem is not None: 
     43            assert result is SVGRenderItem 
     44 
     45#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     46#~ SVG Render Items 
     47#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     48 
    149class SVGRenderItemBase(object): 
    250    def __repr__(self): 
     
    1159#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    1260 
    13 class SVGRenderGroupItemBase(SVGRenderItemBase): 
     61class SVGTransformableRenderItem(SVGRenderItemBase): 
     62    #~ helpers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     63 
     64    def _asCoord(self, coord): 
     65        warnings.warn("TODO: interpret coords") 
     66        return float(coord) 
     67 
     68    def _asCoordTuple(self, coords): 
     69        return tuple([self._asCoord(each) for each in coords]) 
     70 
     71    def GetX(self): 
     72        return self._x 
     73    def SetX(self, value): 
     74        self._x = self._asCoord(value) 
     75    x = property(GetX, SetX) 
     76 
     77    def GetY(self): 
     78        return self._y 
     79    def SetY(self, value): 
     80        self._y = self._asCoord(value) 
     81    y = property(GetY, SetY) 
     82 
     83#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     84 
     85class SVGStyledRenderItem(SVGTransformableRenderItem): 
     86    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     87    #~ Public Methods  
     88    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     89 
     90    def AddStyle(self, *stylesIn, **byStyleName): 
     91        styledict = self._asStyle(*stylesIn, **byStyleName) 
     92        self.GetStyle().update(styledict) 
     93 
     94    def GetStyle(self): 
     95        try:  
     96            return self._styledict 
     97        except AttributeError:  
     98            self._styledict = {} 
     99            return self._styledict 
     100    def SetStyle(self, *stylesIn, **byStyleName): 
     101        if not stylesIn or byStyleName: 
     102            try: del self._styledict 
     103            except AttributeError: pass 
     104        else: 
     105            self._styledict = self._asStyle(*stylesIn, **byStyleName) 
     106    style = property(GetStyle, SetStyle) 
     107 
     108    #~ helpers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     109 
     110    def _asUnimplemented(self, value): 
     111        warnings.warn("TODO: implement") 
     112        return value 
     113 
     114    def _asString(self, value): 
     115        return str(value) 
     116 
     117    def _asColor(self, color): 
     118        """ 
     119        Valid color strings: 
     120            color="none" 
     121            color="black" # constant color lookup 
     122            color="#ff0088" 
     123            color="#f08" 
     124            color="rgb(255, 0, 136)" 
     125            color="rgb(1.0, 0.0, 0.53125)" 
     126        """ 
     127        if isinstance(color, (type(None), int, long, tuple)): 
     128            return color 
     129        elif color == 'currentColor': 
     130            warnings.warn('implement \'currentColor\' color attribute value') 
     131            return None # TODO 
     132        elif not color: 
     133            return None 
     134        else: 
     135            return ColorStringToRGB(color) 
     136 
     137    def _asOpacity(self, opacity): 
     138        result = float(opacity) 
     139        if not (0. <= result <= 1.): 
     140            raise ValueError, "Opacity value must be in the range of [0.0, 1.0], but was %r (%r)" % (opacity, result) 
     141        return result 
     142 
     143    def _asDashArray(self, dasharray): 
     144        if not isinstance(dasharray, (list, tuple)): 
     145            dasharray = dasharray.split(',') or dasharray.split() 
     146            dasharray = [x.strip() for x in dasharray] 
     147        else: 
     148            dasharray = list(dasharray) 
     149        if len(dasharray) & 1: 
     150            # dasharray is odd -- repeat to make it even, according to SVG book 
     151            dasharray *= 2 
     152        return dasharray 
     153 
     154    def _asStyle(self, *stylesIn, **byStyleName): 
     155        styledict = {} 
     156        for styleIn in stylesIn: 
     157            if isinstance(styleIn, dict): 
     158                styledict.update(styleIn) 
     159            else: 
     160                for entry in filter(None, styleIn.split(';')): 
     161                    name, value = entry.split(':', 1)  
     162                    styledict[name.strip()] = value.strip() 
     163        styledict.update(byStyleName) 
     164 
     165        for name, value in styledict.iteritems(): 
     166            try: 
     167                mappingFn = self.explicit_styles_mapping[name] 
     168            except KeyError: pass 
     169            else: 
     170                styledict[name.strip()] = mappingFn(self, value.strip()) 
     171 
     172        warnings.warn("TODO: interpret styles") 
     173        return styledict 
     174 
     175    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     176    #~ Conversion Mappings 
     177    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     178 
     179    explicit_styles_mapping = { 
     180        "stroke": _asColor, 
     181        "stroke-width": SVGTransformableRenderItem._asCoord, 
     182        "stroke-opacity": _asOpacity, 
     183        "stroke-dasharray": _asDashArray, 
     184        "stroke-linecap": _asString, 
     185        "stroke-linejoin": _asString, 
     186        "stroke-meterlimit": _asString, 
     187 
     188        "fill": _asColor, 
     189        "fill-opacity": _asOpacity, 
     190        "fill-rule": _asString, 
     191        } 
     192 
     193#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     194 
     195class SVGShapeRenderItem(SVGStyledRenderItem): 
     196    pass 
     197 
     198#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     199#~ Group render items 
     200#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     201 
     202class SVGRenderGroupItemBase(SVGTransformableRenderItem): 
    14203    def __init__(self): 
    15204        self.children = [] 
     
    28217#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    29218 
    30 class SVGRenderContext(object): 
    31     def __init__(self): 
    32         self.items = [] 
    33  
    34     def push(self, SVGRenderItem): 
    35         self.items.append(SVGRenderItem) 
    36  
    37     def pop(self, SVGRenderItem=None): 
    38         result = self.items.pop() 
    39         if SVGRenderItem is not None: 
    40             assert result is SVGRenderItem 
    41  
    42 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    43  
     219class SVGContainerRenderItem(SVGRenderGroupItemBase): 
     220    def GetWidth(self): 
     221        return self._width 
     222    def SetWidth(self, value): 
     223        width = self._asCoord(value) 
     224        if width < 0: 
     225            raise ValueError, '"width" attribute can not be negative"' 
     226        self._width = width 
     227    width = property(GetWidth, SetWidth) 
     228 
     229    def GetHeight(self): 
     230        return self._height 
     231    def SetHeight(self, value): 
     232        height = self._asCoord(value) 
     233        if height < 0: 
     234            raise ValueError, '"height" attribute can not be negative"' 
     235        self._height = height 
     236    height = property(GetHeight, SetHeight) 
     237 
     238    def GetViewBox(self): 
     239        try: 
     240            return self.viewbox 
     241        except AttributeError: 
     242            self._viewbox = [self.x, self.y, self.width, self.height] 
     243            return self._viewbox 
     244    def SetViewBox(self, value): 
     245        self._viewbox = self._asViewBox(value) 
     246    viewbox = property(GetViewBox, SetViewBox) 
     247 
     248    def GetPreserveAspectRatio(self): 
     249        try: 
     250            return self._alignment 
     251        except AttributeError: 
     252            self._alignment = ['xMid', 'YMid', 'meet'] # svg default 
     253            return self._alignment 
     254    def SetPreserveAspectRatio(self, value): 
     255        self._alignment = self._asAlignmentList(value) 
     256    preserveAspectRatio = alignment = property(GetPreserveAspectRatio, SetPreserveAspectRatio) 
     257 
     258    def GetXAlignment(self): 
     259        try: 
     260            return self.alignment[0] 
     261        except AttributeError: 
     262            return 'xMid' # svg default 
     263    def SetXAlignment(self, value): 
     264        self.alignment[0] = value 
     265    xAlignment = property(GetXAlignment, SetXAlignment) 
     266 
     267    def GetYAlignment(self): 
     268        try: 
     269            return self.alignment[1] 
     270        except AttributeError: 
     271            return 'YMid' # svg default 
     272    def SetYAlignment(self, value): 
     273        self.alignment[0] = value 
     274 
     275    yAlignment = property(GetYAlignment, SetYAlignment) 
     276 
     277    def GetAlignmentStyle(self): 
     278        try: 
     279            return self.alignment[2] 
     280        except AttributeError: 
     281            return 'meet' # svg default 
     282    def SetAlignmentStyle(self, value): 
     283        self.alignment[2] = value 
     284 
     285    styleAlignment = property(GetAlignmentStyle, SetAlignmentStyle) 
     286 
     287    #~ helper methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     288 
     289    def _asAlignmentList(self, alignment): 
     290        alignment = alignment.strip() 
     291        if alignment.lower() == 'none': 
     292            return [None, None, None] 
     293        else: 
     294            alignment = alignment.replace(',', ' ') 
     295            if ' ' in alignment: 
     296                alignment, specifier = alignment.split() 
     297            else: specifier = 'meet' 
     298            return [alignment[0:4], alignment[4:8], specifier.strip().lower()] 
     299 
     300    def _asViewBox(self, viewBox): 
     301        if not isinstance(viewBox, (list, tuple)): 
     302            viewBox = map(self._asCoord, viewBox.replace(',', ' ').split()) 
     303        if len(viewBox) != 4: 
     304            raise ValueError, "viewBox must have four elements, but value has %s (%r)" % (len(viewBox), viewBox) 
     305        return list(viewBox) 
     306 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/SVGShapeSkinObject.py

    r613 r615  
    2424#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    2525 
    26 import warnings 
    2726import logging 
    2827 
    2928from SVGSkinObject import SVGSkinObject 
    30 from SVGRendering import SVGRenderItemBase 
    31  
    32 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    33 #~ Constants / Variables / Etc.  
    34 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    35  
    36 colorlookup = { 
    37     "black": 0x000000, "silver": 0xc0c0c0, "gray": 0x808080, "white": 0xffffff, 
    38     "maroon": 0x800000, "red": 0xff0000, "purple": 0x800080, "fuchsia": 0xff00ff, 
    39     "green": 0x008000, "lime": 0x00ff00, "olive": 0x808000, "yellow": 0xffff00, 
    40     "navy": 0x000080, "blue": 0x0000ff, "teal": 0x008080, "aqua": 0x00ffff, 
    41     } 
     29from SVGRendering import SVGShapeRenderItem 
    4230 
    4331#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    4432#~ Definitions  
    45 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    46  
    47 class SVGShapeRenderItem(SVGRenderItemBase): 
    48     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    49     #~ Public Methods  
    50     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    51  
    52     def AddStyle(self, *stylesIn, **byStyleName): 
    53         styledict = self._asStyle(*stylesIn, **byStyleName) 
    54         self.GetStyle().update(styledict) 
    55  
    56     def GetStyle(self): 
    57         try:  
    58             return self._styledict 
    59         except AttributeError:  
    60             self._styledict = {} 
    61             return self._styledict 
    62     def SetStyle(self, *stylesIn, **byStyleName): 
    63         if not stylesIn or byStyleName: 
    64             try: del self._styledict 
    65             except AttributeError: pass 
    66         else: 
    67             self._styledict = self._asStyle(*stylesIn, **byStyleName) 
    68     style = property(GetStyle, SetStyle) 
    69  
    70     #~ Reading helpers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    71  
    72     def _asUnimplemented(self, value): 
    73         warnings.warn("TODO: implement") 
    74         return value 
    75  
    76     def _asString(self, value): 
    77         return str(value) 
    78  
    79     def _asColor(self, color): 
    80         """ 
    81         Valid color strings: 
    82             color="none" 
    83             color="black" # constant color lookup 
    84             color="#ff0088" 
    85             color="#f08" 
    86             color="rgb(255, 0, 136)" 
    87             color="rgb(1.0, 0.0, 0.53125)" 
    88         """ 
    89         warnings.warn("TODO: interpret color") 
    90         return color 
    91  
    92     def _asOpacity(self, opacity): 
    93         result = float(opacity) 
    94         if not (0. <= result <= 1.): 
    95             raise ValueError, "Opacity value must be in the range of [0.0, 1.0], but was %r (%r)" % (opacity, result) 
    96         return result 
    97  
    98     def _asDashArray(self, dasharray): 
    99         if not isinstance(dasharray, (list, tuple)): 
    100             dasharray = dasharray.split(',') or dasharray.split() 
    101             dasharray = [x.strip() for x in dasharray] 
    102         else: 
    103             dasharray = list(dasharray) 
    104         if len(dasharray) & 1: 
    105             # dasharray is odd -- repeat to make it even, according to SVG book 
    106             dasharray *= 2 
    107         return dasharray 
    108  
    109     def _asCoord(self, coord): 
    110         warnings.warn("TODO: interpret coords") 
    111         return float(coord) 
    112  
    113     def _asCoordTuple(self, coords): 
    114         return tuple([self._asCoord(each) for each in coords]) 
    115  
    116     def _asStyle(self, *stylesIn, **byStyleName): 
    117         styledict = {} 
    118         for styleIn in stylesIn: 
    119             if isinstance(styleIn, dict): 
    120                 styledict.update(styleIn) 
    121             else: 
    122                 for entry in filter(None, styleIn.split(';')): 
    123                     name, value = entry.split(':', 1)  
    124                     styledict[name.strip()] = value.strip() 
    125         styledict.update(byStyleName) 
    126  
    127         for name, value in styledict.iteritems(): 
    128             try: 
    129                 mappingFn = self.explicit_styles_mapping[name] 
    130             except KeyError: pass 
    131             else: 
    132                 styledict[name.strip()] = mappingFn(self, value.strip()) 
    133  
    134         warnings.warn("TODO: interpret styles") 
    135         return styledict 
    136  
    137     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    138     #~ Conversion Mappings 
    139     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    140  
    141     explicit_styles_mapping = { 
    142         "stroke": _asColor, 
    143         "stroke-width": _asCoord, 
    144         "stroke-opacity": _asOpacity, 
    145         "stroke-dasharray": _asDashArray, 
    146         "stroke-linecap": _asString, 
    147         "stroke-linejoin": _asString, 
    148         "stroke-meterlimit": _asString, 
    149  
    150         "fill": _asColor, 
    151         "fill-opacity": _asOpacity, 
    152         "fill-rule": _asString, 
    153         } 
    154  
    15533#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    15634 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/SVGSkinObject.py

    r613 r615  
    4848        SkinObject.__init__(self, builder, parent, node, settings, namespacemap) 
    4949 
    50     def SkinInitialze(self): 
    51         SkinObject.SkinInitialze(self) 
    52  
    5350    def SkinFinalize(self): 
    5451        SkinObject.SkinFinalize(self) 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/UnknownElement.py

    r613 r615  
    3535        self.log.warning("Ignoring unknown or unimplemented element %r in xmlns:%r", self.node[1], self.node[0]) 
    3636 
    37     #def SkinFinalize(self): 
    38     #    SVGSkinObject.SkinFinalize(self) 
    39  
    4037    def DisplayOn(self, renderer, context=[]): 
    4138        pass # ignore the display of this item 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/circle.py

    r613 r615  
    5959class circle(SVGShapeSkinObject): 
    6060    def SkinInitialize(self): 
     61        self.object = CircleRenderItem() 
    6162        SVGShapeSkinObject.SkinInitialize(self) 
    62         self.object = CircleRenderItem() 
    6363        self.object.cx = self.settings.get('cx', 0.) 
    6464        self.object.cy = self.settings.get('cy', 0.) 
     
    6767        self.SetStyleSettings() 
    6868 
    69     #def SkinFinalize(self): 
    70     #    SVGShapeSkinObject.SkinFinalize(self) 
    71  
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/defs.py

    r613 r615  
    3131 
    3232class defs(SVGSkinObject): 
    33     def DisplayChildrenOn(self, renderer, context): 
    34         pass # Children of defs are not displayed -- but rather referenced from other places 
     33    def DisplayOn(self, renderer, context): 
     34        pass # defs are not displayed 
    3535 
    36     def DisplayOn(self, renderer, context): 
    37         pass # defs themselves not displayed 
    38  
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/ellipse.py

    r613 r615  
    8383class ellipse(SVGShapeSkinObject): 
    8484    def SkinInitialize(self): 
     85        self.object = EllipseRenderItem() 
    8586        SVGShapeSkinObject.SkinInitialize(self) 
    86         self.object = EllipseRenderItem() 
    8787        self.object.cx = self.settings.get('cx', 0.) 
    8888        self.object.cy = self.settings.get('cy', 0.) 
     
    9292        self.SetStyleSettings() 
    9393 
    94     #def SkinFinalize(self): 
    95     #    SVGShapeSkinObject.SkinFinalize(self) 
    96  
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/g.py

    r613 r615  
    2525 
    2626from SVGSkinObject import SVGSkinObject 
    27 from SVGRendering import SVGRenderGroupItemBase 
     27from SVGRendering import SVGContainerRenderItem 
    2828 
    2929#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    3131#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    3232 
    33 class GroupRenderItem(SVGRenderGroupItemBase): 
     33class GroupRenderItem(SVGContainerRenderItem): 
    3434    def DisplayOn(self, renderer, rendercontext): 
    3535        renderer.DisplayGroup(self, rendercontext) 
    36         SVGRenderGroupItemBase.DisplayOn(self, renderer, rendercontext) 
     36        SVGContainerRenderItem.DisplayOn(self, renderer, rendercontext) 
    3737 
    3838#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    4040class g(SVGSkinObject): 
    4141    def SkinInitialize(self): 
     42        self.object = GroupRenderItem() 
    4243        SVGSkinObject.SkinInitialize(self) 
    43         self.object = GroupRenderItem() 
    4444 
    45     #def SkinFinalize(self): 
    46     #    SVGSkinObject.SkinFinalize(self) 
    47  
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/line.py

    r613 r615  
    6262class line(SVGShapeSkinObject): 
    6363    def SkinInitialize(self): 
     64        self.object = LineRenderItem() 
    6465        SVGShapeSkinObject.SkinInitialize(self) 
    65         self.object = LineRenderItem() 
    6666        self.object.x1 = self.settings['x1'] 
    6767        self.object.y1 = self.settings['y1'] 
     
    7171        self.SetStyleSettings() 
    7272 
    73     #def SkinFinalize(self): 
    74     #    SVGShapeSkinObject.SkinFinalize(self) 
    75  
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/path.py

    r613 r615  
    3232 
    3333class PathRenderItem(SVGShapeRenderItem): 
    34     def DisplayOn(self, renderer, rendercontext): 
    35         renderer.DisplayPath(self, rendercontext) 
    36  
    37     def GetPath(self): 
    38         return self._path 
    39     def SetPath(self, value): 
    40         self._path = self._asPath(value) 
    41     p = property(GetPath, SetPath) 
    42  
    43     def _asPath(self, path): 
    44         warnings.warn("TODO: implement path interpretation") 
    45         return path 
    46  
    47 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    48  
    49 class path(SVGShapeSkinObject): 
    5034    """ 
    5135    Path commands (from http://www.protocol7.com/svg-wiki/ow.asp?ThePath) 
     
    8367    """ 
    8468 
     69    def DisplayOn(self, renderer, rendercontext): 
     70        renderer.DisplayPath(self, rendercontext) 
     71 
     72    def GetPath(self): 
     73        return self._path 
     74    def SetPath(self, value): 
     75        self._path = self._asPath(value) 
     76    p = property(GetPath, SetPath) 
     77 
     78    def _asPath(self, path): 
     79        warnings.warn("TODO: implement path interpretation") 
     80        return path 
     81 
     82#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     83 
     84class path(SVGShapeSkinObject): 
    8585    def SkinInitialize(self): 
    86         SVGShapeSkinObject.PathInitialize(self
    87         self.object = LineRenderItem(
    88         self.object.p = self.settings['p'] 
     86        self.object = PathRenderItem(
     87        SVGShapeSkinObject.SkinInitialize(self
     88        self.object.p = self.settings['d'] 
    8989 
    9090        self.SetStyleSettings() 
    9191 
    92     #def SkinFinalize(self): 
    93     #    SVGShapeSkinObject.SkinFinalize(self) 
    94  
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/polygon.py

    r613 r615  
    2424#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    2525 
    26 from polyline import polyline 
     26from polyline import PolylineRenderItem 
    2727from SVGShapeSkinObject import SVGShapeSkinObject 
    2828 
     
    3939class polygon(SVGShapeSkinObject): 
    4040    def SkinInitialize(self): 
     41        self.object = PolygonRenderItem() 
    4142        SVGShapeSkinObject.SkinInitialize(self) 
    42         self.object = PolygonRenderItem() 
    4343        self.object.points = self.settings['points'] 
    4444 
    4545        self.SetStyleSettings() 
    4646 
    47     #def SkinFinalize(self): 
    48     #    SVGShapeSkinObject.SkinFinalize(self) 
    49  
    50   
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/polyline.py

    r613 r615  
    6161class polyline(SVGShapeSkinObject): 
    6262    def SkinInitialize(self): 
     63        self.object = PolylineRenderItem() 
    6364        SVGShapeSkinObject.SkinInitialize(self) 
    64         self.object = PolylineRenderItem() 
    6565        self.object.points = self.settings['points'] 
    6666 
    6767        self.SetStyleSettings() 
    68  
    69     #def SkinFinalize(self): 
    70     #    SVGShapeSkinObject.SkinFinalize(self) 
    71  
    7268  
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/rect.py

    r613 r615  
    9898class rect(SVGShapeSkinObject): 
    9999    def SkinInitialize(self): 
     100        self.object = RectRenderItem() 
    100101        SVGShapeSkinObject.SkinInitialize(self) 
    101         self.object = RectRenderItem() 
    102102        self.object.x = self.settings.get('x', 0.) 
    103103        self.object.y = self.settings.get('y', 0.) 
     
    115115        self.SetStyleSettings() 
    116116 
    117     #def SkinFinalize(self): 
    118     #    SVGShapeSkinObject.SkinFinalize(self) 
    119  
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/svg.py

    r613 r615  
    2626import warnings 
    2727from SVGSkinObject import SVGSkinObject 
    28 from SVGRendering import SVGRenderGroupItemBase 
     28from SVGRendering import SVGContainerRenderItem 
    2929 
    3030#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    3232#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    3333 
    34 class SVGRenderItem(SVGRenderGroupItemBase): 
     34class SVGRenderItem(SVGContainerRenderItem): 
     35    def __init__(self): 
     36        SVGContainerRenderItem.__init__(self) 
     37        self.renderingOptions = {} 
     38 
    3539    def DisplayOn(self, renderer, rendercontext): 
    3640        renderer.DisplaySVG(self, rendercontext) 
    37         SVGRenderGroupItemBase.DisplayOn(self, renderer, rendercontext) 
     41        SVGContainerRenderItem.DisplayOn(self, renderer, rendercontext) 
    3842 
    3943#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    4145class svg(SVGSkinObject): 
    4246    def SkinInitialize(self): 
     47        self.object = SVGRenderItem() 
    4348        SVGSkinObject.SkinInitialize(self) 
     49        self.object.x = self.settings.get('x', 0.) 
     50        self.object.y = self.settings.get('y', 0.) 
     51 
     52        try: width = self.settings['width'] 
     53        except LookupError: pass 
     54        else: self.object.width = width  
     55 
     56        try: height = self.settings['height'] 
     57        except LookupError: pass 
     58        else: self.object.height = height  
     59 
     60        try: viewBox = self.settings['viewBox'] 
     61        except LookupError: pass 
     62        else: self.object.viewBox = viewBox  
     63 
     64        try: preserveAspectRatio = self.settings['preserveAspectRatio'] 
     65        except LookupError: pass 
     66        else: self.object.preserveAspectRatio = preserveAspectRatio  
     67 
     68        self.object.renderingOptions['text'] = self.settings.get('text-rendering') 
     69        self.object.renderingOptions['shape'] = self.settings.get('shape-rendering') 
     70        self.object.renderingOptions['image'] = self.settings.get('image-rendering') 
     71 
    4472        self.PushContext() 
    4573        self.context.idmapping = {} 
    4674 
    47         self.object = SVGRenderItem() 
    48         warnings.warn('TODO: implement "x" attribute') 
    49         warnings.warn('TODO: implement "y" attribute') 
    50         warnings.warn('TODO: implement "width" attribute') 
    51         warnings.warn('TODO: implement "height" attribute') 
    52         warnings.warn('TODO: implement "viewBox" attribute') 
    53         warnings.warn('TODO: implement "preserveAspectRatio" attribute') 
    54         warnings.warn('TODO: implement "text-rendering" attribute') 
    55         warnings.warn('TODO: implement "shape-rendering" attribute') 
    56         warnings.warn('TODO: implement "image-rendering" attribute') 
    57  
    58     #def SkinFinalize(self): 
    59     #    SVGSkinObject.SkinFinalize(self) 
    60  
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/symbol.py

    r613 r615  
    2424#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    2525 
    26 import warnings 
    2726from SVGSkinObject import SVGSkinObject 
    28 from SVGRendering import SVGRenderGroupItemBase 
     27from SVGRendering import SVGContainerRenderItem 
    2928 
    3029#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    3231#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    3332 
    34 class SymbolRenderItem(SVGRenderGroupItemBase): 
     33class SymbolRenderItem(SVGContainerRenderItem): 
    3534    def DisplayOn(self, renderer, rendercontext): 
    3635        renderer.DisplaySymbol(self, rendercontext) 
    37         SVGRenderGroupItemBase.DisplayOn(self, renderer, rendercontext) 
     36        SVGContainerRenderItem.DisplayOn(self, renderer, rendercontext) 
    3837 
    3938#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    4140class symbol(SVGSkinObject): 
    4241    def SkinInitialize(self): 
     42        self.object = SymbolRenderItem() 
    4343        SVGSkinObject.SkinInitialize(self) 
    44         self.object = SymbolRenderItem() 
    45         warnings.warn('TODO: implement "viewBox" attribute') 
    46         warnings.warn('TODO: implement "preserveAspectRatio" attribute') 
    4744 
    48     #def SkinFinalize(self): 
    49     #    SVGSkinObject.SkinFinalize(self) 
     45        try: viewBox = self.settings['viewBox'] 
     46        except LookupError: pass 
     47        else: self.object.viewBox = viewBox  
    5048 
     49        try: preserveAspectRatio = self.settings['preserveAspectRatio'] 
     50        except LookupError: pass 
     51        else: self.object.preserveAspectRatio = preserveAspectRatio  
     52 
     53    def DisplayOn(self, renderer, context): 
     54        pass # symbols are not displayed 
     55 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/use.py

    r613 r615  
    2626import warnings 
    2727from SVGSkinObject import SVGSkinObject 
    28 from SVGRendering import SVGRenderItemBase 
     28from SVGRendering import SVGTransformableRenderItem 
    2929 
    3030#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    3232#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    3333 
    34 class UseRenderItem(SVGRenderItemBase): 
     34class UseRenderItem(SVGTransformableRenderItem): 
    3535    def DisplayOn(self, renderer, rendercontext): 
    3636        rendercontext.push(self) 
     
    4747        self.object = UseRenderItem() 
    4848 
    49         warnings.warn('TODO: implement "x" attribute') 
    50         warnings.warn('TODO: implement "y" attribute') 
    51         warnings.warn('TODO: implement "width" attribute') 
    52         warnings.warn('TODO: implement "height" attribute') 
    53  
    5449    def SkinFinalize(self): 
    5550        SVGSkinObject.SkinFinalize(self)