Description
do everything in the instructions file.
Note: the code of (Circle, ConvexPolygon, Point, Shape) files have done, there are other four files have to solve.
However, I could not attach the java files here! let me know how I can sent it to you.
Unformatted Attachment Preview
Purchase answer to see full attachment
Explanation & Answer
Just keeping all files in one place:Feel free to ask any doubts you have, or bugs you encounter...
package guiGen;
import
import
import
import
import
java.awt.Color;
java.awt.Graphics;
java.util.ArrayList;
javax.swing.JPanel;
java.awt.Polygon;
class ShapesPanel extends JPanel {
private ShapesGUI gui;
ShapesPanel(final ShapesGUI gui) {
this.gui = gui;
}
@Override
public void paintComponent(Graphics g) {
g.setColor(Color.BLACK);
// TODO: change the implementation
//All Shapes
ArrayList shapes = this.gui.getShapes();
for (Shape shape : shapes) {
if (shape instanceof Circle) {
// draw a circle
Circle circle = (Circle) shape;
Point center = circle.getCenter();
int radius = (int) circle.getRadius();
int guiX = (int) (center.getX());
int guiY = (int) (center.getY());
g.fillOval(guiX, guiY, 4, 4);
g.drawOval(guiX - radius / 2, guiY - radius / 2, radius,
radius);
} else {
// draw a polygon===============================
ConvexPolygon cp = (ConvexPolygon) shape;
//Rotating 10 deg, every time the polygon is used
cp.rotate();
Point center = cp.getCenter();
int guiX = (int) (center.g...