List of usage examples for java.text NumberFormat setGroupingUsed
public void setGroupingUsed(boolean newValue)
From source file:correlation.and.regression.analysis.MainWindow.java
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed NumberFormat f = NumberFormat.getInstance(); f.setGroupingUsed(false); try {/*from ww w . jav a 2s.c o m*/ if (arr[0] == null) { jFileChooser1.showDialog(null, "Open file"); arr[0] = new OrderedSeries(); arr[0].loadFromFile(jFileChooser1.getSelectedFile().getPath()); } else { if (arr[1] == null) { jFileChooser1.showDialog(null, "Open file"); arr[1] = new OrderedSeries(); arr[1].loadFromFile(jFileChooser1.getSelectedFile().getPath()); showCorrelationField(); jTblStatistic.setModel(arr[0].showStatisticsForLab4(modelStatistic, 1 - 0.05 / 2)); jTblStatistic.setModel(arr[1].showStatisticsForLab4(modelStatistic, 1 - 0.05 / 2)); /*Show coef correlation*/ modelCoefCorr.setValueAt(f.format(StaticFunctions.pairCorrelationCoef(arr[0], arr[1])), 0, 1); modelCoefCorr.setValueAt(f.format(StaticFunctions.significancePairCor(arr[0], arr[1])), 0, 2); modelCoefCorr.setValueAt(f.format(Quantiles.Student(1 - 0.05 / 2, arr[0].size() - 2)), 0, 3); if (Math.abs(StaticFunctions.significancePairCor(arr[0], arr[1])) <= Quantiles .Student(1 - 0.05 / 2, arr[0].size() - 2)) { modelCoefCorr.setValueAt("? ", 0, 4); } else { modelCoefCorr.setValueAt("", 0, 4); } modelCoefCorr.setValueAt(StaticFunctions.getIntervalForPairCorr( StaticFunctions.pairCorrelationCoef(arr[0], arr[1]), arr[0].size()), 0, 5); modelCoefCorr.setValueAt(f.format(StaticFunctions.markCorrelationRatio(arr[0], arr[1])), 1, 1); modelCoefCorr.setValueAt(f.format(StaticFunctions.statisticsCorrelationRatio( StaticFunctions.markCorrelationRatio(arr[0], arr[1]), arr[0])), 1, 2); modelCoefCorr .setValueAt(f.format(Quantiles.Fisher(1 - 0.05, StaticFunctions.getK(arr[0].size()) - 1, arr[0].size() - StaticFunctions.getK(arr[0].size()))), 1, 3); if (StaticFunctions.statisticsCorrelationRatio( StaticFunctions.markCorrelationRatio(arr[0], arr[1]), arr[0]) <= Quantiles.Fisher(1 - 0.05, StaticFunctions.getK(arr[0].size()) - 1, arr[0].size() - StaticFunctions.getK(arr[0].size()))) { modelCoefCorr.setValueAt("? ", 1, 4); } else { modelCoefCorr.setValueAt("", 1, 4); } modelCoefCorr.setValueAt( f.format(StaticFunctions.spirmenCoef(arr[0].toArrayDouble(0), arr[1].toArrayDouble(0))), 2, 1); modelCoefCorr.setValueAt(f.format( StaticFunctions.statisticsSpirmen(arr[0].toArrayDouble(0), arr[1].toArrayDouble(0))), 2, 2); modelCoefCorr.setValueAt(f.format(StaticFunctions.tDistrib(arr[0].size() - 2)), 2, 3); if (Math.abs(StaticFunctions.statisticsSpirmen(arr[0].toArrayDouble(0), arr[1].toArrayDouble(0))) <= StaticFunctions.tDistrib(arr[0].size() - 2)) { modelCoefCorr.setValueAt("? ", 2, 4); } else { modelCoefCorr.setValueAt("", 2, 4); } modelCoefCorr.setValueAt( f.format( StaticFunctions.kendallsCoef(arr[0].toArrayDouble(0), arr[1].toArrayDouble(0))), 3, 1); modelCoefCorr.setValueAt(f.format( StaticFunctions.staticticsKendall(arr[0].toArrayDouble(0), arr[1].toArrayDouble(0))), 3, 2); modelCoefCorr.setValueAt(f.format(Quantiles.Norm(1 - 0.05 / 2)), 3, 3); if (Math.abs(StaticFunctions.staticticsKendall(arr[0].toArrayDouble(0), arr[1].toArrayDouble(0))) <= Quantiles.Norm(1 - 0.05 / 2)) { modelCoefCorr.setValueAt("? ", 3, 4); } else { modelCoefCorr.setValueAt("", 3, 4); } /*Show estemate parametrs*/ modelEstem.setValueAt(StaticFunctions.estimateA(arr[0], arr[1]), 0, 1); modelEstem.setValueAt(f.format(StaticFunctions.dispersiaA(arr[0], arr[1])), 0, 2); modelEstem.setValueAt(f.format(StaticFunctions.statisticA(arr[0], arr[1])), 0, 3); modelEstem.setValueAt(f.format(Quantiles.Student(1 - 0.05 / 2, arr[0].size() - 2)), 0, 4); modelEstem.setValueAt(StaticFunctions.significanceA(arr[0], arr[1]), 0, 5); modelEstem.setValueAt(StaticFunctions.getIntervalForEstemateA(arr[0], arr[1]), 0, 6); modelEstem.setValueAt(StaticFunctions.estimateB(arr[0], arr[1]), 1, 1); modelEstem.setValueAt(f.format(StaticFunctions.dispersiaB(arr[0], arr[1])), 1, 2); modelEstem.setValueAt(f.format(StaticFunctions.statisticB(arr[0], arr[1])), 1, 3); modelEstem.setValueAt(f.format(Quantiles.Student(1 - 0.05 / 2, arr[0].size() - 2)), 1, 4); modelEstem.setValueAt(StaticFunctions.significanceB(arr[0], arr[1]), 1, 5); modelEstem.setValueAt(StaticFunctions.getIntervalForEstemateB(arr[0], arr[1]), 1, 6); double[] tmp = new double[arr[0].size()]; double a = StaticFunctions.estimateA(arr[0], arr[1]); double b = StaticFunctions.estimateB(arr[0], arr[1]); for (int i = 0; i < arr[0].size(); i++) { tmp[i] = StaticFunctions.regression(arr[0].getNumber(i), a, b); } OrderedSeries t = new OrderedSeries(); t.loadFromArray(tmp); jLabelDet.setText(f.format(Math.pow(StaticFunctions.pairCorrelationCoef(arr[0], t), 2) * 100)); jLabelFtest.setText("" + f.format(StaticFunctions.getFtest(arr[0], arr[1]))); if (StaticFunctions.getFtest(arr[0], arr[1]) > Math .pow(Quantiles.Student(1 - 0.05 / 2, arr[0].size() - 2), 2)) { jLabelRes.setText("??? "); } else { jLabelRes.setText("??? "); } } else { arr[0] = null; arr[1] = null; clearAll(); jMenuItem1ActionPerformed(evt); } } } catch (IOException ex) { JOptionPane.showMessageDialog(null, "File has wrong information"); } }
From source file:org.mycore.datamodel.ifs.MCRAudioVideoExtender.java
/** * Returns the streaming bitrate formatted as a String, e. g. "1.3 MBit" or * "300 kBit"./*from w w w. j a v a 2 s. c om*/ * * @return the streaming bitrate formatted as a String */ public String getBitRateFormatted() { NumberFormat bitRateFormatter = NumberFormat.getInstance(Locale.ROOT); bitRateFormatter.setMinimumIntegerDigits(1); bitRateFormatter.setGroupingUsed(false); if (bitRate > 100 * 1024) { bitRateFormatter.setMaximumFractionDigits(2); double b = bitRate / (1024f * 1024f); return bitRateFormatter.format(b) + " MBit"; } bitRateFormatter.setMaximumFractionDigits(1); double b = bitRate / 1024f; return bitRateFormatter.format(b) + " kBit"; }
From source file:com.mycompany.jpegrenamer.MetaDataReader.java
public Map<String, String> getExifMetadata(final File jpegImageFile) throws ImageReadException, IOException, ImageWriteException { Map<String, String> res = new HashMap<>(); Map<String, String> location = new HashMap(); ;//from ww w . ja v a2 s .c o m // note that metadata might be null if no metadata is found. final ImageMetadata metadata = Imaging.getMetadata(jpegImageFile); boolean isClassOk = metadata instanceof JpegImageMetadata; if (!isClassOk || (null == metadata)) { return res; } final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata; if (jpegMetadata == null) { logger.info("File does not contain metadata - " + jpegImageFile.getCanonicalPath()); return res; } String dateOfCaptureString = getTagValue(jpegMetadata, TiffTagConstants.TIFF_TAG_DATE_TIME); SimpleDateFormat sdf = new SimpleDateFormat("''yyyy:MM:dd hh:mm:ss''"); Date dateOfCapture = null; try { dateOfCapture = sdf.parse(dateOfCaptureString); final DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss", Locale.ENGLISH); res.put("date", df.format(dateOfCapture)); } catch (ParseException ex) { logger.error("", ex); } // s = getTagValue(jpegMetadata, TiffTagConstants.TIFF_TAG_DATE_TIME); printTagValue(jpegMetadata, TiffTagConstants.TIFF_TAG_DATE_TIME); printTagValue(jpegMetadata, ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL); printTagValue(jpegMetadata, ExifTagConstants.EXIF_TAG_DATE_TIME_DIGITIZED); printTagValue(jpegMetadata, GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF); printTagValue(jpegMetadata, GpsTagConstants.GPS_TAG_GPS_LATITUDE); printTagValue(jpegMetadata, GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF); printTagValue(jpegMetadata, GpsTagConstants.GPS_TAG_GPS_LONGITUDE); if (null != jpegMetadata) { // note that exif might be null if no Exif metadata is found. final TiffImageMetadata exif = jpegMetadata.getExif(); //logger.info(jpegMetadata.toString()); if (null != exif) { //logger.info(exif.toString()); final TiffImageMetadata.GPSInfo gpsInfo = exif.getGPS(); if (null != gpsInfo) { final String gpsDescription = gpsInfo.toString(); final double longitude = gpsInfo.getLongitudeAsDegreesEast(); final double latitude = gpsInfo.getLatitudeAsDegreesNorth(); logger.info(" " + "GPS Description: " + gpsDescription); logger.info(" " + "GPS Longitude (Degrees East): " + longitude); logger.info(" " + "GPS Latitude (Degrees North): " + latitude); try { Locale fmtLocale = Locale.US; NumberFormat formatter = NumberFormat.getNumberInstance(fmtLocale); formatter.setGroupingUsed(false); location = getAddressByGpsCoordinates(formatter.format(latitude), formatter.format(longitude)); if (location != null) { res.putAll(location); } } catch (MalformedURLException ex) { logger.error("", ex); } catch (org.json.simple.parser.ParseException ex) { logger.error("", ex); } logger.info(" " + location); } // more specific example of how to manually access GPS values final TiffField gpsLatitudeRefField = jpegMetadata .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF); final TiffField gpsLatitudeField = jpegMetadata .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE); final TiffField gpsLongitudeRefField = jpegMetadata .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF); final TiffField gpsLongitudeField = jpegMetadata .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE); if (gpsLatitudeRefField != null && gpsLatitudeField != null && gpsLongitudeRefField != null && gpsLongitudeField != null) { // all of these values are strings. final String gpsLatitudeRef = (String) gpsLatitudeRefField.getValue(); final RationalNumber[] gpsLatitude = (RationalNumber[]) (gpsLatitudeField.getValue()); final String gpsLongitudeRef = (String) gpsLongitudeRefField.getValue(); final RationalNumber[] gpsLongitude = (RationalNumber[]) gpsLongitudeField.getValue(); final RationalNumber gpsLatitudeDegrees = gpsLatitude[0]; final RationalNumber gpsLatitudeMinutes = gpsLatitude[1]; final RationalNumber gpsLatitudeSeconds = gpsLatitude[2]; final RationalNumber gpsLongitudeDegrees = gpsLongitude[0]; final RationalNumber gpsLongitudeMinutes = gpsLongitude[1]; final RationalNumber gpsLongitudeSeconds = gpsLongitude[2]; // This will format the gps info like so: // // gpsLatitude: 8 degrees, 40 minutes, 42.2 seconds S // gpsLongitude: 115 degrees, 26 minutes, 21.8 seconds E logger.info(" " + "GPS Latitude: " + gpsLatitudeDegrees.toDisplayString() + " degrees, " + gpsLatitudeMinutes.toDisplayString() + " minutes, " + gpsLatitudeSeconds.toDisplayString() + " seconds " + gpsLatitudeRef); logger.info(" " + "GPS Longitude: " + gpsLongitudeDegrees.toDisplayString() + " degrees, " + gpsLongitudeMinutes.toDisplayString() + " minutes, " + gpsLongitudeSeconds.toDisplayString() + " seconds " + gpsLongitudeRef); } logger.info(""); final List<ImageMetadata.ImageMetadataItem> items = jpegMetadata.getItems(); for (int i = 0; i < items.size(); i++) { final ImageMetadata.ImageMetadataItem item = items.get(i); // logger.info(" " + "item: " + item); } logger.info(""); } } return res; }
From source file:javadz.beanutils.converters.NumberConverter.java
/** * Convert an input Number object into a String. * * @param value The input value to be converted * @return the converted String value.//from ww w. ja v a 2 s .c o m * @throws Throwable if an error occurs converting to a String */ protected String convertToString(Object value) throws Throwable { String result = null; if (useLocaleFormat && value instanceof Number) { NumberFormat format = getFormat(); format.setGroupingUsed(false); result = format.format(value); if (log().isDebugEnabled()) { log().debug(" Converted to String using format '" + result + "'"); } } else { result = value.toString(); if (log().isDebugEnabled()) { log().debug(" Converted to String using toString() '" + result + "'"); } } return result; }
From source file:taximetro.main.java
private void jButtoncomienzoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtoncomienzoActionPerformed //Establecer parmetros del nuevo estado de los botones comiezo y fin // de carrera, despus de la accin del botn. jButtonfin.setEnabled(true);//ww w . java 2s . co m jButtoncomienzo.setEnabled(false); //Borrado del texto existente del area de texto. jTextAreaticket.setText(""); //Guardar la hora de comienzo de carrera al presionar el boton de comenzar. Calendar tiempo = Calendar.getInstance(zona); DateFormat formatohoras = DateFormat.getTimeInstance(DateFormat.MEDIUM); horacomienzocarrera = formatohoras.format(tiempo.getTimeInMillis()); //Establecer contador de tiempo ponerlo a cero, y inicarlo. cronometro.reset(); cronometro.start(); //Establecer contador del nmero de ticket. ticket++; //Darle formato al nmero del ticket con 5 dgitos, sin punto. NumberFormat formato = NumberFormat.getInstance(); formato.setMinimumIntegerDigits(5); formato.setGroupingUsed(false); textoticket = String.valueOf(formato.format(ticket)); }
From source file:desmoj.extensions.grafic.util.Plotter.java
/** * configure range axis ( lowerBound, upperBound, label, format ticks) * of time-series chart/*from w ww.j av a 2s .co m*/ * @param numberAxis * @param label */ private void configureRangeAxis(NumberAxis numberAxis, String label) { double min = numberAxis.getLowerBound(); double max = numberAxis.getUpperBound(); Double delta = 0.01 * (max - min); numberAxis.setLowerBound(min - delta); numberAxis.setUpperBound(max + delta); numberAxis.setLabel(label); // format Ticks double fontHeight = numberAxis.getTickLabelFont().getLineMetrics("X", this.frc).getHeight(); double maxTicks = this.paintPanel.getSize().height / fontHeight; int digits = Math.max(0, (int) -Math.floor(Math.log10((max - min) / maxTicks))); //System.out.println(fontHeight+" "+digits+" "+Math.log10((max - min)/ maxTicks)); NumberFormat formatter = NumberFormat.getNumberInstance(this.locale); formatter.setMinimumFractionDigits(digits); formatter.setMaximumFractionDigits(digits); formatter.setGroupingUsed(true); numberAxis.setNumberFormatOverride(formatter); }
From source file:com.datasalt.pangool.solr.SolrRecordWriter.java
private String getOutFileName(TaskAttemptContext context, String prefix) { TaskID taskId = context.getTaskAttemptID().getTaskID(); int partition = taskId.getId(); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumIntegerDigits(5);/* w w w . j a v a 2 s . c o m*/ nf.setGroupingUsed(false); StringBuilder result = new StringBuilder(); result.append(prefix); result.append("-"); result.append(nf.format(partition)); return result.toString(); }
From source file:mx.edu.um.mateo.inventario.dao.impl.FacturaAlmacenDaoHibernate.java
private String getFolio(Almacen almacen) { Query query = currentSession() .createQuery("select f from Folio f where f.nombre = :nombre and f.almacen.id = :almacenId"); query.setString("nombre", "FACTURA"); query.setLong("almacenId", almacen.getId()); query.setLockOptions(LockOptions.UPGRADE); Folio folio = (Folio) query.uniqueResult(); if (folio == null) { folio = new Folio("FACTURA"); folio.setAlmacen(almacen);/* w w w. j a va 2 s .co m*/ currentSession().save(folio); return getFolio(almacen); } folio.setValor(folio.getValor() + 1); java.text.NumberFormat nf = java.text.DecimalFormat.getInstance(); nf.setGroupingUsed(false); nf.setMinimumIntegerDigits(9); nf.setMaximumIntegerDigits(9); nf.setMaximumFractionDigits(0); StringBuilder sb = new StringBuilder(); sb.append("FA-"); sb.append(almacen.getEmpresa().getOrganizacion().getCodigo()); sb.append(almacen.getEmpresa().getCodigo()); sb.append(almacen.getCodigo()); sb.append(nf.format(folio.getValor())); return sb.toString(); }
From source file:mx.edu.um.mateo.inventario.dao.impl.FacturaAlmacenDaoHibernate.java
private String getFolioTemporal(Almacen almacen) { Query query = currentSession() .createQuery("select f from Folio f where f.nombre = :nombre and f.almacen.id = :almacenId"); query.setString("nombre", "FACTURA-TEMPORAL"); query.setLong("almacenId", almacen.getId()); query.setLockOptions(LockOptions.UPGRADE); Folio folio = (Folio) query.uniqueResult(); if (folio == null) { folio = new Folio("FACTURA-TEMPORAL"); folio.setAlmacen(almacen);//ww w. java 2 s . c om currentSession().save(folio); currentSession().flush(); return getFolioTemporal(almacen); } folio.setValor(folio.getValor() + 1); java.text.NumberFormat nf = java.text.DecimalFormat.getInstance(); nf.setGroupingUsed(false); nf.setMinimumIntegerDigits(9); nf.setMaximumIntegerDigits(9); nf.setMaximumFractionDigits(0); StringBuilder sb = new StringBuilder(); sb.append("TF-"); sb.append(almacen.getEmpresa().getOrganizacion().getCodigo()); sb.append(almacen.getEmpresa().getCodigo()); sb.append(almacen.getCodigo()); sb.append(nf.format(folio.getValor())); return sb.toString(); }
From source file:com.hm.his.module.user.controller.UserController.java
/** * <p>Description:<p>/* ww w . j a v a2 s . c o m*/ * @author ZhouPengyu * @date 2016-3-2 ?11:39:16 */ @RequestMapping(value = { "/hospitalRegister" }, produces = "application/json;charset=UTF-8", method = RequestMethod.POST) @ResponseBody public String register(@RequestBody Map<String, String> requestParams, HttpServletRequest request, HttpServletResponse response) { String userName = requestParams.get("userName"); String password = requestParams.get("password"); String realName = requestParams.get("realName"); String phone = requestParams.get("phone"); String mail = requestParams.get("mail"); String registerInvitation = requestParams.get("registerInvitation"); String hospitalName = requestParams.get("hospitalName"); String address = requestParams.get("address"); String hospitalLicense = requestParams.get("hospitalLicense"); String invitationCode = requestParams.get("invitationCode"); String smsCaptcha = requestParams.get("smsCaptcha"); HisResponse hisResponse = new HisResponse(); try { String sessionId = SessionUtils.getSession().getId(); String smsCaptchaCache = JedisHelper.get(String.class, sessionId).split("-")[0]; String cachePhoneNo = JedisHelper.get(String.class, sessionId).split("-")[1]; log.error(sessionId + "----??" + smsCaptcha + "--??" + smsCaptchaCache); Map<String, Object> map = new HashMap<String, Object>(); if ((smsCaptchaCache == null || !smsCaptchaCache.equals(smsCaptcha) || !cachePhoneNo.equals(phone)) && !"hmluckycharm!".equals(smsCaptcha)) { map.put("status", 5); hisResponse.setBody(map); return hisResponse.toString(); } Doctor doctor = new Doctor(); if (StringUtils.isNotEmpty(registerInvitation)) { if (registerInvitation.equals("huimeitimes")) { doctor.setStatus(1l); } else { hisResponse.setErrorCode(401); return hisResponse.toString(); } } else doctor.setStatus(1l); Hospital hospital = new Hospital(); hospital.setHospitalName(hospitalName); hospital.setAddress(address); hospital.setOrganizationLicense(hospitalLicense); hospital.setInvitationCode(invitationCode); hospitalService.saveHospital(hospital); Long number = hospital.getHospitalId(); NumberFormat formatter = NumberFormat.getNumberInstance(); formatter.setMinimumIntegerDigits(8); formatter.setGroupingUsed(false); String s = formatter.format(number); hospital.setHospitalNumber( "HM" + RC4Utils.encry_RC4_string(s, UUID.randomUUID().toString()).toUpperCase()); hospitalService.saveHospital(hospital); doctor.setDoctorName(userName); //? ---? doctor.setPassword(MD5Utils.encrypt(password)); //?? doctor.setHighPasswd(MD5Utils.passwordSaltHash(doctor.getDoctorName(), doctor.getPassword())); doctor.setRealName(realName); doctor.setMail(mail); doctor.setPhone(phone); doctor.setFlag(1L); doctor.setIsAdmin(1l); doctor.setHospitalId(hospital.getHospitalId()); doctorService.saveDoctor(doctor); if (doctor.getDoctorId() != null && doctor.getDoctorId() != 0l) { // hospitalExamService.insertDefaultExam(hospital.getHospitalId(), doctor.getDoctorId()); // drugService.addDefaultDrugForNewHospital(hospital.getHospitalId(), doctor.getDoctorId()); map.put("status", doctor.getStatus()); map.put("doctorId", doctor.getDoctorId()); if (hospital.getInvitationCode() != null && hospital.getInvitationCode().equals("18684989279")) map.put("changeImg", 1); else map.put("changeImg", 0); if (doctor.getStatus() != 1l) { smsService.getHospitalSmsConfig(hospital.getHospitalId()); HmMailUtil.sendMail(doctor, hospital); //?? } hisResponse.setBody(map); } else { hisResponse.setErrorCode(401); } } catch (Exception e) { e.printStackTrace(); } return hisResponse.toString(); }