| 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 |
|
|---|
| 26 |
import logging |
|---|
| 27 |
import Abstract |
|---|
| 28 |
import Null |
|---|
| 29 |
|
|---|
| 30 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 31 |
#~ Definitions |
|---|
| 32 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 33 |
|
|---|
| 34 |
class LoggingRenderer(Abstract.AbstractRenderer): |
|---|
| 35 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 36 |
#~ Constants / Variables / Etc. |
|---|
| 37 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 38 |
|
|---|
| 39 |
log = logging.getLogger('SVG.Renders.Logging') |
|---|
| 40 |
|
|---|
| 41 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 42 |
#~ Public Methods |
|---|
| 43 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 44 |
|
|---|
| 45 |
def Display(self, ri): |
|---|
| 46 |
self.resolver = [] |
|---|
| 47 |
ri.DisplayOn(self) |
|---|
| 48 |
del self.resolver |
|---|
| 49 |
|
|---|
| 50 |
#~ Meta Information ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 51 |
|
|---|
| 52 |
def DisplayTitle(self, ri_title): |
|---|
| 53 |
self.log.info('DisplayTitle: %r', ri_title) |
|---|
| 54 |
|
|---|
| 55 |
def DisplayDescription(self, ri_desc): |
|---|
| 56 |
self.log.info('DisplayDescription: %r', ri_desc) |
|---|
| 57 |
|
|---|
| 58 |
#~ Groups ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 59 |
|
|---|
| 60 |
def DisplaySVG(self, ri_svg): |
|---|
| 61 |
self.log.info('DisplaySVG: %r', ri_svg) |
|---|
| 62 |
self.resolver.append(ri_svg.idmapping) |
|---|
| 63 |
try: |
|---|
| 64 |
ri_svg.DisplayChildrenOn(self) |
|---|
| 65 |
finally: |
|---|
| 66 |
self.resolver.pop() |
|---|
| 67 |
|
|---|
| 68 |
def DisplayGroup(self, ri_group): |
|---|
| 69 |
self.log.info('DisplayGroup: %r', ri_group) |
|---|
| 70 |
ri_group.DisplayChildrenOn(self) |
|---|
| 71 |
|
|---|
| 72 |
def DisplaySymbol(self, ri_symbol): |
|---|
| 73 |
self.log.debug('DisplaySymbol: %r', ri_symbol) |
|---|
| 74 |
ri_symbol.DisplayChildrenOn(self) |
|---|
| 75 |
|
|---|
| 76 |
def DisplayUse(self, ri_use): |
|---|
| 77 |
ri_used = self.ResolveReference(ri_use.usereference) |
|---|
| 78 |
if ri_used is not None: |
|---|
| 79 |
ri_used.DisplayOn(self) |
|---|
| 80 |
|
|---|
| 81 |
#~ Shapes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 82 |
|
|---|
| 83 |
def DisplayLine(self, ri_line): |
|---|
| 84 |
self.log.debug('DisplayLine: %r', ri_line) |
|---|
| 85 |
|
|---|
| 86 |
def DisplayRect(self, ri_rect): |
|---|
| 87 |
self.log.debug('DisplayRect: %r', ri_rect) |
|---|
| 88 |
|
|---|
| 89 |
def DisplayCircle(self, ri_circle): |
|---|
| 90 |
self.log.debug('DisplayCircle: %r', ri_circle) |
|---|
| 91 |
|
|---|
| 92 |
def DisplayEllipse(self, ri_ellipse): |
|---|
| 93 |
self.log.debug('DisplayEllipse: %r', ri_ellipse) |
|---|
| 94 |
|
|---|
| 95 |
def DisplayPolygon(self, ri_polygon): |
|---|
| 96 |
self.log.debug('DisplayPolygon: %r', ri_polygon) |
|---|
| 97 |
|
|---|
| 98 |
def DisplayPolyline(self, ri_polyline): |
|---|
| 99 |
self.log.debug('DisplayPolyline: %r', ri_polyline) |
|---|
| 100 |
|
|---|
| 101 |
def DisplayPath(self, ri_path): |
|---|
| 102 |
self.log.debug('DisplayPath: %r', ri_path) |
|---|
| 103 |
|
|---|
| 104 |
def DisplayText(self, ri_text): |
|---|
| 105 |
self.log.debug('DisplayText: %r', ri_text) |
|---|
| 106 |
|
|---|
| 107 |
#~ Order management ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 108 |
|
|---|
| 109 |
def ResolveReference(self, reference): |
|---|
| 110 |
base, tag = reference |
|---|
| 111 |
result = self.resolver[-1].get(tag, None) |
|---|
| 112 |
self.log.info('ResolveReference: %r = %r', reference, result) |
|---|
| 113 |
return result |
|---|
| 114 |
|
|---|