+++ /dev/null
-/*
- * 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();
-
-}
--- /dev/null
+/*
+ * 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();
+
+}
*
* @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 {
}
*
* @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());
/**
* 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();
}
}
//
@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();
}
//
*
* @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.
*
* @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.
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;
/**
* 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;
}
*
* @return The controlled component
*/
- public Controlled controlled() {
- return controlled;
+ public ControlledComponent controlled() {
+ return controlledComponent;
}
/**
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;
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>
*/
/**
* 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);
}
//
/**
* 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;
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));
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;
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.
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);
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() {
@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());
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;
/**
* 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})
* @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);
}
}
});
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) {
* 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);
}