當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。