Updated the device selection with specific sub panels per device type.

Former-commit-id: 312ffdb3213c4e3698477f117adb739cbcc6a941
This commit is contained in:
T. van der Zwan 2013-12-12 22:54:14 +01:00
parent b7e91b7013
commit 91f09eceb0
12 changed files with 389 additions and 87 deletions

View File

@ -1 +1 @@
a63791e2794fa0c76a2a5da3d0ce7b3e4f4089ff ada8097cb71b680dd6fa48cf190ff66c8814ad0b

View File

@ -104,12 +104,16 @@ public class JsonStringBuffer {
++mIndentLevel; ++mIndentLevel;
} }
public void stopArray() { public void stopArray(boolean lastValue) {
--mIndentLevel; --mIndentLevel;
startLine(); startLine();
if (lastValue) {
mStrBuf.append("]\n");
} else {
mStrBuf.append("],\n"); mStrBuf.append("],\n");
} }
}
public void addRawValue(String pKey, String pValue, boolean lastValue) { public void addRawValue(String pKey, String pValue, boolean lastValue) {

View File

@ -28,6 +28,8 @@ import org.hyperion.hypercon.spec.TransformConfig;
*/ */
public class ColorTransformPanel extends JPanel { public class ColorTransformPanel extends JPanel {
private final Dimension maxDim = new Dimension(1024, 20);
private final TransformConfig mColorConfig; private final TransformConfig mColorConfig;
private JPanel mIndexPanel; private JPanel mIndexPanel;
@ -131,45 +133,57 @@ public class ColorTransformPanel extends JPanel {
mRedTransformLabel = new JLabel("RED"); mRedTransformLabel = new JLabel("RED");
mRgbTransformPanel.add(mRedTransformLabel); mRgbTransformPanel.add(mRedTransformLabel);
mRedThresholdSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedThreshold, 0.0, 1.0, 0.1)); mRedThresholdSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedThreshold, 0.0, 1.0, 0.1));
mRedThresholdSpinner.setMaximumSize(maxDim);
mRedThresholdSpinner.addChangeListener(mChangeListener); mRedThresholdSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mRedThresholdSpinner); mRgbTransformPanel.add(mRedThresholdSpinner);
mRedGammaSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedGamma, 0.0, 100.0, 0.1)); mRedGammaSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedGamma, 0.0, 100.0, 0.1));
mRedThresholdSpinner.addChangeListener(mChangeListener); mRedGammaSpinner.setMaximumSize(maxDim);
mRedGammaSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mRedGammaSpinner); mRgbTransformPanel.add(mRedGammaSpinner);
mRedBlacklevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedBlacklevel, 0.0, 1.0, 0.1)); mRedBlacklevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedBlacklevel, 0.0, 1.0, 0.1));
mRedThresholdSpinner.addChangeListener(mChangeListener); mRedBlacklevelSpinner.setMaximumSize(maxDim);
mRedBlacklevelSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mRedBlacklevelSpinner); mRgbTransformPanel.add(mRedBlacklevelSpinner);
mRedWhitelevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedWhitelevel, 0.0, 1.0, 0.1)); mRedWhitelevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedWhitelevel, 0.0, 1.0, 0.1));
mRedThresholdSpinner.addChangeListener(mChangeListener); mRedWhitelevelSpinner.setMaximumSize(maxDim);
mRedWhitelevelSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mRedWhitelevelSpinner); mRgbTransformPanel.add(mRedWhitelevelSpinner);
mGreenTransformLabel = new JLabel("GREEN"); mGreenTransformLabel = new JLabel("GREEN");
mRgbTransformPanel.add(mGreenTransformLabel); mRgbTransformPanel.add(mGreenTransformLabel);
mGreenThresholdSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenThreshold, 0.0, 1.0, 0.1)); mGreenThresholdSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenThreshold, 0.0, 1.0, 0.1));
mGreenThresholdSpinner.setMaximumSize(maxDim);
mGreenThresholdSpinner.addChangeListener(mChangeListener); mGreenThresholdSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mGreenThresholdSpinner); mRgbTransformPanel.add(mGreenThresholdSpinner);
mGreenGammaSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenGamma, 0.0, 100.0, 0.1)); mGreenGammaSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenGamma, 0.0, 100.0, 0.1));
mGreenGammaSpinner.setMaximumSize(maxDim);
mGreenGammaSpinner.addChangeListener(mChangeListener); mGreenGammaSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mGreenGammaSpinner); mRgbTransformPanel.add(mGreenGammaSpinner);
mGreenBlacklevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenBlacklevel, 0.0, 1.0, 0.1)); mGreenBlacklevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenBlacklevel, 0.0, 1.0, 0.1));
mGreenBlacklevelSpinner.setMaximumSize(maxDim);
mGreenBlacklevelSpinner.addChangeListener(mChangeListener); mGreenBlacklevelSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mGreenBlacklevelSpinner); mRgbTransformPanel.add(mGreenBlacklevelSpinner);
mGreenWhitelevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenWhitelevel, 0.0, 1.0, 0.1)); mGreenWhitelevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenWhitelevel, 0.0, 1.0, 0.1));
mGreenWhitelevelSpinner.setMaximumSize(maxDim);
mGreenWhitelevelSpinner.addChangeListener(mChangeListener); mGreenWhitelevelSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mGreenWhitelevelSpinner); mRgbTransformPanel.add(mGreenWhitelevelSpinner);
mBlueTransformLabel = new JLabel("BLUE"); mBlueTransformLabel = new JLabel("BLUE");
mRgbTransformPanel.add(mBlueTransformLabel); mRgbTransformPanel.add(mBlueTransformLabel);
mBlueThresholdSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueThreshold, 0.0, 1.0, 0.1)); mBlueThresholdSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueThreshold, 0.0, 1.0, 0.1));
mBlueThresholdSpinner.setMaximumSize(maxDim);
mBlueThresholdSpinner.addChangeListener(mChangeListener); mBlueThresholdSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mBlueThresholdSpinner); mRgbTransformPanel.add(mBlueThresholdSpinner);
mBlueGammaSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueGamma, 0.0, 100.0, 0.1)); mBlueGammaSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueGamma, 0.0, 100.0, 0.1));
mBlueGammaSpinner.setMaximumSize(maxDim);
mBlueGammaSpinner.addChangeListener(mChangeListener); mBlueGammaSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mBlueGammaSpinner); mRgbTransformPanel.add(mBlueGammaSpinner);
mBlueBlacklevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueBlacklevel, 0.0, 1.0, 0.1)); mBlueBlacklevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueBlacklevel, 0.0, 1.0, 0.1));
mBlueBlacklevelSpinner.setMaximumSize(maxDim);
mBlueBlacklevelSpinner.addChangeListener(mChangeListener); mBlueBlacklevelSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mBlueBlacklevelSpinner); mRgbTransformPanel.add(mBlueBlacklevelSpinner);
mBlueWhitelevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueWhitelevel, 0.0, 1.0, 0.1)); mBlueWhitelevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueWhitelevel, 0.0, 1.0, 0.1));
mBlueWhitelevelSpinner.setMaximumSize(maxDim);
mBlueWhitelevelSpinner.addChangeListener(mChangeListener); mBlueWhitelevelSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mBlueWhitelevelSpinner); mRgbTransformPanel.add(mBlueWhitelevelSpinner);
} }
@ -187,6 +201,7 @@ public class ColorTransformPanel extends JPanel {
mHsvTransformPanel.add(mSaturationAdjustLabel); mHsvTransformPanel.add(mSaturationAdjustLabel);
mSaturationAdjustSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mSaturationGain, 0.0, 1024.0, 0.01)); mSaturationAdjustSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mSaturationGain, 0.0, 1024.0, 0.01));
mSaturationAdjustSpinner.setMaximumSize(maxDim);
mSaturationAdjustSpinner.addChangeListener(mChangeListener); mSaturationAdjustSpinner.addChangeListener(mChangeListener);
mHsvTransformPanel.add(mSaturationAdjustSpinner); mHsvTransformPanel.add(mSaturationAdjustSpinner);
@ -194,6 +209,7 @@ public class ColorTransformPanel extends JPanel {
mHsvTransformPanel.add(mValueAdjustLabel); mHsvTransformPanel.add(mValueAdjustLabel);
mValueAdjustSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mValueGain, 0.0, 1024.0, 0.01)); mValueAdjustSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mValueGain, 0.0, 1024.0, 0.01));
mValueAdjustSpinner.setMaximumSize(maxDim);
mValueAdjustSpinner.addChangeListener(mChangeListener); mValueAdjustSpinner.addChangeListener(mChangeListener);
mHsvTransformPanel.add(mValueAdjustSpinner); mHsvTransformPanel.add(mValueAdjustSpinner);

