当前位置: 首页>>代码示例>>Python>>正文


Python jnius.cast方法代码示例

本文整理汇总了Python中jnius.cast方法的典型用法代码示例。如果您正苦于以下问题:Python jnius.cast方法的具体用法?Python jnius.cast怎么用?Python jnius.cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jnius的用法示例。


在下文中一共展示了jnius.cast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getEnumeration

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def getEnumeration(self, node):
        """
        Build and returns a OWL 2 enumeration using the given graphol node.
        :type node: EnumerationNode
        :rtype: OWLObjectOneOf
        """
        if node.identity() is Identity.Unknown:
            raise DiagramMalformedError(node, 'unsupported operand(s)')
        f1 = lambda x: x.type() is Item.InputEdge
        f2 = lambda x: x.type() is Item.IndividualNode
        individuals = self.HashSet()
        for individual in node.incomingNodes(filter_on_edges=f1, filter_on_nodes=f2):
            conversion = self.convert(individual)
            individuals.add(conversion)
        if individuals.isEmpty():
            raise DiagramMalformedError(node, 'missing operand(s)')
        return self.df.getOWLObjectOneOf(cast(self.Set, individuals)) 
开发者ID:danielepantaleone,项目名称:eddy,代码行数:19,代码来源:owl2.py

示例2: getIntersection

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def getIntersection(self, node):
        """
        Build and returns a OWL 2 intersection using the given graphol node.
        :type node: IntersectionNode
        :rtype: T <= OWLObjectIntersectionOf|OWLDataIntersectionOf
        """
        if node.identity() is Identity.Unknown:
            raise DiagramMalformedError(node, 'unsupported operand(s)')
        collection = self.HashSet()
        f1 = lambda x: x.type() is Item.InputEdge
        f2 = lambda x: x.identity() is node.identity()
        for operand in node.incomingNodes(filter_on_edges=f1, filter_on_nodes=f2):
            conversion = self.convert(operand)
            collection.add(conversion)
        if collection.isEmpty():
            raise DiagramMalformedError(node, 'missing operand(s)')
        if node.identity() is Identity.Concept:
            return self.df.getOWLObjectIntersectionOf(cast(self.Set, collection))
        return self.df.getOWLDataIntersectionOf(cast(self.Set, collection)) 
开发者ID:danielepantaleone,项目名称:eddy,代码行数:21,代码来源:owl2.py

示例3: getRoleChain

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def getRoleChain(self, node):
        """
        Constructs and returns LinkedList of chained OWLObjectExpression (OPE => Role & RoleInverse).
        :type node: RoleChainNode
        :rtype: List
        """
        if not node.inputs:
            raise DiagramMalformedError(node, 'missing operand(s)')
        collection = self.LinkedList()
        for operand in [node.diagram.edge(i).other(node) for i in node.inputs]:
            if operand.type() not in {Item.RoleNode, Item.RoleInverseNode}:
                raise DiagramMalformedError(node, 'unsupported operand (%s)' % operand)
            conversion = self.convert(operand)
            collection.add(conversion)
        if collection.isEmpty():
            raise DiagramMalformedError(node, 'missing operand(s)')
        return cast(self.List, collection) 
开发者ID:danielepantaleone,项目名称:eddy,代码行数:19,代码来源:owl2.py

示例4: createDisjointClassesAxiom

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def createDisjointClassesAxiom(self, node):
        """
        Generate a OWL 2 DisjointClasses axiom.
        :type node: T <= ComplementNode|DisjointUnionNode
        """
        if OWLAxiom.DisjointClasses in self.axiomsList:
            if node.type() is Item.DisjointUnionNode:
                collection = self.HashSet()
                for operand in node.incomingNodes(lambda x: x.type() is Item.InputEdge):
                    conversion = self.convert(operand)
                    collection.add(conversion)
                self.addAxiom(self.df.getOWLDisjointClassesAxiom(cast(self.Set, collection)))
            elif node.type() is Item.ComplementNode:
                operand = first(node.incomingNodes(lambda x: x.type() is Item.InputEdge))
                conversionA = self.convert(operand)
                for included in node.adjacentNodes(lambda x: x.type() in {Item.InclusionEdge, Item.EquivalenceEdge}):
                    conversionB = self.convert(included)
                    collection = self.HashSet()
                    collection.add(conversionA)
                    collection.add(conversionB)
                    self.addAxiom(self.df.getOWLDisjointClassesAxiom(cast(self.Set, collection))) 
开发者ID:danielepantaleone,项目名称:eddy,代码行数:23,代码来源:owl2.py

