Search in sources :

Example 1 with TileEventListener

use of eu.hansolo.tilesfx.events.TileEventListener in project tilesfx by HanSolo.

the class Tile method registerListeners.

private void registerListeners() {
    disabledProperty().addListener(o -> setOpacity(isDisabled() ? 0.4 : 1));
    valueProperty().addListener((o, ov, nv) -> oldValue.set(ov.doubleValue()));
    currentValueProperty().addListener(o -> {
        double currentValue = getCurrentValue();
        if (currentValue > getMaxValue()) {
            fireTileEvent(MAX_VALUE_EXCEEDED);
        } else if (currentValue < getMinValue()) {
            fireTileEvent(MIN_VALUE_UNDERRUN);
        } else {
            fireTileEvent(VALUE_IN_RANGE);
        }
    });
    showing.addListener((o, ov, nv) -> {
        if (nv) {
            while (tileEventQueue.peek() != null) {
                TileEvent event = tileEventQueue.poll();
                for (TileEventListener listener : tileEventListeners) {
                    listener.onTileEvent(event);
                }
            }
        }
    });
}
Also used : TileEvent(eu.hansolo.tilesfx.events.TileEvent) TileEventListener(eu.hansolo.tilesfx.events.TileEventListener)

Aggregations

TileEvent (eu.hansolo.tilesfx.events.TileEvent)1 TileEventListener (eu.hansolo.tilesfx.events.TileEventListener)1