Skip to content

Commit

Permalink
feat: Add delete connections
Browse files Browse the repository at this point in the history
  • Loading branch information
shahrukhqasim committed Oct 13, 2017
1 parent 2ffeee2 commit 26e5fa5
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,38 @@ public void drag(Point2D startPoint, Point2D endPoint, double scale) {
}

void select(boolean select, Vector<Box> boxes, double scale, Rectangle2D rectangle) {
for(Box box : boxes) {
for(Selectable box : boxes) {
box.select(rectangle, scale);
}
}

void selectConnections(boolean select, Vector<Connection> boxes, double scale, Rectangle2D rectangle) {
for(Selectable box : boxes) {
box.select(rectangle, scale);
}
}


private void dragReleasedWithoutConnection(Rectangle2D rectangle, double scale, MouseButton button) {
selectionBox.setBoundingBox(new Rectangle2D(0,0,0,0));
if (button == MouseButton.PRIMARY) {
// For OCR
select(true, this.boxesOcr.getBoxes(), scale, rectangle);
select(true, boxesCell.getBoxes(), scale, new Rectangle2D(0,0,0,0));
selectConnections(true, connections.getConnections(), scale, new Rectangle2D(0,0,0,0));
}
else if (button == MouseButton.SECONDARY) {
// For Cell boxes
select(true, boxesCell.getBoxes(), scale, rectangle);
select(true, boxesOcr.getBoxes(), scale, new Rectangle2D(0,0,0,0));
selectConnections(true, connections.getConnections(), scale, new Rectangle2D(0,0,0,0));
}
else if (button == MouseButton.MIDDLE) {
// For connections
selectConnections(true, connections.getConnections(), scale, rectangle);
select(true, boxesOcr.getBoxes(), scale, new Rectangle2D(0,0,0,0));
select(true, boxesCell.getBoxes(), scale, new Rectangle2D(0,0,0,0));

}
}

Expand Down Expand Up @@ -155,6 +171,15 @@ public void keyPressed(double scale, KeyCode keyCode) {
for (Box b:toBeDeleted) {
boxes.remove(b);
}
Vector<Connection> connections = this.connections.getConnections();
Vector<Connection> toBeDeletedConnections = new Vector<>();
for (Connection c : connections) {
if (c.isSelected())
toBeDeletedConnections.add(c);
}
for (Connection c : toBeDeletedConnections) {
connections.remove(c);
}
}

if (keyCode == KeyCode.C) {
Expand Down

0 comments on commit 26e5fa5

Please sign in to comment.