List of usage examples for java.text DecimalFormatSymbols DecimalFormatSymbols
public DecimalFormatSymbols(Locale locale)
From source file:com.nextgis.firereporter.ScanexNotificationItem.java
/** * Simple coordinate decimal formatter// w ww . j av a 2 s . co m * * @param coord * @return */ public static String formatCoord(double coord) { DecimalFormat df = new DecimalFormat("###.######"); df.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); return df.format(coord); }
From source file:com.qa.perf.emmageeplus.service.EmmageeService.java
@Override public void onCreate() { Log.i(LOG_TAG, "service onCreate"); super.onCreate(); instance = this; isServiceStop = false;/*ww w . ja v a 2 s . c o m*/ isStop = false; memoryInfo = new MemoryInfo(); contextHelper = new ContextHelper(); fomart = new DecimalFormat(); fomart.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); fomart.setGroupingUsed(false); fomart.setMaximumFractionDigits(2); fomart.setMinimumFractionDigits(0); des = new EncryptData(); batteryInfo = new BatteryInfo(); statusBarHeight = getStatusBarHeight(); batteryBroadcast = new BatteryInfoBroadcastReceiver(); registerReceiver(batteryBroadcast, new IntentFilter(BATTERY_CHANGED)); }
From source file:org.apache.cocoon.template.instruction.FormatNumber.java
private String format(ExpressionContext expressionContext) throws Exception { // Determine formatting locale String var = this.var == null ? null : this.var.getStringValue(expressionContext); Number input = this.value.getNumberValue(expressionContext); String type = this.type == null ? null : this.type.getStringValue(expressionContext); String pattern = this.pattern == null ? null : this.pattern.getStringValue(expressionContext); String currencyCode = this.currencyCode == null ? null : this.currencyCode.getStringValue(expressionContext); String currencySymbol = this.currencySymbol == null ? null : this.currencySymbol.getStringValue(expressionContext); Boolean isGroupingUsed = this.isGroupingUsed == null ? null : this.isGroupingUsed.getBooleanValue(expressionContext); Number maxIntegerDigits = this.maxIntegerDigits == null ? null : this.maxIntegerDigits.getNumberValue(expressionContext); Number minIntegerDigits = this.minIntegerDigits == null ? null : this.minIntegerDigits.getNumberValue(expressionContext); Number maxFractionDigits = this.maxFractionDigits == null ? null : this.maxFractionDigits.getNumberValue(expressionContext); Number minFractionDigits = this.minFractionDigits == null ? null : this.minFractionDigits.getNumberValue(expressionContext); Locale loc = getLocale(expressionContext); String formatted;/*from ww w. j a v a 2s.co m*/ if (loc != null) { // Create formatter NumberFormat formatter = null; if (StringUtils.isNotEmpty(pattern)) { // if 'pattern' is specified, 'type' is ignored DecimalFormatSymbols symbols = new DecimalFormatSymbols(loc); formatter = new DecimalFormat(pattern, symbols); } else { formatter = createFormatter(loc, type); } if (StringUtils.isNotEmpty(pattern) || CURRENCY.equalsIgnoreCase(type)) { setCurrency(formatter, currencyCode, currencySymbol); } configureFormatter(formatter, isGroupingUsed, maxIntegerDigits, minIntegerDigits, maxFractionDigits, minFractionDigits); formatted = formatter.format(input); } else { // no formatting locale available, use toString() formatted = input.toString(); } if (var != null) { expressionContext.put(var, formatted); return null; } return formatted; }
From source file:org.clueminer.chameleon.GraphPropertyStore.java
public void printFancy(int w, int d) { DecimalFormat format = new DecimalFormat(); format.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); format.setMinimumIntegerDigits(1);//from w ww . j av a 2 s.c o m format.setMaximumFractionDigits(d); format.setMinimumFractionDigits(d); format.setGroupingUsed(false); printFancy(new PrintWriter(System.out, true), format, w + 2); }
From source file:org.exoplatform.forum.ForumUtils.java
public static String getSizeFile(long size) { String sizeStr = String.valueOf(size); String unit = " Byte"; if (size >= 1024) { DecimalFormat df = new DecimalFormat("#,###.#", new DecimalFormatSymbols(Locale.ENGLISH)); double convertedSize = (double) size / 1024; unit = " Kb"; if (convertedSize >= 1024) { convertedSize = convertedSize / 1024; unit = " Mb"; }/*from w ww . ja v a2s. c om*/ sizeStr = df.format(convertedSize); } return (sizeStr + unit); }
From source file:org.opencastproject.videoeditor.ffmpeg.FFmpegEdit.java
public List<String> makeEdits(List<String> inputfiles, String dest, String outputResolution, List<VideoClip> clips, boolean hasAudio, boolean hasVideo) throws Exception { if (!hasAudio && !hasVideo) { throw new IllegalArgumentException("Inputfiles should have at least audio or video stream."); }/*from ww w .j a v a2 s.c om*/ DecimalFormat f = new DecimalFormat("0.00", new DecimalFormatSymbols(Locale.US)); int n = clips.size(); int i; String outmap = ""; String scale = ""; List<String> command = new ArrayList<String>(); List<String> vpads = new ArrayList<String>(); List<String> apads = new ArrayList<String>(); List<String> clauses = new ArrayList<String>(); // The clauses are ordered if (n > 1) { // Create the input pads if we have multiple segments for (i = 0; i < n; i++) { if (hasVideo) { vpads.add("[v" + i + "]"); // post filter } if (hasAudio) { apads.add("[a" + i + "]"); } } } if (hasVideo && outputResolution != null && outputResolution.length() > 3) // format is "<width>x<height>" scale = ",scale=" + outputResolution; // scale each clip to the same size for (i = 0; i < n; i++) { // Examine each clip // get clip and add fades to each clip VideoClip vclip = clips.get(i); int fileindx = vclip.getSrc(); // get source file by index double inpt = vclip.getStart(); // get in points double duration = vclip.getDuration(); String clip = ""; if (hasVideo) { String vfadeFilter = ""; /* Only include fade into the filter graph if necessary */ if (vfade > 0.00001) { double vend = duration - vfade; vfadeFilter = ",fade=t=in:st=0:d=" + vfade + ",fade=t=out:st=" + f.format(vend) + ":d=" + vfade; } /* Add filters for video */ clip = "[" + fileindx + ":v]trim=" + f.format(inpt) + ":duration=" + f.format(duration) + scale + ",setpts=PTS-STARTPTS" + vfadeFilter + "[v" + i + "]"; clauses.add(clip); } if (hasAudio) { String afadeFilter = ""; /* Only include fade into the filter graph if necessary */ if (afade > 0.00001) { double aend = duration - afade; afadeFilter = ",afade=t=in:st=0:d=" + afade + ",afade=t=out:st=" + f.format(aend) + ":d=" + afade; } /* Add filters for audio */ clip = "[" + fileindx + ":a]atrim=" + f.format(inpt) + ":duration=" + f.format(duration) + ",asetpts=PTS-STARTPTS" + afadeFilter + "[a" + i + "]"; clauses.add(clip); } } if (n > 1) { // concat the outpads when there are more then 1 per stream // use unsafe because different files may have different SAR/framerate if (hasVideo) { clauses.add(StringUtils.join(vpads, "") + "concat=n=" + n + ":unsafe=1[ov0]"); // concat video clips } if (hasAudio) { clauses.add(StringUtils.join(apads, "") + "concat=n=" + n + ":v=0:a=1[oa0]"); // concat audio clips in stream 0, video in stream 1 } outmap = "o"; // if more than one clip } command.add("-y"); // overwrite old pathname for (String o : inputfiles) { command.add("-i"); // Add inputfile in the order of entry command.add(o); } command.add("-filter_complex"); command.add(StringUtils.join(clauses, ";")); String[] options = ffmpegProperties.split(" "); command.addAll(Arrays.asList(options)); if (hasAudio) { command.add("-map"); command.add("[" + outmap + "a0]"); } if (hasVideo) { command.add("-map"); command.add("[" + outmap + "v0]"); } if (hasVideo && videoCodec != null) { // If using different codecs from source, add them here command.add("-c:v"); command.add(videoCodec); } if (hasAudio && audioCodec != null) { command.add("-c:a"); command.add(audioCodec); } command.add(dest); return command; }
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 . j a va 2s .com*/ 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:com.joliciel.jochre.search.highlight.Snippet.java
public String toJson() { try {//from w w w . j a v a 2 s.com DecimalFormatSymbols enSymbols = new DecimalFormatSymbols(Locale.US); DecimalFormat df = new DecimalFormat("0.00", enSymbols); StringWriter writer = new StringWriter(); JsonFactory jsonFactory = new JsonFactory(); JsonGenerator jsonGen = jsonFactory.createGenerator(writer); this.toJson(jsonGen, df); writer.flush(); String json = writer.toString(); return json; } catch (IOException ioe) { LogUtils.logError(LOG, ioe); throw new RuntimeException(ioe); } }
From source file:com.magestore.app.pos.service.config.POSConfigService.java
private DecimalFormat currencyNosymbolFormat(ConfigPriceFormat priceFormat) { // khi to currency format String pattern = "###,###.#"; DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.getDefault()); symbols.setDecimalSeparator(priceFormat.getDecimalSymbol().charAt(0)); symbols.setGroupingSeparator(priceFormat.getGroupSymbol().charAt(0)); DecimalFormat currencyFormat = new DecimalFormat(pattern, symbols); currencyFormat.setGroupingSize(priceFormat.getGroupLength()); currencyFormat.setMaximumFractionDigits(priceFormat.getPrecision()); currencyFormat.setMinimumFractionDigits(priceFormat.getRequirePrecision()); return currencyFormat; }
From source file:org.asqatasun.rules.elementchecker.contrast.ContrastChecker.java
/** * //w ww .j a v a 2 s.c o 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()); } } } }