private String defaultFormat(double d) {
		String str = "" + d;
		int availableSpace = getSize().width - 2 * PIXEL_MARGIN;
		FontMetrics fm = getFontMetrics(getFont());
		if (fm.stringWidth(str) <= availableSpace) return str;
		int eIndex = str.indexOf("E");
		String suffix = "";
		if (eIndex != -1) {
			suffix = str.substring(eIndex);
			str = str.substring(0, eIndex);
			try {
				d = parser.parse(str).doubleValue();
			} catch (ParseException ex) {
				throw new ErrorException(ex);
			}
		}
		NumberFormat standard = NumberFormat.getNumberInstance(Locale.US);
		standard.setGroupingUsed(false);
		String head = str.substring(0, str.indexOf('.') + 1);
		int fractionSpace = availableSpace - fm.stringWidth(head + suffix);
		if (fractionSpace > 0) {
			int fractionDigits = fractionSpace / fm.stringWidth("0");
			standard.setMaximumFractionDigits(fractionDigits);
			return standard.format(d) + suffix;
		}
		str = "";
		while (fm.stringWidth(str + "#") <= availableSpace) {
			str += "#";
		}
		return str;
	}