List of usage examples for java.lang Float valueOf
@HotSpotIntrinsicCandidate public static Float valueOf(float f)
From source file:com.formkiq.core.service.generator.pdfbox.TextToPDFieldMapper.java
/** * Override the default functionality of PDFTextStripper. *///from w w w. j av a 2 s. com @Override protected void writeString(final String o, final List<TextPosition> textPositions) throws IOException { Integer page = Integer.valueOf(getCurrentPageNo() - 1); if (!this.textLocations.containsKey(page)) { this.textLocations.put(page, new ArrayList<>()); } // TODO replace with CollectionUtil.groupBy List<List<TextPosition>> splits = split(removeNonPrintableAndExtraSpaces(textPositions)); for (List<TextPosition> tps : splits) { String text = tps.stream().map(s -> s.getUnicode()).collect(Collectors.joining()); if (text.matches(".*[a-zA-Z0-9/]+.*")) { PDRectangle rect = calculateTextPosition(tps); PDFont font = tps.get(0).getFont(); float fontSize = tps.stream().map(s -> Float.valueOf(s.getFontSizeInPt())).max(Float::compare) .orElse(Float.valueOf(0)).floatValue(); PdfTextField tf = new PdfTextField(); tf.setText(text.replaceAll("\t", " ")); tf.setRectangle(rect); tf.setFontSize(fontSize); tf.setFontName(font.getName()); LOG.log(Level.FINE, "page=" + page + ",rect=" + rect + ",fontsize=" + fontSize + ",font=" + font + ",text=" + text); this.textLocations.get(page).add(tf); } } }
From source file:com.example.hbranciforte.trafficclient.DataTraffic.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_data_traffic); if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); }/* w w w .java2 s. c om*/ try { zone_info = new JSONObject((String) getIntent().getSerializableExtra("zone_info")); } catch (JSONException e) { e.printStackTrace(); } EditText ed_fichas = (EditText) findViewById(R.id.fichas); ed_fichas.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { //float price = (float) 0.0; Integer time = 0; TextView txtvalor = (TextView) findViewById(R.id.valor); TextView txttiempo = (TextView) findViewById(R.id.txtTime); if (s.toString() != "") { try { price = (float) zone_info.getDouble("unit_price") * Float.valueOf(s.toString()); time = zone_info.getInt("unit_time") * Integer.parseInt(s.toString()); txtvalor.setText("$ ".concat(Float.toString(price))); txttiempo.setText(time.toString().concat(" min")); } catch (Exception e) { Log.e("getting data0:", e.getMessage()); txttiempo.setText("0 min"); txtvalor.setText("$ 0.0"); } } } }); }
From source file:org.wicketstuff.gmap.api.GLatLng.java
/** * (37.34068368469045, -122.48519897460936) *///from w w w . j a v a2 s . c o m public static GLatLng parse(String value) { try { StringTokenizer tokenizer = new StringTokenizer(value, "(, )"); float lat = Float.valueOf(tokenizer.nextToken()); float lng = Float.valueOf(tokenizer.nextToken()); return new GLatLng(lat, lng); } catch (Exception e) { return null; } }
From source file:com.orthancserver.DicomDecoder.java
private static void ExtractPixelSpacing(ImagePlus image, JSONObject tags) { JSONObject pixelSpacing = (JSONObject) tags.get("0028,0030"); if (pixelSpacing != null) { String[] tokens = ((String) pixelSpacing.get("Value")).split("\\\\"); if (tokens.length == 2) { FileInfo fi = image.getFileInfo(); fi.pixelWidth = Float.valueOf(tokens[0]); fi.pixelHeight = Float.valueOf(tokens[1]); fi.unit = "mm"; image.setFileInfo(fi);/* w w w. j a v a 2 s . co m*/ image.getCalibration().pixelWidth = fi.pixelWidth; image.getCalibration().pixelHeight = fi.pixelHeight; image.getCalibration().setUnit(fi.unit); } } }
From source file:com.spaceprogram.simplejpa.util.AmazonSimpleDBUtil.java
/** * Decodes zero-padded positive float value from the string representation * * @param value zero-padded string representation of the float value * @return original float value//from w w w .j a va 2 s. c o m */ public static float decodeZeroPaddingFloat(String value) { return Float.valueOf(value).floatValue(); }
From source file:com.sonoport.freesound.response.mapping.Mapper.java
/** * Extract a named value from a {@link JSONObject}. This method checks whether the value exists and is not an * instance of <code>JSONObject.NULL</code>. * * @param jsonObject The {@link JSONObject} being processed * @param field The field to retrieve//from ww w . j a v a 2 s. com * @param fieldType The data type of the field * @return The field value (or null if not found) * * @param <T> The data type to return */ @SuppressWarnings("unchecked") protected <T extends Object> T extractFieldValue(final JSONObject jsonObject, final String field, final Class<T> fieldType) { T fieldValue = null; if ((jsonObject != null) && jsonObject.has(field) && !jsonObject.isNull(field)) { try { if (fieldType == String.class) { fieldValue = (T) jsonObject.getString(field); } else if (fieldType == Integer.class) { fieldValue = (T) Integer.valueOf(jsonObject.getInt(field)); } else if (fieldType == Long.class) { fieldValue = (T) Long.valueOf(jsonObject.getLong(field)); } else if (fieldType == Float.class) { fieldValue = (T) Float.valueOf(Double.toString(jsonObject.getDouble(field))); } else if (fieldType == JSONArray.class) { fieldValue = (T) jsonObject.getJSONArray(field); } else if (fieldType == JSONObject.class) { fieldValue = (T) jsonObject.getJSONObject(field); } else { fieldValue = (T) jsonObject.get(field); } } catch (final JSONException | ClassCastException e) { // TODO Log a warning } } return fieldValue; }
From source file:io.druid.data.input.MapBasedRow.java
@Override public float getFloatMetric(String metric) { Object metricValue = event.get(metric); if (metricValue == null) { return 0.0f; }// w w w . ja v a 2 s. co m if (metricValue instanceof Number) { return ((Number) metricValue).floatValue(); } else if (metricValue instanceof String) { try { return Float.valueOf(((String) metricValue).replace(",", "")); } catch (Exception e) { throw new FormattedException.Builder().withErrorCode(FormattedException.ErrorCode.UNPARSABLE_METRIC) .withDetails( ImmutableMap.<String, Object>of("metricName", metric, "metricValue", metricValue)) .withMessage(e.getMessage()).build(); } } else { throw new IAE("Unknown type[%s]", metricValue.getClass()); } }
From source file:org.eclipse.swt.examples.graphics.BallTab.java
@Override public void next(int width, int height) { for (int i = 0; i < bc.length; i++) { if (bc[i] == null) return; if (bc[i].prevx.size() == 0) { bc[i].prevx.addLast(Float.valueOf(bc[i].x)); bc[i].prevy.addLast(Float.valueOf(bc[i].y)); } else if (bc[i].prevx.size() == bc[i].capacity) { bc[i].prevx.removeFirst();/*from w ww . j av a 2 s .co m*/ bc[i].prevy.removeFirst(); } bc[i].x += bc[i].incX; bc[i].y += bc[i].incY; float random = (float) Math.random(); // right if (bc[i].x + bc[i].ball_size > width) { bc[i].x = width - bc[i].ball_size; bc[i].incX = random * -width / 16 - 1; } // left if (bc[i].x < 0) { bc[i].x = 0; bc[i].incX = random * width / 16 + 1; } // bottom if (bc[i].y + bc[i].ball_size > height) { bc[i].y = (height - bc[i].ball_size) - 2; bc[i].incY = random * -height / 16 - 1; } // top if (bc[i].y < 0) { bc[i].y = 0; bc[i].incY = random * height / 16 + 1; } bc[i].prevx.addLast(Float.valueOf(bc[i].x)); bc[i].prevy.addLast(Float.valueOf(bc[i].y)); } }
From source file:com.frapim.windwatch.wunderground.Api.java
private Wind parseWind(String json) { if (json == null) { Log.e(TAG, "Null json when getting wind, returning null"); return Wind.NULL; }/*from ww w .j a v a2 s . co m*/ Wind wind = new Wind(); try { JSONObject root = new JSONObject(json); JSONObject currentObs = root.getJSONObject(Conditions.CURRENT_OBSERVATION); wind.observationTimestamp = currentObs.getLong(Conditions.OBSERVATION_EPOCH); JSONObject displayLoc = currentObs.getJSONObject(Conditions.DISPLAY_LOCATION); wind.location = displayLoc.getString(Conditions.FULL); wind.text = currentObs.getString(Conditions.Wind.TEXT); ///wind.degrees = Float.valueOf(currentObs.getString(Conditions.Wind.DEGREES)); wind.direction = Direction.getFromStr(currentObs.getString(Conditions.Wind.DIRECTION)); wind.degrees = wind.direction.degrees; wind.gustKph = Float.valueOf(currentObs.getString(Conditions.Wind.GUST_KPH)); wind.gustMph = Float.valueOf(currentObs.getString(Conditions.Wind.GUST_MPH)); wind.kph = Float.valueOf(currentObs.getString(Conditions.Wind.KPH)); wind.setMph(Float.valueOf(currentObs.getString(Conditions.Wind.MPH))); } catch (JSONException e) { Log.e(TAG, "Error parsing json", e); } return wind; }
From source file:net.sf.jasperreports.customizers.marker.CategoryMarkerCustomizer.java
protected CategoryMarker createMarker(JRChart jrc) { Comparable<?> value = getProperty(PROPERTY_CATEGORY); if (value == null) { return null; }// w w w . j a v a2s. c om CategoryMarker marker = new CategoryMarker(value); configureMarker(marker); configureStroke(marker); Boolean drawAsLine = getBooleanProperty(PROPERTY_DRAW_AS_LINE); if (drawAsLine != null) { marker.setDrawAsLine(drawAsLine); } //Setup the font Font font = marker.getLabelFont(); String fontName = getProperty(PROPERTY_FONT_NAME); if (fontName == null) { fontName = font.getName(); } Float fontSize = getFloatProperty(PROPERTY_FONT_SIZE); if (fontSize == null) { fontSize = Float.valueOf(font.getSize()); } int fontStyle = Font.PLAIN; Boolean isBold = getBooleanProperty(PROPERTY_FONT_BOLD); if (isBold != null) { fontStyle = fontStyle | Font.BOLD; } Boolean isItalic = getBooleanProperty(PROPERTY_FONT_ITALIC); if (isItalic != null) { fontStyle = fontStyle | Font.ITALIC; } marker.setLabelFont(FontUtil.getInstance(filler.getJasperReportsContext()).getAwtFontFromBundles(fontName, fontStyle, fontSize, filler.getFillContext().getMasterLocale(), true)); return marker; }