OO Programming with Java


Animations

(continuation of drawing tool)

  1. Define the Timer component presented in the course.
  2. By considering properties of a circle [x,y,r] as a standard vector, add in Circle the operators plus(Circle):Circle, minus(Circle):Circle and mult(value):Circle.
  3. Next, define an Interpolator having three attributes called start, end and current that are Circle, and three operations: next():Circle, hasNext():boolean and update.
    At each call of the next operation, current is updated with:
    current=current + (end-start)/10.
    update is simply if(hasNext()) next();
  4. Create an interface Element (Circle and Interpolator both implements this interface) and change in the application Circle to Element.
    Adapt the code consequently (eg. add required operations into Element).
    For Interpolator, delegate all the operations to current circle.
    Also add an update operation into Element.
  5. Add a timer to the application and add the application has listener.
    The tic event then simply update all the elements and do a repaint.
  6. By using java.beans.XMLEncoder/Decoder, define a way to easily edit application's configuration.

source