The JUnit5 framework shows the following features: (Click all that apply.)
A bag is like a set, except that each element can occur multiple times. As with a set, order doesn't matter. What must you do to add a Bag
class to the Java collections framework? Click all that apply.
Bag
implement Collection
Bag
extend AbstractCollection
size
and iterator
methodscount
method to the Collection
interface to count how many times an element is contained in the bagWhy does the graph editor framework use the Prototype pattern? Click all that apply.
lab14
subdirectory of your personal repo, the other submits a file report.txt
in the lab14
subdirectory of your personal repo.ch08/graphed2
directory into your lab14
directory, Then make an Eclipse project from existing sources with the files in ~/lab14
.SimpleGraph
and SimpleGraphEditor
to NetworkGraph
and NetworkGraphEditor
.setSize
method to CircleNode
. PersonNode
that extends CircleNode
. Supply a default constructor that sets the superclass color to white and the size to 40. Add a field imageURL
, and use Ctrl+Space to generate a getter and setter for it.NetworkGraph
, change the prototypes so you no longer have the circle nodes but instead have one PersonNode
.public class PersonNode { public void setImageURL() { ... try { icon = new ImageIcon(new URL(imageURL)); } catch (IOException ex) { } } private ImageIcon icon; }
paintIcon
method of the ImageIcon
. You'll need to find the bounds to put it in the right place. What did you do?PersonNode
isn't blank but uses a default icon such as this one: CircularNode
and the line attachments are at the circle boundary. Do this:
Shape oldClip = g2.getClip(); g2.setClip(new Ellipse2D.Double(...)); Paint g2.setClip(oldClip);
ImageIcon icon
field with a field Image image
. In setImageURL
, call
image = new ImageIcon(new URL(imageURL)).getImage();In the
draw
method, draw the image like this:
double width = image.getWidth(null); double height = image.getHeight(null); Rectangle2D bounds = getBounds(); double scale = Math.min(bounds.getWidth() / width, bounds.getHeight() / height); width = scale * width; height = scale * height; g2.drawImage(image, (int) (bounds.getX() + bounds.getWidth() - width), (int) (bounds.getY() + bounds.getHeight() - height), (int) width, (int) height, null);What does this code do?