示例5: createEquivalentObjectPropertiesAxiom

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def createEquivalentObjectPropertiesAxiom(self, edge):
        """
        Generate a OWL 2 EquivalentObjectProperties axiom.
        :type edge: InclusionEdge
        """
        if OWLAxiom.EquivalentObjectProperties in self.axiomsList:
            if self.normalize:
                for source, target in ((edge.source, edge.target), (edge.target, edge.source)):
                    conversionA = self.convert(source)
                    conversionB = self.convert(target)
                    self.addAxiom(self.df.getOWLSubObjectPropertyOfAxiom(conversionA, conversionB))
            else:
                conversionA = self.convert(edge.source)
                conversionB = self.convert(edge.target)
                collection = self.HashSet()
                collection.add(conversionA)
                collection.add(conversionB)
                self.addAxiom(self.df.getOWLEquivalentObjectPropertiesAxiom(cast(self.Set, collection))) 
开发者ID:danielepantaleone,项目名称:eddy,代码行数:20,代码来源:owl2.py

示例6: open_url

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def open_url(url):
    if platform == 'android':
        ''' Open a webpage in the default Android browser.  '''
        from jnius import autoclass, cast
        context = autoclass('org.renpy.android.PythonActivity').mActivity
        Uri = autoclass('android.net.Uri')
        Intent = autoclass('android.content.Intent')

        intent = Intent()
        intent.setAction(Intent.ACTION_VIEW)
        intent.setData(Uri.parse(url))
        currentActivity = cast('android.app.Activity', context)
        currentActivity.startActivity(intent)
    else:
        import webbrowser
        webbrowser.open(url) 
开发者ID:metamarcdw,项目名称:nowallet,代码行数:18,代码来源:main.py

示例7: share

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def share(self):
        if platform() == 'android': #check if the app is on Android
            # read more here: http://developer.android.com/training/sharing/send.html
            PythonActivity = autoclass('org.renpy.android.PythonActivity') #request the activity instance
            Intent = autoclass('android.content.Intent') # get the Android Intend class

            String = autoclass('java.lang.String') # get the Java object

            intent = Intent() # create a new Android Intent
            intent.setAction(Intent.ACTION_SEND) #set the action
            # to send a message, it need to be a Java char array. So we use the cast to convert and Java String to a Java Char array
            intent.putExtra(Intent.EXTRA_SUBJECT, cast('java.lang.CharSequence', String('Fast Perception')))
            intent.putExtra(Intent.EXTRA_TEXT, cast('java.lang.CharSequence', String('Wow, I just scored %d on Fast Perception. Check this game: https://play.google.com/store/apps/details?id=com.aronbordin.fastperception' % (self.best_score))))

            intent.setType('text/plain') #text message

            currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
            currentActivity.startActivity(intent) # show the intent in the game activity

    # will be called when our screen be displayed 
开发者ID:aron-bordin,项目名称:Kivy-Tutorials,代码行数:22,代码来源:main.py

示例8: share

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def share(self):
        if platform() == 'android': #check if the app is on Android
            # read more here: http://developer.android.com/training/sharing/send.html
           
            PythonActivity = autoclass('org.renpy.android.PythonActivity') #request the Kivy activity instance
            Intent = autoclass('android.content.Intent') # get the Android Intend class

            String = autoclass('java.lang.String') # get the Java object

            intent = Intent() # create a new Android Intent
            intent.setAction(Intent.ACTION_SEND) #set the action

            # to send a message, it need to be a Java char array. So we use the cast to convert and Java String to a Java Char array
            intent.putExtra(Intent.EXTRA_SUBJECT, cast('java.lang.CharSequence', String('Byte::Debugger() Tutorial #7')))
            intent.putExtra(Intent.EXTRA_TEXT, cast('java.lang.CharSequence', String("Testing Byte::Debugger() Tutorial #7, with Python for Android")))

            intent.setType('text/plain') #text message

            currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
            currentActivity.startActivity(intent) # show the intent in the game activity 
开发者ID:aron-bordin,项目名称:Kivy-Tutorials,代码行数:22,代码来源:main.py

示例9: pause_app

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def pause_app():
    '''
    '''
    if platform == 'android':
        currentActivity = cast(
            'android.app.Activity', PythonActivity.mActivity)
        currentActivity.moveTaskToBack(True)
    else:
        app = App.get_running_app()
        app.stop() 
开发者ID:pythonindia,项目名称:PyCon-Mobile-App,代码行数:12,代码来源:__init__.py

示例10: do_share

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def do_share(data, title):
    if platform != 'android':
        return
    sendIntent = Intent()
    sendIntent.setAction(Intent.ACTION_SEND)
    sendIntent.setType("text/plain")
    sendIntent.putExtra(Intent.EXTRA_TEXT, JS(data))
    it = Intent.createChooser(
        sendIntent, cast('java.lang.CharSequence', JS(title)))
    currentActivity.startActivity(it) 
