/*
 * FunctionInstance.java
 *
 * Created on March 7, 2006, 12:27 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package cz.pcland.functions;
import cz.pcland.ga.Population;
import java.awt.*;
import java.awt.event.*;
import cz.pcland.functions.lexan.*;
import cz.pcland.gavisualization.*;
import cz.pcland.functions.nodes.*;
import cz.pcland.functions.syntax.*;
import java.util.*;
import java.awt.geom.*;
import java.awt.font.*;
/**
 *
 * @author Petr Benhak
 * @version 1.1
 */
public class FunctionInstance {
    public Node node;
    public int from;
    public int to;
    String str;
    String varName;
    
    
    
    public int precision;
    
    /** 
     * Creates a new instance of FunctionInstance 
     * @param node Reference to the root of abstract syntax tree of given expression
     * @param from starts drawing function from this point
     * @param to ends drawing function at this point
     * @param precision Number of bits to represent definition scope
     */
    public FunctionInstance(Node node, int from, int to, String varName, int precision) {
        this.node = node;
        this.from = from;
        this.to = to;
        this.varName = varName;
        str = node.printSyntax(Priorities.LOWESTPRIORITY);
        this.precision = precision;
    }
    
   
    
    /**
     * Text representation of expression
     */
    public String toString(){
        return "<html> Function: "  + str + ", from: " + Operations.getColoredText(Color.ORANGE,String.valueOf(from)) + ", to: " + Operations.getColoredText(Color.ORANGE,String.valueOf(to)) + ", variable name: " + Operations.getColoredText(Color.ORANGE,varName) + ", Resolution: " + Operations.getColoredText(Color.ORANGE,String.valueOf(this.precision))  + "</html>";
    }
    
}
