# S.Chekanov

from java.awt import Color,Font
from java.util import Random
from jhplot  import HPlot,P1D
from math  import sqrt;

c1 = HPlot("Canvas",600,400,1, 1)
c1.visible(1)
c1.setAutoRange()


c1.setGTitle("Operations with data", Color.blue) #put title
c1.viewHisto(0) # make sure starts from 0

# fill first data set
p1= P1D("data1")
p1.add(10,100,5,5)
p1.add(20,50,5,5)
p1.add(30,80,5,5)

print p1.dimension()

# now add some random numbers
rand = Random()
for i in range(100):
        p1.add(10*rand.nextGaussian(), 20*rand.nextGaussian(),0,0)

# make copies of this object
pp1=p1.copy()
pp2=p1.copy()
pp3=p1.copy()

c1.draw(p1)

# now scale the original object in Y
pp1.operScale(1,0.1)
pp1.setTitle("scaled in Y")
pp1.setColor(Color.red)

# now scale in X
pp2.operScale(0,0.1)
pp2.setTitle("scaled in X")
pp2.setColor(Color.green)

# now scale in X
pp3.operSmooth(0,1,4)
pp3.setTitle("smoothed")
pp3.setColor(Color.gray)

c1.draw(pp1)
c1.draw(pp2)
c1.draw(pp3)
