Joomla Vorlagen by Website Hosting

PJ1 - 5th laboratory

1. Use the class Mover in GUI - implement methods moveShape and doMoving; let shape classes implement interface Movable.

pl1 lab05 01

Task 01

2. Create a class BorderedEllipse that will extend the class Ellipse. It will draw an ellipse with a border of a given color. Override the method paint and create suitable constructors.


pl1 lab05 02

Task 02

3. Allows comparing of objects of the class MyDate according of its instance variables – it is necessary to override the method equals.

pl1 lab05 03

Task 03

4. Create an abstract class AbstractShape that will contain common features of shapes - position (it will also implement Movable) and that is Paintable (method paint remain abstract) - shapes will inherit the abstract class.


pl1 lab05 04

Task 04

5. Create interface Resizable that allows to get dimension (width, height) and set it. Create and interface Transformable, that will be Resizable and Movable.

pl1 lab05 05

Task 05

Solution(task01 -04):


Create a class Transformer  whose instances will work with Transformable objects by using the transform method, which gets the object for transformation, the coordinates, and the scaling factor (a double value that, if it is less than 1 then it will shrink) as a parameter. This method then animate the object movement along with a smooth zoom to the desired factor.

Bonus (for 1 point): Use the Transformer class in the GUI - create a button and edit box to enter the zoom factor. Next, create a button handler and use Transformer on the new thread - see using of the Mover (Task 2).

 Other references