diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/Bundle.properties b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/Bundle.properties index 5e8f9dbb0..312cad212 100644 --- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/Bundle.properties +++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/Bundle.properties @@ -168,8 +168,6 @@ EditCosnstraintTermJPanel.editComonentListButton.text=Edit... EditCosnstraintTermJPanel.jComponentListPanel.border.title=Component List EditCosnstraintTermJPanel.jEnabledCheckBox.text=Enabled EditCosnstraintTermJPanel.jLabel1.text=Constraint Term Type: -EditCosnstraintTermJPanel.jTextField1.text=0 -EditCosnstraintTermJPanel.jTextField2.text=0 EditCosnstraintTermJPanel.jLabel3.text=Max error: EditCosnstraintTermJPanel.jLabel4.text=Name: EditCosnstraintTermJPanel.jConstraintNameTextField.text= @@ -207,10 +205,12 @@ TreatmentOptimizationJPanel.jCoordinatesListPanel2.border.title=States Coordinat TreatmentOptimizationJPanel.jButtonEditSettingsCoordinateList.text=Edit... TreatmentOptimizationJPanel.jOptimizeSynVecCheckBox.text=Optimize Synergy Vectors TreatmentOptimizationJPanel.jButtonEditSynergyCoordinateList.text=Edit... -EditCostTermJPanel.jMaxErrorTextField.text=0 +EditCostTermJPanel.jMaxErrorTextField.text=0. EditCostTermJPanel.jCostTermNameTextField.text= EditCostTermJPanel.jComponentTypeTextField.text=\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ TreatmentOptimizationJPanel.jPanelCostConstraints.TabConstraints.tabTitle=Cost/Constraints EditCostTermJPanel.jLabel3.text=Error center: -EditCostTermJPanel.jErrorCenterTextField.text= +EditCostTermJPanel.jErrorCenterTextField.text=0. EditCosnstraintTermJPanel.jComponentTypeTextField.text=\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ +EditCosnstraintTermJPanel.jMaxErrorTextField.text=0 +EditCosnstraintTermJPanel.jMinErrorTextField.text=0 diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/ConstraintTermModel.java b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/ConstraintTermModel.java index 1a88e150f..fb59b5a21 100644 --- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/ConstraintTermModel.java +++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/ConstraintTermModel.java @@ -7,6 +7,7 @@ import org.opensim.modeling.AbstractProperty; import org.opensim.modeling.Model; import org.opensim.modeling.OpenSimObject; +import org.opensim.modeling.PropertyHelper; import org.opensim.modeling.PropertyStringList; import org.opensim.view.pub.OpenSimDB; @@ -20,11 +21,15 @@ public class ConstraintTermModel { OpenSimObject constraintTerm; private TreatmentOptimizationToolModel.Mode mode; private int termIndex = 0; + private AbstractProperty maxErrorProp; + private AbstractProperty minErrorProp; public ConstraintTermModel(OpenSimObject rCNLConstraintTerm, TreatmentOptimizationToolModel.Mode mode){ this.model = OpenSimDB.getInstance().getCurrentModel(); this.constraintTerm = rCNLConstraintTerm; this.mode = mode; + maxErrorProp = rCNLConstraintTerm.updPropertyByName("max_error"); + minErrorProp = rCNLConstraintTerm.updPropertyByName("min_error"); } void setTypeIndex(int selectedIndex) { @@ -54,4 +59,17 @@ PropertyStringList getPropertyComponentList() { } return PropertyStringList.updAs(constraintTerm.updPropertyByName("coordinate_list")); } + public double getMaxError() { + return PropertyHelper.getValueDouble(maxErrorProp); + } + public void setMaxError(double newMaxErr) { + PropertyHelper.setValueDouble(newMaxErr, maxErrorProp); + } + public double getMinError() { + return PropertyHelper.getValueDouble(minErrorProp); + } + public void setMinError(double newMinError) { + PropertyHelper.setValueDouble(newMinError, minErrorProp); + } + } diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/CostTermModel.java b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/CostTermModel.java index f5b97df33..d14c1de41 100644 --- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/CostTermModel.java +++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/CostTermModel.java @@ -7,6 +7,7 @@ import org.opensim.modeling.AbstractProperty; import org.opensim.modeling.Model; import org.opensim.modeling.OpenSimObject; +import org.opensim.modeling.PropertyHelper; import org.opensim.modeling.PropertyStringList; import org.opensim.view.pub.OpenSimDB; @@ -20,11 +21,17 @@ public class CostTermModel { OpenSimObject costTerm; private TreatmentOptimizationToolModel.Mode mode; private int termIndex = 0; + private AbstractProperty errorProp; + private AbstractProperty errorCenterProp; + + public CostTermModel(OpenSimObject rCNLCostTerm, TreatmentOptimizationToolModel.Mode mode){ this.model = OpenSimDB.getInstance().getCurrentModel(); this.costTerm = rCNLCostTerm; this.mode = mode; + errorProp = costTerm.updPropertyByName("max_allowable_error"); + errorCenterProp = costTerm.updPropertyByName("error_center"); } void setTypeIndex(int selectedIndex) { @@ -54,4 +61,17 @@ PropertyStringList getPropertyComponentList() { } return PropertyStringList.updAs(costTerm.updPropertyByName("coordinate_list")); } + + public double getMaxAllowableError() { + return PropertyHelper.getValueDouble(errorProp); + } + public void setMaxAllowableError(double newMaxErr) { + PropertyHelper.setValueDouble(newMaxErr, errorProp); + } + public double getErrorCenter() { + return PropertyHelper.getValueDouble(errorCenterProp); + } + public void setErrorCenter(double newErrorCenter) { + PropertyHelper.setValueDouble(newErrorCenter, errorCenterProp); + } } diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCosnstraintTermJPanel.form b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCosnstraintTermJPanel.form index 1e9bbda93..822a703c1 100644 --- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCosnstraintTermJPanel.form +++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCosnstraintTermJPanel.form @@ -18,45 +18,43 @@ - + - + + - - - - - - - - - - - - - - - - - - + + - - - - - - + - + + + + + + - + + + + + + + + + + + + + + @@ -81,13 +79,13 @@ - + - - + + @@ -130,8 +128,8 @@ - - + + @@ -144,11 +142,7 @@ - - - - - + @@ -218,12 +212,16 @@ - + - + + + + + @@ -232,12 +230,16 @@ - + - + + + + + diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCosnstraintTermJPanel.java b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCosnstraintTermJPanel.java index c542959cf..04edf6a5e 100644 --- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCosnstraintTermJPanel.java +++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCosnstraintTermJPanel.java @@ -5,10 +5,13 @@ */ package org.opensim.rcnl; +import java.text.NumberFormat; +import java.text.ParseException; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.openide.DialogDescriptor; import org.openide.DialogDisplayer; +import org.openide.util.Exceptions; import org.opensim.modeling.AbstractProperty; import org.opensim.modeling.OpenSimObject; import org.opensim.modeling.PropertyHelper; @@ -27,6 +30,8 @@ public class EditCosnstraintTermJPanel extends javax.swing.JPanel { String componentType; private String[] availableComponentNames; private ConstraintTermModel constraintTermModel; + private NumberFormat numFormat = NumberFormat.getInstance(); + /** * Creates new form EditJointTaskJPanel @@ -53,7 +58,9 @@ public EditCosnstraintTermJPanel() { AbstractProperty enabledProp = constraintTerm2Edit.getPropertyByName("is_enabled"); jEnabledCheckBox.setSelected(PropertyHelper.getValueBool(enabledProp)); initializing = false; - jTermComponentListTextArea.setText(constraintTermModel.getPropertyComponentList().toString()); + jTermComponentListTextArea.setText(constraintTermModel.getPropertyComponentList().toString()); + jMaxErrorTextField.setText(String.valueOf(constraintTermModel.getMaxError())); + jMinErrorTextField.setText(String.valueOf(constraintTermModel.getMinError())); } /** @@ -74,9 +81,9 @@ private void initComponents() { jLabel11 = new javax.swing.JLabel(); jConstraintTypeComboBox = new javax.swing.JComboBox<>(); jLabel2 = new javax.swing.JLabel(); - jTextField1 = new javax.swing.JTextField(); + jMinErrorTextField = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); - jTextField2 = new javax.swing.JTextField(); + jMaxErrorTextField = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); jConstraintNameTextField = new javax.swing.JTextField(); jComponentTypeTextField = new javax.swing.JTextField(); @@ -113,8 +120,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jComponentListPanelLayout.setHorizontalGroup( jComponentListPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jComponentListPanelLayout.createSequentialGroup() - .addComponent(jScrollPane2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 762, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(editComonentListButton) .addContainerGap()) ); @@ -124,10 +131,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGap(34, 34, 34) .addComponent(editComonentListButton) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jComponentListPanelLayout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(83, 83, 83)) + .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE) ); org.openide.awt.Mnemonics.setLocalizedText(jLabel11, org.openide.util.NbBundle.getMessage(EditCosnstraintTermJPanel.class, "EditCosnstraintTermJPanel.jLabel11.text")); // NOI18N @@ -141,11 +145,31 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(EditCosnstraintTermJPanel.class, "EditCosnstraintTermJPanel.jLabel2.text")); // NOI18N - jTextField1.setText(org.openide.util.NbBundle.getMessage(EditCosnstraintTermJPanel.class, "EditCosnstraintTermJPanel.jTextField1.text")); // NOI18N + jMinErrorTextField.setText(org.openide.util.NbBundle.getMessage(EditCosnstraintTermJPanel.class, "EditCosnstraintTermJPanel.jMinErrorTextField.text")); // NOI18N + jMinErrorTextField.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + jMinErrorTextFieldFocusLost(evt); + } + }); + jMinErrorTextField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMinErrorTextFieldActionPerformed(evt); + } + }); org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(EditCosnstraintTermJPanel.class, "EditCosnstraintTermJPanel.jLabel3.text")); // NOI18N - jTextField2.setText(org.openide.util.NbBundle.getMessage(EditCosnstraintTermJPanel.class, "EditCosnstraintTermJPanel.jTextField2.text")); // NOI18N + jMaxErrorTextField.setText(org.openide.util.NbBundle.getMessage(EditCosnstraintTermJPanel.class, "EditCosnstraintTermJPanel.jMaxErrorTextField.text")); // NOI18N + jMaxErrorTextField.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + jMaxErrorTextFieldFocusLost(evt); + } + }); + jMaxErrorTextField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMaxErrorTextFieldActionPerformed(evt); + } + }); org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(EditCosnstraintTermJPanel.class, "EditCosnstraintTermJPanel.jLabel4.text")); // NOI18N @@ -175,36 +199,35 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jComponentListPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() + .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel11) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jComponentTypeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(jEnabledCheckBox) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jConstraintTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel4) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jConstraintNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 460, javax.swing.GroupLayout.PREFERRED_SIZE)))) - .addGroup(layout.createSequentialGroup() - .addGap(32, 32, 32) - .addComponent(jLabel3) + .addComponent(jLabel11) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(253, 253, 253) - .addComponent(jLabel2) + .addComponent(jComponentTypeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jEnabledCheckBox) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addGap(0, 309, Short.MAX_VALUE))) - .addContainerGap()) + .addComponent(jConstraintTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jConstraintNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 460, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGroup(layout.createSequentialGroup() + .addGap(32, 32, 32) + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jMaxErrorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(128, 128, 128) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jMinErrorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jComponentListPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -224,13 +247,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(jLabel11) .addComponent(jComponentTypeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jComponentListPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jComponentListPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(14, 14, 14) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jMaxErrorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jMinErrorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2))) .addContainerGap()) ); @@ -292,6 +315,37 @@ private void jConstraintNameTextFieldFocusLost(java.awt.event.FocusEvent evt) {/ jConstraintNameTextFieldActionPerformed(null); }//GEN-LAST:event_jConstraintNameTextFieldFocusLost + private void jMaxErrorTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMaxErrorTextFieldActionPerformed + // TODO add your handling code here: + if(jMaxErrorTextField.getText().trim().length()>0) + try { + constraintTermModel.setMaxError(numFormat.parse(jMaxErrorTextField.getText().trim()).doubleValue()); + } catch (ParseException ex) { + Exceptions.printStackTrace(ex); + } + }//GEN-LAST:event_jMaxErrorTextFieldActionPerformed + + private void jMaxErrorTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jMaxErrorTextFieldFocusLost + // TODO add your handling code here: + jMaxErrorTextFieldActionPerformed(null); + }//GEN-LAST:event_jMaxErrorTextFieldFocusLost + + private void jMinErrorTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMinErrorTextFieldActionPerformed + // TODO add your handling code here: + if(jMinErrorTextField.getText().trim().length()>0) + try { + constraintTermModel.setMinError(numFormat.parse(jMinErrorTextField.getText().trim()).doubleValue()); + } catch (ParseException ex) { + Exceptions.printStackTrace(ex); + } + + }//GEN-LAST:event_jMinErrorTextFieldActionPerformed + + private void jMinErrorTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jMinErrorTextFieldFocusLost + // TODO add your handling code here: + jMinErrorTextFieldActionPerformed(null); + }//GEN-LAST:event_jMinErrorTextFieldFocusLost + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton editComonentListButton; @@ -305,10 +359,10 @@ private void jConstraintNameTextFieldFocusLost(java.awt.event.FocusEvent evt) {/ private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; + private javax.swing.JTextField jMaxErrorTextField; + private javax.swing.JTextField jMinErrorTextField; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTextArea jTermComponentListTextArea; - private javax.swing.JTextField jTextField1; - private javax.swing.JTextField jTextField2; // End of variables declaration//GEN-END:variables private class ListSelectionHandler implements ListSelectionListener { diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCostTermJPanel.form b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCostTermJPanel.form index 8cac22fa2..ffdffc54f 100644 --- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCostTermJPanel.form +++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCostTermJPanel.form @@ -17,53 +17,47 @@ + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + - - - - - - - - @@ -136,26 +130,21 @@ + - - - + - - - - - - - - + + + + @@ -279,6 +268,7 @@ + diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCostTermJPanel.java b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCostTermJPanel.java index cb935738e..a283b40cd 100644 --- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCostTermJPanel.java +++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/EditCostTermJPanel.java @@ -69,6 +69,8 @@ public EditCostTermJPanel() { jErrorCenterTextField.setEnabled(mode == TreatmentOptimizationToolModel.Mode.DesignOptimization); initializing = false; jTermComponentListTextArea.setText(costTermModel.getPropertyComponentList().toString()); + jMaxErrorTextField.setText(String.valueOf(costTermModel.getMaxAllowableError())); + jErrorCenterTextField.setText(String.valueOf(costTermModel.getErrorCenter())); } /** @@ -128,21 +130,18 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jComponentListPanelLayout.setHorizontalGroup( jComponentListPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jComponentListPanelLayout.createSequentialGroup() - .addContainerGap() - .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 886, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 780, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(editComonentListButton) - .addContainerGap()) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jComponentListPanelLayout.setVerticalGroup( jComponentListPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jComponentListPanelLayout.createSequentialGroup() - .addGroup(jComponentListPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jComponentListPanelLayout.createSequentialGroup() - .addGap(34, 34, 34) - .addComponent(editComonentListButton)) - .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(43, 43, 43) + .addComponent(editComonentListButton) + .addContainerGap(101, Short.MAX_VALUE)) + .addComponent(jScrollPane2) ); org.openide.awt.Mnemonics.setLocalizedText(jLabel11, org.openide.util.NbBundle.getMessage(EditCostTermJPanel.class, "EditCostTermJPanel.jLabel11.text")); // NOI18N @@ -193,6 +192,11 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(EditCostTermJPanel.class, "EditCostTermJPanel.jLabel3.text")); // NOI18N jErrorCenterTextField.setText(org.openide.util.NbBundle.getMessage(EditCostTermJPanel.class, "EditCostTermJPanel.jErrorCenterTextField.text")); // NOI18N + jErrorCenterTextField.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + jErrorCenterTextFieldFocusLost(evt); + } + }); jErrorCenterTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jErrorCenterTextFieldActionPerformed(evt); @@ -204,42 +208,37 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() + .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jComponentListPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jEnabledCheckBox) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel11) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComponentTypeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jMaxErrorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(131, 131, 131) + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jErrorCenterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jComponentListPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jCostTermTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, Short.MAX_VALUE)))) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jEnabledCheckBox) + .addComponent(jCostTermTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel11) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jComponentTypeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jMaxErrorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(260, 260, 260) - .addComponent(jLabel3) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jErrorCenterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))))) - .addGap(0, 0, Short.MAX_VALUE))) - .addContainerGap()) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jLabel4) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jCostTermNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 460, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jCostTermNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 460, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -334,14 +333,19 @@ private void jCostTermNameTextFieldFocusLost(java.awt.event.FocusEvent evt) {//G private void jErrorCenterTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jErrorCenterTextFieldActionPerformed // TODO add your handling code here: + if(jErrorCenterTextField.getText().trim().length()>0) + try { + costTermModel.setErrorCenter(numFormat.parse(jErrorCenterTextField.getText().trim()).doubleValue()); + } catch (ParseException ex) { + Exceptions.printStackTrace(ex); + } }//GEN-LAST:event_jErrorCenterTextFieldActionPerformed private void jMaxErrorTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMaxErrorTextFieldActionPerformed // TODO add your handling code here: - AbstractProperty errorProp = costTerm2Edit.getPropertyByName("max_allowable_error"); if(jMaxErrorTextField.getText().trim().length()>0) try { - PropertyHelper.setValueDouble(numFormat.parse(jMaxErrorTextField.getText().trim()).doubleValue(), errorProp); + costTermModel.setMaxAllowableError(numFormat.parse(jMaxErrorTextField.getText().trim()).doubleValue()); } catch (ParseException ex) { Exceptions.printStackTrace(ex); } @@ -352,6 +356,11 @@ private void jMaxErrorTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-F jMaxErrorTextFieldActionPerformed(null); }//GEN-LAST:event_jMaxErrorTextFieldFocusLost + private void jErrorCenterTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jErrorCenterTextFieldFocusLost + // TODO add your handling code here: + jErrorCenterTextFieldActionPerformed(null); + }//GEN-LAST:event_jErrorCenterTextFieldFocusLost + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton editComonentListButton; diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/RCNLCostTermsInfo.java b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/RCNLCostTermsInfo.java index a951a1026..aa799d439 100644 --- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/RCNLCostTermsInfo.java +++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/RCNLCostTermsInfo.java @@ -31,8 +31,8 @@ public class RCNLCostTermsInfo { }; static String[][] designOptimizationCostTerms= { {"generalized_coordinate_tracking", "generalized_speed_tracking", "marker_position_tracking", - "inverse_dynamics_load_tracking", "inverse_dynamics_slope_tracking", "kinetic_inconsistency_minimization", - "joint_acceleration_minimization", "external_force_tracking", "external_moment_tracking", + "inverse_dynamics_load_tracking", "inverse_dynamics_slope_tracking", + "external_force_tracking", "external_moment_tracking", "muscle_activation_tracking", "controller_tracking", "controller_slope_minimization", "controller_frequency_minimization", "controller_shape_tracking", "joint_acceleration_minimization", "joint_power_minimization", "joint_energy_generation_goal", "joint_energy_absorption_goal", @@ -41,14 +41,15 @@ public class RCNLCostTermsInfo { "relative_metabolic_cost_per_time", "relative_metabolic_cost_per_distance", "propulsive_impulse_goal", "braking_impulse_goal"}, {"coordinate", "coordinate", "marker", - "load" , "load" , "load", - "coordinate", "force", "moment", + "load" , "load" , "force", "moment", "muscle", "controller", "controller", "controller", "controller", "coordinate", "coordinate", "coordinate", "coordinate", "muscle", "coordinate", "none", "none", "none", "none", "none", "none", "none", "none"}, - {"N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N", + {"N","N","N","N","N","N", + "N","N","N","N","N","N", + "N","N","N","N","N","N", "Y","Y","Y","Y","Y","Y","Y","Y" } }; diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.form b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.form index 0c616a2c9..30f4fa0c5 100644 --- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.form +++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.form @@ -181,7 +181,7 @@ - + @@ -699,7 +699,7 @@ - + diff --git a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.java b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.java index a6a1dfeda..449c77fbf 100644 --- a/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.java +++ b/Gui/opensim/rice_cnl/src/org/opensim/rcnl/TreatmentOptimizationJPanel.java @@ -760,20 +760,15 @@ private void editConstraintTermButtonActionPerformed(java.awt.event.ActionEvent int[] sels = jConstraintTermList.getSelectedIndices(); int idx = sels[0]; OpenSimObject currentTerm = (OpenSimObject)constraintTermListModel.get(idx); - OpenSimObject constraintTerm = currentTerm.clone(); - EditCosnstraintTermJPanel ejtPanel = new EditCosnstraintTermJPanel(constraintTerm, mode); + OpenSimObject termToEdit = currentTerm.clone(); + EditCosnstraintTermJPanel ejtPanel = new EditCosnstraintTermJPanel(termToEdit, mode); DialogDescriptor dlg = new DialogDescriptor(ejtPanel, "Create/Edit One Constraint Term "); Dialog d = DialogDisplayer.getDefault().createDialog(dlg); d.setVisible(true); Object userInput = dlg.getValue(); if (((Integer)userInput).compareTo((Integer)DialogDescriptor.OK_OPTION)==0){ - constraintTermListModel.addElement(constraintTerm); - AbstractProperty ap = treatmentOptimizationToolModel.getToolAsObject().getPropertyByName("RCNLConstraintTermSet"); - //System.out.println(ap.getTypeName()+" "+ap.isListProperty()+" "); - PropertyObjectList.updAs(ap).adoptAndAppendValue(constraintTerm); - PropertyObjectList poList = treatmentOptimizationToolModel.getConstraintTermListAsObjectList(); - constraintTermListModel = new ConstraintTermListModel(poList); - jConstraintTermList.setModel(constraintTermListModel); + constraintTermListModel.set(idx, termToEdit); + treatmentOptimizationToolModel.getConstraintTermListAsObjectList().setValue(idx, termToEdit); } }//GEN-LAST:event_editConstraintTermButtonActionPerformed @@ -856,17 +851,6 @@ private void addCostTermButtonActionPerformed(java.awt.event.ActionEvent evt) {/ private void jButtonEditCoordinateListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEditCoordinateListActionPerformed // TODO add your handling code here: - // Create Panel for selecting from existing model coordinates - // CoordinateTableModel ctm = new CoordinateTableModel(treatmentOptimizationToolModel.getPropCoordinateListString(), model); - // SelectQuantitiesFromListJPanel selectionPanel = new SelectQuantitiesFromListJPanel(ctm); - // DialogDescriptor dlg = new DialogDescriptor(selectionPanel,"Select Coordinates"); - // dlg.setModal(true); - // DialogDisplayer.getDefault().createDialog(dlg).setVisible(true); - // Object userInput = dlg.getValue(); - // if (((Integer)userInput).compareTo((Integer)DialogDescriptor.OK_OPTION)==0){ - // ctm.populateCoordinateListProperty(); - // jCoordinateListTextArea.setText(treatmentOptimizationToolModel.getPropCoordinateListString().toString()); - // } }//GEN-LAST:event_jButtonEditCoordinateListActionPerformed private void solverSettingsFilePathStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_solverSettingsFilePathStateChanged