184 |
raise MetapostException(slashify(config.mp_directory) \ |
raise MetapostException(slashify(config.mp_directory) \ |
185 |
+diagram+config.midfix+'.mp'+' not found') |
+diagram+config.midfix+'.mp'+' not found') |
186 |
|
|
187 |
s = open(slashify(config.mp_directory)+diagram+config.midfix+'.uml').read() |
s_file = open(slashify(config.mp_directory)+diagram+config.midfix+'.uml') |
188 |
|
s = s_file.read() |
189 |
|
s_file.close() |
190 |
l = navidoc.util.parser.parse_indented(s) |
l = navidoc.util.parser.parse_indented(s) |
191 |
m = navidoc.parser.ElementList(l) |
m = navidoc.parser.ElementList(l) |
192 |
|
|
254 |
slashify(config.mp_directory)+diagram+midfix+'.eps') |
slashify(config.mp_directory)+diagram+midfix+'.eps') |
255 |
return |
return |
256 |
|
|
257 |
log = open(slashify(config.mp_directory)+diagram+config.midfix+'.mp.log').read() |
log_file = open(slashify(config.mp_directory)+diagram+config.midfix+'.mp.log') |
258 |
|
log = log_file.read() |
259 |
|
log_file.close() |
260 |
|
|
261 |
if log.find("\n"+'!') != -1: |
if log.find("\n"+'!') != -1: |
262 |
dbg_navidoc('[mp] Converting diagram %s failed.' % (diagram)) |
dbg_navidoc('[mp] Converting diagram %s failed.' % (diagram)) |
263 |
dbg_fail('An error was found from MetPost log when convertin diagram %s. The log is shown below.' % (diagram)) |
dbg_fail('An error was found from MetPost log when convertin diagram %s. The log is shown below.' % (diagram)) |
341 |
)] |
)] |
342 |
dbg("Mapped corners: "+str(self.corners)) |
dbg("Mapped corners: "+str(self.corners)) |
343 |
|
|
344 |
def imgmapanchor(self, scale=1.0, diagram=''): |
def imgmapanchor(self, scale=1.0, diagram='', context=''): |
345 |
#If we have a link with empty target and empty title, let's link |
# Adding javascript thingy, when target not defined |
346 |
#it to the diagram itself, if diagram name provided. |
if context.endswith('_implicit'): |
347 |
if self.title == '' and diagram: self.title = diagram+config.midfix+'.png' |
id_postfix = '' |
348 |
if self.target == '' and diagram: |
context = context[:len(context)-len('_implicit')] |
|
self.target = slashify(relative_path(config.working_directory, config.mp_directory))+diagram+config.midfix+'.png' |
|
|
if self.target.endswith('.png'): |
|
|
target = '_plain' |
|
|
diagram = '' |
|
349 |
else: |
else: |
350 |
target = '_top' |
id_postfix = '_implicit' |
351 |
diagram = '#'+diagram |
context = context + '_implicit' |
352 |
|
|
353 |
|
if self.target == '' and diagram and context: |
354 |
|
self.target = "javascript:setImg('"+diagram+"_img', '"+slashify(relative_path(config.working_directory, config.mp_directory))+diagram+context+config.midfix+".png', '#"+diagram+id_postfix+"_map')" |
355 |
|
|
356 |
|
if not self.target.startswith('javascript'): diagram = '#'+diagram |
357 |
|
else: diagram = '' |
358 |
|
|
359 |
return """<area href="%s%s" shape="rect" coords="%s" target="%s" title="%s" alt="%s" />""" \ |
return """<area href="%s%s" shape="rect" coords="%s" target="%s" title="%s" alt="%s" />""" \ |
360 |
% (self.target, diagram, |
% (self.target, diagram, |
361 |
",".join(["%s"%(int(c*scale)) for c in self.corners]), |
",".join(["%s"%(int(c*scale)) for c in self.corners]), '_top', |
362 |
target, |
self.title, self.title) |
|
self.title, |
|
|
self.title) |
|
363 |
|
|
364 |
class MetapostException(Exception): |
class MetapostException(Exception): |
365 |
def __init__(self, value): |
def __init__(self, value): |