From: David ‘Bombe’ Roden Date: Sun, 26 May 2013 12:22:49 +0000 (+0200) Subject: Add name to controllers. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b61d311f6fd16ccf65decf3b29e9b06bb58406cd;p=sonitus.git Add name to controllers. --- diff --git a/src/main/java/net/pterodactylus/sonitus/data/Controller.java b/src/main/java/net/pterodactylus/sonitus/data/Controller.java index afc92c0..6f9de5b 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/Controller.java +++ b/src/main/java/net/pterodactylus/sonitus/data/Controller.java @@ -25,6 +25,13 @@ package net.pterodactylus.sonitus.data; public interface Controller> { /** + * Returns the name of this controller. + * + * @return The name of this controller + */ + String name(); + + /** * Returns the minimum value of this controller. * * @return The minimum value of this controller diff --git a/src/main/java/net/pterodactylus/sonitus/data/controller/AbstractController.java b/src/main/java/net/pterodactylus/sonitus/data/controller/AbstractController.java index c091573..b355a89 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/controller/AbstractController.java +++ b/src/main/java/net/pterodactylus/sonitus/data/controller/AbstractController.java @@ -30,6 +30,9 @@ import net.pterodactylus.sonitus.data.Controller; */ public abstract class AbstractController> implements Controller { + /** The name of this controller. */ + private final String name; + /** The minimum value of this controller. */ private final V minimum; @@ -45,6 +48,8 @@ public abstract class AbstractController> implements Con /** * Creates a new abstract controller. * + * @param name + * The name of the controller * @param minimum * The minimum value of the controller * @param maximum @@ -53,9 +58,9 @@ public abstract class AbstractController> implements Con * {@code true} if this controller has a “center” position, {@code false} * otherwise * @param currentValue - * The current value of this controller */ - public AbstractController(V minimum, V maximum, boolean centered, V currentValue) { + public AbstractController(String name, V minimum, V maximum, boolean centered, V currentValue) { + this.name = name; this.minimum = minimum; this.maximum = maximum; this.centered = centered; @@ -67,6 +72,11 @@ public abstract class AbstractController> implements Con // @Override + public String name() { + return name; + } + + @Override public V minimum() { return minimum; } diff --git a/src/main/java/net/pterodactylus/sonitus/data/controller/Fader.java b/src/main/java/net/pterodactylus/sonitus/data/controller/Fader.java index 0f78ea2..279da03 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/controller/Fader.java +++ b/src/main/java/net/pterodactylus/sonitus/data/controller/Fader.java @@ -26,19 +26,26 @@ import net.pterodactylus.sonitus.data.Controller; */ 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 maximum position. + * + * @param name + * The name of the fader + */ + public Fader(String name) { + this(name, 1.0); } /** * Creates a new fader that is at the given position. * + * @param name + * The name of the fader * @param currentValue * The current value of the fader (from {@code 0.0} to {@code 1.0}) */ - public Fader(Double currentValue) { - super(0.0, 1.0, false, currentValue); + public Fader(String name, Double currentValue) { + super(name, 0.0, 1.0, false, currentValue); } } diff --git a/src/main/java/net/pterodactylus/sonitus/data/controller/Switch.java b/src/main/java/net/pterodactylus/sonitus/data/controller/Switch.java index cb853a3..1b997d4 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/controller/Switch.java +++ b/src/main/java/net/pterodactylus/sonitus/data/controller/Switch.java @@ -24,19 +24,26 @@ package net.pterodactylus.sonitus.data.controller; */ public abstract class Switch extends AbstractController { - /** Creates a new switch that is off. */ - public Switch() { - this(false); + /** + * Creates a new switch that is off. + * + * @param name + * The name of the switch + */ + public Switch(String name) { + this(name, false); } /** * Creates a new switch with the given state. * + * @param name + * The name of the switch * @param active * The state of the switch */ - public Switch(boolean active) { - super(false, true, false, active); + public Switch(String name, boolean active) { + super(name, false, true, false, active); } } diff --git a/src/main/java/net/pterodactylus/sonitus/data/sink/AudioSink.java b/src/main/java/net/pterodactylus/sonitus/data/sink/AudioSink.java index fdcbbd6..611dcd9 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/sink/AudioSink.java +++ b/src/main/java/net/pterodactylus/sonitus/data/sink/AudioSink.java @@ -64,7 +64,7 @@ public class AudioSink implements Sink { /** Creates a new audio sink. */ public AudioSink() { super(); - volumeFader = new Fader() { + volumeFader = new Fader("Volume") { @Override protected void valueSet(Double value) { @@ -74,7 +74,7 @@ public class AudioSink implements Sink { } } }; - muteSwitch = new Switch() { + muteSwitch = new Switch("Mute") { private float previousValue; diff --git a/src/main/java/net/pterodactylus/sonitus/gui/FaderPanel.java b/src/main/java/net/pterodactylus/sonitus/gui/FaderPanel.java index 68ca774..b37fec6 100644 --- a/src/main/java/net/pterodactylus/sonitus/gui/FaderPanel.java +++ b/src/main/java/net/pterodactylus/sonitus/gui/FaderPanel.java @@ -48,7 +48,7 @@ public class FaderPanel extends JPanel { setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12)); /* create label. */ - JLabel label = new JLabel("Volume"); + JLabel label = new JLabel(fader.name()); add(label, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); /* create fader labels. */ diff --git a/src/main/java/net/pterodactylus/sonitus/gui/SwitchPanel.java b/src/main/java/net/pterodactylus/sonitus/gui/SwitchPanel.java index 40ba4d8..5ffd8a2 100644 --- a/src/main/java/net/pterodactylus/sonitus/gui/SwitchPanel.java +++ b/src/main/java/net/pterodactylus/sonitus/gui/SwitchPanel.java @@ -47,7 +47,7 @@ public class SwitchPanel extends JPanel { setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12)); /* create label. */ - JLabel label = new JLabel("Mute"); + JLabel label = new JLabel(switchController.name()); add(label, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); /* create checkbox. */