List of usage examples for java.text DecimalFormatSymbols setDecimalSeparator
public void setDecimalSeparator(char decimalSeparator)
From source file:org.dashbuilder.dataprovider.backend.csv.CSVParser.java
protected DecimalFormat getNumberFormat(String columnId) { DecimalFormat format = _numberFormatMap.get(columnId); if (format == null) { DecimalFormatSymbols numberSymbols = new DecimalFormatSymbols(); numberSymbols.setGroupingSeparator(dataSetDef.getNumberGroupSeparator(columnId)); numberSymbols.setDecimalSeparator(dataSetDef.getNumberDecimalSeparator(columnId)); format = new DecimalFormat(dataSetDef.getPattern(columnId), numberSymbols); _numberFormatMap.put(columnId, format); }//w w w . j ava2s. co m return format; }
From source file:org.dashbuilder.dataprovider.csv.CSVParser.java
protected DecimalFormat getNumberFormat(String columnId) { DecimalFormat format = _numberFormatMap.get(columnId); if (format == null) { DecimalFormatSymbols numberSymbols = new DecimalFormatSymbols(); numberSymbols.setGroupingSeparator(dataSetDef.getNumberGroupSeparator(columnId)); numberSymbols.setDecimalSeparator(dataSetDef.getNumberDecimalSeparator(columnId)); format = new DecimalFormat(dataSetDef.getNumberPattern(columnId), numberSymbols); _numberFormatMap.put(columnId, format); }/*ww w . j av a 2 s . c o m*/ return format; }
From source file:org.asqatasun.rules.elementchecker.contrast.ContrastChecker.java
/** * // w w w .ja va2s . co m * @param sspHandler * @param domElements * @param testSolutionHandler * * @throws ContrastCheckerParseResultException */ private void checkDomElements(SSPHandler sspHandler, Collection<DomElement> domElements, TestSolutionHandler testSolutionHandler) throws ContrastCheckerParseResultException { for (DomElement domElement : domElements) { // if the luminosity couldn't have been computed, its value is set // to "-1" if (isElementPartOfTheScope(domElement)) { String bgColor = domElement.getBgColor(); String fgColor = domElement.getFgColor(); if (ContrastHelper.isColorTestable(fgColor) && ContrastHelper.isColorTestable(bgColor)) { elementCounter++; Double contrast = ContrastHelper.getConstrastRatio(fgColor, bgColor); if (contrast < contrastRatio) { LOGGER.debug(" cssPath " + domElement.getPath() + " " + +contrast); DecimalFormatSymbols decimalSymbol = new DecimalFormatSymbols(Locale.getDefault()); decimalSymbol.setDecimalSeparator('.'); TestSolution elementSolution = createRemarkOnBadContrastElement(sspHandler, domElement, new DecimalFormat("#.00", decimalSymbol).format(contrast)); testSolutionHandler.addTestSolution(elementSolution); } else { LOGGER.debug(" good luminosity " + domElement.getPath() + " " + +contrast); } } else { elementCounter++; createNmiRemarkForManualCheckElement(sspHandler, domElement); testSolutionHandler.addTestSolution(TestSolution.NEED_MORE_INFO); LOGGER.debug(" nmi " + domElement.getPath()); } } } }
From source file:fr.amap.lidar.PtgScanConversion.java
public void toTxt(SimpleScan scan, File outputDirectory, boolean exportRGB, boolean exportIntensity) throws IOException, Exception { /***Convert rxp to txt***/ File outputTxtFile = new File( outputDirectory.getAbsolutePath() + File.separator + scan.file.getName() + ".txt"); try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputTxtFile))) { /**Transformation**/ Mat4D popMatrix = scan.popMatrix; Mat4D sopMatrix = scan.sopMatrix; Mat4D transfMatrix = Mat4D.multiply(sopMatrix, popMatrix); Mat3D rotation = new Mat3D(); rotation.mat = new double[] { transfMatrix.mat[0], transfMatrix.mat[1], transfMatrix.mat[2], transfMatrix.mat[4], transfMatrix.mat[5], transfMatrix.mat[6], transfMatrix.mat[8], transfMatrix.mat[9], transfMatrix.mat[10] }; DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.getDefault()); otherSymbols.setDecimalSeparator('.'); otherSymbols.setGroupingSeparator('.'); DecimalFormat strictFormat = new DecimalFormat("###.##", otherSymbols); String header = "directionX directionY directionZ x y z empty"; if (exportIntensity) { header += " intensity"; }/*from w ww.ja va 2 s . c om*/ if (exportRGB) { header += " red green blue"; } header += "\n"; writer.write(header); PTGScan ptgScan = new PTGScan(); ptgScan.openScanFile(scan.file); LPointShotExtractor shots = new LPointShotExtractor(ptgScan); Iterator<LShot> iterator = shots.iterator(); int shotID = 0; while (iterator.hasNext()) { LShot shot = iterator.next(); shot.direction.normalize(); Vec4D origin = Mat4D.multiply(transfMatrix, new Vec4D(shot.origin.x, shot.origin.y, shot.origin.z, 1.0d)); Vec3D direction = Mat3D.multiply(rotation, new Vec3D(shot.direction.x, shot.direction.y, shot.direction.z)); direction = Vec3D.normalize(direction); SphericalCoordinates sc = new SphericalCoordinates(); sc.toSpherical(new Vector3d(direction.x, direction.y, direction.z)); short empty = 1; if (shot.ranges.length > 0) { empty = 0; } double x = origin.x + direction.x * 100; double y = origin.y + direction.y * 100; double z = origin.z + direction.z * 100; writer.write(direction.x + " " + direction.y + " " + direction.z + " " + x + " " + y + " " + z + " " + empty + "\n"); // for(int i=0;i<shot.ranges.length;i++){ // // double x = origin.x + direction.x * shot.ranges[i]; // double y = origin.y + direction.y * shot.ranges[i]; // double z = origin.z + direction.z * shot.ranges[i]; // // String echo = shotID + " " + x + " " + y + " " + z + " " + direction.x + " " + direction.y+ " " + direction.z + " " + shot.ranges[i]+" "+shot.ranges.length+" "+i; // // if(exportIntensity){ // echo += " " + strictFormat.format(shot.point.intensity); // } // // if(exportRGB){ // echo += " " + strictFormat.format(shot.point.red); // echo += " " + strictFormat.format(shot.point.green); // echo += " " + strictFormat.format(shot.point.blue); // } // // echo += "\n"; // // writer.write(echo); // } shotID++; } } catch (Exception ex) { System.err.println(ex); } }
From source file:org.openehr.rm.datatypes.quantity.DvQuantity.java
/** * string form displayable for humans// w ww . ja v a 2 s . c om * * @return string presentation */ public String toString() { DecimalFormat format = new DecimalFormat(); format.setMinimumFractionDigits(precision); format.setMaximumFractionDigits(precision); DecimalFormatSymbols dfs = format.getDecimalFormatSymbols(); dfs.setDecimalSeparator(DECIMAL_SEPARATOR); format.setDecimalFormatSymbols(dfs); format.setGroupingUsed(false); String tmp = format.format(magnitude) + (StringUtils.isEmpty(getUnits()) ? "" : "," + getUnits()); return tmp; }
From source file:ub.botiga.ServletDispatcher.java
private void showCistell(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); User u = (User) session.getAttribute("user"); if (u == null) { response.sendRedirect("/Botiga/"); return;/* w w w . j a v a 2s . c om*/ } HashMap<String, Product> cistell = getCistell(request); HashMap<String, Product> historial = u.getProducts(); for (Product p : historial.values()) { cistell.remove(p.getName()); } session.setAttribute("cistell", cistell); if (u.getCredits() - getPreuCistell(request) < 0) { request.setAttribute("creditsuficient", false); } else { request.setAttribute("creditsuficient", true); } request.setAttribute("cistell", cistell.values()); DecimalFormat df = new DecimalFormat(); df.setMaximumFractionDigits(2); DecimalFormatSymbols dfs = new DecimalFormatSymbols(); dfs.setDecimalSeparator('.'); df.setDecimalFormatSymbols(dfs); request.setAttribute("preucistell", df.format(getPreuCistell(request))); showPage(request, response, "cistell.jsp"); }
From source file:ch.entwine.weblounge.common.impl.content.image.ImageContentImpl.java
/** * {@inheritDoc}/*ww w .j a va 2 s .com*/ * * @see ch.entwine.weblounge.common.impl.content.ResourceContentImpl#extendXml(java.lang.StringBuffer) */ @Override protected StringBuffer extendXml(StringBuffer xml) { xml = super.extendXml(xml); if (width <= 0) throw new IllegalArgumentException("Image must be wider than 0 pixels"); if (height <= 0) throw new IllegalArgumentException("Image must be taller than 0 pixels"); DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols(); formatSymbols.setDecimalSeparator('.'); NumberFormat nf = new DecimalFormat("0.000000", formatSymbols); xml.append("<width>").append(width).append("</width>"); xml.append("<height>").append(height).append("</height>"); if (dateTaken != null) { xml.append("<datetaken>").append(WebloungeDateFormat.formatStatic(dateTaken)).append("</datetaken>"); } if (!StringUtils.isBlank(location)) { xml.append("<location><![CDATA[").append(location).append("]]></location>"); } if (gpsLat != -1 && gpsLong != -1) { xml.append("<gps lat=\"").append(nf.format(gpsLat)).append("\" lng=\"").append(nf.format(gpsLong)) .append("\" />"); } if (filmspeed != -1) { xml.append("<filmspeed>").append(filmspeed).append("</filmspeed>"); } if (fnumber != -1) { xml.append("<fnumber>").append(fnumber).append("</fnumber>"); } if (focalWidth != -1) { xml.append("<focalwidth>").append(focalWidth).append("</focalwidth>"); } if (exposureTime != -1) { xml.append("<exposuretime>").append(exposureTime).append("</exposuretime>"); } return xml; }
From source file:com.physphil.android.unitconverterultimate.fragments.ConversionFragment.java
/** * Get DecimalFormat used to format result * * @return DecimalFormat/*w w w . ja v a2s. c o m*/ */ private DecimalFormat getDecimalFormat() { DecimalFormat formatter = new DecimalFormat(); //Set maximum number of decimal places formatter.setMaximumFractionDigits(mPrefs.getNumberDecimals()); //Set group and decimal separators DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols(); symbols.setDecimalSeparator(mPrefs.getDecimalSeparator().charAt(0)); String groupSeparator = mPrefs.getGroupSeparator(); boolean isSeparatorUsed = !groupSeparator.equals(getString(R.string.group_separator_none)); formatter.setGroupingUsed(isSeparatorUsed); if (isSeparatorUsed) { symbols.setGroupingSeparator(groupSeparator.charAt(0)); } formatter.setDecimalFormatSymbols(symbols); return formatter; }
From source file:org.totschnig.myexpenses.util.Utils.java
/** * @param currency//from ww w.j a v a 2 s. c om * @param separator * @return a Decimalformat with the number of fraction digits appropriate for * currency, and with the given separator, but without the currency * symbol appropriate for CSV and QIF export */ public static DecimalFormat getDecimalFormat(Currency currency, char separator) { DecimalFormat nf = new DecimalFormat(); DecimalFormatSymbols symbols = new DecimalFormatSymbols(); symbols.setDecimalSeparator(separator); nf.setDecimalFormatSymbols(symbols); int fractionDigits = currency.getDefaultFractionDigits(); if (fractionDigits != -1) { nf.setMinimumFractionDigits(fractionDigits); nf.setMaximumFractionDigits(fractionDigits); } else { nf.setMaximumFractionDigits(Money.DEFAULTFRACTIONDIGITS); } nf.setGroupingUsed(false); return nf; }
From source file:org.talend.dataprep.transformation.actions.math.ChangeNumberFormat.java
/** * Return the custom format out of the parameters. * * @param parameters the action parameters. * @return the custom format out of the parameters. *//*from ww w . j av a 2 s . c om*/ private NumberFormat getCustomFormat(Map<String, String> parameters) { final DecimalFormat decimalFormat = new DecimalFormat(parameters.get(TARGET_PATTERN + "_" + CUSTOM)); DecimalFormatSymbols decimalFormatSymbols = decimalFormat.getDecimalFormatSymbols(); String decimalSeparator = getCustomizableParam(TARGET + DECIMAL + SEPARATOR, parameters); if (!StringUtils.isEmpty(decimalSeparator)) { decimalFormatSymbols.setDecimalSeparator(decimalSeparator.charAt(0)); } String groupingSeparator = getCustomizableParam(TARGET + GROUPING + SEPARATOR, parameters); if (StringUtils.isEmpty(groupingSeparator) || groupingSeparator.equals(decimalSeparator)) { decimalFormat.setGroupingUsed(false); } else { decimalFormatSymbols.setGroupingSeparator(groupingSeparator.charAt(0)); } decimalFormat.setDecimalFormatSymbols(decimalFormatSymbols); return decimalFormat; }