idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
25,900 | private static ClassLoader getParentCl ( ) { try { Method m = ClassLoader . class . getMethod ( "getPlatformClassLoader" ) ; return ( ClassLoader ) m . invoke ( null ) ; } catch ( NoSuchMethodException e ) { return null ; } catch ( Exception e ) { throw new JqmInitError ( "Could not fetch Platform Class Loader" , e ) ;... | A helper - in Java 9 the extension CL was renamed to platform CL and hosts all the JDK classes . Before 9 it was useless and we used bootstrap CL instead . |
25,901 | public static Properties loadProperties ( String [ ] filesToLoad ) { Properties p = new Properties ( ) ; InputStream fis = null ; for ( String path : filesToLoad ) { try { fis = Db . class . getClassLoader ( ) . getResourceAsStream ( path ) ; if ( fis != null ) { p . load ( fis ) ; jqmlogger . info ( "A jqm.properties ... | Helper method to load a property file from class path . |
25,902 | private void init ( boolean upgrade ) { initAdapter ( ) ; initQueries ( ) ; if ( upgrade ) { dbUpgrade ( ) ; } boolean versionValid = false ; while ( ! versionValid ) { try { checkSchemaVersion ( ) ; versionValid = true ; } catch ( Exception e ) { String msg = e . getLocalizedMessage ( ) ; if ( e . getCause ( ) != null... | Main database initialization . To be called only when _ds is a valid DataSource . |
25,903 | private void dbUpgrade ( ) { DbConn cnx = this . getConn ( ) ; Map < String , Object > rs = null ; int db_schema_version = 0 ; try { rs = cnx . runSelectSingleRow ( "version_select_latest" ) ; db_schema_version = ( Integer ) rs . get ( "VERSION_D1" ) ; } catch ( Exception e ) { } cnx . rollback ( ) ; if ( SCHEMA_VERSIO... | Updates the database . Never call this during normal operations upgrade is a user - controlled operation . |
25,904 | private void initAdapter ( ) { Connection tmp = null ; DatabaseMetaData meta = null ; try { tmp = _ds . getConnection ( ) ; meta = tmp . getMetaData ( ) ; product = meta . getDatabaseProductName ( ) . toLowerCase ( ) ; } catch ( SQLException e ) { throw new DatabaseException ( "Cannot connect to the database" , e ) ; }... | Creates the adapter for the target database . |
25,905 | public DbConn getConn ( ) { Connection cnx = null ; try { Thread . interrupted ( ) ; cnx = _ds . getConnection ( ) ; if ( cnx . getAutoCommit ( ) ) { cnx . setAutoCommit ( false ) ; cnx . rollback ( ) ; } if ( cnx . getTransactionIsolation ( ) != Connection . TRANSACTION_READ_COMMITTED ) { cnx . setTransactionIsolation... | A connection to the database . Should be short - lived . No transaction active by default . |
25,906 | String getQuery ( String key ) { String res = this . adapter . getSqlText ( key ) ; if ( res == null ) { throw new DatabaseException ( "Query " + key + " does not exist" ) ; } return res ; } | Gets the interpolated text of a query from cache . If key does not exist an exception is thrown . |
25,907 | public RuntimeParameter addParameter ( String key , String value ) { RuntimeParameter jp = new RuntimeParameter ( ) ; jp . setJi ( this . getId ( ) ) ; jp . setKey ( key ) ; jp . setValue ( value ) ; return jp ; } | Helper method to add a parameter without having to create it explicitely . The created parameter should be persisted afterwards . |
25,908 | void endOfRunDb ( ) { DbConn cnx = null ; try { cnx = Helpers . getNewDbSession ( ) ; History . create ( cnx , this . ji , this . resultStatus , endDate ) ; jqmlogger . trace ( "An History was just created for job instance " + this . ji . getId ( ) ) ; cnx . runUpdate ( "ji_delete_by_id" , this . ji . getId ( ) ) ; cnx... | Part of the endOfRun process that needs the database . May be deferred if the database is not available . |
25,909 | private Integer highlanderMode ( JobDef jd , DbConn cnx ) { if ( ! jd . isHighlander ( ) ) { return null ; } try { Integer existing = cnx . runSelectSingle ( "ji_select_existing_highlander" , Integer . class , jd . getId ( ) ) ; return existing ; } catch ( NoResultException ex ) { } ResultSet rs = cnx . runSelect ( tru... | Helper . Current transaction is committed in some cases . |
25,910 | private String getStringPredicate ( String fieldName , List < String > filterValues , List < Object > prms ) { if ( filterValues != null && ! filterValues . isEmpty ( ) ) { String res = "" ; for ( String filterValue : filterValues ) { if ( filterValue == null ) { continue ; } if ( ! filterValue . isEmpty ( ) ) { prms .... | GetJob helper - String predicates are all created the same way so this factors some code . |
25,911 | public void prepare ( Properties p , Connection cnx ) { this . tablePrefix = p . getProperty ( "com.enioka.jqm.jdbc.tablePrefix" , "" ) ; queries . putAll ( DbImplBase . queries ) ; for ( Map . Entry < String , String > entry : DbImplBase . queries . entrySet ( ) ) { queries . put ( entry . getKey ( ) , this . adaptSql... | Called after creating the first connection . The adapter should create its caches and do all initialization it requires . Most importantly the SQL query cache should be created . |
25,912 | public boolean accept ( File file ) { if ( file . isDirectory ( ) && file . canRead ( ) ) { return true ; } else if ( properties . selection_type == DialogConfigs . DIR_SELECT ) { return false ; } else { String name = file . getName ( ) . toLowerCase ( Locale . getDefault ( ) ) ; for ( String ext : validExtensions ) { ... | Function to filter files based on defined rules . |
25,913 | public void setSize ( int size ) { if ( size != MaterialProgressDrawable . LARGE && size != MaterialProgressDrawable . DEFAULT ) { return ; } final DisplayMetrics metrics = getResources ( ) . getDisplayMetrics ( ) ; if ( size == MaterialProgressDrawable . LARGE ) { mCircleHeight = mCircleWidth = ( int ) ( CIRCLE_DIAMET... | One of DEFAULT or LARGE . |
25,914 | public void setRefreshing ( boolean refreshing ) { if ( refreshing && mRefreshing != refreshing ) { mRefreshing = refreshing ; int endTarget = 0 ; if ( ! mUsingCustomStart ) { switch ( mDirection ) { case BOTTOM : endTarget = getMeasuredHeight ( ) - ( int ) ( mSpinnerFinalOffset ) ; break ; case TOP : default : endTarg... | Notify the widget that refresh state has changed . Do not call this when refresh is triggered by a swipe gesture . |
25,915 | private void setAnimationProgress ( float progress ) { if ( isAlphaUsedForScale ( ) ) { setColorViewAlpha ( ( int ) ( progress * MAX_ALPHA ) ) ; } else { ViewCompat . setScaleX ( mCircleView , progress ) ; ViewCompat . setScaleY ( mCircleView , progress ) ; } } | Pre API 11 this does an alpha animation . |
25,916 | public void setProgressBackgroundColor ( int colorRes ) { mCircleView . setBackgroundColor ( colorRes ) ; mProgress . setBackgroundColor ( getResources ( ) . getColor ( colorRes ) ) ; } | Set the background color of the progress spinner disc . |
25,917 | private void setRawDirection ( SwipyRefreshLayoutDirection direction ) { if ( mDirection == direction ) { return ; } mDirection = direction ; switch ( mDirection ) { case BOTTOM : mCurrentTargetOffsetTop = mOriginalOffsetTop = getMeasuredHeight ( ) ; break ; case TOP : default : mCurrentTargetOffsetTop = mOriginalOffse... | only TOP or Bottom |
25,918 | public static boolean uniform ( Color color , Pixel [ ] pixels ) { return Arrays . stream ( pixels ) . allMatch ( p -> p . toInt ( ) == color . toRGB ( ) . toInt ( ) ) ; } | Returns true if all pixels in the array have the same color |
25,919 | public static int scale ( Double factor , int pixel ) { return rgb ( ( int ) Math . round ( factor * red ( pixel ) ) , ( int ) Math . round ( factor * green ( pixel ) ) , ( int ) Math . round ( factor * blue ( pixel ) ) ) ; } | Scales the brightness of a pixel . |
25,920 | public void set ( String name , Object value ) { hashAttributes . put ( name , value ) ; if ( plugin != null ) { plugin . invalidate ( ) ; } } | Set an attribute . |
25,921 | public static int wavelengthToRGB ( float wavelength ) { float gamma = 0.80f ; float r , g , b , factor ; int w = ( int ) wavelength ; if ( w < 380 ) { r = 0.0f ; g = 0.0f ; b = 0.0f ; } else if ( w < 440 ) { r = - ( wavelength - 440 ) / ( 440 - 380 ) ; g = 0.0f ; b = 1.0f ; } else if ( w < 490 ) { r = 0.0f ; g = ( wav... | Convert a wavelength to an RGB value . |
25,922 | public static void convolveHV ( Kernel kernel , int [ ] inPixels , int [ ] outPixels , int width , int height , boolean alpha , int edgeAction ) { int index = 0 ; float [ ] matrix = kernel . getKernelData ( null ) ; int rows = kernel . getHeight ( ) ; int cols = kernel . getWidth ( ) ; int rows2 = rows / 2 ; int cols2 ... | Convolve with a 2D kernel . |
25,923 | private void initPixelsArray ( BufferedImage image ) { int width = image . getWidth ( ) ; int height = image . getHeight ( ) ; pixels = new int [ width * height ] ; image . getRGB ( 0 , 0 , width , height , pixels , 0 , width ) ; } | takes the pixels from a BufferedImage and stores them in an array |
25,924 | private int [ ] changeColor ( ) { int [ ] changedPixels = new int [ pixels . length ] ; double frequenz = 2 * Math . PI / 1020 ; for ( int i = 0 ; i < pixels . length ; i ++ ) { int argb = pixels [ i ] ; int a = ( argb >> 24 ) & 0xff ; int r = ( argb >> 16 ) & 0xff ; int g = ( argb >> 8 ) & 0xff ; int b = argb & 0xff ;... | changes the color of the image - more red and less blue |
25,925 | private static Set < String > imageOrientationsOf ( ImageMetadata metadata ) { String exifIFD0DirName = new ExifIFD0Directory ( ) . getName ( ) ; Tag [ ] tags = Arrays . stream ( metadata . getDirectories ( ) ) . filter ( dir -> dir . getName ( ) . equals ( exifIFD0DirName ) ) . findFirst ( ) . map ( Directory :: getTa... | returns the values of the orientation tag |
25,926 | public static float noise1 ( float x ) { int bx0 , bx1 ; float rx0 , rx1 , sx , t , u , v ; if ( start ) { start = false ; init ( ) ; } t = x + N ; bx0 = ( ( int ) t ) & BM ; bx1 = ( bx0 + 1 ) & BM ; rx0 = t - ( int ) t ; rx1 = rx0 - 1.0f ; sx = sCurve ( rx0 ) ; u = rx0 * g1 [ p [ bx0 ] ] ; v = rx1 * g1 [ p [ bx1 ] ] ;... | Compute 1 - dimensional Perlin noise . |
25,927 | public static float noise2 ( float x , float y ) { int bx0 , bx1 , by0 , by1 , b00 , b10 , b01 , b11 ; float rx0 , rx1 , ry0 , ry1 , q [ ] , sx , sy , a , b , t , u , v ; int i , j ; if ( start ) { start = false ; init ( ) ; } t = x + N ; bx0 = ( ( int ) t ) & BM ; bx1 = ( bx0 + 1 ) & BM ; rx0 = t - ( int ) t ; rx1 = r... | Compute 2 - dimensional Perlin noise . |
25,928 | private List < Pair < Integer , Double > > integerPixelCoordinatesAndWeights ( double d , int numPixels ) { if ( d <= 0.5 ) return Collections . singletonList ( new Pair < > ( 0 , 1.0 ) ) ; else if ( d >= numPixels - 0.5 ) return Collections . singletonList ( new Pair < > ( numPixels - 1 , 1.0 ) ) ; else { double shift... | Operates on one dimension at a time . |
25,929 | public static BufferedImage createImage ( ImageProducer producer ) { PixelGrabber pg = new PixelGrabber ( producer , 0 , 0 , - 1 , - 1 , null , 0 , 0 ) ; try { pg . grabPixels ( ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( "Image fetch interrupted" ) ; } if ( ( pg . status ( ) & ImageObserver .... | Cretae a BufferedImage from an ImageProducer . |
25,930 | public static BufferedImage convertImageToARGB ( Image image ) { if ( image instanceof BufferedImage && ( ( BufferedImage ) image ) . getType ( ) == BufferedImage . TYPE_INT_ARGB ) return ( BufferedImage ) image ; BufferedImage p = new BufferedImage ( image . getWidth ( null ) , image . getHeight ( null ) , BufferedIma... | Convert an Image into a TYPE_INT_ARGB BufferedImage . If the image is already of this type the original image is returned unchanged . |
25,931 | public static BufferedImage cloneImage ( BufferedImage image ) { BufferedImage newImage = new BufferedImage ( image . getWidth ( ) , image . getHeight ( ) , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D g = newImage . createGraphics ( ) ; g . drawRenderedImage ( image , null ) ; g . dispose ( ) ; return newImage ; } | Clones a BufferedImage . |
25,932 | public static void paintCheckedBackground ( Component c , Graphics g , int x , int y , int width , int height ) { if ( backgroundImage == null ) { backgroundImage = new BufferedImage ( 64 , 64 , BufferedImage . TYPE_INT_ARGB ) ; Graphics bg = backgroundImage . createGraphics ( ) ; for ( int by = 0 ; by < 64 ; by += 8 )... | Paint a check pattern used for a background to indicate image transparency . |
25,933 | public static Rectangle getSelectedBounds ( BufferedImage p ) { int width = p . getWidth ( ) ; int height = p . getHeight ( ) ; int maxX = 0 , maxY = 0 , minX = width , minY = height ; boolean anySelected = false ; int y1 ; int [ ] pixels = null ; for ( y1 = height - 1 ; y1 >= 0 ; y1 -- ) { pixels = getRGB ( p , 0 , y1... | Calculates the bounds of the non - transparent parts of the given image . |
25,934 | public static void composeThroughMask ( Raster src , WritableRaster dst , Raster sel ) { int x = src . getMinX ( ) ; int y = src . getMinY ( ) ; int w = src . getWidth ( ) ; int h = src . getHeight ( ) ; int srcRGB [ ] = null ; int selRGB [ ] = null ; int dstRGB [ ] = null ; for ( int i = 0 ; i < h ; i ++ ) { srcRGB = ... | Compose src onto dst using the alpha of sel to interpolate between the two . I can t think of a way to do this using AlphaComposite . |
25,935 | public void setMatrix ( int [ ] matrix ) { this . matrix = matrix ; sum = 0 ; for ( int i = 0 ; i < matrix . length ; i ++ ) sum += matrix [ i ] ; } | Set the dither matrix . |
25,936 | public static float gain ( float a , float b ) { float c = ( 1.0f / b - 2.0f ) * ( 1.0f - 2.0f * a ) ; if ( a < 0.5 ) return a / ( c + 1.0f ) ; else return ( c - a ) / ( c - 1.0f ) ; } | A variant of the gamma function . |
25,937 | public static float smoothPulse ( float a1 , float a2 , float b1 , float b2 , float x ) { if ( x < a1 || x >= b2 ) return 0 ; if ( x >= a2 ) { if ( x < b1 ) return 1.0f ; x = ( x - b1 ) / ( b2 - b1 ) ; return 1.0f - ( x * x * ( 3.0f - 2.0f * x ) ) ; } x = ( x - a1 ) / ( a2 - a1 ) ; return x * x * ( 3.0f - 2.0f * x ) ; ... | A smoothed pulse function . A cubic function is used to smooth the step between two thresholds . |
25,938 | public static float smoothStep ( float a , float b , float x ) { if ( x < a ) return 0 ; if ( x >= b ) return 1 ; x = ( x - a ) / ( b - a ) ; return x * x * ( 3 - 2 * x ) ; } | A smoothed step function . A cubic function is used to smooth the step between two thresholds . |
25,939 | public static int mixColors ( float t , int rgb1 , int rgb2 ) { int a1 = ( rgb1 >> 24 ) & 0xff ; int r1 = ( rgb1 >> 16 ) & 0xff ; int g1 = ( rgb1 >> 8 ) & 0xff ; int b1 = rgb1 & 0xff ; int a2 = ( rgb2 >> 24 ) & 0xff ; int r2 = ( rgb2 >> 16 ) & 0xff ; int g2 = ( rgb2 >> 8 ) & 0xff ; int b2 = rgb2 & 0xff ; a1 = lerp ( t ... | Linear interpolation of ARGB values . |
25,940 | public static int bilinearInterpolate ( float x , float y , int nw , int ne , int sw , int se ) { float m0 , m1 ; int a0 = ( nw >> 24 ) & 0xff ; int r0 = ( nw >> 16 ) & 0xff ; int g0 = ( nw >> 8 ) & 0xff ; int b0 = nw & 0xff ; int a1 = ( ne >> 24 ) & 0xff ; int r1 = ( ne >> 16 ) & 0xff ; int g1 = ( ne >> 8 ) & 0xff ; i... | Bilinear interpolation of ARGB values . |
25,941 | public static int brightnessNTSC ( int rgb ) { int r = ( rgb >> 16 ) & 0xff ; int g = ( rgb >> 8 ) & 0xff ; int b = rgb & 0xff ; return ( int ) ( r * 0.299f + g * 0.587f + b * 0.114f ) ; } | Return the NTSC gray level of an RGB value . |
25,942 | public static int colorSpline ( int x , int numKnots , int [ ] xknots , int [ ] yknots ) { int span ; int numSpans = numKnots - 3 ; float k0 , k1 , k2 , k3 ; float c0 , c1 , c2 , c3 ; if ( numSpans < 1 ) throw new IllegalArgumentException ( "Too few knots in spline" ) ; for ( span = 0 ; span < numSpans ; span ++ ) if (... | Compute a Catmull - Rom spline for RGB values but with variable knot spacing . |
25,943 | public void copyTo ( Gradient g ) { g . numKnots = numKnots ; g . map = ( int [ ] ) map . clone ( ) ; g . xKnots = ( int [ ] ) xKnots . clone ( ) ; g . yKnots = ( int [ ] ) yKnots . clone ( ) ; g . knotTypes = ( byte [ ] ) knotTypes . clone ( ) ; } | Copy one Gradient into another . |
25,944 | public void setColor ( int n , int color ) { int firstColor = map [ 0 ] ; int lastColor = map [ 256 - 1 ] ; if ( n > 0 ) for ( int i = 0 ; i < n ; i ++ ) map [ i ] = ImageMath . mixColors ( ( float ) i / n , firstColor , color ) ; if ( n < 256 - 1 ) for ( int i = n ; i < 256 ; i ++ ) map [ i ] = ImageMath . mixColors (... | Set a knot color . |
25,945 | public void setKnotType ( int n , int type ) { knotTypes [ n ] = ( byte ) ( ( knotTypes [ n ] & ~ COLOR_MASK ) | type ) ; rebuildGradient ( ) ; } | Set a knot type . |
25,946 | public void setKnotBlend ( int n , int type ) { knotTypes [ n ] = ( byte ) ( ( knotTypes [ n ] & ~ BLEND_MASK ) | type ) ; rebuildGradient ( ) ; } | Set a knot blend type . |
25,947 | public void setKnots ( int [ ] x , int [ ] rgb , byte [ ] types ) { numKnots = rgb . length + 2 ; xKnots = new int [ numKnots ] ; yKnots = new int [ numKnots ] ; knotTypes = new byte [ numKnots ] ; if ( x != null ) System . arraycopy ( x , 0 , xKnots , 1 , numKnots - 2 ) ; else for ( int i = 1 ; i > numKnots - 1 ; i ++... | Set the values of all the knots . This version does not require the extra knots at - 1 and 256 |
25,948 | public void setKnots ( int [ ] x , int [ ] y , byte [ ] types , int offset , int count ) { numKnots = count ; xKnots = new int [ numKnots ] ; yKnots = new int [ numKnots ] ; knotTypes = new byte [ numKnots ] ; System . arraycopy ( x , offset , xKnots , 0 , numKnots ) ; System . arraycopy ( y , offset , yKnots , 0 , num... | Set the values of a set of knots . |
25,949 | public void splitSpan ( int n ) { int x = ( xKnots [ n ] + xKnots [ n + 1 ] ) / 2 ; addKnot ( x , getColor ( x / 256.0f ) , knotTypes [ n ] ) ; rebuildGradient ( ) ; } | Split a span into two by adding a knot in the middle . |
25,950 | public int knotAt ( int x ) { for ( int i = 1 ; i < numKnots - 1 ; i ++ ) if ( xKnots [ i + 1 ] > x ) return i ; return 1 ; } | Return the knot at a given position . |
25,951 | public void randomize ( ) { numKnots = 4 + ( int ) ( 6 * Math . random ( ) ) ; xKnots = new int [ numKnots ] ; yKnots = new int [ numKnots ] ; knotTypes = new byte [ numKnots ] ; for ( int i = 0 ; i < numKnots ; i ++ ) { xKnots [ i ] = ( int ) ( 255 * Math . random ( ) ) ; yKnots [ i ] = 0xff000000 | ( ( int ) ( 255 * ... | Randomize the gradient . |
25,952 | public void mutate ( float amount ) { for ( int i = 0 ; i < numKnots ; i ++ ) { int rgb = yKnots [ i ] ; int r = ( ( rgb >> 16 ) & 0xff ) ; int g = ( ( rgb >> 8 ) & 0xff ) ; int b = ( rgb & 0xff ) ; r = PixelUtils . clamp ( ( int ) ( r + amount * 255 * ( Math . random ( ) - 0.5 ) ) ) ; g = PixelUtils . clamp ( ( int ) ... | Mutate the gradient . |
25,953 | public void setBufferedImage ( BufferedImage img ) { image = img ; width = img . getWidth ( ) ; height = img . getHeight ( ) ; updateColorArray ( ) ; } | Sets a new image |
25,954 | public BufferedImage getNewImageInstance ( ) { BufferedImage buf = new BufferedImage ( image . getWidth ( ) , image . getHeight ( ) , image . getType ( ) ) ; buf . setData ( image . getData ( ) ) ; return buf ; } | Return a new instance of the BufferedImage |
25,955 | public BufferedImage getBufferedImage ( int width , int height ) { BufferedImage buf = new BufferedImage ( width , height , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D g2d = ( Graphics2D ) buf . getGraphics ( ) ; g2d . setRenderingHint ( RenderingHints . KEY_INTERPOLATION , RenderingHints . VALUE_INTERPOLATION_BILINEA... | Resize and return the image passing the new height and width |
25,956 | public void resize ( int w , int h ) { BufferedImage buf = new BufferedImage ( w , h , image . getType ( ) ) ; Graphics2D g2d = ( Graphics2D ) buf . getGraphics ( ) ; g2d . setRenderingHint ( RenderingHints . KEY_INTERPOLATION , RenderingHints . VALUE_INTERPOLATION_BILINEAR ) ; g2d . drawImage ( image , 0 , 0 , w , h ,... | Resize the image passing the new height and width |
25,957 | public double multi8p ( int x , int y , double masc ) { int aR = getIntComponent0 ( x - 1 , y - 1 ) ; int bR = getIntComponent0 ( x - 1 , y ) ; int cR = getIntComponent0 ( x - 1 , y + 1 ) ; int aG = getIntComponent1 ( x - 1 , y - 1 ) ; int bG = getIntComponent1 ( x - 1 , y ) ; int cG = getIntComponent1 ( x - 1 , y + 1 ... | Multiple of gradient windwos per masc relation of x y |
25,958 | public void fillRect ( int x , int y , int w , int h , Color c ) { int color = c . getRGB ( ) ; for ( int i = x ; i < x + w ; i ++ ) { for ( int j = y ; j < y + h ; j ++ ) { setIntColor ( i , j , color ) ; } } } | Fills a rectangle in the image . |
25,959 | public void prepareFilter ( float transition ) { try { method . invoke ( filter , new Object [ ] { new Float ( transition ) } ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Error setting value for property: " + property ) ; } } | Prepare the filter for the transiton at a given time . The default implementation sets the given filter property but you could override this method to make other changes . |
25,960 | public static MarvinImage rgbToBinary ( MarvinImage img , int threshold ) { MarvinImage resultImage = new MarvinImage ( img . getWidth ( ) , img . getHeight ( ) , MarvinImage . COLOR_MODEL_BINARY ) ; for ( int y = 0 ; y < img . getHeight ( ) ; y ++ ) { for ( int x = 0 ; x < img . getWidth ( ) ; x ++ ) { int gray = ( in... | Converts an image in RGB mode to BINARY mode |
25,961 | public static MarvinImage binaryToRgb ( MarvinImage img ) { MarvinImage resultImage = new MarvinImage ( img . getWidth ( ) , img . getHeight ( ) , MarvinImage . COLOR_MODEL_RGB ) ; for ( int y = 0 ; y < img . getHeight ( ) ; y ++ ) { for ( int x = 0 ; x < img . getWidth ( ) ; x ++ ) { if ( img . getBinaryColor ( x , y ... | Converts an image in BINARY mode to RGB mode |
25,962 | public static int [ ] binaryToRgb ( boolean [ ] binaryArray ) { int [ ] rgbArray = new int [ binaryArray . length ] ; for ( int i = 0 ; i < binaryArray . length ; i ++ ) { if ( binaryArray [ i ] ) { rgbArray [ i ] = 0x00000000 ; } else { rgbArray [ i ] = 0x00FFFFFF ; } } return rgbArray ; } | Converts a boolean array containing the pixel data in BINARY mode to an integer array with the pixel data in RGB mode . |
25,963 | public void setAngle ( float angle ) { this . angle = angle ; float cos = ( float ) Math . cos ( angle ) ; float sin = ( float ) Math . sin ( angle ) ; m00 = cos ; m01 = sin ; m10 = - sin ; m11 = cos ; } | Specifies the angle of the effect . |
25,964 | public static int scanright ( Color color , int height , int width , int col , PixelsExtractor f , int tolerance ) { if ( col == width || ! PixelTools . colorMatches ( color , tolerance , f . apply ( new Area ( col , 0 , 1 , height ) ) ) ) return col ; else return scanright ( color , height , width , col + 1 , f , tole... | Starting with the given column index will return the first column index which contains a colour that does not match the given color . |
25,965 | public void clear ( ) { if ( arrMask != null ) { for ( int y = 0 ; y < height ; y ++ ) { for ( int x = 0 ; x < width ; x ++ ) { arrMask [ x ] [ y ] = false ; } } } } | Clear the mask for a new selection |
25,966 | public Pixel [ ] pixels ( ) { Pixel [ ] pixels = new Pixel [ count ( ) ] ; Point [ ] points = points ( ) ; for ( int k = 0 ; k < points . length ; k ++ ) { pixels [ k ] = pixel ( points [ k ] ) ; } return pixels ; } | Returns all the pixels for the image |
25,967 | public boolean forall ( PixelPredicate predicate ) { return Arrays . stream ( points ( ) ) . allMatch ( p -> predicate . test ( p . x , p . y , pixel ( p ) ) ) ; } | Returns true if the predicate is true for all pixels in the image . |
25,968 | public void foreach ( PixelFunction fn ) { Arrays . stream ( points ( ) ) . forEach ( p -> fn . apply ( p . x , p . y , pixel ( p ) ) ) ; } | Executes the given side effecting function on each pixel . |
25,969 | public boolean contains ( Color color ) { return exists ( p -> p . toInt ( ) == color . toPixel ( ) . toInt ( ) ) ; } | Returns true if a pixel with the given color exists |
25,970 | public int [ ] argb ( int x , int y ) { Pixel p = pixel ( x , y ) ; return new int [ ] { p . alpha ( ) , p . red ( ) , p . green ( ) , p . blue ( ) } ; } | Returns the ARGB components for the pixel at the given coordinates |
25,971 | public int [ ] [ ] argb ( ) { return Arrays . stream ( points ( ) ) . map ( p -> argb ( p . x , p . y ) ) . toArray ( int [ ] [ ] :: new ) ; } | Returns the ARGB components for all pixels in this image |
25,972 | public Set < RGBColor > colours ( ) { return stream ( ) . map ( Pixel :: toColor ) . collect ( Collectors . toSet ( ) ) ; } | Returns a set of the distinct colours used in this image . |
25,973 | public BufferedImage toNewBufferedImage ( int type ) { BufferedImage target = new BufferedImage ( width , height , type ) ; Graphics2D g2 = ( Graphics2D ) target . getGraphics ( ) ; g2 . drawImage ( awt , 0 , 0 , null ) ; g2 . dispose ( ) ; return target ; } | Returns a new AWT BufferedImage from this image . |
25,974 | public static Dimension dimensionsToFit ( Dimension target , Dimension source ) { int maxWidth ; if ( target . getX ( ) == 0 ) { maxWidth = source . getX ( ) ; } else { maxWidth = target . getX ( ) ; } int maxHeight ; if ( target . getY ( ) == 0 ) { maxHeight = source . getY ( ) ; } else { maxHeight = target . getY ( )... | Returns width and height that allow the given source width height to fit inside the target width height without losing aspect ratio |
25,975 | public void setGamma ( float rGamma , float gGamma , float bGamma ) { this . rGamma = rGamma ; this . gGamma = gGamma ; this . bGamma = bGamma ; initialized = false ; } | Set the gamma levels . |
25,976 | public void setColorInterpolated ( int index , int firstIndex , int lastIndex , int color ) { int firstColor = map [ firstIndex ] ; int lastColor = map [ lastIndex ] ; for ( int i = firstIndex ; i <= index ; i ++ ) map [ i ] = ImageMath . mixColors ( ( float ) ( i - firstIndex ) / ( index - firstIndex ) , firstColor , ... | Set the color at index to color . Entries are interpolated linearly from the existing entries at firstIndex and lastIndex to the new entry . firstIndex < index < lastIndex must hold . |
25,977 | public void setColorRange ( int firstIndex , int lastIndex , int color1 , int color2 ) { for ( int i = firstIndex ; i <= lastIndex ; i ++ ) map [ i ] = ImageMath . mixColors ( ( float ) ( i - firstIndex ) / ( lastIndex - firstIndex ) , color1 , color2 ) ; } | Set a range of the colormap interpolating between two colors . |
25,978 | public void setColorRange ( int firstIndex , int lastIndex , int color ) { for ( int i = firstIndex ; i <= lastIndex ; i ++ ) map [ i ] = color ; } | Set a range of the colormap to a single color . |
25,979 | public void buttonClick ( View v ) { switch ( v . getId ( ) ) { case R . id . show : showAppMsg ( ) ; break ; case R . id . cancel_all : AppMsg . cancelAll ( this ) ; break ; default : return ; } } | Button onClick listener . |
25,980 | public LayoutParams getLayoutParams ( ) { if ( mLayoutParams == null ) { mLayoutParams = new LayoutParams ( LayoutParams . MATCH_PARENT , LayoutParams . WRAP_CONTENT ) ; } return mLayoutParams ; } | Gets the crouton s layout parameters constructing a default if necessary . |
25,981 | public AppMsg setLayoutGravity ( int gravity ) { mLayoutParams = new FrameLayout . LayoutParams ( LayoutParams . MATCH_PARENT , LayoutParams . WRAP_CONTENT , gravity ) ; return this ; } | Constructs and sets the layout parameters to have some gravity . |
25,982 | public static int getPercentage ( String percentage ) { if ( isNotEmpty ( percentage ) && isNumeric ( percentage ) ) { int p = Integer . parseInt ( percentage ) ; return p ; } else { return 0 ; } } | Takes a numeric string value and converts it to a integer between 0 and 100 . |
25,983 | public App named ( String name ) { App newApp = copy ( ) ; newApp . name = name ; return newApp ; } | Builder method for specifying the name of an app . |
25,984 | public App on ( Heroku . Stack stack ) { App newApp = copy ( ) ; newApp . stack = new App . Stack ( stack ) ; return newApp ; } | Builder method for specifying the stack an app should be created on . |
25,985 | public Range < App > listApps ( String range ) { return connection . execute ( new AppList ( range ) , apiKey ) ; } | List all apps for the current user s account . |
25,986 | public String renameApp ( String appName , String newName ) { return connection . execute ( new AppRename ( appName , newName ) , apiKey ) . getName ( ) ; } | Rename an existing app . |
25,987 | public AddonChange addAddon ( String appName , String addonName ) { return connection . execute ( new AddonInstall ( appName , addonName ) , apiKey ) ; } | Add an addon to the app . |
25,988 | public List < Addon > listAppAddons ( String appName ) { return connection . execute ( new AppAddonsList ( appName ) , apiKey ) ; } | List the addons already added to an app . |
25,989 | public AddonChange removeAddon ( String appName , String addonName ) { return connection . execute ( new AddonRemove ( appName , addonName ) , apiKey ) ; } | Remove an addon from an app . |
25,990 | public List < Release > listReleases ( String appName ) { return connection . execute ( new ReleaseList ( appName ) , apiKey ) ; } | List of releases for an app . |
25,991 | public Release rollback ( String appName , String releaseUuid ) { return connection . execute ( new Rollback ( appName , releaseUuid ) , apiKey ) ; } | Rollback an app to a specific release . |
25,992 | public Release getReleaseInfo ( String appName , String releaseName ) { return connection . execute ( new ReleaseInfo ( appName , releaseName ) , apiKey ) ; } | Information about a specific release . |
25,993 | public List < Collaborator > listCollaborators ( String appName ) { return connection . execute ( new CollabList ( appName ) , apiKey ) ; } | Get a list of collaborators that are allowed access to an app . |
25,994 | public void addCollaborator ( String appName , String collaborator ) { connection . execute ( new SharingAdd ( appName , collaborator ) , apiKey ) ; } | Add a collaborator to an app . |
25,995 | public void removeCollaborator ( String appName , String collaborator ) { connection . execute ( new SharingRemove ( appName , collaborator ) , apiKey ) ; } | Remove a collaborator from an app . |
25,996 | public void updateConfig ( String appName , Map < String , String > config ) { connection . execute ( new ConfigUpdate ( appName , config ) , apiKey ) ; } | Update environment variables to an app . |
25,997 | public Map < String , String > listConfig ( String appName ) { return connection . execute ( new ConfigList ( appName ) , apiKey ) ; } | List all the environment variables for an app . |
25,998 | public void transferApp ( String appName , String to ) { connection . execute ( new SharingTransfer ( appName , to ) , apiKey ) ; } | Transfer the ownership of an application to another user . |
25,999 | public LogStreamResponse getLogs ( String appName , Boolean tail ) { return connection . execute ( new Log ( appName , tail ) , apiKey ) ; } | Get logs for an app . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.