[Demonstration 1]

[Buggy Method]
@Override
public void mousePressed(MouseEvent ev) {
    requestFocus();
    Point2D.Double newLoc = new Point2D.Double(ev.getX() / getScreenScale(), ev.getY() / getScreenScale());
    if (shapeToPlace != null || shapesToPlace != null) {
        if (doSnap && gridSpacing > 0) {
            newLoc = toGrid(newLoc);
        }
        if (shapeToPlace != null) {
            // Set location of shape to location user clicked
            shapeToPlace.setPosition(newLoc);
            addShape(shapeToPlace);
            setSelected(shapeToPlace);
            shapeToPlace = null;
        } else {
            importShapes(shapesToPlace, newLoc);
            shapesToPlace = null;
        }
    } else if (ev.isControlDown()) {
        // Select shape and then do CTRL-Click on second shape to measure distance from origin to origin
        if (selected != null) {
            for (CADShape shape : shapes) {
                // Check for mouse pointing to shape
                if (shape.isPositionClicked(newLoc) || shape.isShapeClicked(newLoc)) {
                    double dx = shape.xLoc - selected.xLoc;
                    double dy = shape.yLoc - selected.yLoc;
                    itemInfo.setText(" dx: " + LaserCut.df.format(dx) + " in, dy: " + LaserCut.df.format(dy) + " in (" + LaserCut.df.format(inchesToMM(dx)) + " mm, " + LaserCut.df.format(inchesToMM(dy)) + " mm)");
                    measure1 = new Point2D.Double(selected.xLoc * SCREEN_PPI, selected.yLoc * SCREEN_PPI);
                    measure2 = new Point2D.Double(shape.xLoc * SCREEN_PPI, shape.yLoc * SCREEN_PPI);
                    showMeasure = true;
                    break;
                }
            }
        }
    } else if (ev.isShiftDown()) {
        if (selected != null) {
            /*
                Cases:
                  shape to add is in an existing group
                    remove shape from old group
                    delete old group if this leaves it with only one member
                    add shape to selected's group
                  shape to add is not in an existing group
                    add shape to selected's group
                  shape is selected shape
                    remove shape from its group
                    make one remaining member of group the new selected shape, or
                    delete group if this leaves it with only one member
               */
            CADShapeGroup selGroup = selected.getGroup();
            for (CADShape shape : shapes) {
                if (shape.isShapeClicked(newLoc)) {
                    pushToUndoStack();
                    CADShapeGroup shapeGroup = shape.getGroup();
                    if (shape == selected) {
                        // clicked shape is selected shape, so remove from group and
                        // assign remaining shape in group as selected shape
                        CADShape newSel;
                        if (selGroup != null) {
                            newSel = selGroup.removeFromGroup(shape);
                            setSelected(newSel);
                        }
                    } else {
                        // clicked shape is not selected shape
                        if (selGroup == null) {
                            // No group, so create one and add both shapes to it
                            selGroup = new CADShapeGroup();
                            selGroup.addToGroup(selected);
                            selGroup.addToGroup(shape);
                            setSelected(selected);
                            break;
                        } else {
                            if (selGroup.contains(shape)) {
                                // clicked shape in already in group, so remove it
                                selGroup.removeFromGroup(shape);
                                break;
                            } else {
                                if (shapeGroup != null) {
                                    // clicked was already in another group, so remove it from it
                                    shapeGroup.removeFromGroup(shape);
                                }
                                // Add clicked shape to selected group
                                selGroup.addToGroup(shape);
                                break;
                            }
                        }
                    }
                }
            }
        }
    } else {
        if (selected != null) {
            if (selected.isPositionClicked(newLoc)) {
                dragged = selected;
                showMeasure = false;
                return;
            }
            for (CADShape shape : shapes) {
                // Check for click and drag of shape's position
                if (shape.isPositionClicked(newLoc)) {
                    dragged = shape;
                    setSelected(shape);
                    itemInfo.setText("xLoc: " + dragged.xLoc + ", yLoc: " + dragged.yLoc);
                    showMeasure = false;
                    return;
                }
            }
        }
        CADShape procShape = null;
        for (CADShape shape : shapes) {
            // Check for selection or deselection of shapes
            if (shape.isShapeClicked(newLoc) || (shape instanceof CADReference && shape.isPositionClicked(newLoc))) {
                procShape = shape;
                break;
            }
        }
        if ((procShape == null || procShape == selected) && selected != null && selected.selectMovePoint(DrawSurface.this, newLoc, toGrid(newLoc))) {
            dragged = selected;
            repaint();
            return;
        }
        if (procShape != null) {
            pushToUndoStack();
            setSelected(procShape);
            itemInfo.setText(procShape.getInfo());
            showMeasure = false;
        } else {
            pushToUndoStack();
            setSelected(null);
            itemInfo.setText("");
            showMeasure = false;
            scrollPoint = newLoc;
            LaserCut.this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        }
    }
    repaint();
}

