private Figure findConnectableFigure(int x, int y, Drawing drawing) { FigureEnumeration fe = drawing.figuresReverse(); while (fe.hasNextFigure()) { Figure figure = fe.nextFigure(); if (!figure.includes(getConnection()) && figure.canConnect() && figure.containsPoint(x, y)) { return figure; } } return null; }
private Figure findConnectableFigure(int x, int y, Drawing drawing) { FigureEnumeration k = drawing.figuresReverse(); while (k.hasMoreElements()) { Figure figure = k.nextFigure(); if (!figure.includes(getConnection()) && figure.canConnect()) { if (figure.containsPoint(x, y)) { return figure; } } } return null; }