Rename “Controlled” to “ControlledComponent.”
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 28 May 2013 04:49:12 +0000 (06:49 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 28 May 2013 04:49:12 +0000 (06:49 +0200)
src/main/java/net/pterodactylus/sonitus/data/Controlled.java [deleted file]
src/main/java/net/pterodactylus/sonitus/data/ControlledComponent.java [new file with mode: 0644]
src/main/java/net/pterodactylus/sonitus/data/Filter.java
src/main/java/net/pterodactylus/sonitus/data/Pipeline.java
src/main/java/net/pterodactylus/sonitus/data/Sink.java
src/main/java/net/pterodactylus/sonitus/data/Source.java
src/main/java/net/pterodactylus/sonitus/data/event/MetadataUpdated.java
src/main/java/net/pterodactylus/sonitus/gui/ComponentInfoPanel.java
src/main/java/net/pterodactylus/sonitus/gui/MainWindow.java
src/main/java/net/pterodactylus/sonitus/gui/PipelinePanel.java

diff --git a/src/main/java/net/pterodactylus/sonitus/data/Controlled.java b/src/main/java/net/pterodactylus/sonitus/data/Controlled.java
deleted file mode 100644 (file)
index 6b4c617..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Sonitus - Controlled.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 <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sonitus.data;
-
-import java.util.List;
-
-/**
- * Interface for components that can be controlled externally in some way.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public interface Controlled {
-
-       /**
-        * Returns the name of this controlled component.
-        *
-        * @return The name of this controlled component
-        */
-       public String name();
-
-       /**
-        * Returns the current metadata of this component.
-        *
-        * @return The current metadata of this component
-        */
-       public Metadata metadata();
-
-       /**
-        * Returns the controllers offered by this component.
-        *
-        * @return The controllers of this component
-        */
-       public List<Controller<?>> controllers();
-
-}
diff --git a/src/main/java/net/pterodactylus/sonitus/data/ControlledComponent.java b/src/main/java/net/pterodactylus/sonitus/data/ControlledComponent.java
new file mode 100644 (file)
index 0000000..29c7828
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Sonitus - Controlled.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 <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sonitus.data;
+
+import java.util.List;
+
+/**
+ * Interface for components that can be controlled externally in some way.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public interface ControlledComponent {
+
+       /**
+        * Returns the name of this controlled component.
+        *
+        * @return The name of this controlled component
+        */
+       public String name();
+
+       /**
+        * Returns the current metadata of this component.
+        *
+        * @return The current metadata of this component
+        */
+       public Metadata metadata();
+
+       /**
+        * Returns the controllers offered by this component.
+        *
+        * @return The controllers of this component
+        */
+       public List<Controller<?>> controllers();
+
+}
index 794c82a..c251cfe 100644 (file)
@@ -23,6 +23,6 @@ package net.pterodactylus.sonitus.data;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public interface Filter extends Controlled, Source, Sink {
+public interface Filter extends ControlledComponent, Source, Sink {
 
 }
index 975c21c..ee67eec 100644 (file)
@@ -46,7 +46,7 @@ import com.google.common.util.concurrent.MoreExecutors;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public class Pipeline implements Iterable<Controlled> {
+public class Pipeline implements Iterable<ControlledComponent> {
 
        /** The logger. */
        private static final Logger logger = Logger.getLogger(Pipeline.class.getName());
@@ -102,18 +102,18 @@ public class Pipeline implements Iterable<Controlled> {
        /**
         * Returns the traffic counters of the given controlled component.
         *
-        * @param controlled
+        * @param controlledComponent
         *              The controlled component to get the traffic counters for
         * @return The traffic counters for the given controlled component
         */
-       public TrafficCounter trafficCounter(Controlled controlled) {
+       public TrafficCounter trafficCounter(ControlledComponent controlledComponent) {
                long input = -1;
                long output = -1;
                for (Connection connection : connections) {
                        /* the connection where the source matches knows the output. */
-                       if (connection.source.equals(controlled)) {
+                       if (connection.source.equals(controlledComponent)) {
                                output = connection.counter();
-                       } else if (connection.sinks.contains(controlled)) {
+                       } else if (connection.sinks.contains(controlledComponent)) {
                                input = connection.counter();
                        }
                }
@@ -171,8 +171,8 @@ public class Pipeline implements Iterable<Controlled> {
        //
 
        @Override
-       public Iterator<Controlled> iterator() {
-               return ImmutableSet.<Controlled>builder().add(source).addAll(sinks.values()).build().iterator();
+       public Iterator<ControlledComponent> iterator() {
+               return ImmutableSet.<ControlledComponent>builder().add(source).addAll(sinks.values()).build().iterator();
        }
 
        //
index c238fef..cacfdb7 100644 (file)
@@ -8,7 +8,7 @@ import java.io.IOException;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public interface Sink extends Controlled {
+public interface Sink extends ControlledComponent {
 
        /**
         * Opens this sink using the format parameters of the given metadata.
index cf2dd66..b12ec20 100644 (file)
@@ -7,7 +7,7 @@ import java.io.IOException;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public interface Source extends Controlled {
+public interface Source extends ControlledComponent {
 
        /**
         * Returns the metadata of the audio stream.
index deb1ec6..d60f33a 100644 (file)
 
 package net.pterodactylus.sonitus.data.event;
 
-import net.pterodactylus.sonitus.data.Controlled;
+import net.pterodactylus.sonitus.data.ControlledComponent;
 import net.pterodactylus.sonitus.data.Metadata;
 
 /**
  * Event that notifies all listeners that the {@link Metadata} of a {@link
- * Controlled} component was changed.
+ * ControlledComponent} component was changed.
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
 public class MetadataUpdated {
 
        /** The controlled component. */
-       private final Controlled controlled;
+       private final ControlledComponent controlledComponent;
 
        /** The new metadata. */
        private final Metadata metadata;
@@ -37,13 +37,13 @@ public class MetadataUpdated {
        /**
         * Creates a new metadata updated event.
         *
-        * @param controlled
+        * @param controlledComponent
         *              The controlled component
         * @param metadata
         *              The new metadata
         */
-       public MetadataUpdated(Controlled controlled, Metadata metadata) {
-               this.controlled = controlled;
+       public MetadataUpdated(ControlledComponent controlledComponent, Metadata metadata) {
+               this.controlledComponent = controlledComponent;
                this.metadata = metadata;
        }
 
@@ -56,8 +56,8 @@ public class MetadataUpdated {
         *
         * @return The controlled component
         */
-       public Controlled controlled() {
-               return controlled;
+       public ControlledComponent controlled() {
+               return controlledComponent;
        }
 
        /**
index cd0b9e2..a6b45d5 100644 (file)
@@ -27,7 +27,7 @@ import javax.swing.Box;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 
-import net.pterodactylus.sonitus.data.Controlled;
+import net.pterodactylus.sonitus.data.ControlledComponent;
 import net.pterodactylus.sonitus.data.Controller;
 import net.pterodactylus.sonitus.data.FormatMetadata;
 import net.pterodactylus.sonitus.data.controller.Fader;
@@ -37,7 +37,7 @@ import net.pterodactylus.sonitus.data.controller.Switch;
 import com.google.common.base.Optional;
 
 /**
- * Panel that shows information about a {@link Controlled} component.
+ * Panel that shows information about a {@link ControlledComponent}.
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
@@ -58,14 +58,14 @@ public class ComponentInfoPanel extends JPanel {
        /**
         * Creates a new component info panel.
         *
-        * @param controlled
+        * @param controlledComponent
         *              The component to display
         */
-       public ComponentInfoPanel(Controlled controlled) {
+       public ComponentInfoPanel(ControlledComponent controlledComponent) {
                super(new GridBagLayout());
 
                setPreferredSize(new Dimension(400, 0));
-               createPanel(controlled);
+               createPanel(controlledComponent);
        }
 
        //
@@ -127,13 +127,13 @@ public class ComponentInfoPanel extends JPanel {
        /**
         * Creates the panel for the given controlled component.
         *
-        * @param controlled
+        * @param controlledComponent
         *              The controlled component
         */
-       private void createPanel(Controlled controlled) {
+       private void createPanel(ControlledComponent controlledComponent) {
                setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
 
-               headerLabel.setText(controlled.name());
+               headerLabel.setText(controlledComponent.name());
                headerLabel.setFont(headerLabel.getFont().deriveFont(Font.BOLD));
 
                int line = 0;
@@ -146,7 +146,7 @@ public class ComponentInfoPanel extends JPanel {
                add(formatLabel, new GridBagConstraints(1, line++, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
 
                /* add the controllers. */
-               for (Controller<?> controller : controlled.controllers()) {
+               for (Controller<?> controller : controlledComponent.controllers()) {
                        add(new JLabel(controller.name()), new GridBagConstraints(0, line, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(6, 0, 0, 6), 0, 0));
                        if (controller instanceof Fader) {
                                add(new FaderPanel((Fader) controller), new GridBagConstraints(1, line++, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(6, 0, 0, 0), 0, 0));
index 7d64497..aa358c3 100644 (file)
@@ -30,7 +30,7 @@ import javax.swing.JTabbedPane;
 import javax.swing.Timer;
 import javax.swing.WindowConstants;
 
-import net.pterodactylus.sonitus.data.Controlled;
+import net.pterodactylus.sonitus.data.ControlledComponent;
 import net.pterodactylus.sonitus.data.Pipeline;
 import net.pterodactylus.sonitus.gui.PipelinePanel.ComponentHoverListener;
 import net.pterodactylus.sonitus.main.Version;
@@ -58,7 +58,7 @@ public class MainWindow extends JFrame {
        private final JPanel infoPanel = new JPanel(infoPanelCardLayout);
 
        /** The mapping from controlled components to info panels. */
-       private final Map<Controlled, ComponentInfoPanel> controlledInfoPanels = Maps.newHashMap();
+       private final Map<ControlledComponent, ComponentInfoPanel> controlledInfoPanels = Maps.newHashMap();
 
        /**
         * Creates a new main window.
@@ -75,8 +75,8 @@ public class MainWindow extends JFrame {
                pipelinePanel.addComponentHoverListener(new ComponentHoverListener() {
 
                        @Override
-                       public void componentEntered(Controlled controlled) {
-                               infoPanelCardLayout.show(infoPanel, controlled.name());
+                       public void componentEntered(ControlledComponent controlledComponent) {
+                               infoPanelCardLayout.show(infoPanel, controlledComponent.name());
                        }
                });
                pipelineInfoPanel.add(pipelinePanel, BorderLayout.CENTER);
@@ -86,10 +86,10 @@ public class MainWindow extends JFrame {
                setSize(new Dimension(800, 450));
 
                /* create info panels for all components. */
-               for (Controlled controlled : pipeline) {
-                       ComponentInfoPanel componentInfoPanel = new ComponentInfoPanel(controlled);
-                       infoPanel.add(componentInfoPanel, controlled.name());
-                       controlledInfoPanels.put(controlled, componentInfoPanel);
+               for (ControlledComponent controlledComponent : pipeline) {
+                       ComponentInfoPanel componentInfoPanel = new ComponentInfoPanel(controlledComponent);
+                       infoPanel.add(componentInfoPanel, controlledComponent.name());
+                       controlledInfoPanels.put(controlledComponent, componentInfoPanel);
                }
 
                Timer timer = new Timer(250, new ActionListener() {
@@ -97,7 +97,7 @@ public class MainWindow extends JFrame {
                        @Override
                        public void actionPerformed(ActionEvent actionEvent) {
                                /* update all info panels. */
-                               for (Controlled controlled : MainWindow.this.pipeline) {
+                               for (ControlledComponent controlled : MainWindow.this.pipeline) {
                                        ComponentInfoPanel componentInfoPanel = controlledInfoPanels.get(controlled);
                                        componentInfoPanel.input(MainWindow.this.pipeline.trafficCounter(controlled).input());
                                        componentInfoPanel.output(MainWindow.this.pipeline.trafficCounter(controlled).output());
index dcb3e3f..8c5fa15 100644 (file)
@@ -31,7 +31,7 @@ import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.event.EventListenerList;
 
-import net.pterodactylus.sonitus.data.Controlled;
+import net.pterodactylus.sonitus.data.ControlledComponent;
 import net.pterodactylus.sonitus.data.Filter;
 import net.pterodactylus.sonitus.data.Pipeline;
 import net.pterodactylus.sonitus.data.Sink;
@@ -115,7 +115,7 @@ public class PipelinePanel extends JPanel {
        /**
         * Displays the given component.
         *
-        * @param controlled
+        * @param controlledComponent
         *              The component to add this panel.
         * @param level
         *              The level at which to show the component (the source is level {@code 0})
@@ -124,16 +124,16 @@ public class PipelinePanel extends JPanel {
         * @param width
         *              The width of the component in grid cells
         */
-       private void addControlled(final Controlled controlled, int level, int position, int width) {
+       private void addControlled(final ControlledComponent controlledComponent, int level, int position, int width) {
                /* create a GUI component that displays the component. */
-               JLabel sourceLabel = new JLabel(controlled.name());
+               JLabel sourceLabel = new JLabel(controlledComponent.name());
                sourceLabel.setBorder(createEtchedBorder());
                sourceLabel.addMouseListener(new MouseAdapter() {
 
                        @Override
                        public void mouseEntered(MouseEvent mouseEvent) {
                                for (ComponentHoverListener componentHoverListener : componentHoverListeners.getListeners(ComponentHoverListener.class)) {
-                                       componentHoverListener.componentEntered(controlled);
+                                       componentHoverListener.componentEntered(controlledComponent);
                                }
                        }
                });
@@ -142,12 +142,12 @@ public class PipelinePanel extends JPanel {
                add(sourceLabel, new GridBagConstraints(position, level, width, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
 
                /* if the component does not have connected sinks, exit here. */
-               if (!(controlled instanceof Source)) {
+               if (!(controlledComponent instanceof Source)) {
                        return;
                }
 
                /* iterate over the component’s sinks. */
-               Collection<Sink> sinks = pipeline.sinks((Source) controlled);
+               Collection<Sink> sinks = pipeline.sinks((Source) controlledComponent);
                int sinkWidth = width / sinks.size();
                int sinkIndex = 0;
                for (Sink connectedSink : sinks) {
@@ -169,10 +169,10 @@ public class PipelinePanel extends JPanel {
                 * Notifies the listener that the mouse is now over the given controlled
                 * component.
                 *
-                * @param controlled
+                * @param controlledComponent
                 *              The controlled component now under the mouse
                 */
-               void componentEntered(Controlled controlled);
+               void componentEntered(ControlledComponent controlledComponent);
 
        }