001/******************************************************************************* 002 * This software is provided as a supplement to the authors' textbooks on digital 003 * image processing published by Springer-Verlag in various languages and editions. 004 * Permission to use and distribute this software is granted under the BSD 2-Clause 005 * "Simplified" License (see http://opensource.org/licenses/BSD-2-Clause). 006 * Copyright (c) 2006-2016 Wilhelm Burger, Mark J. Burge. All rights reserved. 007 * Visit http://imagingbook.com for additional details. 008 *******************************************************************************/ 009package imagingbook.lib.settings; 010 011/** 012 * This class holds various settings for the imagingbook library. 013 * @author wilbur 014 * 015 */ 016public abstract class PrintPrecision { 017 018 private static int defaultPrecision = 3; 019 private static int precision = defaultPrecision; 020 private static String formatStringFloat; 021 022 static { 023 reset(); 024 } 025 026 public static void reset() { 027 set(defaultPrecision); 028 } 029 030 public static void set(int nDigits) { 031 precision = Math.max(nDigits, 0); 032 if (nDigits > 0) { 033 formatStringFloat = "%." + precision + "f"; // e.g. "%.5f" 034 } 035 else { 036 formatStringFloat = "%e"; // use scientific format - OK? 037 } 038 } 039 040 public static String getFormatStringFloat() { 041 return formatStringFloat; 042 } 043 044 public static int get() { 045 return precision; 046 } 047 048}