idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
17,000 | public int ZoomForPixelSize ( int pixelSize ) { for ( int i = 0 ; i < 30 ; i ++ ) { if ( pixelSize > Resolution ( i ) ) { if ( i != 0 ) { return i - 1 ; } else { return 0 ; // We don't want to scale up } } } return 0 ; } | Maximal scaledown zoom of the pyramid closest to the pixelSize | 71 | 13 |
17,001 | public int [ ] GoogleTile ( double lat , double lon , int zoom ) { double [ ] meters = LatLonToMeters ( lat , lon ) ; int [ ] tile = MetersToTile ( meters [ 0 ] , meters [ 1 ] , zoom ) ; return this . GoogleTile ( tile [ 0 ] , tile [ 1 ] , zoom ) ; } | Converts a lat long coordinates to Google Tile Coordinates | 79 | 11 |
17,002 | public String QuadTree ( int tx , int ty , int zoom ) { String quadKey = "" ; ty = ( int ) ( ( Math . pow ( 2 , zoom ) - 1 ) - ty ) ; for ( int i = zoom ; i < 0 ; i -- ) { int digit = 0 ; int mask = 1 << ( i - 1 ) ; if ( ( tx & mask ) != 0 ) { digit += 1 ; } if ( ( ty & mask ) != 0 ) { digit += 2 ; } quadKey += ( digit... | Converts TMS tile coordinates to Microsoft QuadTree | 121 | 10 |
17,003 | private void net ( WritableRandomIter hacksIter , WritableRandomIter netIter ) { // calculates the max order of basin (max hackstream value) pm . beginTask ( "Extraction of rivers of chosen order..." , nRows ) ; for ( int r = 0 ; r < nRows ; r ++ ) { for ( int c = 0 ; c < nCols ; c ++ ) { double value = hacksIter . get... | Return the map of the network with only the river of the choosen order . | 199 | 16 |
17,004 | public static ByteBuffer bytes ( String s , Charset charset ) { return ByteBuffer . wrap ( s . getBytes ( charset ) ) ; } | Encode a String in a ByteBuffer using the provided charset . | 33 | 14 |
17,005 | public void write ( Writer writer ) throws IOException { GFF3Writer . writeVersionPragma ( writer ) ; GFF3Writer . writeRegionPragma ( writer , entry . getPrimaryAccession ( ) , windowBeginPosition , windowEndPosition ) ; int ID = 0 ; if ( show . contains ( SHOW_GENE ) ) { locusTagGeneMap = new HashMap < String , GFF3G... | Writes the GFF3 file . | 556 | 8 |
17,006 | public static String trim ( String string , int pos ) { int len = string . length ( ) ; int leftPos = pos ; int rightPos = len ; for ( ; rightPos > 0 ; -- rightPos ) { char ch = string . charAt ( rightPos - 1 ) ; if ( ch != ' ' && ch != ' ' && ch != ' ' && ch != ' ' ) { break ; } } for ( ; leftPos < rightPos ; ++ leftP... | Removes all whitespace characters from the beginning and end of the string starting from the given position . | 185 | 20 |
17,007 | public static String trimRight ( String string ) { for ( int i = string . length ( ) ; i > 0 ; -- i ) { if ( string . charAt ( i - 1 ) != ' ' && string . charAt ( i - 1 ) != ' ' && string . charAt ( i - 1 ) != ' ' && string . charAt ( i - 1 ) != ' ' ) { return i == string . length ( ) ? string : string . substring ( 0 ... | Removes all whitespace characters from the end of the string . | 111 | 13 |
17,008 | public static String trimRight ( String string , int pos ) { int i = string . length ( ) ; for ( ; i > pos ; -- i ) { char charAt = string . charAt ( i - 1 ) ; if ( charAt != ' ' && charAt != ' ' && charAt != ' ' && charAt != ' ' ) { break ; } } if ( i <= pos ) { return "" ; } return ( 0 == pos && i == string . length ... | Removes all whitespace characters from the end of the string starting from the given position . | 117 | 18 |
17,009 | public static String trimRight ( String string , char c ) { for ( int i = string . length ( ) ; i > 0 ; -- i ) { char charAt = string . charAt ( i - 1 ) ; if ( charAt != c && charAt != ' ' && charAt != ' ' && charAt != ' ' && charAt != ' ' ) { return i == string . length ( ) ? string : string . substring ( 0 , i ) ; } ... | Removes all whitespace characters and instances of the given character from the end of the string . | 105 | 19 |
17,010 | public static String trimLeft ( String string ) { for ( int i = 0 ; i < string . length ( ) ; ++ i ) { char charAt = string . charAt ( i ) ; if ( charAt != ' ' && charAt != ' ' && charAt != ' ' && charAt != ' ' ) { return i == 0 ? string : string . substring ( i ) ; } } return string ; } | Removes all whitespace characters from the beginning of the string . | 89 | 13 |
17,011 | public static Vector < String > split ( String string , String regex ) { Vector < String > strings = new Vector < String > ( ) ; for ( String value : string . split ( new String ( regex ) ) ) { value = value . trim ( ) ; if ( ! value . equals ( "" ) ) { strings . add ( shrink ( value ) ) ; } } return strings ; } | Split the string into values using the regular expression removes whitespace from the beginning and end of the resultant strings and replaces runs of whitespace with a single space . | 81 | 32 |
17,012 | public static String shrink ( String string ) { if ( string == null ) { return null ; } string = string . trim ( ) ; return SHRINK . matcher ( string ) . replaceAll ( " " ) ; } | Trims the string and replaces runs of whitespace with a single space . | 47 | 15 |
17,013 | public static String shrink ( String string , char c ) { if ( string == null ) { return null ; } string = string . trim ( ) ; Pattern pattern = Pattern . compile ( "\\" + String . valueOf ( c ) + "{2,}" ) ; return pattern . matcher ( string ) . replaceAll ( String . valueOf ( c ) ) ; } | Trims the string and replaces runs of whitespace with a single character . | 78 | 15 |
17,014 | public static String remove ( String string , char c ) { return string . replaceAll ( String . valueOf ( c ) , "" ) ; } | Removes the characters from the string . | 30 | 8 |
17,015 | public static Date getYear ( String string ) { if ( string == null ) { return null ; } Date date = null ; try { date = ( ( SimpleDateFormat ) year . clone ( ) ) . parse ( string ) ; } catch ( ParseException ex ) { return null ; } return date ; } | Returns the year given a string in format yyyy . | 65 | 12 |
17,016 | private int getNeighbours ( int [ ] src1d , int i , int ox , int oy , int d_w , int d_h ) { int x , y , result ; x = ( i % d_w ) + ox ; // d_w and d_h are assumed to be set to the y = ( i / d_w ) + oy ; // width and height of scr1d if ( ( x < 0 ) || ( x >= d_w ) || ( y < 0 ) || ( y >= d_h ) ) { result = 0 ; } else { re... | getNeighbours will get the pixel value of i s neighbour that s ox and oy away from i if the point is outside the image then 0 is returned . This version gets from source image . | 151 | 40 |
17,017 | private int reduce ( int a , int [ ] labels ) { if ( labels [ a ] == a ) { return a ; } else { return reduce ( labels [ a ] , labels ) ; } } | Reduces the number of labels . | 42 | 7 |
17,018 | public static boolean playsAll ( Role role , String ... r ) { if ( role == null ) { return false ; } for ( String s : r ) { if ( ! role . value ( ) . contains ( s ) ) { return false ; } } return true ; } | Checks if all roles are played . | 57 | 8 |
17,019 | public static boolean plays ( Role role , String r ) { if ( r == null ) { throw new IllegalArgumentException ( "null role" ) ; } if ( role == null ) { return false ; } return role . value ( ) . contains ( r ) ; } | Checks if one role is played . | 57 | 8 |
17,020 | public static boolean inRange ( Range range , double val ) { return val >= range . min ( ) && val <= range . max ( ) ; } | Check if a certain value is in range | 31 | 8 |
17,021 | public void close ( ) { entry . close ( ) ; getBlockCounter ( ) . clear ( ) ; getSkipTagCounter ( ) . clear ( ) ; getCache ( ) . resetOrganismCache ( ) ; getCache ( ) . resetReferenceCache ( ) ; } | Release resources used by the reader . Help the GC to cleanup the heap | 57 | 14 |
17,022 | public static BufferedImage ByteBufferImage ( byte [ ] data , int width , int height ) { int [ ] bandoffsets = { 0 , 1 , 2 , 3 } ; DataBufferByte dbb = new DataBufferByte ( data , data . length ) ; WritableRaster wr = Raster . createInterleavedRaster ( dbb , width , height , width * 4 , 4 , bandoffsets , null ) ; int [... | create a buffered image from a set of color triplets | 177 | 12 |
17,023 | public static Window getRectangleAroundPoint ( Window activeRegion , double x , double y ) { double minx = activeRegion . getRectangle ( ) . getBounds2D ( ) . getMinX ( ) ; double ewres = activeRegion . getWEResolution ( ) ; double snapx = minx + ( Math . round ( ( x - minx ) / ewres ) * ewres ) ; double miny = activeR... | return the rectangle of the cell of the active region that surrounds the given coordinates | 365 | 15 |
17,024 | public static void rasterizePolygonGeometry ( Window active , Geometry polygon , RasterData raster , RasterData rasterToMap , double value , IHMProgressMonitor monitor ) { GeometryFactory gFactory = new GeometryFactory ( ) ; int rows = active . getRows ( ) ; int cols = active . getCols ( ) ; double delta = active . get... | Fill polygon areas mapping on a raster | 496 | 9 |
17,025 | public static boolean removeGrassRasterMap ( String mapsetPath , String mapName ) throws IOException { // list of files to remove String mappaths [ ] = filesOfRasterMap ( mapsetPath , mapName ) ; // first delete the list above, which are just files for ( int j = 0 ; j < mappaths . length ; j ++ ) { File filetoremove = ... | Given the mapsetpath and the mapname the map is removed with all its accessor files | 138 | 19 |
17,026 | public static double [ ] rowColToNodeboundCoordinates ( Window active , int row , int col ) { double anorth = active . getNorth ( ) ; double awest = active . getWest ( ) ; double nsres = active . getNSResolution ( ) ; double ewres = active . getWEResolution ( ) ; double [ ] nsew = new double [ 4 ] ; nsew [ 0 ] = anorth... | Transforms row and column index of the active region into an array of the coordinates of the edgaes i . e . n s e w | 161 | 29 |
17,027 | public static double [ ] CalculateAcadExtrusion ( double [ ] coord_in , double [ ] xtru ) { double [ ] coord_out ; double dxt0 = 0D , dyt0 = 0D , dzt0 = 0D ; double dvx1 , dvx2 , dvx3 ; double dvy1 , dvy2 , dvy3 ; double dmod , dxt , dyt , dzt ; double aux = 1D / 64D ; double aux1 = Math . abs ( xtru [ 0 ] ) ; double a... | Method that allows to apply the extrusion transformation of Autocad | 649 | 13 |
17,028 | public void deleteGeoTable ( String tableName ) throws Exception { String sql = "SELECT DropGeoTable('" + tableName + "');" ; try ( IHMStatement stmt = mConn . createStatement ( ) ) { stmt . execute ( sql ) ; } } | Delete a geo - table with all attached indexes and stuff . | 60 | 12 |
17,029 | public void runRawSqlToCsv ( String sql , File csvFile , boolean doHeader , String separator ) throws Exception { try ( BufferedWriter bw = new BufferedWriter ( new FileWriter ( csvFile ) ) ) { SpatialiteWKBReader wkbReader = new SpatialiteWKBReader ( ) ; try ( IHMStatement stmt = mConn . createStatement ( ) ; IHMResul... | Execute a query from raw sql and put the result in a csv file . | 526 | 17 |
17,030 | public void read ( ) throws IOException { System . out . println ( "DwgFile.read() executed ..." ) ; setDwgVersion ( ) ; if ( dwgVersion . equals ( "R13" ) ) { dwgReader = new DwgFileV14Reader ( ) ; dwgReader . read ( this ) ; } else if ( dwgVersion . equals ( "R14" ) ) { dwgReader = new DwgFileV14Reader ( ) ; dwgReade... | Reads a DWG file and put its objects in the dwgObjects Vector This method is version independent | 189 | 22 |
17,031 | public void blockManagement ( ) { Vector dwgObjectsWithoutBlocks = new Vector ( ) ; boolean addingToBlock = false ; for ( int i = 0 ; i < dwgObjects . size ( ) ; i ++ ) { try { DwgObject entity = ( DwgObject ) dwgObjects . get ( i ) ; if ( entity instanceof DwgArc && ! addingToBlock ) { dwgObjectsWithoutBlocks . add ( ... | Modify the geometry of the objects contained in the blocks of a DWG file and add these objects to the DWG object list . | 717 | 27 |
17,032 | public void initializeLayerTable ( ) { layerTable = new Vector ( ) ; layerNames = new Vector ( ) ; for ( int i = 0 ; i < dwgObjects . size ( ) ; i ++ ) { DwgObject obj = ( DwgObject ) dwgObjects . get ( i ) ; if ( obj instanceof DwgLayer ) { Vector layerTableRecord = new Vector ( ) ; layerTableRecord . add ( new Intege... | Initialize a new Vector that contains the DWG file layers . Each layer have three parameters . These parameters are handle name and color | 192 | 26 |
17,033 | public int getColorByLayer ( DwgObject entity ) { int colorByLayer = 0 ; int layer = entity . getLayerHandle ( ) ; for ( int j = 0 ; j < layerTable . size ( ) ; j ++ ) { Vector layerTableRecord = ( Vector ) layerTable . get ( j ) ; int lHandle = ( ( Integer ) layerTableRecord . get ( 0 ) ) . intValue ( ) ; if ( lHandle... | Returns the color of the layer of a DWG object | 129 | 11 |
17,034 | public void addDwgSectionOffset ( String key , int seek , int size ) { DwgSectionOffset dso = new DwgSectionOffset ( key , seek , size ) ; dwgSectionOffsets . add ( dso ) ; } | Add a DWG section offset to the dwgSectionOffsets vector | 52 | 14 |
17,035 | public int getDwgSectionOffset ( String key ) { int offset = 0 ; for ( int i = 0 ; i < dwgSectionOffsets . size ( ) ; i ++ ) { DwgSectionOffset dso = ( DwgSectionOffset ) dwgSectionOffsets . get ( i ) ; String ikey = dso . getKey ( ) ; if ( key . equals ( ikey ) ) { offset = dso . getSeek ( ) ; break ; } } return offse... | Returns the offset of DWG section given by its key | 109 | 11 |
17,036 | public void addDwgObjectOffset ( int handle , int offset ) { DwgObjectOffset doo = new DwgObjectOffset ( handle , offset ) ; dwgObjectOffsets . add ( doo ) ; } | Add a DWG object offset to the dwgObjectOffsets vector | 47 | 14 |
17,037 | protected void initValidator ( ) throws SQLException , IOException { EmblEntryValidationPlanProperty emblEntryValidationPlanProperty = new EmblEntryValidationPlanProperty ( ) ; emblEntryValidationPlanProperty . validationScope . set ( ValidationScope . getScope ( fileType ) ) ; emblEntryValidationPlanProperty . isDevMo... | Inits the validator . | 400 | 6 |
17,038 | protected void initWriters ( ) throws IOException { String summarywriter = prefix == null ? "VAL_SUMMARY.txt" : prefix + "_" + "VAL_SUMMARY.txt" ; String infowriter = prefix == null ? "VAL_INFO.txt" : prefix + "_" + "VAL_INFO.txt" ; String errorwriter = prefix == null ? "VAL_ERROR.txt" : prefix + "_" + "VAL_ERROR.txt" ... | separate method to instantiate so unit tests can call this | 256 | 12 |
17,039 | private List < ValidationPlanResult > validateFile ( File file , Writer writer ) throws IOException { List < ValidationPlanResult > messages = new ArrayList < ValidationPlanResult > ( ) ; ArrayList < Object > entryList = new ArrayList < Object > ( ) ; BufferedReader fileReader = null ; try { fileReader = new BufferedRe... | Validate file . | 253 | 4 |
17,040 | private void prepareReader ( BufferedReader fileReader , String fileId ) { switch ( fileType ) { case EMBL : EmblEntryReader emblReader = new EmblEntryReader ( fileReader , EmblEntryReader . Format . EMBL_FORMAT , fileId ) ; emblReader . setCheckBlockCounts ( lineCount ) ; reader = emblReader ; break ; case GENBANK : r... | Prepare reader . | 191 | 4 |
17,041 | private void writeResultsToFile ( ValidationPlanResult planResult ) throws IOException { /** * first set any report messages (probably exceptional that the * translation report needs to get set outside the embl-api-core package * due to the need for embl-ff writers **/ for ( ValidationResult result : planResult . getRe... | Write results to file . | 353 | 5 |
17,042 | protected Object getNextEntryFromReader ( Writer writer ) { try { parseError = false ; ValidationResult parseResult = reader . read ( ) ; if ( parseResult . getMessages ( "FT.10" ) . size ( ) >= 1 && ( fixMode || fixDiagnoseMode ) ) { parseResult . removeMessage ( "FT.10" ) ; // writer fixes automatically if quotes are... | Gets the next entry from reader . | 209 | 8 |
17,043 | private void setNetworkPipes ( boolean isAreaNotAllDry ) throws Exception { int length = inPipes . size ( ) ; networkPipes = new Pipe [ length ] ; SimpleFeatureIterator stationsIter = inPipes . features ( ) ; boolean existOut = false ; int tmpOutIndex = 0 ; try { int t = 0 ; while ( stationsIter . hasNext ( ) ) { Simpl... | Initializating the array . | 640 | 6 |
17,044 | public boolean joinLine ( ) { if ( ! isCurrentLine ( ) ) { return false ; } if ( ! isNextLine ( ) ) { return false ; } if ( ! isNextTag ( ) ) { return true ; // no next tag -> continue block } if ( ! isCurrentTag ( ) ) { return false ; // no current tag -> new block } // compare current and next tag return getCurrentTa... | Returns true if the next and current lines can be joined together either because they have the same tag or because the next line does not have a tag . | 100 | 30 |
17,045 | public String getCurrentLine ( ) { if ( ! isCurrentLine ( ) ) { return null ; } if ( isTag ( currentLine ) ) return FlatFileUtils . trimRight ( currentLine , getTagWidth ( currentLine ) ) ; else return currentLine . trim ( ) ; } | Return current line without tag . | 62 | 6 |
17,046 | public String getNextLine ( ) { if ( ! isNextLine ( ) ) { return null ; } if ( isTag ( nextLine ) ) return FlatFileUtils . trimRight ( nextLine , getTagWidth ( nextLine ) ) ; else return nextLine . trim ( ) ; } | Return next line without tag . | 62 | 6 |
17,047 | public String getCurrentMaskedLine ( ) { if ( ! isCurrentLine ( ) ) { return null ; } StringBuilder str = new StringBuilder ( ) ; int tagWidth = getTagWidth ( currentLine ) ; for ( int i = 0 ; i < tagWidth ; ++ i ) { str . append ( " " ) ; } if ( currentLine . length ( ) > tagWidth ) { str . append ( currentLine . subs... | Return current line with tag masked with whitespace . | 109 | 10 |
17,048 | public String getNextMaskedLine ( ) { if ( ! isNextLine ( ) ) { return null ; } StringBuilder str = new StringBuilder ( ) ; int tagWidth = getTagWidth ( nextLine ) ; for ( int i = 0 ; i < tagWidth ; ++ i ) { str . append ( " " ) ; } if ( nextLine . length ( ) > tagWidth ) { str . append ( nextLine . substring ( tagWidt... | Return next line with tag masked with whitespace . | 109 | 10 |
17,049 | public String getCurrentShrinkedLine ( ) { if ( ! isCurrentLine ( ) ) { return null ; } String string = FlatFileUtils . trim ( currentLine , getTagWidth ( currentLine ) ) ; if ( string . equals ( "" ) ) { return null ; } return FlatFileUtils . shrink ( string ) ; } | Shrink and return the current line without tag . | 74 | 11 |
17,050 | public void propertyChange ( PropertyChangeEvent evt ) { if ( "progress" == evt . getPropertyName ( ) ) { int progress = ( Integer ) evt . getNewValue ( ) ; progressMonitor . setProgress ( progress ) ; // String message = String.format("Completed %d%%.\n", progress); // progressMonitor.setNote(message); if ( progressMo... | Invoked when task s progress property changes . | 209 | 9 |
17,051 | public double [ ] positionAt ( int col , int row ) { if ( isInRaster ( col , row ) ) { GridGeometry2D gridGeometry = getGridGeometry ( ) ; Coordinate coordinate = CoverageUtilities . coordinateFromColRow ( col , row , gridGeometry ) ; return new double [ ] { coordinate . x , coordinate . y } ; } return null ; } | Get world position from col row . | 85 | 7 |
17,052 | public int [ ] gridAt ( double x , double y ) { if ( isInRaster ( x , y ) ) { GridGeometry2D gridGeometry = getGridGeometry ( ) ; int [ ] colRowFromCoordinate = CoverageUtilities . colRowFromCoordinate ( new Coordinate ( x , y ) , gridGeometry , null ) ; return colRowFromCoordinate ; } return null ; } | Get grid col and row from a world coordinate . | 90 | 10 |
17,053 | public void setValueAt ( int col , int row , double value ) { if ( makeNew ) { if ( isInRaster ( col , row ) ) { ( ( WritableRandomIter ) iter ) . setSample ( col , row , 0 , value ) ; } else { throw new RuntimeException ( "Setting value outside of raster." ) ; } } else { throw new RuntimeException ( "Writing not allow... | Sets a raster value if the raster is writable . | 93 | 14 |
17,054 | public double [ ] surrounding ( int col , int row ) { GridNode node = new GridNode ( iter , cols , rows , xRes , yRes , col , row ) ; List < GridNode > surroundingNodes = node . getSurroundingNodes ( ) ; double [ ] surr = new double [ 8 ] ; for ( int i = 0 ; i < surroundingNodes . size ( ) ; i ++ ) { GridNode gridNode ... | Get the values of the surrounding cells . | 150 | 8 |
17,055 | public void write ( String path ) throws Exception { if ( makeNew ) { RasterWriter . writeRaster ( path , buildRaster ( ) ) ; } else { throw new RuntimeException ( "Only new rasters can be dumped." ) ; } } | Write the raster to file . | 54 | 7 |
17,056 | public static Raster read ( String path ) throws Exception { GridCoverage2D coverage2d = RasterReader . readRaster ( path ) ; Raster raster = new Raster ( coverage2d ) ; return raster ; } | Read a raster from file . | 51 | 7 |
17,057 | private void checkDuplicateTokens ( MutableTemplateInfo templateInfo ) throws TemplateException { List < String > allTokenNames = new ArrayList < String > ( ) ; for ( TemplateTokenInfo tokenInfo : templateInfo . tokenInfos ) { if ( allTokenNames . contains ( tokenInfo . getName ( ) ) ) { throw new TemplateException ( "... | throws error if a token name appears twice - will bail as soon as one duplicate is hit | 127 | 19 |
17,058 | private void processGroups ( MutableTemplateInfo template ) throws TemplateException { List < TemplateTokenGroupInfo > groupInfos = template . groupInfo ; List < String > allGroupTokens = new ArrayList < String > ( ) ; for ( TemplateTokenGroupInfo groupInfo : groupInfos ) { for ( String newToken : groupInfo . getContai... | creates a group containing all tokens not contained in any other sections - an all others group | 324 | 18 |
17,059 | public void shrink ( ) { if ( c . length == length ) { return ; } char [ ] newc = new char [ length ] ; System . arraycopy ( c , 0 , newc , 0 , length ) ; c = newc ; } | Shrinks the capacity of the buffer to the current length if necessary . This method involves copying the data once! | 53 | 23 |
17,060 | public StringBuffer toStringBuffer ( ) { StringBuffer sb = new StringBuffer ( length ) ; sb . append ( c , 0 , length ) ; return sb ; } | Converts the contents of the buffer into a StringBuffer . This method involves copying the new data once! | 38 | 21 |
17,061 | public static GridCoverage2D createSubCoverageFromTemplate ( GridCoverage2D template , Envelope2D subregion , Double value , WritableRaster [ ] writableRasterHolder ) { RegionMap regionMap = getRegionParamsFromGridCoverage ( template ) ; double xRes = regionMap . getXres ( ) ; double yRes = regionMap . getYres ( ) ; do... | Create a subcoverage given a template coverage and an envelope . | 427 | 13 |
17,062 | public static int [ ] getRegionColsRows ( GridCoverage2D gridCoverage ) { GridGeometry2D gridGeometry = gridCoverage . getGridGeometry ( ) ; GridEnvelope2D gridRange = gridGeometry . getGridRange2D ( ) ; int height = gridRange . height ; int width = gridRange . width ; int [ ] params = new int [ ] { width , height } ; ... | Get the array of rows and cols . | 98 | 9 |
17,063 | public static int [ ] getLoopColsRowsForSubregion ( GridCoverage2D gridCoverage , Envelope2D subregion ) throws Exception { GridGeometry2D gridGeometry = gridCoverage . getGridGeometry ( ) ; GridEnvelope2D subRegionGrid = gridGeometry . worldToGrid ( subregion ) ; int minCol = subRegionGrid . x ; int maxCol = subRegion... | Get the cols and rows ranges to use to loop the original gridcoverage . | 149 | 17 |
17,064 | public static int [ ] renderedImage2IntegerArray ( RenderedImage renderedImage , double multiply ) { int width = renderedImage . getWidth ( ) ; int height = renderedImage . getHeight ( ) ; int [ ] values = new int [ width * height ] ; RandomIter imageIter = RandomIterFactory . create ( renderedImage , null ) ; int inde... | Transform a double values rendered image in its integer array representation by scaling the values . | 156 | 16 |
17,065 | public static byte [ ] renderedImage2ByteArray ( RenderedImage renderedImage , boolean doRowsThenCols ) { int width = renderedImage . getWidth ( ) ; int height = renderedImage . getHeight ( ) ; byte [ ] values = new byte [ width * height ] ; RandomIter imageIter = RandomIterFactory . create ( renderedImage , null ) ; i... | Transform a double values rendered image in its byte array . | 228 | 11 |
17,066 | public static void setNovalueBorder ( WritableRaster raster ) { int width = raster . getWidth ( ) ; int height = raster . getHeight ( ) ; for ( int c = 0 ; c < width ; c ++ ) { raster . setSample ( c , 0 , 0 , doubleNovalue ) ; raster . setSample ( c , height - 1 , 0 , doubleNovalue ) ; } for ( int r = 0 ; r < height ;... | Creates a border of novalues . | 148 | 8 |
17,067 | public static WritableRaster replaceNovalue ( RenderedImage renderedImage , double newValue ) { WritableRaster tmpWR = ( WritableRaster ) renderedImage . getData ( ) ; RandomIter pitTmpIterator = RandomIterFactory . create ( renderedImage , null ) ; int height = renderedImage . getHeight ( ) ; int width = renderedImage... | Replace the current internal novalue with a given value . | 172 | 12 |
17,068 | public static ROI prepareROI ( Geometry roi , AffineTransform mt2d ) throws Exception { // transform the geometry to raster space so that we can use it as a ROI source Geometry rasterSpaceGeometry = JTS . transform ( roi , new AffineTransform2D ( mt2d . createInverse ( ) ) ) ; // simplify the geometry so that it's as p... | Utility method for transforming a geometry ROI into the raster space using the provided affine transformation . | 162 | 21 |
17,069 | public static boolean isGrass ( String path ) { File file = new File ( path ) ; File cellFolderFile = file . getParentFile ( ) ; File mapsetFile = cellFolderFile . getParentFile ( ) ; File windFile = new File ( mapsetFile , "WIND" ) ; return cellFolderFile . getName ( ) . toLowerCase ( ) . equals ( "cell" ) && windFile... | Checks if the given path is a GRASS raster file . | 95 | 14 |
17,070 | public static GridCoverage2D mergeCoverages ( GridCoverage2D valuesMap , GridCoverage2D onMap ) { RegionMap valuesRegionMap = getRegionParamsFromGridCoverage ( valuesMap ) ; int cs = valuesRegionMap . getCols ( ) ; int rs = valuesRegionMap . getRows ( ) ; RegionMap onRegionMap = getRegionParamsFromGridCoverage ( onMap ... | Coverage merger . | 363 | 4 |
17,071 | public static double [ ] [ ] calculateHypsographic ( GridCoverage2D elevationCoverage , int bins , IHMProgressMonitor pm ) { if ( pm == null ) { pm = new DummyProgressMonitor ( ) ; } RegionMap regionMap = getRegionParamsFromGridCoverage ( elevationCoverage ) ; int cols = regionMap . getCols ( ) ; int rows = regionMap .... | Calculates the hypsographic curve for the given raster using the supplied bins . | 638 | 18 |
17,072 | static public void zipFolder ( String srcFolder , String destZipFile , boolean addBaseFolder ) throws IOException { if ( new File ( srcFolder ) . isDirectory ( ) ) { try ( FileOutputStream fileWriter = new FileOutputStream ( destZipFile ) ; ZipOutputStream zip = new ZipOutputStream ( fileWriter ) ) { addFolderToZip ( "... | Compress a folder and its contents . | 121 | 8 |
17,073 | public static String unzipFolder ( String zipFile , String destFolder , boolean addTimeStamp ) throws IOException { String newFirstName = null ; try ( ZipFile zf = new ZipFile ( zipFile ) ) { Enumeration < ? extends ZipEntry > zipEnum = zf . entries ( ) ; String firstName = null ; while ( zipEnum . hasMoreElements ( ) ... | Uncompress a compressed file to the contained structure . | 542 | 11 |
17,074 | public void setWorkingDirectory ( File dir ) { if ( ! dir . exists ( ) ) { throw new IllegalArgumentException ( dir + " doesn't exist." ) ; } pb . directory ( dir ) ; } | Set the working directory where the process get executed . | 46 | 10 |
17,075 | public int exec ( ) throws IOException { int exitValue = 0 ; List < String > argl = new ArrayList < String > ( ) ; argl . add ( executable . toString ( ) ) ; for ( Object a : args ) { if ( a != null ) { if ( a . getClass ( ) == String . class ) { argl . add ( a . toString ( ) ) ; } else if ( a . getClass ( ) == String ... | Process execution . This call blocks until the process is done . | 430 | 12 |
17,076 | private void addResult ( ValidationResult result ) { if ( result == null || result . count ( ) == 0 ) { return ; } this . results . add ( result ) ; } | Adds a validationResult to the results - if there are any messages | 39 | 13 |
17,077 | public List < ValidationMessage < Origin > > getMessages ( String messageKey , Severity severity ) { List < ValidationMessage < Origin >> messages = new ArrayList < ValidationMessage < Origin > > ( ) ; for ( ValidationResult result : results ) { for ( ValidationMessage < Origin > message : result . getMessages ( ) ) { ... | Finds validation messages by the message key and severity . | 121 | 11 |
17,078 | public static byte [ ] serialize ( Object obj ) throws IOException { try ( ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ) { ObjectOutputStream out = new ObjectOutputStream ( bos ) ; out . writeObject ( obj ) ; out . close ( ) ; return bos . toByteArray ( ) ; } } | Serialize an Object to disk . | 70 | 7 |
17,079 | public static < T > T deSerialize ( byte [ ] bytes , Class < T > adaptee ) throws Exception { ObjectInputStream in = new ObjectInputStream ( new ByteArrayInputStream ( bytes ) ) ; Object readObject = in . readObject ( ) ; return adaptee . cast ( readObject ) ; } | Deserialize a byte array to a given object . | 67 | 11 |
17,080 | public static void serializeToDisk ( File file , Object obj ) throws IOException { byte [ ] serializedObj = serialize ( obj ) ; try ( RandomAccessFile raFile = new RandomAccessFile ( file , "rw" ) ) { raFile . write ( serializedObj ) ; } } | Serialize an object to disk . | 64 | 7 |
17,081 | public static < T > T deSerializeFromDisk ( File file , Class < T > adaptee ) throws Exception { try ( RandomAccessFile raf = new RandomAccessFile ( file , "r" ) ) { long length = raf . length ( ) ; // System.out.println(length + "/" + (int) length); byte [ ] bytes = new byte [ ( int ) length ] ; int read = raf . read ... | Deserialize a file to a given object . | 156 | 10 |
17,082 | private void checkParametersAndRunEnergyBalance ( double [ ] rain , double [ ] [ ] T , double [ ] [ ] V , double [ ] [ ] P , double [ ] [ ] RH , double month , double day , double hour , double [ ] Abasin , double [ ] [ ] [ ] A , double [ ] [ ] [ ] EI , double [ ] [ ] DTd , double [ ] [ ] DTm , double [ ] [ ] canopy ) ... | Method to check the input parameters . | 686 | 7 |
17,083 | public static BufferedReader getBufferedXMLReader ( InputStream stream , int xmlLookahead ) throws IOException { // create a buffer so we can reset the input stream BufferedInputStream input = new BufferedInputStream ( stream ) ; input . mark ( xmlLookahead ) ; // create object to hold encoding info EncodingInfo encodi... | Wraps an xml input xstream in a buffered reader specifying a lookahead that can be used to preparse some of the xml document resetting it back to its original state for actual parsing . | 162 | 40 |
17,084 | public static BufferedReader getBufferedXMLReader ( Reader reader , int xmlLookahead ) throws IOException { // ensure the reader is a buffered reader if ( ! ( reader instanceof BufferedReader ) ) { reader = new BufferedReader ( reader ) ; } // mark the input stream reader . mark ( xmlLookahead ) ; return ( BufferedRead... | Wraps an xml reader in a buffered reader specifying a lookahead that can be used to preparse some of the xml document resetting it back to its original state for actual parsing . | 80 | 38 |
17,085 | private void validateCoefficients ( ) { if ( coefsValid ) return ; if ( n >= 2 ) { double xBar = ( double ) sumX / n ; double yBar = ( double ) sumY / n ; a1 = ( double ) ( ( n * sumXY - sumX * sumY ) / ( n * sumXX - sumX * sumX ) ) ; a0 = ( double ) ( yBar - a1 * xBar ) ; } else { a0 = a1 = Double . NaN ; } coefsValid... | Validate the coefficients . | 124 | 5 |
17,086 | public static synchronized void initializeDXF_SCHEMA ( CoordinateReferenceSystem crs ) { if ( DXF_POINTSCHEMA != null && DXF_POINTSCHEMA . getAttributeCount ( ) != 0 ) return ; SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder ( ) ; b . setName ( "dxfpointfile" ) ; b . setCRS ( crs ) ; b . add ( "the_geom" , Po... | Initialize a JUMP FeatureSchema to load dxf data keeping some graphic attributes . | 615 | 18 |
17,087 | private byte [ ] readClassData ( JavaFileObject classFile ) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; byte [ ] buf = new byte [ 4096 ] ; InputStream classStream = classFile . openInputStream ( ) ; int n = classStream . read ( buf ) ; while ( n > 0 ) { bos . write ( buf , 0 , n ) ;... | Reads all class file data into a byte array from the given file object . | 114 | 16 |
17,088 | public static String [ ] getAllMarksArray ( ) { Set < String > keySet = markNamesToDef . keySet ( ) ; return ( String [ ] ) keySet . toArray ( new String [ keySet . size ( ) ] ) ; } | Getter for an array of all available marks . | 55 | 10 |
17,089 | public static void substituteMark ( Rule rule , String wellKnownMarkName ) { PointSymbolizer pointSymbolizer = StyleUtilities . pointSymbolizerFromRule ( rule ) ; Mark oldMark = SLD . mark ( pointSymbolizer ) ; Graphic graphic = SLD . graphic ( pointSymbolizer ) ; graphic . graphicalSymbols ( ) . clear ( ) ; Mark mark ... | Change the mark shape in a rule . | 174 | 8 |
17,090 | public static void substituteExternalGraphics ( Rule rule , URL externalGraphicsUrl ) { String urlString = externalGraphicsUrl . toString ( ) ; String format = "" ; if ( urlString . toLowerCase ( ) . endsWith ( ".png" ) ) { format = "image/png" ; } else if ( urlString . toLowerCase ( ) . endsWith ( ".jpg" ) ) { format ... | Change the external graphic in a rule . | 260 | 8 |
17,091 | public static void changeMarkSize ( Rule rule , int newSize ) { PointSymbolizer pointSymbolizer = StyleUtilities . pointSymbolizerFromRule ( rule ) ; Graphic graphic = SLD . graphic ( pointSymbolizer ) ; graphic . setSize ( ff . literal ( newSize ) ) ; // Mark oldMark = SLDs.mark(pointSymbolizer); // oldMark.setSize(ff... | Changes the size of a mark inside a rule . | 114 | 10 |
17,092 | public static void changeRotation ( Rule rule , int newRotation ) { PointSymbolizer pointSymbolizer = StyleUtilities . pointSymbolizerFromRule ( rule ) ; Graphic graphic = SLD . graphic ( pointSymbolizer ) ; graphic . setRotation ( ff . literal ( newRotation ) ) ; // Mark oldMark = SLDs.mark(pointSymbolizer); // oldMar... | Changes the rotation value inside a rule . | 102 | 8 |
17,093 | @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) public static void setOffset ( Symbolizer symbolizer , String text ) { if ( text . indexOf ( ' ' ) == - 1 ) { return ; } String [ ] split = text . split ( "," ) ; if ( split . length != 2 ) { return ; } double xOffset = Double . parseDouble ( split [ 0 ] ) ; double yO... | Sets the offset in a symbolizer . | 249 | 9 |
17,094 | public static String styleToString ( Style style ) throws Exception { StyledLayerDescriptor sld = sf . createStyledLayerDescriptor ( ) ; UserLayer layer = sf . createUserLayer ( ) ; layer . setLayerFeatureConstraints ( new FeatureTypeConstraint [ ] { null } ) ; sld . addStyledLayer ( layer ) ; layer . addUserStyle ( st... | Converts a style to its string representation to be written to file . | 135 | 14 |
17,095 | public static StyleWrapper createStyleFromGraphic ( File graphicsPath ) throws IOException { String name = graphicsPath . getName ( ) ; ExternalGraphic exGraphic = null ; if ( name . toLowerCase ( ) . endsWith ( ".png" ) ) { exGraphic = sf . createExternalGraphic ( graphicsPath . toURI ( ) . toURL ( ) , "image/png" ) ;... | Generates a style based on a graphic . | 433 | 9 |
17,096 | public static float [ ] getDash ( String dashStr ) { if ( dashStr == null ) { return null ; } String [ ] dashSplit = dashStr . split ( "," ) ; //$NON-NLS-1$ int size = dashSplit . length ; float [ ] dash = new float [ size ] ; try { for ( int i = 0 ; i < dash . length ; i ++ ) { dash [ i ] = Float . parseFloat ( dashSp... | Returns a dash array from a dash string . | 127 | 9 |
17,097 | public static String getDashString ( float [ ] dashArray ) { StringBuilder sb = null ; for ( float f : dashArray ) { if ( sb == null ) { sb = new StringBuilder ( String . valueOf ( f ) ) ; } else { sb . append ( "," ) ; sb . append ( String . valueOf ( f ) ) ; } } return sb . toString ( ) ; } | Converts teh array to string . | 92 | 8 |
17,098 | public static int sld2awtJoin ( String sldJoin ) { if ( sldJoin . equals ( lineJoinNames [ 1 ] ) ) { return BasicStroke . JOIN_BEVEL ; } else if ( sldJoin . equals ( "" ) || sldJoin . equals ( lineJoinNames [ 2 ] ) ) { return BasicStroke . JOIN_MITER ; } else if ( sldJoin . equals ( lineJoinNames [ 3 ] ) ) { return Bas... | Convert a sld line join definition to the java awt value . | 136 | 15 |
17,099 | public static int sld2awtCap ( String sldCap ) { if ( sldCap . equals ( "" ) || sldCap . equals ( lineCapNames [ 1 ] ) ) { return BasicStroke . CAP_BUTT ; } else if ( sldCap . equals ( lineCapNames [ 2 ] ) ) { return BasicStroke . CAP_ROUND ; } else if ( sldCap . equals ( lineCapNames [ 3 ] ) ) { return BasicStroke . C... | Convert a sld line cap definition to the java awt value . | 134 | 15 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.