From 7fd39e525f49730b76e756b613f20b9dd72808b9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 26 May 2013 13:29:50 +0200 Subject: [PATCH] Add fader implementation. --- .../sonitus/data/controller/Fader.java | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/main/java/net/pterodactylus/sonitus/data/controller/Fader.java 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)); + } + +} -- 2.7.4