Question: 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 Visitor
{ // 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 } }
Fill onGroup method
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock

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 Visitor