idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
17,200
public void goTo ( Sector sector , boolean animate ) { View view = getWwd ( ) . getView ( ) ; view . stopAnimations ( ) ; view . stopMovement ( ) ; if ( sector == null ) { return ; } Box extent = Sector . computeBoundingBox ( getWwd ( ) . getModel ( ) . getGlobe ( ) , getWwd ( ) . getSceneController ( ) . getVerticalExaggeration ( ) , sector ) ; Angle fov = view . getFieldOfView ( ) ; double zoom = extent . getRadius ( ) / fov . cosHalfAngle ( ) / fov . tanHalfAngle ( ) ; if ( animate ) { view . goTo ( new Position ( sector . getCentroid ( ) , 0d ) , zoom ) ; } else { ( ( OrbitView ) wwd . getView ( ) ) . setCenterPosition ( new Position ( sector . getCentroid ( ) , 0d ) ) ; ( ( OrbitView ) wwd . getView ( ) ) . setZoom ( zoom ) ; } }
Move to see a given sector .
17,201
public void setFlatGlobe ( boolean doMercator ) { EarthFlat globe = new EarthFlat ( ) ; globe . setElevationModel ( new ZeroElevationModel ( ) ) ; wwd . getModel ( ) . setGlobe ( globe ) ; wwd . getView ( ) . stopMovement ( ) ; GeographicProjection projection ; if ( doMercator ) { projection = new ProjectionMercator ( ) ; } else { projection = new ProjectionEquirectangular ( ) ; } globe . setProjection ( projection ) ; wwd . redraw ( ) ; }
Set the globe as flat .
17,202
public void setSphereGlobe ( ) { Earth globe = new Earth ( ) ; wwd . getModel ( ) . setGlobe ( globe ) ; wwd . getView ( ) . stopMovement ( ) ; wwd . redraw ( ) ; }
Set the globe as sphere .
17,203
public void setFlatSphereGlobe ( ) { Earth globe = new Earth ( ) ; globe . setElevationModel ( new ZeroElevationModel ( ) ) ; wwd . getModel ( ) . setGlobe ( globe ) ; wwd . getView ( ) . stopMovement ( ) ; wwd . redraw ( ) ; }
Set the globe as flat sphere .
17,204
public List < Message > getFilteredList ( EMessageType messageType , Long fromTsMillis , Long toTsMillis , long limit ) throws Exception { String tableName = TABLE_MESSAGES ; String sql = "select " + getQueryFieldsString ( ) + " from " + tableName ; List < String > wheresList = new ArrayList < > ( ) ; if ( messageType != null && messageType != EMessageType . ALL ) { String where = type_NAME + "=" + messageType . getCode ( ) ; wheresList . add ( where ) ; } if ( fromTsMillis != null ) { String where = TimeStamp_NAME + ">" + fromTsMillis ; wheresList . add ( where ) ; } if ( toTsMillis != null ) { String where = TimeStamp_NAME + "<" + toTsMillis ; wheresList . add ( where ) ; } if ( wheresList . size ( ) > 0 ) { sql += " WHERE " ; for ( int i = 0 ; i < wheresList . size ( ) ; i ++ ) { if ( i > 0 ) { sql += " AND " ; } sql += wheresList . get ( i ) ; } } sql += " order by " + ID_NAME + " desc" ; if ( limit > 0 ) { sql += " limit " + limit ; } String _sql = sql ; List < Message > messages = new ArrayList < Message > ( ) ; logDb . execOnConnection ( connection -> { try ( IHMStatement stmt = connection . createStatement ( ) ; IHMResultSet rs = stmt . executeQuery ( _sql ) ; ) { while ( rs . next ( ) ) { Message event = resultSetToItem ( rs ) ; messages . add ( event ) ; } } return null ; } ) ; return messages ; }
Get the list of messages filtered .
17,205
public boolean accept ( File file ) { String name = file . getName ( ) ; if ( FilenameUtils . wildcardMatch ( name , wildcards , caseSensitivity ) ) { return true ; } return false ; }
Checks to see if the filename matches one of the wildcards .
17,206
public SimpleFeature convertDwgAttribute ( String typeName , String layerName , DwgAttrib attribute , int id ) { Point2D pto = attribute . getInsertionPoint ( ) ; Coordinate coord = new Coordinate ( pto . getX ( ) , pto . getY ( ) , attribute . getElevation ( ) ) ; String textString = attribute . getText ( ) ; return createPointTextFeature ( typeName , layerName , id , coord , textString ) ; }
Builds a point feature from a dwg attribute .
17,207
public SimpleFeature convertDwgPolyline2D ( String typeName , String layerName , DwgPolyline2D polyline2d , int id ) { Point2D [ ] ptos = polyline2d . getPts ( ) ; CoordinateList coordList = new CoordinateList ( ) ; if ( ptos != null ) { for ( int j = 0 ; j < ptos . length ; j ++ ) { Coordinate coord = new Coordinate ( ptos [ j ] . getX ( ) , ptos [ j ] . getY ( ) , 0.0 ) ; coordList . add ( coord ) ; } SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder ( ) ; b . setName ( typeName ) ; b . setCRS ( crs ) ; b . add ( THE_GEOM , LineString . class ) ; b . add ( LAYER , String . class ) ; SimpleFeatureType type = b . buildFeatureType ( ) ; SimpleFeatureBuilder builder = new SimpleFeatureBuilder ( type ) ; Geometry lineString = gF . createLineString ( coordList . toCoordinateArray ( ) ) ; Object [ ] values = new Object [ ] { lineString , layerName } ; builder . addAll ( values ) ; return builder . buildFeature ( typeName + "." + id ) ; } return null ; }
Builds a line feature from a dwg polyline 2D .
17,208
public SimpleFeature convertDwgPoint ( String typeName , String layerName , DwgPoint point , int id ) { double [ ] p = point . getPoint ( ) ; Point2D pto = new Point2D . Double ( p [ 0 ] , p [ 1 ] ) ; CoordinateList coordList = new CoordinateList ( ) ; Coordinate coord = new Coordinate ( pto . getX ( ) , pto . getY ( ) , 0.0 ) ; coordList . add ( coord ) ; SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder ( ) ; b . setName ( typeName ) ; b . setCRS ( crs ) ; b . add ( THE_GEOM , MultiPoint . class ) ; b . add ( LAYER , String . class ) ; SimpleFeatureType type = b . buildFeatureType ( ) ; SimpleFeatureBuilder builder = new SimpleFeatureBuilder ( type ) ; Geometry points = gF . createMultiPoint ( coordList . toCoordinateArray ( ) ) ; Object [ ] values = new Object [ ] { points , layerName } ; builder . addAll ( values ) ; return builder . buildFeature ( typeName + "." + id ) ; }
Builds a point feature from a dwg point .
17,209
public SimpleFeature convertDwgLine ( String typeName , String layerName , DwgLine line , int id ) { double [ ] p1 = line . getP1 ( ) ; double [ ] p2 = line . getP2 ( ) ; Point2D [ ] ptos = new Point2D [ ] { new Point2D . Double ( p1 [ 0 ] , p1 [ 1 ] ) , new Point2D . Double ( p2 [ 0 ] , p2 [ 1 ] ) } ; CoordinateList coordList = new CoordinateList ( ) ; for ( int j = 0 ; j < ptos . length ; j ++ ) { Coordinate coord = new Coordinate ( ptos [ j ] . getX ( ) , ptos [ j ] . getY ( ) , 0.0 ) ; coordList . add ( coord ) ; } SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder ( ) ; b . setName ( typeName ) ; b . setCRS ( crs ) ; b . add ( THE_GEOM , LineString . class ) ; b . add ( LAYER , String . class ) ; SimpleFeatureType type = b . buildFeatureType ( ) ; SimpleFeatureBuilder builder = new SimpleFeatureBuilder ( type ) ; Geometry lineString = gF . createLineString ( coordList . toCoordinateArray ( ) ) ; Object [ ] values = new Object [ ] { lineString , layerName } ; builder . addAll ( values ) ; return builder . buildFeature ( typeName + "." + id ) ; }
Builds a line feature from a dwg line .
17,210
public SimpleFeature convertDwgCircle ( String typeName , String layerName , DwgCircle circle , int id ) { double [ ] center = circle . getCenter ( ) ; double radius = circle . getRadius ( ) ; Point2D [ ] ptos = GisModelCurveCalculator . calculateGisModelCircle ( new Point2D . Double ( center [ 0 ] , center [ 1 ] ) , radius ) ; CoordinateList coordList = new CoordinateList ( ) ; for ( int j = 0 ; j < ptos . length ; j ++ ) { Coordinate coord = new Coordinate ( ptos [ j ] . getX ( ) , ptos [ j ] . getY ( ) , 0.0 ) ; coordList . add ( coord ) ; } if ( ( ptos [ ptos . length - 1 ] . getX ( ) != ptos [ 0 ] . getX ( ) ) || ( ptos [ ptos . length - 1 ] . getY ( ) != ptos [ 0 ] . getY ( ) ) ) { Coordinate coord = new Coordinate ( ptos [ 0 ] . getX ( ) , ptos [ 0 ] . getY ( ) , 0.0 ) ; coordList . add ( coord ) ; } SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder ( ) ; b . setName ( typeName ) ; b . setCRS ( crs ) ; b . add ( THE_GEOM , Polygon . class ) ; b . add ( LAYER , String . class ) ; SimpleFeatureType type = b . buildFeatureType ( ) ; SimpleFeatureBuilder builder = new SimpleFeatureBuilder ( type ) ; LinearRing linearRing = gF . createLinearRing ( coordList . toCoordinateArray ( ) ) ; Geometry polygon = gF . createPolygon ( linearRing , null ) ; Object [ ] values = new Object [ ] { polygon , layerName } ; builder . addAll ( values ) ; return builder . buildFeature ( typeName + "." + id ) ; }
Builds a polygon feature from a dwg circle .
17,211
public SimpleFeature convertDwgSolid ( String typeName , String layerName , DwgSolid solid , int id ) { double [ ] p1 = solid . getCorner1 ( ) ; double [ ] p2 = solid . getCorner2 ( ) ; double [ ] p3 = solid . getCorner3 ( ) ; double [ ] p4 = solid . getCorner4 ( ) ; Point2D [ ] ptos = new Point2D [ ] { new Point2D . Double ( p1 [ 0 ] , p1 [ 1 ] ) , new Point2D . Double ( p2 [ 0 ] , p2 [ 1 ] ) , new Point2D . Double ( p3 [ 0 ] , p3 [ 1 ] ) , new Point2D . Double ( p4 [ 0 ] , p4 [ 1 ] ) } ; CoordinateList coordList = new CoordinateList ( ) ; for ( int j = 0 ; j < ptos . length ; j ++ ) { Coordinate coord = new Coordinate ( ptos [ j ] . getX ( ) , ptos [ j ] . getY ( ) ) ; coordList . add ( coord ) ; } coordList . closeRing ( ) ; SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder ( ) ; b . setName ( typeName ) ; b . setCRS ( crs ) ; b . add ( THE_GEOM , Polygon . class ) ; b . add ( LAYER , String . class ) ; SimpleFeatureType type = b . buildFeatureType ( ) ; SimpleFeatureBuilder builder = new SimpleFeatureBuilder ( type ) ; LinearRing linearRing = gF . createLinearRing ( coordList . toCoordinateArray ( ) ) ; Geometry polygon = gF . createPolygon ( linearRing , null ) ; Object [ ] values = new Object [ ] { polygon , layerName } ; builder . addAll ( values ) ; return builder . buildFeature ( typeName + "." + id ) ; }
Builds a polygon feature from a dwg solid .
17,212
public SimpleFeature convertDwgArc ( String typeName , String layerName , DwgArc arc , int id ) { double [ ] c = arc . getCenter ( ) ; Point2D center = new Point2D . Double ( c [ 0 ] , c [ 1 ] ) ; double radius = ( arc ) . getRadius ( ) ; double initAngle = Math . toDegrees ( ( arc ) . getInitAngle ( ) ) ; double endAngle = Math . toDegrees ( ( arc ) . getEndAngle ( ) ) ; Point2D [ ] ptos = GisModelCurveCalculator . calculateGisModelArc ( center , radius , initAngle , endAngle ) ; CoordinateList coordList = new CoordinateList ( ) ; for ( int j = 0 ; j < ptos . length ; j ++ ) { Coordinate coord = new Coordinate ( ptos [ j ] . getX ( ) , ptos [ j ] . getY ( ) , 0.0 ) ; coordList . add ( coord ) ; } SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder ( ) ; b . setName ( typeName ) ; b . setCRS ( crs ) ; b . add ( THE_GEOM , LineString . class ) ; b . add ( LAYER , String . class ) ; SimpleFeatureType type = b . buildFeatureType ( ) ; SimpleFeatureBuilder builder = new SimpleFeatureBuilder ( type ) ; Geometry lineString = gF . createLineString ( coordList . toCoordinateArray ( ) ) ; Object [ ] values = new Object [ ] { lineString , layerName } ; builder . addAll ( values ) ; return builder . buildFeature ( typeName + "." + id ) ; }
Builds a line feature from a dwg arc .
17,213
public static double norm_vec ( double x , double y , double z ) { return Math . sqrt ( x * x + y * y + z * z ) ; }
Normalized Vector .
17,214
public static double lag1 ( double [ ] vals ) { double mean = mean ( vals ) ; int size = vals . length ; double r1 ; double q = 0 ; double v = ( vals [ 0 ] - mean ) * ( vals [ 0 ] - mean ) ; for ( int i = 1 ; i < size ; i ++ ) { double delta0 = ( vals [ i - 1 ] - mean ) ; double delta1 = ( vals [ i ] - mean ) ; q += ( delta0 * delta1 - q ) / ( i + 1 ) ; v += ( delta1 * delta1 - v ) / ( i + 1 ) ; } r1 = q / v ; return r1 ; }
Returns the lag - 1 autocorrelation of a dataset ;
17,215
public static double round ( double val , int places ) { long factor = ( long ) Math . pow ( 10 , places ) ; val = val * factor ; long tmp = Math . round ( val ) ; return ( double ) tmp / factor ; }
Round a double value to a specified number of decimal places .
17,216
public static double random ( double min , double max ) { assert max > min ; return min + Math . random ( ) * ( max - min ) ; }
Generate a random number in a range .
17,217
private boolean checkStructure ( ) { File ds ; ds = new File ( mapsetPath + File . separator + GrassLegacyConstans . CATS + File . separator ) ; if ( ! ds . exists ( ) ) if ( ! ds . mkdir ( ) ) return false ; ds = new File ( mapsetPath + File . separator + GrassLegacyConstans . CELL + File . separator ) ; if ( ! ds . exists ( ) ) if ( ! ds . mkdir ( ) ) return false ; ds = new File ( mapsetPath + File . separator + GrassLegacyConstans . CELL_MISC + File . separator ) ; if ( ! ds . exists ( ) ) if ( ! ds . mkdir ( ) ) return false ; ds = new File ( mapsetPath + File . separator + GrassLegacyConstans . CELL_MISC + File . separator + name ) ; if ( ! ds . exists ( ) ) if ( ! ds . mkdir ( ) ) return false ; ds = new File ( mapsetPath + File . separator + GrassLegacyConstans . FCELL + File . separator ) ; if ( ! ds . exists ( ) ) if ( ! ds . mkdir ( ) ) return false ; ds = new File ( mapsetPath + File . separator + GrassLegacyConstans . CELLHD + File . separator ) ; if ( ! ds . exists ( ) ) if ( ! ds . mkdir ( ) ) return false ; ds = new File ( mapsetPath + File . separator + GrassLegacyConstans . COLR + File . separator ) ; if ( ! ds . exists ( ) ) if ( ! ds . mkdir ( ) ) return false ; ds = new File ( mapsetPath + File . separator + GrassLegacyConstans . HIST + File . separator ) ; if ( ! ds . exists ( ) ) if ( ! ds . mkdir ( ) ) return false ; return true ; }
check if the needed folders are there ( they could be missing if the mapset has just been created and this is the first file that gets into it
17,218
private boolean createEmptyHeader ( String filePath , int rows ) { try { RandomAccessFile theCreatedFile = new RandomAccessFile ( filePath , "rw" ) ; rowaddresses = new long [ rows + 1 ] ; theCreatedFile . write ( 4 ) ; for ( int i = 0 ; i < rows + 1 ; i ++ ) { theCreatedFile . writeInt ( 0 ) ; } pointerInFilePosition = theCreatedFile . getFilePointer ( ) ; rowaddresses [ 0 ] = pointerInFilePosition ; theCreatedFile . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; return false ; } return true ; }
creates the space for the header of the rasterfile filling the spaces with zeroes . After the compression the values will be rewritten
17,219
private void createCellhd ( int chproj , int chzone , double chn , double chs , double che , double chw , int chcols , int chrows , double chnsres , double chewres , int chformat , int chcompressed ) throws Exception { StringBuffer data = new StringBuffer ( 512 ) ; data . append ( "proj: " + chproj + "\n" ) . append ( "zone: " + chzone + "\n" ) . append ( "north: " + chn + "\n" ) . append ( "south: " + chs + "\n" ) . append ( "east: " + che + "\n" ) . append ( "west: " + chw + "\n" ) . append ( "cols: " + chcols + "\n" ) . append ( "rows: " + chrows + "\n" ) . append ( "n-s resol: " + chnsres + "\n" ) . append ( "e-w resol: " + chewres + "\n" ) . append ( "format: " + chformat + "\n" ) . append ( "compressed: " + chcompressed ) ; File ds = new File ( mapsetPath + File . separator + GrassLegacyConstans . CELLHD + File . separator + name ) ; OutputStreamWriter windFile = new OutputStreamWriter ( new FileOutputStream ( ds ) ) ; windFile . write ( data . toString ( ) ) ; windFile . close ( ) ; }
changes the cellhd file inserting the new values obtained from the environment
17,220
public boolean compressAndWriteObj ( RandomAccessFile theCreatedFile , RandomAccessFile theCreatedNullFile , Object dataObject ) throws RasterWritingFailureException { if ( dataObject instanceof double [ ] [ ] ) { compressAndWrite ( theCreatedFile , theCreatedNullFile , ( double [ ] [ ] ) dataObject ) ; } else { throw new RasterWritingFailureException ( "Raster type not supported." ) ; } }
Passing the object after defining the type of data that will be written
17,221
public String getStyle ( StyleType type , Color color , String colorName , String layerName ) { throw new UnsupportedOperationException ( ) ; }
Generates a style from a template using the provided substitutions .
17,222
protected Reader toReader ( Object input ) throws IOException { if ( input instanceof Reader ) { return ( Reader ) input ; } if ( input instanceof InputStream ) { return new InputStreamReader ( ( InputStream ) input ) ; } if ( input instanceof String ) { return new StringReader ( ( String ) input ) ; } if ( input instanceof URL ) { return new InputStreamReader ( ( ( URL ) input ) . openStream ( ) ) ; } if ( input instanceof File ) { return new FileReader ( ( File ) input ) ; } throw new IllegalArgumentException ( "Unable to turn " + input + " into reader" ) ; }
Turns input into a Reader .
17,223
public static boolean supportsNative ( ) { if ( ! testedLibLoading ) { LiblasJNALibrary wrapper = LiblasWrapper . getWrapper ( ) ; if ( wrapper != null ) { isNativeLibAvailable = true ; } testedLibLoading = true ; } return isNativeLibAvailable ; }
Checks of nativ libs are available .
17,224
public static ALasReader getReader ( File lasFile , CoordinateReferenceSystem crs ) throws Exception { if ( supportsNative ( ) ) { return new LiblasReader ( lasFile , crs ) ; } else { return new LasReaderBuffered ( lasFile , crs ) ; } }
Get a las reader .
17,225
public static ALasWriter getWriter ( File lasFile , CoordinateReferenceSystem crs ) throws Exception { if ( supportsNative ( ) ) { return new LiblasWriter ( lasFile , crs ) ; } else { return new LasWriterBuffered ( lasFile , crs ) ; } }
Get a las writer .
17,226
public void setRoot ( DbLevel v ) { DbLevel oldRoot = v ; root = v ; fireTreeStructureChanged ( oldRoot ) ; }
Sets the root to a given variable .
17,227
public void onError ( Exception e ) { e . printStackTrace ( ) ; String localizedMessage = e . getLocalizedMessage ( ) ; if ( localizedMessage == null ) { localizedMessage = e . getMessage ( ) ; } if ( localizedMessage == null || localizedMessage . trim ( ) . length ( ) == 0 ) { localizedMessage = "An undefined error was thrown. Please send the below trace to your technical contact:\n" ; localizedMessage += ExceptionUtils . getStackTrace ( e ) ; } String _localizedMessage = localizedMessage ; SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { JOptionPane . showMessageDialog ( parent , _localizedMessage , "ERROR" , JOptionPane . ERROR_MESSAGE ) ; } } ) ; }
Called if an error occurrs . Can be overridden . SHows dialog by default .
17,228
public static boolean tcaMax ( FlowNode flowNode , RandomIter tcaIter , RandomIter hacklengthIter , double maxTca , double maxDistance ) { List < FlowNode > enteringNodes = flowNode . getEnteringNodes ( ) ; for ( Node node : enteringNodes ) { double tca = node . getValueFromMap ( tcaIter ) ; if ( tca >= maxTca ) { if ( NumericsUtilities . dEq ( tca , maxTca ) ) { if ( node . getValueFromMap ( hacklengthIter ) > maxDistance ) return false ; } else return false ; } } return true ; }
Compare two value of tca and distance .
17,229
public static boolean isCircularBoundary ( CompoundLocation < Location > location , long sequenceLength ) { if ( location . getLocations ( ) . size ( ) == 1 ) { return false ; } boolean lastLocation = false ; List < Location > locationList = location . getLocations ( ) ; for ( int i = 0 ; i < locationList . size ( ) ; i ++ ) { if ( i == locationList . size ( ) - 1 ) { lastLocation = true ; } Long position = location . getLocations ( ) . get ( i ) . getEndPosition ( ) ; if ( position == sequenceLength && ! lastLocation ) { return true ; } } return false ; }
Checks to see if a feature s location spans a circular boundary - assumes the genome the feature is coming from is circular .
17,230
public static boolean deleteDeletedValueQualifiers ( Feature feature , ArrayList < Qualifier > deleteQualifierList ) { boolean deleted = false ; for ( Qualifier qual : deleteQualifierList ) { feature . removeQualifier ( qual ) ; deleted = true ; } return deleted ; }
deletes the qualifiers which have DELETED value
17,231
public static boolean deleteDuplicatedQualfiier ( Feature feature , String qualifierName ) { ArrayList < Qualifier > qualifiers = ( ArrayList < Qualifier > ) feature . getQualifiers ( qualifierName ) ; Set < String > qualifierValueSet = new HashSet < String > ( ) ; for ( Qualifier qual : qualifiers ) { if ( qual . getValue ( ) != null ) { if ( ! qualifierValueSet . add ( qual . getValue ( ) ) ) { feature . removeQualifier ( qual ) ; return true ; } } } return false ; }
Delete duplicated qualfiier .
17,232
public ImageIcon getImage ( String key ) { ImageIcon image = imageMap . get ( key ) ; if ( image == null ) { image = createImage ( key ) ; imageMap . put ( key , image ) ; } return image ; }
Get an image for a certain key .
17,233
public static Style getStyleFromFile ( File file ) { Style style = null ; try { String name = file . getName ( ) ; if ( ! name . endsWith ( "sld" ) ) { String nameWithoutExtention = FileUtilities . getNameWithoutExtention ( file ) ; File sldFile = new File ( file . getParentFile ( ) , nameWithoutExtention + ".sld" ) ; if ( sldFile . exists ( ) ) { file = sldFile ; } else { return null ; } } SLDHandler h = new SLDHandler ( ) ; StyledLayerDescriptor sld = h . parse ( file , null , null , null ) ; style = getDefaultStyle ( sld ) ; return style ; } catch ( Exception e ) { e . printStackTrace ( ) ; return null ; } }
Get the style from an sld file .
17,234
private static void genericizeftStyles ( List < FeatureTypeStyle > ftStyles ) { for ( FeatureTypeStyle featureTypeStyle : ftStyles ) { featureTypeStyle . featureTypeNames ( ) . clear ( ) ; featureTypeStyle . featureTypeNames ( ) . add ( new NameImpl ( GENERIC_FEATURE_TYPENAME ) ) ; } }
Converts the type name of all FeatureTypeStyles to Feature so that the all apply to any feature type . This is admittedly dangerous but is extremely useful because it means that the style can be used with any feature type .
17,235
public static Color colorWithoutAlpha ( Color color ) { return new Color ( color . getRed ( ) , color . getGreen ( ) , color . getBlue ( ) ) ; }
REmoves the alpha channel from a color .
17,236
public static Color colorWithAlpha ( Color color , int alpha ) { return new Color ( color . getRed ( ) , color . getGreen ( ) , color . getBlue ( ) , alpha ) ; }
Creates a color with the given alpha .
17,237
public Map < String , TemplateTokenInfo > getTokensAsMap ( ) { HashMap < String , TemplateTokenInfo > tokens = new HashMap < String , TemplateTokenInfo > ( ) ; for ( TemplateTokenInfo tokenInfo : tokenInfos ) tokens . put ( tokenInfo . getName ( ) , tokenInfo ) ; return Collections . unmodifiableMap ( tokens ) ; }
returns a map keyed with the token name
17,238
public < T > T getTile4TileCoordinate ( final int tx , final int ty , int zoom , Class < T > adaptee ) throws IOException { Tile tile = new Tile ( tx , ty , ( byte ) zoom , tileSize ) ; RendererJob mapGeneratorJob = new RendererJob ( tile , mapDataStore , renderTheme , displayModel , scaleFactor , false , false ) ; TileBitmap tb = renderer . executeJob ( mapGeneratorJob ) ; if ( ! ( tileCache instanceof InMemoryTileCache ) ) { tileCache . put ( mapGeneratorJob , tb ) ; } if ( tb instanceof AwtTileBitmap ) { AwtTileBitmap bmp = ( AwtTileBitmap ) tb ; if ( bmp != null ) { BufferedImage bitmap = AwtGraphicFactory . getBitmap ( bmp ) ; if ( adaptee . isAssignableFrom ( BufferedImage . class ) ) { return adaptee . cast ( bitmap ) ; } else if ( adaptee . isAssignableFrom ( byte [ ] . class ) ) { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; ImageIO . write ( bitmap , "png" , baos ) ; baos . flush ( ) ; byte [ ] imageInByte = baos . toByteArray ( ) ; baos . close ( ) ; return adaptee . cast ( imageInByte ) ; } } } throw new RuntimeException ( "Can't handle tilebitmap of type -> " + tb . getClass ( ) ) ; }
Get tile data for a given tile schema coordinate .
17,239
public void ENopen ( String input , String report , String outputBin ) throws EpanetException { int errcode = epanet . ENopen ( input , report , outputBin ) ; checkError ( errcode ) ; }
Opens the Toolkit to analyze a particular distribution system .
17,240
public void ENsaveinpfile ( String fileName ) throws EpanetException { int err = epanet . ENsaveinpfile ( fileName ) ; checkError ( err ) ; }
Writes all current network input data to a file using the format of an EPANET input file .
17,241
public void ENsavehydfile ( String filePath ) throws EpanetException { int err = epanet . ENsavehydfile ( filePath ) ; checkError ( err ) ; }
Saves the current contents of the binary hydraulics file to a file .
17,242
public int ENgetcount ( Components countcode ) throws EpanetException { int [ ] count = new int [ 1 ] ; int error = epanet . ENgetcount ( countcode . getCode ( ) , count ) ; checkError ( error ) ; return count [ 0 ] ; }
Retrieves the number of network components of a specified type .
17,243
public float ENgetoption ( OptionParameterCodes optionCode ) throws EpanetException { float [ ] optionValue = new float [ 1 ] ; int error = epanet . ENgetoption ( optionCode . getCode ( ) , optionValue ) ; checkError ( error ) ; return optionValue [ 0 ] ; }
Retrieves the value of a particular analysis option .
17,244
public long ENgettimeparam ( TimeParameterCodes timeParameterCode ) throws EpanetException { long [ ] timeValue = new long [ 1 ] ; int error = epanet . ENgettimeparam ( timeParameterCode . getCode ( ) , timeValue ) ; checkError ( error ) ; return timeValue [ 0 ] ; }
Retrieves the value of a specific analysis time parameter .
17,245
public int ENgetpatternindex ( String id ) throws EpanetException { int [ ] index = new int [ 1 ] ; int error = epanet . ENgetpatternindex ( id , index ) ; checkError ( error ) ; return index [ 0 ] ; }
Retrieves the index of a particular time pattern .
17,246
public float ENgetpatternvalue ( int index , int period ) throws EpanetException { float [ ] value = new float [ 1 ] ; int errcode = epanet . ENgetpatternvalue ( index , period , value ) ; checkError ( errcode ) ; return value [ 0 ] ; }
Retrieves the multiplier factor for a specific time period in a time pattern .
17,247
public int ENgetnodeindex ( String id ) throws EpanetException { int [ ] index = new int [ 1 ] ; int error = epanet . ENgetnodeindex ( id , index ) ; checkError ( error ) ; return index [ 0 ] ; }
Retrieves the index of a node with a specified ID .
17,248
public NodeTypes ENgetnodetype ( int index ) throws EpanetException { int [ ] typecode = new int [ 1 ] ; int error = epanet . ENgetnodetype ( index , typecode ) ; checkError ( error ) ; NodeTypes type = NodeTypes . forCode ( typecode [ 0 ] ) ; return type ; }
Retrieves the node - type code for a specific node .
17,249
public int ENgetlinkindex ( String id ) throws EpanetException { int [ ] index = new int [ 1 ] ; int error = epanet . ENgetlinkindex ( id , index ) ; checkError ( error ) ; return index [ 0 ] ; }
Retrieves the index of a link with a specified ID .
17,250
public String ENgetlinkid ( int index ) throws EpanetException { ByteBuffer bb = ByteBuffer . allocate ( 64 ) ; int errcode = epanet . ENgetlinkid ( index , bb ) ; checkError ( errcode ) ; String label ; label = byteBuffer2String ( bb ) ; return label ; }
Retrieves the ID label of a link with a specified index .
17,251
public LinkTypes ENgetlinktype ( int index ) throws EpanetException { int [ ] typecode = new int [ 1 ] ; int error = epanet . ENgetlinktype ( index , typecode ) ; checkError ( error ) ; LinkTypes type = LinkTypes . forCode ( typecode [ 0 ] ) ; return type ; }
Retrieves the link - type code for a specific link .
17,252
public int [ ] ENgetlinknodes ( int index ) throws EpanetException { int [ ] from = new int [ 1 ] ; int [ ] to = new int [ 1 ] ; int error = epanet . ENgetlinknodes ( index , from , to ) ; checkError ( error ) ; return new int [ ] { from [ 0 ] , to [ 0 ] } ; }
Retrieves the indexes of the end nodes of a specified link .
17,253
public float [ ] ENgetlinkvalue ( int index , LinkParameters param ) throws EpanetException { float [ ] value = new float [ 2 ] ; int errcode = epanet . ENgetlinkvalue ( index , param . getCode ( ) , value ) ; checkError ( errcode ) ; return value ; }
Retrieves the value of a specific link parameter .
17,254
public int ENgetversion ( ) throws EpanetException { int [ ] version = new int [ 0 ] ; int errcode = epanet . ENgetversion ( version ) ; checkError ( errcode ) ; return version [ 0 ] ; }
Get the version of OmsEpanet .
17,255
public void ENsetnodevalue ( int index , NodeParameters nodeParameter , float value ) throws EpanetException { int errcode = epanet . ENsetnodevalue ( index , nodeParameter . getCode ( ) , value ) ; checkError ( errcode ) ; }
Sets the value of a parameter for a specific node .
17,256
public void ENsetlinkvalue ( int index , LinkParameters linkParameter , float value ) throws EpanetException { int errcode = epanet . ENsetnodevalue ( index , linkParameter . getCode ( ) , value ) ; checkError ( errcode ) ; }
Sets the value of a parameter for a specific link .
17,257
public void ENaddpattern ( String id ) throws EpanetException { int errcode = epanet . ENaddpattern ( id ) ; checkError ( errcode ) ; }
Adds a new time pattern to the network .
17,258
public void ENsettimeparam ( TimeParameterCodes code , Long timevalue ) throws EpanetException { int errcode = epanet . ENsettimeparam ( code . getCode ( ) , timevalue ) ; checkError ( errcode ) ; }
Sets the value of a time parameter .
17,259
public void ENsetoption ( OptionParameterCodes optionCode , float value ) throws EpanetException { int errcode = epanet . ENsetoption ( optionCode . getCode ( ) , value ) ; checkError ( errcode ) ; }
Sets the value of a particular analysis option .
17,260
public static ValidationException error ( String messageKey , Object ... params ) { return new ValidationException ( ValidationMessage . error ( messageKey , params ) ) ; }
Creates a ValidationException which contains a ValidationMessage error .
17,261
public static ValidationException warning ( String messageKey , Object ... params ) { return new ValidationException ( ValidationMessage . warning ( messageKey , params ) ) ; }
Creates a ValidationException which contains a ValidationMessage warning .
17,262
public static ValidationException info ( String messageKey , Object ... params ) { return new ValidationException ( ValidationMessage . info ( messageKey , params ) ) ; }
Creates a ValidationException which contains a ValidationMessage info .
17,263
protected void writeFeatureLocation ( Writer writer ) throws IOException { new FeatureLocationWriter ( entry , feature , wrapType , featureHeader , qualifierHeader ) . write ( writer ) ; }
overridden in HTMLFeatureWriter
17,264
public void beginElement ( String elementName ) throws IOException { addElementName ( elementName ) ; indent ( ) ; writer . write ( "<" ) ; writer . write ( elementName ) ; }
Writes <elementName .
17,265
public void openElement ( String elementName ) throws IOException { assert ( elementNames . size ( ) > 0 ) ; assert ( elementNames . get ( elementNames . size ( ) - 1 ) . equals ( elementName ) ) ; writer . write ( ">" ) ; if ( indent || noTextElement ) { writer . write ( "\n" ) ; } }
Writes > \ n .
17,266
public void setData ( FieldContent data ) { if ( this . data != null ) { throw new ComponentException ( "Attempt to set @In field twice: " + comp + "." + field . getName ( ) ) ; } this . data = data ; }
called in in access
17,267
double qobs ( int dummy , double [ ] xt ) { int x = ( int ) ( xt [ 0 ] ) ; double p = Math . random ( ) ; double [ ] distr = accumP [ x ] ; int i , left = 0 , right = distr . length - 1 ; while ( left <= right ) { i = ( left + right ) / 2 ; if ( p < distr [ i ] ) { right = i - 1 ; } else if ( distr [ i ] < p ) { left = i + 1 ; } else { return i ; } } return left ; }
An efficient version of qobs using binary search in accumP
17,268
public static byte [ ] hexToBytes ( String hex ) { int byteLen = hex . length ( ) / 2 ; byte [ ] bytes = new byte [ byteLen ] ; for ( int i = 0 ; i < hex . length ( ) / 2 ; i ++ ) { int i2 = 2 * i ; if ( i2 + 1 > hex . length ( ) ) throw new IllegalArgumentException ( "Hex string has odd length" ) ; int nib1 = hexToInt ( hex . charAt ( i2 ) ) ; int nib0 = hexToInt ( hex . charAt ( i2 + 1 ) ) ; byte b = ( byte ) ( ( nib1 << 4 ) + ( byte ) nib0 ) ; bytes [ i ] = b ; } return bytes ; }
Converts a hexadecimal string to a byte array . The hexadecimal digit symbols are case - insensitive .
17,269
private Geometry setSRID ( Geometry g , int SRID ) { if ( SRID != 0 ) g . setSRID ( SRID ) ; return g ; }
Sets the SRID if it was specified in the WKB
17,270
private void readCoordinate ( ) throws IOException { for ( int i = 0 ; i < inputDimension ; i ++ ) { if ( i <= 1 ) { ordValues [ i ] = precisionModel . makePrecise ( dis . readDouble ( ) ) ; } else { ordValues [ i ] = dis . readDouble ( ) ; } } }
Reads a coordinate value with the specified dimensionality . Makes the X and Y ordinates precise according to the precision model in use .
17,271
public static void connectElements ( List < IHillSlope > elements ) { Collections . sort ( elements , elements . get ( 0 ) ) ; for ( int i = 0 ; i < elements . size ( ) ; i ++ ) { IHillSlope elem = elements . get ( i ) ; for ( int j = i + 1 ; j < elements . size ( ) ; j ++ ) { IHillSlope tmp = elements . get ( j ) ; elem . addConnectedDownstreamElementWithCheck ( tmp ) ; } } }
Connect the various elements in a chain of tributary basins and nets
17,272
public static final String bytesToHex ( byte [ ] bs , int off , int length ) { StringBuffer sb = new StringBuffer ( length * 2 ) ; bytesToHexAppend ( bs , off , length , sb ) ; return sb . toString ( ) ; }
Converts a byte array into a string of upper case hex chars .
17,273
public Vector getPoints ( double inc ) { Vector arc = new Vector ( ) ; double angulo ; int iempieza = ( int ) empieza + 1 ; int iacaba = ( int ) acaba ; if ( empieza <= acaba ) { addNode ( arc , empieza ) ; for ( angulo = iempieza ; angulo <= iacaba ; angulo += inc ) { addNode ( arc , angulo ) ; } addNode ( arc , acaba ) ; } else { addNode ( arc , empieza ) ; for ( angulo = iempieza ; angulo <= 360 ; angulo += inc ) { addNode ( arc , angulo ) ; } for ( angulo = 1 ; angulo <= iacaba ; angulo += inc ) { addNode ( arc , angulo ) ; } addNode ( arc , angulo ) ; } Point2D aux = ( Point2D ) arc . get ( arc . size ( ) - 1 ) ; double aux1 = Math . abs ( aux . getX ( ) - coord2 . getX ( ) ) ; double aux2 = Math . abs ( aux . getY ( ) - coord2 . getY ( ) ) ; return arc ; }
This method calculates an arc in a Gis geometry model . This arc is represented in this model by a Vector of Point2D . The distance between points in the arc is given as an argument
17,274
public Vector getCentralPoint ( ) { Vector arc = new Vector ( ) ; if ( empieza <= acaba ) { addNode ( arc , ( empieza + acaba ) / 2.0 ) ; } else { addNode ( arc , empieza ) ; double alfa = 360 - empieza ; double beta = acaba ; double an = alfa + beta ; double mid = an / 2.0 ; if ( mid <= alfa ) { addNode ( arc , empieza + mid ) ; } else { addNode ( arc , mid - alfa ) ; } } return arc ; }
Method that allows to obtain a set of points located in the central zone of this arc object
17,275
public static List < FileStoreDataSet > getDataSets ( File cacheRoot ) { if ( cacheRoot == null ) { String message = Logging . getMessage ( "nullValue.FileStorePathIsNull" ) ; Logging . logger ( ) . severe ( message ) ; throw new IllegalArgumentException ( message ) ; } ArrayList < FileStoreDataSet > datasets = new ArrayList < FileStoreDataSet > ( ) ; File [ ] cacheDirs = FileStoreDataSet . listDirs ( cacheRoot ) ; for ( File cacheDir : cacheDirs ) { if ( cacheDir . getName ( ) . equals ( "license" ) ) continue ; File [ ] subDirs = FileStoreDataSet . listDirs ( cacheDir ) ; if ( subDirs . length == 0 ) { datasets . add ( new FileStoreDataSet ( cacheDir , cacheRoot . getPath ( ) ) ) ; } else { if ( isSingleDataSet ( subDirs ) ) { datasets . add ( new FileStoreDataSet ( cacheDir , cacheRoot . getPath ( ) ) ) ; } else { for ( File sd : subDirs ) { FileStoreDataSet ds = new FileStoreDataSet ( sd , cacheRoot . getPath ( ) ) ; datasets . add ( ds ) ; } } } } return datasets ; }
Find all of the data set directories in a cache root .
17,276
protected static File [ ] listDirs ( File parent ) { return parent . listFiles ( new FileFilter ( ) { public boolean accept ( File file ) { return file . isDirectory ( ) ; } } ) ; }
List all of the sub - directories in a parent directory .
17,277
protected static boolean isNumeric ( String s ) { for ( char c : s . toCharArray ( ) ) { if ( ! Character . isDigit ( c ) ) return false ; } return true ; }
Determines if a string contains only digits .
17,278
public static void createModulesOverview ( ) { Map < String , List < ClassField > > hmModules = HortonMachine . getInstance ( ) . moduleName2Fields ; Map < String , List < ClassField > > jggModules = JGrassGears . getInstance ( ) . moduleName2Fields ; Map < String , Class < ? > > hmModulesClasses = HortonMachine . getInstance ( ) . moduleName2Class ; Map < String , Class < ? > > jggModulesClasses = JGrassGears . getInstance ( ) . moduleName2Class ; Set < String > hmNames = hmModules . keySet ( ) ; String [ ] hmNamesArray = ( String [ ] ) hmNames . toArray ( new String [ hmNames . size ( ) ] ) ; Set < String > jggNames = jggModules . keySet ( ) ; String [ ] jggNamesArray = ( String [ ] ) jggNames . toArray ( new String [ jggNames . size ( ) ] ) ; Arrays . sort ( hmNamesArray ) ; Arrays . sort ( jggNamesArray ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( "#summary An overview of the modules implemented in the HortonMachine\n\n" ) ; sb . append ( "<wiki:toc max_depth=\"4\" />\n\n" ) ; sb . append ( "= HortonMachine Modules Overview =\n" ) ; sb . append ( "== !HortonMachine Modules ==\n" ) ; String status = "CERTIFIED" ; sb . append ( "=== Release ready ==\n" ) ; dumpModules ( hmModules , hmModulesClasses , hmNamesArray , sb , status ) ; status = "TESTED" ; sb . append ( "=== Tested but not for upcoming release ==\n" ) ; dumpModules ( hmModules , hmModulesClasses , hmNamesArray , sb , status ) ; status = "DRAFT" ; sb . append ( "=== Module that are not passing the QA rules yet ==\n" ) ; dumpModules ( hmModules , hmModulesClasses , hmNamesArray , sb , status ) ; sb . append ( "\n<BR/><BR/><BR/>\n\n" ) ; sb . append ( "== Gears Modules ==\n" ) ; status = "CERTIFIED" ; sb . append ( "=== Release ready ==\n" ) ; dumpModules ( jggModules , jggModulesClasses , jggNamesArray , sb , status ) ; status = "TESTED" ; sb . append ( "=== Tested but not for upcoming release ==\n" ) ; dumpModules ( jggModules , jggModulesClasses , jggNamesArray , sb , status ) ; status = "DRAFT" ; sb . append ( "=== Module that are not passing the QA rules yet ==\n" ) ; dumpModules ( jggModules , jggModulesClasses , jggNamesArray , sb , status ) ; System . out . println ( sb . toString ( ) ) ; }
Creates an overview of all the OMS modules for the wiki site .
17,279
public static Server startTcpServerMode ( String port , boolean doSSL , String tcpPassword , boolean ifExists , String baseDir ) throws SQLException { List < String > params = new ArrayList < > ( ) ; params . add ( "-tcpAllowOthers" ) ; params . add ( "-tcpPort" ) ; if ( port == null ) { port = "9123" ; } params . add ( port ) ; if ( doSSL ) { params . add ( "-tcpSSL" ) ; } if ( tcpPassword != null ) { params . add ( "-tcpPassword" ) ; params . add ( tcpPassword ) ; } if ( ifExists ) { params . add ( "-ifExists" ) ; } if ( baseDir != null ) { params . add ( "-baseDir" ) ; params . add ( baseDir ) ; } Server server = Server . createTcpServer ( params . toArray ( new String [ 0 ] ) ) . start ( ) ; return server ; }
Start the server mode .
17,280
public static Server startWebServerMode ( String port , boolean doSSL , boolean ifExists , String baseDir ) throws SQLException { List < String > params = new ArrayList < > ( ) ; params . add ( "-webAllowOthers" ) ; if ( port != null ) { params . add ( "-webPort" ) ; params . add ( port ) ; } if ( doSSL ) { params . add ( "-webSSL" ) ; } if ( ifExists ) { params . add ( "-ifExists" ) ; } if ( baseDir != null ) { params . add ( "-baseDir" ) ; params . add ( baseDir ) ; } Server server = Server . createWebServer ( params . toArray ( new String [ 0 ] ) ) . start ( ) ; return server ; }
Start the web server mode .
17,281
public static String createTableFromShp ( ASpatialDb db , File shapeFile , String newTableName , boolean avoidSpatialIndex ) throws Exception { FileDataStore store = FileDataStoreFinder . getDataStore ( shapeFile ) ; SimpleFeatureSource featureSource = store . getFeatureSource ( ) ; SimpleFeatureType schema = featureSource . getSchema ( ) ; if ( newTableName == null ) { newTableName = FileUtilities . getNameWithoutExtention ( shapeFile ) ; } return createTableFromSchema ( db , schema , newTableName , avoidSpatialIndex ) ; }
Create a spatial table using a shapefile as schema .
17,282
public static boolean importShapefile ( ASpatialDb db , File shapeFile , String tableName , int limit , IHMProgressMonitor pm ) throws Exception { FileDataStore store = FileDataStoreFinder . getDataStore ( shapeFile ) ; SimpleFeatureSource featureSource = store . getFeatureSource ( ) ; SimpleFeatureCollection features = featureSource . getFeatures ( ) ; return importFeatureCollection ( db , features , tableName , limit , pm ) ; }
Import a shapefile into a table .
17,283
private void writeExif ( ) throws IOException { IIOMetadata metadata = jpegReader . getImageMetadata ( 0 ) ; String [ ] names = metadata . getMetadataFormatNames ( ) ; IIOMetadataNode root = ( IIOMetadataNode ) metadata . getAsTree ( names [ 0 ] ) ; NodeList nList = root . getElementsByTagName ( "unknown" ) ; IIOMetadataNode app1EXIFNode = ( IIOMetadataNode ) nList . item ( 0 ) ; ArrayList < IIOMetadata > md = readExif ( app1EXIFNode ) ; IIOMetadata exifMetadata = md . get ( 0 ) ; exifMetadata = insertGPSCoords ( exifMetadata ) ; IIOMetadataNode app1NodeNew = createNewExifNode ( exifMetadata , null , null ) ; app1EXIFNode . setUserObject ( app1NodeNew . getUserObject ( ) ) ; FileImageOutputStream out1 = new FileImageOutputStream ( new File ( "GPS_" + imageFile . getName ( ) ) ) ; jpegWriter . setOutput ( out1 ) ; metadata . setFromTree ( names [ 0 ] , root ) ; IIOImage image = new IIOImage ( jpegReader . readAsRenderedImage ( 0 , jpegReader . getDefaultReadParam ( ) ) , null , metadata ) ; jpegWriter . write ( jpegReader . getStreamMetadata ( ) , image , jpegWriter . getDefaultWriteParam ( ) ) ; }
Main method to write the gps data to the exif
17,284
private ArrayList < IIOMetadata > readExif ( IIOMetadataNode app1EXIFNode ) { byte [ ] app1Params = ( byte [ ] ) app1EXIFNode . getUserObject ( ) ; MemoryCacheImageInputStream app1EXIFInput = new MemoryCacheImageInputStream ( new ByteArrayInputStream ( app1Params , 6 , app1Params . length - 6 ) ) ; ImageReader tiffReader = null ; Iterator < ImageReader > readers = ImageIO . getImageReadersByFormatName ( "tiff" ) ; while ( readers . hasNext ( ) ) { tiffReader = ( ImageReader ) readers . next ( ) ; if ( tiffReader . getClass ( ) . getName ( ) . startsWith ( "com.sun.media" ) ) { break ; } } if ( tiffReader == null ) { throw new RuntimeException ( "Cannot find core TIFF reader!" ) ; } ArrayList < IIOMetadata > out = new ArrayList < IIOMetadata > ( 1 ) ; tiffReader . setInput ( app1EXIFInput ) ; IIOMetadata tiffMetadata = null ; try { tiffMetadata = tiffReader . getImageMetadata ( 0 ) ; TIFFImageReadParam rParam = ( TIFFImageReadParam ) tiffReader . getDefaultReadParam ( ) ; rParam . setTIFFDecompressor ( null ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } ; tiffReader . dispose ( ) ; out . add ( 0 , tiffMetadata ) ; return out ; }
Private method - Reads the exif metadata for an image
17,285
private IIOMetadataNode createNewExifNode ( IIOMetadata tiffMetadata , IIOMetadata thumbMeta , BufferedImage thumbnail ) { IIOMetadataNode app1Node = null ; ImageWriter tiffWriter = null ; try { Iterator < ImageWriter > writers = ImageIO . getImageWritersByFormatName ( "tiff" ) ; while ( writers . hasNext ( ) ) { tiffWriter = writers . next ( ) ; if ( tiffWriter . getClass ( ) . getName ( ) . startsWith ( "com.sun.media" ) ) { break ; } } if ( tiffWriter == null ) { System . out . println ( "Cannot find core TIFF writer!" ) ; System . exit ( 0 ) ; } ImageWriteParam writeParam = tiffWriter . getDefaultWriteParam ( ) ; writeParam . setCompressionMode ( ImageWriteParam . MODE_EXPLICIT ) ; writeParam . setCompressionType ( "EXIF JPEG" ) ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; MemoryCacheImageOutputStream app1EXIFOutput = new MemoryCacheImageOutputStream ( baos ) ; tiffWriter . setOutput ( app1EXIFOutput ) ; tiffWriter . prepareWriteEmpty ( jpegReader . getStreamMetadata ( ) , new ImageTypeSpecifier ( image ) , image . getWidth ( ) , image . getHeight ( ) , tiffMetadata , null , writeParam ) ; tiffWriter . endWriteEmpty ( ) ; app1EXIFOutput . flush ( ) ; byte [ ] app1Parameters = new byte [ 6 + baos . size ( ) ] ; app1Parameters [ 0 ] = ( byte ) 'E' ; app1Parameters [ 1 ] = ( byte ) 'x' ; app1Parameters [ 2 ] = ( byte ) 'i' ; app1Parameters [ 3 ] = ( byte ) 'f' ; app1Parameters [ 4 ] = app1Parameters [ 5 ] = ( byte ) 0 ; System . arraycopy ( baos . toByteArray ( ) , 0 , app1Parameters , 6 , baos . size ( ) ) ; app1Node = new IIOMetadataNode ( "unknown" ) ; app1Node . setAttribute ( "MarkerTag" , ( new Integer ( 0xE1 ) ) . toString ( ) ) ; app1Node . setUserObject ( app1Parameters ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { if ( tiffWriter != null ) tiffWriter . dispose ( ) ; } return app1Node ; }
Private method - creates a copy of the metadata that can be written to
17,286
private long [ ] [ ] getLatitude ( String lat ) { float secs = Float . parseFloat ( "0" + lat . substring ( 4 ) ) * 60.f ; long nom = ( long ) ( secs * 1000 ) ; long [ ] [ ] latl = new long [ ] [ ] { { Long . parseLong ( lat . substring ( 0 , 2 ) ) , 1 } , { Long . parseLong ( lat . substring ( 2 , 4 ) ) , 1 } , { nom , 1000 } } ; return latl ; }
assumes the the format is HHMM . MMMM
17,287
private long [ ] [ ] getLongitude ( String longi ) { float secs = Float . parseFloat ( "0" + longi . substring ( 5 ) ) * 60.f ; long nom = ( long ) ( secs * 1000 ) ; long [ ] [ ] longl = new long [ ] [ ] { { Long . parseLong ( longi . substring ( 0 , 3 ) ) , 1 } , { Long . parseLong ( longi . substring ( 3 , 5 ) ) , 1 } , { nom , 1000 } } ; return longl ; }
assumes the the format is HHHMM . MMMM
17,288
private long [ ] [ ] getTime ( String time ) { long [ ] [ ] timel = new long [ ] [ ] { { Long . parseLong ( time . substring ( 0 , 2 ) ) , 1 } , { Long . parseLong ( time . substring ( 2 , 4 ) ) , 1 } , { Long . parseLong ( time . substring ( 4 ) ) , 1 } } ; return timel ; }
Convert a time to exif format .
17,289
private String [ ] getDate ( String date ) { String dateStr = "20" + date . substring ( 4 ) + ":" + date . substring ( 2 , 4 ) + ":" + date . substring ( 0 , 2 ) ; String [ ] dateArray = new String [ 11 ] ; for ( int i = 0 ; i < dateStr . length ( ) ; i ++ ) dateArray [ i ] = dateStr . substring ( i , i + 1 ) ; dateArray [ 10 ] = "" ; return dateArray ; }
Convert a date to exif date .
17,290
void clear ( ) { count = 0 ; m0 = 0.0 ; clusters . space . setToOrigin ( m1 ) ; clusters . space . setToOrigin ( m2 ) ; var = 0.0 ; key = null ; }
Completely clears this cluster . All points and their associated mass is removed along with any key that was assigned to the cluster
17,291
void set ( final double m , final Object pt ) { if ( m == 0.0 ) { if ( count != 0 ) { clusters . space . setToOrigin ( m1 ) ; clusters . space . setToOrigin ( m2 ) ; } } else { clusters . space . setToScaled ( m1 , m , pt ) ; clusters . space . setToScaledSqr ( m2 , m , pt ) ; } count = 1 ; m0 = m ; var = 0.0 ; }
Sets this cluster equal to a single point .
17,292
void add ( final double m , final Object pt ) { if ( count == 0 ) { set ( m , pt ) ; } else { count += 1 ; if ( m != 0.0 ) { m0 += m ; clusters . space . addScaled ( m1 , m , pt ) ; clusters . space . addScaledSqr ( m2 , m , pt ) ; update ( ) ; } } }
Adds a point to the cluster .
17,293
void set ( GvmCluster < S , K > cluster ) { if ( cluster == this ) throw new IllegalArgumentException ( "cannot set cluster to itself" ) ; m0 = cluster . m0 ; clusters . space . setTo ( m1 , cluster . m1 ) ; clusters . space . setTo ( m2 , cluster . m2 ) ; var = cluster . var ; }
Sets this cluster equal to the specified cluster
17,294
void add ( GvmCluster < S , K > cluster ) { if ( cluster == this ) throw new IllegalArgumentException ( ) ; if ( cluster . count == 0 ) return ; if ( count == 0 ) { set ( cluster ) ; } else { count += cluster . count ; m0 += cluster . m0 ; clusters . space . add ( m1 , cluster . m1 ) ; clusters . space . add ( m2 , cluster . m2 ) ; update ( ) ; } }
Adds the specified cluster to this cluster .
17,295
public static synchronized String char2DOS437 ( StringBuffer stringbuffer , int i , char c ) { if ( unicode2DOS437 == null ) { unicode2DOS437 = new char [ 0x10000 ] ; for ( int j = 0 ; j < 256 ; j ++ ) { char c1 ; if ( ( c1 = unicode [ 2 ] [ j ] ) != '\uFFFF' ) unicode2DOS437 [ c1 ] = ( char ) j ; } } if ( i != 2 ) { StringBuffer stringbuffer1 = new StringBuffer ( stringbuffer . length ( ) ) ; for ( int k = 0 ; k < stringbuffer . length ( ) ; k ++ ) { char c2 = unicode2DOS437 [ stringbuffer . charAt ( k ) ] ; stringbuffer1 . append ( c2 == 0 ? c : c2 ) ; } return new String ( stringbuffer1 ) ; } else { return new String ( stringbuffer ) ; } }
Char to DOS437 converter
17,296
public static void callAnnotated ( Object o , Class < ? extends Annotation > ann , boolean lazy ) { try { getMethodOfInterest ( o , ann ) . invoke ( o ) ; } catch ( IllegalAccessException ex ) { throw new RuntimeException ( ex ) ; } catch ( InvocationTargetException ex ) { throw new RuntimeException ( ex . getCause ( ) ) ; } catch ( IllegalArgumentException ex ) { if ( ! lazy ) { throw new RuntimeException ( ex . getMessage ( ) ) ; } } }
Call an method by Annotation .
17,297
public static Class infoClass ( Class cmp ) { Class info = null ; try { info = Class . forName ( cmp . getName ( ) + "CompInfo" ) ; } catch ( ClassNotFoundException E ) { info = cmp ; } return info ; }
Get the info class for a component object
17,298
public static boolean adjustOutputPath ( File outputDir , Object comp , Logger log ) { boolean adjusted = false ; ComponentAccess cp = new ComponentAccess ( comp ) ; for ( Access in : cp . inputs ( ) ) { String fieldName = in . getField ( ) . getName ( ) ; Class fieldType = in . getField ( ) . getType ( ) ; if ( fieldType == File . class ) { Role role = in . getField ( ) . getAnnotation ( Role . class ) ; if ( role != null && Annotations . plays ( role , Role . OUTPUT ) ) { try { File f = ( File ) in . getField ( ) . get ( comp ) ; if ( f != null && ! f . isAbsolute ( ) ) { f = new File ( outputDir , f . getName ( ) ) ; in . setFieldValue ( f ) ; adjusted = true ; if ( log . isLoggable ( Level . CONFIG ) ) { log . config ( "Adjusting output for '" + fieldName + "' to " + f ) ; } } } catch ( Exception ex ) { throw new ComponentException ( "Failed adjusting output path for '" + fieldName ) ; } } } } return adjusted ; }
Adjust the output path .
17,299
public static Properties createDefault ( Object comp ) { Properties p = new Properties ( ) ; ComponentAccess ca = new ComponentAccess ( comp ) ; for ( Access in : ca . inputs ( ) ) { try { String name = in . getField ( ) . getName ( ) ; Object o = in . getField ( ) . get ( comp ) ; if ( o != null ) { String value = o . toString ( ) ; p . put ( name , value ) ; } } catch ( Exception ex ) { throw new ComponentException ( "Failed access to field: " + in . getField ( ) . getName ( ) ) ; } } return p ; }
Create a default parameter set