List of usage examples for java.text NumberFormat getNumberInstance
public static NumberFormat getNumberInstance(Locale inLocale)
From source file:org.sakaiproject.util.impl.FormattedTextImpl.java
public NumberFormat getNumberFormat(Integer maxFractionDigits, Integer minFractionDigits, Boolean groupingUsed) {/*from www . j a v a 2s . c o m*/ NumberFormat nbFormat = NumberFormat.getInstance(); try { nbFormat = NumberFormat.getNumberInstance(new ResourceLoader().getLocale()); } catch (Exception e) { M_log.error("Error while retrieving local number format, using default ", e); } if (maxFractionDigits != null) nbFormat.setMaximumFractionDigits(maxFractionDigits); if (minFractionDigits != null) nbFormat.setMinimumFractionDigits(minFractionDigits); if (groupingUsed != null) nbFormat.setGroupingUsed(groupingUsed); return nbFormat; }
From source file:hudson.plugins.sshslaves.SSHLauncher.java
/** * Given the output of "java -version" in <code>r</code>, determine if this * version of Java is supported. This method has default visiblity for testing. * * @param logger/*from w w w .j a v a 2 s . c o m*/ * where to log the output * @param javaCommand * the command executed, used for logging * @param r * the output of "java -version" * @param output * copy the data from <code>r</code> into this output buffer */ @CheckForNull protected String checkJavaVersion(final PrintStream logger, String javaCommand, final BufferedReader r, final StringWriter output) throws IOException { String line; while (null != (line = r.readLine())) { output.write(line); output.write("\n"); line = line.toLowerCase(Locale.ENGLISH); if (line.startsWith("java version \"") || line.startsWith("openjdk version \"")) { final String versionStr = line.substring(line.indexOf('\"') + 1, line.lastIndexOf('\"')); logger.println(Messages.SSHLauncher_JavaVersionResult(getTimestamp(), javaCommand, versionStr)); // parse as a number and we should be OK as all we care about is up through the first dot. try { final Number version = NumberFormat.getNumberInstance(Locale.US).parse(versionStr); if (version.doubleValue() < 1.5) { throw new IOException(Messages.SSHLauncher_NoJavaFound(line)); } } catch (final ParseException e) { throw new IOException(Messages.SSHLauncher_NoJavaFound(line)); } return javaCommand; } } return null; }
From source file:com.landenlabs.all_devtool.PackageFragment.java
boolean addPackageInfo(PackageInfo packInfo) { if (packInfo == null) return false; String packageName = packInfo.packageName.trim(); for (PackingItem item : m_workList) { if (item.fieldStr().equals(packageName)) { return false; }/* ww w. j ava 2s . co m*/ } ArrayListPairString pkgList = new ArrayListPairString(); String appName = packInfo.applicationInfo.loadLabel(getActivity().getPackageManager()).toString().trim(); long pkgSize = 0; addList(pkgList, "Version", packInfo.versionName); addList(pkgList, "VerCode", String.valueOf(packInfo.versionCode)); // addList(pkgList, "Directory", packInfo.applicationInfo.sourceDir); try { File file = new File(packInfo.applicationInfo.sourceDir); pkgSize = file.length(); addList(pkgList, "FileSize", NumberFormat.getNumberInstance(Locale.getDefault()).format(pkgSize)); } catch (Exception ex) { } if (!TextUtils.isEmpty(packInfo.applicationInfo.permission)) addList(pkgList, "Permission", packInfo.applicationInfo.permission); if (packInfo.applicationInfo.sharedLibraryFiles != null) addList(pkgList, "ShrLibs", packInfo.applicationInfo.sharedLibraryFiles.toString()); addList(pkgList, "TargetSDK", String.valueOf(packInfo.applicationInfo.targetSdkVersion)); m_date.setTime(packInfo.firstInstallTime); addList(pkgList, "Install First", s_timeFormat.format(m_date)); m_date.setTime(packInfo.lastUpdateTime); addList(pkgList, "Install Last", s_timeFormat.format(m_date)); if (packInfo.requestedPermissions != null) { // addList(pkgList, "RegPermissions", Arrays.toString(packInfo.requestedPermissions).replaceAll("[a-z]*", "").replaceAll(",", "\n")); addList(pkgList, m_regPermissionsStr, String.format(" #%d", packInfo.requestedPermissions.length)); if (false) { for (int pidx = 0; pidx != packInfo.requestedPermissions.length; pidx++) { String perm = packInfo.requestedPermissions[pidx].replaceAll("[a-z.]*", ""); if (perm.length() > 30) perm = perm.substring(0, 30); addList(pkgList, String.format(" %2d", pidx), perm); } } } if (packInfo.permissions != null) { addList(pkgList, m_permissionsStr, String.format(" #%d", packInfo.permissions.length)); } if (packInfo.activities != null) { addList(pkgList, m_activitiesStr, String.format(" #%d", packInfo.activities.length)); } if (packInfo.services != null) { addList(pkgList, m_servicesStr, String.format(" #%d", packInfo.services.length)); } if (Build.VERSION.SDK_INT > 21) { if (packInfo.splitNames != null && packInfo.splitNames.length != 0) { for (int splitIdx = 0; splitIdx != packInfo.splitNames.length; splitIdx++) { addList(pkgList, String.format(" SplitName%2d", splitIdx), packInfo.splitNames[splitIdx]); } } } addList(pkgList, "Apk File", packInfo.applicationInfo.publicSourceDir); StringBuilder flagStr = new StringBuilder(); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) flagStr.append(" Debug "); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_IS_GAME) != 0) flagStr.append(" Game "); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_ALLOW_BACKUP) != 0) flagStr.append(" AllowBackup "); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) flagStr.append(" System "); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_LARGE_HEAP) != 0) flagStr.append(" LargeHeap "); if (flagStr.length() != 0) { addList(pkgList, "Flags", flagStr.toString()); } if (packInfo.signatures != null) { String signatures = ""; for (android.content.pm.Signature sig : packInfo.signatures) { signatures = signatures + " " + sig.toCharsString(); } addList(pkgList, "Signature", signatures); } if (packInfo.providers != null) { addList(pkgList, m_providers, String.valueOf(packInfo.providers.length)); if (false) { String providers = ""; for (ProviderInfo providerInfo : packInfo.providers) { providers = providers + " " + providerInfo.name; } addList(pkgList, "Providers", providers); } } m_workList.add(new PackingItem(packInfo.packageName.trim(), pkgList, packInfo, pkgSize, appName)); return true; }
From source file:org.orcid.core.adapter.impl.Jaxb2JpaAdapterImpl.java
/** * Get a string with the proper amount format * /*from w ww . j a v a 2 s.c o m*/ * @param local * @return an example string showing how the amount should be entered * */ private String getSampleAmountInProperFormat(java.util.Locale locale) { double example = 1234567.89; NumberFormat numberFormatExample = NumberFormat.getNumberInstance(locale); return numberFormatExample.format(example); }
From source file:org.opentaps.common.util.UtilCommon.java
/** * Converts a localized number <code>String</code> to a <code>BigDecimal</code> using the given <code>Locale</code>, defaulting to the system <code>Locale</code>. * @param locale the <code>Locale</code> to use for parsing the number, optional, defaults to the system <code>Locale</code> * @param numberString a <code>String</code> to convert to a <code>BigDecimal</code> * @return the corresponding <code>BigDecimal</code> value * @throws ParseException if an occurs during parsing *//*from w w w .jav a 2s. c o m*/ public static BigDecimal parseLocalizedNumber(Locale locale, String numberString) throws ParseException { locale = UtilMisc.ensureLocale(locale); NumberFormat parser = NumberFormat.getNumberInstance(locale); Number n = parser.parse(numberString); return new BigDecimal(n.toString()); }
From source file:com.MainFiles.Functions.java
public String fn_getAgentEODTransactions(String strAgentID, String strTerminalID, String intID) throws SQLException { String strResponse = ""; String SQL, sqlQuery = ""; String strTotalcredit = ""; String strdate = ""; double amount = 0; String strStatementPrinting = ""; String strTotaldebits = ""; int i = 1;/*from w ww . j a va2 s.c o m*/ Connection dbConnection = connections.getDBConnection(ECSERVER, ECDB, ECUSER, ECPASSWORD); try { NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "tz")); String strStoredProcedure = "{call SP_DAILY_TRANSACTIONS(?,?)}"; CallableStatement callableStatement = dbConnection.prepareCall(strStoredProcedure); callableStatement.setString(1, strTerminalID); callableStatement.registerOutParameter(2, java.sql.Types.VARCHAR); callableStatement.executeUpdate(); String strStatus = callableStatement.getString(2); if (strStatus.equals("1")) { String query = "select transactiontype,transactioncount,amount from tbagentsummary where serialnumber='" + strTerminalID + "'"; ResultSet rsrecordQuery = connections.ExecuteQueryReturnString(ECSERVER, query, ECPASSWORD, ECUSER, ECDB); while (rsrecordQuery.next()) { String strAmount = NumberFormat.getNumberInstance(Locale.US) .format(Double.parseDouble(rsrecordQuery.getString("AMOUNT").toString())); strStatementPrinting += " "; strStatementPrinting += PadSpaces(15, rsrecordQuery.getString("TRANSACTIONTYPE").toString(), "RIGHT"); strStatementPrinting += PadSpaces(4, rsrecordQuery.getString("TRANSACTIONCOUNT").toString(), "LEFT"); strStatementPrinting += PadSpaces(12, strAmount.replace("TZS", ""), "LEFT"); strStatementPrinting += "#"; } } String StrMerchantFloatAccount = fn_getAgentAccountNumber(strAgentID); strResponse += "AGENT ID: " + strAgentID + "#"; strResponse += "TRAN NUM: " + intID + "#"; strResponse += "ACCOUNT NUM: " + StrMerchantFloatAccount + "#"; strResponse += "--------------------------------" + "#"; strResponse += " " + "#"; strResponse += " EOD SUMMARY REPORT " + "#"; strResponse += " " + "#"; strResponse += " TRANS. COUNT AMOUNT" + "#"; strResponse += " " + "#"; strResponse += strStatementPrinting; strResponse += " " + "#"; strResponse += " " + "#"; return strResponse; } catch (Exception ex) { this.log("INFO :: Error on fn_getAgentEODTransactions " + ex.getMessage() + "\n" + this.StackTraceWriter(ex), "ERROR"); } finally { dbConnection.close(); } return null; }
From source file:com.landenlabs.all_devtool.PackageFragment.java
/** * Load installed (user or system) packages. * * TODO - include/*from ww w. j av a 2 s.c om*/ * /data/local/tmp * /sdcard/local/tmp ? * /storage/sdcardx/LOST.DIR/ * /sdcard/download * */ void loadCachedPackages() { try { // m_pkgUninstallBtn.setText(R.string.package_uninstall); m_uninstallResId = R.string.package_del_cache; m_pkgUninstallBtn.post(new Runnable() { @Override public void run() { updateUninstallBtn(); } }); m_workList = new ArrayList<PackingItem>(); // PackageManager.GET_SIGNATURES | PackageManager.GET_PERMISSIONS | PackageManager.GET_PROVIDERS; int flags1 = PackageManager.GET_META_DATA | PackageManager.GET_SHARED_LIBRARY_FILES | PackageManager.GET_INTENT_FILTERS; int flags2 = PackageManager.GET_META_DATA | PackageManager.GET_SHARED_LIBRARY_FILES; int flags3 = PackageManager.GET_META_DATA; int flags4 = 0; List<PackageInfo> packList = getActivity().getPackageManager().getInstalledPackages(flags1); /* packList = mergePackages(packList, getActivity().getPackageManager().getInstalledPackages(flags2)); packList = mergePackages(packList, getActivity().getPackageManager().getInstalledPackages(flags3)); packList = mergePackages(packList, getActivity().getPackageManager().getInstalledPackages(flags4)); */ if (packList != null) for (int idx = 0; idx < packList.size(); idx++) { PackageInfo packInfo = packList.get(idx); long cacheSize = 0; long fileCount = 0; if (packInfo == null || packInfo.lastUpdateTime <= 0) { continue; // Bad package } Context pkgContext; try { m_log.d(String.format("%3d/%d : %s", idx, packList.size(), packInfo.packageName)); pkgContext = getActivity().createPackageContext(packInfo.packageName, Context.CONTEXT_IGNORE_SECURITY); } catch (Exception ex) { m_log.e(ex.getLocalizedMessage()); continue; // Bad package } File cacheDirectory = null; Utils.DirSizeCount cacheDirSize = null; if (pkgContext.getCacheDir() != null) { cacheDirectory = pkgContext.getCacheDir(); } else { // cacheDirectory = new File(mContext.getPackageResourcePath()); if (pkgContext.getFilesDir() != null) { String dataPath = pkgContext.getFilesDir().getPath(); // "/data/data/" cacheDirectory = new File(dataPath, pkgContext.getPackageName() + "/cache"); } } if (cacheDirectory != null) { // cacheSize = cacheDirectory.length()/1024; cacheDirSize = Utils.getDirectorySize(cacheDirectory); if (true) { // Cache is not readable or empty, // Try and map cache dir to one of the sd storage paths for (String storageDir : m_storageDirs) { try { File cacheDirectory2 = new File(cacheDirectory.getCanonicalPath() .replace("/data/data", storageDir + "/Android/data")); if (cacheDirectory2.exists()) { cacheDirectory = cacheDirectory2; Utils.DirSizeCount dirSize = Utils.getDirectorySize(cacheDirectory2); if (cacheDirSize == null || dirSize.size > cacheDirSize.size) { cacheDirSize = dirSize; cacheDirectory = cacheDirectory2; } } } catch (Exception ex) { m_log.d(ex.getMessage()); } } } } else { m_log.d(packInfo.packageName + " missing cache dir"); } Utils.DirSizeCount datDirSize = null; if (packInfo.applicationInfo.dataDir != null) { try { datDirSize = Utils.getDirectorySize(new File(packInfo.applicationInfo.dataDir)); } catch (Exception ex) { } } /* Method getPackageSizeInfo; try { getPackageSizeInfo = getActivity().getPackageManager().getClass().getMethod( "getPackageSizeInfo", String.class, Class.forName("android.content.pm.IPackageStatsObserver")); getPackageSizeInfo.invoke(getActivity().getPackageManager(), packInfo.packageName, new IPackageStatsObserver() { @Override public void onGetStatsCompleted( PackageStats pStats, boolean succeeded) throws RemoteException { totalSize = totalSize + pStats.cacheSize; } } ); } catch (Exception e) { continue; } */ /* if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) */ { ArrayListPairString pkgList = new ArrayListPairString(); String appName = "unknown"; try { appName = packInfo.applicationInfo.loadLabel(getActivity().getPackageManager()) .toString().trim(); } catch (Exception ex) { m_log.e(ex.getLocalizedMessage()); } long pkgSize = 0; addList(pkgList, "Version", packInfo.versionName); addList(pkgList, "TargetSDK", String.valueOf(packInfo.applicationInfo.targetSdkVersion)); String installTyp = "auto"; if (Build.VERSION.SDK_INT >= 21) { switch (packInfo.installLocation) { case PackageInfo.INSTALL_LOCATION_AUTO: break; case PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY: installTyp = "internal"; break; case PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL: installTyp = "external"; break; } } addList(pkgList, "Install", installTyp); // Add application info. try { addList(pkgList, "Allow Backup", String.valueOf((packInfo.applicationInfo.flags & FLAG_ALLOW_BACKUP) != 0)); addList(pkgList, "Debuggable", String.valueOf( (packInfo.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0)); addList(pkgList, "External Storage", String.valueOf( (packInfo.applicationInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0)); String themeName = getResourceName(packInfo, packInfo.applicationInfo.theme); if (!TextUtils.isEmpty(themeName)) addList(pkgList, "Theme", themeName); } catch (Exception ex) { Log.d("foo", ex.getMessage()); } try { File file = new File(packInfo.applicationInfo.sourceDir); pkgSize = file.length(); } catch (Exception ex) { } addList(pkgList, "Apk File", packInfo.applicationInfo.publicSourceDir); addList(pkgList, "Apk Size", NumberFormat.getNumberInstance(Locale.getDefault()).format(pkgSize)); addList(pkgList, "Src Dir", packInfo.applicationInfo.sourceDir); addList(pkgList, "lib Dir", packInfo.applicationInfo.nativeLibraryDir); addList(pkgList, "dat Dir", packInfo.applicationInfo.dataDir); if (null != datDirSize) { addList(pkgList, "* Dir Size", NumberFormat.getNumberInstance(Locale.getDefault()).format(datDirSize.size)); addList(pkgList, "* File Count", NumberFormat.getNumberInstance(Locale.getDefault()).format(datDirSize.count)); } if (null != cacheDirectory) { addList(pkgList, "Cache", cacheDirectory.getCanonicalPath()); if (null != cacheDirSize) { cacheSize = cacheDirSize.size; addList(pkgList, "* Dir Size", NumberFormat.getNumberInstance(Locale.getDefault()) .format(cacheDirSize.size)); addList(pkgList, "* File Count", NumberFormat .getNumberInstance(Locale.getDefault()).format(cacheDirSize.count)); } } if (null != packInfo.applicationInfo.sharedLibraryFiles && packInfo.applicationInfo.sharedLibraryFiles.length != 0) { addList(pkgList, "ShareLibs", NumberFormat.getNumberInstance(Locale.getDefault()) .format(packInfo.applicationInfo.sharedLibraryFiles.length)); for (String shrLibStr : packInfo.applicationInfo.sharedLibraryFiles) { addList(pkgList, " ", shrLibStr); } } if (true) { // packInfo.configPreferences; use with flag= GET_CONFIGURATIONS; // packInfo.providers use with GET_PROVIDERS; List<IntentFilter> outFilters = new ArrayList<IntentFilter>(); List<ComponentName> outActivities = new ArrayList<ComponentName>(); int num = getActivity().getPackageManager().getPreferredActivities(outFilters, outActivities, packInfo.packageName); if (num > 0) { addList(pkgList, "Preferred #", String.valueOf(num)); } } /* if (null != cacheDirectory) */ // if (cacheDirSize != null) { m_workList.add(new PackingItem(packInfo.packageName.trim(), pkgList, packInfo, cacheSize, appName)); } } } } catch (Exception ex) { m_log.e(ex.getMessage()); } }
From source file:org.orcid.core.manager.impl.OrcidProfileManagerImpl.java
/** * Replace the funding amount string into the desired format * /*from w ww .j a v a 2 s .c om*/ * @param updatedOrcidProfile * The profile containing the new funding * */ private void setFundingAmountsWithTheCorrectFormat(OrcidProfile updatedOrcidProfile) throws IllegalArgumentException { FundingList fundings = updatedOrcidProfile.retrieveFundings(); for (Funding funding : fundings.getFundings()) { // If the amount is not empty, update it if (funding.getAmount() != null && StringUtils.isNotBlank(funding.getAmount().getContent())) { String amount = funding.getAmount().getContent(); Locale locale = localeManager.getLocale(); ParsePosition parsePosition = new ParsePosition(0); DecimalFormat numberFormat = (DecimalFormat) NumberFormat.getNumberInstance(locale); DecimalFormatSymbols symbols = numberFormat.getDecimalFormatSymbols(); /** * When spaces are allowed, the grouping separator is the * character 160, which is a non-breaking space So, lets change * it so it uses the default space as a separator * */ if (symbols.getGroupingSeparator() == 160) { symbols.setGroupingSeparator(' '); } numberFormat.setDecimalFormatSymbols(symbols); Number number = numberFormat.parse(amount, parsePosition); String formattedAmount = number.toString(); if (parsePosition.getIndex() != amount.length()) { double example = 1234567.89; NumberFormat numberFormatExample = NumberFormat.getNumberInstance(localeManager.getLocale()); throw new IllegalArgumentException( "The amount: " + amount + " doesn'n have the right format, it should use the format: " + numberFormatExample.format(example)); } funding.getAmount().setContent(formattedAmount); } } }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
/** * Build and run a thermometer chart. JFreeChart thermometer charts have some * limitations. They always have a maximum of three ranges, and the colors of those * ranges seems to be fixed./* w ww .j a v a2s . c om*/ */ protected JFreeChart createThermometerChart() throws JRException { JRThermometerPlot jrPlot = (JRThermometerPlot) getPlot(); // Create the plot that will hold the thermometer. ThermometerPlot chartPlot = new ThermometerPlot((ValueDataset) getDataset()); ChartUtil chartUtil = ChartUtil.getInstance(getChartContext().getJasperReportsContext()); // setting localized range axis formatters chartPlot.getRangeAxis().setStandardTickUnits(chartUtil.createIntegerTickUnits(getLocale())); Range range = convertRange(jrPlot.getDataRange()); // Set the boundary of the thermomoter chartPlot.setLowerBound(range.getLowerBound()); chartPlot.setUpperBound(range.getUpperBound()); // Units can only be Fahrenheit, Celsius or none, so turn off for now. chartPlot.setUnits(ThermometerPlot.UNITS_NONE); // Set the color of the mercury. Only used when the value is outside of // any defined ranges. Color color = jrPlot.getMercuryColor(); if (color != null) { chartPlot.setMercuryPaint(color); chartPlot.setUseSubrangePaint(false); } // localizing the default format, can be overridden by display.getMask() chartPlot.setValueFormat(NumberFormat.getNumberInstance(getLocale())); // Set the formatting of the value display JRValueDisplay display = jrPlot.getValueDisplay(); if (display != null) { if (display.getColor() != null) { chartPlot.setValuePaint(display.getColor()); } if (display.getMask() != null) { chartPlot.setValueFormat( new DecimalFormat(display.getMask(), DecimalFormatSymbols.getInstance(getLocale()))); } if (display.getFont() != null) { // chartPlot.setValueFont(getFontUtil().getAwtFont(display.getFont())); } } // Set the location of where the value is displayed ValueLocationEnum valueLocation = jrPlot.getValueLocationValue(); switch (valueLocation) { case NONE: chartPlot.setValueLocation(ThermometerPlot.NONE); break; case LEFT: chartPlot.setValueLocation(ThermometerPlot.LEFT); break; case RIGHT: chartPlot.setValueLocation(ThermometerPlot.RIGHT); break; case BULB: default: chartPlot.setValueLocation(ThermometerPlot.BULB); break; } // Define the three ranges range = convertRange(jrPlot.getLowRange()); if (range != null) { chartPlot.setSubrangeInfo(2, range.getLowerBound(), range.getUpperBound()); } range = convertRange(jrPlot.getMediumRange()); if (range != null) { chartPlot.setSubrangeInfo(1, range.getLowerBound(), range.getUpperBound()); } range = convertRange(jrPlot.getHighRange()); if (range != null) { chartPlot.setSubrangeInfo(0, range.getLowerBound(), range.getUpperBound()); } // Build a chart around this plot JFreeChart jfreeChart = new JFreeChart(evaluateTextExpression(getChart().getTitleExpression()), null, chartPlot, isShowLegend()); // Set the generic options configureChart(jfreeChart, getPlot()); return jfreeChart; }
From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java
/** * Build and run a thermometer chart. JFreeChart thermometer charts have some * limitations. They always have a maximum of three ranges, and the colors of those * ranges seems to be fixed.//from ww w . ja v a2s. com */ protected JFreeChart createThermometerChart() throws JRException { JRThermometerPlot jrPlot = (JRThermometerPlot) getPlot(); // Create the plot that will hold the thermometer. ThermometerPlot chartPlot = new ThermometerPlot((ValueDataset) getDataset()); ChartUtil chartUtil = ChartUtil.getInstance(chartContext.getJasperReportsContext()); // setting localized range axis formatters chartPlot.getRangeAxis().setStandardTickUnits(chartUtil.createIntegerTickUnits(getLocale())); Range range = convertRange(jrPlot.getDataRange()); // Set the boundary of the thermomoter chartPlot.setLowerBound(range.getLowerBound()); chartPlot.setUpperBound(range.getUpperBound()); // Units can only be Fahrenheit, Celsius or none, so turn off for now. chartPlot.setUnits(ThermometerPlot.UNITS_NONE); // Set the color of the mercury. Only used when the value is outside of // any defined ranges. Color color = jrPlot.getMercuryColor(); if (color != null) { chartPlot.setMercuryPaint(color); chartPlot.setUseSubrangePaint(false); } // localizing the default format, can be overridden by display.getMask() chartPlot.setValueFormat(NumberFormat.getNumberInstance(getLocale())); // Set the formatting of the value display JRValueDisplay display = jrPlot.getValueDisplay(); if (display != null) { if (display.getColor() != null) { chartPlot.setValuePaint(display.getColor()); } if (display.getMask() != null) { chartPlot.setValueFormat( new DecimalFormat(display.getMask(), DecimalFormatSymbols.getInstance(getLocale()))); } if (display.getFont() != null) { chartPlot.setValueFont(fontUtil.getAwtFont(display.getFont(), getLocale())); } } // Set the location of where the value is displayed switch (jrPlot.getValueLocationValue()) { case NONE: chartPlot.setValueLocation(ThermometerPlot.NONE); break; case LEFT: chartPlot.setValueLocation(ThermometerPlot.LEFT); break; case RIGHT: chartPlot.setValueLocation(ThermometerPlot.RIGHT); break; case BULB: default: chartPlot.setValueLocation(ThermometerPlot.BULB); break; } // Define the three ranges range = convertRange(jrPlot.getLowRange()); if (range != null) { chartPlot.setSubrangeInfo(2, range.getLowerBound(), range.getUpperBound()); } range = convertRange(jrPlot.getMediumRange()); if (range != null) { chartPlot.setSubrangeInfo(1, range.getLowerBound(), range.getUpperBound()); } range = convertRange(jrPlot.getHighRange()); if (range != null) { chartPlot.setSubrangeInfo(0, range.getLowerBound(), range.getUpperBound()); } // Build a chart around this plot JFreeChart jfreeChart = new JFreeChart(evaluateTextExpression(getChart().getTitleExpression()), null, chartPlot, isShowLegend()); // Set the generic options configureChart(jfreeChart); return jfreeChart; }