+ controllerPanel.add(new SwitchPanel((Switch) controller), new GridBagConstraints(1, controllerIndex, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(6, 0, 0, 0), 0, 0));
+ } else if (controller instanceof Knob) {
+ controllerPanel.add(new KnobPanel((Knob) controller), new GridBagConstraints(1, controllerIndex, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(6, 0, 0, 0), 0, 0));
+ }
+ ++controllerIndex;
+ }
+
+ return controllerPanel;
+ }
+
+ /**
+ * A {@link JPanel} that displays {@link Metadata} information about a {@link
+ * Controlled} component.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+ private static class MetadataPanel extends JPanel {
+
+ /** The controlled component. */
+ private final Controlled controlled;
+
+ /** The format label. */
+ private JLabel format;
+
+ /** The title label. */
+ private JLabel title;
+
+ /**
+ * Creates a new metadata panel.
+ *
+ * @param controlled
+ * The controlled component
+ */
+ public MetadataPanel(Controlled controlled) {
+ this.controlled = controlled;
+
+ setBorder(createTitledBorder(createEtchedBorder(), "Metadata"));
+ setLayout(new GridBagLayout());
+
+ format = new JLabel();
+ title = new JLabel();
+
+ JLabel formatLabel = new JLabel("Format");
+ formatLabel.setFont(formatLabel.getFont().deriveFont(Font.BOLD));
+ JLabel titleLabel = new JLabel("Title");
+ titleLabel.setFont(formatLabel.getFont().deriveFont(Font.BOLD));
+
+ add(formatLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
+ add(format, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
+ add(titleLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0));
+ add(title, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
+
+ metadataUpdated(new MetadataUpdated(controlled, controlled.metadata()));
+ }
+
+ /**
+ * Called by the {@link EventBus} when a {@link Controlled} component updates
+ * its metadata.
+ *
+ * @param metadataUpdated
+ * The metadata updated event
+ */
+ @Subscribe
+ public void metadataUpdated(MetadataUpdated metadataUpdated) {
+ /* do we care about the event’s component? */
+ if (!controlled.equals(metadataUpdated.controlled())) {
+ return;