public String formatLogNumber(double value, Direction axisDirection) {

    NumberFormat numberFormat = NumberFormat.getNumberInstance(styler.getLocale());

    String decimalPattern;

    if (axisDirection == Direction.X && styler.getXAxisDecimalPattern() != null) {

      decimalPattern = styler.getXAxisDecimalPattern();
    }
    else if (axisDirection == Direction.Y && styler.getYAxisDecimalPattern() != null) {
      decimalPattern = styler.getYAxisDecimalPattern();
    }
    else if (styler.getDecimalPattern() != null) {

      decimalPattern = styler.getDecimalPattern();
    }
    else {
      if (Math.abs(value) > 1000.0 || Math.abs(value) < 0.001) {
        decimalPattern = "0E0";
      }
      else {
        decimalPattern = "0.###";
      }
    }

    DecimalFormat normalFormat = (DecimalFormat) numberFormat;
    normalFormat.applyPattern(decimalPattern);
    return normalFormat.format(value);

  }