Example #1
0
    def setUp(self):
        self.logger: Logger = TestOglInterface2.clsLogger

        self.app: App = TestOglInterface2.clsApp

        self._pyutInterface: PyutInterface = PyutInterface()
        self._destinationAnchor: SelectAnchorPoint = SelectAnchorPoint(
            250, 250, AttachmentPoint.NORTH)
Example #2
0
    def _getAttachmentPoint(self, xmlOglInterface: Element, parent: OglClass) -> SelectAnchorPoint:

        attachmentPointStr: str             = xmlOglInterface.getAttribute(PyutXmlConstants.ATTR_LOLLIPOP_ATTACHMENT_POINT)
        attachmentPoint:    AttachmentPoint = AttachmentPoint.toEnum(attachmentPointStr)
        attachPosition:     OglPosition     = self._determineAttachmentPoint(attachmentPoint=attachmentPoint, oglClass=parent)

        anchorPoint: SelectAnchorPoint = SelectAnchorPoint(x=attachPosition.x, y=attachPosition.y, attachmentPoint=attachmentPoint, parent=parent)

        return anchorPoint
Example #3
0
    def createLollipopInterface(self, implementor: OglClass,
                                attachmentAnchor: SelectAnchorPoint):

        from org.pyut.ui.UmlClassDiagramsFrame import UmlClassDiagramsFrame
        from org.pyut.history.commands.CreateOglInterfaceCommand import CreateOglInterfaceCommand
        from org.pyut.history.commands.CommandGroup import CommandGroup

        attachmentAnchor.setYouAreTheSelectedAnchor()

        umlFrame: UmlClassDiagramsFrame = self.getFileHandling(
        ).getCurrentFrame()

        cmd: CreateOglInterfaceCommand = CreateOglInterfaceCommand(
            implementor=implementor, attachmentAnchor=attachmentAnchor)
        group: CommandGroup = CommandGroup("Create lollipop")

        group.addCommand(cmd)
        umlFrame.getHistory().addCommandGroup(group)
        umlFrame.getHistory().execute()
Example #4
0
    def __init__(self, destinationAnchor: SelectAnchorPoint):

        super().__init__()

        self.logger: Logger = getLogger(__name__)
        self._destinationAnchor: SelectAnchorPoint = cast(
            SelectAnchorPoint, None)

        if destinationAnchor is not None:
            self._destinationAnchor = destinationAnchor
            destinationAnchor.AddLine(self)
Example #5
0
    def setUp(self):
        self.logger: Logger = TestIDFactory.clsLogger

        self.app: App = TestIDFactory.clsApp

        self._idFactory: IDFactory = IDFactory()

        self._pyutInterface: PyutInterface = PyutInterface()
        self._destinationAnchor: SelectAnchorPoint = SelectAnchorPoint(
            250, 250, AttachmentPoint.NORTH)

        self._pyutClass: PyutClass = PyutClass(name='UnitTestClass')
Example #6
0
    def drawLollipops(self):

        diagramFrame: Diagram = self._diagramFrame.GetDiagram()

        rectShape: RectangleShape = RectangleShape(400, 50, 130, 80)
        rectShape.SetDraggable(True)
        diagramFrame.AddShape(rectShape)

        dw, dh = rectShape.GetSize()

        eastX, eastY = dw, dh / 2

        destAnchor = SelectAnchorPoint(parent=rectShape,
                                       attachmentPoint=AttachmentPoint.EAST,
                                       x=eastX,
                                       y=eastY)
        destAnchor.SetDraggable(False)

        lollipopLine: LollipopLine = LollipopLine(destAnchor)

        diagramFrame.AddShape(lollipopLine)
Example #7
0
    def __createAnchorHints(self, destinationClass: OglClass, anchorX: int,
                            anchorY: int, attachmentPoint: AttachmentPoint,
                            umlFrame):

        anchorHint: SelectAnchorPoint = SelectAnchorPoint(
            x=anchorX,
            y=anchorY,
            attachmentPoint=attachmentPoint,
            parent=destinationClass)
        anchorHint.SetProtected(True)

        destinationClass.AddAnchorPoint(anchorHint)
        umlFrame.getDiagram().AddShape(anchorHint)
Example #8
0
    def testSerialize(self):

        pyutClass: PyutClass = PyutClass(name='Implementor')
        implementor: OglClass = OglClass(pyutClass=pyutClass)

        attachmentAnchor: SelectAnchorPoint = SelectAnchorPoint(
            x=100, y=100, attachmentPoint=AttachmentPoint.NORTH)

        cOglXFaceCmd: CreateOglInterfaceCommand = CreateOglInterfaceCommand(
            implementor=implementor, attachmentAnchor=attachmentAnchor)

        #
        # Override the created OglInterface2
        #
        oglInterface: OglInterface2 = cOglXFaceCmd._shape
        pyutInterface: PyutInterface = cOglXFaceCmd._pyutInterface

        floatMethod: PyutMethod = TestCommandCommon.createTestMethod(
            'floatMethod', PyutVisibilityEnum.PRIVATE, PyutType('float'))
        intMethod: PyutMethod = TestCommandCommon.createTestMethod(
            'intMethod', PyutVisibilityEnum.PROTECTED, PyutType('int'))

        pyutInterface.methods = [intMethod, floatMethod]
        oglInterface.pyutInterface = pyutInterface

        cOglXFaceCmd._shape = oglInterface
        serializedShape: str = cOglXFaceCmd.serialize()

        self.logger.debug(f'{serializedShape=}')

        self.assertIsNotNone(serializedShape, 'Something must come back')

        self.maxDiff = None
        self.logger.debug(
            f'{len(self._serializedCommand)=}  {len(serializedShape)=}')

        import re
        fixedSerializedShape = re.sub('shapeId=[0-9]*', 'shapeId=2',
                                      serializedShape)

        self.logger.debug(f'{fixedSerializedShape=}')

        expectedValue: str = self._serializedCommand
        actualValue: str = fixedSerializedShape

        self.assertEqual(expectedValue, actualValue, 'Oops, something changed')