001package jmri.jmrix.internal;
002
003import javax.annotation.Nonnull;
004import jmri.Light;
005import jmri.NamedBean;
006import jmri.implementation.AbstractVariableLight;
007import jmri.util.PreferNumericComparator;
008
009/**
010 * Implement a LightManager for "Internal" (virtual) lights.
011 *
012 * @author Bob Jacobsen Copyright (C) 2009
013 */
014public class InternalLightManager extends jmri.managers.AbstractLightManager {
015
016    public InternalLightManager(InternalSystemConnectionMemo memo) {
017        super(memo);
018    }
019
020    /**
021     * Create and return an internal (no layout connection) Light
022     */
023    @Override
024    protected Light createNewLight(@Nonnull String systemName, String userName) {
025        return new AbstractVariableLight(systemName, userName) {
026
027            @Override
028            protected void sendIntensity(double intensity) {
029                // nothing to do
030            }
031
032            @Override
033            protected void sendOnOffCommand(int newState) {
034                // nothing to do
035            }
036
037            @Override
038            protected int getNumberOfSteps() {
039                return 100;
040            }
041
042            @Override
043            public int compareSystemNameSuffix(@Nonnull String suffix1, @Nonnull String suffix2, NamedBean n) {
044                return (new PreferNumericComparator()).compare(suffix1, suffix2);
045            }
046        };
047    }
048
049    /**
050     * {@inheritDoc}
051     */
052    @Override
053    @Nonnull
054    public InternalSystemConnectionMemo getMemo() {
055        return (InternalSystemConnectionMemo) memo;
056    }
057
058    @Override
059    public boolean supportsVariableLights(@Nonnull String systemName) {
060        return true;
061    }
062
063    @Override
064    public boolean allowMultipleAdditions(@Nonnull String systemName) {
065        return true;
066    }
067
068    /**
069     * {@inheritDoc}
070     */
071    @Override
072    public String getEntryToolTip() {
073        return Bundle.getMessage("AddOutputEntryToolTip");
074    }
075
076}