开发者ID:pythonindia,项目名称:PyCon-Mobile-App,代码行数:12,代码来源:__init__.py

示例11: getDatatypeRestriction

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def getDatatypeRestriction(self, node):
        """
        Build and returns a OWL 2 datatype restriction using the given graphol node.
        :type node: DatatypeRestrictionNode
        :rtype: OWLDatatypeRestriction
        """
        f1 = lambda x: x.type() is Item.InputEdge
        f2 = lambda x: x.type() is Item.ValueDomainNode
        f3 = lambda x: x.type() is Item.FacetNode

        #############################################
        # BUILD DATATYPE
        #################################

        operand = first(node.incomingNodes(filter_on_edges=f1, filter_on_nodes=f2))
        if not operand:
            raise DiagramMalformedError(node, 'missing value domain node')

        de = self.convert(operand)

        #############################################
        # BUILD FACETS
        #################################

        incoming = node.incomingNodes(filter_on_edges=f1, filter_on_nodes=f3)
        if not incoming:
            raise DiagramMalformedError(node, 'missing facet node(s)')

        collection = self.HashSet()
        for facet in incoming:
            conversion = self.convert(facet)
            collection.add(conversion)

        #############################################
        # BUILD DATATYPE RESTRICTION
        #################################

        return self.df.getOWLDatatypeRestriction(de, cast(self.Set, collection)) 
开发者ID:danielepantaleone,项目名称:eddy,代码行数:40,代码来源:owl2.py

示例12: createAnnotationAssertionAxiom

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def createAnnotationAssertionAxiom(self, node):
        """
        Generate a OWL 2 annotation axiom.
        :type node: AbstractNode
        """
        if OWLAxiom.Annotation in self.axiomsList:
            meta = self.project.meta(node.type(), node.text())
            if meta and not isEmpty(meta.get(K_DESCRIPTION, '')):
                aproperty = self.df.getOWLAnnotationProperty(self.IRI.create("rdfs:comment"))
                value = self.df.getOWLLiteral(OWLAnnotationText(meta.get(K_DESCRIPTION, '')))
                value = cast(self.OWLAnnotationValue, value)
                annotation = self.df.getOWLAnnotation(aproperty, value)
                conversion = self.convert(node)
                self.addAxiom(self.df.getOWLAnnotationAssertionAxiom(conversion.getIRI(), annotation)) 
开发者ID:danielepantaleone,项目名称:eddy,代码行数:16,代码来源:owl2.py

示例13: createDisjointDataPropertiesAxiom

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def createDisjointDataPropertiesAxiom(self, edge):
        """
        Generate a OWL 2 DisjointDataProperties axiom.
        :type edge: InclusionEdge
        """
        if OWLAxiom.DisjointDataProperties in self.axiomsList:
            conversionA = self.convert(edge.source)
            conversionB = self.convert(edge.target)
            collection = self.HashSet()
            collection.add(conversionA)
            collection.add(conversionB)
            self.addAxiom(self.df.getOWLDisjointDataPropertiesAxiom(cast(self.Set, collection))) 
开发者ID:danielepantaleone,项目名称:eddy,代码行数:14,代码来源:owl2.py

示例14: createDisjointObjectPropertiesAxiom

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def createDisjointObjectPropertiesAxiom(self, edge):
        """
        Generate a OWL 2 DisjointObjectProperties axiom.
        :type edge: InclusionEdge
        """
        if OWLAxiom.DisjointObjectProperties in self.axiomsList:
            conversionA = self.convert(edge.source)
            conversionB = self.convert(edge.target)
            collection = self.HashSet()
            collection.add(conversionA)
            collection.add(conversionB)
            self.addAxiom(self.df.getOWLDisjointObjectPropertiesAxiom(cast(self.Set, collection))) 
开发者ID:danielepantaleone,项目名称:eddy,代码行数:14,代码来源:owl2.py

示例15: pause_app

# 需要导入模块: import jnius [as 别名]
# 或者: from jnius import cast [as 别名]
def pause_app():
    '''
    '''
    from kivy.utils import platform
    if platform == 'android':
        from jnius import cast
        from jnius import autoclass
        PythonActivity = autoclass('org.kivy.android.PythonActivity')
        currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
        currentActivity.moveTaskToBack(True)
    else:
        app = App.get_running_app()
        app.stop() 
开发者ID:pydelhi,项目名称:pydelhi_mobile,代码行数:15,代码来源:__init__.py


注:本文中的jnius.cast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。