List of usage examples for java.lang Double Double
@Deprecated(since = "9") public Double(String s) throws NumberFormatException
From source file:com.aurel.track.fieldType.fieldChange.converter.DoubleSetterConverter.java
/** * Convert the string to object value after load * @param value/*from w w w .j a v a 2s .com*/ * @param setter * @return */ @Override public Object getActualValueFromStoredString(String value, Integer setter) { if (value == null || "".equals(value) || setter == null) { return null; } switch (setter.intValue()) { case FieldChangeSetters.SET_TO: case FieldChangeSetters.ADD_IF_SET: case FieldChangeSetters.ADD_OR_SET: try { return new Double(value); } catch (Exception e) { LOGGER.warn("Converting the " + value + " to Double from xml string failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } return null; }
From source file:ch.zhaw.icclab.tnova.expressionsolver.OTFlyEval.java
@POST @Consumes(MediaType.APPLICATION_JSON)//from ww w. j a v a 2s .c om @Produces(MediaType.APPLICATION_JSON) public Response evalOnTheFly(String incomingMsg) { JSONObject incoming = (JSONObject) JSONValue.parse(incomingMsg); JSONObject outgoing = new JSONObject(); String result = ""; try { String expression = (String) incoming.get("exp"); JSONArray vals = (JSONArray) incoming.get("values"); Stack<Double> param = new Stack<Double>(); for (int i = 0; i < vals.size(); i++) { Double val = new Double((String) vals.get(i)); param.push(val); } double threshold = Double.parseDouble((String) incoming.get("threshold")); result = evaluateExpression(expression, param, threshold); } catch (Exception ex) { if (App.showExceptions) ex.printStackTrace(); } logger.info("received expression: " + incoming.get("exp")); logger.info("expression evaluation result: " + result); //construct proper JSON response. outgoing.put("info", "t-nova expression evaluation service"); if (result != null && result.length() != 0) { outgoing.put("result", result); outgoing.put("status", "ok"); KPI.expressions_evaluated += 1; KPI.api_calls_success += 1; return Response.ok(outgoing.toJSONString(), MediaType.APPLICATION_JSON_TYPE).build(); } else { outgoing.put("status", "execution failed"); outgoing.put("msg", "malformed request parameters, check your expression or parameter list for correctness."); KPI.expressions_evaluated += 1; KPI.api_calls_failed += 1; return Response.status(Response.Status.BAD_REQUEST).entity(outgoing.toJSONString()) .encoding(MediaType.APPLICATION_JSON).build(); } }
From source file:asr.failure.FailureDetector.java
/** * Compute the {@link PhiMeasure}./*from www . j a v a2 s . c o m*/ * * @param now * @return phi, null if there are not enough samples */ public Double phi(long now) { if (latestHeartbeat == -1 || samples.getN() < minSamples) { return null; } synchronized (samples) { return new Double(PhiMeasure.compute(samples, now - latestHeartbeat)); } }
From source file:net.sourceforge.fenixedu.presentationTier.validator.form.GreaterThen.java
public static boolean validateFloat0(Object bean, ValidatorAction va, Field field, ActionMessages errors, HttpServletRequest request, ServletContext application) { String inputString = ValidatorUtils.getValueAsString(bean, field.getProperty()); String lowerValueString = field.getVarValue("value"); if ((inputString == null) || (inputString.length() == 0)) { return true; }/*from ww w .ja va 2s . c o m*/ Double input = null; Double lowerValue = null; try { input = new Double(inputString); lowerValue = new Double(lowerValueString); } catch (NumberFormatException e) { errors.add(field.getKey(), Resources.getActionMessage(request, va, field)); return false; } if (!GenericValidator.isBlankOrNull(inputString)) { if (input.floatValue() < lowerValue.floatValue()) { errors.add(field.getKey(), Resources.getActionMessage(request, va, field)); } return false; } return true; }
From source file:ijfx.ui.filter.FilterTest.java
public void update(ActionEvent event) { ArrayList<Double> numbers = new ArrayList<>(); RandomDataGenerator generator = new RandomDataGenerator(); for (int i = 0; i != 300; i++) { numbers.add(new Double(generator.nextUniform(0, 0.5))); }//from ww w . java2 s.com filter.setAllPossibleValue(numbers); borderPane.getStylesheets().remove(ImageJFX.getStylesheet()); borderPane.getStylesheets().add(ImageJFX.getStylesheet()); }
From source file:com.epiq.bitshark.ui.PowerAxis.java
/** * //from ww w .j a v a 2 s . c o m * @param g2 * @param state * @param dataArea * @param edge * @return */ @Override public List refreshTicks(java.awt.Graphics2D g2, AxisState state, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge) { List<NumberTick> tickList = new ArrayList<NumberTick>(); for (int i = -50; i < 180; i += 10) { tickList.add(new NumberTick(new Double(i), String.format("%d dB", (int) Math.round(valueToDb(i))), TextAnchor.CENTER_RIGHT, TextAnchor.CENTER, 0)); } return tickList; }
From source file:Main.java
/** * <p>Inserts the specified element at the specified position in the array. * Shifts the element currently at that position (if any) and any subsequent * elements to the right (adds one to their indices).</p> * * <p>This method returns a new array with the same elements of the input * array plus the given element on the specified position. The component * type of the returned array is always the same as that of the input * array.</p>/* ww w . java2s .com*/ * * <p>If the input array is <code>null</code>, a new one element array is returned * whose component type is the same as the element.</p> * * <pre> * ArrayUtils.add([1.1], 0, 2.2) = [2.2, 1.1] * ArrayUtils.add([2.3, 6.4], 2, 10.5) = [2.3, 6.4, 10.5] * ArrayUtils.add([2.6, 6.7], 0, -4.8) = [-4.8, 2.6, 6.7] * ArrayUtils.add([2.9, 6.0, 0.3], 2, 1.0) = [2.9, 6.0, 1.0, 0.3] * </pre> * * @param array the array to add the element to, may be <code>null</code> * @param index the position of the new object * @param element the object to add * @return A new array containing the existing elements and the new element * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index > array.length). */ public static double[] add(double[] array, int index, double element) { return (double[]) add(array, index, new Double(element), Double.TYPE); }
From source file:org.jfree.data.statistics.BoxAndWhiskerItemTest.java
/** * Confirm that the equals method can distinguish all the required fields. *//*from ww w . j a v a2 s. co m*/ @Test public void testEquals() { BoxAndWhiskerItem i1 = new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()); BoxAndWhiskerItem i2 = new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()); assertTrue(i1.equals(i2)); assertTrue(i2.equals(i1)); }
From source file:eu.alpinweiss.filegen.util.generator.impl.AutoNumberGenerator.java
@Override public void generate(final ParameterVault parameterVault, ThreadLocalRandom randomGenerator, ValueVault valueVault) {// w w w .java2 s. com valueVault.storeValue(new IntegerDataWrapper() { @Override public Double getNumberValue() { int value = startNum + (parameterVault.rowCount() * parameterVault.dataPartNumber()) + parameterVault.iterationNumber(); return new Double(value); } }); }
From source file:com.redhat.lightblue.metadata.types.DoubleTypeTest.java
@Test public void testToJson() { JsonNodeFactory jsonNodeFactory = new JsonNodeFactory(true); JsonNode jsonNode = doubleType.toJson(jsonNodeFactory, Double.MAX_VALUE); assertTrue(new Double(jsonNode.asDouble()).equals(Double.MAX_VALUE)); }