Example usage for java.lang Float valueOf

List of usage examples for java.lang Float valueOf

Introduction

In this page you can find the example usage for java.lang Float valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Float valueOf(float f) 

Source Link

Document

Returns a Float instance representing the specified float value.

Usage

From source file:de.hstsoft.sdeep.model.Note.java

public static Note fromJson(JSONObject obj) {
    Note note = new Note();
    float xPosition = Float.valueOf(obj.get("x").toString());
    float yPosition = Float.valueOf(obj.get("y").toString());
    note.position = new Point2D.Float(xPosition, yPosition);
    note.year = Integer.valueOf(obj.get("year").toString());
    note.month = Integer.valueOf(obj.get("month").toString());
    note.day = Integer.valueOf(obj.get("day").toString());
    note.daysSurvived = Integer.valueOf(obj.get("daysSurvived").toString());
    note.title = obj.get("title").toString();
    note.text = obj.get("text").toString();
    return note;/*from w ww  .  j a v a2  s  . co  m*/
}

From source file:com.redhat.rhn.domain.monitoring.command.FloatValidator.java

/**
 * {@inheritDoc}/*from  w ww .  jav  a 2  s .  c o m*/
 */
public boolean isConvertible(String value) {
    if (value == null) {
        return true;
    }
    try {
        Float.valueOf(value);
        return true;
    } catch (NumberFormatException e) {
        return false;
    }
}

From source file:com.xiaomi.linden.lucene.similarity.IDFManager.java

private IDFManager(String fileName) throws IOException {
    List<String> lines = FileUtils.readLines(new File(fileName));
    wordsIDF = new HashMap<>();
    for (String line : lines) {
        String[] tokens = line.split("\t");
        if (tokens.length != 2) {
            continue;
        }//from ww  w .  j  a v  a  2 s .  co  m
        Float idf = Float.valueOf(tokens[1]);
        if (idf > maxIDF) {
            maxIDF = idf;
        }
        wordsIDF.put(tokens[0], idf);
    }
}

From source file:ImageUtil.java

public static ByteArrayOutputStream smartCrop(ByteArrayInputStream bais, int width, int height)
        throws IOException {
    BufferedImage src = ImageIO.read(bais);

    Float scale;/* w  w w  .  j a  va2 s.c o  m*/
    if (src.getWidth() > src.getHeight()) {
        scale = Float.valueOf(height) / Float.valueOf(src.getHeight());
        if (src.getWidth() * scale < width) {
            scale = Float.valueOf(width) / Float.valueOf(src.getWidth());
        }
    } else {
        scale = Float.valueOf(width) / Float.valueOf(src.getWidth());
        if (src.getHeight() * scale < height) {
            scale = Float.valueOf(height) / Float.valueOf(src.getHeight());
        }
    }
    //        
    //        System.out.println("--- " + src.getWidth() + " - " + width);
    //        System.out.println("--- " + src.getHeight() + " - " + height);
    //        System.out.println("--- " + scale + " -- " + Float.valueOf(src.getWidth() * scale).intValue() + " -- " + Float.valueOf(src.getHeight() * scale).intValue());
    //        
    BufferedImage temp = scale(src, Float.valueOf(src.getWidth() * scale).intValue(),
            Float.valueOf(src.getHeight() * scale).intValue());

    temp = crop(temp, width, height);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageIO.write(temp, "JPG", baos);

    return baos;
}

From source file:com.wabacus.system.datatype.FloatType.java

public Object getColumnValue(ResultSet rs, String column, AbsDatabaseType dbtype) throws SQLException {
    return Float.valueOf(rs.getFloat(column));
}

From source file:com.wabacus.system.datatype.FloatType.java

public Object getColumnValue(ResultSet rs, int iindex, AbsDatabaseType dbtype) throws SQLException {
    return Float.valueOf(rs.getFloat(iindex));
}

From source file:com.snapdeal.scm.fh.service.impl.ConvertorService.java

@SuppressWarnings("unchecked")
@Override/*from   w  w  w .j a  v  a 2  s  .c om*/
public <T> T convertToObject(Class<T> clazz, String value) throws ParseException {
    if (StringUtils.isEmpty(value) || StringUtils.NULL.equalsIgnoreCase(value)) {
        return null;
    }
    if (clazz.equals(Integer.class)) {
        return (T) Integer.valueOf(value);
    }
    if (clazz.equals(Date.class)) {
        try {
            return (T) new Date(Long.valueOf(value));
        } catch (NumberFormatException ne) {
            return (T) DateUtils.parseDate(value, ALLOWED_DATE_FORMATS);
        }
    }
    if (clazz.equals(String.class)) {
        return (T) value;
    }
    if (clazz.equals(Float.class)) {
        return (T) Float.valueOf(value);
    }
    if (clazz.equals(Double.class)) {
        return (T) Double.valueOf(value);
    }
    if (clazz.equals(Boolean.class)) {
        if (value.equals("1") || value.equalsIgnoreCase("true")) {
            return (T) Boolean.TRUE;
        } else if (value.equals("0") || value.equalsIgnoreCase("false")) {
            return (T) Boolean.FALSE;
        }
    }
    throw new ParseException("unable to parse string [" + value + "] to class " + clazz, 0);
}

From source file:Main.java

/**
 * according station to get frequency string
 * @param station for 100KZ, range 875-1080, for 50khz 8750,1080
 * @return string like 87.5 or 87.50//w  ww.  jav a  2 s.  co m
 */
public static String formatStation(int station) {
    float frequency = (float) station / CONVERT_RATE;
    String result = null;
    if (false/*FeatureOption.MTK_FM_50KHZ_SUPPORT*/) {
        result = String.format(Locale.ENGLISH, "%.2f", Float.valueOf(frequency));
    } else {
        result = String.format(Locale.ENGLISH, "%.1f", Float.valueOf(frequency));
    }
    return result;
}

From source file:grails.plugin.searchable.internal.compass.search.SearchableSubsetSearchResultFactory.java

public Object buildSearchResult(final CompassHits hits, final Object collectedHits,
        final Object collectedCompassHits, Map options) {
    final int offset = MapUtils.getIntValue(options, "offset");
    final int max = MapUtils.getIntValue(options, "max");
    final List scores = new ArrayList(max);
    for (int i = offset; i < Math.min(offset + max, hits.length()); i++) {
        scores.add(i - offset, Float.valueOf(hits.score(i)));
    }//from w  w  w .  j a  va  2s .  c o  m

    Map map = new HashMap();
    map.put("offset", offset);
    map.put("max", max);
    map.put("results", collectedHits);

    map.put("scores", scores);
    map.put("total", hits.length());
    //need to return the compass hits also!
    map.put("hits", collectedCompassHits);
    return map;
}

From source file:com.xiaomi.linden.lucene.similarity.IDFManager.java

private IDFManager(InputStream inputStream) throws IOException {
    String line;//from w  ww .j  a va 2s . c  o  m
    BufferedReader bf = new BufferedReader(new InputStreamReader(inputStream));
    wordsIDF = new HashMap<>();
    while ((line = bf.readLine()) != null) {
        String[] tokens = line.split("\t");
        if (tokens.length != 2)
            continue;
        Float idf = Float.valueOf(tokens[1]);
        if (idf > maxIDF)
            maxIDF = idf;
        wordsIDF.put(tokens[0], idf);
    }
    bf.close();
}