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);
}
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());
}
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();
}
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());
}
}
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);
}
Aggregations