net.sf.latexdraw.parsers.svg.parsers
Class UnitProcessor

java.lang.Object
  extended by net.sf.latexdraw.parsers.svg.parsers.UnitProcessor

public final class UnitProcessor
extends java.lang.Object

This processor manages and transforms value in different units.

This file is part of LaTeXDraw.
Copyright (c) 2005-2012 Arnaud BLOUIN

LaTeXDraw is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

LaTeXDraw is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

10/24/07

Version:
3.0
Author:
Arnaud BLOUIN

Field Summary
static UnitProcessor INSTANCE
          The singleton.
 
Constructor Summary
private UnitProcessor()
           
 
Method Summary
 double toPoint(double value, SVGLength.LengthType lgthType)
          Transforms a value in point according to the given unit (%, em and ex are not managed).
 double toUserUnit(double value, SVGLength.LengthType lgthType)
          Transforms a value in the user unit (in pixels) according to the given unit (%, em and ex are not managed).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final UnitProcessor INSTANCE
The singleton.

Constructor Detail

UnitProcessor

private UnitProcessor()
Method Detail

toPoint

public double toPoint(double value,
                      SVGLength.LengthType lgthType)
Transforms a value in point according to the given unit (%, em and ex are not managed).

Parameters:
value - The value to transform.
lgthType - The type of the value.
Returns:
The value in point.
Throws:
java.lang.IllegalArgumentException - If the given length type is not valid or not managed.

toUserUnit

public double toUserUnit(double value,
                         SVGLength.LengthType lgthType)
Transforms a value in the user unit (in pixels) according to the given unit (%, em and ex are not managed).

Parameters:
value - The value to transform.
lgthType - The type of the value.
Returns:
The value in the user unit (in pixels).
Throws:
java.lang.IllegalArgumentException - If the given length type is not valid or not managed.