Search in sources :

Example 1 with ListComponent

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));
}
Also used : ArrayList(java.util.ArrayList) ClipListComponent(de.mossgrabers.framework.graphics.canvas.component.ClipListComponent) ListComponent(de.mossgrabers.framework.graphics.canvas.component.ListComponent) Pair(de.mossgrabers.framework.utils.Pair)

Example 2 with ListComponent

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));
}
Also used : ArrayList(java.util.ArrayList) ClipListComponent(de.mossgrabers.framework.graphics.canvas.component.ClipListComponent) ListComponent(de.mossgrabers.framework.graphics.canvas.component.ListComponent) Pair(de.mossgrabers.framework.utils.Pair)

Aggregations

ClipListComponent (de.mossgrabers.framework.graphics.canvas.component.ClipListComponent)2 ListComponent (de.mossgrabers.framework.graphics.canvas.component.ListComponent)2 Pair (de.mossgrabers.framework.utils.Pair)2 ArrayList (java.util.ArrayList)2