Search in sources :

Example 1 with FrameworkException

use of de.mossgrabers.framework.utils.FrameworkException in project DrivenByMoss by git-moss.

the class FeatureGroupManager method setTemporary.

/**
 * Set the active feature group. If the feature group to activate is only temporary, calling
 * restore sets back the previous active one.
 *
 * @param featureGroupID The ID of the feature group to activate
 * @param syncSiblings Sync changes to siblings if true
 */
private void setTemporary(final E featureGroupID, final boolean syncSiblings) {
    if (featureGroupID == null)
        throw new FrameworkException("Attempt to set the temporary feature group to null.");
    // Do nothing if already active
    if (this.isActive(featureGroupID))
        return;
    // Deactivate the current temporary or active feature group
    final F deactivate = this.getActive();
    if (deactivate != null)
        deactivate.onDeactivate();
    // Activate the new temporary feature group
    this.temporaryID = featureGroupID;
    this.get(this.temporaryID).onActivate();
    if (syncSiblings)
        this.connectedManagers.forEach(sibling -> sibling.setActive(featureGroupID, false));
    this.notifyObservers(this.activeID, this.temporaryID);
}
Also used : FrameworkException(de.mossgrabers.framework.utils.FrameworkException) List(java.util.List) EnumMap(java.util.EnumMap) Map(java.util.Map) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) FrameworkException(de.mossgrabers.framework.utils.FrameworkException)

Example 2 with FrameworkException

use of de.mossgrabers.framework.utils.FrameworkException in project DrivenByMoss by git-moss.

the class AbstractMode method setParameterProvider.

/**
 * Set the parameters controlled by this mode if used with the given button combination.
 *
 * @param buttonID The ID of the button which can activate the given parameters
 * @param parameterProvider Interface to get a number of parameters
 */
protected void setParameterProvider(final ButtonID buttonID, final IParameterProvider parameterProvider) {
    if (this.controls.size() != parameterProvider.size())
        throw new FrameworkException("Number of knobs must match the number of parameters!");
    if (buttonID == null) {
        this.defaultParameterProvider = parameterProvider;
        return;
    }
    final IHwButton button = this.surface.getButton(buttonID);
    if (button == null)
        throw new FrameworkException("Attempt to set parameters for non-existing button " + buttonID + "!");
    this.parameterProviders.put(buttonID, parameterProvider);
    button.addEventHandler(ButtonEvent.DOWN, event -> this.bindControls());
    button.addEventHandler(ButtonEvent.UP, event -> this.bindControls());
}
Also used : FrameworkException(de.mossgrabers.framework.utils.FrameworkException) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton)

Example 3 with FrameworkException

use of de.mossgrabers.framework.utils.FrameworkException in project DrivenByMoss by git-moss.

the class LightInfo method setColors.

/**
 * Set all pad info values at once.
 *
 * @param color The color
 * @param blinkColor The new blink color
 * @param fast True to blink fast
 */
public void setColors(final int color, final int blinkColor, final boolean fast) {
    if (color < 0 || color > 127)
        throw new FrameworkException("color must be in the range of 0..127.");
    if (blinkColor < -1 || blinkColor > 127)
        throw new FrameworkException("blinkColor must be in the range of 0..127 or -1 for off.");
    this.color = color;
    this.blinkColor = blinkColor;
    this.fast = fast;
    this.encode();
}
Also used : FrameworkException(de.mossgrabers.framework.utils.FrameworkException)

Example 4 with FrameworkException

use of de.mossgrabers.framework.utils.FrameworkException in project DrivenByMoss by git-moss.

the class AbstractSessionView method drawSessionGrid.

/**
 * Draw a session grid, where each pad stands for a clip.
 *
 * @param ignoreFlipCheck True to ignore the check for same columns and rows
 */
protected void drawSessionGrid(final boolean ignoreFlipCheck) {
    final boolean flipSession = this.surface.getConfiguration().isFlipSession();
    if (flipSession && this.columns != this.rows && !ignoreFlipCheck)
        throw new FrameworkException("Session flip is only supported for same size of rows and columns!");
    final ITrackBank tb = this.model.getCurrentTrackBank();
    for (int x = 0; x < this.columns; x++) {
        final ITrack t = tb.getItem(x);
        final ISlotBank slotBank = t.getSlotBank();
        for (int y = 0; y < this.rows; y++) this.drawPad(slotBank.getItem(y), flipSession ? y : x, flipSession ? x : y, t.isRecArm());
    }
}
Also used : ISlotBank(de.mossgrabers.framework.daw.data.bank.ISlotBank) FrameworkException(de.mossgrabers.framework.utils.FrameworkException) ITrack(de.mossgrabers.framework.daw.data.ITrack) ITrackBank(de.mossgrabers.framework.daw.data.bank.ITrackBank)

Example 5 with FrameworkException

use of de.mossgrabers.framework.utils.FrameworkException in project DrivenByMoss by git-moss.

the class FeatureGroupManager method setActive.

/**
 * Set the active feature group.
 *
 * @param featureGroupID The ID of the feature group to activate
 * @param syncSiblings Changes sibling feature group managers as well if true
 */
private void setActive(final E featureGroupID, final boolean syncSiblings) {
    final E id = featureGroupID == null ? this.defaultID : featureGroupID;
    if (id == null)
        throw new FrameworkException("Attempt to set the active feature group to null and no default feature group is registered.");
    // Do nothing if already active
    if (this.isActive(id))
        return;
    // Deactivate the current temporary or active feature group
    final F deactivate = this.getActive();
    if (deactivate != null)
        deactivate.onDeactivate();
    this.temporaryID = null;
    // Activate the feature group
    this.previousID = this.activeID;
    this.activeID = id;
    this.get(this.activeID).onActivate();
    if (syncSiblings)
        this.connectedManagers.forEach(sibling -> sibling.setActive(featureGroupID, false));
    this.notifyObservers(this.previousID, this.activeID);
}
Also used : FrameworkException(de.mossgrabers.framework.utils.FrameworkException) List(java.util.List) EnumMap(java.util.EnumMap) Map(java.util.Map) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) FrameworkException(de.mossgrabers.framework.utils.FrameworkException)

Aggregations

FrameworkException (de.mossgrabers.framework.utils.FrameworkException)5 ArrayList (java.util.ArrayList)2 EnumMap (java.util.EnumMap)2 List (java.util.List)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 IHwButton (de.mossgrabers.framework.controller.hardware.IHwButton)1 ITrack (de.mossgrabers.framework.daw.data.ITrack)1 ISlotBank (de.mossgrabers.framework.daw.data.bank.ISlotBank)1 ITrackBank (de.mossgrabers.framework.daw.data.bank.ITrackBank)1