Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 1: 1- Download the code source of the open source application that you find on the following link: https://github.com/gre/shape-editor., 2- Open the project on
Part 1:
1- Download the code source of the open source application that you find on the following link: https://github.com/gre/shape-editor.,
2- Open the project on an IDE (Eclipse, NetBeans or inttellij...etc),
3- Test the program by running the class Window.java to try the program (see figures
B, C and D) below that show some screen shots of the use of this application),
Part 2:
We want to extend the application in a way that the user could draw a complete picture that contains a rectangle, a circle and a triangle by only one click.
To realize this goal, you are asked to use the composite design pattern (see Fig.A) as follow:
- Rename the existing method called draw(Graphics gx) into drawOriginal(Graphics gx),
- Create a method draw(Graphics gx) in the interface Figure,
- Create a java class Picture that extends the existing interface Figure and that could
be composed of other figures (Rectangle, Triangle, Circle...) that implement the
interface Figure,
- The class Picture will implement the added method draw(Graphics gx),
- In the class Rectangle, Circle, and Triangle (or Polygon) implement the added
method draw(Graphics gx) and choose the dimensions and color that will be used to
draw or fill these graphics,
- Add a JButton in the GUI of the application called drawPicture. When the user clicks
on this button a picture containing three shapes (a Circle, a Triangle and a Rectangle)
will be directly drawn (see Fig.AA).
- The event handling of clicking on the button drawPicture is implemented in the class
Window and in the method actionPerformed the class composite Picture will be instantiated and uses methods add and remove to manipulate the figures that could be added to the composite such as Rectangle, Triangle or Circle.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started