View File

@ -0,0 +1,24 @@
package org.hyperion.hypercon.gui.device;
import java.awt.Dimension;
import javax.swing.JPanel;
import org.hyperion.hypercon.spec.DeviceConfig;
public abstract class DeviceTypePanel extends JPanel {
protected final Dimension firstColMinDim = new Dimension(80, 10);
protected final Dimension maxDim = new Dimension(1024, 20);
protected DeviceConfig mDeviceConfig = null;
public DeviceTypePanel() {
super();
}
public void setDeviceConfig(DeviceConfig pDeviceConfig) {
mDeviceConfig = pDeviceConfig;
}
}

View File

@ -0,0 +1,63 @@
package org.hyperion.hypercon.gui.device;
import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.hyperion.hypercon.spec.DeviceConfig;
public class LightPackPanel extends DeviceTypePanel {
private JLabel mSerialNoLabel;
private JTextField mSerialNoField;
public LightPackPanel() {
super();
initialise();
}
@Override
public void setDeviceConfig(DeviceConfig pDeviceConfig) {
super.setDeviceConfig(pDeviceConfig);
mSerialNoField.setText(mDeviceConfig.mOutput);
}
private void initialise() {
mSerialNoLabel = new JLabel("Serial #: ");
mSerialNoLabel.setMinimumSize(firstColMinDim);
add(mSerialNoLabel);
mSerialNoField = new JTextField();
mSerialNoField.setMaximumSize(maxDim);
mSerialNoField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
mDeviceConfig.mOutput = mSerialNoField.getText();
}
@Override
public void insertUpdate(DocumentEvent e) {
mDeviceConfig.mOutput = mSerialNoField.getText();
}
@Override
public void changedUpdate(DocumentEvent e) {
mDeviceConfig.mOutput = mSerialNoField.getText();
}
});
add(mSerialNoField);
GroupLayout layout = new GroupLayout(this);
setLayout(layout);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addComponent(mSerialNoLabel)
.addComponent(mSerialNoField));
layout.setVerticalGroup(layout.createParallelGroup()
.addComponent(mSerialNoLabel)
.addComponent(mSerialNoField));
}
}

