List of usage examples for java.lang Float Float
@Deprecated(since = "9") public Float(String s) throws NumberFormatException
From source file:edu.hawaii.soest.hioos.isus.ISUSFrame.java
public double getInternalPowerVoltage5() { this.internalPowerVoltage5.flip(); return (new Float(this.internalPowerVoltage5.getFloat())).doubleValue(); }
From source file:edu.hawaii.soest.hioos.isus.ISUSFrame.java
public double getMainPowerVoltage() { this.mainPowerVoltage.flip(); return (new Float(this.mainPowerVoltage.getFloat())).doubleValue(); }
From source file:edu.hawaii.soest.hioos.isus.ISUSFrame.java
public double getReferenceAverage() { this.referenceAverage.flip(); return (new Float(this.referenceAverage.getFloat())).doubleValue(); }
From source file:net.sf.juffrou.reflect.spring.BeanWrapperTests.java
@Test public void testNumberCoercion() { NumberTestBean tb = new NumberTestBean(); BeanWrapper bw = new JuffrouSpringBeanWrapper(tb); try {/*from w w w. ja v a2 s . co m*/ bw.setPropertyValue("short2", new Integer(2)); bw.setPropertyValue("int2", new Long(8)); bw.setPropertyValue("long2", new BigInteger("6")); bw.setPropertyValue("bigInteger", new Integer(3)); bw.setPropertyValue("float2", new Double(8.1)); bw.setPropertyValue("double2", new BigDecimal(6.1)); bw.setPropertyValue("bigDecimal", new Float(4.0)); } catch (BeansException ex) { fail("Should not throw BeansException: " + ex.getMessage()); } assertTrue("Correct short2 value", new Short("2").equals(bw.getPropertyValue("short2"))); assertTrue("Correct short2 value", new Short("2").equals(tb.getShort2())); assertTrue("Correct int2 value", new Integer("8").equals(bw.getPropertyValue("int2"))); assertTrue("Correct int2 value", new Integer("8").equals(tb.getInt2())); assertTrue("Correct long2 value", new Long("6").equals(bw.getPropertyValue("long2"))); assertTrue("Correct long2 value", new Long("6").equals(tb.getLong2())); assertTrue("Correct bigInteger value", new BigInteger("3").equals(bw.getPropertyValue("bigInteger"))); assertTrue("Correct bigInteger value", new BigInteger("3").equals(tb.getBigInteger())); assertTrue("Correct float2 value", new Float("8.1").equals(bw.getPropertyValue("float2"))); assertTrue("Correct float2 value", new Float("8.1").equals(tb.getFloat2())); assertTrue("Correct double2 value", new Double("6.1").equals(bw.getPropertyValue("double2"))); assertTrue("Correct double2 value", new Double("6.1").equals(tb.getDouble2())); assertTrue("Correct bigDecimal value", new BigDecimal("4.0").equals(bw.getPropertyValue("bigDecimal"))); assertTrue("Correct bigDecimal value", new BigDecimal("4.0").equals(tb.getBigDecimal())); }
From source file:edu.hawaii.soest.hioos.isus.ISUSFrame.java
public double getReferenceVariance() { this.referenceVariance.flip(); return (new Float(this.referenceVariance.getFloat())).doubleValue(); }
From source file:io.s4.util.LoadGenerator.java
@SuppressWarnings("unchecked") private Object makeSettableValue(Property property, Object value) { String propertyName = property.getName(); Class propertyType = property.getType(); if (propertyType.isArray()) { if (!(value instanceof JSONArray)) { System.err.println("Type mismatch for field " + propertyName); return null; }//www . ja v a 2 s . c o m System.out.println("Is array!"); return makeArray(property, (JSONArray) value); } else if (property.isList()) { if (!(value instanceof JSONArray)) { System.err.println("Type mismatch for field " + propertyName); return null; } return makeList(property, (JSONArray) value); } else if (propertyType.isPrimitive()) { if (!(value instanceof Number || value instanceof Boolean)) { System.err.println("Type mismatch for field " + propertyName + "; expected number or boolean, found " + value.getClass()); return null; } return value; // hmm... does this work? } else if (propertyType.equals(String.class)) { if (!(value instanceof String)) { System.err.println( "Type mismatch for field " + propertyName + "; expected String, found " + value.getClass()); return null; } return value; } else if (property.isNumber()) { if (!(value instanceof Integer || value instanceof Long || value instanceof Float || value instanceof Double || value instanceof BigDecimal || value instanceof BigInteger)) { return null; } Number adjustedValue = (Number) value; if (propertyType.equals(Long.class) && !(value instanceof Long)) { adjustedValue = new Long(((Number) value).longValue()); } else if (propertyType.equals(Integer.class) && !(value instanceof Integer)) { adjustedValue = new Integer(((Number) value).intValue()); } else if (propertyType.equals(Double.class) && !(value instanceof Double)) { adjustedValue = new Double(((Number) value).doubleValue()); } else if (propertyType.equals(Float.class) && !(value instanceof Float)) { adjustedValue = new Float(((Number) value).floatValue()); } else if (propertyType.equals(BigDecimal.class)) { adjustedValue = new BigDecimal(((Number) value).longValue()); } else if (propertyType.equals(BigInteger.class)) { adjustedValue = BigInteger.valueOf(((Number) value).longValue()); } return adjustedValue; } else if (value instanceof JSONObject) { return makeRecord((JSONObject) value, property.getSchema()); } return null; }
From source file:com.gisgraphy.importer.GeonamesZipCodeImporterTest.java
@Test public void findFeatureNoResultThenNoResults() { String lat = "3.5"; String lng = "44"; String accuracy = "5"; String placeName = "place name"; String countryCode = "FR"; String adm1Name = "adm1name"; String adm1Code = "adm1code"; String adm2Name = "adm2name"; String adm2Code = "adm2code"; String adm3Name = "adm3name"; String adm3COde = "adm3code"; FulltextQuery fulltextQuery = new FulltextQuery(placeName + " " + adm1Name); fulltextQuery.limitToCountryCode(countryCode); fulltextQuery.withPlaceTypes(com.gisgraphy.fulltext.Constants.CITY_AND_CITYSUBDIVISION_PLACETYPE); GeonamesZipCodeSimpleImporter importer = new GeonamesZipCodeSimpleImporter() { int count = 0; @Override//from w ww . j av a 2 s . c om protected FulltextResultsDto doAFulltextSearch(String query, String countryCode) { count = count + 1; if (count == 1) { return new FulltextResultsDto(); } else if (count == 2) { return new FulltextResultsDto(); } else return null; } }; String[] fields = { countryCode, "post", placeName, adm1Name, adm1Code, adm2Name, adm2Code, adm3Name, adm3COde, lat, lng, accuracy }; Point point = GeolocHelper.createPoint(new Float(lng), new Float(lat)); int maxDistance = importer.getAccurateDistance(new Integer(accuracy)); Long actualFeatureId = importer.findFeature(fields, point, maxDistance); Assert.assertNull(actualFeatureId); }
From source file:org.squale.squalecommon.enterpriselayer.facade.quality.MeasureFacade.java
/** * Creation d'une mesure de type Kiviat pour une application * /*from w w w . j a v a 2 s .c o m*/ * @param pAuditId Id de l'audit * @param pAllFactors tous les facteurs (= "true") ou seulement ceux ayant une note ? * @throws JrafEnterpriseException en cas de pb Hibernate * @return les donnes ncessaires la conception du Kiviat via une Applet soit : Map dont la cl contient les * projets et la valeur contient une map (facteurs, notes) */ public static Map getApplicationKiviat(Long pAuditId, String pAllFactors) throws JrafEnterpriseException { MeasureDAOImpl measureDAO = MeasureDAOImpl.getInstance(); // Session Hibernate ISession session = null; Map result = new HashMap(); try { // rcupration d'une session session = PERSISTENTPROVIDER.getSession(); ApplicationBO application = (ApplicationBO) ApplicationDAOImpl.getInstance().loadByAuditId(session, pAuditId); Iterator itp = application.getChildren().iterator(); ArrayList nullValuesList = new ArrayList(); while (itp.hasNext()) { // On ajoute les notes de chaque projets sur le kiviat ProjectBO project = (ProjectBO) itp.next(); SortedMap values = new TreeMap(); Long idProject = new Long(project.getId()); // recupere les facteurs du projet Collection factorResults = QualityResultDAOImpl.getInstance().findWhere(session, idProject, pAuditId); // et cree le map nom => note correspondant Iterator itf = factorResults.iterator(); while (itf.hasNext()) { FactorResultBO factor = (FactorResultBO) itf.next(); // le -1 est trait directement par le kiviatMaker Float value = new Float(factor.getMeanMark()); // le nom internationalis est gr dans le kiviatMaker String name = factor.getRule().getName(); values.put(name, value); if (factor.getMeanMark() < 0) { nullValuesList.add(name); } } // affichage seulement des facteurs qui ont des valeurs final int FACTORS_MIN = 3; values = deleteFactors(values, nullValuesList, pAllFactors, FACTORS_MIN); // et on envoie les valeurs result.put(project.getName(), values); } } catch (Exception e) { FacadeHelper.convertException(e, MeasureFacade.class.getName() + ".getMeasures"); } finally { FacadeHelper.closeSession(session, MeasureFacade.class.getName() + ".getMeasures"); } return result; }
From source file:abfab3d.shapejs.ShapeJSGlobal.java
/** * Load a model into a Grid//from w w w.j a v a 2 s . c o m * <p/> * This method is defined as a JavaScript function. */ public static Object loadModelDensity(Context cx, Scriptable thisObj, Object[] args, Function funObj) { if (args.length < 1) { throw Context.reportRuntimeError("No file provided for load() command"); } String filename = Context.toString(args[0]); printf("filename: %s\n", filename); AttributeGrid grid = null; if (filename == null || filename.length() == 0) { throw Context.reportRuntimeError("No file provided for load() command"); } // TODO: This needs URL caching double vs = 0.1 * MM; if (args.length > 1) { Object arg1 = unwrap(args[1]); printf("arg[1]: %s\n", arg1); if (arg1 instanceof Grid) { grid = (AttributeGrid) arg1; } else { vs = getDouble(arg1); } } double margin = vs; if (args.length > 2) { margin = getDouble(args[2]); } printf("load(%s, vs: %7.3f mm, margin: %7.3f mm)\n", filename, vs / MM, margin / MM); try { BoundingBoxCalculator bb = new BoundingBoxCalculator(); TriangleProducer tp = null; if (filename.endsWith(".x3d") || filename.endsWith(".x3db") || filename.endsWith(".x3dv")) { tp = new X3DReader(filename); tp.getTriangles(bb); } else if (filename.endsWith(".svx")) { SVXReader reader = new SVXReader(); return reader.load(filename); } else { tp = new STLReader(filename); tp.getTriangles(bb); } double bounds[] = new double[6]; bb.getBounds(bounds); printf(" orig bounds: [ %7.3f, %7.3f], [%7.3f, %7.3f], [%7.3f, %7.3f] mm; vs: %7.3f mm\n", bounds[0] / MM, bounds[1] / MM, bounds[2] / MM, bounds[3] / MM, bounds[4] / MM, bounds[5] / MM, vs / MM); // Add a margin around the model to get some space bounds = MathUtil.extendBounds(bounds, margin); // // round up to the nearest voxel // MathUtil.roundBounds(bounds, vs); int nx = (int) Math.round((bounds[1] - bounds[0]) / vs); int ny = (int) Math.round((bounds[3] - bounds[2]) / vs); int nz = (int) Math.round((bounds[5] - bounds[4]) / vs); printf(" grid bounds: [ %7.3f, %7.3f], [%7.3f, %7.3f], [%7.3f, %7.3f] mm; vs: %7.3f mm\n", bounds[0] / MM, bounds[1] / MM, bounds[2] / MM, bounds[3] / MM, bounds[4] / MM, bounds[5] / MM, vs / MM); printf(" grid size: [%d x %d x %d]\n", nx, ny, nz); // range check bounds and voxelSized for (int i = 0; i < bounds.length; i++) { Float f = new Float(bounds[i]); if (f.isNaN()) { throw new IllegalArgumentException("Grid size[" + i + "] is Not a Number."); } } if (nx <= 0) { throw new IllegalArgumentException("Grid x size <= 0: " + nx); } if (ny <= 0) { throw new IllegalArgumentException("Grid y size <= 0" + ny); } if (nz <= 0) { throw new IllegalArgumentException("Grid z size <= 0" + nz); } AttributeGrid dest = null; if (grid == null) { dest = makeEmptyGrid(new int[] { nx, ny, nz }, vs); } else { dest = grid; } dest.setGridBounds(bounds); WaveletRasterizer rasterizer = new WaveletRasterizer(bounds, nx, ny, nz); rasterizer.setMaxAttributeValue(m_svr); tp.getTriangles(rasterizer); rasterizer.getRaster(dest); System.out.println("Loaded: " + filename); return dest; } catch (Throwable t) { t.printStackTrace(); } throw Context.reportRuntimeError("Failed to load file: " + filename); }
From source file:edu.hawaii.soest.hioos.isus.ISUSFrame.java
public double getSeaWaterDarkCounts() { this.seaWaterDarkCounts.flip(); return (new Float(this.seaWaterDarkCounts.getFloat())).doubleValue(); }