From: David ‘Bombe’ Roden Date: Tue, 28 May 2013 04:49:12 +0000 (+0200) Subject: Rename “Controlled” to “ControlledComponent.” X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=fa5196e029c48636f0c318311244395cfae49953;p=sonitus.git Rename “Controlled” to “ControlledComponent.” --- 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 index 6b4c617..0000000 --- a/src/main/java/net/pterodactylus/sonitus/data/Controlled.java +++ /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 . - */ - -package net.pterodactylus.sonitus.data; - -import java.util.List; - -/** - * Interface for components that can be controlled externally in some way. - * - * @author David ‘Bombe’ Roden - */ -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> 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 index 0000000..29c7828 --- /dev/null +++ b/src/main/java/net/pterodactylus/sonitus/data/ControlledComponent.java @@ -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 . + */ + +package net.pterodactylus.sonitus.data; + +import java.util.List; + +/** + * Interface for components that can be controlled externally in some way. + * + * @author David ‘Bombe’ Roden + */ +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> controllers(); + +} diff --git a/src/main/java/net/pterodactylus/sonitus/data/Filter.java b/src/main/java/net/pterodactylus/sonitus/data/Filter.java index 794c82a..c251cfe 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/Filter.java +++ b/src/main/java/net/pterodactylus/sonitus/data/Filter.java @@ -23,6 +23,6 @@ package net.pterodactylus.sonitus.data; * * @author David ‘Bombe’ Roden */ -public interface Filter extends Controlled, Source, Sink { +public interface Filter extends ControlledComponent, Source, Sink { } diff --git a/src/main/java/net/pterodactylus/sonitus/data/Pipeline.java b/src/main/java/net/pterodactylus/sonitus/data/Pipeline.java index 975c21c..ee67eec 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/Pipeline.java +++ b/src/main/java/net/pterodactylus/sonitus/data/Pipeline.java @@ -46,7 +46,7 @@ import com.google.common.util.concurrent.MoreExecutors; * * @author David ‘Bombe’ Roden */ -public class Pipeline implements Iterable { +public class Pipeline implements Iterable { /** The logger. */ private static final Logger logger = Logger.getLogger(Pipeline.class.getName()); @@ -102,18 +102,18 @@ public class Pipeline implements Iterable { /** * 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 { // @Override - public Iterator iterator() { - return ImmutableSet.builder().add(source).addAll(sinks.values()).build().iterator(); + public Iterator iterator() { + return ImmutableSet.builder().add(source).addAll(sinks.values()).build().iterator(); } // diff --git a/src/main/java/net/pterodactylus/sonitus/data/Sink.java b/src/main/java/net/pterodactylus/sonitus/data/Sink.java index c238fef..cacfdb7 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/Sink.java +++ b/src/main/java/net/pterodactylus/sonitus/data/Sink.java @@ -8,7 +8,7 @@ import java.io.IOException; * * @author David ‘Bombe’ Roden */ -public interface Sink extends Controlled { +public interface Sink extends ControlledComponent { /** * Opens this sink using the format parameters of the given metadata. diff --git a/src/main/java/net/pterodactylus/sonitus/data/Source.java b/src/main/java/net/pterodactylus/sonitus/data/Source.java index cf2dd66..b12ec20 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/Source.java +++ b/src/main/java/net/pterodactylus/sonitus/data/Source.java @@ -7,7 +7,7 @@ import java.io.IOException; * * @author David ‘Bombe’ Roden */ -public interface Source extends Controlled { +public interface Source extends ControlledComponent { /** * Returns the metadata of the audio stream. diff --git a/src/main/java/net/pterodactylus/sonitus/data/event/MetadataUpdated.java b/src/main/java/net/pterodactylus/sonitus/data/event/MetadataUpdated.java index deb1ec6..d60f33a 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/event/MetadataUpdated.java +++ b/src/main/java/net/pterodactylus/sonitus/data/event/MetadataUpdated.java @@ -17,19 +17,19 @@ 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 David ‘Bombe’ Roden */ 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; } /** diff --git a/src/main/java/net/pterodactylus/sonitus/gui/ComponentInfoPanel.java b/src/main/java/net/pterodactylus/sonitus/gui/ComponentInfoPanel.java index cd0b9e2..a6b45d5 100644 --- a/src/main/java/net/pterodactylus/sonitus/gui/ComponentInfoPanel.java +++ b/src/main/java/net/pterodactylus/sonitus/gui/ComponentInfoPanel.java @@ -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 David ‘Bombe’ Roden */ @@ -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)); diff --git a/src/main/java/net/pterodactylus/sonitus/gui/MainWindow.java b/src/main/java/net/pterodactylus/sonitus/gui/MainWindow.java index 7d64497..aa358c3 100644 --- a/src/main/java/net/pterodactylus/sonitus/gui/MainWindow.java +++ b/src/main/java/net/pterodactylus/sonitus/gui/MainWindow.java @@ -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 controlledInfoPanels = Maps.newHashMap(); + private final Map 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()); diff --git a/src/main/java/net/pterodactylus/sonitus/gui/PipelinePanel.java b/src/main/java/net/pterodactylus/sonitus/gui/PipelinePanel.java index dcb3e3f..8c5fa15 100644 --- a/src/main/java/net/pterodactylus/sonitus/gui/PipelinePanel.java +++ b/src/main/java/net/pterodactylus/sonitus/gui/PipelinePanel.java @@ -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 sinks = pipeline.sinks((Source) controlled); + Collection 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); }