List of usage examples for java.lang Double toString
public static String toString(double d)
From source file:playground.dgrether.analysis.charts.DgModalSplitGroupChart.java
private void calculateData() { // calculate thresholds for income classes DgIncomeClass[] incomeThresholds = new DgIncomeClass[this.numberOfClasses]; DgAnalysisPopulation[] groups = new DgAnalysisPopulation[this.numberOfClasses]; double deltaY = this.ana.getMaxIncome() / (this.numberOfClasses - 1); for (int i = 0; i < incomeThresholds.length; i++) { incomeThresholds[i] = new DgIncomeClass((i * deltaY), ((i + 1) * deltaY)); groups[i] = new DgAnalysisPopulation(); }/*w w w . j a v a 2s . c o m*/ for (DgPersonData d : ana.getPersonData().values()) { double y = d.getIncome().getIncome(); int pos = (int) (y / deltaY); DgIncomeClass c = incomeThresholds[pos]; if (!(c.getMin() <= y) && (y <= c.getMax())) { throw new IllegalStateException(); } groups[pos].getPersonData().put(d.getPersonId(), d); } String[] groupDescriptions = new String[groups.length]; double[] xvalues = new double[groups.length]; double[] carvalues = new double[groups.length]; double[] ptvalues = new double[groups.length]; double groupSize = 0.0; double carPlans = 0.0; for (int i = 0; i < groups.length; i++) { // groupDescriptions[i] = incomeThresholds[i].getTitle(); String title = Double.toString(incomeThresholds[i].getMax()); title = title.substring(0, (title.indexOf(".") /*+ 3*/)); groupDescriptions[i] = title; xvalues[i] = i; groupSize = groups[i].getPersonData().size(); if (groupSize < this.groupThreshold) { continue; } carPlans = groups[i].calculateNumberOfCarPlans(runId); carvalues[i] = carPlans / groupSize * 100.0; ptvalues[i] = (groupSize - carPlans) / groupSize * 100.0; this.dataset.addValue(carvalues[i], "car", groupDescriptions[i]); this.dataset.addValue(ptvalues[i], "non-car", groupDescriptions[i]); } }
From source file:eu.optimis.ecoefficiencytool.core.tools.EnergyCreditsManager.java
/** * * @param emmittedCO2kg Kg of emmitted CO2. *///from w w w . ja v a2s .c o m private static void setRemainingEmissionsInEUETSs(double emmittedCO2kg) throws ConfigurationException { updateCurrentEmissionsExcess(); PropertiesConfiguration configEnergyCredits = ConfigManager .getPropertiesConfiguration(ConfigManager.ENERGYCREDITS_CONFIG_FILE); Iterator euas = configEnergyCredits.getKeys("EUA"); while (euas.hasNext()) { String key = (String) euas.next(); double remainingCredit = configEnergyCredits.getDouble(key); if (emmittedCO2kg < remainingCredit) { remainingCredit = remainingCredit - emmittedCO2kg; configEnergyCredits.setProperty(key, Double.toString(remainingCredit)); configEnergyCredits.save(); return; } else { emmittedCO2kg = emmittedCO2kg - remainingCredit; configEnergyCredits.setProperty(key, Double.toString(0.0)); } } if (emmittedCO2kg > 0.0) { double currentExcess = configEnergyCredits.getDouble("exceededEmissions"); currentExcess += emmittedCO2kg; configEnergyCredits.setProperty("exceededEmissions", Double.toString(currentExcess)); log.warn("Exceeding allowed CO2 emissions by " + currentExcess + "kg."); } configEnergyCredits.save(); }
From source file:com.duroty.lucene.parser.MSExcelParser.java
/** * DOCUMENT ME!/* w w w. ja v a2 s .com*/ * * @return DOCUMENT ME! * * @throws ParserException DOCUMENT ME! */ private String getContents() throws ParserException { String contents = ""; try { POIFSFileSystem fs = new POIFSFileSystem(input); HSSFWorkbook workbook = new HSSFWorkbook(fs); StringBuffer buffer = new StringBuffer(); for (int i = 0; i < workbook.getNumberOfSheets(); i++) { HSSFSheet sheet = workbook.getSheetAt(i); Iterator rows = sheet.rowIterator(); while (rows.hasNext()) { HSSFRow row = (HSSFRow) rows.next(); Iterator cells = row.cellIterator(); while (cells.hasNext()) { HSSFCell cell = (HSSFCell) cells.next(); switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_NUMERIC: String num = Double.toString(cell.getNumericCellValue()).trim(); if (num.length() > 0) { buffer.append(num + " "); } break; case HSSFCell.CELL_TYPE_STRING: String text = cell.getStringCellValue().trim(); if (text.length() > 0) { buffer.append(text + " "); } break; } } buffer.append("\n"); /*if (sleep > 0) { try { Thread.sleep(sleep); } catch (Exception ex) { } }*/ } } contents = buffer.toString(); } catch (Exception ex) { throw new ParserException(ex); } return contents; }
From source file:com.wormsim.tracking.TrackedDouble.java
@Override public String toVarianceString() { return Double.toString(this.getVariance()); }
From source file:Main.java
/** * Takes an array of doubles and returns all elements assembled in * a {@link String} joined by the defined separator. * <br>//from w w w . j av a 2 s .com * Example: Create a {@link String} using an {@link double[]} * separated by ", ": * <br> * <code> * double[] array = {1.0, 2.0, 3.0}; * <br> * String output = CollectionUtils.join(array, ", "); * <br> * </code> * * @param collection a {@link double[]} of objects to join. * @param separator the {@link String} separator used to join the collection. * @return {@link String} joined string. */ public static String join(double[] collection, String separator) { String output = ""; for (int i = 0; i < collection.length - 1; i++) { String o = Double.toString(collection[i]); output += o + separator; } if (collection.length > 0) output += Double.toString(collection[collection.length - 1]); return output; }
From source file:de.micromata.genome.gwiki.page.gspt.BodyContentImpl.java
@Override public void print(double arg0) throws IOException { write(Double.toString(arg0)); }
From source file:com.projity.algorithm.ValueDifference.java
public String toString() { return Double.toString(value); }
From source file:com.wormsim.tracking.TrackedDouble.java
@Override public String toWithinVarianceString() { return Double.toString(this.getWithinVariance()); }
From source file:com.itude.mobile.mobbl.core.model.parser.MBJsonDocumentParser.java
public void parseJsonValue(Object jsonValue, MBDefinition definition, MBElementContainer element) { if (jsonValue instanceof JSONObject) { JSONObject jsonObject = (JSONObject) jsonValue; List<MBElementDefinition> elements = definition.getChildElements(); for (MBElementDefinition childDefinition : elements) { try { if (!jsonObject.has(childDefinition.getName())) { element.addElement(childDefinition.createElement()); } else { Object jsonChild = jsonObject.get(childDefinition.getName()); if (!(jsonChild instanceof JSONObject) && !(jsonChild instanceof JSONArray)) { MBElement childElement = childDefinition.createElement(); if (jsonChild instanceof String) { childElement.setBodyText((String) jsonChild); }//w w w . ja va 2 s. c o m if (jsonChild instanceof Integer) { childElement.setBodyText(Integer.toString((Integer) jsonChild)); } if (jsonChild instanceof Double) { childElement.setBodyText(Double.toString((Double) jsonChild)); } if (jsonChild instanceof Long) { childElement.setBodyText(Long.toString((Long) jsonChild)); } element.addElement(childElement); } if (jsonChild instanceof JSONObject) { MBElement childElement = childDefinition.createElement(); element.addElement(childElement); parseJsonValue((jsonChild), childDefinition, childElement); } if (jsonChild instanceof JSONArray) { for (int i = 0; i < ((JSONArray) jsonChild).length(); i++) { MBElement childElement = childDefinition.createElement(); element.addElement(childElement); parseJsonValue(((JSONArray) jsonChild).get(i), childDefinition, childElement); } } } } catch (Exception e) { String message = "Error parsing value : " + childDefinition.getName() + " of document " + definition.getName() + " : " + e.getMessage(); throw new MBParseErrorException(message, e); } } } // get attributes if (definition instanceof MBElementDefinition && element instanceof MBElement) { try { for (MBAttributeDefinition attributeDefinition : ((MBElementDefinition) definition) .getAttributes()) { JSONObject jsonObject = (JSONObject) jsonValue; Object attributeValue = JSONObject.NULL; if (jsonObject.has(attributeDefinition.getName())) attributeValue = jsonObject.get(attributeDefinition.getName()); if (attributeValue == JSONObject.NULL) attributeValue = attributeDefinition.getDefaultValue(); else attributeValue = attributeValue.toString(); ((MBElement) element).setAttributeValue((String) attributeValue, attributeDefinition.getName()); } } catch (Exception e) { String message = "Error parsing document " + definition.getName() + " : " + e.getMessage(); throw new MBParseErrorException(message, e); } } }
From source file:com.igormaznitsa.ideamindmap.facet.InMemoryPreferenceNode.java
@Override public void putDouble(String key, double value) { this.put(key, Double.toString(value)); }