OglLinkFactory.py :  » UML » Python-UML-Tool » pyut-1.4.0 » src » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » UML » Python UML Tool 
Python UML Tool » pyut 1.4.0 » src » OglLinkFactory.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

__version__ = "$Revision: 1.5 $"
__author__  = "EI5, eivd, Group Burgbacher - Waelti"
__date__    = "2001-12-12"

from __future__ import nested_scopes
from OglAggregation import *
from OglComposition import *
from OglInheritance import *
from OglInterface import *
from OglNoteLink import *
from OglSDMessage import *

from singleton import *
from PyutConsts import *

def getOglLinkFactory():
    """
    Function to get the unique OglLinkFactory instance (singleton).

    @since 1.0
    @author P. Waelti <pwaelti@eivd.ch>
    """
    return OglLinkFactory()



def getLinkType(link):
    """
    Added by P. Dabrowski <przemek.dabrowski@destroy-display.com> (20.11.2005)
    @return type (integer) of the link as defined in PyutConsts.py
    """
    if isinstance(link, OglAggregation):
        return OGL_AGGREGATION
    elif isinstance(link, OglComposition):
        return OGL_COMPOSITION
    elif isinstance(link, OglInheritance):
        return OGL_INHERITANCE
    elif isinstance(link, OglAssociation):
        return OGL_ASSOCIATION
    elif isinstance(link, OglInterface):
        return OGL_INTERFACE
    elif isinstance(link, OglNoteLink):
        return OGL_NOTELINK


class OglLinkFactory(Singleton):
    """
    This class is a factory to produce `OglLink` objects.
    It works under the Factory Design Pattern model. Ask a kind of link
    to this object and it will return you what you was asking for.

    :version: $Revision: 1.5 $
    :author: Philippe Waelti
    :contact: pwaelti@eivd.ch
    """
    def getOglLink(self, srcShape, pyutLink, destShape, linkType, 
                   srcPos=None, dstPos=None):
        """
        Used to get a OglLink of the given linkType.

        @param OglObject srcShape : Source shape
        @param PyutLink pyutLink : Conceptual links associated with the
                                   graphical links.
        @param OglObject destShape : Destination shape
        @param int linkType : The linkType of the link (OGL_INHERITANCE, ...)
        @param tuple srcPos, dstPos : position on both src and dst objects

        @return OglLink : The link you asked

        @author Philippe Waelti
        @modified C.Dutoit 25112002 : added OGL_SD_MESSAGE
        """
        if linkType == OGL_AGGREGATION:
            return OglAggregation(srcShape, pyutLink, destShape)

        elif linkType == OGL_COMPOSITION:
            return OglComposition(srcShape, pyutLink, destShape)

        elif linkType == OGL_INHERITANCE:
            return OglInheritance(srcShape, pyutLink, destShape)

        elif linkType == OGL_ASSOCIATION:
            return OglAssociation(srcShape, pyutLink, destShape)

        elif linkType == OGL_INTERFACE:
            return OglInterface(srcShape, pyutLink, destShape)

        elif linkType == OGL_NOTELINK:
            return OglNoteLink(srcShape, pyutLink, destShape)
        else:
            print "Unknown linkType of OglLink into factory :", repr(linkType)
            return None


www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.