private JPanel getParamsPanel() { JPanel paramsPanel = new JPanel(); Box b2 = Box.createVerticalBox(); JComponent indTestParamBox = getIndTestParamBox(); if (indTestParamBox != null) { b2.add(indTestParamBox); } paramsPanel.add(b2); paramsPanel.setBorder(new TitledBorder("Parameters")); return paramsPanel; }
public void setup() { this.varNames = params.getVarNames(); for (Object parentModel : parentModels) { if (parentModel instanceof DataWrapper) { DataWrapper wrapper = (DataWrapper) parentModel; DataModel dataModel = wrapper.getSelectedDataModel(); new IndTestChooser().adjustIndTestParams(dataModel, params); break; } else if (parentModel instanceof GraphWrapper) { GraphWrapper wrapper = (GraphWrapper) parentModel; new IndTestChooser().adjustIndTestParams(wrapper.getGraph(), params); break; } else if (parentModel instanceof DagWrapper) { DagWrapper wrapper = (DagWrapper) parentModel; new IndTestChooser().adjustIndTestParams(wrapper.getGraph(), params); break; } else if (parentModel instanceof SemGraphWrapper) { SemGraphWrapper wrapper = (SemGraphWrapper) parentModel; new IndTestChooser().adjustIndTestParams(wrapper.getGraph(), params); break; } } DataModel dataModel1 = null; Graph graph = null; for (Object parentModel1 : parentModels) { if (parentModel1 instanceof DataWrapper) { DataWrapper dataWrapper = (DataWrapper) parentModel1; dataModel1 = dataWrapper.getSelectedDataModel(); } if (parentModel1 instanceof GraphWrapper) { GraphWrapper graphWrapper = (GraphWrapper) parentModel1; graph = graphWrapper.getGraph(); } if (parentModel1 instanceof DagWrapper) { DagWrapper dagWrapper = (DagWrapper) parentModel1; graph = dagWrapper.getDag(); } if (parentModel1 instanceof SemGraphWrapper) { SemGraphWrapper semGraphWrapper = (SemGraphWrapper) parentModel1; graph = semGraphWrapper.getGraph(); } } if (dataModel1 != null) { varNames = new ArrayList(dataModel1.getVariableNames()); } else if (graph != null) { Iterator it = graph.getNodes().iterator(); varNames = new ArrayList(); Node temp; while (it.hasNext()) { temp = (Node) it.next(); if (temp.getNodeType() == NodeType.MEASURED) { varNames.add(temp.getName()); } } } else { throw new NullPointerException( "Null model (no graph or data model " + "passed to the search)."); } params.setVarNames(varNames); JButton knowledgeButton = new JButton("Edit"); IntTextField depthField = new IntTextField(params.getIndTestParams().getDepth(), 4); depthField.setFilter( new IntTextField.Filter() { public int filter(int value, int oldValue) { try { params.getIndTestParams().setDepth(value); Preferences.userRoot().putInt("depth", value); return value; } catch (Exception e) { return oldValue; } } }); double alpha = params.getIndTestParams().getAlpha(); if (!Double.isNaN(alpha)) { alphaField = new DoubleTextField(alpha, 4, NumberFormatUtil.getInstance().getNumberFormat()); alphaField.setFilter( new DoubleTextField.Filter() { public double filter(double value, double oldValue) { try { params.getIndTestParams().setAlpha(value); Preferences.userRoot().putDouble("alpha", value); return value; } catch (Exception e) { return oldValue; } } }); } setBorder(new MatteBorder(10, 10, 10, 10, super.getBackground())); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); Box b2 = Box.createHorizontalBox(); b2.add(new JLabel("Knowledge:")); b2.add(Box.createGlue()); b2.add(knowledgeButton); add(b2); add(Box.createVerticalStrut(10)); if (!Double.isNaN(alpha)) { Box b0 = Box.createHorizontalBox(); b0.add(new JLabel("Alpha Value:")); b0.add(Box.createGlue()); b0.add(alphaField); add(b0); add(Box.createVerticalStrut(10)); } Box b1 = Box.createHorizontalBox(); b1.add(new JLabel("Search Depth:")); b1.add(Box.createGlue()); b1.add(depthField); add(b1); add(Box.createVerticalStrut(10)); knowledgeButton.addActionListener( new ActionListener() { public final void actionPerformed(ActionEvent e) { openKnowledgeEditor(); } }); }
/** Construct the toolbar panel. */ protected JPanel getToolbar() { JPanel toolbar = new JPanel(); getExecuteButton().setText("Execute*"); getExecuteButton() .addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { removeStatsTabs(); execute(); } }); JButton statsButton = new JButton("Calc Stats"); statsButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Window owner = (Window) getTopLevelAncestor(); new WatchedProcess(owner) { public void watch() { calcStats(); } }; } }); Box b1 = Box.createVerticalBox(); b1.add(getParamsPanel()); b1.add(Box.createVerticalStrut(10)); Box b2 = Box.createHorizontalBox(); b2.add(Box.createGlue()); b2.add(getExecuteButton()); b1.add(b2); b1.add(Box.createVerticalStrut(10)); if (getAlgorithmRunner().getDataModel() instanceof DataSet) { Box b3 = Box.createHorizontalBox(); b3.add(Box.createGlue()); b3.add(statsButton); b1.add(b3); } // if (getAlgorithmRunner().getParams() instanceof MeekSearchParams) { // MeekSearchParams params = (MeekSearchParams) getAlgorithmRunner().getParams(); // JCheckBox preventCycles = new JCheckBox("Aggressively Prevent Cycles"); // preventCycles.setHorizontalTextPosition(AbstractButton.RIGHT); // preventCycles.setSelected(params.isAggressivelyPreventCycles()); // // preventCycles.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // JCheckBox box = (JCheckBox) e.getSource(); // MeekSearchParams params = (MeekSearchParams) // getAlgorithmRunner().getParams(); // params.setAggressivelyPreventCycles(box.isSelected()); // } // }); // // b1.add(Box.createVerticalStrut(5)); // Box hBox = Box.createHorizontalBox(); // hBox.add(Box.createHorizontalGlue()); // hBox.add(preventCycles); // b1.add(hBox); // b1.add(Box.createVerticalStrut(5)); // } Box b4 = Box.createHorizontalBox(); JLabel label = new JLabel( "<html>" + "*Please note that some" + "<br>searches may take a" + "<br>long time to complete." + "</html>"); label.setHorizontalAlignment(SwingConstants.CENTER); label.setVerticalAlignment(SwingConstants.CENTER); label.setBorder(new TitledBorder("")); b4.add(label); b1.add(Box.createVerticalStrut(10)); b1.add(b4); toolbar.add(b1); return toolbar; }