idx
int64 0
41.2k
| question
stringlengths 73
5.81k
| target
stringlengths 5
918
|
|---|---|---|
39,800
|
public void clear ( ) { itemBox . setValue ( "" ) ; label . removeStyleName ( CssName . ACTIVE ) ; Collection < Widget > values = suggestionMap . values ( ) ; for ( Widget widget : values ) { Widget parent = widget . getParent ( ) ; if ( parent instanceof ListItem ) { parent . removeFromParent ( ) ; } } suggestionMap . clear ( ) ; clearStatusText ( ) ; }
|
Clear the chip items on the autocomplete box
|
39,801
|
protected String nativeCaptureToDataURL ( CanvasElement canvas , Element element , String mimeType ) { VideoElement videoElement = ( VideoElement ) element ; int width = videoElement . getVideoWidth ( ) ; int height = videoElement . getVideoHeight ( ) ; if ( Double . isNaN ( width ) || Double . isNaN ( height ) ) { width = videoElement . getClientWidth ( ) ; height = videoElement . getClientHeight ( ) ; } canvas . setWidth ( width ) ; canvas . setHeight ( height ) ; Context2d context = canvas . getContext2d ( ) ; context . drawImage ( videoElement , 0 , 0 , width , height ) ; return canvas . toDataUrl ( mimeType ) ; }
|
Native call to capture the frame of the video stream .
|
39,802
|
public static boolean isSupported ( ) { return Navigator . webkitGetUserMedia != null || Navigator . getUserMedia != null || Navigator . mozGetUserMedia != null || Navigator . msGetUserMedia != null ; }
|
Tests if the browser supports the Streams API . This should be called before creating any MaterialCameraCapture widgets to avoid errors on the browser .
|
39,803
|
public void setLineDistanceWidth ( int lineDistanceWidth ) { if ( divLine . isAttached ( ) ) { divLine . setWidth ( lineDistanceWidth + "px" ) ; } else { divLine . addAttachHandler ( event -> divLine . setWidth ( lineDistanceWidth + "px" ) ) ; } }
|
Will set the distance width of the step line from another step .
|
39,804
|
public void crop ( String url , Type type ) { setUrl ( url ) ; bind ( url , ( ) -> crop ( type ) ) ; }
|
Cropped the image with given URL and result type
|
39,805
|
public void bind ( String url , Functions . Func callback ) { cropper . croppie ( "bind" , url ) . then ( ( result , object ) -> { callback . call ( ) ; return true ; } ) ; }
|
Bind an image the cropper . Returns a promise to be resolved when the image has been loaded and the cropper has been initialized .
|
39,806
|
public void setPopupPosition ( int popupX , int popupY ) { this . popupX = popupX ; this . popupY = popupY ; setLeft ( popupX ) ; setTop ( popupY ) ; }
|
Set the popup position of the context menu
|
39,807
|
protected void masonryRemove ( Widget target ) { this . target = target ; if ( target != sizerDiv ) { super . remove ( target ) ; reload ( ) ; } }
|
Remove the item with Masonry support
|
39,808
|
protected void revalidateLayout ( ) { for ( MaterialIcon icon : iconList ) { icon . removeFromParent ( ) ; } iconList . clear ( ) ; MouseOutHandler outHandler = event -> { if ( ! isEnabled ( ) || ! isEditable ( ) ) { return ; } revalidateSelection ( currentRating ) ; } ; for ( int i = 0 ; i < maxRating ; i ++ ) { final int rating = i + 1 ; MaterialIcon icon = new MaterialIcon ( unselectedRatingIcon ) ; registerHandler ( icon . addClickHandler ( event -> { if ( ! isEnabled ( ) || ! isEditable ( ) ) { return ; } setValue ( rating , true ) ; } ) ) ; registerHandler ( icon . addMouseOverHandler ( event -> { if ( ! isEnabled ( ) || ! isEditable ( ) ) { return ; } revalidateSelection ( rating ) ; } ) ) ; registerHandler ( icon . addMouseOutHandler ( outHandler ) ) ; add ( icon ) ; iconList . add ( icon ) ; } revalidateSelection ( currentRating ) ; }
|
Method called internally by the component to re - validate the number of icons when the maximum rating is changed .
|
39,809
|
protected void revalidateSelection ( int rating ) { for ( MaterialIcon icon : iconList ) { icon . removeStyleName ( AddinsCssName . MATERIAL_RATING_UNSELECTED ) ; icon . removeStyleName ( AddinsCssName . MATERIAL_RATING_SELECTED ) ; } for ( int i = 0 ; i < rating && i < iconList . size ( ) ; i ++ ) { MaterialIcon icon = iconList . get ( i ) ; icon . setIconType ( selectedRatingIcon ) ; icon . addStyleName ( AddinsCssName . MATERIAL_RATING_SELECTED ) ; } for ( int i = rating ; i < iconList . size ( ) ; i ++ ) { MaterialIcon icon = iconList . get ( i ) ; icon . setIconType ( unselectedRatingIcon ) ; icon . addStyleName ( AddinsCssName . MATERIAL_RATING_UNSELECTED ) ; } }
|
Method called internally by the component to revalidade selections by the user switching the icons accordingly .
|
39,810
|
public void setDimension ( int width , int height ) { setWidth ( String . valueOf ( width ) ) ; setHeight ( String . valueOf ( height ) ) ; reload ( ) ; }
|
Allowing to set the dimension of the Avatar component .
|
39,811
|
public static void animate ( Widget source , final Widget target ) { animate ( source . getElement ( ) , target . getElement ( ) ) ; }
|
Helper method to apply the path animator .
|
39,812
|
public static void reverseAnimate ( final Widget source , final Widget target ) { reverseAnimate ( source . getElement ( ) , target . getElement ( ) ) ; }
|
Helper method to reverse animate the source element to target element .
|
39,813
|
public static void reverseAnimate ( Widget source , Widget target , Functions . Func reverseCallback ) { reverseAnimate ( source . getElement ( ) , target . getElement ( ) , reverseCallback ) ; }
|
Helper method to reverse animate the source element to target element with reverse callback .
|
39,814
|
public static void reverseAnimate ( Element sourceElement , Element targetElement , Functions . Func reverseCallback ) { MaterialPathAnimator animator = new MaterialPathAnimator ( ) ; animator . setSourceElement ( sourceElement ) ; animator . setTargetElement ( targetElement ) ; animator . setReverseCallback ( reverseCallback ) ; animator . reverseAnimate ( ) ; }
|
Helper method to reverse animate the source element to target element with reverse callback
|
39,815
|
public void setValue ( Double value , boolean fireEvents , boolean autoStart ) { super . setValue ( value , fireEvents ) ; setEndValue ( value ) ; if ( autoStart ) { start ( ) ; } }
|
Provide a better control whether you want to automatically start the counting of the new value . By Default it will start counting with the given value .
|
39,816
|
public void open ( ) { if ( ! isAttached ( ) ) { RootPanel . get ( ) . add ( this ) ; } windowCount ++ ; if ( windowOverlay != null && ! windowOverlay . isAttached ( ) ) { RootPanel . get ( ) . add ( windowOverlay ) ; } if ( fullsceenOnMobile && Window . matchMedia ( Resolution . ALL_MOBILE . asMediaQuery ( ) ) ) { setMaximize ( true ) ; } if ( openAnimation == null ) { getOpenMixin ( ) . setOn ( true ) ; OpenEvent . fire ( this , true ) ; } else { setOpacity ( 0 ) ; Scheduler . get ( ) . scheduleDeferred ( ( ) -> { getOpenMixin ( ) . setOn ( true ) ; openAnimation . animate ( this , ( ) -> OpenEvent . fire ( this , true ) ) ; } ) ; } }
|
Open the window .
|
39,817
|
public void close ( ) { RootPanel . get ( ) . getElement ( ) . getStyle ( ) . setCursor ( Style . Cursor . DEFAULT ) ; windowCount -- ; if ( closeAnimation == null ) { getOpenMixin ( ) . setOn ( false ) ; if ( windowOverlay != null && windowOverlay . isAttached ( ) && windowCount < 1 ) { windowOverlay . removeFromParent ( ) ; } CloseEvent . fire ( this , false ) ; } else { closeAnimation . animate ( this , ( ) -> { getOpenMixin ( ) . setOn ( false ) ; if ( windowOverlay != null && windowOverlay . isAttached ( ) && windowCount < 1 ) { windowOverlay . removeFromParent ( ) ; } CloseEvent . fire ( this , false ) ; } ) ; } }
|
Close the window .
|
39,818
|
protected void expandItems ( MaterialTreeItem item ) { item . expand ( ) ; item . setHide ( true ) ; item . getTreeItems ( ) . forEach ( this :: expandItems ) ; }
|
Recursive function to expand each tree item .
|
39,819
|
public void deselectSelectedItem ( ) { if ( selectedItem != null ) { clearSelectedStyles ( selectedItem ) ; setSelectedItem ( null ) ; SelectionEvent . fire ( this , null ) ; } }
|
Deselect selected tree item
|
39,820
|
protected void collapseItems ( MaterialTreeItem item ) { item . collapse ( ) ; item . setHide ( false ) ; item . getTreeItems ( ) . forEach ( this :: collapseItems ) ; }
|
Recursive function to collapse each tree item .
|
39,821
|
public void nextStep ( ) { if ( currentStepIndex >= getWidgetCount ( ) - 1 ) { CompleteEvent . fire ( MaterialStepper . this , currentStepIndex + 1 ) ; } else { Widget w = getWidget ( currentStepIndex ) ; if ( w instanceof MaterialStep ) { MaterialStep step = ( MaterialStep ) w ; step . setActive ( false ) ; step . setSuccessText ( step . getDescription ( ) ) ; int nextStepIndex = getWidgetIndex ( step ) + 1 ; if ( nextStepIndex >= 0 ) { for ( int i = nextStepIndex ; i < getWidgetCount ( ) ; i ++ ) { w = getWidget ( i ) ; if ( ! ( w instanceof MaterialStep ) ) { continue ; } MaterialStep nextStep = ( MaterialStep ) w ; if ( nextStep . isEnabled ( ) && nextStep . isVisible ( ) ) { nextStep . setActive ( true ) ; setCurrentStepIndex ( i ) ; NextEvent . fire ( MaterialStepper . this ) ; break ; } } } } } }
|
Go to next step used by linear stepper .
|
39,822
|
public void prevStep ( ) { if ( currentStepIndex > 0 ) { Widget w = getWidget ( currentStepIndex ) ; if ( w instanceof MaterialStep ) { MaterialStep step = ( MaterialStep ) w ; step . setActive ( false ) ; int prevStepIndex = getWidgetIndex ( step ) - 1 ; if ( prevStepIndex >= 0 ) { for ( int i = prevStepIndex ; i >= 0 ; i -- ) { w = getWidget ( i ) ; if ( ! ( w instanceof MaterialStep ) ) { continue ; } MaterialStep prevStep = ( MaterialStep ) w ; if ( prevStep . isEnabled ( ) && prevStep . isVisible ( ) ) { prevStep . setActive ( true ) ; setCurrentStepIndex ( i ) ; PreviousEvent . fire ( MaterialStepper . this ) ; break ; } } } } } else { GWT . log ( "You have reached the minimum step." ) ; } }
|
Go to previous step used by linear stepper .
|
39,823
|
public void goToStep ( int step ) { for ( int i = 0 ; i < getWidgetCount ( ) ; i ++ ) { Widget w = getWidget ( i ) ; if ( w instanceof MaterialStep ) { ( ( MaterialStep ) w ) . setActive ( false ) ; } } Widget w = getWidget ( step - 1 ) ; if ( w instanceof MaterialStep ) { ( ( MaterialStep ) w ) . setActive ( true ) ; } setCurrentStepIndex ( step - 1 ) ; }
|
Go to specific step manually by setting which step index you want to go .
|
39,824
|
public void goToStepId ( int id ) { for ( int i = 0 ; i < getWidgetCount ( ) ; i ++ ) { Widget w = getWidget ( i ) ; if ( w instanceof MaterialStep ) { MaterialStep materialStep = ( MaterialStep ) w ; boolean active = materialStep . getStep ( ) == id ; materialStep . setActive ( active ) ; if ( active ) { setCurrentStepIndex ( i ) ; } } } }
|
Go to the step with the specified step id .
|
39,825
|
public MaterialStep getCurrentStep ( ) { if ( currentStepIndex > getWidgetCount ( ) - 1 || currentStepIndex < 0 ) { return null ; } Widget w = getWidget ( currentStepIndex ) ; if ( w instanceof MaterialStep ) { return ( MaterialStep ) w ; } return null ; }
|
Gets the current step component .
|
39,826
|
public void showFeedback ( String feedbackText ) { feedbackSpan . setText ( feedbackText ) ; new MaterialAnimation ( ) . transition ( Transition . FADEINUP ) . duration ( 400 ) . animate ( feedbackSpan ) ; MaterialLoader . loading ( true , getCurrentStep ( ) . getDivBody ( ) ) ; add ( divFeedback ) ; }
|
Show feedback message and circular loader on body container
|
39,827
|
public void onSelection ( SelectionEvent < MaterialStep > event ) { if ( stepSkippingAllowed ) { if ( event . getSelectedItem ( ) . getState ( ) == State . SUCCESS ) { goToStep ( event . getSelectedItem ( ) ) ; } } }
|
Called when a step title is clicked .
|
39,828
|
public void open ( ) { setCutOutStyle ( ) ; if ( targetElement == null ) { throw new IllegalStateException ( "The target element should be set before calling open()." ) ; } targetElement . scrollIntoView ( ) ; if ( computedBackgroundColor == null ) { setupComputedBackgroundColor ( ) ; } Style docStyle = Document . get ( ) . getDocumentElement ( ) . getStyle ( ) ; viewportOverflow = docStyle . getOverflow ( ) ; docStyle . setProperty ( "overflow" , "hidden" ) ; if ( backgroundSize == null ) { backgroundSize = body ( ) . width ( ) + 300 + "px" ; } setupTransition ( ) ; if ( animated ) { focusElement . getStyle ( ) . setProperty ( "boxShadow" , "0px 0px 0px 0rem " + computedBackgroundColor ) ; Scheduler . get ( ) . scheduleDeferred ( ( ) -> { focusElement . getStyle ( ) . setProperty ( "boxShadow" , "0px 0px 0px " + backgroundSize + " " + computedBackgroundColor ) ; } ) ; } else { focusElement . getStyle ( ) . setProperty ( "boxShadow" , "0px 0px 0px " + backgroundSize + " " + computedBackgroundColor ) ; } if ( circle ) { focusElement . getStyle ( ) . setProperty ( "WebkitBorderRadius" , "50%" ) ; focusElement . getStyle ( ) . setProperty ( "borderRadius" , "50%" ) ; focusElement . getStyle ( ) . setProperty ( "webkitBorderTopLeftRadius" , "49.9%" ) ; focusElement . getStyle ( ) . setProperty ( "borderTopLeftRadius" , "49.9%" ) ; } else { focusElement . getStyle ( ) . clearProperty ( "WebkitBorderRadius" ) ; focusElement . getStyle ( ) . clearProperty ( "borderRadius" ) ; focusElement . getStyle ( ) . clearProperty ( "webkitBorderTopLeftRadius" ) ; focusElement . getStyle ( ) . clearProperty ( "borderTopLeftRadius" ) ; } setupCutOutPosition ( focusElement , targetElement , cutOutPadding , circle ) ; setupWindowHandlers ( ) ; getElement ( ) . getStyle ( ) . clearDisplay ( ) ; if ( getParent ( ) == null ) { autoAddedToDocument = true ; RootPanel . get ( ) . add ( this ) ; } OpenEvent . fire ( this , this ) ; }
|
Opens the dialog cut out taking all the screen . The target element should be set before calling this method .
|
39,829
|
public void close ( boolean autoClosed ) { Document . get ( ) . getDocumentElement ( ) . getStyle ( ) . setProperty ( "overflow" , viewportOverflow ) ; getElement ( ) . getStyle ( ) . setDisplay ( Display . NONE ) ; getHandlerRegistry ( ) . clearHandlers ( ) ; if ( autoAddedToDocument ) { this . removeFromParent ( ) ; autoAddedToDocument = false ; } CloseEvent . fire ( this , this , autoClosed ) ; }
|
Closes the cut out .
|
39,830
|
protected void setupWindowHandlers ( ) { registerHandler ( Window . addResizeHandler ( event -> setupCutOutPosition ( focusElement , targetElement , cutOutPadding , circle ) ) ) ; registerHandler ( Window . addWindowScrollHandler ( event -> setupCutOutPosition ( focusElement , targetElement , cutOutPadding , circle ) ) ) ; }
|
Configures a resize handler and a scroll handler on the window to properly adjust the Cut Out .
|
39,831
|
protected void setupComputedBackgroundColor ( ) { MaterialWidget temp = new MaterialWidget ( Document . get ( ) . createDivElement ( ) ) ; temp . setBackgroundColor ( backgroundColor ) ; Style style = temp . getElement ( ) . getStyle ( ) ; style . setPosition ( Position . FIXED ) ; style . setWidth ( 1 , Unit . PX ) ; style . setHeight ( 1 , Unit . PX ) ; style . setLeft ( - 10 , Unit . PX ) ; style . setTop ( - 10 , Unit . PX ) ; style . setZIndex ( - 10000 ) ; String computed = ColorHelper . setupComputedBackgroundColor ( backgroundColor ) ; if ( opacity < 1 && computed . startsWith ( "rgb(" ) ) { computed = computed . replace ( "rgb(" , "rgba(" ) . replace ( ")" , ", " + opacity + ")" ) ; } computedBackgroundColor = computed ; }
|
Gets the computed background color based on the backgroundColor CSS class .
|
39,832
|
public void setLanguage ( Language language ) { this . language = language ; this . label . setText ( language . getName ( ) ) ; this . image . setUrl ( language . getImage ( ) ) ; }
|
Update the ui for the name and image components .
|
39,833
|
protected UploadFile convertUploadFile ( File file ) { Date lastModifiedDate = new Date ( ) ; if ( file . lastModifiedDate != null && ! file . lastModifiedDate . isEmpty ( ) ) { lastModifiedDate = new Date ( file . lastModifiedDate ) ; } return new UploadFile ( file . name , lastModifiedDate , Double . parseDouble ( file . size ) , file . type ) ; }
|
Converts a Native File Object to Upload File object
|
39,834
|
public double getThickness ( ) { return options . thickness != null ? Double . parseDouble ( options . thickness . replace ( "px" , "" ) ) : null ; }
|
Get the bar s thickness in px .
|
39,835
|
public Axis getAxis ( ) { return options . orientation != null ? Axis . fromStyleName ( options . orientation ) : null ; }
|
Get the axis orientation of splitter component .
|
39,836
|
public Dock getDock ( ) { return options . dock != null ? Dock . fromStyleName ( options . dock ) : null ; }
|
Get the dock value .
|
39,837
|
public void addItem ( String text , T value , OptGroup optGroup ) { if ( ! values . contains ( value ) ) { values . add ( value ) ; optGroup . add ( buildOption ( text , value ) ) ; } }
|
Add item directly to combobox component with existing OptGroup
|
39,838
|
public Option addItem ( String text , T value ) { if ( ! values . contains ( value ) ) { Option option = buildOption ( text , value ) ; values . add ( value ) ; listbox . add ( option ) ; return option ; } return null ; }
|
Add Value directly to combobox component
|
39,839
|
protected Option buildOption ( String text , T value ) { Option option = new Option ( ) ; option . setText ( text ) ; option . setValue ( keyFactory . generateKey ( value ) ) ; return option ; }
|
Build the Option Element with provided params
|
39,840
|
public T getSingleValue ( ) { List < T > values = getSelectedValue ( ) ; if ( ! values . isEmpty ( ) ) { return values . get ( 0 ) ; } return null ; }
|
Only return a single value even if multi support is activate .
|
39,841
|
public void setSingleValue ( T value , boolean fireEvents ) { int index = this . values . indexOf ( value ) ; if ( index < 0 && value instanceof String ) { index = getIndexByString ( ( String ) value ) ; } if ( index > - 1 ) { List < T > before = getValue ( ) ; setSelectedIndex ( index ) ; if ( fireEvents ) { ValueChangeEvent . fireIfNotEqual ( this , before , Collections . singletonList ( value ) ) ; } } }
|
Set the selected value using a single item generally used in single selection mode .
|
39,842
|
public void setFillColor ( Color fillColor ) { this . fillColor = fillColor ; options . fill = ColorHelper . setupComputedBackgroundColor ( fillColor ) ; }
|
Set the fillColor of the circular progress
|
39,843
|
public void setEmptyFillColor ( Color emptyFillColor ) { this . emptyFillColor = emptyFillColor ; options . emptyFill = ColorHelper . setupComputedBackgroundColor ( emptyFillColor ) ; }
|
Set the empty fill color of the circular progress
|
39,844
|
public void add ( String text , Image image ) { this . imageElem = image . getElement ( ) . toString ( ) ; add ( text + image ) ; }
|
Autocomplete with Image item selection .
|
39,845
|
public void recycle ( RecyclePosition position ) { stubCount = determineStubCount ( ) ; switch ( position ) { case BOTTOM : if ( hasRecycledWidgets ( ) ) { remove ( getRecycledWidgets ( ) . stream ( ) . skip ( 0 ) . limit ( ( parent . getLimit ( ) * ( currentIndex + 1 ) ) - stubCount ) . collect ( Collectors . toList ( ) ) ) ; currentIndex ++ ; if ( currentIndex < loadIndex ) { add ( getRecycledWidgets ( currentIndex ) ) ; } } break ; case TOP : if ( currentIndex > 0 ) { remove ( getRecycledWidgets ( currentIndex ) ) ; int skip = ( ( parent . getLimit ( ) * currentIndex ) - parent . getLimit ( ) ) - stubCount ; insert ( getRecycledWidgets ( ) . stream ( ) . skip ( skip < 0 ? 0 : skip ) . limit ( parent . getLimit ( ) ) . collect ( Collectors . toList ( ) ) ) ; currentIndex -- ; } break ; } }
|
Will recycle the provided widgets (
|
39,846
|
public List < Widget > getRecycledWidgets ( ) { List < Widget > widgets = new ArrayList < > ( ) ; for ( Integer recycledIndex : recycledWidgets . keySet ( ) ) { widgets . addAll ( recycledWidgets . get ( recycledIndex ) ) ; } return widgets ; }
|
Get all recycled widgets
|
39,847
|
protected void executeSassScript ( String sassScript ) throws MojoExecutionException , MojoFailureException { final Log log = this . getLog ( ) ; System . setProperty ( "org.jruby.embed.localcontext.scope" , "threadsafe" ) ; log . debug ( "Execute SASS Ruby Script:\n" + sassScript ) ; final ScriptEngineManager scriptEngineManager = new ScriptEngineManager ( ) ; final ScriptEngine jruby = scriptEngineManager . getEngineByName ( "jruby" ) ; try { CompilerCallback compilerCallback = new CompilerCallback ( log ) ; jruby . getBindings ( ScriptContext . ENGINE_SCOPE ) . put ( "compiler_callback" , compilerCallback ) ; jruby . eval ( sassScript ) ; if ( failOnError && compilerCallback . hadError ( ) ) { throw new MojoFailureException ( "SASS compilation encountered errors (see above for details)." ) ; } } catch ( final ScriptException e ) { throw new MojoExecutionException ( "Failed to execute SASS ruby script:\n" + sassScript , e ) ; } }
|
Execute the SASS Compilation Ruby Script
|
39,848
|
public final VH onCreateViewHolder ( ViewGroup parent , int viewType ) { VH viewHolder ; if ( isHeaderType ( viewType ) ) { viewHolder = onCreateHeaderViewHolder ( parent , viewType ) ; } else if ( isFooterType ( viewType ) ) { viewHolder = onCreateFooterViewHolder ( parent , viewType ) ; } else { viewHolder = onCreateItemViewHolder ( parent , viewType ) ; } return viewHolder ; }
|
Invokes onCreateHeaderViewHolder onCreateItemViewHolder or onCreateFooterViewHolder methods based on the view type param .
|
39,849
|
public final void onBindViewHolder ( VH holder , int position ) { if ( isHeaderPosition ( position ) ) { onBindHeaderViewHolder ( holder , position ) ; } else if ( isFooterPosition ( position ) ) { onBindFooterViewHolder ( holder , position ) ; } else { onBindItemViewHolder ( holder , position ) ; } }
|
Invokes onBindHeaderViewHolder onBindItemViewHolder or onBindFooterViewHOlder methods based on the position param .
|
39,850
|
public int getItemViewType ( int position ) { int viewType = TYPE_ITEM ; if ( isHeaderPosition ( position ) ) { viewType = TYPE_HEADER ; } else if ( isFooterPosition ( position ) ) { viewType = TYPE_FOOTER ; } return viewType ; }
|
Returns the type associated to an item given a position passed as arguments . If the position is related to a header item returns the constant TYPE_HEADER or TYPE_FOOTER if the position is related to the footer if not returns TYPE_ITEM .
|
39,851
|
public int getItemCount ( ) { int size = items . size ( ) ; if ( hasHeader ( ) ) { size ++ ; } if ( hasFooter ( ) ) { size ++ ; } return size ; }
|
Returns the items list size if there is no a header configured or the size taking into account that if a header or a footer is configured the number of items returned is going to include this elements .
|
39,852
|
Point getPointForID ( int id ) { for ( int i = 0 ; i < pointCount ; i ++ ) { if ( id == - 1 || points [ i ] . id == id ) { return points [ i ] ; } } return null ; }
|
Gets the Point matching the given ID . if available
|
39,853
|
void assignPrimaryID ( ) { if ( pointCount == 0 ) { primaryID = - 1 ; } else if ( primaryID <= 0 ) { primaryID = points [ 0 ] . id ; } else { for ( int i = 0 ; i < pointCount ; i ++ ) { if ( points [ i ] . id == primaryID ) { return ; } } primaryID = points [ 0 ] . id ; } }
|
Updates the primary point ID
|
39,854
|
Point addPoint ( Point p ) { if ( points . length == pointCount ) { points = Arrays . copyOf ( points , points . length * 2 ) ; } if ( points [ pointCount ] == null ) { points [ pointCount ] = new Point ( ) ; } if ( p != null ) { p . copyTo ( points [ pointCount ] ) ; } return points [ pointCount ++ ] ; }
|
Adds a Point to this state object .
|
39,855
|
void removePointForID ( int id ) { for ( int i = 0 ; i < pointCount ; i ++ ) { if ( points [ i ] . id == id ) { if ( i < pointCount - 1 ) { System . arraycopy ( points , i + 1 , points , i , pointCount - i - 1 ) ; points [ pointCount - 1 ] = null ; } pointCount -- ; } } }
|
Removes the point with the given ID
|
39,856
|
void setPoint ( int index , Point p ) { if ( index >= pointCount ) { throw new IndexOutOfBoundsException ( ) ; } p . copyTo ( points [ index ] ) ; }
|
Replaces the touch point data at the given index with the given touch point data
|
39,857
|
boolean equalsSorted ( TouchState ts ) { if ( ts . pointCount == pointCount && ts . primaryID == primaryID && ts . window == window ) { for ( int i = 0 ; i < pointCount ; i ++ ) { Point p1 = ts . points [ i ] ; Point p2 = points [ i ] ; if ( p1 . x != p2 . x || p1 . y != p2 . y || p1 . id != p2 . id ) { return false ; } } return true ; } else { return false ; } }
|
Compare two non - null states whose points are sorted by ID
|
39,858
|
boolean canBeFoldedWith ( TouchState ts , boolean ignoreIDs ) { if ( ts . pointCount != pointCount ) { return false ; } if ( ignoreIDs ) { return true ; } for ( int i = 0 ; i < pointCount ; i ++ ) { if ( ts . points [ i ] . id != points [ i ] . id ) { return false ; } } return true ; }
|
Finds out whether two non - null states are identical in everything but their touch point coordinates
|
39,859
|
int getValue ( LinuxEventBuffer buffer ) { int axis = buffer . getEventCode ( ) ; int value = buffer . getEventValue ( ) ; int i ; for ( i = 0 ; i < axes . length && axes [ i ] != - 1 ; i ++ ) { if ( axes [ i ] == axis ) { return transform ( i , value ) ; } } if ( i == axes . length ) { axes = Arrays . copyOf ( axes , axes . length * 2 ) ; Arrays . fill ( axes , i + 1 , axes . length - 1 , - 1 ) ; translates = Arrays . copyOf ( translates , translates . length * 2 ) ; scalars = Arrays . copyOf ( scalars , scalars . length * 2 ) ; mins = Arrays . copyOf ( mins , mins . length * 2 ) ; maxs = Arrays . copyOf ( maxs , maxs . length * 2 ) ; } initTransform ( axis , i ) ; return transform ( i , value ) ; }
|
Gets the transformed pixel coordinate of the current event in the buffer provided .
|
39,860
|
int getAxis ( LinuxEventBuffer buffer ) { int axis = buffer . getEventCode ( ) ; if ( flipXY ) { switch ( axis ) { case LinuxInput . ABS_X : return LinuxInput . ABS_Y ; case LinuxInput . ABS_Y : return LinuxInput . ABS_X ; case LinuxInput . ABS_MT_POSITION_X : return LinuxInput . ABS_MT_POSITION_Y ; case LinuxInput . ABS_MT_POSITION_Y : return LinuxInput . ABS_MT_POSITION_X ; default : return axis ; } } else { return axis ; } }
|
Gets the transformed axis number of the current event in the buffer provided .
|
39,861
|
MonocleWindow getWindow ( boolean recalculateCache ) { if ( window == null || recalculateCache ) { window = ( MonocleWindow ) MonocleWindowManager . getInstance ( ) . getFocusedWindow ( ) ; } return window ; }
|
Returns the Glass window on which this event state is located .
|
39,862
|
protected void pushToSystem ( HashMap < String , Object > cacheData , int supportedActions ) { MouseInput . getInstance ( ) . notifyDragStart ( ) ; ( ( MonocleApplication ) Application . GetApplication ( ) ) . enterDnDEventLoop ( ) ; actionPerformed ( Clipboard . ACTION_COPY_OR_MOVE ) ; }
|
Here the magic happens . When this method is called all input events should be grabbed and appropriate drag notifications should be sent instead of regular input events
|
39,863
|
void add ( TouchPipeline pipeline ) { for ( int i = 0 ; i < pipeline . filters . size ( ) ; i ++ ) { addFilter ( pipeline . filters . get ( i ) ) ; } }
|
Adds the filters in the given pipeline to this pipeline
|
39,864
|
void addNamedFilters ( String filterNameList ) { String [ ] touchFilterNames = filterNameList . split ( "," ) ; if ( touchFilterNames != null ) { for ( String touchFilterName : touchFilterNames ) { String s = touchFilterName . trim ( ) ; if ( s . length ( ) > 0 ) { addNamedFilter ( s ) ; } } } }
|
Attempts to add the filters named in the comma - separated list provided .
|
39,865
|
void flush ( ) { for ( int i = 0 ; i < filters . size ( ) ; i ++ ) { TouchFilter filter = filters . get ( i ) ; while ( filter . flush ( flushState ) ) { if ( MonocleSettings . settings . traceEventsVerbose ) { MonocleTrace . traceEvent ( "Flushing %s from %s" , flushState , filter ) ; } boolean consumed = false ; for ( int j = i + 1 ; j < filters . size ( ) && ! consumed ; j ++ ) { consumed = filters . get ( j ) . filter ( flushState ) ; } if ( ! consumed ) { touch . setState ( flushState ) ; } } } }
|
Flushes any remaining data in the pipeline possibly pushing more state objects to TouchInput .
|
39,866
|
public static synchronized NativePlatform getNativePlatform ( ) { if ( platform == null ) { String platformFactoryProperty = AccessController . doPrivileged ( ( PrivilegedAction < String > ) ( ) -> System . getProperty ( "monocle.platform" , "MX6,OMAP,Dispman,Android,X11,Linux,Headless" ) ) ; String [ ] platformFactories = platformFactoryProperty . split ( "," ) ; for ( int i = 0 ; i < platformFactories . length ; i ++ ) { String factoryName = platformFactories [ i ] . trim ( ) ; String factoryClassName ; if ( factoryName . contains ( "." ) ) { factoryClassName = factoryName ; } else { factoryClassName = "com.sun.glass.ui.monocle." + factoryName + "PlatformFactory" ; } if ( MonocleSettings . settings . tracePlatformConfig ) { MonocleTrace . traceConfig ( "Trying platform %s with class %s" , factoryName , factoryClassName ) ; } try { final ClassLoader loader = NativePlatformFactory . class . getClassLoader ( ) ; final Class < ? > clazz = Class . forName ( factoryClassName , false , loader ) ; if ( ! NativePlatformFactory . class . isAssignableFrom ( clazz ) ) { throw new IllegalArgumentException ( "Unrecognized Monocle platform: " + factoryClassName ) ; } NativePlatformFactory npf = ( NativePlatformFactory ) clazz . newInstance ( ) ; if ( npf . matches ( ) && npf . getMajorVersion ( ) == majorVersion && npf . getMinorVersion ( ) == minorVersion ) { platform = npf . createNativePlatform ( ) ; if ( MonocleSettings . settings . tracePlatformConfig ) { MonocleTrace . traceConfig ( "Matched %s" , factoryName ) ; } return platform ; } } catch ( Exception e ) { if ( MonocleSettings . settings . tracePlatformConfig ) { MonocleTrace . traceConfig ( "Failed to create platform %s" , factoryClassName ) ; } e . printStackTrace ( ) ; } } throw new UnsupportedOperationException ( "Cannot load a native platform from: '" + platformFactoryProperty + "'" ) ; } return platform ; }
|
Obtains a NativePlatform that matches the platform on which we are running .
|
39,867
|
static synchronized Udev getInstance ( ) { if ( instance == null ) { try { instance = new Udev ( ) ; } catch ( IOException e ) { System . err . println ( "Udev: failed to open connection" ) ; e . printStackTrace ( ) ; } } return instance ; }
|
Gets the singleton Udev object
|
39,868
|
private Map < String , String > readEvent ( ) throws IOException { Map < String , String > map = new HashMap < > ( ) ; ByteBuffer b ; synchronized ( this ) { b = buffer ; if ( b == null ) { return map ; } } int length = _readEvent ( fd , b ) ; synchronized ( this ) { if ( buffer == null ) { return map ; } int propertiesOffset = _getPropertiesOffset ( buffer ) ; int propertiesLength = _getPropertiesLength ( buffer ) ; int propertiesEnd = propertiesOffset + propertiesLength ; if ( length < propertiesEnd ) { throw new IOException ( "Mismatched property segment length" ) ; } buffer . position ( propertiesOffset ) ; StringBuffer key = new StringBuffer ( ) ; StringBuffer value = new StringBuffer ( ) ; nextKey : while ( buffer . position ( ) < propertiesEnd ) { key . setLength ( 0 ) ; value . setLength ( 0 ) ; boolean readKey = false ; while ( buffer . position ( ) < length && ! readKey ) { char ch = ( char ) buffer . get ( ) ; switch ( ch ) { case '\000' : map . put ( key . toString ( ) , "" ) ; continue nextKey ; case '=' : readKey = true ; break ; default : key . append ( ch ) ; } } while ( buffer . position ( ) < propertiesEnd ) { char ch = ( char ) buffer . get ( ) ; switch ( ch ) { case '\000' : map . put ( key . toString ( ) , value . toString ( ) ) ; continue nextKey ; default : value . append ( ch ) ; } } } buffer . clear ( ) ; } return map ; }
|
Reads data from the udev monitor . Blocks until data is available
|
39,869
|
synchronized void close ( ) { thread . interrupt ( ) ; _close ( fd ) ; fd = 0l ; buffer = null ; thread = null ; }
|
Closes the udev monitor connection
|
39,870
|
synchronized boolean put ( ByteBuffer event ) throws InterruptedException { boolean isSync = event . getInt ( eventStruct . getTypeIndex ( ) ) == 0 && event . getInt ( eventStruct . getValueIndex ( ) ) == 0 ; while ( bb . limit ( ) - bb . position ( ) < event . limit ( ) ) { if ( MonocleSettings . settings . traceEventsVerbose ) { MonocleTrace . traceEvent ( "Event buffer %s is full, waiting for some space to become available" , bb ) ; } wait ( ) ; } if ( isSync ) { positionOfLastSync = bb . position ( ) ; } bb . put ( event ) ; if ( MonocleSettings . settings . traceEventsVerbose ) { int index = bb . position ( ) - eventStruct . getSize ( ) ; MonocleTrace . traceEvent ( "Read %s [index=%d]" , getEventDescription ( index ) , index ) ; } return isSync ; }
|
Adds a raw Linux event to the buffer . Blocks if the buffer is full . Checks whether this is a SYN SYN_REPORT event terminator .
|
39,871
|
synchronized void nextEvent ( ) { if ( currentPosition > positionOfLastSync ) { throw new IllegalStateException ( "Cannot advance past the last" + " EV_SYN EV_SYN_REPORT 0" ) ; } currentPosition += eventStruct . getSize ( ) ; if ( MonocleSettings . settings . traceEventsVerbose && hasNextEvent ( ) ) { MonocleTrace . traceEvent ( "Processing %s [index=%d]" , getEventDescription ( ) , currentPosition ) ; } }
|
Advances to the next event line . Call from the application thread .
|
39,872
|
static String typeToString ( short type ) { for ( Field field : LinuxInput . class . getDeclaredFields ( ) ) { try { if ( field . getName ( ) . startsWith ( "EV_" ) && field . getType ( ) == Short . TYPE && field . getShort ( null ) == type ) { return field . getName ( ) ; } } catch ( IllegalAccessException e ) { } } return new Formatter ( ) . format ( "0x%04x" , type & 0xffff ) . out ( ) . toString ( ) ; }
|
Convert an event type to its equivalent string . This method is inefficient and is for debugging use only .
|
39,873
|
static String codeToString ( String type , short code ) { int i = type . indexOf ( "_" ) ; if ( i >= 0 ) { String prefix = type . substring ( i + 1 ) ; String altPrefix = prefix . equals ( "KEY" ) ? "BTN" : prefix ; for ( Field field : LinuxInput . class . getDeclaredFields ( ) ) { String name = field . getName ( ) ; try { if ( ( name . startsWith ( prefix ) || name . startsWith ( altPrefix ) ) && field . getType ( ) == Short . TYPE && field . getShort ( null ) == code ) { return field . getName ( ) ; } } catch ( IllegalAccessException e ) { } } } return new Formatter ( ) . format ( "0x%04x" , code & 0xffff ) . out ( ) . toString ( ) ; }
|
Convert an event code to its equivalent string given its type string . The type string is needed because event codes are context sensitive . For example the code 1 is SYN_CONFIG for an EV_SYN event but KEY_ESC for an EV_KEY event . This method is inefficient and is for debugging use only .
|
39,874
|
static Map < Integer , LinuxAbsoluteInputCapabilities > getCapabilities ( File devNode , BitSet axes ) throws IOException { if ( axes == null || axes . isEmpty ( ) ) { return null ; } LinuxSystem system = LinuxSystem . getLinuxSystem ( ) ; LinuxSystem . InputAbsInfo info = new LinuxSystem . InputAbsInfo ( ) ; long fd = system . open ( devNode . getPath ( ) , LinuxSystem . O_RDONLY ) ; if ( fd == - 1 ) { throw new IOException ( system . getErrorMessage ( ) ) ; } Map < Integer , LinuxAbsoluteInputCapabilities > caps = new HashMap < Integer , LinuxAbsoluteInputCapabilities > ( ) ; for ( int i = 0 ; ( i = axes . nextSetBit ( i ) ) != - 1 ; i ++ ) { caps . put ( i , new LinuxAbsoluteInputCapabilities ( system , info , fd , i ) ) ; } system . close ( fd ) ; return caps ; }
|
Reads capabilities from a device node .
|
39,875
|
private void releaseID ( int id ) { ids . removeInt ( id ) ; nextID = 1 ; for ( int i = 0 ; i < ids . size ( ) ; i ++ ) { nextID = Math . max ( ids . get ( i ) + 1 , nextID ) ; } }
|
Release a touch point ID
|
39,876
|
void invokeAndWait ( final Runnable r ) { final CountDownLatch latch = new CountDownLatch ( 1 ) ; queue . postRunnable ( ( ) -> { try { r . run ( ) ; } finally { latch . countDown ( ) ; } } ) ; try { latch . await ( ) ; } catch ( InterruptedException e ) { } }
|
Posts a Runnable to the JavaFX event queue and waits for the Runnable to complete .
|
39,877
|
String eglErrorToString ( int errorCode ) { if ( errorCode >= 0x3000 && errorCode < 0x3020 ) { for ( Field field : EGL . class . getFields ( ) ) { try { if ( field . getName ( ) . startsWith ( "EGL_" ) && field . getType ( ) == Integer . TYPE && field . getInt ( null ) == errorCode ) { return field . getName ( ) ; } } catch ( IllegalAccessException e ) { } } } return new Formatter ( ) . format ( "0x%04x" , errorCode & 0xffff ) . out ( ) . toString ( ) ; }
|
Convert an EGL error code such as EGL_BAD_CONTEXT to a string representation .
|
39,878
|
TouchPipeline getBasePipeline ( ) { if ( basePipeline == null ) { basePipeline = new TouchPipeline ( ) ; String [ ] touchFilterNames = AccessController . doPrivileged ( ( PrivilegedAction < String > ) ( ) -> System . getProperty ( "monocle.input.touchFilters" , "SmallMove" ) ) . split ( "," ) ; if ( touchFilterNames != null ) { for ( String touchFilterName : touchFilterNames ) { basePipeline . addNamedFilter ( touchFilterName . trim ( ) ) ; } } } return basePipeline ; }
|
Gets the base touch filter pipeline common to all touch devices
|
39,879
|
void setState ( TouchState newState ) { if ( MonocleSettings . settings . traceEvents ) { MonocleTrace . traceEvent ( "Set %s" , newState ) ; } newState . sortPointsByID ( ) ; newState . assignPrimaryID ( ) ; MonocleWindow oldWindow = state . getWindow ( false , null ) ; boolean recalculateWindow = state . getPointCount ( ) == 0 ; MonocleWindow window = newState . getWindow ( recalculateWindow , oldWindow ) ; View oldView = oldWindow == null ? null : oldWindow . getView ( ) ; View view = window == null ? null : window . getView ( ) ; if ( ! newState . equalsSorted ( state ) ) { if ( view != oldView ) { postTouchEvent ( state , TouchEvent . TOUCH_RELEASED ) ; postTouchEvent ( newState , TouchEvent . TOUCH_PRESSED ) ; } else if ( view != null ) { postTouchEvent ( window , view , newState ) ; } MouseInputSynthesizer . getInstance ( ) . setState ( newState ) ; } newState . copyTo ( state ) ; newState . clearWindow ( ) ; }
|
Called from the input processor to update the touch state and send touch and mouse events .
|
39,880
|
private void postTouchEvent ( TouchState state , int eventType ) { Window window = state . getWindow ( false , null ) ; View view = window == null ? null : window . getView ( ) ; if ( view != null ) { switch ( state . getPointCount ( ) ) { case 0 : postNoPoints ( view ) ; break ; case 1 : postPoint ( window , view , eventType , state . getPoint ( 0 ) ) ; break ; default : { int count = state . getPointCount ( ) ; int [ ] states = new int [ count ] ; int [ ] ids = new int [ count ] ; int [ ] xs = new int [ count ] ; int [ ] ys = new int [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { states [ i ] = eventType ; TouchState . Point p = state . getPoint ( i ) ; ids [ i ] = p . id ; xs [ i ] = p . x ; ys [ i ] = p . y ; } postPoints ( window , view , states , ids , xs , ys ) ; } } } }
|
Sends the same event type for all points in the given state
|
39,881
|
private void postTouchEvent ( MonocleWindow window , View view , TouchState newState ) { int count = countEvents ( newState ) ; switch ( count ) { case 0 : postNoPoints ( view ) ; break ; case 1 : if ( state . getPointCount ( ) == 1 ) { TouchState . Point oldPoint = state . getPoint ( 0 ) ; TouchState . Point newPoint = newState . getPointForID ( oldPoint . id ) ; if ( newPoint != null ) { if ( newPoint . x == oldPoint . x && newPoint . y == oldPoint . y ) { postPoint ( window , view , TouchEvent . TOUCH_STILL , newPoint ) ; } else { postPoint ( window , view , TouchEvent . TOUCH_MOVED , newPoint ) ; } } else { postPoint ( window , view , TouchEvent . TOUCH_RELEASED , oldPoint ) ; } } else { postPoint ( window , view , TouchEvent . TOUCH_PRESSED , newState . getPoint ( 0 ) ) ; } break ; default : { int [ ] states = new int [ count ] ; int [ ] ids = new int [ count ] ; int [ ] xs = new int [ count ] ; int [ ] ys = new int [ count ] ; for ( int i = 0 ; i < state . getPointCount ( ) ; i ++ ) { TouchState . Point oldPoint = state . getPoint ( i ) ; TouchState . Point newPoint = newState . getPointForID ( oldPoint . id ) ; if ( newPoint != null ) { ids [ i ] = newPoint . id ; xs [ i ] = newPoint . x ; ys [ i ] = newPoint . y ; if ( newPoint . x == oldPoint . x && newPoint . y == oldPoint . y ) { states [ i ] = TouchEvent . TOUCH_STILL ; } else { states [ i ] = TouchEvent . TOUCH_MOVED ; } } else { states [ i ] = TouchEvent . TOUCH_RELEASED ; ids [ i ] = oldPoint . id ; xs [ i ] = oldPoint . x ; ys [ i ] = oldPoint . y ; } } for ( int i = 0 , j = state . getPointCount ( ) ; i < newState . getPointCount ( ) ; i ++ ) { TouchState . Point newPoint = newState . getPoint ( i ) ; TouchState . Point oldPoint = state . getPointForID ( newPoint . id ) ; if ( oldPoint == null ) { states [ j ] = TouchEvent . TOUCH_PRESSED ; ids [ j ] = newPoint . id ; xs [ j ] = newPoint . x ; ys [ j ] = newPoint . y ; j ++ ; } } postPoints ( window , view , states , ids , xs , ys ) ; } } }
|
Sends updated touch points within the same View as last processed touch points .
|
39,882
|
protected long _createWindow ( long NativeWindow , long NativeScreen , int mask ) { id = MonocleWindowManager . getInstance ( ) . addWindow ( this ) ; return id ; }
|
creates the native window
|
39,883
|
void shutdown ( ) { runnableProcessor . shutdown ( ) ; if ( cursor != null ) { cursor . shutdown ( ) ; } if ( screen != null ) { screen . shutdown ( ) ; } }
|
Called once during JavaFX shutdown to release platform resources .
|
39,884
|
public synchronized AcceleratedScreen getAcceleratedScreen ( int [ ] attributes ) throws GLException , UnsatisfiedLinkError { if ( accScreen == null ) { accScreen = new AcceleratedScreen ( attributes ) ; } return accScreen ; }
|
Gets the AcceleratedScreen for this platform
|
39,885
|
public synchronized AcceleratedScreen getAcceleratedScreen ( int [ ] attributes ) throws GLException { if ( accScreen == null ) { accScreen = new AndroidAcceleratedScreen ( attributes ) ; } return accScreen ; }
|
Create the accelerated screen for this platform
|
39,886
|
static Map < String , BitSet > readCapabilities ( File sysPath ) { Map < String , BitSet > capsMap = new HashMap < String , BitSet > ( ) ; File [ ] capsFiles = new File ( sysPath , "device/capabilities" ) . listFiles ( ) ; if ( capsFiles == null ) { return capsMap ; } for ( int i = 0 ; i < capsFiles . length ; i ++ ) { try { BufferedReader r = new BufferedReader ( new FileReader ( capsFiles [ i ] ) ) ; String s = r . readLine ( ) ; r . close ( ) ; if ( s == null ) { continue ; } String [ ] elements = s . split ( " " ) ; if ( elements == null ) { continue ; } byte [ ] b = new byte [ elements . length * ( LinuxArch . is64Bit ( ) ? 8 : 4 ) ] ; ByteBuffer bb = ByteBuffer . wrap ( b ) ; bb . order ( ByteOrder . LITTLE_ENDIAN ) ; for ( int j = elements . length - 1 ; j >= 0 ; j -- ) { if ( LinuxArch . is64Bit ( ) ) { bb . putLong ( Long . parseUnsignedLong ( elements [ j ] , 16 ) ) ; } else { bb . putInt ( Integer . parseUnsignedInt ( elements [ j ] , 16 ) ) ; } } capsMap . put ( capsFiles [ i ] . getName ( ) , BitSet . valueOf ( b ) ) ; } catch ( IOException | RuntimeException e ) { e . printStackTrace ( ) ; } } return capsMap ; }
|
Read input device capability data from sysfs
|
39,887
|
static void triggerUdevNotification ( String sysClass ) { File [ ] devices = new File ( "/sys/class/" + sysClass ) . listFiles ( ) ; byte [ ] action = "change" . getBytes ( ) ; for ( File device : devices ) { File uevent = new File ( device , "uevent" ) ; if ( uevent . exists ( ) ) { try { write ( uevent . getAbsolutePath ( ) , action ) ; } catch ( IOException e ) { System . err . println ( "Udev: Failed to write to " + uevent ) ; System . err . println ( " Check that you have permission to access input devices" ) ; if ( ! e . getMessage ( ) . contains ( "Permission denied" ) ) { e . printStackTrace ( ) ; } } } } }
|
Fires udev notification events for devices of the given type
|
39,888
|
static int [ ] readInts ( String location , int expectedLength ) throws IOException { BufferedReader r = new BufferedReader ( new FileReader ( location ) ) ; String s = r . readLine ( ) ; r . close ( ) ; if ( s != null && s . length ( ) > 0 ) { String [ ] elements = s . split ( "," ) ; try { if ( expectedLength == 0 || elements . length == expectedLength ) { int [ ] xs = new int [ elements . length ] ; for ( int i = 0 ; i < xs . length ; i ++ ) { xs [ i ] = Integer . parseInt ( elements [ i ] ) ; } return xs ; } } catch ( NumberFormatException e ) { } } if ( expectedLength != 0 ) { throw new IOException ( "Expected to find " + expectedLength + " integers in " + location + " but found '" + s + "'" ) ; } else { return new int [ 0 ] ; } }
|
Read a comma - separated list of integer values from a file
|
39,889
|
static int readInt ( String location ) throws IOException { BufferedReader r = new BufferedReader ( new FileReader ( location ) ) ; String s = r . readLine ( ) ; r . close ( ) ; try { if ( s != null && s . length ( ) > 0 ) { return Integer . parseInt ( s ) ; } else { throw new IOException ( location + " does not contain an integer" ) ; } } catch ( NumberFormatException e ) { throw new IOException ( location + " does not contain an integer ('" + s + "'" ) ; } }
|
Read a single integer value from a file
|
39,890
|
public void enableRendering ( boolean flag ) { if ( flag ) { egl . eglMakeCurrent ( eglDisplay , eglSurface , eglSurface , eglContext ) ; } else { egl . eglMakeCurrent ( eglDisplay , 0 , 0 , eglContext ) ; } }
|
Make the EGL drawing surface current or not
|
39,891
|
boolean initPlatformLibraries ( ) throws UnsatisfiedLinkError { if ( ! initialized ) { glesLibraryHandle = ls . dlopen ( "libGLESv2.so" , LinuxSystem . RTLD_LAZY | LinuxSystem . RTLD_GLOBAL ) ; if ( glesLibraryHandle == 0l ) { throw new UnsatisfiedLinkError ( "Error loading libGLESv2.so" ) ; } eglLibraryHandle = ls . dlopen ( "libEGL.so" , LinuxSystem . RTLD_LAZY | LinuxSystem . RTLD_GLOBAL ) ; if ( eglLibraryHandle == 0l ) { throw new UnsatisfiedLinkError ( "Error loading libEGL.so" ) ; } initialized = true ; } return true ; }
|
Load any native libraries needed to instantiate and initialize the native drawing surface and rendering context
|
39,892
|
public boolean swapBuffers ( ) { boolean result = false ; synchronized ( NativeScreen . framebufferSwapLock ) { result = egl . eglSwapBuffers ( eglDisplay , eglSurface ) ; if ( ! result ) { createSurface ( ) ; result = egl . eglSwapBuffers ( eglDisplay , eglSurface ) ; } } return result ; }
|
Copy the contents of the GL backbuffer to the screen
|
39,893
|
private void processXEvent ( X . XEvent event , RunnableProcessor runnableProcessor ) { switch ( X . XEvent . getType ( event . p ) ) { case X . ButtonPress : { X . XButtonEvent buttonEvent = new X . XButtonEvent ( event ) ; int button = X . XButtonEvent . getButton ( buttonEvent . p ) ; runnableProcessor . invokeLater ( new ButtonPressProcessor ( button ) ) ; break ; } case X . ButtonRelease : { X . XButtonEvent buttonEvent = new X . XButtonEvent ( event ) ; int button = X . XButtonEvent . getButton ( buttonEvent . p ) ; runnableProcessor . invokeLater ( new ButtonReleaseProcessor ( button ) ) ; break ; } case X . MotionNotify : { X . XMotionEvent motionEvent = new X . XMotionEvent ( event ) ; int x = X . XMotionEvent . getX ( motionEvent . p ) ; int y = X . XMotionEvent . getY ( motionEvent . p ) ; runnableProcessor . invokeLater ( new MotionProcessor ( x , y ) ) ; break ; } } }
|
Dispatch the X Event to the appropriate processor . All processors run via invokeLater
|
39,894
|
private static int buttonToGlassButton ( int button ) { switch ( button ) { case X . Button1 : return MouseEvent . BUTTON_LEFT ; case X . Button2 : return MouseEvent . BUTTON_OTHER ; case X . Button3 : return MouseEvent . BUTTON_RIGHT ; default : return MouseEvent . BUTTON_NONE ; } }
|
Convenience method to convert X11 button codes to glass button codes
|
39,895
|
MonocleWindow getWindow ( boolean recalculateCache ) { if ( window == null || recalculateCache ) { window = ( MonocleWindow ) MonocleWindowManager . getInstance ( ) . getWindowForLocation ( x , y ) ; } return window ; }
|
Returns the Glass window on which the coordinates of this state are located .
|
39,896
|
int getModifiers ( ) { int modifiers = KeyEvent . MODIFIER_NONE ; for ( int i = 0 ; i < buttonsPressed . size ( ) ; i ++ ) { switch ( buttonsPressed . get ( i ) ) { case MouseEvent . BUTTON_LEFT : modifiers |= KeyEvent . MODIFIER_BUTTON_PRIMARY ; break ; case MouseEvent . BUTTON_OTHER : modifiers |= KeyEvent . MODIFIER_BUTTON_MIDDLE ; break ; case MouseEvent . BUTTON_RIGHT : modifiers |= KeyEvent . MODIFIER_BUTTON_SECONDARY ; break ; } } return modifiers ; }
|
Returns the Glass event modifiers for this state
|
39,897
|
boolean canBeFoldedWith ( MouseState ms ) { return ms . buttonsPressed . equals ( buttonsPressed ) && ms . wheel == wheel ; }
|
Finds out whether two non - null states are identical in everything but their coordinates
|
39,898
|
void difference ( IntSet dest , IntSet compared ) { int i = 0 ; int j = 0 ; while ( i < size && j < compared . size ) { int a = elements [ i ] ; int b = compared . elements [ j ] ; if ( a < b ) { dest . addInt ( a ) ; i ++ ; } else if ( a > b ) { j ++ ; } else { i ++ ; j ++ ; } } while ( i < size ) { dest . addInt ( elements [ i ] ) ; i ++ ; } }
|
Adds to the set dest values that in this set but are not in the set compared .
|
39,899
|
void copyTo ( IntSet target ) { if ( target . elements . length < size ) { target . elements = Arrays . copyOf ( elements , elements . length ) ; } else { System . arraycopy ( elements , 0 , target . elements , 0 , size ) ; } target . size = size ; }
|
Copies the contents of this set to the target set .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.