From: David ‘Bombe’ Roden Date: Sun, 26 May 2013 11:29:50 +0000 (+0200) Subject: Add fader implementation. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=7fd39e525f49730b76e756b613f20b9dd72808b9;p=sonitus.git Add fader implementation. --- diff --git a/src/main/java/net/pterodactylus/sonitus/data/controller/Fader.java b/src/main/java/net/pterodactylus/sonitus/data/controller/Fader.java new file mode 100644 index 0000000..4cb6f28 --- /dev/null +++ b/src/main/java/net/pterodactylus/sonitus/data/controller/Fader.java @@ -0,0 +1,44 @@ +/* + * Sonitus - Fader.java - Copyright © 2013 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sonitus.data.controller; + +import net.pterodactylus.sonitus.data.Controller; + +/** + * A {@link Controller} that implements a simple fader. + * + * @author David ‘Bombe’ Roden + */ +public abstract class Fader extends AbstractController { + + /** Creates a new fader that is at maximum position. */ + public Fader() { + this(1.0); + } + + /** + * Creates a new fader that is at the given position. + * + * @param currentValue + * The current value of the fader (from {@code 0.0} to {@code 1.0}) + */ + public Fader(double currentValue) { + super(0, Integer.MAX_VALUE, false, (int) (Math.max(0, Math.min(1, currentValue)) * Integer.MAX_VALUE)); + } + +}