idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
6,300 | private void connectArcToPort ( SbgnPDNode lPort , Port vPort ) { for ( Object e : ( lPort . getEdges ( ) ) ) { if ( ( ( LEdge ) e ) . type . equals ( "rigid edge" ) ) continue ; Arc arc = idToArcs . get ( ( ( LEdge ) e ) . label ) ; if ( lPort . label . equals ( ( ( LEdge ) e ) . getSource ( ) . label ) ) { arc . setSource ( vPort ) ; } else if ( lPort . label . equals ( ( ( LEdge ) e ) . getTarget ( ) . label ) ) { arc . setTarget ( vPort ) ; } } } | This method connects the existing arcs to the newly created ports which are created by ChiLay and SBGNPD Layout . |
6,301 | private void populateCompartmentOccurencesMap ( Glyph targetGlyph , HashMap < String , Integer > compartmentIDandOccurenceMap ) { String rootID = "root" ; if ( targetGlyph . getCompartmentRef ( ) != null ) { Glyph containerCompartment = ( Glyph ) targetGlyph . getCompartmentRef ( ) ; String compartmentID = containerCompartment . getId ( ) ; Integer compartmentOccurrenceValue = compartmentIDandOccurenceMap . get ( compartmentID ) ; if ( compartmentOccurrenceValue != null ) { compartmentIDandOccurenceMap . put ( compartmentID , compartmentOccurrenceValue + 1 ) ; } else compartmentIDandOccurenceMap . put ( compartmentID , 1 ) ; } else { Integer compartmentOccurrenceValue = compartmentIDandOccurenceMap . get ( rootID ) ; if ( compartmentOccurrenceValue != null ) { compartmentIDandOccurenceMap . put ( rootID , compartmentOccurrenceValue + 1 ) ; } else compartmentIDandOccurenceMap . put ( rootID , 1 ) ; } } | Updates a hashmap by incrementing the number of nodes in the compartment glyph that includes targetGlyph . It is assumed that given hashmap includes compartment ids as keys and number of nodes as values . This method is an utility method that will be used to populate a hashmap while determining the compartment node of a process node by majority rule . |
6,302 | private void createVNodes ( VCompound parent , List < Glyph > glyphs ) { for ( Glyph glyph : glyphs ) { if ( ! glyphClazzOneOf ( glyph , GlyphClazz . UNIT_OF_INFORMATION , GlyphClazz . STATE_VARIABLE ) ) { if ( ! isChildless ( glyph ) ) { VCompound v = new VCompound ( glyph ) ; idToGLyph . put ( glyph . getId ( ) , glyph ) ; glyphToVNode . put ( glyph , v ) ; parent . children . add ( v ) ; createVNodes ( v , glyph . getGlyph ( ) ) ; } else { VNode v = new VNode ( glyph ) ; idToGLyph . put ( glyph . getId ( ) , glyph ) ; glyphToVNode . put ( glyph , v ) ; parent . children . add ( v ) ; } } } } | Recursively creates VNodes from Glyphs of Sbgn . |
6,303 | private void createLEdges ( List < Arc > arcs ) { for ( Arc arc : arcs ) { LEdge lEdge = layout . newEdge ( null ) ; lEdge . type = arc . getClazz ( ) ; lEdge . label = arc . getId ( ) ; LNode sourceLNode = viewToLayout . get ( glyphToVNode . get ( arc . getSource ( ) ) ) ; LNode targetLNode = viewToLayout . get ( glyphToVNode . get ( arc . getTarget ( ) ) ) ; idToArcs . put ( arc . getId ( ) , arc ) ; layout . getGraphManager ( ) . add ( lEdge , sourceLNode , targetLNode ) ; } } | Creates LNodes from Arcs of Sbgn and adds it to the passed layout object . |
6,304 | private void createLNode ( VNode vNode , VNode parent ) { LNode lNode = layout . newNode ( vNode ) ; lNode . type = vNode . glyph . getClazz ( ) ; lNode . label = vNode . glyph . getId ( ) ; LGraph rootLGraph = layout . getGraphManager ( ) . getRoot ( ) ; viewToLayout . put ( vNode , lNode ) ; layoutToView . put ( lNode . label , vNode ) ; if ( parent != null ) { LNode parentLNode = viewToLayout . get ( parent ) ; parentLNode . getChild ( ) . add ( lNode ) ; } else { rootLGraph . add ( lNode ) ; } lNode . setLocation ( vNode . glyph . getBbox ( ) . getX ( ) , vNode . glyph . getBbox ( ) . getY ( ) ) ; if ( vNode instanceof VCompound ) { VCompound vCompound = ( VCompound ) vNode ; layout . getGraphManager ( ) . add ( layout . newGraph ( null ) , lNode ) ; for ( VNode vChildNode : vCompound . getChildren ( ) ) { createLNode ( vChildNode , vCompound ) ; } } else { lNode . setWidth ( vNode . glyph . getBbox ( ) . getW ( ) ) ; lNode . setHeight ( vNode . glyph . getBbox ( ) . getH ( ) ) ; } } | Helper function for creating LNode objects from VNode objects and adds them to the given layout . |
6,305 | private void setCompartmentRefForComplexMembers ( final Glyph glyph , final Glyph compartment , final Set < Glyph > visited ) { if ( ! visited . add ( glyph ) ) return ; glyph . setCompartmentRef ( compartment ) ; if ( glyph . getGlyph ( ) . size ( ) > 0 ) { for ( Glyph g : glyph . getGlyph ( ) ) { setCompartmentRefForComplexMembers ( g , compartment , visited ) ; } } } | Recursively sets compartmentRef fields of members of a complex glyph to the same value as complex s compartment . |
6,306 | private void removePortsFromArcs ( List < Arc > arcs ) { for ( Arc arc : arcs ) { if ( arc . getSource ( ) instanceof Port ) { Glyph source = portIDToOwnerGlyph . get ( ( ( Port ) arc . getSource ( ) ) . getId ( ) ) ; arc . setSource ( source ) ; } if ( arc . getTarget ( ) instanceof Port ) { Glyph target = portIDToOwnerGlyph . get ( ( ( Port ) arc . getTarget ( ) ) . getId ( ) ) ; arc . setTarget ( target ) ; } } } | This method replaces ports of arc objects with their owners . |
6,307 | private void initPortIdToGlyphMap ( List < Glyph > glyphs ) { for ( Glyph glyph : glyphs ) { for ( Port p : glyph . getPort ( ) ) { portIDToOwnerGlyph . put ( p . getId ( ) , glyph ) ; } if ( glyph . getGlyph ( ) . size ( ) > 0 ) initPortIdToGlyphMap ( glyph . getGlyph ( ) ) ; } } | This method initializes map for glyphs and their respective ports . |
6,308 | public boolean isSafe ( Node node , Edge edge ) { initMaps ( ) ; setColor ( node , BLACK ) ; setLabel ( node , 0 ) ; setLabel ( edge , 0 ) ; labelEquivRecursive ( node , UPWARD , 0 , false , false ) ; labelEquivRecursive ( node , DOWNWARD , 0 , false , false ) ; Node neigh = edge . getTargetNode ( ) ; if ( getColor ( neigh ) != WHITE ) return false ; setColor ( neigh , GRAY ) ; setLabel ( neigh , 0 ) ; queue . add ( neigh ) ; labelEquivRecursive ( neigh , UPWARD , 0 , true , false ) ; labelEquivRecursive ( neigh , DOWNWARD , 0 , true , false ) ; while ( ! queue . isEmpty ( ) ) { Node current = queue . remove ( 0 ) ; if ( ST . contains ( current ) ) return true ; boolean safe = processNode2 ( current ) ; if ( safe ) return true ; setColor ( current , BLACK ) ; } return false ; } | Checks whether an edge is on an unwanted cycle . |
6,309 | protected boolean processNode2 ( Node current ) { return processEdges ( current , current . getDownstream ( ) ) || processEdges ( current , current . getUpstream ( ) ) ; } | Continue the search from the node . 2 is added because a name clash in the parent class . |
6,310 | private boolean processEdges ( Node current , Collection < Edge > edges ) { for ( Edge edge : edges ) { if ( ! result . contains ( edge ) ) continue ; setLabel ( edge , getLabel ( current ) ) ; Node neigh = edge . getSourceNode ( ) == current ? edge . getTargetNode ( ) : edge . getSourceNode ( ) ; if ( getColor ( neigh ) == WHITE ) { if ( neigh . isBreadthNode ( ) ) { setLabel ( neigh , getLabel ( current ) + 1 ) ; } else { setLabel ( neigh , getLabel ( edge ) ) ; } if ( getLabel ( neigh ) == limit || isEquivalentInTheSet ( neigh , ST ) ) { return true ; } setColor ( neigh , GRAY ) ; if ( neigh . isBreadthNode ( ) ) { queue . addLast ( neigh ) ; } else { queue . addFirst ( neigh ) ; } labelEquivRecursive ( neigh , UPWARD , getLabel ( neigh ) , true , ! neigh . isBreadthNode ( ) ) ; labelEquivRecursive ( neigh , DOWNWARD , getLabel ( neigh ) , true , ! neigh . isBreadthNode ( ) ) ; } } return false ; } | Continue evaluating the next edge . |
6,311 | protected void createAndAdd ( Model model , String id , String localName ) { BioPAXElement bpe = this . getFactory ( ) . create ( localName , id ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "id:" + id + " " + localName + " : " + bpe ) ; } if ( bpe != null ) { model . add ( bpe ) ; } else { log . warn ( "null object created during reading. It might not be an official BioPAX class.ID: " + id + " Class " + "name " + localName ) ; } } | This method is called by the reader for each OWL instance in the OWL model . It creates a POJO instance with the given id and inserts it into the model . The inserted object is clean in the sense that its properties are not set yet . |
6,312 | protected Object resourceFixes ( BioPAXElement bpe , Object value ) { if ( this . isFixReusedPEPs ( ) && value instanceof physicalEntityParticipant ) { value = this . getReusedPEPHelper ( ) . fixReusedPEP ( ( physicalEntityParticipant ) value , bpe ) ; } return value ; } | This method currently only fixes reusedPEPs if the option is set . As L2 is becoming obsolete this method will be slated for deprecation . |
6,313 | protected void bindValue ( String valueString , PropertyEditor editor , BioPAXElement bpe , Model model ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Binding: " + bpe + '(' + bpe . getModelInterface ( ) + " has " + editor + ' ' + valueString ) ; } Object value = ( valueString == null ) ? null : valueString . trim ( ) ; if ( editor instanceof ObjectPropertyEditor ) { value = model . getByID ( valueString ) ; value = resourceFixes ( bpe , value ) ; if ( value == null ) { throw new IllegalBioPAXArgumentException ( "Illegal or Dangling Value/Reference: " + valueString + " (element: " + bpe . getUri ( ) + " property: " + editor . getProperty ( ) + ")" ) ; } } if ( editor == null ) { log . error ( "Editor is null. This probably means an invalid BioPAX property. Failed to set " + valueString ) ; } else { editor . setValueToBean ( value , bpe ) ; } } | This method binds the value to the bpe . Actual assignment is handled by the editor - but this method performs most of the workarounds and also error handling due to invalid parameters . |
6,314 | private boolean containsNull ( PhysicalEntity [ ] pes ) { for ( PhysicalEntity pe : pes ) { if ( pe == null ) return true ; } return false ; } | Checks if any element in the chain is null . |
6,315 | protected PhysicalEntity [ ] fillArray ( PhysicalEntity parent , PhysicalEntity target , int depth , int dir ) { if ( parent == target ) { PhysicalEntity [ ] pes = new PhysicalEntity [ depth ] ; pes [ 0 ] = target ; return pes ; } if ( parent instanceof Complex ) { for ( PhysicalEntity mem : ( ( Complex ) parent ) . getComponent ( ) ) { PhysicalEntity [ ] pes = fillArray ( mem , target , depth + 1 , 0 ) ; if ( pes != null ) { pes [ pes . length - depth ] = parent ; return pes ; } } } if ( dir <= 0 ) for ( PhysicalEntity mem : parent . getMemberPhysicalEntity ( ) ) { PhysicalEntity [ ] pes = fillArray ( mem , target , depth + 1 , - 1 ) ; if ( pes != null ) { pes [ pes . length - depth ] = parent ; return pes ; } } if ( dir >= 0 ) for ( PhysicalEntity grand : parent . getMemberPhysicalEntityOf ( ) ) { PhysicalEntity [ ] pes = fillArray ( grand , target , depth + 1 , 1 ) ; if ( pes != null ) { pes [ pes . length - depth ] = parent ; return pes ; } } return null ; } | Creates the chain that links the given endpoints . |
6,316 | public Set < String > getCellularLocations ( ) { Set < String > locs = new HashSet < String > ( ) ; for ( PhysicalEntity pe : pes ) { CellularLocationVocabulary voc = pe . getCellularLocation ( ) ; if ( voc != null ) { for ( String term : voc . getTerm ( ) ) { if ( term != null && term . length ( ) > 0 ) locs . add ( term ) ; } } } return locs ; } | Retrieves the cellular location of the PhysicalEntity . |
6,317 | public boolean intersects ( PhysicalEntityChain rpeh , boolean ignoreEndPoints ) { for ( PhysicalEntity pe1 : pes ) { for ( PhysicalEntity pe2 : rpeh . pes ) { if ( pe1 == pe2 ) { if ( ignoreEndPoints ) { if ( ( pes [ 0 ] == pe1 || pes [ pes . length - 1 ] == pe1 ) && ( rpeh . pes [ 0 ] == pe2 || rpeh . pes [ rpeh . pes . length - 1 ] == pe2 ) ) { continue ; } } return true ; } } } return false ; } | Checks if two chains intersect . |
6,318 | public Activity checkActivityLabel ( ) { boolean active = false ; boolean inactive = false ; for ( PhysicalEntity pe : pes ) { for ( Object o : PE2TERM . getValueFromBean ( pe ) ) { String s = ( String ) o ; if ( s . contains ( "inactiv" ) ) inactive = true ; else if ( s . contains ( "activ" ) ) active = true ; } for ( String s : pe . getName ( ) ) { if ( s . contains ( "inactiv" ) ) inactive = true ; else if ( s . contains ( "activ" ) ) active = true ; } } if ( active ) if ( inactive ) return Activity . BOTH ; else return Activity . ACTIVE ; else if ( inactive ) return Activity . INACTIVE ; else return Activity . NONE ; } | Checks if the chain has a member with an activity label . |
6,319 | public Set < ModificationFeature > getModifications ( ) { Set < ModificationFeature > set = new HashSet < ModificationFeature > ( ) ; for ( PhysicalEntity pe : pes ) { set . addAll ( PE2FEAT . getValueFromBean ( pe ) ) ; } return set ; } | Collects modifications from the elements of the chain . |
6,320 | public boolean satisfies ( Match match , int ... ind ) { Collection < BioPAXElement > set = con . generate ( match , ind ) ; switch ( type ) { case EQUAL : return set . size ( ) == size ; case GREATER : return set . size ( ) > size ; case GREATER_OR_EQUAL : return set . size ( ) >= size ; case LESS : return set . size ( ) < size ; case LESS_OR_EQUAL : return set . size ( ) <= size ; default : throw new RuntimeException ( "Should not reach here. Did somebody modify Type enum?" ) ; } } | Checks if generated element size is in limits . |
6,321 | public void writeResult ( Map < BioPAXElement , List < Match > > matches , OutputStream out ) throws IOException { writeResultDetailed ( matches , out , 5 ) ; } | Writes the result as A modifications - of - A B gains - of - B loss - of - B where A and B are gene symbols and whitespace is tab . Modifications are comma separated . |
6,322 | public String getValue ( Match m , int col ) { switch ( col ) { case 0 : { return getGeneSymbol ( m , "controller ER" ) ; } case 1 : { return concat ( getModifications ( m , "controller simple PE" , "controller PE" ) , " " ) ; } case 2 : { return getGeneSymbol ( m , "changed ER" ) ; } case 3 : { return concat ( getDeltaModifications ( m , "input simple PE" , "input PE" , "output simple PE" , "output PE" ) [ 0 ] , " " ) ; } case 4 : { return concat ( getDeltaModifications ( m , "input simple PE" , "input PE" , "output simple PE" , "output PE" ) [ 1 ] , " " ) ; } default : throw new RuntimeException ( "Invalid col number: " + col ) ; } } | Creates values for the result file columns . |
6,323 | @ SuppressWarnings ( { "unchecked" } ) public static < T extends LocalizableResource > T get ( Class < T > cls , String locale ) { Map < String , LocalizableResource > localeCache = getLocaleCache ( cls ) ; T m = ( T ) localeCache . get ( locale ) ; if ( m != null ) { return m ; } synchronized ( cache ) { m = ( T ) localeCache . get ( locale ) ; if ( m != null ) { return m ; } m = provider . create ( cls , locale ) ; put ( cls , locale , m ) ; return m ; } } | Get localization object for the specified locale . |
6,324 | public static < T extends LocalizableResource > void put ( Class < T > cls , String locale , T m ) { Map < String , LocalizableResource > localeCache = getLocaleCache ( cls ) ; synchronized ( cache ) { localeCache . put ( locale , m ) ; } } | Populate localization object cache for the specified locale . |
6,325 | public Glyph . State createStateVar ( EntityFeature ef , ObjectFactory factory ) { if ( ef instanceof FragmentFeature ) { FragmentFeature ff = ( FragmentFeature ) ef ; SequenceLocation loc = ff . getFeatureLocation ( ) ; if ( loc instanceof SequenceInterval ) { SequenceInterval si = ( SequenceInterval ) loc ; SequenceSite begin = si . getSequenceIntervalBegin ( ) ; SequenceSite end = si . getSequenceIntervalEnd ( ) ; if ( begin != null && end != null ) { Glyph . State state = factory . createGlyphState ( ) ; state . setValue ( "x[" + begin . getSequencePosition ( ) + " - " + end . getSequencePosition ( ) + "]" ) ; return state ; } } } else if ( ef instanceof ModificationFeature ) { ModificationFeature mf = ( ModificationFeature ) ef ; SequenceModificationVocabulary modType = mf . getModificationType ( ) ; if ( modType != null ) { Set < String > terms = modType . getTerm ( ) ; if ( terms != null && ! terms . isEmpty ( ) ) { String orig = terms . iterator ( ) . next ( ) ; String term = orig . toLowerCase ( ) ; String s = symbolMapping . containsKey ( term ) ? symbolMapping . get ( term ) : orig ; Glyph . State state = factory . createGlyphState ( ) ; state . setValue ( s ) ; SequenceLocation loc = mf . getFeatureLocation ( ) ; if ( locMapping . containsKey ( term ) ) { state . setVariable ( locMapping . get ( term ) ) ; } if ( loc instanceof SequenceSite ) { SequenceSite ss = ( SequenceSite ) loc ; if ( ss . getSequencePosition ( ) > 0 ) { state . setVariable ( ( state . getVariable ( ) != null ? state . getVariable ( ) : "" ) + ss . getSequencePosition ( ) ) ; } } return state ; } } } return null ; } | Creates State to represent the entity feature . |
6,326 | protected int [ ] translate ( int [ ] outer ) { int [ ] t = new int [ inds . length ] ; for ( int i = 0 ; i < t . length ; i ++ ) { t [ i ] = outer [ inds [ i ] ] ; } return t ; } | This methods translates the indexes of outer constraint to this inner constraint . |
6,327 | public Collection < BioPAXElement > generate ( Match match , int ... outer ) { return constr . generate ( match , translate ( outer ) ) ; } | Calls generate method of the constraint with index translation . |
6,328 | public boolean satisfies ( Match match , int ... ind ) { BioPAXElement ele0 = match . get ( ind [ 0 ] ) ; BioPAXElement ele1 = match . get ( ind [ 1 ] ) ; if ( ele1 == null ) return false ; Set vals = pa . getValueFromBean ( ele0 ) ; return vals . contains ( ele1 ) ; } | Checks if the PathAccessor is generating the second mapped element . |
6,329 | public Collection < BioPAXElement > generate ( Match match , int ... ind ) { BioPAXElement ele0 = match . get ( ind [ 0 ] ) ; if ( ele0 == null ) throw new RuntimeException ( "Constraint cannot generate based on null value" ) ; Set vals = pa . getValueFromBean ( ele0 ) ; List < BioPAXElement > list = new ArrayList < BioPAXElement > ( vals . size ( ) ) ; for ( Object o : vals ) { assert o instanceof BioPAXElement ; list . add ( ( BioPAXElement ) o ) ; } return list ; } | Uses the encapsulated PAthAccessor to generate satisfying elements . |
6,330 | public boolean satisfies ( Match match , int ... ind ) { assert ind . length == 2 ; return ( match . get ( ind [ 0 ] ) == match . get ( ind [ 1 ] ) ) == equals ; } | Checks if the two elements are identical or not identical as desired . |
6,331 | protected void addValidValue ( String value ) { if ( value != null && ! value . isEmpty ( ) ) validValues . add ( value . toLowerCase ( ) ) ; } | Adds the given valid value to the set of valid values . |
6,332 | public boolean okToTraverse ( Level3Element ele ) { if ( validValues . isEmpty ( ) ) return true ; boolean empty = true ; boolean objectRelevant = false ; for ( PathAccessor acc : accessors . keySet ( ) ) { Class clazz = accessors . get ( acc ) ; if ( ! clazz . isAssignableFrom ( ele . getClass ( ) ) ) continue ; objectRelevant = true ; Set values = acc . getValueFromBean ( ele ) ; if ( empty ) empty = values . isEmpty ( ) ; for ( Object o : values ) if ( validValues . contains ( o . toString ( ) . toLowerCase ( ) ) ) return true ; } return ! objectRelevant || ( empty && isEmptyOK ( ) ) ; } | Checks if the related values of the object are among valid values . Returns true if none of the accessors is applicable to the given object . |
6,333 | public String getName ( SmallMoleculeReference smr ) { if ( map . containsKey ( smr ) ) return map . get ( smr ) . getDisplayName ( ) ; else return smr . getDisplayName ( ) ; } | Gets the standard name of the small molecule . |
6,334 | protected Map < EntityReference , Set < String > > extractModifNames ( Map mfMap ) { Map < EntityReference , Set < String > > map = new HashMap < EntityReference , Set < String > > ( ) ; for ( Object o : mfMap . keySet ( ) ) { EntityReference er = ( EntityReference ) o ; map . put ( er , extractModifNames ( ( Set ) mfMap . get ( er ) ) ) ; } return map ; } | Extracts the modification terms from the moficiation features . |
6,335 | protected Set < String > extractModifNames ( Set mfSet ) { Set < String > set = new HashSet < String > ( ) ; for ( Object o : mfSet ) { ModificationFeature mf = ( ModificationFeature ) o ; if ( mf . getModificationType ( ) != null && ! mf . getModificationType ( ) . getTerm ( ) . isEmpty ( ) ) { set . add ( mf . getModificationType ( ) . getTerm ( ) . iterator ( ) . next ( ) ) ; } } return set ; } | Extracts terms of the modification features . |
6,336 | public E get ( String uri ) { if ( map == empty ) return null ; synchronized ( map ) { return map . get ( uri ) ; } } | Gets a BioPAX element by URI . |
6,337 | public synchronized void replace ( final BioPAXElement existing , final BioPAXElement replacement ) { ModelUtils . replace ( this , Collections . singletonMap ( existing , replacement ) ) ; remove ( existing ) ; if ( replacement != null ) add ( replacement ) ; } | It does not automatically replace or clean up the old element s object properties therefore some child elements may become dangling if they were used by the replaced element only . |
6,338 | private int getMaxMemory ( ) { int total = 0 ; for ( MemoryPoolMXBean mpBean : ManagementFactory . getMemoryPoolMXBeans ( ) ) { if ( mpBean . getType ( ) == MemoryType . HEAP ) { total += mpBean . getUsage ( ) . getMax ( ) >> 20 ; } } return total ; } | Gets the maximum memory heap size for the application . This size can be modified by passing - Xmx option to the virtual machine like java - Xmx5G MyClass . java . |
6,339 | public void actionPerformed ( ActionEvent e ) { if ( e . getSource ( ) == pcRadio || e . getSource ( ) == customFileRadio || e . getSource ( ) == customURLRadio ) { pcCombo . setEnabled ( pcRadio . isSelected ( ) ) ; modelField . setEnabled ( customFileRadio . isSelected ( ) ) ; loadButton . setEnabled ( customFileRadio . isSelected ( ) ) ; urlField . setEnabled ( customURLRadio . isSelected ( ) ) ; } else if ( e . getSource ( ) == loadButton ) { String current = modelField . getText ( ) ; String initial = current . trim ( ) . length ( ) > 0 ? current : "." ; JFileChooser fc = new JFileChooser ( initial ) ; fc . setFileFilter ( new FileNameExtensionFilter ( "BioPAX file (*.owl)" , "owl" ) ) ; if ( fc . showOpenDialog ( this ) == JFileChooser . APPROVE_OPTION ) { File file = fc . getSelectedFile ( ) ; modelField . setText ( file . getPath ( ) ) ; } } else if ( e . getSource ( ) == patternCombo ) { Miner m = ( Miner ) patternCombo . getSelectedItem ( ) ; descArea . setText ( m . getDescription ( ) ) ; String text = outputField . getText ( ) ; if ( text . contains ( "/" ) ) text = text . substring ( 0 , text . lastIndexOf ( "/" ) + 1 ) ; else text = "" ; text += m . getName ( ) + ".txt" ; outputField . setText ( text ) ; } else if ( e . getSource ( ) == runButton ) { run ( ) ; } checkRunButton ( ) ; } | Performs interactive operations . |
6,340 | private void checkRunButton ( ) { runButton . setEnabled ( ( pcRadio . isSelected ( ) || ( customFileRadio . isSelected ( ) && ! modelField . getText ( ) . trim ( ) . isEmpty ( ) ) || ( customURLRadio . isSelected ( ) && ! urlField . getText ( ) . trim ( ) . isEmpty ( ) ) ) && ! outputField . getText ( ) . trim ( ) . isEmpty ( ) ) ; } | Checks if the run button should be enabled . |
6,341 | private Object [ ] getAvailablePatterns ( ) { List < Miner > minerList = new ArrayList < Miner > ( ) ; if ( miners != null && miners . length > 0 ) { minerList . addAll ( Arrays . asList ( miners ) ) ; } else { minerList . add ( new DirectedRelationMiner ( ) ) ; minerList . add ( new ControlsStateChangeOfMiner ( ) ) ; minerList . add ( new CSCOButIsParticipantMiner ( ) ) ; minerList . add ( new CSCOBothControllerAndParticipantMiner ( ) ) ; minerList . add ( new CSCOThroughControllingSmallMoleculeMiner ( ) ) ; minerList . add ( new CSCOThroughBindingSmallMoleculeMiner ( ) ) ; minerList . add ( new ControlsStateChangeDetailedMiner ( ) ) ; minerList . add ( new ControlsPhosphorylationMiner ( ) ) ; minerList . add ( new ControlsTransportMiner ( ) ) ; minerList . add ( new ControlsExpressionMiner ( ) ) ; minerList . add ( new ControlsExpressionWithConvMiner ( ) ) ; minerList . add ( new CSCOThroughDegradationMiner ( ) ) ; minerList . add ( new ControlsDegradationIndirectMiner ( ) ) ; minerList . add ( new ConsumptionControlledByMiner ( ) ) ; minerList . add ( new ControlsProductionOfMiner ( ) ) ; minerList . add ( new CatalysisPrecedesMiner ( ) ) ; minerList . add ( new ChemicalAffectsThroughBindingMiner ( ) ) ; minerList . add ( new ChemicalAffectsThroughControlMiner ( ) ) ; minerList . add ( new ControlsTransportOfChemicalMiner ( ) ) ; minerList . add ( new InComplexWithMiner ( ) ) ; minerList . add ( new InteractsWithMiner ( ) ) ; minerList . add ( new NeighborOfMiner ( ) ) ; minerList . add ( new ReactsWithMiner ( ) ) ; minerList . add ( new UsedToProduceMiner ( ) ) ; minerList . add ( new RelatedGenesOfInteractionsMiner ( ) ) ; minerList . add ( new UbiquitousIDMiner ( ) ) ; } for ( Miner miner : minerList ) { if ( miner instanceof MinerAdapter ) ( ( MinerAdapter ) miner ) . setBlacklist ( blacklist ) ; } return minerList . toArray ( new Object [ minerList . size ( ) ] ) ; } | Gets the available pattern miners . First lists the parameter miners then adds the known miners in the package . |
6,342 | public static ValidatorResponse unmarshal ( String xml ) throws JAXBException { JAXBContext jaxbContext = JAXBContext . newInstance ( "org.biopax.validator.jaxb" ) ; Unmarshaller un = jaxbContext . createUnmarshaller ( ) ; Source src = new StreamSource ( new StringReader ( xml ) ) ; ValidatorResponse resp = un . unmarshal ( src , ValidatorResponse . class ) . getValue ( ) ; return resp ; } | Converts a biopax - validator XML response to the java object . |
6,343 | public static Set < ? extends BioPAXElement > getObjectBiopaxPropertyValues ( BioPAXElement bpe , String property ) { Set < BioPAXElement > values = new HashSet < BioPAXElement > ( ) ; EditorMap em = SimpleEditorMap . L3 ; @ SuppressWarnings ( "unchecked" ) PropertyEditor < BioPAXElement , BioPAXElement > editor = ( PropertyEditor < BioPAXElement , BioPAXElement > ) em . getEditorForProperty ( property , bpe . getModelInterface ( ) ) ; if ( editor != null ) { return editor . getValueFromBean ( bpe ) ; } else return values ; } | Example 1 . |
6,344 | public static Set getBiopaxPropertyValues ( BioPAXElement bpe , String property ) { EditorMap em = SimpleEditorMap . L3 ; @ SuppressWarnings ( "unchecked" ) PropertyEditor < BioPAXElement , Object > editor = ( PropertyEditor < BioPAXElement , Object > ) em . getEditorForProperty ( property , bpe . getModelInterface ( ) ) ; if ( editor != null ) { return editor . getValueFromBean ( bpe ) ; } else return null ; } | Example 2 . |
6,345 | public void handle ( RequestContext context ) throws SecurityProviderException , IOException { RedirectUtils . redirect ( context . getRequest ( ) , context . getResponse ( ) , getTargetUrl ( ) ) ; } | Redirects to the target URL . |
6,346 | public void addEnumValue ( final String enumName , final String enumValue ) { for ( MetadataEnum instance : enumList ) { if ( instance . getName ( ) . equals ( enumName ) && instance . getNamespace ( ) . equals ( getCurrentNamespace ( ) ) ) { instance . addValue ( enumValue ) ; return ; } } final MetadataEnum newEnum = new MetadataEnum ( enumName ) ; newEnum . addValue ( enumValue ) ; newEnum . setNamespace ( getCurrentNamespace ( ) ) ; newEnum . setSchemaName ( getCurrentSchmema ( ) ) ; newEnum . setPackageApi ( getCurrentPackageApi ( ) ) ; enumList . add ( newEnum ) ; } | Adds a enumeration value to the specified enumeration name . If no enumeration class is found then a new enumeration class will be created . |
6,347 | public void addGroupElement ( final String groupName , final MetadataElement groupElement ) { for ( MetadataItem item : groupList ) { if ( item . getName ( ) . equals ( groupName ) && item . getNamespace ( ) . equals ( getCurrentNamespace ( ) ) ) { item . getElements ( ) . add ( groupElement ) ; return ; } } final MetadataItem newItem = new MetadataItem ( groupName ) ; newItem . getElements ( ) . add ( groupElement ) ; newItem . setNamespace ( getCurrentNamespace ( ) ) ; newItem . setSchemaName ( getCurrentSchmema ( ) ) ; newItem . setPackageApi ( getCurrentPackageApi ( ) ) ; newItem . setPackageImpl ( getCurrentPackageImpl ( ) ) ; groupList . add ( newItem ) ; } | Adds a new element to the specific group element class . If no group element class is found then a new group element class . will be created . |
6,348 | public void addGroupReference ( final String groupName , final MetadataElement groupReference ) { groupReference . setRef ( getNamespaceValue ( groupReference . getRef ( ) ) ) ; for ( MetadataItem item : groupList ) { if ( item . getName ( ) . equals ( groupName ) && item . getNamespace ( ) . equals ( getCurrentNamespace ( ) ) ) { item . getReferences ( ) . add ( groupReference ) ; return ; } } final MetadataItem newItem = new MetadataItem ( groupName ) ; newItem . getReferences ( ) . add ( groupReference ) ; newItem . setNamespace ( getCurrentNamespace ( ) ) ; newItem . setSchemaName ( getCurrentSchmema ( ) ) ; newItem . setPackageApi ( getCurrentPackageApi ( ) ) ; newItem . setPackageImpl ( getCurrentPackageImpl ( ) ) ; groupList . add ( newItem ) ; } | Adds a new reference to the specific group element class . If no group element class is found then a new group element class . will be created . |
6,349 | public void addClassElement ( final String className , final MetadataElement classElement ) { classElement . setType ( getNamespaceValue ( classElement . getType ( ) ) ) ; if ( classElement . getMaxOccurs ( ) != null && ! classElement . getMaxOccurs ( ) . equals ( "1" ) ) { classElement . setMaxOccurs ( "unbounded" ) ; } for ( MetadataItem item : classList ) { if ( item . getName ( ) . equals ( className ) && item . getNamespace ( ) . equals ( getCurrentNamespace ( ) ) && item . getPackageApi ( ) . equals ( getCurrentPackageApi ( ) ) ) { for ( MetadataElement element : item . getElements ( ) ) { if ( element . getName ( ) . equals ( classElement . getName ( ) ) && ! classElement . getIsAttribute ( ) ) { element . setMaxOccurs ( "unbounded" ) ; return ; } } item . getElements ( ) . add ( classElement ) ; return ; } } final MetadataItem newItem = new MetadataItem ( className ) ; newItem . getElements ( ) . add ( classElement ) ; newItem . setNamespace ( getCurrentNamespace ( ) ) ; newItem . setSchemaName ( getCurrentSchmema ( ) ) ; newItem . setPackageApi ( getCurrentPackageApi ( ) ) ; newItem . setPackageImpl ( getCurrentPackageImpl ( ) ) ; classList . add ( newItem ) ; } | Adds a new element to the specific element class . If no element class is found then a new element class . will be created . |
6,350 | public void addClassReference ( final String className , final MetadataElement classReference ) { classReference . setRef ( getNamespaceValue ( classReference . getRef ( ) ) ) ; for ( MetadataItem item : classList ) { if ( item . getName ( ) . equals ( className ) && item . getNamespace ( ) . equals ( getCurrentNamespace ( ) ) && item . getPackageApi ( ) . equals ( getCurrentPackageApi ( ) ) ) { item . getReferences ( ) . add ( classReference ) ; return ; } } final MetadataItem newItem = new MetadataItem ( className ) ; newItem . getReferences ( ) . add ( classReference ) ; newItem . setNamespace ( getCurrentNamespace ( ) ) ; newItem . setSchemaName ( getCurrentSchmema ( ) ) ; newItem . setPackageApi ( getCurrentPackageApi ( ) ) ; newItem . setPackageImpl ( getCurrentPackageImpl ( ) ) ; classList . add ( newItem ) ; } | Adds a new reference to the specific element class . If no element class is found then a new element class . will be created . |
6,351 | public void preResolveDataTypes ( ) { for ( MetadataItem metadataClass : classList ) { preResolveDataTypeImpl ( metadataClass ) ; } for ( MetadataItem metadataClass : groupList ) { preResolveDataTypeImpl ( metadataClass ) ; } } | Replaces all data type occurrences found in the element types for all classes with the simple data type . This simplifies later the XSLT ddJavaAll step . |
6,352 | public final boolean isItemInsideView ( int position ) { float x = ( getXForItemAtPosition ( position ) + offsetX ) ; float y = ( getYForItemAtPosition ( position ) + offsetY ) ; float itemSize = getNoxItemSize ( ) ; int viewWidth = shapeConfig . getViewWidth ( ) ; boolean matchesHorizontally = x + itemSize >= 0 && x <= viewWidth ; float viewHeight = shapeConfig . getViewHeight ( ) ; boolean matchesVertically = y + itemSize >= 0 && y <= viewHeight ; return matchesHorizontally && matchesVertically ; } | Returns true if the view should be rendered inside the view window taking into account the offset applied by the scroll effect . |
6,353 | public int getNoxItemHit ( float x , float y ) { int noxItemPosition = - 1 ; for ( int i = 0 ; i < getNumberOfElements ( ) ; i ++ ) { float noxItemX = getXForItemAtPosition ( i ) + offsetX ; float noxItemY = getYForItemAtPosition ( i ) + offsetY ; float itemSize = getNoxItemSize ( ) ; boolean matchesHorizontally = x >= noxItemX && x <= noxItemX + itemSize ; boolean matchesVertically = y >= noxItemY && y <= noxItemY + itemSize ; if ( matchesHorizontally && matchesVertically ) { noxItemPosition = i ; break ; } } return noxItemPosition ; } | Returns the position of the NoxView if any of the previously configured NoxItem instances is hit . If there is no any NoxItem hit this method returns - 1 . |
6,354 | protected final void setNoxItemXPosition ( int position , float x ) { noxItemsXPositions [ position ] = x ; minX = ( int ) Math . min ( x , minX ) ; maxX = ( int ) Math . max ( x , maxX ) ; } | Configures the X position for a given NoxItem indicated with the item position . This method uses two counters to calculate the Shape minimum and maximum X position used to configure the Shape scroll . |
6,355 | protected final void setNoxItemYPosition ( int position , float y ) { noxItemsYPositions [ position ] = y ; minY = ( int ) Math . min ( y , minY ) ; maxY = ( int ) Math . max ( y , maxY ) ; } | Configures the Y position for a given NoxItem indicated with the item position . This method uses two counters to calculate the Shape minimum and maximum Y position used to configure the Shape scroll . |
6,356 | public static Optional < Class < ? > > getClassWithAnnotation ( final Class < ? > source , final Class < ? extends Annotation > annotationClass ) { Class < ? > nextSource = source ; while ( nextSource != Object . class ) { if ( nextSource . isAnnotationPresent ( annotationClass ) ) { return Optional . of ( nextSource ) ; } else { nextSource = nextSource . getSuperclass ( ) ; } } return Optional . empty ( ) ; } | Class that returns if a class or any subclass is annotated with given annotation . |
6,357 | private String removeFinalSlash ( String path ) { if ( path != null && ! path . isEmpty ( ) && path . endsWith ( "/" ) ) { return path . substring ( 0 , path . length ( ) - 1 ) ; } return path ; } | Due a bug in Pact we need to remove final slash character on path |
6,358 | private String getDataType ( String [ ] items ) { for ( String item : items ) { if ( XsdDatatypeEnum . ENTITIES . isDataType ( item ) ) { return item ; } } return items [ 0 ] ; } | Returns first data type which is a standard xsd data type . If no such data type found then the first one will be returned . |
6,359 | public static String resolveHomeDirectory ( String path ) { if ( path . startsWith ( "~" ) ) { return path . replace ( "~" , System . getProperty ( "user.home" ) ) ; } return path ; } | Method that changes any string starting with ~ to user . home property . |
6,360 | public void handle ( RequestContext context , AuthenticationException e ) throws SecurityProviderException , IOException { saveRequest ( context ) ; String loginFormUrl = getLoginFormUrl ( ) ; if ( StringUtils . isNotEmpty ( loginFormUrl ) ) { RedirectUtils . redirect ( context . getRequest ( ) , context . getResponse ( ) , loginFormUrl ) ; } else { sendError ( e , context ) ; } } | Saves the current request in the request cache and then redirects to the login form page . |
6,361 | public static void copyPackageInfo ( final MetadataParserPath path , final Metadata metadata , final boolean verbose ) throws IOException { for ( final MetadataDescriptor descriptor : metadata . getMetadataDescriptorList ( ) ) { if ( descriptor . getPathToPackageInfoApi ( ) != null ) { final File sourceFile = new File ( descriptor . getPathToPackageInfoApi ( ) ) ; final String destDirectory = path . pathToApi + File . separatorChar + descriptor . getPackageApi ( ) . replace ( '.' , '/' ) ; deleteExistingPackageInfo ( destDirectory , verbose ) ; copy ( sourceFile , destDirectory , verbose ) ; } if ( descriptor . getPathToPackageInfoImpl ( ) != null ) { final File sourceFile = new File ( descriptor . getPathToPackageInfoImpl ( ) ) ; final String destDirectory = path . pathToImpl + File . separatorChar + descriptor . getPackageImpl ( ) . replace ( '.' , '/' ) ; deleteExistingPackageInfo ( destDirectory , verbose ) ; copy ( sourceFile , destDirectory , verbose ) ; } } } | Copies the optional packageInfo files into the packages . |
6,362 | public static void deleteExistingPackageInfo ( final String destDirectory , final boolean verbose ) { final File htmlFile = new File ( destDirectory + File . separatorChar + PACKAGE_HTML_NAME ) ; final File javaFile = new File ( destDirectory + File . separatorChar + PACKAGE_JAVA_NAME ) ; final Boolean isHtmlDeleted = FileUtils . deleteQuietly ( htmlFile ) ; final Boolean isJavaDeleted = FileUtils . deleteQuietly ( javaFile ) ; if ( verbose ) { log . info ( String . format ( "File %s deleted: %s" , htmlFile . getAbsolutePath ( ) , isHtmlDeleted . toString ( ) ) ) ; log . info ( String . format ( "File %s deleted: %s" , javaFile . getAbsolutePath ( ) , isJavaDeleted . toString ( ) ) ) ; } } | Deletes package . html or package - info . java from the given directory . |
6,363 | public void execute ( ) throws BuildException { if ( path == null ) throw new BuildException ( "Path isn't defined" ) ; if ( descriptors == null ) throw new BuildException ( "Descriptors isn't defined" ) ; if ( descriptors . getData ( ) == null ) throw new BuildException ( "No descriptor defined" ) ; ClassLoader oldCl = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { if ( classpathRef != null || classpath != null ) { org . apache . tools . ant . types . Path p = new org . apache . tools . ant . types . Path ( getProject ( ) ) ; if ( classpathRef != null ) { org . apache . tools . ant . types . Reference reference = new org . apache . tools . ant . types . Reference ( getProject ( ) , classpathRef ) ; p . setRefid ( reference ) ; } if ( classpath != null ) { p . append ( classpath ) ; } ClassLoader cl = getProject ( ) . createClassLoader ( oldCl , p ) ; Thread . currentThread ( ) . setContextClassLoader ( cl ) ; } final List < Descriptor > data = descriptors . getData ( ) ; for ( Descriptor d : data ) { d . applyNamespaces ( ) ; } List < Javadoc > javadoc = null ; if ( javadocs != null ) { javadoc = javadocs . getData ( ) ; } final MetadataParser metadataParser = new MetadataParser ( ) ; metadataParser . parse ( path , data , javadoc , verbose ) ; } catch ( Throwable t ) { throw new BuildException ( t . getMessage ( ) , t ) ; } finally { Thread . currentThread ( ) . setContextClassLoader ( oldCl ) ; } } | Execute Ant task |
6,364 | protected boolean excludeRequest ( HttpServletRequest request ) { if ( ArrayUtils . isNotEmpty ( urlsToExclude ) ) { for ( String pathPattern : urlsToExclude ) { if ( pathMatcher . match ( pathPattern , HttpUtils . getRequestUriWithoutContextPath ( request ) ) ) { return true ; } } } return false ; } | Returns trues if the request should be excluded from processing . |
6,365 | protected boolean includeRequest ( HttpServletRequest request ) { if ( ArrayUtils . isNotEmpty ( urlsToInclude ) ) { for ( String pathPattern : urlsToInclude ) { if ( pathMatcher . match ( pathPattern , HttpUtils . getRequestUriWithoutContextPath ( request ) ) ) { return true ; } } } return false ; } | Returns trues if the request should be included for processing . |
6,366 | public void setShape ( Shape shape ) { validateShape ( shape ) ; this . shape = shape ; this . shape . calculate ( ) ; initializeScroller ( ) ; resetScroll ( ) ; } | Changes the Shape used to the one passed as argument . This method will refresh the view . |
6,367 | public boolean onTouchEvent ( MotionEvent event ) { super . onTouchEvent ( event ) ; boolean clickCaptured = processTouchEvent ( event ) ; boolean scrollCaptured = scroller != null && scroller . onTouchEvent ( event ) ; boolean singleTapCaptured = getGestureDetectorCompat ( ) . onTouchEvent ( event ) ; return clickCaptured || scrollCaptured || singleTapCaptured ; } | Delegates touch events to the scroller instance initialized previously to implement the scroll effect . If the scroller does not handle the MotionEvent NoxView will check if any NoxItem has been clicked to notify a previously configured OnNoxItemClickListener . |
6,368 | protected void onVisibilityChanged ( View changedView , int visibility ) { super . onVisibilityChanged ( changedView , visibility ) ; if ( changedView != this ) { return ; } if ( visibility == View . VISIBLE ) { resume ( ) ; } else { pause ( ) ; } } | Controls visibility changes to pause or resume this custom view and avoid performance problems . |
6,369 | private void updateShapeOffset ( ) { int offsetX = scroller . getOffsetX ( ) ; int offsetY = scroller . getOffsetY ( ) ; shape . setOffset ( offsetX , offsetY ) ; } | Checks the X and Y scroll offset to update that values into the Shape configured previously . |
6,370 | private void drawNoxItem ( Canvas canvas , int position , float left , float top ) { if ( noxItemCatalog . isBitmapReady ( position ) ) { Bitmap bitmap = noxItemCatalog . getBitmap ( position ) ; canvas . drawBitmap ( bitmap , left , top , paint ) ; } else if ( noxItemCatalog . isDrawableReady ( position ) ) { Drawable drawable = noxItemCatalog . getDrawable ( position ) ; drawNoxItemDrawable ( canvas , ( int ) left , ( int ) top , drawable ) ; } else if ( noxItemCatalog . isPlaceholderReady ( position ) ) { Drawable drawable = noxItemCatalog . getPlaceholder ( position ) ; drawNoxItemDrawable ( canvas , ( int ) left , ( int ) top , drawable ) ; } } | Draws a NoxItem during the onDraw method . |
6,371 | private void drawNoxItemDrawable ( Canvas canvas , int left , int top , Drawable drawable ) { if ( drawable != null ) { int itemSize = ( int ) noxConfig . getNoxItemSize ( ) ; drawable . setBounds ( left , top , left + itemSize , top + itemSize ) ; drawable . draw ( canvas ) ; } } | Draws a NoxItem drawable during the onDraw method given a canvas object and all the information needed to draw the Drawable passed as parameter . |
6,372 | private void createShape ( ) { if ( shape == null ) { float firstItemMargin = noxConfig . getNoxItemMargin ( ) ; float firstItemSize = noxConfig . getNoxItemSize ( ) ; int viewHeight = getMeasuredHeight ( ) ; int viewWidth = getMeasuredWidth ( ) ; int numberOfElements = noxItemCatalog . size ( ) ; ShapeConfig shapeConfig = new ShapeConfig ( numberOfElements , viewWidth , viewHeight , firstItemSize , firstItemMargin ) ; shape = ShapeFactory . getShapeByKey ( defaultShapeKey , shapeConfig ) ; } else { shape . setNumberOfElements ( noxItemCatalog . size ( ) ) ; } shape . calculate ( ) ; } | Initializes a Shape instance given the NoxView configuration provided programmatically or using XML styleable attributes . |
6,373 | private void initializeNoxViewConfig ( Context context , AttributeSet attrs , int defStyleAttr , int defStyleRes ) { noxConfig = new NoxConfig ( ) ; TypedArray attributes = context . getTheme ( ) . obtainStyledAttributes ( attrs , R . styleable . nox , defStyleAttr , defStyleRes ) ; initializeNoxItemSize ( attributes ) ; initializeNoxItemMargin ( attributes ) ; initializeNoxItemPlaceholder ( attributes ) ; initializeShapeConfig ( attributes ) ; initializeTransformationConfig ( attributes ) ; attributes . recycle ( ) ; } | Initializes a NoxConfig instance given the NoxView configuration provided programmatically or using XML styleable attributes . |
6,374 | private void initializeNoxItemSize ( TypedArray attributes ) { float noxItemSizeDefaultValue = getResources ( ) . getDimension ( R . dimen . default_nox_item_size ) ; float noxItemSize = attributes . getDimension ( R . styleable . nox_item_size , noxItemSizeDefaultValue ) ; noxConfig . setNoxItemSize ( noxItemSize ) ; } | Configures the nox item default size used in NoxConfig Shape and NoxItemCatalog to draw nox item instances during the onDraw execution . |
6,375 | private void initializeNoxItemMargin ( TypedArray attributes ) { float noxItemMarginDefaultValue = getResources ( ) . getDimension ( R . dimen . default_nox_item_margin ) ; float noxItemMargin = attributes . getDimension ( R . styleable . nox_item_margin , noxItemMarginDefaultValue ) ; noxConfig . setNoxItemMargin ( noxItemMargin ) ; } | Configures the nox item default margin used in NoxConfig Shape and NoxItemCatalog to draw nox item instances during the onDraw execution . |
6,376 | private void initializeNoxItemPlaceholder ( TypedArray attributes ) { Drawable placeholder = attributes . getDrawable ( R . styleable . nox_item_placeholder ) ; if ( placeholder == null ) { placeholder = getContext ( ) . getResources ( ) . getDrawable ( R . drawable . ic_nox ) ; } noxConfig . setPlaceholder ( placeholder ) ; } | Configures the placeholder used if there is no another placeholder configured in the NoxItem instances during the onDraw execution . |
6,377 | private void initializeShapeConfig ( TypedArray attributes ) { defaultShapeKey = attributes . getInteger ( R . styleable . nox_shape , ShapeFactory . FIXED_CIRCULAR_SHAPE_KEY ) ; } | Configures the Shape used to show the list of NoxItems . |
6,378 | private void initializeTransformationConfig ( TypedArray attributes ) { useCircularTransformation = attributes . getBoolean ( R . styleable . nox_use_circular_transformation , true ) ; } | Configures the visual transformation applied to the NoxItem resources loaded images downloaded from the internet and resources loaded from the system . |
6,379 | private GestureDetectorCompat getGestureDetectorCompat ( ) { if ( gestureDetector == null ) { GestureDetector . OnGestureListener gestureListener = new SimpleOnGestureListener ( ) { public boolean onSingleTapUp ( MotionEvent e ) { boolean handled = false ; int position = shape . getNoxItemHit ( e . getX ( ) , e . getY ( ) ) ; if ( position >= 0 ) { handled = true ; NoxItem noxItem = noxItemCatalog . getNoxItem ( position ) ; listener . onNoxItemClicked ( position , noxItem ) ; } return handled ; } } ; gestureDetector = new GestureDetectorCompat ( getContext ( ) , gestureListener ) ; } return gestureDetector ; } | Returns a GestureDetectorCompat lazy instantiated created to handle single tap events and detect if a NoxItem has been clicked to notify the previously configured listener . |
6,380 | public void traverseAndFilter ( final TreeWalker walker , final String indent , final Metadata metadata , final StringBuilder sb ) { final Node parend = walker . getCurrentNode ( ) ; final boolean isLogged = appendText ( indent , ( Element ) parend , sb ) ; for ( final Filter filter : filterList ) { if ( filter . filter ( metadata , walker ) ) { appendText ( " catched by: " + filter . getClass ( ) . getSimpleName ( ) , sb ) ; break ; } } if ( isLogged ) { appendText ( "\n" , sb ) ; } for ( Node n = walker . firstChild ( ) ; n != null ; n = walker . nextSibling ( ) ) { traverseAndFilter ( walker , indent + " " , metadata , sb ) ; } walker . setCurrentNode ( parend ) ; } | Traverses the DOM and applies the filters for each visited node . |
6,381 | private boolean appendText ( final String text , final StringBuilder sb ) { if ( sb != null ) { if ( text != null && text . indexOf ( ":annotation" ) < 0 && text . indexOf ( ":documentation" ) < 0 ) { sb . append ( text ) ; return true ; } } return false ; } | Appends the given text . |
6,382 | private boolean appendText ( final String indent , final Element element , final StringBuilder sb ) { if ( sb != null ) { if ( element . getTagName ( ) . indexOf ( ":annotation" ) < 0 && element . getTagName ( ) . indexOf ( ":documentation" ) < 0 ) { sb . append ( String . format ( ELEMENT_LOG , indent , element . getTagName ( ) , element . getAttribute ( "name" ) ) ) ; return true ; } } return false ; } | Appends the given element . |
6,383 | public static void addProviderProfileInfo ( Profile profile , UserProfile providerProfile ) { String email = providerProfile . getEmail ( ) ; if ( StringUtils . isEmpty ( email ) ) { throw new IllegalStateException ( "No email included in provider profile" ) ; } String username = providerProfile . getUsername ( ) ; if ( StringUtils . isEmpty ( username ) ) { username = email ; } String firstName = providerProfile . getFirstName ( ) ; String lastName = providerProfile . getLastName ( ) ; profile . setUsername ( username ) ; profile . setEmail ( email ) ; profile . setAttribute ( FIRST_NAME_ATTRIBUTE_NAME , firstName ) ; profile . setAttribute ( LAST_NAME_ATTRIBUTE_NAME , lastName ) ; } | Adds the info from the provider profile to the specified profile . |
6,384 | public static Profile createProfile ( Connection < ? > connection ) { Profile profile = new Profile ( ) ; UserProfile providerProfile = connection . fetchUserProfile ( ) ; String email = providerProfile . getEmail ( ) ; if ( StringUtils . isEmpty ( email ) ) { throw new IllegalStateException ( "No email included in provider profile" ) ; } String username = providerProfile . getUsername ( ) ; if ( StringUtils . isEmpty ( username ) ) { username = email ; } String firstName = providerProfile . getFirstName ( ) ; String lastName = providerProfile . getLastName ( ) ; String displayName ; if ( StringUtils . isNotEmpty ( connection . getDisplayName ( ) ) ) { displayName = connection . getDisplayName ( ) ; } else { displayName = firstName + " " + lastName ; } profile . setUsername ( username ) ; profile . setEmail ( email ) ; profile . setAttribute ( FIRST_NAME_ATTRIBUTE_NAME , firstName ) ; profile . setAttribute ( LAST_NAME_ATTRIBUTE_NAME , lastName ) ; profile . setAttribute ( DISPLAY_NAME_ATTRIBUTE_NAME , displayName ) ; if ( StringUtils . isNotEmpty ( connection . getImageUrl ( ) ) ) { profile . setAttribute ( AVATAR_LINK_ATTRIBUTE_NAME , connection . getImageUrl ( ) ) ; } return profile ; } | Creates a profile from the specified connection . |
6,385 | public void handle ( RequestContext context , AccessDeniedException e ) throws SecurityProviderException , IOException { saveException ( context , e ) ; if ( StringUtils . isNotEmpty ( getErrorPageUrl ( ) ) ) { forwardToErrorPage ( context ) ; } else { sendError ( e , context ) ; } } | Forwards to the error page but if not error page was specified a 403 error is sent . |
6,386 | public void handle ( RequestContext context , AuthenticationException e ) throws SecurityProviderException , IOException { String targetUrl = getTargetUrl ( ) ; if ( StringUtils . isNotEmpty ( targetUrl ) ) { RedirectUtils . redirect ( context . getRequest ( ) , context . getResponse ( ) , targetUrl ) ; } else { sendError ( e , context ) ; } } | Redirects the response to target URL if target URL is not empty . If not a 401 UNAUTHORIZED error is sent . |
6,387 | Bitmap getBitmap ( int position ) { return bitmaps [ position ] != null ? bitmaps [ position ] . get ( ) : null ; } | Returns the bitmap associated to a NoxItem instance given a position or null if the resource wasn t downloaded . |
6,388 | Drawable getPlaceholder ( int position ) { Drawable placeholder = placeholders [ position ] ; if ( placeholder == null && defaultPlaceholder != null ) { Drawable clone = defaultPlaceholder . getConstantState ( ) . newDrawable ( ) ; placeholders [ position ] = clone ; placeholder = clone ; } return placeholder ; } | Returns the defaultPlaceholder associated to a NoxItem instance given a position or null if the resource wasn t downloaded or previously configured . |
6,389 | void load ( int position , boolean useCircularTransformation ) { if ( isDownloading ( position ) ) { return ; } NoxItem noxItem = noxItems . get ( position ) ; if ( ( noxItem . hasUrl ( ) && ! isBitmapReady ( position ) ) || noxItem . hasResourceId ( ) && ! isDrawableReady ( position ) ) { loading [ position ] = true ; loadNoxItem ( position , noxItem , useCircularTransformation ) ; } } | Given a position associated to a NoxItem starts the NoxItem resources download . This load will download the resources associated to the NoxItem only if wasn t previously downloaded or the download is not being performed . |
6,390 | public void recreate ( ) { int newSize = noxItems . size ( ) ; WeakReference < Bitmap > newBitmaps [ ] = new WeakReference [ newSize ] ; Drawable newDrawables [ ] = new Drawable [ newSize ] ; Drawable newPlaceholders [ ] = new Drawable [ newSize ] ; boolean newLoadings [ ] = new boolean [ newSize ] ; ImageLoader . Listener newListeners [ ] = new ImageLoader . Listener [ newSize ] ; float length = Math . min ( bitmaps . length , newSize ) ; for ( int i = 0 ; i < length ; i ++ ) { newBitmaps [ i ] = bitmaps [ i ] ; newDrawables [ i ] = drawables [ i ] ; newPlaceholders [ i ] = placeholders [ i ] ; newLoadings [ i ] = loading [ i ] ; newListeners [ i ] = listeners [ i ] ; } bitmaps = newBitmaps ; drawables = newDrawables ; placeholders = newPlaceholders ; loading = newLoadings ; listeners = newListeners ; } | Regenerates all the internal data structures . This method should be called when the number of nox items in the catalog has changed externally . |
6,391 | private void loadNoxItem ( final int position , NoxItem noxItem , boolean useCircularTransformation ) { imageLoader . load ( noxItem . getUrl ( ) ) . load ( noxItem . getResourceId ( ) ) . withPlaceholder ( noxItem . getPlaceholderId ( ) ) . size ( noxItemSize ) . useCircularTransformation ( useCircularTransformation ) . notify ( getImageLoaderListener ( position ) ) ; } | Starts the resource download given a NoxItem instance and a given position . |
6,392 | private ImageLoader . Listener getImageLoaderListener ( final int position ) { if ( listeners [ position ] == null ) { listeners [ position ] = new NoxItemCatalogImageLoaderListener ( position , this ) ; } return listeners [ position ] ; } | Returns the ImageLoader . Listener associated to a NoxItem given a position . If the ImageLoader . Listener wasn t previously created creates a new instance . |
6,393 | private void checkArguments ( final MetadataParserPath path , final List < ? > confList ) { if ( path == null ) { throw new IllegalArgumentException ( "Invalid configuration. The 'path' element missing!" ) ; } else if ( confList == null ) { throw new IllegalArgumentException ( "Invalid configuration. At least one 'descriptor' element has to be defined!" ) ; } else if ( confList . isEmpty ( ) ) { throw new IllegalArgumentException ( "Invalid configuration. At least one 'descriptor' element has to be defined!" ) ; } } | Validates the given arguments . |
6,394 | public static List < String > getTenantNames ( TenantService tenantService ) throws ProfileException { List < Tenant > tenants = tenantService . getAllTenants ( ) ; List < String > tenantNames = new ArrayList < > ( tenants . size ( ) ) ; if ( CollectionUtils . isNotEmpty ( tenants ) ) { for ( Tenant tenant : tenants ) { tenantNames . add ( tenant . getName ( ) ) ; } } return tenantNames ; } | Returns a list with the names of all tenants . |
6,395 | public static String getCurrentTenantName ( ) { Profile profile = SecurityUtils . getCurrentProfile ( ) ; if ( profile != null ) { return profile . getTenant ( ) ; } else { return null ; } } | Returns the current tenant name which is the tenant of the currently authenticated profile . |
6,396 | public static String getAttributeValue ( final Element element , final String name ) { final Node node = element . getAttributes ( ) . getNamedItem ( name ) ; if ( node != null ) { return node . getNodeValue ( ) ; } return null ; } | Returns the attribute value for the given attribute name . |
6,397 | public static Node getNextParentNodeWithAttr ( final Node parent , final String attrName ) { Node parentNode = parent ; Element parendElement = ( Element ) parentNode ; Node valueNode = parendElement . getAttributes ( ) . getNamedItem ( attrName ) ; while ( valueNode == null ) { parentNode = parentNode . getParentNode ( ) ; if ( parentNode != null ) { if ( parentNode . getNodeType ( ) == Node . ELEMENT_NODE ) { parendElement = ( Element ) parentNode ; valueNode = parendElement . getAttributes ( ) . getNamedItem ( attrName ) ; } } else { break ; } } return parendElement ; } | Returns the next parent node which has the specific attribute name defined . |
6,398 | public static boolean hasChildsOf ( final Element parentElement , XsdElementEnum child ) { NodeList nodeList = parentElement . getChildNodes ( ) ; for ( int i = 0 ; i < nodeList . getLength ( ) ; i ++ ) { final Node childNode = nodeList . item ( i ) ; if ( childNode . getNodeType ( ) == Node . ELEMENT_NODE ) { final Element childElement = ( Element ) childNode ; if ( child . isTagNameEqual ( childElement . getTagName ( ) ) ) { return true ; } if ( childElement . hasChildNodes ( ) ) { if ( hasChildsOf ( childElement , child ) ) { return true ; } } } } return false ; } | Checks the existence of a w3c child element . |
6,399 | public static boolean hasParentOf ( final Element parentElement , XsdElementEnum parentEnum ) { Node parent = parentElement . getParentNode ( ) ; while ( parent != null ) { if ( parent . getNodeType ( ) == Node . ELEMENT_NODE ) { final Element parentElm = ( Element ) parent ; if ( parentEnum . isTagNameEqual ( parentElm . getTagName ( ) ) ) { return true ; } } parent = parent . getParentNode ( ) ; } return false ; } | Checks for the first parent node occurrence of the a w3c parentEnum element . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.