use of de.mossgrabers.framework.graphics.canvas.component.ListComponent in project DrivenByMoss by git-moss.
the class AbstractGraphicDisplay method addListElement.
/**
* {@inheritDoc}
*/
@Override
public void addListElement(final String[] items, final boolean[] selected) {
final List<Pair<String, Boolean>> menu = new ArrayList<>();
for (int i = 0; i < items.length; i++) menu.add(new Pair<>(items[i], Boolean.valueOf(selected[i])));
this.addElement(new ListComponent(menu));
}
use of de.mossgrabers.framework.graphics.canvas.component.ListComponent in project DrivenByMoss by git-moss.
the class AbstractGraphicDisplay method addListElement.
/**
* {@inheritDoc}
*/
@Override
public void addListElement(final int displaySize, final String[] elements, final int selectedIndex) {
final List<Pair<String, Boolean>> menu = new ArrayList<>();
final int startIndex = Math.max(0, Math.min(selectedIndex, elements.length - displaySize));
for (int i = 0; i < displaySize; i++) {
final int pos = startIndex + i;
final String itemName = pos < elements.length ? elements[pos] : "";
menu.add(new Pair<>(itemName, Boolean.valueOf(pos == selectedIndex)));
}
this.addElement(new ListComponent(menu));
}
Aggregations