step() is a function in that Python code. So you should make it a function in Java too! 
That step() function relies on a method called rgb_to_hsv() from a class called colorsys. 
You’re gonna need to find a corresponding Java library which does the same thing as that method. 
Maybe Java’s class ColorSpace from package java.awt.color w/ its method fromRGB() can do that: 
Docs.Oracle.com/javase/10/docs/api/java/awt/color/ColorSpace.html#fromRGB(float[])