View File

@ -0,0 +1,104 @@
package org.hyperion.hypercon.gui.device;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.GroupLayout;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.hyperion.hypercon.spec.DeviceConfig;
/**
* Panel for configuring Ws2801 specific settings
*/
public class SerialPanel extends DeviceTypePanel {
public static final String[] KnownOutputs = { "/dev/ttyS0", "/dev/ttyUSB0", "/dev/ttyAMA0", "/dev/null"};
private JLabel mOutputLabel;
private JComboBox<String> mOutputCombo;
private JLabel mBaudrateLabel;
private JSpinner mBaudrateSpinner;
public SerialPanel() {
super();
initialise();
}
@Override
public void setDeviceConfig(DeviceConfig pDeviceConfig) {
super.setDeviceConfig(pDeviceConfig);
mOutputCombo.setSelectedItem(mDeviceConfig.mOutput);
((SpinnerNumberModel)mBaudrateSpinner.getModel()).setValue(mDeviceConfig.mBaudrate);
}
private void initialise() {
mOutputLabel = new JLabel("Output: ");
mOutputLabel.setMinimumSize(firstColMinDim);
add(mOutputLabel);
mOutputCombo = new JComboBox<>(KnownOutputs);
mOutputCombo.setMaximumSize(maxDim);
mOutputCombo.setEditable(true);
mOutputCombo.addActionListener(mActionListener);
add(mOutputCombo);
mBaudrateLabel = new JLabel("Baudrate: ");
mBaudrateLabel.setMinimumSize(firstColMinDim);
add(mBaudrateLabel);
mBaudrateSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 1000000, 128));
mBaudrateSpinner .setMaximumSize(maxDim);
mBaudrateSpinner.addChangeListener(mChangeListener);
add(mBaudrateSpinner);
GroupLayout layout = new GroupLayout(this);
layout.setAutoCreateGaps(true);
setLayout(layout);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup()
.addComponent(mOutputLabel)
.addComponent(mBaudrateLabel))
.addGroup(layout.createParallelGroup()
.addComponent(mOutputCombo)
.addComponent(mBaudrateSpinner))
);
layout.setVerticalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup()
.addComponent(mOutputLabel)
.addComponent(mOutputCombo))
.addGroup(layout.createParallelGroup()
.addComponent(mBaudrateLabel)
.addComponent(mBaudrateSpinner))
);
}
private ActionListener mActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == mOutputCombo) {
mDeviceConfig.mOutput = (String)mOutputCombo.getSelectedItem();
} else if (e.getSource() == mBaudrateSpinner) {
mDeviceConfig.mBaudrate = (Integer)mBaudrateSpinner.getValue();
}
}
};
private ChangeListener mChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
mDeviceConfig.mBaudrate = (Integer)mBaudrateSpinner.getValue();
}
};
}

