Skip to content

Package: Slot

Slot

nameinstructionbranchcomplexitylinemethod
Slot(Point, Device)
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
Slot(Point, Device, VariableAssignment)
M: 36 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
accept(ItemVisitor)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
acceptConnectVisitor(ConnectVisitor)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
draw(Graphics)
M: 41 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
giveImage()
M: 18 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
markAsSelected(Graphics)
M: 14 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package networkconfigurator.item;
2:
3: import java.awt.Color;
4: import java.awt.Graphics;
5: import java.awt.Point;
6: import java.awt.Rectangle;
7: import java.awt.image.BufferedImage;
8: import java.io.File;
9: import java.io.IOException;
10:
11: import javax.imageio.ImageIO;
12:
13: import model.assignment.VariableAssignment;
14: import networkconfigurator.DetailBarLabel;
15: import networkconfigurator.DetailBarPropertyEntry;
16: import networkconfigurator.DetailDrawPropertyEntry;
17:
18: /**
19: * Slot Node.
20: */
21: public class Slot extends Adapter {
22:         /**
23:          * Constructor.
24:          *
25:          * @param p
26:          * the point;
27:          * @param owner
28:          * the owner
29:          */
30:         public Slot(final Point p, final Device owner) {
31:                 this.setPoint(p);
32:                 setBoundary();
33:                 this.setName("Slot");
34:                 this.setOwner(owner);
35:         }
36:
37:         /**
38:          * Constructor with name.
39:          *
40:          * @param p
41:          * the point.
42:          * @param owner
43:          * the owner
44:          * @param name
45:          * the name of the slot.
46:          */
47:         public Slot(final Point p, final Device owner, final VariableAssignment name) {
48:                 this(p, owner);
49:                 this.setName(name.getValue());
50:                 this.getPropertyBar().add(new DetailBarPropertyEntry(new DetailBarLabel("Name")));
51:                 this.getPropertyBar().add(new DetailBarPropertyEntry(name));
52:                 this.getPropertyDraw().add(new DetailDrawPropertyEntry(name));
53:         }
54:
55:         @Override
56:         public void markAsSelected(final Graphics g) {
57:                 final Rectangle boundary = getBoundary();
58:                 g.drawOval(boundary.x, boundary.y, boundary.width, boundary.height);
59:         }
60:
61:         @Override
62:         public BufferedImage giveImage() {
63:                 try {
64:                         return ImageIO.read(new File(NcNodeConstants.PACKAGE_ICONS + "slot.png"));
65:                 } catch (final IOException e) {
66:                         e.printStackTrace();
67:                 }
68:                 return null;
69:         }
70:
71:         @Override
72:         public void accept(final ItemVisitor nodeVisitor) {
73:                 nodeVisitor.slot(this);
74:         }
75:
76:         @Override
77:         public void draw(final Graphics g) {
78:                 final BufferedImage image = giveImage();
79:
80:                 g.setColor(Color.BLACK);
81:                 final Rectangle b = getBoundary();
82:                 g.drawString(this.getName(), b.x, b.y);
83:                 g.drawImage(image, getBoundary().x, getBoundary().y, b.width, b.height, null);
84:
85:•                if (this.getSelected()) {
86:                         markAsSelected(g);
87:                 }
88:                 notifyObserver();
89:
90:         }
91:
92:         @Override
93:         public void acceptConnectVisitor(final ConnectVisitor visitor) {
94:                 visitor.slot(this);
95:         };
96:
97: }