/*
 * UnaryMinus.java
 *
 * Created on 2. prosinec 2005, 18:52
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package cz.pcland.functions.nodes;
import java.util.*;
import java.awt.*;
import cz.pcland.gavisualization.*;
/**
 *
 * @author petr
 */
public class UnaryMinus extends UnaryOperation{

    /** Creates a new instance of UnaryMinus */
    public UnaryMinus(Node node) {
        super(node);
    }
    
    public double evaluate(double varValue, String varName) {
        return -child.evaluate(varValue, varName);
    }
    
   
    public String print(int priority) {
        return "-" + this.child.print(Priorities.UNARYMINUS);
    }
    
    public String printSyntax(int priority) {
        if(priority > Priorities.UNARYMINUS) {    
           return Operations.getColoredText(Color.ORANGE, "-") + "(" + this.child.printSyntax(Priorities.UNARYMINUS) +")";
        }else {
           return "-" + this.child.printSyntax(Priorities.UNARYMINUS);
        }
    }
    
}