View File

@ -0,0 +1,63 @@
package org.hyperion.hypercon.gui.device;
import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.hyperion.hypercon.spec.DeviceConfig;
public class TestDevicePanel extends DeviceTypePanel {
private JLabel mFilenameLabel;
private JTextField mFilenameField;
public TestDevicePanel() {
super();
initialise();
}
@Override
public void setDeviceConfig(DeviceConfig pDeviceConfig) {
super.setDeviceConfig(pDeviceConfig);
mFilenameField.setText(mDeviceConfig.mOutput);
}
private void initialise() {
mFilenameLabel = new JLabel("Filename: ");
mFilenameLabel.setMinimumSize(firstColMinDim);
add(mFilenameLabel);
mFilenameField = new JTextField();
mFilenameField.setMaximumSize(maxDim);
mFilenameField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
mDeviceConfig.mOutput = mFilenameField.getText();
}
@Override
public void insertUpdate(DocumentEvent e) {
mDeviceConfig.mOutput = mFilenameField.getText();
}
@Override
public void changedUpdate(DocumentEvent e) {
mDeviceConfig.mOutput = mFilenameField.getText();
}
});
add(mFilenameField);
GroupLayout layout = new GroupLayout(this);
setLayout(layout);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addComponent(mFilenameLabel)
.addComponent(mFilenameField));
layout.setVerticalGroup(layout.createParallelGroup()
.addComponent(mFilenameLabel)
.addComponent(mFilenameField));
}
}

View File

