Answered step by step
Verified Expert Solution
Question
1 Approved Answer
package edu.luc.etl.cs313.android.shapes.model; import java.util.List; /** * A shape visitor for calculating the bounding box, that is, the smallest * rectangle containing the shape. The resulting
package edu.luc.etl.cs313.android.shapes.model; import java.util.List; /** * A shape visitor for calculating the bounding box, that is, the smallest * rectangle containing the shape. The resulting bounding box is returned as a * rectangle at a specific location. */ public class BoundingBox implements VisitorFill on Polygon method{ // TODO entirely your job (except onCircle) @Override public Location onCircle(final Circle c) { final int radius = c.getRadius(); return new Location(-radius, -radius, new Rectangle(2 * radius, 2 * radius)); } @Override public Location onFill(final Fill f) { return f.getShape().accept(this); } @Override public Location onGroup(final Group g) { // Fill this method } @Override public Location onLocation(final Location l) { Location location = l.shape.accept(this); return new Location(l.x+location.x, l.y+location.y, location.shape); } @Override public Location onRectangle(final Rectangle r) { return new Location(0, 0, new Rectangle(r.getWidth(), r.getHeight())); } @Override public Location onStroke(final Stroke c) { return c.getShape().accept(this); } @Override public Location onOutline(final Outline o) { return o.getShape().accept(this); } @Override public Location onPolygon(final Polygon s) { // Fill this method } }
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