/** * Get the text to display in the pager that reflects the state of the pager. * * @return the text */ protected String createText() { // Default text is 1 based. NumberFormat formatter = NumberFormat.getFormat("#,###"); HasRows display = getDisplay(); Range range = display.getVisibleRange(); int pageStart = range.getStart() + 1; int pageSize = range.getLength(); int dataSize = display.getRowCount(); int endIndex = Math.min(dataSize, pageStart + pageSize - 1); endIndex = Math.max(pageStart, endIndex); boolean exact = display.isRowCountExact(); return formatter.format(pageStart) + "-" + formatter.format(endIndex) + (exact ? " of " : " of over ") + formatter.format(dataSize); }
private NumberFormat createFormatter(int precision) { String pattern = "0"; if (precision > 0) { pattern += "."; while (precision > 0) { pattern += "0"; precision--; } } return NumberFormat.getFormat(pattern); }
/** * Creates a new number property editor. * * @param pattern the number format pattern */ public NumberPropertyEditor(String pattern) { this(NumberFormat.getFormat(pattern)); }
@Override public final Integer parse(final CharSequence pobject) throws ParseException { if (StringUtils.isEmpty(Objects.toString(pobject))) { return null; } try { return Integer.valueOf((int) NumberFormat.getFormat("###0").parse(pobject.toString())); } catch (final NumberFormatException e) { throw new ParseException(e.getMessage(), 0); // NOPMD, we needn't a stack trace } } }
public NumberRenderer(String format) { if (format == null) { this.formater = NumberFormat.getDecimalFormat(); } else { this.formater = NumberFormat.getFormat(format); } }
@Override public final Long parse(final CharSequence pobject) throws ParseException { if (StringUtils.isEmpty(Objects.toString(pobject))) { return null; } try { return Long.valueOf((long) NumberFormat.getFormat("###0").parse(pobject.toString())); } catch (final NumberFormatException e) { throw new ParseException(e.getMessage(), 0); // NOPMD, we needn't a stack trace } } }
String humanReadableRowCount(long rows) { int unit = 1000; if (rows < unit) return Long.toString(rows); int exp = (int) (Math.log(rows) / Math.log(unit)); String pre = ("KMGTPE" ).charAt(exp-1) + (""); return NumberFormat.getFormat(ESTIMATIONS_FORMAT).format(rows / Math.pow(unit, exp)) + pre; }
@Override public String render(final Long pobject) { if (pobject == null) { return StringUtils.EMPTY; } return NumberFormat.getFormat("###0").format(pobject); } }
private String format(double d) { return NumberFormat.getFormat("#.00").format(d); } }
@Override public String render(final Long pobject) { if (pobject == null) { return StringUtils.EMPTY; } return NumberFormat.getFormat("###0").format(pobject); } }
/** * Formats the number. * * @param value the number * @param format the format using the {@link DateTimeFormat} syntax. * @return the formatted string */ public static String number(double value, String format) { return NumberFormat.getFormat(format).format(value); }
public NumberRenderer(String format) { if (format == null) { this.formater = NumberFormat.getDecimalFormat(); } else { this.formater = NumberFormat.getFormat(format); } }
String humanReadableRowCount(long rows) { int unit = 1000; if (rows < unit) return Long.toString(rows); int exp = (int) (Math.log(rows) / Math.log(unit)); String pre = ("KMGTPE" ).charAt(exp-1) + (""); return NumberFormat.getFormat(ESTIMATIONS_FORMAT).format(rows / Math.pow(unit, exp)) + pre; }
@Override public final Long parse(final CharSequence pobject) throws ParseException { if (StringUtils.isEmpty(Objects.toString(pobject))) { return null; } try { return Long.valueOf((long) NumberFormat.getFormat("###0").parse(pobject.toString())); } catch (final NumberFormatException e) { throw new ParseException(e.getMessage(), 0); // NOPMD, we needn't a stack trace } } }
@Override public String render(final Integer pobject) { if (pobject == null) { return StringUtils.EMPTY; } return NumberFormat.getFormat("###0").format(pobject); } }
String humanReadableByteCount(long bytes) { final String _b = " " + DataSetExplorerConstants.INSTANCE.bytes(); int unit = 1024; if (bytes < unit) return Long.toString(bytes) + _b; int exp = (int) (Math.log(bytes) / Math.log(unit)); String pre = ("KMGTPE").charAt(exp-1) + _b; return NumberFormat.getFormat(ESTIMATIONS_FORMAT).format(bytes / Math.pow(unit, exp)) + pre; }
String humanReadableByteCount(long bytes) { final String _b = " " + DataSetExplorerConstants.INSTANCE.bytes(); int unit = 1024; if (bytes < unit) return Long.toString(bytes) + _b; int exp = (int) (Math.log(bytes) / Math.log(unit)); String pre = ("KMGTPE").charAt(exp-1) + _b; return NumberFormat.getFormat(ESTIMATIONS_FORMAT).format(bytes / Math.pow(unit, exp)) + pre; }
protected NumberFormat getNumberFormat(String pattern) { if (StringUtils.isBlank(pattern)) { return getNumberFormat(ColumnSettings.NUMBER_PATTERN); } NumberFormat format = numberPatternMap.get(pattern); if (format == null) { format = NumberFormat.getFormat(pattern); numberPatternMap.put(pattern, format); } return format; }
protected C3Tick createTickY() { return factory.createC3Tick(f -> { try { double doubleFormat = Double.parseDouble(f); return NumberFormat.getFormat("#,###.##").format(doubleFormat); } catch(NumberFormatException e) { return f; } }); }
private NumberFormat getNumberFormat() { if (axis.getFormat() != null && axis.getFormat().trim().length() > 0) return NumberFormat.getFormat(axis.getFormat()); else return numberFormat; }