Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Zest 2.0] Cleanup compiler warnings in HorizontalShiftAlgorithm #506

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,31 @@ public void applyLayout(boolean clean) {
if (!clean) {
return;
}
ArrayList rowsList = new ArrayList();
List<List<EntityLayout>> rowsList = new ArrayList<>();
EntityLayout[] entities = context.getEntities();

for (EntityLayout element : entities) {
addToRowList(element, rowsList);
}

Collections.sort(rowsList, (o1, o2) -> {
List a0 = (List) o1;
List a1 = (List) o2;
EntityLayout entity0 = (EntityLayout) a0.get(0);
EntityLayout entity1 = (EntityLayout) a1.get(0);
Collections.sort(rowsList, (a0, a1) -> {
EntityLayout entity0 = a0.get(0);
EntityLayout entity1 = a1.get(0);
return (int) (entity0.getLocation().y - entity1.getLocation().y);
});

Comparator entityComparator = (o1,
o2) -> (int) (((EntityLayout) o1).getLocation().y - ((EntityLayout) o2).getLocation().y);
Comparator<EntityLayout> entityComparator = (o1, o2) -> (int) (o1.getLocation().y - o2.getLocation().y);
DisplayIndependentRectangle bounds = context.getBounds();
int heightSoFar = 0;

for (Object element : rowsList) {
List currentRow = (List) element;
for (List<EntityLayout> currentRow : rowsList) {
Collections.sort(currentRow, entityComparator);

int i = 0;
int width = (int) (bounds.width / 2 - currentRow.size() * 75);

heightSoFar += ((EntityLayout) currentRow.get(0)).getSize().height + VSPACING;
for (Object element2 : currentRow) {
EntityLayout entity = (EntityLayout) element2;
heightSoFar += currentRow.get(0).getSize().height + VSPACING;
for (EntityLayout entity : currentRow) {
DisplayIndependentDimension size = entity.getSize();
i++;
entity.setLocation(width + 10 * i + size.width / 2, heightSoFar + size.height / 2);
Expand All @@ -86,19 +81,18 @@ public void setLayoutContext(LayoutContext context) {
this.context = context;
}

private void addToRowList(EntityLayout entity, ArrayList rowsList) {
private static void addToRowList(EntityLayout entity, List<List<EntityLayout>> rowsList) {
double layoutY = entity.getLocation().y;

for (Object element : rowsList) {
List currentRow = (List) element;
EntityLayout currentRowEntity = (EntityLayout) currentRow.get(0);
for (List<EntityLayout> currentRow : rowsList) {
EntityLayout currentRowEntity = currentRow.get(0);
double currentRowY = currentRowEntity.getLocation().y;
if (layoutY >= currentRowY - DELTA && layoutY <= currentRowY + DELTA) {
currentRow.add(entity);
return;
}
}
List newRow = new ArrayList();
List<EntityLayout> newRow = new ArrayList<>();
newRow.add(entity);
rowsList.add(newRow);
}
Expand Down
Loading