net.sf.latexdraw.parsers.ps
Class PSFunctionParser

java.lang.Object
  extended by net.sf.latexdraw.parsers.ps.PSFunctionParser

public class PSFunctionParser
extends java.lang.Object

Defines a postscript function parser.

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.

03/11/08

Version:
3.0
Author:
Arnaud BLOUIN

Field Summary
static java.lang.String CMD_ABS
           
static java.lang.String CMD_ADD
           
static java.lang.String CMD_CEILING
           
static java.lang.String CMD_CLEAR
           
static java.lang.String CMD_COS
           
static java.lang.String CMD_COUNT
           
static java.lang.String CMD_DIV
           
static java.lang.String CMD_DUP
           
static java.lang.String CMD_EXCH
           
static java.lang.String CMD_EXP
           
static java.lang.String CMD_FLOOR
           
static java.lang.String CMD_IDIV
           
static java.lang.String CMD_MOD
           
static java.lang.String CMD_MUL
           
static java.lang.String CMD_NEG
           
static java.lang.String CMD_POP
           
static java.lang.String CMD_ROLL
           
static java.lang.String CMD_SIN
           
static java.lang.String CMD_SQRT
           
static java.lang.String CMD_SUB
           
static java.lang.String CMD_X
           
protected  java.util.List<PSArithemticCommand> commands
           
protected  java.lang.String function
          The postscript function.
 
Constructor Summary
PSFunctionParser(java.lang.String fct)
          Creates and parser from postscript functions.
 
Method Summary
 double getY(double x)
           
 PSArithemticCommand identifyCommand(java.lang.String cmd)
           
 void parseFunction()
          Parses the function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

function

protected java.lang.String function
The postscript function.


commands

protected java.util.List<PSArithemticCommand> commands

CMD_MUL

public static final java.lang.String CMD_MUL
See Also:
Constant Field Values

CMD_ADD

public static final java.lang.String CMD_ADD
See Also:
Constant Field Values

CMD_SUB

public static final java.lang.String CMD_SUB
See Also:
Constant Field Values

CMD_SIN

public static final java.lang.String CMD_SIN
See Also:
Constant Field Values

CMD_COS

public static final java.lang.String CMD_COS
See Also:
Constant Field Values

CMD_DIV

public static final java.lang.String CMD_DIV
See Also:
Constant Field Values

CMD_IDIV

public static final java.lang.String CMD_IDIV
See Also:
Constant Field Values

CMD_MOD

public static final java.lang.String CMD_MOD
See Also:
Constant Field Values

CMD_NEG

public static final java.lang.String CMD_NEG
See Also:
Constant Field Values

CMD_EXCH

public static final java.lang.String CMD_EXCH
See Also:
Constant Field Values

CMD_CLEAR

public static final java.lang.String CMD_CLEAR
See Also:
Constant Field Values

CMD_DUP

public static final java.lang.String CMD_DUP
See Also:
Constant Field Values

CMD_POP

public static final java.lang.String CMD_POP
See Also:
Constant Field Values

CMD_ROLL

public static final java.lang.String CMD_ROLL
See Also:
Constant Field Values

CMD_SQRT

public static final java.lang.String CMD_SQRT
See Also:
Constant Field Values

CMD_EXP

public static final java.lang.String CMD_EXP
See Also:
Constant Field Values

CMD_ABS

public static final java.lang.String CMD_ABS
See Also:
Constant Field Values

CMD_FLOOR

public static final java.lang.String CMD_FLOOR
See Also:
Constant Field Values

CMD_CEILING

public static final java.lang.String CMD_CEILING
See Also:
Constant Field Values

CMD_COUNT

public static final java.lang.String CMD_COUNT
See Also:
Constant Field Values

CMD_X

public static final java.lang.String CMD_X
See Also:
Constant Field Values
Constructor Detail

PSFunctionParser

public PSFunctionParser(java.lang.String fct)
                 throws InvalidFormatPSFunctionException
Creates and parser from postscript functions.

Parameters:
fct - The function to parse.
Throws:
InvalidFormatPSFunctionException - If the function format is not valid.
Since:
3.0
Method Detail

getY

public double getY(double x)
            throws InvalidFormatPSFunctionException
Parameters:
x - The X-coordinate used to computre the Y using the function.
Returns:
The y value corresponding to the given X value.
Throws:
InvalidFormatPSFunctionException - If the function is not correct.

parseFunction

public void parseFunction()
                   throws InvalidFormatPSFunctionException
Parses the function.

Throws:
InvalidFormatPSFunctionException - If the function is not correct.

identifyCommand

public PSArithemticCommand identifyCommand(java.lang.String cmd)
                                    throws InvalidFormatPSFunctionException
Parameters:
cmd - The arithmetic command to analyse.
Returns:
The arithmetic instance corresponding to the given command.
Throws:
InvalidFormatPSFunctionException - If the function is not correct.
Since:
3.0