ilog.views.svg
Interface SVGDocumentBuilderConfigurator.RealToStringConverter

All Known Implementing Classes:
DefaultRealToStringConverter
Enclosing class:
SVGDocumentBuilderConfigurator

public static interface SVGDocumentBuilderConfigurator.RealToStringConverter

This interface must be implemented by classes that want to define how the SVG DOM used by the SVGDocumentBuilder will translate real number values to DOM strings. You can set your instance using the SVGDocumentBuilderConfigurator.setRealToStringConverter(ilog.views.svg.SVGDocumentBuilderConfigurator.RealToStringConverter) method; the default is of type DefaultRealToStringConverter. For example, if you want your real numbers in SVG files having only 3 decimals instead of the regular number of decimals that Java is producing, you could use the following sample RealToStringConverter subclass:


 class ThreeRealToStringConverter implements SVGDocumentBuilderConfigurator.RealToStringConverter
 {
    public String floatToString(float value) 
    {
       return doubleToString((double)value);
    }
   
    public String doubleToString(double value)
    {
       // of course an improved version would be to test for no overflow when
       // multiplying by 1000.
       return Double.toString(((double)(int)(value*1000))/1000); 
    }
 }
 

Since:
JViews 5.0

Method Summary
 String doubleToString(double value)
          Defines how a double value will be translated to a String.
 String floatToString(float value)
          Defines how a float value will be translated to a String.
 

Method Detail

floatToString

String floatToString(float value)
Defines how a float value will be translated to a String.


doubleToString

String doubleToString(double value)
Defines how a double value will be translated to a String.



Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.