List of usage examples for com.jgoodies.binding PresentationModel getBean
public B getBean()
From source file:fi.smaa.jsmaa.gui.components.BetaMeasurementPanel.java
License:Open Source License
public BetaMeasurementPanel(JComponent parent, PresentationModel<BetaMeasurement> model) { ValueModel alphaModel = new NonNegativeValueModel(parent, model.getModel(BetaMeasurement.PROPERTY_ALPHA), "alpha"); ValueModel betaModel = new NonNegativeValueModel(parent, model.getModel(BetaMeasurement.PROPERTY_BETA), "beta"); ValueModel minModel = new BetaMinMaxValueModel(parent, model.getBean(), model.getModel(BetaMeasurement.PROPERTY_MIN), true); ValueModel maxModel = new BetaMinMaxValueModel(parent, model.getBean(), model.getModel(BetaMeasurement.PROPERTY_MAX), false); setLayout(new FlowLayout(FlowLayout.LEADING, 0, 5)); alphaField = BasicComponentFactory.createFormattedTextField(alphaModel, new DefaultFormatter()); betaField = BasicComponentFactory.createFormattedTextField(betaModel, new DefaultFormatter()); alphaField.setHorizontalAlignment(JTextField.CENTER); betaField.setHorizontalAlignment(JTextField.CENTER); alphaField.setColumns(5);//from w ww . j a v a2 s . c om betaField.setColumns(5); minField = BasicComponentFactory.createFormattedTextField(minModel, new DefaultFormatter()); maxField = BasicComponentFactory.createFormattedTextField(maxModel, new DefaultFormatter()); minField.setHorizontalAlignment(JTextField.CENTER); maxField.setHorizontalAlignment(JTextField.CENTER); minField.setColumns(5); maxField.setColumns(5); add(new JLabel("\u03B1")); add(alphaField); add(new JLabel("\u03B2")); add(betaField); add(new JLabel("min")); add(minField); add(new JLabel("max")); add(maxField); addFocusListener(new FocusTransferrer(alphaField)); setFocusTraversalPolicyProvider(true); }
From source file:fi.smaa.jsmaa.gui.components.DiscreteMeasurementPanel.java
License:Open Source License
public DiscreteMeasurementPanel(JComponent parent, PresentationModel<DiscreteMeasurement> m) { setLayout(new FlowLayout()); dm = m.getBean(); this.parent = parent; jlist = new JList(dm); jlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jlist.setSelectedIndex(0);//from www . j a va 2 s .c om jlist.addListSelectionListener(this); add("Discrete points: ", new JScrollPane(jlist)); valueText = new JTextField(); valueText.addActionListener(new AddButtonListener()); String strvalue = "" + dm.getElementAt(jlist.getSelectedIndex()).getX(); valueText.setText(strvalue); valueText.setHorizontalAlignment(JTextField.CENTER); valueText.setColumns(5); add(new JLabel("P(X=")); add("Value:", valueText); add(new JLabel(") = ")); probabilityText = new JTextField(); probabilityText.addActionListener(new AddButtonListener()); String strprobability = "" + dm.getElementAt(jlist.getSelectedIndex()).getY(); probabilityText.setText(strprobability); probabilityText.setHorizontalAlignment(JTextField.CENTER); probabilityText.setColumns(5); add("Probability:", probabilityText); addButton = new JButton("+"); addButton.addActionListener(new AddButtonListener()); add(addButton); deleteButton = new JButton("-"); deleteButton.addActionListener(new DeleteButtonListener()); add(deleteButton); add(new JLabel("P(\u2126) = ")); sumProbabilityLabel = new JLabel("1.0"); refreshSummedProbability(); add(sumProbabilityLabel); addFocusListener(new FocusTransferrer(valueText)); setFocusTraversalPolicyProvider(true); setFocusTraversalPolicy(new TwoComponentFocusTraversalPolicy(valueText, probabilityText)); }
From source file:fi.smaa.jsmaa.gui.components.IntervalPanel.java
License:Open Source License
public IntervalPanel(JComponent parent, PresentationModel<Interval> model) { ValueModel startModel = new IntervalValueModel(parent, model.getBean(), model.getModel(Interval.PROPERTY_START), true); ValueModel endModel = new IntervalValueModel(parent, model.getBean(), model.getModel(Interval.PROPERTY_END), false);/*from w ww .ja v a 2 s.c o m*/ init(startModel, endModel); addFocusListener(new FocusTransferrer(endField)); setFocusTraversalPolicyProvider(true); setFocusTraversalPolicy(new TwoComponentFocusTraversalPolicy(endField, startField)); }
From source file:org.drugis.addis.presentation.PresentationModelFactory.java
License:Open Source License
@SuppressWarnings({ "unchecked", "rawtypes" }) public <T> PresentationModel<T> getModel(final T obj) { PresentationModel mod = d_cache.get(obj); if ((mod != null) && (mod.getBean() == obj)) { return mod; }// w w w . j a v a 2s .c o m mod = createModel(obj); d_cache.put(obj, mod); return mod; }
From source file:org.drugis.addis.presentation.PresentationModelFactoryTest.java
License:Open Source License
@Test public void testMetaAnalysisGetModel() { List<Study> studies = new ArrayList<Study>(); studies.add(ExampleData.buildStudyChouinard()); studies.add(ExampleData.buildStudyDeWilde()); RandomEffectsMetaAnalysis anal = ExampleData.buildRandomEffectsMetaAnalysis("meta", ExampleData.buildEndpointHamd(), studies, TreatmentDefinition.createTrivial(ExampleData.buildDrugFluoxetine()), TreatmentDefinition.createTrivial(ExampleData.buildDrugParoxetine())); PresentationModel m = d_manager.getModel(anal); assertEquals(anal, m.getBean()); PresentationModel m2 = d_manager.getModel(anal); assertTrue(m == m2);// www . j a v a 2s. c o m assertTrue(m instanceof PairWiseMetaAnalysisPresentation); }
From source file:org.drugis.addis.presentation.PresentationModelFactoryTest.java
License:Open Source License
@Test public void testStudyGetModel() { Study s = new Study("Study", new Indication(666L, "evil")); PresentationModel m = d_manager.getModel(s); assertEquals(s, m.getBean()); assertTrue(m instanceof StudyPresentation); }
From source file:org.drugis.addis.presentation.PresentationModelFactoryTest.java
License:Open Source License
@Test public void testGetIndicationModel() { Indication indication = new Indication(0L, ""); PresentationModel m = d_manager.getModel(indication); assertEquals(indication, m.getBean()); assertEquals(m.getClass(), IndicationPresentation.class); assertEquals(m, d_manager.getLabeledModel(indication)); }
From source file:org.drugis.addis.presentation.PresentationModelFactoryTest.java
License:Open Source License
@Test public void testGetDrugModel() { Drug d = ExampleData.buildDrugFluoxetine(); PresentationModel m = d_manager.getModel(d); assertEquals(d, m.getBean()); assertEquals(DrugPresentation.class, m.getClass()); assertEquals(d_domain.getStudies(d).size(), ((DrugPresentation) m).getStudyListPresentation().getIncludedStudies().size()); assertTrue(d_domain.getStudies(d)/* w w w. ja va 2s . c o m*/ .containsAll(((DrugPresentation) m).getStudyListPresentation().getIncludedStudies())); }
From source file:org.drugis.addis.presentation.PresentationModelFactoryTest.java
License:Open Source License
@Test public void testGetEndpointModel() { OutcomeMeasure e = ExampleData.buildEndpointHamd(); PresentationModel m = d_manager.getModel(e); assertEquals(e, m.getBean()); assertEquals(VariablePresentation.class, m.getClass()); assertEquals(d_domain.getStudies(e).size(), ((VariablePresentation) m).getStudyListPresentation().getIncludedStudies().size()); assertTrue(d_domain.getStudies(e)/*from w w w. j a v a 2s .c o m*/ .containsAll(((VariablePresentation) m).getStudyListPresentation().getIncludedStudies())); }
From source file:org.drugis.addis.presentation.RelativeEffectTableModelBaseTest.java
License:Open Source License
@SuppressWarnings("unchecked") @Test/*from www . jav a2 s.c om*/ public void testGetValueAtUpperRightPart() { assertEquals(3, d_threeArmStudy.getArms().size()); Arm pg0 = d_threeArmStudy.getArms().get(0); Arm pg1 = d_threeArmStudy.getArms().get(1); Arm pg2 = d_threeArmStudy.getArms().get(2); PresentationModel<BasicRelativeEffect<?>> val01 = (PresentationModel<BasicRelativeEffect<?>>) d_threeArmModel .getValueAt(0, 1); assertTrue(d_relativeEffectClass.isInstance(val01.getBean())); assertEquals(d_threeArmStudy.getMeasurement(d_endpoint, pg0), val01.getBean().getBaseline()); assertEquals(d_threeArmStudy.getMeasurement(d_endpoint, pg1), val01.getBean().getSubject()); PresentationModel<BasicRelativeEffect<?>> val12 = (PresentationModel<BasicRelativeEffect<?>>) d_threeArmModel .getValueAt(1, 2); assertTrue(d_relativeEffectClass.isInstance(val12.getBean())); assertEquals(d_threeArmStudy.getMeasurement(d_endpoint, pg1), val12.getBean().getBaseline()); assertEquals(d_threeArmStudy.getMeasurement(d_endpoint, pg2), val12.getBean().getSubject()); }