use of edu.cmu.tetrad.data.SplitCasesSpec in project tetrad by cmu-phil.
the class SplitCasesParamsEditor method setup.
public void setup() {
SplitCasesSpec spec = (SplitCasesSpec) this.params.get("splitCasesSpec", null);
if (spec != null) {
spec = getDefaultSpec(this.dataSet.getNumRows(), this.params.getInt("numSplits", 3));
}
numSplitsField = new IntTextField(this.params.getInt("numSplits", 3), 2);
numSplitsField.setFilter(new IntTextField.Filter() {
public int filter(int value, int oldValue) {
setNumSplits(value);
return value;
}
});
splitEditorPanel = new JPanel();
splitEditorPanel.setLayout(new BorderLayout());
setNumSplits(params.getInt("numSplits", 3));
JRadioButton shuffleButton = new JRadioButton("Shuffled order");
JRadioButton noShuffleButton = new JRadioButton("Original order");
shuffleButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
params.set("dataShuffled", true);
}
});
noShuffleButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
params.set("dataShuffled", false);
}
});
ButtonGroup group = new ButtonGroup();
group.add(shuffleButton);
group.add(noShuffleButton);
shuffleButton.setSelected(params.getBoolean("dataShuffled", true));
Box b1 = Box.createVerticalBox();
Box b2 = Box.createHorizontalBox();
b2.add(new JLabel("Using data in:"));
b2.add(Box.createHorizontalGlue());
b1.add(b2);
Box b3 = Box.createHorizontalBox();
b3.add(Box.createHorizontalStrut(10));
b3.add(shuffleButton);
b3.add(Box.createHorizontalGlue());
b1.add(b3);
Box b4 = Box.createHorizontalBox();
b4.add(Box.createHorizontalStrut(10));
b4.add(noShuffleButton);
b4.add(Box.createHorizontalGlue());
b1.add(b4);
b1.add(Box.createVerticalStrut(10));
Box b5 = Box.createHorizontalBox();
b5.add(new JLabel("Split data into "));
b5.add(numSplitsField);
b5.add(new JLabel(" subsets as follows:"));
b5.add(Box.createHorizontalGlue());
b1.add(b5);
b1.add(Box.createVerticalStrut(10));
b1.add(splitEditorPanel);
b1.add(Box.createVerticalGlue());
setLayout(new BorderLayout());
add(b1, BorderLayout.CENTER);
}
use of edu.cmu.tetrad.data.SplitCasesSpec in project tetrad by cmu-phil.
the class SplitCasesParamsEditor method setNumSplits.
// ================================PUBLIC METHODS=======================//
private void setNumSplits(int numSplits) {
if (numSplits < 1) {
throw new IllegalArgumentException("Number of splits must be " + "at least 1.");
}
this.params.set("numSplits", numSplits);
splitEditorPanel.removeAll();
SplitCasesSpec defaultSpec = getDefaultSpec(this.dataSet.getNumRows(), numSplits);
SplitEditor splitEditor = new SplitEditor(defaultSpec);
this.params.set("splitCasesSpec", defaultSpec);
splitEditorPanel.add(splitEditor, BorderLayout.CENTER);
splitEditorPanel.revalidate();
splitEditorPanel.repaint();
numSplitsField.setText(String.valueOf(numSplits));
Preferences.userRoot().putInt("latestNumCategories", numSplits);
}
Aggregations