From b7e91b70132fc791edf4eacf039cbfd2127ae657 Mon Sep 17 00:00:00 2001 From: "T. van der Zwan" Date: Thu, 12 Dec 2013 22:39:56 +0100 Subject: [PATCH] Updated HyperCon with effect configuration removed. Former-commit-id: 721510af90c601954390b881f957224725a7fed9 --- .../hyperion/hypercon/JsonStringBuffer.java | 16 + .../src/org/hyperion/hypercon/LedString.java | 8 - .../src/org/hyperion/hypercon/Main.java | 7 - .../hypercon/gui/BootSequencePanel.java | 126 ------ .../hyperion/hypercon/gui/ConfigPanel.java | 5 +- .../hyperion/hypercon/gui/DevicePanel.java | 93 ++-- .../hypercon/gui/EffectEnginePanel.java | 66 ++- .../gui/effectengine/ColorPicker.java | 74 ---- .../EffectArgumentCellEditor.java | 96 ---- .../gui/effectengine/EffectArgumentType.java | 53 --- .../gui/effectengine/EffectEnginePanel.java | 419 ------------------ .../effectengine/NewEffectArgumentDialog.java | 228 ---------- .../hyperion/hypercon/spec/BootSequence.java | 27 -- .../hyperion/hypercon/spec/DeviceType.java | 59 ++- .../hypercon/spec/EffectEngineConfig.java | 43 -- .../hyperion/hypercon/spec/MiscConfig.java | 41 +- .../hypercon/spec/TransformConfig.java | 16 +- 17 files changed, 205 insertions(+), 1172 deletions(-) delete mode 100644 src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/BootSequencePanel.java delete mode 100644 src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/ColorPicker.java delete mode 100644 src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/EffectArgumentCellEditor.java delete mode 100644 src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/EffectArgumentType.java delete mode 100644 src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/EffectEnginePanel.java delete mode 100644 src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/NewEffectArgumentDialog.java delete mode 100644 src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/BootSequence.java delete mode 100644 src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/EffectEngineConfig.java diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/JsonStringBuffer.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/JsonStringBuffer.java index da215d1b..58b2aa17 100644 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/JsonStringBuffer.java +++ b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/JsonStringBuffer.java @@ -162,6 +162,22 @@ public class JsonStringBuffer { } } + /** + * Adds an array element to an opened array. + * + * @param pValue The value of the element + * @param pLastValue Indicates that it is the last element in the array + */ + public void addArrayElement(String pValue, boolean pLastValue) { + startLine(); + mStrBuf.append('"').append(pValue).append('"'); + if (pLastValue) { + mStrBuf.append("\n"); + } else { + mStrBuf.append(",\n"); + } + } + @Override public String toString() { return mStrBuf.toString(); diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/LedString.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/LedString.java index 96b9e09c..0534a6e3 100644 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/LedString.java +++ b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/LedString.java @@ -7,7 +7,6 @@ import java.util.Vector; import org.hyperion.hypercon.spec.ColorConfig; import org.hyperion.hypercon.spec.DeviceConfig; -import org.hyperion.hypercon.spec.EffectEngineConfig; import org.hyperion.hypercon.spec.ImageProcessConfig; import org.hyperion.hypercon.spec.Led; import org.hyperion.hypercon.spec.LedFrameConstruction; @@ -31,9 +30,6 @@ public class LedString { /** The miscellaneous configuration (bootsequence, blackborder detector, etc) */ public final MiscConfig mMiscConfig = new MiscConfig(); - /** The effect engine configuration, containing the Effects */ - public final EffectEngineConfig mEffectEngineConfig = new EffectEngineConfig(); - /** The translation of the led frame construction and image processing to individual led configuration */ public Vector leds; @@ -72,10 +68,6 @@ public class LedString { jsonBuf.newLine(); - mEffectEngineConfig.appendTo(jsonBuf); - - jsonBuf.newLine(); - jsonBuf.addValue("endOfJson", "endOfJson", true); fw.write(jsonBuf.toString()); diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/Main.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/Main.java index 189a329e..c2f0681d 100644 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/Main.java +++ b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/Main.java @@ -51,7 +51,6 @@ public class Main { configFile.store(ledString.mProcessConfig); configFile.store(ledString.mColorConfig); configFile.store(ledString.mMiscConfig); - configFile.store(ledString.mEffectEngineConfig); configFile.save(configFilename); } }); @@ -65,12 +64,6 @@ public class Main { configFile.restore(ledString.mProcessConfig); configFile.restore(ledString.mColorConfig); configFile.restore(ledString.mMiscConfig); - configFile.restore(ledString.mEffectEngineConfig); - - if (HyperConConfig.loadDefaultEffect) { - ledString.mEffectEngineConfig.loadDefault(); - HyperConConfig.loadDefaultEffect = false; - } } // Add the HyperCon configuration panel diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/BootSequencePanel.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/BootSequencePanel.java deleted file mode 100644 index 606570cd..00000000 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/BootSequencePanel.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.hyperion.hypercon.gui; - -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.Transient; - -import javax.swing.BorderFactory; -import javax.swing.GroupLayout; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JSpinner; -import javax.swing.SpinnerNumberModel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import org.hyperion.hypercon.spec.BootSequence; -import org.hyperion.hypercon.spec.MiscConfig; - -public class BootSequencePanel extends JPanel { - - private final MiscConfig mMiscConfig; - - private JCheckBox mBootSequenceCheck; - private JLabel mBootSequenceLabel; - private JComboBox mBootSequenceCombo; - private JLabel mBootSequenceLengthLabel; - private JSpinner mBootSequenceLengthSpinner; - - public BootSequencePanel(final MiscConfig pMiscconfig) { - super(); - - mMiscConfig = pMiscconfig; - - initialise(); - } - - @Override - @Transient - public Dimension getMaximumSize() { - Dimension maxSize = super.getMaximumSize(); - Dimension prefSize = super.getPreferredSize(); - return new Dimension(maxSize.width, prefSize.height); - } - - private void initialise() { - setBorder(BorderFactory.createTitledBorder("Boot Sequence")); - - mBootSequenceCheck = new JCheckBox("Enabled"); - mBootSequenceCheck.setSelected(mMiscConfig.mBootsequenceEnabled); - mBootSequenceCheck.addActionListener(mActionListener); - add(mBootSequenceCheck); - - mBootSequenceLabel = new JLabel("Type:"); - mBootSequenceLabel.setEnabled(mMiscConfig.mBootsequenceEnabled); - add(mBootSequenceLabel); - - mBootSequenceCombo = new JComboBox<>(BootSequence.values()); - mBootSequenceCombo.setSelectedItem(mMiscConfig.mBootSequence); - mBootSequenceCombo.setToolTipText("The sequence used on startup to verify proper working of all the leds"); - mBootSequenceCombo.addActionListener(mActionListener); - add(mBootSequenceCombo); - - mBootSequenceLengthLabel = new JLabel("Length [ms]"); - add(mBootSequenceLengthLabel); - - mBootSequenceLengthSpinner = new JSpinner(new SpinnerNumberModel(mMiscConfig.mBootSequenceLength_ms, 500, 3600000, 1000)); - mBootSequenceLengthSpinner.addChangeListener(mChangeListener); - add(mBootSequenceLengthSpinner); - - - GroupLayout layout = new GroupLayout(this); - layout.setAutoCreateGaps(true); - setLayout(layout); - - layout.setHorizontalGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup() - .addComponent(mBootSequenceCheck) - .addComponent(mBootSequenceLabel) - .addComponent(mBootSequenceLengthLabel) - ) - .addGroup(layout.createParallelGroup() - .addComponent(mBootSequenceCheck) - .addComponent(mBootSequenceCombo) - .addComponent(mBootSequenceLengthSpinner) - )); - layout.setVerticalGroup(layout.createSequentialGroup() - .addComponent(mBootSequenceCheck) - .addGroup(layout.createParallelGroup() - .addComponent(mBootSequenceLabel) - .addComponent(mBootSequenceCombo) - ) - .addGroup(layout.createParallelGroup() - .addComponent(mBootSequenceLengthLabel) - .addComponent(mBootSequenceLengthSpinner) - )); - - toggleEnabled(mMiscConfig.mBootsequenceEnabled); - } - - private void toggleEnabled(boolean pEnabled) { - mBootSequenceLabel.setEnabled(pEnabled); - mBootSequenceCombo.setEnabled(pEnabled); - mBootSequenceLengthLabel.setEnabled(pEnabled); - mBootSequenceLengthSpinner.setEnabled(pEnabled); - } - - private final ActionListener mActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - mMiscConfig.mBootsequenceEnabled = mBootSequenceCheck.isSelected(); - mMiscConfig.mBootSequence = (BootSequence) mBootSequenceCombo.getSelectedItem(); - - toggleEnabled(mMiscConfig.mBootsequenceEnabled); - } - }; - - private final ChangeListener mChangeListener = new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - mMiscConfig.mBootSequenceLength_ms = (Integer)mBootSequenceLengthSpinner.getValue(); - } - }; -} diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/ConfigPanel.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/ConfigPanel.java index b757aa18..a7d06cf8 100644 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/ConfigPanel.java +++ b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/ConfigPanel.java @@ -21,7 +21,6 @@ import org.hyperion.hypercon.ConfigurationFile; import org.hyperion.hypercon.LedFrameFactory; import org.hyperion.hypercon.LedString; import org.hyperion.hypercon.Main; -import org.hyperion.hypercon.gui.effectengine.EffectEnginePanel; /** * The main-config panel of HyperCon. Includes the configuration and the panels to edit and @@ -134,7 +133,6 @@ public class ConfigPanel extends JPanel { mSpecificationTabs.addTab("Hardware", getHardwarePanel()); mSpecificationTabs.addTab("Process", getProcessPanel()); mSpecificationTabs.addTab("External", getExternalPanel()); - mSpecificationTabs.addTab("Effect Engine", new EffectEnginePanel(ledString.mEffectEngineConfig)); } return mSpecificationTabs; } @@ -173,7 +171,6 @@ public class ConfigPanel extends JPanel { mProcessPanel = new JPanel(); mProcessPanel.setLayout(new BoxLayout(mProcessPanel, BoxLayout.Y_AXIS)); - mProcessPanel.add(new BootSequencePanel(ledString.mMiscConfig)); mProcessPanel.add(new FrameGrabberPanel(ledString.mMiscConfig)); mProcessPanel.add(new ColorSmoothingPanel(ledString.mColorConfig)); mProcessPanel.add(new ColorsPanel(ledString.mColorConfig)); @@ -189,7 +186,7 @@ public class ConfigPanel extends JPanel { mExternalPanel.add(new XbmcPanel(ledString.mMiscConfig)); mExternalPanel.add(new InterfacePanel(ledString.mMiscConfig)); - mExternalPanel.add(new org.hyperion.hypercon.gui.EffectEnginePanel()); + mExternalPanel.add(new EffectEnginePanel(ledString.mMiscConfig)); mExternalPanel.add(Box.createVerticalGlue()); } return mExternalPanel; diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/DevicePanel.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/DevicePanel.java index 721fced0..90219e28 100644 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/DevicePanel.java +++ b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/DevicePanel.java @@ -1,5 +1,6 @@ package org.hyperion.hypercon.gui; +import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -10,11 +11,8 @@ import javax.swing.GroupLayout; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.JSpinner; -import javax.swing.SpinnerNumberModel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; +import org.hyperion.hypercon.gui.device.DeviceTypePanel; import org.hyperion.hypercon.spec.ColorByteOrder; import org.hyperion.hypercon.spec.DeviceConfig; import org.hyperion.hypercon.spec.DeviceType; @@ -25,15 +23,10 @@ public class DevicePanel extends JPanel { private final DeviceConfig mDeviceConfig; - private JLabel mTypeLabel; private JComboBox mTypeCombo; - private JLabel mOutputLabel; - private JComboBox mOutputCombo; - - private JLabel mBaudrateLabel; - private JSpinner mBaudrateSpinner; + private JPanel mDevicePanel; private JLabel mRgbLabel; private JComboBox mRgbCombo; @@ -57,16 +50,8 @@ public class DevicePanel extends JPanel { private void initialise() { setBorder(BorderFactory.createTitledBorder("Device")); - mOutputLabel = new JLabel("Output"); - add(mOutputLabel); - - mOutputCombo = new JComboBox<>(KnownOutputs); - mOutputCombo.setEditable(true); - mOutputCombo.setSelectedItem(mDeviceConfig.mOutput); - mOutputCombo.addActionListener(mActionListener); - add(mOutputCombo); - - mTypeLabel = new JLabel("LED Type:"); + mTypeLabel = new JLabel("Type: "); + mTypeLabel.setMinimumSize(new Dimension(80, 10)); add(mTypeLabel); mTypeCombo = new JComboBox<>(DeviceType.values()); @@ -74,14 +59,17 @@ public class DevicePanel extends JPanel { mTypeCombo.addActionListener(mActionListener); add(mTypeCombo); - mBaudrateLabel = new JLabel("Baudrate"); - add(mBaudrateLabel); + mDevicePanel = new JPanel(); + mDevicePanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); + mDevicePanel.setLayout(new BorderLayout()); + DeviceTypePanel typePanel = mDeviceConfig.mType.getConfigPanel(mDeviceConfig); + if (typePanel != null) { + mDevicePanel.add(typePanel, BorderLayout.CENTER); + } + add(mDevicePanel); - mBaudrateSpinner = new JSpinner(new SpinnerNumberModel(mDeviceConfig.mBaudrate, 1, 1000000, 128)); - mBaudrateSpinner.addChangeListener(mChangeListener); - add(mBaudrateSpinner); - - mRgbLabel = new JLabel("RGB Byte Order"); + mRgbLabel = new JLabel("RGB Byte Order: "); + mRgbLabel.setMinimumSize(new Dimension(80, 10)); add(mRgbLabel); mRgbCombo = new JComboBox<>(ColorByteOrder.values()); @@ -89,52 +77,41 @@ public class DevicePanel extends JPanel { mRgbCombo.addActionListener(mActionListener); add(mRgbCombo); - GroupLayout layout = new GroupLayout(this); layout.setAutoCreateGaps(true); setLayout(layout); - layout.setHorizontalGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup() - .addComponent(mOutputLabel) - .addComponent(mTypeLabel) - .addComponent(mBaudrateLabel) - .addComponent(mRgbLabel)) - .addGroup(layout.createParallelGroup() - .addComponent(mOutputCombo) - .addComponent(mTypeCombo) - .addComponent(mBaudrateSpinner) - .addComponent(mRgbCombo)) - ); - layout.setVerticalGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup() - .addComponent(mOutputLabel) - .addComponent(mOutputCombo)) - .addGroup(layout.createParallelGroup() + layout.setHorizontalGroup(layout.createParallelGroup() + .addGroup(layout.createSequentialGroup() .addComponent(mTypeLabel) .addComponent(mTypeCombo)) - .addGroup(layout.createParallelGroup() - .addComponent(mBaudrateLabel) - .addComponent(mBaudrateSpinner)) - .addGroup(layout.createParallelGroup() + .addComponent(mDevicePanel) + .addGroup(layout.createSequentialGroup() .addComponent(mRgbLabel) .addComponent(mRgbCombo))); + layout.setVerticalGroup(layout.createParallelGroup() + .addGroup(layout.createSequentialGroup() + .addComponent(mTypeLabel) + .addComponent(mDevicePanel) + .addComponent(mRgbLabel)) + .addGroup(layout.createSequentialGroup() + .addComponent(mTypeCombo) + .addComponent(mDevicePanel) + .addComponent(mRgbCombo))); } private final ActionListener mActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mDeviceConfig.mType = (DeviceType)mTypeCombo.getSelectedItem(); - mDeviceConfig.mOutput = (String)mOutputCombo.getSelectedItem(); - mDeviceConfig.mBaudrate = (Integer)mBaudrateSpinner.getValue(); mDeviceConfig.mColorByteOrder = (ColorByteOrder)mRgbCombo.getSelectedItem(); - } - }; - - private final ChangeListener mChangeListener = new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - mDeviceConfig.mBaudrate = (Integer)mBaudrateSpinner.getValue(); + + mDevicePanel.removeAll(); + DeviceTypePanel typePanel = mDeviceConfig.mType.getConfigPanel(mDeviceConfig); + if (typePanel != null) { + mDevicePanel.add(typePanel, BorderLayout.CENTER); + } + revalidate(); } }; } diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/EffectEnginePanel.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/EffectEnginePanel.java index 0442aac7..0526ea7e 100644 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/EffectEnginePanel.java +++ b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/EffectEnginePanel.java @@ -1,14 +1,28 @@ package org.hyperion.hypercon.gui; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + import javax.swing.BorderFactory; import javax.swing.GroupLayout; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import org.hyperion.hypercon.spec.MiscConfig; + +/** + * THe EffectEnginePanel contains the components for configuring the parameters of the Effect Engine + */ public class EffectEnginePanel extends JPanel { + /** The MISC config contains the effect engine settings */ + private final MiscConfig mMiscConfig; + private JLabel mPathLabel; private JTextField mPathField; @@ -17,9 +31,11 @@ public class EffectEnginePanel extends JPanel { private JLabel mBootSequenceLabel; private JTextField mBootSequenceField; - public EffectEnginePanel() { + public EffectEnginePanel(final MiscConfig pMiscConfig) { super(); + mMiscConfig = pMiscConfig; + initialise(); } @@ -27,9 +43,26 @@ public class EffectEnginePanel extends JPanel { setBorder(BorderFactory.createTitledBorder("Effect Engine")); mPathLabel = new JLabel("Directory: "); + mPathLabel.setMinimumSize(new Dimension(80, 10)); add(mPathLabel); mPathField = new JTextField(); + mPathField.setMaximumSize(new Dimension(1024, 20)); + mPathField.setText(mMiscConfig.mEffectEnginePath); + mPathField.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void removeUpdate(DocumentEvent e) { + mMiscConfig.mEffectEnginePath = mPathField.getText(); + } + @Override + public void insertUpdate(DocumentEvent e) { + mMiscConfig.mEffectEnginePath = mPathField.getText(); + } + @Override + public void changedUpdate(DocumentEvent e) { + mMiscConfig.mEffectEnginePath = mPathField.getText(); + } + }); add(mPathField); add(getBootSequencePanel()); @@ -56,22 +89,51 @@ public class EffectEnginePanel extends JPanel { mBootSequencePanel.setBorder(BorderFactory.createTitledBorder("Bootsequence")); mBootSequenceCheck = new JCheckBox("Enabled"); + mBootSequenceCheck.setSelected(mMiscConfig.mBootSequenceEnabled); + mBootSequenceCheck.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + mMiscConfig.mBootSequenceEnabled = mBootSequenceCheck.isSelected(); + mBootSequenceLabel.setEnabled(mMiscConfig.mBootSequenceEnabled); + mBootSequenceField.setEnabled(mMiscConfig.mBootSequenceEnabled); + } + }); mBootSequencePanel.add(mBootSequenceCheck); mBootSequenceLabel = new JLabel("Type:"); + mBootSequenceLabel.setMinimumSize(new Dimension(75, 10)); + mBootSequenceLabel.setEnabled(mMiscConfig.mBootSequenceEnabled); mBootSequencePanel.add(mBootSequenceLabel); mBootSequenceField = new JTextField(); + mBootSequenceField.setMaximumSize(new Dimension(1024, 20)); + mBootSequenceField.setText(mMiscConfig.mBootSequenceEffect); + mBootSequenceField.setEnabled(mMiscConfig.mBootSequenceEnabled); + mBootSequenceField.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void removeUpdate(DocumentEvent e) { + mMiscConfig.mBootSequenceEffect = mBootSequenceField.getText(); + } + @Override + public void insertUpdate(DocumentEvent e) { + mMiscConfig.mBootSequenceEffect = mBootSequenceField.getText(); + } + @Override + public void changedUpdate(DocumentEvent e) { + mMiscConfig.mBootSequenceEffect = mBootSequenceField.getText(); + } + }); mBootSequencePanel.add(mBootSequenceField); GroupLayout layout = new GroupLayout(mBootSequencePanel); mBootSequencePanel.setLayout(layout); layout.setVerticalGroup(layout.createSequentialGroup() + .addComponent(mBootSequenceCheck) .addGroup(layout.createParallelGroup() .addComponent(mBootSequenceLabel) .addComponent(mBootSequenceField)) - .addComponent(mBootSequenceCheck)); + ); layout.setHorizontalGroup(layout.createParallelGroup() .addGroup(layout.createSequentialGroup() diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/ColorPicker.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/ColorPicker.java deleted file mode 100644 index 387607b0..00000000 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/ColorPicker.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.hyperion.hypercon.gui.effectengine; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -import javax.swing.JColorChooser; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPopupMenu; - -public class ColorPicker extends JComponent { - - private JLabel mLabel; - private JButton mButton; - - JPopupMenu mPopup = new JPopupMenu(); - JColorChooser mColorChooser = new JColorChooser(); - - private Color mSelectedColor = Color.RED; - - public ColorPicker() { - super(); - - initialise(); - } - - private void initialise() { - setLayout(new BorderLayout()); - - mLabel = new JLabel("[23, 123, 1]"); - add(mLabel, BorderLayout.CENTER); - - mButton = new JButton(); - mButton.setPreferredSize(new Dimension(25, 25)); - add(mButton, BorderLayout.EAST); - - mPopup.add(mColorChooser); - mButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - Color newColor = JColorChooser.showDialog(ColorPicker.this, "Select a color", mSelectedColor); - if (newColor == null) { - return; - } - setColor(newColor); - } - }); - } - - public void setColor(Color pColor) { - mSelectedColor = pColor; - mLabel.setText(String.format("[%d, %d, %d]", mSelectedColor.getRed(), mSelectedColor.getGreen(), mSelectedColor.getBlue())); - } - - public Color getColor() { - return mSelectedColor; - } - - public static void main(String[] pArgs) { - JFrame frame = new JFrame(); - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - frame.setSize(240, 100); - - frame.getContentPane().setLayout(new BorderLayout()); - frame.getContentPane().add(new ColorPicker()); - - frame.setVisible(true); - } -} diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/EffectArgumentCellEditor.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/EffectArgumentCellEditor.java deleted file mode 100644 index 51e07587..00000000 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/EffectArgumentCellEditor.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.hyperion.hypercon.gui.effectengine; - -import java.awt.Color; -import java.awt.Component; -import java.awt.event.MouseEvent; -import java.text.ParseException; -import java.util.EventObject; - -import javax.swing.AbstractCellEditor; -import javax.swing.JCheckBox; -import javax.swing.JSpinner; -import javax.swing.JSpinner.DefaultEditor; -import javax.swing.JTable; -import javax.swing.JTextField; -import javax.swing.SpinnerNumberModel; -import javax.swing.table.TableCellEditor; - - -public class EffectArgumentCellEditor extends AbstractCellEditor implements TableCellEditor { - - int selEditor = 0; - - private JSpinner mIntegerSpinner = new JSpinner(new SpinnerNumberModel(0, Integer.MIN_VALUE, Integer.MAX_VALUE, 1)); - private JSpinner mDoubleSpinner = new JSpinner(new SpinnerNumberModel(0.0, -Double.MAX_VALUE, Double.MAX_VALUE, 1.0)); - private JCheckBox mBooleanCheck = new JCheckBox(); - private JTextField mStringEditor = new JTextField(); - private ColorPicker mColorChooser = new ColorPicker(); - - @Override - public boolean shouldSelectCell(EventObject anEvent) { - return true; - } - - @Override - public boolean isCellEditable(EventObject anEvent) { - if (anEvent instanceof MouseEvent) { - return ((MouseEvent)anEvent).getClickCount() >= 2; - } - return true; - } - - @Override - public boolean stopCellEditing() { - try { - // Make sure manually editted values are comitted - ((DefaultEditor)mIntegerSpinner.getEditor()).commitEdit(); - ((DefaultEditor)mDoubleSpinner.getEditor()).commitEdit(); - } catch (ParseException e) { - } - return super.stopCellEditing(); - } - - @Override - public Object getCellEditorValue() { - switch (selEditor) { - case 0: - return mIntegerSpinner.getValue(); - case 1: - return mDoubleSpinner.getValue(); - case 2: - return mBooleanCheck.isSelected(); - case 3: - return mStringEditor.getText(); - case 4: - return mColorChooser.getColor(); - } - - return null; - } - - @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - if (value instanceof Integer) { - selEditor = 0; - mIntegerSpinner.setValue((Integer)value); - return mIntegerSpinner; - } else if (value instanceof Double) { - selEditor = 1; - mDoubleSpinner.setValue((Double)value); - return mDoubleSpinner; - } else if (value instanceof Boolean) { - selEditor = 2; - mBooleanCheck.setSelected((Boolean)value); - return mBooleanCheck; - } else if (value instanceof Color) { - selEditor = 4; - mColorChooser.setColor((Color)value); - return mColorChooser; - } - - selEditor = 3; - mStringEditor.setText('"' + value.toString() + '"'); - return mStringEditor; - } - -} diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/EffectArgumentType.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/EffectArgumentType.java deleted file mode 100644 index f707abb6..00000000 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/EffectArgumentType.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.hyperion.hypercon.gui.effectengine; - -import java.awt.Color; - -/** - * Enumeration for the type of possible effect-arguments - */ -public enum EffectArgumentType { - /** The 'int' instance of the argument-type, maps to 'int' or {@link java.lang.Integer} */ - int_arg("int"), - /** The 'double' instance of the argument-type, maps to 'double' or {@link java.lang.Double} */ - double_arg("double"), - /** The 'color' instance of the argument-type, maps to {@link java.awt.Color} */ - color_arg("color"), - /** The 'string' instance of the argument-type, maps to {@link java.lang.String} */ - string_arg("string"); - - /** The 'pretty' name of the effect argument type (should be unique) */ - private final String mName; - - /** - * Constructs the EffectArgumentType with the given name - * - * @param pName The name of the type - */ - private EffectArgumentType(final String pName) { - mName = pName; - } - - public Object getDefaultValue() { - switch(this) { - case int_arg: - return 0; - case double_arg: - return 0.0; - case color_arg: - return Color.WHITE; - case string_arg: - return ""; - } - return ""; - } - - /** - * Returns the string representation of the argument-type, which is its set name - * - * @return The name of the EffectArgumentType - */ - @Override - public String toString() { - return mName; - } -} diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/EffectEnginePanel.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/EffectEnginePanel.java deleted file mode 100644 index a94081ee..00000000 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/EffectEnginePanel.java +++ /dev/null @@ -1,419 +0,0 @@ -package org.hyperion.hypercon.gui.effectengine; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.Transient; -import java.util.Vector; - -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; -import javax.swing.ComboBoxEditor; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.JTextField; -import javax.swing.ListSelectionModel; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.table.AbstractTableModel; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableColumn; - -import org.hyperion.hypercon.spec.EffectConfig; -import org.hyperion.hypercon.spec.EffectConfig.EffectArg; -import org.hyperion.hypercon.spec.EffectEngineConfig; - -public class EffectEnginePanel extends JPanel { - /** The Effect Engine configuration */ - private final EffectEngineConfig mEffectEngingeConfig; - - /** The combobox model for selecting an effect configuration */ - private final DefaultComboBoxModel mEffectModel; - - private final DefaultComboBoxModel mPythonScriptModel; - - private JPanel mControlPanel; - private JComboBox mEffectCombo; - private JButton mCloneButton; - private JButton mAddButton; - private JButton mDelButton; - - private JPanel mEffectPanel; - private JLabel mPythonLabel; - private JTextField mPythonField; - private JPanel mEffectArgumentPanel; - private JTable mEffectArgumentTable; - private JPanel mArgumentControlPanel; - private JButton mAddArgumentButton; - private JButton mDelArgumentButton; - - private AbstractTableModel mEffectArgumentTableModel = new AbstractTableModel() { - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - EffectConfig effect = (EffectConfig) mEffectModel.getSelectedItem(); - if (effect == null) { - return false; - } - if (rowIndex == effect.mArgs.size()) { - return columnIndex == 0; - } - return true; - }; - - @Override - public int getColumnCount() { - return 2; - } - - @Override - public String getColumnName(int column) { - switch (column) { - case 0: - return "name"; - case 1: - return "value"; - } - return ""; - }; - - @Override - public int getRowCount() { - EffectConfig effect = (EffectConfig) mEffectModel.getSelectedItem(); - if (effect == null) { - return 0; - } - return effect.mArgs.size(); - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - EffectConfig effect = (EffectConfig) mEffectModel.getSelectedItem(); - if (effect == null) { - return ""; - } - if (rowIndex == effect.mArgs.size()) { - if (columnIndex == 0) { - return "[key]"; - } - return ""; - } - if (columnIndex == 0) { - return effect.mArgs.get(rowIndex).key; - } else if (columnIndex == 1){ - return effect.mArgs.get(rowIndex).value; - - } - return ""; - } - - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - EffectConfig effect = (EffectConfig) mEffectModel.getSelectedItem(); - if (effect == null) { - return; - } - - if (rowIndex == effect.mArgs.size()) { - String key = aValue.toString().trim(); - if (key.isEmpty() || key.equals("[key]")) { - return; - } - - effect.mArgs.addElement(new EffectConfig.EffectArg(aValue.toString(), "")); - return; - } - if (columnIndex == 0) { - String key = aValue.toString().trim(); - if (!key.isEmpty()) { - effect.mArgs.get(rowIndex).key = (String)aValue; - } - } else { - effect.mArgs.get(rowIndex).value = aValue; - } - }; - }; - - public EffectEnginePanel(final EffectEngineConfig pEffectEngineConfig) { - super(); - - mEffectEngingeConfig = pEffectEngineConfig; - mEffectModel = new DefaultComboBoxModel(mEffectEngingeConfig.mEffects); - mPythonScriptModel = new DefaultComboBoxModel<>(); - for (EffectConfig effect : mEffectEngingeConfig.mEffects) { - if (mPythonScriptModel.getIndexOf(effect.mScript) >= 0) { - continue; - } - mPythonScriptModel.addElement(effect.mScript); - } - - initialise(); - - effectSelectionChanged(); - } - - private void initialise() { - setLayout(new BorderLayout()); - - add(getControlPanel(), BorderLayout.NORTH); - add(getEffectPanel(), BorderLayout.CENTER); - } - - @Override - @Transient - public Dimension getMaximumSize() { - Dimension maxSize = super.getMaximumSize(); - Dimension prefSize = super.getPreferredSize(); - return new Dimension(maxSize.width, prefSize.height); - } - - private void effectSelectionChanged() { - EffectConfig effect = (EffectConfig)mEffectModel.getSelectedItem(); - - // Enable option for the selected effect or disable if none selected - mEffectPanel.setEnabled(effect != null); - mPythonLabel.setEnabled(effect != null); - mPythonField.setEnabled(effect != null); - mEffectArgumentTable.setEnabled(effect != null); - - - if (effect == null) { - // Clear all fields - mPythonField.setText(""); - mEffectArgumentTableModel.fireTableDataChanged(); - return; - } else { - // Update fields based on the selected effect - mPythonField.setText(effect.mScript); - mEffectArgumentTableModel.fireTableDataChanged(); - } - } - - private JPanel getControlPanel() { - if (mControlPanel == null) { - mControlPanel = new JPanel(); - mControlPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 2, 5)); - mControlPanel.setPreferredSize(new Dimension(150, 25)); - mControlPanel.setLayout(new BoxLayout(mControlPanel, BoxLayout.LINE_AXIS)); - - mEffectCombo = new JComboBox<>(mEffectModel); - mEffectCombo.setEditable(true); - mEffectCombo.setEditor(new ComboBoxEditor() { - private final JTextField mTextField = new JTextField(); - - private EffectConfig mCurrentEffect = null; - - @Override - public void setItem(Object anObject) { - if (anObject instanceof EffectConfig) { - mCurrentEffect = (EffectConfig) anObject; - mTextField.setText(mCurrentEffect.mId); - } - } - - @Override - public void selectAll() { - if (mCurrentEffect == null) { - return; - } - mTextField.selectAll(); - } - - @Override - public Object getItem() { - String newId = mTextField.getText().trim(); - if (newId.isEmpty() || newId.contains("\"")) { - return mCurrentEffect; - } - mCurrentEffect.mId = newId; - return mCurrentEffect; } - - @Override - public Component getEditorComponent() { - return mTextField; - } - - private final Vector mActionListeners = new Vector<>(); - @Override - public void addActionListener(ActionListener l) { - mActionListeners.add(l); - } - @Override - public void removeActionListener(ActionListener l) { - mActionListeners.remove(l); - } - }); - mEffectCombo.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - effectSelectionChanged(); - } - }); - mControlPanel.add(mEffectCombo); - - mCloneButton = new JButton("Clone"); - mCloneButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - EffectConfig effect = (EffectConfig) mEffectModel.getSelectedItem(); - EffectConfig effectClone = effect.clone(); - effectClone.mId += " [clone]"; - mEffectModel.addElement(effectClone); - mEffectModel.setSelectedItem(effectClone); - } - }); - mControlPanel.add(mCloneButton); - - mAddButton = new JButton("Add"); - mAddButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - String newId = JOptionPane.showInputDialog(mAddButton, "Name of the new effect: ", "Effect Name", JOptionPane.QUESTION_MESSAGE); - // Make that an ID is set - if (newId == null || newId.isEmpty()) { - return; - } - // Make sure the ID does not yet exist - for (EffectConfig effect : mEffectEngingeConfig.mEffects) { - if (effect.mId.equalsIgnoreCase(newId)) { - JOptionPane.showMessageDialog(mAddButton, "Given name(" + effect.mId + ") allready exists", "Duplicate effect name", JOptionPane.ERROR_MESSAGE); - return; - } - } - - EffectConfig newConfig = new EffectConfig(); - newConfig.mId = newId; - mEffectModel.addElement(newConfig); - mEffectModel.setSelectedItem(newConfig); - } - }); - mControlPanel.add(mAddButton); - - mDelButton = new JButton("Del"); - mDelButton.setEnabled(mEffectModel.getSize() > 0); - mDelButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (mEffectModel.getSelectedItem() != null) { - mEffectModel.removeElement(mEffectModel.getSelectedItem()); - } - mDelButton.setEnabled(mEffectModel.getSize() > 0); - } - }); - mControlPanel.add(mDelButton); - } - return mControlPanel; - } - - private JPanel getEffectPanel() { - if (mEffectPanel == null) { - mEffectPanel = new JPanel(); - mEffectPanel.setBorder(BorderFactory.createTitledBorder("")); - mEffectPanel.setLayout(new BoxLayout(mEffectPanel, BoxLayout.PAGE_AXIS)); - - JPanel subPanel = new JPanel(new BorderLayout()); - subPanel.setPreferredSize(new Dimension(150, 25)); - subPanel.setMaximumSize(new Dimension(20000, 20)); - mEffectPanel.add(subPanel); - - mPythonLabel = new JLabel("Python: "); - subPanel.add(mPythonLabel, BorderLayout.WEST); - - mPythonField = new JTextField(); - mPythonField.getDocument().addDocumentListener(new DocumentListener() { - @Override - public void removeUpdate(DocumentEvent e) { - update(); - } - @Override - public void insertUpdate(DocumentEvent e) { - update(); - } - @Override - public void changedUpdate(DocumentEvent e) { - update(); - } - private void update() { - EffectConfig effect = (EffectConfig) mEffectModel.getSelectedItem(); - if (effect == null) { - return; - } - effect.mScript = mPythonField.getText(); - } - }); - mPythonField.setMaximumSize(new Dimension(150, 25)); - subPanel.add(mPythonField); - - mEffectArgumentPanel = new JPanel(); - mEffectArgumentPanel.setBorder(BorderFactory.createTitledBorder("Arguments")); - mEffectArgumentPanel.setLayout(new BorderLayout()); - - mEffectArgumentTable = new JTable(mEffectArgumentTableModel); - mEffectArgumentTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - mEffectArgumentPanel.add(new JScrollPane(mEffectArgumentTable), BorderLayout.CENTER); - - mEffectArgumentPanel.add(getArgumentControlPanel(), BorderLayout.SOUTH); - - mEffectPanel.add(mEffectArgumentPanel); - -// mEffectArgumentTable.getColumnModel().getColumn(0).setMaxWidth(100); - TableColumn col = mEffectArgumentTable.getColumnModel().getColumn(1); -// col.setMaxWidth(100); - col.setCellEditor(new EffectArgumentCellEditor()); - col.setCellRenderer(new DefaultTableCellRenderer() { - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - if (value instanceof Color) { - Color color = (Color)value; - value = String.format("[%d, %d, %d]", color.getRed(), color.getGreen(), color.getBlue()); - } - return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - } - }); - } - return mEffectPanel; - } - - private JPanel getArgumentControlPanel() { - if (mArgumentControlPanel == null) { - mArgumentControlPanel = new JPanel(); - - mAddArgumentButton = new JButton("+"); - mAddArgumentButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - EffectArg newArg = NewEffectArgumentDialog.showDialog(); - if (newArg != null) { - ((EffectConfig)mEffectModel.getSelectedItem()).mArgs.add(newArg); - int row = ((EffectConfig)mEffectModel.getSelectedItem()).mArgs.size()-1; - mEffectArgumentTableModel.fireTableRowsInserted(row, row); - } - } - }); - mArgumentControlPanel.add(mAddArgumentButton); - - mDelArgumentButton = new JButton("-"); - mDelArgumentButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - int selRow = mEffectArgumentTable.getSelectedRow(); - if (selRow >= 0) { - ((EffectConfig)mEffectModel.getSelectedItem()).mArgs.remove(selRow); - mEffectArgumentTableModel.fireTableRowsDeleted(selRow, selRow); - } - } - }); - mArgumentControlPanel.add(mDelArgumentButton); - } - return mArgumentControlPanel; - } -} diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/NewEffectArgumentDialog.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/NewEffectArgumentDialog.java deleted file mode 100644 index 05efc046..00000000 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/gui/effectengine/NewEffectArgumentDialog.java +++ /dev/null @@ -1,228 +0,0 @@ -package org.hyperion.hypercon.gui.effectengine; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.GroupLayout; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; - -import org.hyperion.hypercon.spec.EffectConfig.EffectArg; - -/** - * Dialog for specifying the required parameters (name and type) of an effect argument. - */ -public class NewEffectArgumentDialog extends JDialog { - - /** Return mask for cancellation (cancel-button, closing, etc) */ - public static final int CANCEL_OPTION = 1; - /** Return mask for accepting (ok-button) */ - public static final int OK_OPTION = 2; - - /** Panel contains the parameters that require configuration by the user */ - private JPanel mArgumentPanel; - private JLabel mNameLabel; - private JTextField mNameField; - private JLabel mTypeLabel; - private JComboBox mTypeCombo; - - /** Panel contains the controls for the dialog */ - private JPanel mControlPanel; - private JButton mOkButton; - private JButton mCancelButton; - - /** The current return value for the dialog */ - private int mReturnValue; - - /** - * Constructs an empty NewEffectArgumentDialog - */ - public NewEffectArgumentDialog() { - super(); - - initialise(); - - mNameField.addKeyListener(mKeyListener); - mTypeCombo.addKeyListener(mKeyListener); - mOkButton.addKeyListener(mKeyListener); - mCancelButton.addKeyListener(mKeyListener); - } - - /** - * Initialises the dialog, constructing all its sub-panels and components - */ - private void initialise() { - setTitle("New effect argument"); - setResizable(false); - setSize(320,150); - setLayout(new BorderLayout()); - setModal(true); - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - - add(getArgumentPanel(), BorderLayout.CENTER); - add(getControlPanel(), BorderLayout.SOUTH); - - mOkAction.setEnabled(false); - } - - /** - * Initialises, if not yet initialised, and returns the argument configuration panel - * - * @return The argument configuration panel ({@link #mArgumentPanel}) - */ - private JPanel getArgumentPanel() { - if (mArgumentPanel == null) { - mArgumentPanel = new JPanel(); - mArgumentPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); - - mNameLabel = new JLabel("Name: "); - mArgumentPanel.add(mNameLabel); - - mNameField = new JTextField(""); - mNameField.getDocument().addDocumentListener(new DocumentListener() { - @Override - public void removeUpdate(DocumentEvent e) { - documentChanged(); - } - - @Override - public void insertUpdate(DocumentEvent e) { - documentChanged(); - } - - @Override - public void changedUpdate(DocumentEvent e) { - documentChanged(); - } - - private void documentChanged() { - String name = mNameField.getText(); - boolean validName = !(name.isEmpty() || name.contains("\"")); - mOkAction.setEnabled(validName); - } - }); - mArgumentPanel.add(mNameField); - - mTypeLabel = new JLabel("Type: "); - mArgumentPanel.add(mTypeLabel); - - mTypeCombo = new JComboBox<>(EffectArgumentType.values()); - mArgumentPanel.add(mTypeCombo); - - GroupLayout layout = new GroupLayout(mArgumentPanel); - layout.setAutoCreateGaps(true); - mArgumentPanel.setLayout(layout); - - layout.setHorizontalGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup() - .addComponent(mNameLabel) - .addComponent(mTypeLabel)) - .addGroup(layout.createParallelGroup() - .addComponent(mNameField) - .addComponent(mTypeCombo))); - - layout.setVerticalGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup() - .addComponent(mNameLabel) - .addComponent(mNameField)) - .addGroup(layout.createParallelGroup() - .addComponent(mTypeLabel) - .addComponent(mTypeCombo))); - } - return mArgumentPanel; - } - - /** - * Initialises, if not yet initialised, and returns the dialog control panel - * - * @return The dialog control panel ({@link #mControlPanel}) - */ - private JPanel getControlPanel() { - if (mControlPanel == null) { - mControlPanel = new JPanel(); - mControlPanel.setLayout(new FlowLayout(FlowLayout.TRAILING)); - - mOkButton = new JButton(mOkAction); - mControlPanel.add(mOkButton); - - mCancelButton = new JButton(mCancelAction); - mControlPanel.add(mCancelButton); - } - return mControlPanel; - } - - /** - * Shows a new instance of the NewEffectArgumentDialog and constructs anew EffectArg. - * - * @return The newly constructed argument (or null if cancelled) - */ - public static EffectArg showDialog() { - NewEffectArgumentDialog dialog = new NewEffectArgumentDialog(); - dialog.mReturnValue = CANCEL_OPTION; - dialog.setVisible(true); - if (dialog.mReturnValue == OK_OPTION) { - String name = dialog.mNameField.getText(); - EffectArgumentType type = (EffectArgumentType) dialog.mTypeCombo.getSelectedItem(); - - return new EffectArg(name, type.getDefaultValue()); - } - - return null; - } - - private final KeyListener mKeyListener = new KeyListener() { - @Override - public void keyTyped(KeyEvent e) { - if (e.getKeyChar() == KeyEvent.VK_ENTER) { - if (mOkAction.isEnabled()) { - mOkAction.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "Ok")); - } - } else if (e.getKeyChar() == KeyEvent.VK_ESCAPE) { - mCancelAction.actionPerformed(new ActionEvent(e.getSource(), e.getID(), "Cancel")); - } - } - @Override - public void keyReleased(KeyEvent e) { - } - @Override - public void keyPressed(KeyEvent e) { - } - }; - - /** Action for handling 'OK' */ - private final Action mOkAction = new AbstractAction("Ok") { - @Override - public void actionPerformed(ActionEvent e) { - mReturnValue = OK_OPTION; - setVisible(false); - } - }; - - /** Action for handling 'CANCEL' */ - private final Action mCancelAction = new AbstractAction("Cancel") { - @Override - public void actionPerformed(ActionEvent e) { - mReturnValue = CANCEL_OPTION; - setVisible(false); - } - }; - - /** - * Test entry-point for showing the dialog - */ - public static void main(String[] pArgs) { - NewEffectArgumentDialog.showDialog(); - } -} diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/BootSequence.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/BootSequence.java deleted file mode 100644 index 0b7d9921..00000000 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/BootSequence.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.hyperion.hypercon.spec; - -/** - * Enumeration of possible boot sequences - */ -public enum BootSequence { - /** The rainbow boot sequence */ - rainbow, - /** The Knight Rider (or KITT) boot sequence */ - knightrider; - - /** - * Returns a string representation of the BootSequence - * - * @return String representation of this boot-sequence - */ - @Override - public String toString() { - switch(this) { - case rainbow: - return "Rainbow"; - case knightrider: - return "Knight Rider"; - } - return "None"; - } -} diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/DeviceType.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/DeviceType.java index 674c883c..ce94b32a 100644 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/DeviceType.java +++ b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/DeviceType.java @@ -1,5 +1,11 @@ package org.hyperion.hypercon.spec; +import org.hyperion.hypercon.gui.device.DeviceTypePanel; +import org.hyperion.hypercon.gui.device.LightPackPanel; +import org.hyperion.hypercon.gui.device.SerialPanel; +import org.hyperion.hypercon.gui.device.TestDevicePanel; +import org.hyperion.hypercon.gui.device.Ws2801Panel; + /** * Enumeration of known device types */ @@ -12,19 +18,68 @@ public enum DeviceType { lpd6803("LPD6803"), /** SEDU LED device */ sedu("SEDU"), + /** Lightberry device */ + lightberry("Lightberry"), /** Adalight device */ adalight("Adalight"), /** Lightpack USB led device */ lightpack("Lightpack"), + /** Paintpack USB led device */ + paintpack("Paintpack"), /** Test device for writing color values to file-output */ test("Test"), /** No device, no output is generated */ none("None"); + /** The 'pretty' name of the device type */ private final String mName; - private DeviceType(String name) { - mName = name; + /** The device specific configuration panel */ + private DeviceTypePanel mConfigPanel; + + /** + * Constructs the DeviceType + * + * @param name The 'pretty' name of the device type + * @param pConfigPanel The panel for device type specific configuration + */ + private DeviceType(final String name) { + mName = name; + } + + /** + * Returns the configuration panel for the this device-type (or null if no configuration is required) + * + * @return The panel for configuring this device type + */ + public DeviceTypePanel getConfigPanel(DeviceConfig pDeviceConfig) { + if (mConfigPanel == null) { + switch (this) { + case ws2801: + case lightberry: + case lpd6803: + case lpd8806: + mConfigPanel = new Ws2801Panel(); + break; + case test: + mConfigPanel = new TestDevicePanel(); + break; + case adalight: + case sedu: + mConfigPanel = new SerialPanel(); + break; + case lightpack: + mConfigPanel = new LightPackPanel(); + break; + case paintpack: + case none: + break; + } + } + if (mConfigPanel != null) { + mConfigPanel.setDeviceConfig(pDeviceConfig); + } + return mConfigPanel; } @Override diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/EffectEngineConfig.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/EffectEngineConfig.java deleted file mode 100644 index ae3c530b..00000000 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/EffectEngineConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.hyperion.hypercon.spec; - -import java.util.Vector; - -import org.hyperion.hypercon.JsonStringBuffer; - -/** - * The configuration structure for the effect engine. It contains definition for zero or more - * 'effects' - */ -public class EffectEngineConfig { - - public final Vector mEffects = new Vector<>(); - - public void appendTo(JsonStringBuffer pJsonBuf) { - pJsonBuf.startObject("effects"); - - for (EffectConfig effect : mEffects) { - effect.append(pJsonBuf, effect.equals(mEffects.get(mEffects.size()-1))); - } - - pJsonBuf.stopObject(); - } - - public void loadDefault() { - EffectConfig rainbowSwirl = new EffectConfig(); - rainbowSwirl.mId = "Rainbow swirl"; - rainbowSwirl.mScript = "rainbow-swirl.py"; - rainbowSwirl.mArgs.add(new EffectConfig.EffectArg("rotation-time", 10.0)); - rainbowSwirl.mArgs.add(new EffectConfig.EffectArg("brightness", 1.0)); - rainbowSwirl.mArgs.add(new EffectConfig.EffectArg("reverse", false)); - - EffectConfig rainbowMood = new EffectConfig(); - rainbowMood.mId = "Rainbow mood"; - rainbowMood.mScript = "rainbow-mood.py"; - rainbowMood.mArgs.add(new EffectConfig.EffectArg("rotation-time", 10.0)); - rainbowMood.mArgs.add(new EffectConfig.EffectArg("brightness", 1.0)); - rainbowMood.mArgs.add(new EffectConfig.EffectArg("reverse", false)); - - mEffects.add(rainbowSwirl); - mEffects.add(rainbowMood); - } -} diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/MiscConfig.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/MiscConfig.java index 794f54a6..86ec65f5 100644 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/MiscConfig.java +++ b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/MiscConfig.java @@ -6,13 +6,14 @@ import org.hyperion.hypercon.JsonStringBuffer; * Miscellaneous configuration items for the Hyperion daemon. */ public class MiscConfig { + + /** The absolute location(s) of the effects */ + public String mEffectEnginePath = "/opt/hyperion/effects"; - /** Flag indicating that the boot sequence is enabled */ - public boolean mBootsequenceEnabled = true; - /** The selected boot sequence */ - public BootSequence mBootSequence = BootSequence.rainbow; - /** The length of the boot sequence [ms] */ - public int mBootSequenceLength_ms = 3000; + /** Flag indicating that the boot sequence is enabled(true) or not(false) */ + public boolean mBootSequenceEnabled = true; + /** The effect selected for the boot sequence */ + public String mBootSequenceEffect = "Rainbow Swirl (fast)"; /** Flag indicating that the Frame Grabber is enabled */ public boolean mFrameGrabberEnabled = true; @@ -54,19 +55,25 @@ public class MiscConfig { public int mBoblightPort = 19333; public void appendTo(JsonStringBuffer strBuf) { - String bootsequenceComment = - "The boot-sequence configuration, contains the following items: \n" + - " * type : The type of the boot-sequence ('rainbow', 'knightrider', 'none') \n" + - " * duration_ms : The length of the boot-sequence [ms]\n"; - strBuf.writeComment(bootsequenceComment); + String effectEngineComment = + "The configuration of the effect engine, contains the following items: \n" + + " * paths : An array with absolute location(s) of directories with effects \n" + + " * bootsequence : The effect selected as 'boot sequence'"; + strBuf.writeComment(effectEngineComment); - strBuf.toggleComment(!mBootsequenceEnabled); - strBuf.startObject("bootsequence"); - strBuf.addValue("type", mBootSequence.name(), false); - strBuf.addValue("duration_ms", mBootSequenceLength_ms, true); - strBuf.stopObject(); + String[] effectPaths = mEffectEnginePath.split(":"); + + strBuf.startObject("effects"); + strBuf.startArray("paths"); + for (String effectPath : effectPaths) { + strBuf.addArrayElement(effectPath, effectPath == effectPaths[effectPaths.length-1]); + } + strBuf.stopArray(); + strBuf.toggleComment(!mBootSequenceEnabled); + strBuf.addValue("bootsequence", mBootSequenceEffect, true); strBuf.toggleComment(false); - + strBuf.stopObject(); + strBuf.newLine(); String grabComment = diff --git a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/TransformConfig.java b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/TransformConfig.java index a5893210..2c0c0f5b 100644 --- a/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/TransformConfig.java +++ b/src/config-tool/ConfigTool/src/org/hyperion/hypercon/spec/TransformConfig.java @@ -12,30 +12,30 @@ public class TransformConfig { /** The saturation gain (in HSV space) */ public double mSaturationGain = 1.0; /** The value gain (in HSV space) */ - public double mValueGain = 1.5; + public double mValueGain = 1.0; /** The minimum required RED-value (in RGB space) */ - public double mRedThreshold = 0.1; + public double mRedThreshold = 0.0; /** The gamma-curve correct for the RED-value (in RGB space) */ - public double mRedGamma = 2.0; + public double mRedGamma = 1.0; /** The black-level of the RED-value (in RGB space) */ public double mRedBlacklevel = 0.0; /** The white-level of the RED-value (in RGB space) */ - public double mRedWhitelevel = 0.8; + public double mRedWhitelevel = 1.0; /** The minimum required GREEN-value (in RGB space) */ - public double mGreenThreshold = 0.1; + public double mGreenThreshold = 0.0; /** The gamma-curve correct for the GREEN-value (in RGB space) */ - public double mGreenGamma = 2.0; + public double mGreenGamma = 1.0; /** The black-level of the GREEN-value (in RGB space) */ public double mGreenBlacklevel = 0.0; /** The white-level of the GREEN-value (in RGB space) */ public double mGreenWhitelevel = 1.0; /** The minimum required BLUE-value (in RGB space) */ - public double mBlueThreshold = 0.1; + public double mBlueThreshold = 0.0; /** The gamma-curve correct for the BLUE-value (in RGB space) */ - public double mBlueGamma = 2.0; + public double mBlueGamma = 1.0; /** The black-level of the BLUE-value (in RGB space) */ public double mBlueBlacklevel = 0.0; /** The white-level of the BLUE-value (in RGB space) */