List of usage examples for java.lang Double Double
@Deprecated(since = "9") public Double(String s) throws NumberFormatException
From source file:gda.device.detector.countertimer.TFGScalerWithRatio.java
@Override public double[] readout() throws DeviceException { double[] output = super.readout(); if (getDarkCurrent() != null) { output = adjustForDarkCurrent(output, getCollectionTime()); }//from w w w. java2 s .com if (outputRatio) { Double ratio = new Double(0); // find which col is which I0, It and Iref Double[] values = getI0It(output); ratio = values[1] / values[0]; // always return a numerical value if (ratio.isInfinite() || ratio.isNaN()) { ratio = 0.0; } // append to output array output = correctCounts(output, values); output = ArrayUtils.add(output, ratio); } return output; }
From source file:com.rabbitmq.jms.sample.StockQuoter.java
@Scheduled(fixedRate = 5000L) // every 5 seconds public void publishQuote() { // Pick a random stock symbol Collections.shuffle(stocks);/*from www . j a v a2s.com*/ String symbol = stocks.get(0); // Toss a coin and decide if the price goes... if (RandomUtils.nextBoolean()) { // ...up by a random 0-10% lastPrice.put(symbol, new Double( Math.round(lastPrice.get(symbol) * (1 + RandomUtils.nextInt(10) / 100.0) * 100) / 100)); } else { // ...or down by a similar random amount lastPrice.put(symbol, new Double( Math.round(lastPrice.get(symbol) * (1 - RandomUtils.nextInt(10) / 100.0) * 100) / 100)); } // Log new price locally log.info("Quote..." + symbol + " is now " + lastPrice.get(symbol)); // Coerce a javax.jms.MessageCreator MessageCreator messageCreator = (Session session) -> { return session.createObjectMessage("Quote..." + symbol + " is now " + lastPrice.get(symbol)); }; // And publish to RabbitMQ using Spring's JmsTemplate jmsTemplate.send("rabbit-trader-channel", messageCreator); }
From source file:com.judoscript.jamaica.MyUtils.java
public static Object parseFloatObject(String x, String typeHint) { char ch = x.charAt(x.length() - 1); boolean isDouble = ch == 'd' || ch == 'D'; if (ch == 'f' || ch == 'F' || ch == 'd' || ch == 'D') x = x.substring(0, x.length() - 1); isDouble |= "double".equals(typeHint); if (isDouble && typeHint == null) typeHint = "double"; double d;//from w w w . ja v a 2 s . co m try { d = Double.parseDouble(x); } catch (Exception e) { d = 0; } if (typeHint != null) return number2object(d, typeHint); if (isDouble) return new Double(d); else return new Float((float) d); }
From source file:com.qualogy.qafe.core.script.Script.java
public void addAll(ApplicationContext context, ApplicationStoreIdentifier storeId, DataIdentifier dataId, List placeHolders, String localStoreId) { for (Iterator iter = placeHolders.iterator(); iter.hasNext();) { PlaceHolder placeHolder = (PlaceHolder) iter.next(); if (placeHolder != null) { Object placeHolderValue = ParameterValueHandler.get(context, storeId, dataId, placeHolder, localStoreId);/* w w w .ja v a2 s . c o m*/ if (placeHolderValue instanceof String && NumberUtils.isNumber((String) placeHolderValue)) { placeHolderValue = NumberUtils.createNumber((String) placeHolderValue); } if (placeHolderValue instanceof BigDecimal) { placeHolderValue = new Double(((BigDecimal) placeHolderValue).doubleValue()); } String scriptKey = placeHolder.getName(); scriptKey = IDENTIFIER_PREFIX + parameters.keySet().size(); expression = StringUtils.replace(expression, placeHolder.getPlaceHolderKey(), scriptKey); parameters.put(scriptKey, placeHolderValue); } } }
From source file:eu.planets_project.pp.plato.action.fte.AnalyseResultsFastTrack.java
@Override protected void init() { for (Leaf l : selectedPlan.getTree().getRoot().getAllLeaves()) { // initialise the values for free text transformers // AND fill up unmapped values to map to neutral, i.e. 2.5, in the transformer // since the user wont be able to edit the mappings in FTE... l.initTransformer(new Double(2.5)); }// w w w .j av a2 s .co m analyseResults.init(); }
From source file:fr.pasteque.pos.payment.PaymentInfo.java
public String printTotal() { Formats.setAltCurrency(this.currency); return Formats.CURRENCY.formatValue(new Double(getTotal())); }
From source file:org.jfree.chart.demo.PieChart3DDemo2.java
/** * Creates a new demo.//from w w w. j a v a2s . c om * * @param title the frame title. */ public PieChart3DDemo2(final String title) { super(title); // create a dataset... final DefaultPieDataset data = new DefaultPieDataset(); data.setValue("Java", new Double(43.2)); data.setValue("Visual Basic", new Double(10.0)); data.setValue("C/C++", new Double(17.5)); data.setValue("PHP", new Double(32.5)); data.setValue("Perl", new Double(12.5)); // create the chart... final JFreeChart chart = ChartFactory.createPieChart3D("Pie Chart 3D Demo 2", // chart title data, // data true, // include legend true, false); chart.setBackgroundPaint(Color.yellow); final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(270); plot.setDirection(Rotation.ANTICLOCKWISE); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.33); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); final Rotator rotator = new Rotator(plot); rotator.start(); }
From source file:info.magnolia.cms.util.NodeDataUtil.java
/** * Returns the value as an Object./*from ww w . ja v a2 s . co m*/ * @return Object */ public static Object getValue(NodeData nd) { try { switch (nd.getType()) { case (PropertyType.STRING): return nd.getString(); case (PropertyType.DOUBLE): return new Double(nd.getDouble()); case (PropertyType.LONG): return new Long(nd.getLong()); case (PropertyType.BOOLEAN): return new Boolean(nd.getBoolean()); case (PropertyType.DATE): return nd.getDate().getTime(); case (PropertyType.BINARY): return null; default: return null; } } catch (Exception e) { if (log.isDebugEnabled()) log.debug("Exception caught: " + e.getMessage(), e); //$NON-NLS-1$ } return null; }
From source file:test.gov.nih.nci.cacoresdk.domain.other.primarykey.DoubleKeyResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set//from w w w . j a v a 2 s . c o m * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { DoubleKey searchObject = new DoubleKey(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.primarykey.DoubleKey", searchObject); String id = ""; if (results != null && results.size() > 0) { DoubleKey obj = (DoubleKey) ((List) results).get(0); Double idVal = obj.getId(); id = new Double(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/DoubleKey/" + id; WebClient client = WebClient.create(url); client.type("application/xml").accept("application/xml"); Response response = client.get(); if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } File myFile = new File("DoubleKey" + "XML.xml"); System.out.println("writing data to file " + myFile.getAbsolutePath()); FileWriter myWriter = new FileWriter(myFile); BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { myWriter.write(output); System.out.println(output); } myWriter.flush(); myWriter.close(); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:de.suse.swamp.test.TestStatisticsGraph.java
public void testStatistic() { XYSeries series = new XYSeries("Running Workflows"); series.add(1995, 0.5);/* ww w.j a v a 2 s . com*/ series.add(2000, 3.0); series.add(2010, 20.0); series.add(2020, 50.0); XYDataset dataset = new XYSeriesCollection(series); JFreeChart chart = ChartFactory.createTimeSeriesChart("test", "time", "value", dataset, false, false, false); JFreeChart chart4; DefaultPieDataset dataset2 = new DefaultPieDataset(); // Initialize the dataset dataset2.setValue("California", new Double(10.0)); dataset2.setValue("Arizona", new Double(8.0)); dataset2.setValue("New Mexico", new Double(8.0)); dataset2.setValue("Texas", new Double(40.0)); dataset2.setValue("Louisiana", new Double(8.0)); dataset2.setValue("Mississippi", new Double(4.0)); dataset2.setValue("Alabama", new Double(2.0)); dataset2.setValue("Florida", new Double(20.0)); chart4 = ChartFactory.createPieChart3D("Driving Time Spent Per State (3D with Transparency)", // The chart title dataset2, // The dataset for the chart true, // Is a legend required? true, // Use tooltips false // Configure chart to generate URLs? ); PiePlot3D plot4 = (PiePlot3D) chart4.getPlot(); plot4.setForegroundAlpha(0.6f); try { ChartUtilities.saveChartAsPNG(new java.io.File("test.png"), chart, 500, 300); ChartUtilities.saveChartAsPNG(new java.io.File("test2.png"), chart4, 500, 300); } catch (java.io.IOException exc) { System.err.println("Error writing image to file"); } }