List of usage examples for java.lang Float Float
@Deprecated(since = "9") public Float(String s) throws NumberFormatException
From source file:MutableFloat.java
/** * Gets this mutable as an instance of Float. * * @return a Float instance containing the value from this mutable *///from w ww . j av a2 s. co m public Float toFloat() { return new Float(floatValue()); }
From source file:com.whizzosoftware.hobson.philipshue.api.HueBridgeParser.java
protected LightState createLightState(JSONObject obj) throws JSONException { LightState state = new LightState(); state.setOn(obj.getBoolean("on")); state.setBrightness(obj.getInt("bri")); if (obj.has("xy")) { JSONArray a = obj.getJSONArray("xy"); state.setXY(new Float(a.getDouble(0)), new Float(a.getDouble(1))); }/* www . j a va2 s.c om*/ state.setEffect(obj.getString("effect")); if (obj.has("modelid")) { state.setModel(obj.getString("modelid")); } state.setReachable(obj.getBoolean("reachable")); return state; }
From source file:dsd.dao.RawDataDAO.java
private static Object[][] PrepareMultipleValuesForUpdate(List<RawData> listOfData) { Object[][] valueArray = new Object[listOfData.size()][7]; for (int i = 0; i < listOfData.size(); i++) { valueArray[i][0] = new Float(listOfData.get(i).getRawDataID()); valueArray[i][1] = new Float(listOfData.get(i).getWindSpeed()); valueArray[i][2] = new Float(listOfData.get(i).getWindDirection()); valueArray[i][3] = new Float(listOfData.get(i).getHydrometer()); valueArray[i][4] = new Float(listOfData.get(i).getSonar()); valueArray[i][5] = new Integer( listOfData.get(i).getSonarType() == null ? 0 : listOfData.get(i).getSonarType().getCode()); valueArray[i][6] = new Timestamp(listOfData.get(i).getTimestamp()); }/* w ww . j a v a2 s . co m*/ return valueArray; }
From source file:knop.psfj.heatmap.FractionnedSpace.java
/** * Gets the pixel value./*from w w w.j a va 2s .c o m*/ * * @param f the f * @return the pixel value */ public float getPixelValue(Fraction f) { DescriptiveStatistics stats = new DescriptiveStatistics(); float median = Float.NaN; //System.out.println(f); if (f.size() != 0) { for (Point p : f) { //System.out.println(p.getValue()); if (stats == null) System.out.println(stats); if (p == null) continue; stats.addValue(p.getValue()); } median = new Float(stats.getPercentile(50)); //System.out.println("Resultat : "+median); } return median; }
From source file:com.springsource.greenhouse.events.JdbcEventRepositoryTest.java
private void assertSocial(EventSession session, boolean favorite) { assertEquals("Developing Social-Ready Web Applications", session.getTitle()); // assertEquals(new DateTime(2010, 10, 21, 14, 45, 0, 0, DateTimeZone.UTC), session.getStartTime()); // assertEquals(new DateTime(2010, 10, 21, 16, 15, 0, 0, DateTimeZone.UTC), session.getEndTime()); assertEquals(1, session.getLeaders().size()); assertEquals("Craig Walls", session.getLeaders().get(0).getName()); assertEquals(favorite, session.isFavorite()); assertEquals(new Float(0), session.getRating()); assertEquals(favorite, session.isFavorite()); assertEquals("Junior Ballroom B", session.getRoom().getLabel()); }
From source file:es.udc.fic.test.model.RegataTest.java
@Test public void testDiaIniDiaFin() { //Creamos una sola regata con la instancia de todos los objetos en memoria Regata regata = new Regata(); regata.setNombre("Mock Regata"); regata.setDescripcion("Mock Desc"); regataDao.save(regata);/*from w w w. j a v a 2 s .c om*/ Tipo tipoCatamaran = new Tipo("Catamarn", "Desc Catamarn", false); tipoDao.save(tipoCatamaran); Tipo tipoCrucero = new Tipo("Crucero", "Desc Crucero", false); tipoDao.save(tipoCrucero); Tipo tipoLigero = new Tipo("Vela ligera", "Desc Vela ligera", true); tipoDao.save(tipoLigero); Barco b1 = new Barco(204566, "Juan Sebastian El Cano", tipoCatamaran, new Float(1.5), "Lagoon 421"); inscripcionService.inscribir(regata, b1, "Iago Surez"); Barco b2 = new Barco(199012, "El Holandes Errante", tipoCrucero, new Float(2.5), "SWAN 66 FD"); inscripcionService.inscribir(regata, b2, "Samu Paredes"); Barco b3 = new Barco(201402, "La Perla Negra", tipoCrucero, new Float(1.5), "X6"); inscripcionService.inscribir(regata, b3, "Adrian Pallas"); Barco b4 = new Barco(202102, "La Pinta", tipoCrucero, new Float(1.5), "X6"); inscripcionService.inscribir(regata, b4, "Pedro Cabalar"); Barco b5 = new Barco(182345, "Venus", tipoLigero, null, "Laser Standar"); inscripcionService.inscribir(regata, b5, "Jesus Lopez"); Barco b6 = new Barco(206745, "Apolo", tipoLigero, null, "Laser Radial"); inscripcionService.inscribir(regata, b6, "Diego Bascoy"); Calendar dia1 = Calendar.getInstance(); dia1.add(Calendar.DAY_OF_YEAR, -18); Calendar dia2 = Calendar.getInstance(); dia2.add(Calendar.DAY_OF_YEAR, -18); dia2.add(Calendar.HOUR, 2); Calendar dia3 = Calendar.getInstance(); dia3.add(Calendar.DAY_OF_YEAR, -17); Manga manga1 = new Manga(dia1, regata, null, 100); Manga manga2 = new Manga(dia2, regata, null, 100); Manga manga3 = new Manga(dia3, regata, null, 100); List<Posicion> posManga1 = new ArrayList<Posicion>(); posManga1.add(new Posicion(new Long(3600), Penalizacion.DNC, manga1, b1, (long) 0)); posManga1.add(new Posicion(new Long(3700), Penalizacion.OCS, manga1, b2, (long) 0)); posManga1.add(new Posicion(new Long(3750), Penalizacion.NAN, manga1, b3, (long) 0)); posManga1.add(new Posicion(new Long(3900), Penalizacion.NAN, manga1, b4, (long) 0)); posManga1.add(new Posicion(new Long(3400), Penalizacion.SCP, manga1, b5, (long) 0)); posManga1.add(new Posicion(new Long(2400), Penalizacion.NAN, manga1, b6, (long) 0)); manga1.setPosiciones(posManga1); mangaService.cerrarYGuardarManga(manga1); regata.addManga(manga1); List<Posicion> posManga2 = new ArrayList<Posicion>(); posManga2.add(new Posicion(new Long(3400), Penalizacion.NAN, manga2, b1, (long) 0)); posManga2.add(new Posicion(new Long(3600), Penalizacion.NAN, manga2, b2, (long) 0)); posManga2.add(new Posicion(new Long(3950), Penalizacion.NAN, manga2, b3, (long) 0)); posManga2.add(new Posicion(new Long(3200), Penalizacion.RDG, manga2, b4, (long) 0)); posManga2.add(new Posicion(new Long(3100), Penalizacion.NAN, manga2, b5, (long) 0)); posManga2.add(new Posicion(new Long(2800), Penalizacion.RET, manga2, b6, (long) 0)); manga2.setPosiciones(posManga2); mangaService.cerrarYGuardarManga(manga2); regata.addManga(manga2); List<Posicion> posManga3 = new ArrayList<Posicion>(); posManga3.add(new Posicion(new Long(13500), Penalizacion.RDG, manga3, b1, (long) 0)); posManga3.add(new Posicion(new Long(13200), Penalizacion.NAN, manga3, b2, (long) 0)); posManga3.add(new Posicion(new Long(13350), Penalizacion.DGM, manga3, b3, (long) 0)); posManga3.add(new Posicion(new Long(13900), Penalizacion.NAN, manga3, b4, (long) 0)); posManga3.add(new Posicion(new Long(14400), Penalizacion.DNE, manga3, b5, (long) 0)); posManga3.add(new Posicion(new Long(15400), Penalizacion.NAN, manga3, b6, (long) 0)); manga3.setPosiciones(posManga3); mangaService.cerrarYGuardarManga(manga3); regata.addManga(manga3); assertEquals(dia1, regata.getDiaIni()); assertEquals(dia3, regata.getDiaFin()); assertEquals(regata.getDiasManga().size(), 2); assertEquals(regata.getDiasManga().get(0), dia1); assertEquals(regata.getDiasManga().get(1), dia3); }
From source file:com.fengduo.bee.commons.core.lang.CollectionUtils.java
public static <T extends Object> Map<Float, T> toFloatMap(Collection<T> values, String property) { return CollectionUtils.<Float, T>toNumberMap(values, property, new Float(0f)); }
From source file:io.clubby.server.ClubbyDynamicSettings.java
protected static <T> T getObject(String name, Class<T> cls) { T obj = (T) DynamicSettings.instance().getParsedObject(GROUP, name); if (obj != null) { return obj; }//from w w w. j a va2 s . co m String json = DynamicSettings.instance().get(GROUP, name); if (empty(json)) { return null; } if (Long.class.equals(cls)) { obj = (T) new Long(Long.parseLong(json)); } else if (Double.class.equals(cls)) { obj = (T) new Double(Double.parseDouble(json)); } else if (Integer.class.equals(cls)) { obj = (T) new Integer(Integer.parseInt(json)); } else if (Float.class.equals(cls)) { obj = (T) new Float(Float.parseFloat(json)); } else if (ZonedDateTime.class.equals(cls)) { obj = (T) DateUtils.ISO_FORMAT.parse(json); } else { obj = JSON.parse(json, cls); } DynamicSettings.instance().stashParsedObject(GROUP, name, obj); return obj; }
From source file:NumberUtils.java
/** * Converts the given number to a <code>Float</code> (by using <code>floatValue()</code>). * * @param number/* w w w . ja v a 2s. c om*/ * @return java.lang.Float */ public static Float toFloat(Number number) { return number == null || number instanceof Float ? (Float) number : new Float(number.floatValue()); }
From source file:net.sf.dynamicreports.jasper.builder.JasperConcatenatedReportBuilder.java
public JasperConcatenatedReportBuilder toPng(OutputStream outputStream, float zoom) throws DRException { Validate.notNull(outputStream, "outputStream must not be null"); Validate.isTrue(zoom > 0, "zoom must be > 0"); int maxWidth = 0; int maxHeight = 0; for (JasperPrint jasperPrint : jasperReportHandler.getPrintList()) { int pages = jasperPrint.getPages().size(); int pageWidth = (int) (jasperPrint.getPageWidth() * zoom); maxWidth += pageWidth * pages + (pages - 1) + 2; int height = (int) (jasperPrint.getPageHeight() * zoom) + 2; if (height > maxHeight) { maxHeight = height;/* w ww . ja va 2 s . c o m*/ } } Image pageImage = new BufferedImage(maxWidth, maxHeight, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = (Graphics2D) pageImage.getGraphics(); g2d.setColor(Color.LIGHT_GRAY); g2d.fill(new Rectangle2D.Float(1, 1, maxWidth - 1, maxHeight - 1)); int offset = 1; for (JasperPrint jasperPrint : jasperReportHandler.getPrintList()) { int pageWidth = (int) (jasperPrint.getPageWidth() * zoom); for (int i = 0; i < jasperPrint.getPages().size(); i++) { try { JRGraphics2DExporter exporter = new JRGraphics2DExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, pageImage.getGraphics()); exporter.setParameter(JRGraphics2DExporterParameter.OFFSET_X, offset); exporter.setParameter(JRGraphics2DExporterParameter.OFFSET_Y, 1); exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(i)); exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, new Float(zoom)); exporter.exportReport(); offset += pageWidth + 1; } catch (JRException e) { throw new DRException(e); } } } try { ImageIO.write((RenderedImage) pageImage, "png", outputStream); } catch (IOException e) { throw new DRException(e); } return this; }