Class: TracePlot

Inherits:
Object
  • Object
show all
Defined in:
lib/trace_plot/trace_plot.rb

Instance Method Summary collapse

Constructor Details

#initialize(value, params) ⇒ TracePlot

Returns a new instance of TracePlot.



33
34
35
36
# File 'lib/trace_plot/trace_plot.rb', line 33

def initialize(value,params)
  @value=check_val(value)
  @params=self.check_par(params)
end

Instance Method Details

#check_par(params) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/trace_plot/trace_plot.rb', line 38

def check_par(params)
        hash = Hash.new
  permitted = ["title","vertical","width","height","file_name"]
        keys = params.keys
        keys.each{ |key|
                 if permitted.include?(key)==false
                        raise "Error : Permitted key are title,vertical,width,height,file-name"
                  end
        }
  
  if params["title"]==nil
                hash["title"]="A sample Graph"
        else
                 hash["title"]=params["title"]
        end

  if params["vertical"]==nil
                hash["vertical"]=true
          else
                hash["vertical"]=params["vertical"]
        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

#getParamsObject



86
87
88
# File 'lib/trace_plot/trace_plot.rb', line 86

def getParams
        @params
end

#getValueObject



82
83
84
# File 'lib/trace_plot/trace_plot.rb', line 82

def getValue
  @value 
end

#saveObject



91
92
93
94
95
96
97
# File 'lib/trace_plot/trace_plot.rb', line 91

def save
  begin
          a = Java::ComDomain::clocomics
            a.save_trace(self.getValue,self.getParams)
  rescue Exception => ex
  end
end

#viewObject



98
99
100
101
102
103
104
105
106
# File 'lib/trace_plot/trace_plot.rb', line 98

def view
   begin
                       a = Java::ComDomain::clocomics
                       a.view_trace(self.getValue,self.getParams)
               rescue Exception => ex
               end


end