/[navidoc]/navidoc/navidoc/mp/__init__.py
ViewVC logotype

Diff of /navidoc/navidoc/mp/__init__.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.40 by humppake, Tue Jun 17 09:07:30 2003 UTC revision 1.41 by humppake, Tue Jun 17 12:04:04 2003 UTC
# Line 184  def create_uml(diagram, context='', scal Line 184  def create_uml(diagram, context='', scal
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    
# Line 252  def mp2png(diagram, scale=1.0): Line 254  def mp2png(diagram, scale=1.0):
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))
# Line 336  class MPLink: Line 341  class MPLink:
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):

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.41

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26