Ejemplo n.º 1
0
 /** Called to alter data in all cells */
 public boolean operateOnData(CharacterData data) {
   if (!(data instanceof ContinuousData)) return false;
   ContinuousData cData = (ContinuousData) data;
   int numItems = cData.getNumItems();
   String[] items = new String[numItems];
   for (int i = 0; i < items.length; i++) {
     if (StringUtil.blank(cData.getItemName(i))) items[i] = "(unnamed)";
     else items[i] = cData.getItemName(i);
   }
   int d =
       ListDialog.queryList(
           containerOfModule(),
           "Rename item",
           "Rename item:",
           MesquiteString.helpString,
           items,
           0);
   if (!MesquiteInteger.isCombinable(d) || d < 0 || d >= numItems) return false;
   else {
     String s =
         MesquiteString.queryString(
             containerOfModule(), "Rename Item", "New name for " + items[d], items[d]);
     if (StringUtil.blank(s)) return false;
     cData.setItemReference(d, NameReference.getNameReference(s));
     return true;
   }
 }
 /*.................................................................................................................*/
 public void fromString(String description, MesquiteInteger stringPos, int format) {
   hasDefaultValues = false;
   ParseUtil.getToken(description, stringPos); // RMatrix
   ParseUtil.getToken(description, stringPos); // =
   ParseUtil.getToken(description, stringPos); // (
   for (int i = 0; i < getNumStates(); i++) {
     String s = ParseUtil.getToken(description, stringPos);
     if (s.equalsIgnoreCase(")") || StringUtil.blank(s)) return;
     setStateFreq(i, MesquiteDouble.fromString(s));
   }
   checkNormality(getStateFrequencies());
 }