Skip to content

Commit

Permalink
fixes regions not being removed in scenarios with many regions
Browse files Browse the repository at this point in the history
  • Loading branch information
crissNb committed Mar 10, 2024
1 parent 1988169 commit 206c7af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/gecko/viewmodel/EditorViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public void updateRegions() throws ModelException {
.map(element -> (StateViewModel) element)
.collect(Collectors.toSet());
for (RegionViewModel regionViewModel : regionViewModels) {
regionViewModel.clearStates();
for (StateViewModel stateViewModel : stateViewModels) {
regionViewModel.checkStateInRegion(stateViewModel);
regionViewModel.updateTarget();
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/gecko/viewmodel/RegionViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public void removeState(@NonNull StateViewModel state) {
statesProperty.remove(state);
}

public void clearStates() {
statesProperty.clear();
}

@Override
public Object accept(@NonNull PositionableViewModelElementVisitor visitor) {
return visitor.visit(this);
Expand All @@ -86,7 +90,7 @@ public Color getColor() {
}

/**
* Checks if the given state is in the region and adds it to the region if it is or removes it if it is not.
* Checks if the given state is in the region and adds it to the region if it is.
*
* @param state the state to check
*/
Expand All @@ -98,8 +102,6 @@ public void checkStateInRegion(StateViewModel state) {
state.getSize().getY());
if (regionBound.intersects(stateBound)) {
addState(state);
} else {
removeState(state);
}
}

Expand Down

0 comments on commit 206c7af

Please sign in to comment.