class FunctionPlot

Public Class Methods

new(function,min,max,params) click to toggle source
# File lib/function_plot/function_plot.rb, line 2
def initialize(function,min,max,params)
        @params=self.check_par(params)
        @function=function
        @min=min
        @max=max
end

Public Instance Methods

check_par(params) click to toggle source
# File lib/function_plot/function_plot.rb, line 9
def check_par(params)
        hash = Hash.new
        permitted = ["title","x_label","y_label","legend","width","height","file_name"]
        keys = params.keys
        keys.each{ |key|
                 if permitted.include?(key)==false
                        raise "Error : Permitted key are title,x_label,y_label,legend,width,height,file_name"
                end
        }
        
        if params["title"]==nil
                hash["title"]="A sample Graph"
        else
                 hash["title"]=params["title"]
        end

        if params["x_label"]==nil
                hash["x_label"]="Categories"
        else
                 hash["x_label"]=params["x_label"]
        end

        if params["y_label"]==nil
                hash["y_label"]="Values"
        else
                hash["y_label"]=params["y_label"]
        end


       if params["legend"]==nil
                hash["legend"]=false
        else
                hash["legend"]=params["legend"]
        end
        

        if params["width"]==nil
                hash["width"]=1500
        else
                hash["width"]=params["width"]
        end

        if params["height"]==nil
                hash["height"]=800
        else
                hash["height"]=params["height"]
        end

        if params["file_name"]==nil
                hash["file_name"]="sample.jpg"
        else
                hash["file_name"]=params["file_name"]
        end

        params_map = HashMap.new(hash)
        return params_map
end
getFunction() click to toggle source
# File lib/function_plot/function_plot.rb, line 67
def getFunction
        @function
end
getMax() click to toggle source
# File lib/function_plot/function_plot.rb, line 75
def getMax
        @max
end
getMin() click to toggle source
# File lib/function_plot/function_plot.rb, line 71
def getMin
        @min 
end
getParams() click to toggle source
# File lib/function_plot/function_plot.rb, line 79
def getParams
        @params
end
save() click to toggle source
# File lib/function_plot/function_plot.rb, line 84
def save
        begin
                a = Java::ComDomain::clocomics
                a.save_function(self.getFunction,self.getMin,self.getMax,self.getParams)
        rescue Exception => ex
        end
end
view() click to toggle source
# File lib/function_plot/function_plot.rb, line 91
def view
         begin
                a = Java::ComDomain::clocomics
                a.view_function(self.getFunction,self.getMin,self.getMax,self.getParams)
        rescue Exception => ex
        end


end