@ -0,0 +1,104 @@
package org.hyperion.hypercon.gui.device;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.GroupLayout;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.hyperion.hypercon.spec.DeviceConfig;
/**
* Panel for configuring Ws2801 specific settings
*/
public class Ws2801Panel extends DeviceTypePanel {
public static final String[] KnownOutputs = {"/dev/spidev0.0", "/dev/spidev0.1", "/dev/null"};
private JLabel mOutputLabel;
private JComboBox<String> mOutputCombo;
private JLabel mBaudrateLabel;
private JSpinner mBaudrateSpinner;
public Ws2801Panel() {
super();
initialise();
}
@Override
public void setDeviceConfig(DeviceConfig pDeviceConfig) {
super.setDeviceConfig(pDeviceConfig);
mOutputCombo.setSelectedItem(mDeviceConfig.mOutput);
((SpinnerNumberModel)mBaudrateSpinner.getModel()).setValue(mDeviceConfig.mBaudrate);
}
private void initialise() {
mOutputLabel = new JLabel("Output: ");
mOutputLabel.setMinimumSize(firstColMinDim);
add(mOutputLabel);
mOutputCombo = new JComboBox<>(KnownOutputs);
mOutputCombo.setMaximumSize(maxDim);
mOutputCombo.setEditable(true);
mOutputCombo.addActionListener(mActionListener);
add(mOutputCombo);
mBaudrateLabel = new JLabel("Baudrate: ");
mBaudrateLabel.setMinimumSize(firstColMinDim);
add(mBaudrateLabel);
mBaudrateSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 1000000, 128));
mBaudrateSpinner.setMaximumSize(maxDim);
mBaudrateSpinner.addChangeListener(mChangeListener);
add(mBaudrateSpinner);
GroupLayout layout = new GroupLayout(this);
layout.setAutoCreateGaps(true);
setLayout(layout);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup()
.addComponent(mOutputLabel)
.addComponent(mBaudrateLabel))
.addGroup(layout.createParallelGroup()
.addComponent(mOutputCombo)
.addComponent(mBaudrateSpinner))
);
layout.setVerticalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup()
.addComponent(mOutputLabel)
.addComponent(mOutputCombo))
.addGroup(layout.createParallelGroup()
.addComponent(mBaudrateLabel)
.addComponent(mBaudrateSpinner))
);
}
private ActionListener mActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == mOutputCombo) {
mDeviceConfig.mOutput = (String)mOutputCombo.getSelectedItem();
} else if (e.getSource() == mBaudrateSpinner) {
mDeviceConfig.mBaudrate = (Integer)mBaudrateSpinner.getValue();
}
}
};
private ChangeListener mChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
mDeviceConfig.mBaudrate = (Integer)mBaudrateSpinner.getValue();
}
};
}

View File