[Buggy Hunk]
if (shape.isShapeClicked(newLoc) || (shape instanceof CADReference && shape.isPositionClicked(newLoc)) ) {

[Patch]
if (shape.isShapeClicked(newLoc) || ((shape instanceof CADReference || shape instanceof CADShapeSpline)&& shape.isPositionClicked(newLoc)) ) {

[Demonstration 2]

[Buggy Method]
public List<Intersection> getEmptyNeighbors() {
    List<Intersection> emptyNeighbors = new ArrayList<Intersection>();
    int[] dx = { -1, 0, 1, 0 }, dy = { 0, -1, 0, 1 };
    assert dx.length == dy.length : "dx and dy should have the same length";
    for (int i = 0; i < dx.length - 1; i++) {
        int newX = x + dx[i];
        int newY = y + dy[i];
        if (goban.isInGoban(newX, newY)) {
            Intersection adjIntersection = goban.getIntersection(newX, newY);
            if (adjIntersection.isEmpty()) {
                emptyNeighbors.add(adjIntersection);
            }
        }
    }
    return emptyNeighbors;
}

[Buggy Hunk]
for (int i = 0; i < dx.length - 1; i++) {

[Patch]
for (int i = 0; i < dx.length; i++) {

[Demonstration 3]

[Buggy Method]
public ArrayList<Integer> pelaajaVoiSiirtaaRuutuihin(Pelaaja pelaaja, int lahtoruutu) {
    ArrayList<Integer> lista = new ArrayList<>();
    if (pelaaja.getMaali() == 0) {
        int i = lahtoruutu;
        int siirto = 0;
        while (true) {
            siirto++;
            int kohderuutu = lahtoruutu - siirto;
            if (siirto > 6) {
                break;
            } else if (kohderuutu <= 0) {
                kohderuutu = 0;
                if (this.nappulatKotialueella(pelaaja) && !lista.contains(kohderuutu)) {
                    lista.add(kohderuutu);
                }
                break;
            } else if (this.ruutuunVoiSiirtya(kohderuutu, pelaaja)) {
                lista.add(kohderuutu);
            }
        }
    } else {
        int i = lahtoruutu;
        int siirto = 0;
        while (true) {
            siirto++;
            int kohderuutu = siirto + lahtoruutu;
            if (siirto > 6) {
                break;
            } else if (kohderuutu > 25) {
                kohderuutu = 25;
                if (this.nappulatKotialueella(pelaaja) && !lista.contains(kohderuutu)) {
                    lista.add(kohderuutu);
                }
                break;
            } else if (this.ruutuunVoiSiirtya(kohderuutu, pelaaja)) {
                lista.add(kohderuutu);
            }
        }
    }
    return lista;
}

[Buggy Hunk]
} else if (kohderuutu > 25) {

[Patch]
} else if (kohderuutu >= 25) {