idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
3,900
public Bundle addIteration ( String label ) { mCpuTime = Process . getElapsedCpuTime ( ) - mCpuTime ; mExecTime = SystemClock . uptimeMillis ( ) - mExecTime ; Bundle iteration = new Bundle ( ) ; iteration . putString ( METRIC_KEY_LABEL , label ) ; iteration . putLong ( METRIC_KEY_EXECUTION_TIME , mExecTime ) ; iteratio...
Add a measured segment and start measuring the next segment . Returns collected data in a Bundle object .
3,901
public Bundle stopTiming ( String label ) { addIteration ( label ) ; if ( mPerfWriter != null ) mPerfWriter . writeStopTiming ( mPerfMeasurement ) ; return mPerfMeasurement ; }
Stop measurement of user and cpu time .
3,902
public void addMeasurement ( String label , String value ) { if ( mPerfWriter != null ) mPerfWriter . writeMeasurement ( label , value ) ; }
Add a string field to the collector .
3,903
public static < T > Predicate < T > and ( Predicate < ? super T > ... components ) { return and ( Arrays . asList ( components ) ) ; }
Returns a Predicate that evaluates to true iff each of its components evaluates to true . The components are evaluated in order and evaluation will be short - circuited as soon as the answer is determined .
3,904
public static < T > Predicate < T > or ( Predicate < ? super T > ... components ) { return or ( Arrays . asList ( components ) ) ; }
Returns a Predicate that evaluates to true iff any one of its components evaluates to true . The components are evaluated in order and evaluation will be short - circuited as soon as the answer is determined .
3,905
public static < T > Predicate < T > or ( Iterable < ? extends Predicate < ? super T > > components ) { return new OrPredicate ( components ) ; }
Returns a Predicate that evaluates to true iff any one of its components evaluates to true . The components are evaluated in order and evaluation will be short - circuited as soon as the answer is determined . Does not defensively copy the iterable passed in so future changes to it will alter the behavior of this Predi...
3,906
private final void applyPagination ( final Query query , final PaginationData pagination ) { query . setFirstResult ( ( pagination . getPageNumber ( ) - 1 ) * pagination . getPageSize ( ) ) ; query . setMaxResults ( pagination . getPageSize ( ) ) ; }
Applies pagination to the query .
3,907
public static Program compete ( List < Program > programs , Program current , Program candidate , LGP manager , RandEngine randEngine ) { if ( manager . getReplacementStrategy ( ) == LGPReplacementStrategy . DirectCompetition ) { if ( CollectionUtils . isBetterThan ( candidate , current ) ) { int index = programs . ind...
this method returns the pointer to the loser in the competition for survival ;
3,908
@ TargetApi ( Build . VERSION_CODES . JELLY_BEAN ) void changeViewPosition ( float xAxisDelta , float yAxisDelta ) { float endLeftBoundPointX = calculateEndLeftBound ( xAxisDelta ) ; float endTopBoundPointY = calculateEndTopBound ( yAxisDelta ) ; getView ( ) . setX ( endLeftBoundPointX ) ; getView ( ) . setY ( endTopBo...
Changes the position of the view based on view s visual position within its parent container
3,909
@ TargetApi ( Build . VERSION_CODES . JELLY_BEAN ) int calculateEndLeftBound ( float xAxisDelta ) { return ( int ) ( getView ( ) . getX ( ) + xAxisDelta ) ; }
Calculates the resulting X coordinate of the view s left bound based on the X position of the view and the X - axis delta
3,910
@ TargetApi ( Build . VERSION_CODES . JELLY_BEAN ) int calculateEndTopBound ( float yAxisDelta ) { return ( int ) ( getView ( ) . getY ( ) + yAxisDelta ) ; }
Calculates the resulting Y coordinate of the view s top bound based on the Y position of the view and the Y - axis delta
3,911
public int compareTo ( Program that ) { int cmp = Integer . compare ( depth , that . depth ) ; if ( cmp == 0 ) { return Integer . compare ( length , that . length ) ; } else { return cmp ; } }
The method return - 1 if this program is better than that program
3,912
private boolean isViewLeftAligned ( ViewGroup . MarginLayoutParams layoutParams ) { final int left = getView ( ) . getLeft ( ) ; boolean viewLeftAligned = left == 0 || left == layoutParams . leftMargin ; LOGGER . trace ( "View is {} aligned" , viewLeftAligned ? "LEFT" : "RIGHT" ) ; return viewLeftAligned ; }
Checks whether view is left aligned
3,913
private boolean isViewTopAligned ( ViewGroup . MarginLayoutParams layoutParams ) { final int top = getView ( ) . getTop ( ) ; boolean viewTopAligned = top == 0 || top == layoutParams . topMargin ; LOGGER . trace ( "View is {} aligned" , viewTopAligned ? "TOP" : "BOTTOM" ) ; return viewTopAligned ; }
Checks whether view is top aligned
3,914
private String determineAnnotatedEndpointPath ( Class < ? > endpointClass ) { if ( endpointClass . isAnnotationPresent ( ServerEndpoint . class ) ) { return endpointClass . getAnnotation ( ServerEndpoint . class ) . value ( ) ; } else { throw new IllegalArgumentException ( String . format ( "@ServerEndpoint annotation ...
move to sort of ruleEngine
3,915
public static DaVinci init ( Context context , int size ) { if ( INSTANCE == null ) INSTANCE = new DaVinci ( context , size ) ; if ( context != null ) INSTANCE . mContext = context ; return INSTANCE ; }
Initialise DaVinci muse have a googleApiClient to retrieve Bitmaps from Smartphone
3,916
public Drawable get ( ) { final Drawable [ ] drawables = new Drawable [ ] { mPlaceHolder , new BitmapDrawable ( mContext . getResources ( ) , Bitmap . createBitmap ( 1 , 1 , Bitmap . Config . ARGB_8888 ) ) , } ; final TransitionDrawable transitionDrawable = new TransitionDrawable ( drawables ) ; into ( new Callback ( )...
Load the bitmap into a TransitionDrawable Starts the treatment when loaded execute a transition
3,917
private Bitmap loadImage ( final String path , final Object into , final Transformation transformation ) { if ( into == null || mImagesCache == null || path == null || path . trim ( ) . isEmpty ( ) ) return null ; Log . d ( TAG , "load(" + path + ")" ) ; Bitmap bitmap = null ; if ( transformation == null ) { bitmap = l...
Start the loading of an image
3,918
private void downloadBitmap ( final String path , final Object into , final Transformation transformation ) { new AsyncTask < Void , Void , Bitmap > ( ) { protected Bitmap doInBackground ( Void ... params ) { Bitmap bitmap = getBitmap ( path ) ; Log . d ( TAG , "bitmap from bluetooth " + path + " " + bitmap ) ; if ( bi...
Download bitmap from bluetooth asset and store it into LruCache and LruDiskCache
3,919
public void onDataChanged ( DataEventBuffer dataEvents ) { for ( DataEvent dataEvent : dataEvents ) { String path = dataEvent . getDataItem ( ) . getUri ( ) . getPath ( ) ; Log . d ( TAG , "onDataChanged(" + path + ")" ) ; if ( path . startsWith ( DAVINCI_PATH ) ) { Log . d ( TAG , "davinci-onDataChanged " + path ) ; A...
When received assets from DataApi
3,920
boolean isPreviousAnimationCompleted ( ) { Animation previousAnimation = view . getAnimation ( ) ; boolean previousAnimationCompleted = previousAnimation == null || previousAnimation . hasEnded ( ) ; if ( ! previousAnimationCompleted ) { LOGGER . warn ( "Unable to move the view. View is being currently moving" ) ; } re...
Checks whether previous animation on the view completed
3,921
private void updateXAxisDelta ( MovingParams details ) { if ( ! hasHorizontalSpaceToMove ( details . getXAxisDelta ( ) ) ) { LOGGER . warn ( "Unable to move the view horizontally. No horizontal space left to move" ) ; details . setXAxisDelta ( 0.0f ) ; } }
Updates the X - axis delta in moving details based on checking whether there is enough space left to move the view horizontally
3,922
private void updateYAxisDelta ( MovingParams details ) { if ( ! hasVerticalSpaceToMove ( details . getYAxisDelta ( ) ) ) { LOGGER . warn ( "Unable to move the view vertically. No vertical space left to move" ) ; details . setYAxisDelta ( 0.0f ) ; } }
Updates the Y - axis delta in moving details based on checking whether there is enough space left to move the view vertically
3,923
public static void apply ( Program child , LGP manager , RandEngine randEngine ) { double r = randEngine . uniform ( ) ; List < Instruction > instructions = child . getInstructions ( ) ; if ( child . length ( ) < manager . getMacroMutateMaxProgramLength ( ) && ( ( r < manager . getMacroMutateInsertionRate ( ) ) || chil...
single instruction would only be exchanged there would be no code growth .
3,924
public static List < String > getAccountEmails ( Context context ) { final Set < String > emailSet = new HashSet < String > ( ) ; final Account [ ] accounts = AccountManager . get ( context ) . getAccounts ( ) ; for ( Account account : accounts ) { if ( isEmail ( account . name ) ) { emailSet . add ( account . name ) ;...
Retrieves a list of e - mails on the device
3,925
private static boolean isEmail ( String account ) { if ( TextUtils . isEmpty ( account ) ) { return false ; } final Pattern emailPattern = Patterns . EMAIL_ADDRESS ; final Matcher matcher = emailPattern . matcher ( account ) ; return matcher . matches ( ) ; }
Returns true if the given string is an email .
3,926
public FutureAPIResponse createEventAsFuture ( Event event ) throws IOException { RequestBuilder builder = new RequestBuilder ( "POST" ) ; builder . setUrl ( apiUrl + "/events.json?accessKey=" + accessKey ) ; String requestJsonString = event . toJsonString ( ) ; builder . setBody ( requestJsonString ) ; builder . setHe...
Sends an asynchronous create event request to the API .
3,927
public String createEvent ( Event event ) throws ExecutionException , InterruptedException , IOException { return createEvent ( createEventAsFuture ( event ) ) ; }
Sends a synchronous create event request to the API .
3,928
public String createEvent ( FutureAPIResponse response ) throws ExecutionException , InterruptedException , IOException { int status = response . get ( ) . getStatus ( ) ; String message = response . get ( ) . getMessage ( ) ; if ( status != HTTP_CREATED ) { throw new IOException ( status + " " + message ) ; } return (...
Synchronize a previously sent asynchronous create event request .
3,929
public FutureAPIResponse getEventAsFuture ( String eid ) throws IOException { Request request = ( new RequestBuilder ( "GET" ) ) . setUrl ( apiUrl + "/events/" + eid + ".json?accessKey=" + accessKey ) . build ( ) ; return new FutureAPIResponse ( client . executeRequest ( request , getHandler ( ) ) ) ; }
Sends an asynchronous get event request to the API .
3,930
public Event getEvent ( String eid ) throws ExecutionException , InterruptedException , IOException { return getEvent ( getEventAsFuture ( eid ) ) ; }
Sends a synchronous get event request to the API .
3,931
public Event getEvent ( FutureAPIResponse response ) throws ExecutionException , InterruptedException , IOException { int status = response . get ( ) . getStatus ( ) ; String message = response . get ( ) . getMessage ( ) ; if ( status == HTTP_OK ) { GsonBuilder gsonBuilder = new GsonBuilder ( ) ; gsonBuilder . register...
Synchronize a previously sent asynchronous get item request .
3,932
public FutureAPIResponse setUserAsFuture ( String uid , Map < String , Object > properties , DateTime eventTime ) throws IOException { return createEventAsFuture ( new Event ( ) . event ( "$set" ) . entityType ( "user" ) . entityId ( uid ) . eventTime ( eventTime ) . properties ( properties ) ) ; }
Sends a set user properties request . Implicitly creates the user if it s not already there . Properties could be empty .
3,933
public String setUser ( String uid , Map < String , Object > properties , DateTime eventTime ) throws ExecutionException , InterruptedException , IOException { return createEvent ( setUserAsFuture ( uid , properties , eventTime ) ) ; }
Sets properties of a user . Implicitly creates the user if it s not already there . Properties could be empty .
3,934
public String unsetUser ( String uid , List < String > properties , DateTime eventTime ) throws ExecutionException , InterruptedException , IOException { return createEvent ( unsetUserAsFuture ( uid , properties , eventTime ) ) ; }
Unsets properties of a user . The list must not be empty .
3,935
public FutureAPIResponse deleteUserAsFuture ( String uid , DateTime eventTime ) throws IOException { return createEventAsFuture ( new Event ( ) . event ( "$delete" ) . entityType ( "user" ) . entityId ( uid ) . eventTime ( eventTime ) ) ; }
Sends a delete user request .
3,936
public String deleteUser ( String uid ) throws ExecutionException , InterruptedException , IOException { return deleteUser ( uid , new DateTime ( ) ) ; }
Deletes a user . Event time is recorded as the time when the function is called .
3,937
public FutureAPIResponse setItemAsFuture ( String iid , Map < String , Object > properties , DateTime eventTime ) throws IOException { return createEventAsFuture ( new Event ( ) . event ( "$set" ) . entityType ( "item" ) . entityId ( iid ) . eventTime ( eventTime ) . properties ( properties ) ) ; }
Sends a set item properties request . Implicitly creates the item if it s not already there . Properties could be empty .
3,938
public String setItem ( String iid , Map < String , Object > properties , DateTime eventTime ) throws ExecutionException , InterruptedException , IOException { return createEvent ( setItemAsFuture ( iid , properties , eventTime ) ) ; }
Sets properties of a item . Implicitly creates the item if it s not already there . Properties could be empty .
3,939
public FutureAPIResponse unsetItemAsFuture ( String iid , List < String > properties , DateTime eventTime ) throws IOException { if ( properties . isEmpty ( ) ) { throw new IllegalStateException ( "property list cannot be empty" ) ; } Map < String , Object > propertiesMap = Maps . newHashMap ( ) ; for ( String property...
Sends an unset item properties request . The list must not be empty .
3,940
public String unsetItem ( String iid , List < String > properties , DateTime eventTime ) throws ExecutionException , InterruptedException , IOException { return createEvent ( unsetItemAsFuture ( iid , properties , eventTime ) ) ; }
Unsets properties of a item . The list must not be empty .
3,941
public FutureAPIResponse deleteItemAsFuture ( String iid , DateTime eventTime ) throws IOException { return createEventAsFuture ( new Event ( ) . event ( "$delete" ) . entityType ( "item" ) . entityId ( iid ) . eventTime ( eventTime ) ) ; }
Sends a delete item request .
3,942
public String deleteItem ( String iid , DateTime eventTime ) throws ExecutionException , InterruptedException , IOException { return createEvent ( deleteItemAsFuture ( iid , eventTime ) ) ; }
Deletes a item .
3,943
public String deleteItem ( String iid ) throws ExecutionException , InterruptedException , IOException { return deleteItem ( iid , new DateTime ( ) ) ; }
Deletes a item . Event time is recorded as the time when the function is called .
3,944
public FutureAPIResponse userActionItemAsFuture ( String action , String uid , String iid , Map < String , Object > properties , DateTime eventTime ) throws IOException { return createEventAsFuture ( new Event ( ) . event ( action ) . entityType ( "user" ) . entityId ( uid ) . targetEntityType ( "item" ) . targetEntity...
Sends a user - action - on - item request .
3,945
public String userActionItem ( String action , String uid , String iid , Map < String , Object > properties , DateTime eventTime ) throws ExecutionException , InterruptedException , IOException { return createEvent ( userActionItemAsFuture ( action , uid , iid , properties , eventTime ) ) ; }
Records a user - action - on - item event .
3,946
public void createEvent ( String eventName , String entityType , String entityId , String targetEntityType , String targetEntityId , Map < String , Object > properties , DateTime eventTime ) throws IOException { if ( eventTime == null ) { eventTime = new DateTime ( ) ; } Event event = new Event ( ) . event ( eventName ...
Create and write a json - encoded event to the underlying file .
3,947
public void log ( Object ... args ) { if ( ! isRateLimited ( ) ) { level . log ( logger , message , args ) ; } incrementStats ( ) ; }
logging APIs .
3,948
public FutureAPIResponse sendQueryAsFuture ( Map < String , Object > query ) throws ExecutionException , InterruptedException , IOException { RequestBuilder builder = new RequestBuilder ( "POST" ) ; builder . setUrl ( apiUrl + "/queries.json" ) ; GsonBuilder gsonBuilder = new GsonBuilder ( ) ; gsonBuilder . registerTyp...
Sends a query asynchronously .
3,949
public JsonObject sendQuery ( Map < String , Object > query ) throws ExecutionException , InterruptedException , IOException { return sendQuery ( sendQueryAsFuture ( query ) ) ; }
Sends a query synchronously .
3,950
public JsonObject sendQuery ( FutureAPIResponse response ) throws ExecutionException , InterruptedException , IOException { int status = response . get ( ) . getStatus ( ) ; String message = response . get ( ) . getMessage ( ) ; if ( status != HTTP_OK ) { throw new IOException ( status + " " + message ) ; } return ( ( ...
Gets query result from a previously sent asynchronous request .
3,951
public static RateLimitedLogBuilder . MissingRateAndPeriod withRateLimit ( Logger logger ) { return new RateLimitedLogBuilder . MissingRateAndPeriod ( Objects . requireNonNull ( logger ) ) ; }
Start building a new RateLimitedLog wrapping the SLF4J logger
3,952
private void outOfCacheCapacity ( ) { synchronized ( knownPatterns ) { if ( knownPatterns . size ( ) > MAX_PATTERNS_PER_LOG ) { logger . warn ( "out of capacity in RateLimitedLog registry; accidentally " + "using interpolated strings as patterns?" ) ; registry . flush ( ) ; knownPatterns . clear ( ) ; } } }
We ve run out of capacity in our cache of RateLimitedLogWithPattern objects . This probably means that the caller is accidentally calling us with an already - interpolated string instead of using the pattern as the key and letting us do the interpolation . Don t lose data ; instead fall back to flushing the entire cach...
3,953
public void setClearVisible ( boolean visible ) { if ( mClearButtonEnabled ) { final Drawable d = ( visible ? mTappableDrawable : null ) ; final Drawable [ ] drawables = getCompoundDrawables ( ) ; if ( drawables != null ) { setCompoundDrawables ( drawables [ 0 ] , drawables [ 1 ] , d , drawables [ 3 ] ) ; } else { Log ...
Sets the visibility of the clear button . The clear button must also be enabled for it to be visible .
3,954
public String getStatus ( ) throws ExecutionException , InterruptedException , IOException { return ( new FutureAPIResponse ( client . prepareGet ( apiUrl ) . execute ( getHandler ( ) ) ) ) . get ( ) . getMessage ( ) ; }
Get status of the API .
3,955
public static SecretKey generateKey ( final byte [ ] key ) { return new SecretKey ( ) { private byte [ ] k ; { if ( key . length == 16 ) { k = key ; } else { k = new byte [ 16 ] ; System . arraycopy ( key , 0 , k , 0 , key . length < 16 ? key . length : 16 ) ; } } public String getAlgorithm ( ) { return "AES" ; } publi...
16 bytes max 128 - bit encription
3,956
public void setAxis ( int axis ) { boolean axisChanged = ( axis != majorAxis ) ; majorAxis = axis ; if ( axisChanged ) { preferenceChanged ( null , true , true ) ; } }
Sets the tile axis property . This is the axis along which the child views are tiled .
3,957
private Rectangle getCompleteBoxAllocation ( Box b ) { Rectangle ret = b . getAbsoluteBounds ( ) ; if ( b instanceof ElementBox ) { ElementBox eb = ( ElementBox ) b ; for ( int i = eb . getStartChild ( ) ; i < eb . getEndChild ( ) ; i ++ ) { Box child = eb . getSubBox ( i ) ; if ( child . isVisible ( ) ) { Rectangle r ...
Obtains the allocation of a box together with all its child boxes .
3,958
protected boolean isBefore ( int x , int y , Rectangle innerAlloc ) { innerAlloc . setBounds ( box . getAbsoluteBounds ( ) ) ; if ( majorAxis == View . X_AXIS ) { return ( x < innerAlloc . x ) ; } else { return ( y < innerAlloc . y ) ; } }
Determines if a point falls before an allocated region .
3,959
protected boolean isAfter ( int x , int y , Rectangle innerAlloc ) { innerAlloc . setBounds ( box . getAbsoluteBounds ( ) ) ; if ( majorAxis == View . X_AXIS ) { return ( x > ( innerAlloc . width + innerAlloc . x ) ) ; } else { return ( y > ( innerAlloc . height + innerAlloc . y ) ) ; } }
Determines if a point falls after an allocated region .
3,960
protected boolean validateLayout ( Dimension dim ) { if ( majorAxis == X_AXIS ) { majorRequest = getRequirements ( X_AXIS , majorRequest ) ; minorRequest = getRequirements ( Y_AXIS , minorRequest ) ; oldDimension . setSize ( majorRequest . preferred , minorRequest . preferred ) ; } else { majorRequest = getRequirements...
Validates layout .
3,961
public static final Rectangle toRect ( Shape a ) { return a instanceof Rectangle ? ( Rectangle ) a : a . getBounds ( ) ; }
Converts an Shape to instance of rectangle
3,962
public static final boolean intersection ( Rectangle src1 , Rectangle src2 , Rectangle dest ) { int x1 = Math . max ( src1 . x , src2 . x ) ; int y1 = Math . max ( src1 . y , src2 . y ) ; int x2 = Math . min ( src1 . x + src1 . width , src2 . x + src2 . width ) ; int y2 = Math . min ( src1 . y + src1 . height , src2 . ...
Calculates intersection of two rectangles
3,963
public static final Box getBox ( CSSBoxView v ) { try { AttributeSet attr = v . getAttributes ( ) ; return ( Box ) attr . getAttribute ( Constants . ATTRIBUTE_BOX_REFERENCE ) ; } catch ( Exception e ) { throw new IllegalStateException ( e ) ; } }
Gets the box reference from properties
3,964
public static final Box getBox ( View v ) { if ( v instanceof CSSBoxView ) return getBox ( ( CSSBoxView ) v ) ; AttributeSet attr = v . getAttributes ( ) ; if ( attr == null ) { throw new NullPointerException ( "AttributeSet of " + v . getClass ( ) . getName ( ) + "@" + Integer . toHexString ( v . hashCode ( ) ) + " is...
Gets the box reference from properties .
3,965
public void activateTooltip ( boolean show ) { if ( show ) { ToolTipManager . sharedInstance ( ) . registerComponent ( this ) ; } else { ToolTipManager . sharedInstance ( ) . unregisterComponent ( this ) ; } ToolTipManager . sharedInstance ( ) . setEnabled ( show ) ; }
Activates tooltips .
3,966
public void fireGeneralEvent ( GeneralEvent e ) { Object [ ] listeners = listenerList . getListenerList ( ) ; for ( int i = listeners . length - 2 ; i >= 0 ; i -= 2 ) { if ( listeners [ i ] == GeneralEventListener . class ) { ( ( GeneralEventListener ) listeners [ i + 1 ] ) . generalEventUpdate ( e ) ; } } }
Fires general event . All registered listeners will be notified .
3,967
public Graphics2D renderContent ( ) { View view = null ; ViewFactory factory = getEditorKit ( ) . getViewFactory ( ) ; if ( factory instanceof SwingBoxViewFactory ) { view = ( ( SwingBoxViewFactory ) factory ) . getViewport ( ) ; } if ( view != null ) { int w = ( int ) view . getPreferredSpan ( View . X_AXIS ) ; int h ...
Renders current content to graphic context which is returned . May return null ;
3,968
public Graphics2D renderContent ( Graphics2D g ) { if ( g . getClip ( ) == null ) throw new NullPointerException ( "Clip is not set on graphics context" ) ; ViewFactory factory = getEditorKit ( ) . getViewFactory ( ) ; if ( factory instanceof SwingBoxViewFactory ) { View view = ( ( SwingBoxViewFactory ) factory ) . get...
Renders current content to given graphic context which is updated and returned . Context must have set the clip otherwise NullPointerException is thrown .
3,969
public boolean setCSSBoxAnalyzer ( CSSBoxAnalyzer cba ) { EditorKit kit = getEditorKit ( ) ; if ( kit instanceof SwingBoxEditorKit ) { ( ( SwingBoxEditorKit ) kit ) . setCSSBoxAnalyzer ( cba ) ; return true ; } return false ; }
Sets the css box analyzer .
3,970
public JFrame getMainWindow ( ) { if ( mainWindow == null ) { mainWindow = new JFrame ( ) ; mainWindow . setTitle ( "Swing Browser" ) ; mainWindow . setVisible ( true ) ; mainWindow . setBounds ( new Rectangle ( 0 , 0 , 583 , 251 ) ) ; mainWindow . setContentPane ( getMainPanel ( ) ) ; mainWindow . addWindowListener ( ...
This method initializes jFrame
3,971
private static int [ ] makeCharTable ( byte [ ] needle ) { int [ ] table = new int [ ALPHABET_SIZE ] ; int l = needle . length ; for ( int i = 0 ; i < ALPHABET_SIZE ; ++ i ) { table [ i ] = l ; } l -- ; for ( int i = 0 ; i < l ; ++ i ) { table [ needle [ i ] & 0xff ] = l - i ; } return table ; }
Makes the jump table based on the mismatched character information .
3,972
private static int [ ] makeOffsetTable ( byte [ ] needle ) { int l = needle . length ; int [ ] table = new int [ l ] ; int lastPrefixPosition = l ; for ( int i = l - 1 ; i >= 0 ; -- i ) { if ( isPrefix ( needle , i + 1 ) ) { lastPrefixPosition = i + 1 ; } table [ l - 1 - i ] = lastPrefixPosition - i + l - 1 ; } for ( i...
Makes the jump table based on the scan offset which mismatch occurs .
3,973
private static int suffixLength ( byte [ ] needle , int p ) { int len = 0 ; for ( int i = p , j = needle . length - 1 ; i >= 0 && needle [ i ] == needle [ j ] ; -- i , -- j ) { len ++ ; } return len ; }
Returns the maximum length of the substring ends at p and is a suffix .
3,974
protected void processPaint ( Graphics gg , Shape a ) { Graphics2D g = ( Graphics2D ) gg ; AffineTransform tmpTransform = g . getTransform ( ) ; if ( ! tmpTransform . equals ( transform ) ) { transform = tmpTransform ; invalidateTextLayout ( ) ; } Component c = container ; int p0 = getStartOffset ( ) ; int p1 = getEndO...
Process paint .
3,975
protected void renderContent ( Graphics2D g , Shape a , Color fg , int p0 , int p1 ) { TextLayout layout = getTextLayout ( ) ; Rectangle absoluteBounds = box . getAbsoluteBounds ( ) ; Rectangle absoluteContentBounds = box . getAbsoluteContentBounds ( ) ; int pStart = getStartOffset ( ) ; int pEnd = getEndOffset ( ) ; i...
Renders content .
3,976
protected void repaint ( final int ms , final Rectangle bounds ) { if ( container != null ) { container . repaint ( ms , bounds . x , bounds . y , bounds . width , bounds . height ) ; } }
Repaints the content used by blink decoration .
3,977
protected Rectangle2D getStringBounds ( TextLayout tl ) { return new Rectangle2D . Float ( 0 , - tl . getAscent ( ) , tl . getAdvance ( ) , tl . getAscent ( ) + tl . getDescent ( ) + tl . getLeading ( ) ) ; }
Gets the string bounds .
3,978
protected String getTextEx ( int position , int len ) { try { return getDocument ( ) . getText ( position , len ) ; } catch ( BadLocationException e ) { e . printStackTrace ( ) ; return "" ; } }
Gets the text .
3,979
protected void setPropertiesFromAttributes ( AttributeSet attr ) { if ( attr != null ) { Font newFont = ( Font ) attr . getAttribute ( Constants . ATTRIBUTE_FONT ) ; if ( newFont != null ) { setFont ( newFont ) ; } else { throw new IllegalStateException ( "Font can not be null !" ) ; } setForeground ( ( Color ) attr . ...
Sets the properties from the attributes .
3,980
protected void setFont ( Font newFont ) { if ( font == null || ! font . equals ( newFont ) ) { font = new Font ( newFont . getAttributes ( ) ) ; invalidateCache ( ) ; invalidateTextLayout ( ) ; } }
Sets the font .
3,981
protected void setForeground ( Color newColor ) { if ( foreground == null || ! foreground . equals ( newColor ) ) { foreground = new Color ( newColor . getRGB ( ) ) ; invalidateCache ( ) ; } }
Sets the foreground .
3,982
protected void setFontVariant ( String newFontVariant ) { if ( fontVariant == null || ! fontVariant . equals ( newFontVariant ) ) { FontVariant val [ ] = FontVariant . values ( ) ; for ( FontVariant aVal : val ) { if ( aVal . toString ( ) . equals ( newFontVariant ) ) { fontVariant = newFontVariant ; invalidateCache ( ...
Sets the font variant .
3,983
protected void setTextDecoration ( List < TextDecoration > newTextDecoration ) { if ( textDecoration == null || ! textDecoration . equals ( newTextDecoration ) ) { textDecoration = newTextDecoration ; reflectTextDecoration ( textDecoration ) ; invalidateCache ( ) ; } }
Sets the text decoration .
3,984
protected TextLayout getTextLayout ( ) { if ( refreshTextLayout ) { refreshTextLayout = false ; layout = new TextLayout ( getText ( ) , getFont ( ) , new FontRenderContext ( transform , true , false ) ) ; } return layout ; }
Gets the text layout .
3,985
public void update ( SwingBoxDocument doc , Viewport root , Dimension dim ) throws IOException { ContentReader rdr = new ContentReader ( ) ; List < ElementSpec > elements = rdr . update ( root , dim , getCSSBoxAnalyzer ( ) ) ; ElementSpec elementsArray [ ] = elements . toArray ( new ElementSpec [ 0 ] ) ; doc . create (...
Updates layout using new dimensions .
3,986
protected void loadPage ( JEditorPane pane , HyperlinkEvent evt ) { try { pane . setPage ( evt . getURL ( ) ) ; } catch ( IOException e ) { System . err . println ( e . getLocalizedMessage ( ) ) ; } }
Loads given page as HyperlinkEvent .
3,987
public List < ElementSpec > read ( DocumentSource docSource , CSSBoxAnalyzer cba , Dimension dim ) throws IOException { if ( cba == null ) throw new IllegalArgumentException ( "CSSBoxAnalyzer can not be NULL !!!\nProvide your custom implementation or check instantiation of DefaultAnalyzer object..." ) ; elements = new ...
Reads input data and converts them to elements
3,988
public List < ElementSpec > update ( Viewport root , Dimension newDimension , CSSBoxAnalyzer cba ) throws IOException { if ( cba == null ) throw new IllegalArgumentException ( "CSSBoxAnalyzer can not be NULL !!!\nProvide your custom implementation or check instantiation of DefaultAnalyzer object..." ) ; elements = new ...
Updates the layout . It is designed to do a re - layout only not to process input data again .
3,989
void HuffmanBlockEncoder ( BufferedOutputStream outStream , int zigzag [ ] , int prec , int DCcode , int ACcode ) throws IOException { int temp , temp2 , nbits , k , r , i ; temp = temp2 = zigzag [ 0 ] - prec ; if ( temp < 0 ) { temp = - temp ; temp2 -- ; } nbits = 0 ; while ( temp != 0 ) { nbits ++ ; temp >>= 1 ; } bu...
HuffmanBlockEncoder run length encodes and Huffman encodes the quantized data .
3,990
void bufferIt ( BufferedOutputStream outStream , int code , int size ) throws IOException { int PutBuffer = code ; int PutBits = bufferPutBits ; PutBuffer &= ( 1 << size ) - 1 ; PutBits += size ; PutBuffer <<= 24 - PutBits ; PutBuffer |= bufferPutBuffer ; while ( PutBits >= 8 ) { int c = ( ( PutBuffer >> 16 ) & 0xFF ) ...
and sends them to outStream by the byte .
3,991
public boolean check ( String value , String hashString ) { return update ( value . getBytes ( ) ) . asString ( ) . equalsIgnoreCase ( hashString ) ; }
get hash from given string and check for equals it with hashString
3,992
public < T > Flow < T > map ( Mapper < ? super B , T > mapper ) { return then ( new FlowMap < B , T > ( mapper ) ) ; }
converts B into T with Mapper ignores null - values
3,993
public static org . w3c . dom . Element findAnchorElement ( org . w3c . dom . Element e ) { if ( "a" . equalsIgnoreCase ( e . getTagName ( ) . trim ( ) ) ) return e ; else if ( e . getParentNode ( ) != null && e . getParentNode ( ) . getNodeType ( ) == Node . ELEMENT_NODE ) return findAnchorElement ( ( org . w3c . dom ...
Examines the given element and all its parent elements in order to find the a element .
3,994
public void setParent ( View parent ) { if ( parent == null && view != null ) view . setParent ( null ) ; this . parent = parent ; if ( ( parent != null ) && ( getElement ( ) != null ) ) { ViewFactory f = getViewFactory ( ) ; loadChildren ( f ) ; } }
Sets the view parent .
3,995
public String getDelegateName ( ) { javax . swing . text . Element data = getElement ( ) ; if ( data instanceof DelegateElement ) { return ( ( DelegateElement ) data ) . getDelegateName ( ) ; } return null ; }
Gets the name of delegate
3,996
public float getMaximumSpan ( int axis ) { if ( view != null ) { return view . getMaximumSpan ( axis ) ; } return Integer . MAX_VALUE ; }
Determines the maximum span for this view along an axis .
3,997
public void paint ( Graphics g , Shape allocation ) { if ( view != null ) { view . paint ( g , allocation ) ; } }
Renders the view .
3,998
public Shape getChildAllocation ( int index , Shape a ) { if ( view != null ) return view . getChildAllocation ( index , a ) ; return a ; }
Fetches the allocation for the given child view . This enables finding out where various views are located without assuming the views store their location . This returns the given allocation since this view simply acts as a gateway between the view hierarchy and the associated component .
3,999
public int viewToModel ( float x , float y , Shape a , Position . Bias [ ] bias ) { if ( view != null ) { int retValue = view . viewToModel ( x , y , a , bias ) ; return retValue ; } return - 1 ; }
Provides a mapping from the view coordinate space to the logical coordinate space of the model .