@ -47,8 +47,8 @@ public class ColorConfig {
strBuf.append("\t/// - 'gamma' The gamma-curve correction factor\n"); strBuf.append("\t/// - 'gamma' The gamma-curve correction factor\n");
strBuf.append("\t/// - 'blacklevel' The lowest possible value (when the channel is black)\n"); strBuf.append("\t/// - 'blacklevel' The lowest possible value (when the channel is black)\n");
strBuf.append("\t/// - 'whitelevel' The highest possible value (when the channel is white)\n"); strBuf.append("\t/// - 'whitelevel' The highest possible value (when the channel is white)\n");
strBuf.append("\t///"); strBuf.append("\t///\n");
strBuf.append("\t/// Next to the list with color transforms there is also a smoothing option."); strBuf.append("\t/// Next to the list with color transforms there is also a smoothing option.\n");
strBuf.append("\t/// * 'smoothing' : Smoothing of the colors in the time-domain with the following tuning \n"); strBuf.append("\t/// * 'smoothing' : Smoothing of the colors in the time-domain with the following tuning \n");
strBuf.append("\t/// parameters:\n"); strBuf.append("\t/// parameters:\n");
strBuf.append("\t/// - 'type' The type of smoothing algorithm ('linear' or 'none')\n"); strBuf.append("\t/// - 'type' The type of smoothing algorithm ('linear' or 'none')\n");

View File

@ -12,7 +12,7 @@ public class DeviceConfig {
/** The device 'file' name */ /** The device 'file' name */
public String mOutput = "/dev/spidev0.0"; public String mOutput = "/dev/spidev0.0";
/** The baudrate of the device */ /** The baudrate of the device */
public int mBaudrate = 1000000; public int mBaudrate = 250000;
/** The order of the color bytes */ /** The order of the color bytes */
public ColorByteOrder mColorByteOrder = ColorByteOrder.RGB; public ColorByteOrder mColorByteOrder = ColorByteOrder.RGB;

View File

@ -1,76 +0,0 @@
package org.hyperion.hypercon.spec;
import java.util.Vector;
import org.hyperion.hypercon.JsonStringBuffer;
/**
* The configuration structure for a single 'effect'.
*/
public class EffectConfig {
/** The identifier of the effect */
public String mId;
/** The python-script used to generate the effect */
public String mScript;
/** The arguments (key-value) of the python-script */
public final Vector<EffectArg> mArgs = new Vector<>();
/**
* The effect argument contains a key-value combination that holds a single argument of an
* effect
*/
static public class EffectArg {
/** The key of the effect argument */
public String key;
/** The value of the effect argument */
public Object value;
/**
* Constructs an new effect argument with empty key and value
*/
public EffectArg() {
this("", "");
}
/**
* Constructs an effect argument with the given key and value
*
* @param pKey The key of the new argument
* @param pValue The value of the new argument
*/
public EffectArg(String pKey, Object pValue) {
key = pKey;
value = pValue;
}
}
public void append(JsonStringBuffer pJsonBuf, boolean endOfEffects) {
pJsonBuf.startObject(mId);
pJsonBuf.addValue("script", mScript, false);
//pJsonBuf.addRawValue("args", String.format(Locale.ENGLISH, "{\n%s\n}", mArgs), true);
pJsonBuf.stopObject(endOfEffects);
}
@Override
public String toString() {
return mId;
}
@Override
public EffectConfig clone() {
EffectConfig thisClone = new EffectConfig();
thisClone.mId = mId;
thisClone.mScript = mScript;
for (EffectArg arg : mArgs) {
thisClone.mArgs.add(new EffectArg(arg.key, arg.value));
}
return thisClone;
}
}

View File

@ -13,7 +13,7 @@ public class MiscConfig {
/** Flag indicating that the boot sequence is enabled(true) or not(false) */ /** Flag indicating that the boot sequence is enabled(true) or not(false) */
public boolean mBootSequenceEnabled = true; public boolean mBootSequenceEnabled = true;
/** The effect selected for the boot sequence */ /** The effect selected for the boot sequence */
public String mBootSequenceEffect = "Rainbow Swirl (fast)"; public String mBootSequenceEffect = "Rainbow swirl fast";
/** Flag indicating that the Frame Grabber is enabled */ /** Flag indicating that the Frame Grabber is enabled */
public boolean mFrameGrabberEnabled = true; public boolean mFrameGrabberEnabled = true;
@ -68,7 +68,7 @@ public class MiscConfig {
for (String effectPath : effectPaths) { for (String effectPath : effectPaths) {
strBuf.addArrayElement(effectPath, effectPath == effectPaths[effectPaths.length-1]); strBuf.addArrayElement(effectPath, effectPath == effectPaths[effectPaths.length-1]);
} }
strBuf.stopArray(); strBuf.stopArray(!mBootSequenceEnabled);
strBuf.toggleComment(!mBootSequenceEnabled); strBuf.toggleComment(!mBootSequenceEnabled);
strBuf.addValue("bootsequence", mBootSequenceEffect, true); strBuf.addValue("bootsequence", mBootSequenceEffect, true);
strBuf.toggleComment(false); strBuf.toggleComment(false);