Skip to content

Commit

Permalink
Add clustering of entities
Browse files Browse the repository at this point in the history
When moving entities to avoid intersection, the Hass entities are first
grouped together into clusters. Then these clusters are separated from
 each other instead of the Hass entities individually.
  • Loading branch information
DigiLive committed Jan 2, 2025
1 parent 3f76eb8 commit c820130
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/com/shmuelzon/HomeAssistantFloorPlan/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -1067,12 +1067,17 @@ private void separateStateIcons(Set<? extends Entity> entities) {
}

private void moveEntityIconsToAvoidIntersection() {
List<ClusterEntity> clusters = clusterEntities(homeAssistantEntities.values());

for (int i = 0; i < 100; i++) {
List<Set<Entity>> intersectingStateIcons = findIntersectingStateIcons();
if (intersectingStateIcons.isEmpty())
List<Set<Entity>> intersectingStateIcons = findIntersectingStateIcons(clusters);
if (intersectingStateIcons.isEmpty()) {
break;
for (Set<Entity> set : intersectingStateIcons)
}

for (Set<Entity> set : intersectingStateIcons) {
separateStateIcons(set);
}
}
}
};
}

0 comments on commit c820130

Please sign in to comment.