Skip to content

Commit 00860bb

Browse files
committed
Abstract ConstructLineSegment by providing subclasses addLineSegment method to add a line segment
1 parent 28ec1be commit 00860bb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/actions/ConstructLineSegmentAction.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,25 @@ public void performAction() {
5959

6060
//construct line segment
6161
LineSegment lineSegment = new LineSegment((SimplePoint)(items.get(0)), (SimplePoint)(items.get(1)));
62+
63+
64+
addLineSegment(lineSegment);
65+
}
66+
/**
67+
* This method updates the panel's list of paint components and selection after a line segment is added
68+
* Subclasses should call this method to update the panel when customizing the addition of a line segment
69+
*
70+
* @param lineSegment the lineSegment to be added to the painting panel
71+
*/
72+
protected void addLineSegment(LineSegment lineSegment) {
73+
6274
//add to panel
6375
panel.addPaintComponent(lineSegment);
6476

6577
//change selection
6678
panel.getSelectTool().clearSelection();
6779
panel.getSelectTool().selectComponent(lineSegment);
6880
panel.repaint();
69-
70-
7181
}
7282

7383
@Override

0 commit comments

Comments
 (0)